22 #include <boost/function.hpp>
37 #include "hurricane/Timer.h"
38 #include "hurricane/Commons.h"
39 #include "hurricane/Warning.h"
40 #include "hurricane/Point.h"
41 #include "hurricane/Box.h"
42 #include "hurricane/Transformation.h"
43 #include "hurricane/Query.h"
44 #include "hurricane/viewer/DisplayStyle.h"
45 #include "hurricane/viewer/CellWidgets.h"
46 #include "hurricane/viewer/Selector.h"
47 #include "hurricane/viewer/SelectorCriterion.h"
48 #include "hurricane/viewer/Ruler.h"
54 using std::unary_function;
55 using std::shared_ptr;
72 enum UpdateState { ExternalEmit = 0
89 typedef void ( DrawExtensionGo_t )(
CellWidget*
95 typedef void ( InitExtensionGo_t )(
CellWidget* );
96 typedef boost::function< void(QPainter&) > PainterCb_t;
97 enum RubberShape { Centric=1, Barycentric, Steiner };
98 enum TextFlag { Bold =0x0001
108 enum Flag { NoFlags =0x0000
109 , NoResetCommands=0x0001
119 void setCell (
Cell*,
Path topPath=
Path(),
unsigned int flags=NoFlags );
120 inline Cell* getCell ()
const;
121 inline Cell* getTopCell ()
const;
122 inline Path getTopPath ()
const;
123 inline shared_ptr<State>& getState ();
124 inline shared_ptr<State> getStateClone ();
125 inline PaletteWidget* getPalette ();
126 inline Occurrences getOccurrencesUnder (
const QRect& )
const;
128 inline SelectorSet& getSelectorSet ();
129 inline RulerSet& getRulerSet ();
130 inline RubberShape getRubberShape ()
const;
131 inline int getStartLevel ()
const;
132 inline int getStopLevel ()
const;
133 inline Query::Mask getQueryFilter ()
const ;
134 void bindToPalette ( PaletteWidget* );
135 void detachFromPalette ();
136 void detach ( Selector*);
137 void bindCommand ( Command* );
138 void unbindCommand ( Command* );
139 void resetCommands ();
140 inline void setActiveCommand ( Command* );
141 inline Command* getActiveCommand ()
const;
142 Command* getCommand (
const std::string& )
const;
143 inline void resetActiveCommand ();
145 inline void setRealSnapGridStep (
DbU::Unit step );
146 inline unsigned int getDbuMode ()
const;
147 inline bool gridMode ()
const;
148 inline bool symbolicMode ()
const;
149 inline bool physicalMode ()
const;
151 inline bool showBoundaries ()
const;
152 inline bool showSelection ()
const;
153 inline bool cumulativeSelection ()
const;
154 inline void setPixelThreshold (
int );
155 inline void setDbuMode (
int );
157 inline void setRubberShape ( RubberShape );
158 inline void setStartLevel (
int );
159 inline void setStopLevel (
int );
160 inline void setQueryFilter ( Query::Mask );
161 inline bool timeout (
const char*,
const Timer&,
double timeout,
bool& timedout )
const;
163 inline void setEnableRedrawInterrupt (
bool );
164 inline void addDrawExtensionGo (
const Name&, InitExtensionGo_t*, DrawExtensionGo_t* );
165 inline void copyDrawExtensionGos (
const CellWidget* );
166 inline QPainter& getPainter (
size_t plane=PlaneId::Working );
167 inline const DisplayStyle::HSVr& getDarkening ()
const;
168 inline void copyToPrinter (
int xpaper,
int ypaper, QPrinter*, PainterCb_t& );
169 inline void copyToImage ( QImage*, PainterCb_t& );
170 inline int getPixelThreshold ()
const;
171 inline const float& getScale ()
const;
172 inline const QPoint& getMousePosition ()
const;
173 inline void updateMousePosition ();
174 void setLayerVisible (
const Name& layer,
bool visible );
175 bool isLayerVisible (
const Name& );
176 bool isDrawable (
const Name& );
177 bool isDrawableLayer (
const Name& );
178 bool isDrawableExtension (
const Name& );
179 bool isSelectable (
const Name& )
const;
180 bool isSelectable (
const Layer* )
const;
181 bool isPrinter ()
const;
182 void setPrinter (
bool );
183 inline void setDarkening (
const DisplayStyle::HSVr& );
184 inline void setPen (
const QPen& ,
size_t plane=PlaneId::Working );
186 void drawBox (
const Box& );
187 void drawBoxBorder (
const Box& );
189 void drawLine (
const Point&,
const Point&,
bool mode=
true );
190 void drawText (
const Point&,
const char*,
unsigned int flags=0,
int angle=0 );
191 void drawGrid ( QRect );
193 void drawRuler ( shared_ptr<Ruler> );
194 void drawRulers ( QRect );
195 void drawDisplayText (
const QRect& ,
const char*,
unsigned int flags=0 );
196 void drawDisplayText (
const QPoint&,
const char*,
unsigned int flags=0,
int angle=0 );
197 void drawScreenPolygon (
const QPoint*,
int count,
size_t plane=PlaneId::Working );
198 void drawScreenPolygon (
const QPolygon&,
size_t plane=PlaneId::Working );
199 void drawScreenLine (
const QPoint&,
const QPoint&,
size_t plane=PlaneId::Working,
bool mode=
true );
200 void drawScreenRect (
const QPoint&,
const QPoint&,
size_t plane=PlaneId::Working );
201 void drawScreenRect (
const QRect& ,
size_t plane=PlaneId::Working );
202 void drawScreenPolyline (
const QPoint*,
int,
int,
size_t plane=PlaneId::Working );
206 QRect dbuToScreenRect (
const Box& box ,
bool usePoint=
true )
const;
207 inline int dbuToScreenX (
DbU::Unit x )
const;
208 inline int dbuToScreenY (
DbU::Unit y )
const;
209 inline int dbuToScreenLength (
DbU::Unit length )
const;
211 inline QPoint dbuToScreenPoint (
const Point& point )
const;
212 inline DbU::Unit screenToDbuLength (
int length )
const;
213 inline DbU::Unit screenToDbuX (
int x )
const;
214 inline DbU::Unit screenToDbuY (
int y )
const;
215 inline Point screenToDbuPoint (
const QPoint& point )
const;
216 inline Box screenToDbuBox (
const QRect& rect )
const;
217 inline Box& pixelInflate (
Box&,
int pixels )
const;
218 inline Point getTopLeft ()
const;
219 inline Box getVisibleArea ()
const;
220 Box computeVisibleArea (
float scale )
const;
221 Box computeVisibleArea (
float scale,
const Point& topLeft )
const;
222 Box computeVisibleArea (
const Box&,
float& scale )
const;
224 inline bool _underDetailedGridThreshold()
const;
227 inline Point _onSnapGrid (
const Point& )
const;
229 inline Point _onCursorGrid (
const Point& )
const;
231 void pushCursor ( Qt::CursorShape cursor );
233 virtual QSize minimumSizeHint ()
const;
234 virtual void showEvent ( QShowEvent* );
235 virtual void resizeEvent ( QResizeEvent* );
236 virtual void wheelEvent ( QWheelEvent* );
237 virtual void keyPressEvent ( QKeyEvent* );
238 virtual void keyReleaseEvent ( QKeyEvent* );
239 virtual void mouseMoveEvent ( QMouseEvent* );
240 virtual void mousePressEvent ( QMouseEvent* );
241 virtual void mouseReleaseEvent ( QMouseEvent* );
243 void cellChanged (
Cell* );
244 void cellPreModificated ();
245 void cellPostModificated ();
246 void stateChanged ( shared_ptr<CellWidget::State>& );
247 void styleChanged ();
248 void queryFilterChanged ();
250 void updatePalette (
Cell* );
251 void mousePositionChanged (
const Point& position );
252 void selectionModeChanged ();
253 void selectionChanged (
const SelectorSet& );
254 void selectionToggled ( Selector* );
255 void unlinkSelector ( Selector* );
256 void showBoundariesToggled (
bool );
258 virtual void paintEvent ( QPaintEvent* );
261 void setState ( shared_ptr<CellWidget::State>&
262 ,
unsigned int flags=NoFlags );
263 inline void openRefreshSession ();
264 inline void closeRefreshSession ();
265 inline DrawingPlanes& getDrawingPlanes ();
269 void selectOccurrencesUnder (
Box selectArea );
274 void setShowSelection (
bool state );
275 void setCumulativeSelection (
bool state );
279 void _unselectAll ();
280 inline void addRuler (
const Point&,
const Point& );
281 inline void addRuler ( shared_ptr<Ruler> );
282 inline void clearRulers ();
283 void changeQueryFilter ();
284 void rubberChange ();
286 void setStyle (
int id );
287 void updatePalette ();
288 void cellPreModificate ();
289 void cellPostModificate ();
290 inline void refresh ();
291 void _redraw ( QRect redrawArea );
292 inline void redrawSelection ();
293 void redrawSelection ( QRect redrawArea );
294 void goLeft (
int dx = 0 );
295 void goRight (
int dx = 0 );
296 void goUp (
int dy = 0 );
297 void goDown (
int dy = 0 );
298 void fitToContents (
bool historyEnable=
true );
299 void fitToNet (
const Net*,
bool historyEnable=
true );
300 void setScale (
float );
301 void scaleHistoryUp ();
302 void scaleHistoryDown ();
306 void setShowBoundaries (
bool state );
308 void reframe (
const Box& box,
bool historyEnable=
true );
309 void displayReframe ();
310 void _goLeft (
int dx );
311 void _goRight (
int dx );
312 void _goUp (
int dy );
313 void _goDown (
int dy );
315 std::string _getString ()
const;
321 void setRestore (
bool );
322 inline void setShowSpot (
bool );
323 inline const QPoint& getSpotPoint ()
const;
325 QPoint computeSpotPoint (
const QPoint& );
326 void moveTo (
const QPoint& );
337 enum EventType { GoLeft = 1
344 RedrawEvent ( EventType,
int shift, CellWidget* );
345 inline EventType getType ()
const;
346 inline int getShift ()
const;
353 class RedrawManager {
355 inline RedrawManager ( CellWidget* );
358 void goRight (
int );
363 inline void stopProcessing ();
364 inline bool isProcessing ()
const;
365 inline bool interrupted ()
const;
366 inline size_t getPendings ()
const;
367 inline void openRefreshSession ();
368 inline void closeRefreshSession ();
371 list<RedrawEvent*> _events;
380 enum Ids { Normal = 0
391 class DrawingPlanes {
393 DrawingPlanes (
const QSize& size, CellWidget* cw );
395 inline bool getLineMode ()
const;
396 inline size_t getWorkingPlane ()
const;
397 inline void pushWorkingPlane ();
398 inline void popWorkingPlane ();
399 inline int width ()
const;
400 inline int height ()
const;
401 inline QSize size ()
const;
402 inline void select (
size_t i );
403 inline QPainter& painter (
size_t i=PlaneId::Working );
404 inline void begin (
size_t i=PlaneId::Working );
405 inline void end (
size_t i=PlaneId::Working );
406 inline void buffersBegin ();
407 inline void buffersEnd ();
408 void setLineMode (
bool mode );
409 void setPen (
const QPen& pen );
410 void setBrush (
const QBrush& brush );
411 void setBackground (
const QBrush& brush );
412 void setBackgroundMode ( Qt::BGMode mode );
413 void resize (
const QSize& size );
414 void shiftLeft (
int dx );
415 void shiftRight (
int dx );
416 void shiftUp (
int dy );
417 void shiftDown (
int dy );
418 inline void copyToSelect ();
419 inline void copyToSelect (
const QRect& );
420 void copyToSelect (
int sx,
int sy,
int h,
int w );
421 inline void copyToScreen ();
422 void copyToScreen (
int sx,
int sy,
int h,
int w );
423 inline void copyToPrinter (
int xpaper,
int ypaper, QPrinter*, CellWidget::PainterCb_t& );
424 void copyToPrinter (
int xpaper,
int ypaper,
int sx,
int sy,
int h,
int w, QPrinter*, CellWidget::PainterCb_t& );
425 inline void copyToImage ( QImage*, CellWidget::PainterCb_t& );
426 void copyToImage (
int sx,
int sy,
int h,
int w, QImage*, CellWidget::PainterCb_t& );
428 static const int _cartoucheWidth;
429 static const int _cartoucheHeight;
430 static const int _titleHeight;
431 CellWidget* _cellWidget;
435 QPainter _painters[PlaneId::Working];
439 size_t _workingPlane;
440 size_t _pushWorkingPlane;
443 DrawingPlanes (
const DrawingPlanes& );
444 DrawingPlanes& operator= (
const DrawingPlanes& );
448 class DrawingQuery :
public Query {
450 DrawingQuery ( CellWidget* widget );
451 inline void setQuery (
const Box& area
452 ,
const Transformation& transformation
453 ,
const BasicLayer* basicLayer
454 , ExtensionSlice::Mask extensionMask
455 ,
unsigned int filter
457 inline void addDrawExtensionGo (
const Name&
461 inline void copyDrawExtensionGos (
const DrawingQuery& );
462 void setDrawExtensionGo (
const Name& );
463 virtual bool hasMasterCellCallback ()
const;
464 virtual bool hasGoCallback ()
const;
465 virtual bool hasMarkerCallback ()
const;
466 virtual bool hasRubberCallback ()
const;
467 virtual bool hasExtensionGoCallback ()
const;
468 virtual void masterCellCallback ();
469 virtual void goCallback ( Go* );
470 virtual void rubberCallback ( Rubber* );
471 virtual void markerCallback ( Marker* );
472 virtual void extensionGoCallback ( Go* );
473 void drawMasterCell (
const Cell* cell
474 ,
const Transformation& transformation
476 void drawGo (
const Go* go
477 ,
const BasicLayer* basicLayer
479 ,
const Transformation& transformation
481 void drawRubber (
const Rubber* rubber
483 ,
const Transformation& transformation
485 void drawMarker (
const Marker* marker
487 ,
const Transformation& transformation
489 void drawExtensionGo ( CellWidget* widget
491 ,
const BasicLayer* basicLayer
493 ,
const Transformation& transformation
495 inline unsigned int getGoCount ()
const;
496 inline unsigned int getExtensionGoCount ()
const;
497 inline unsigned int getInstanceCount ()
const;
498 inline void resetGoCount ();
499 inline void resetExtensionGoCount ();
500 inline void resetInstanceCount ();
503 CellWidget* _cellWidget;
504 DrawExtensionGo_t* _drawExtensionGo;
505 map<Name,pair<InitExtensionGo_t*,DrawExtensionGo_t*> >
507 unsigned int _goCount;
508 unsigned int _extensionGoCount;
509 unsigned int _instanceCount;
513 class TextDrawingQuery :
public Query {
515 TextDrawingQuery ( CellWidget* widget );
516 inline void setQuery (
const Box& area
517 ,
const Transformation& transformation
519 virtual bool hasMasterCellCallback ()
const;
520 virtual bool hasGoCallback ()
const;
521 virtual bool hasRubberCallback ()
const;
522 virtual bool hasExtensionGoCallback ()
const;
523 virtual void masterCellCallback ();
524 virtual void goCallback ( Go* go );
525 virtual void extensionGoCallback ( Go* go );
526 virtual void rubberCallback ( Rubber* );
529 CellWidget* _cellWidget;
533 class SelectorCriterions {
535 SelectorCriterions ();
536 ~SelectorCriterions ();
537 inline void setCellWidget ( CellWidget* );
538 inline const vector<SelectorCriterion*>& getCriterions ()
const;
539 SelectorCriterion* add ( Occurrence netOccurrence );
540 SelectorCriterion* add ( Box area );
541 inline SelectorCriterion* add ( SelectorCriterion* );
542 bool remove ( Occurrence netOccurrence );
546 inline size_t size ()
const;
548 CellWidget* _cellWidget;
549 vector<SelectorCriterion*> _criterions;
555 inline State ( Cell* cell=NULL, Path topPath=Path() );
556 State* clone ()
const;
557 inline void setCell ( Cell* );
558 inline void setTopPath ( Path );
559 inline void setCellWidget ( CellWidget* );
563 inline void setDbuMode (
int );
565 inline void setShowBoundaries (
bool );
566 inline void setShowSelection (
bool );
567 inline void setCumulativeSelection (
bool );
568 void setScale (
float );
570 inline void setTopLeft (
const Point& );
571 inline void setQueryFilter ( Query::Mask );
572 inline void setStartLevel (
int );
573 inline void setStopLevel (
int );
574 inline void setRubberShape ( RubberShape );
575 inline void setHistoryEnable (
bool );
576 bool scaleHistoryUp ();
577 bool scaleHistoryDown ();
578 inline Cell* getCell ()
const;
579 inline Cell* getTopCell ()
const;
580 inline Path getTopPath ()
const;
581 const Name& getName ()
const;
582 inline SelectorCriterions& getSelection ();
583 inline RulerSet& getRulers ();
585 inline unsigned int getDbuMode ()
const;
586 inline bool gridMode ()
const;
587 inline bool symbolicMode ()
const;
588 inline bool physicalMode ()
const;
589 inline bool nanoMode ()
const;
590 inline bool microMode ()
const;
591 inline bool showBoundaries ()
const;
592 inline bool showSelection ()
const;
593 inline bool cumulativeSelection ()
const;
594 inline bool getHistoryEnable ()
const;
595 inline size_t getHistorySize ()
const;
596 inline const float& getScale ()
const;
597 inline const Point& getTopLeft ()
const;
598 inline Query::Mask getQueryFilter ()
const;
599 inline int getStartLevel ()
const;
600 inline int getStopLevel ()
const;
601 inline RubberShape getRubberShape ()
const;
606 inline ScaleEntry (
float,
const Point& );
615 Name _hierarchicalName;
616 CellWidget* _cellWidget;
617 SelectorCriterions _selection;
620 unsigned int _dbuMode;
622 bool _showBoundaries;
624 Query::Mask _queryFilter;
627 RubberShape _rubberShape;
628 bool _cumulativeSelection;
629 vector<ScaleEntry> _scaleHistory;
634 class FindStateName :
public unary_function< const shared_ptr<State>&, bool > {
636 inline FindStateName (
const Name& );
637 inline bool operator() (
const shared_ptr<State>& );
639 const Name _cellHierName;
644 vector<Qt::CursorShape> _cursors;
646 Technology* _technology;
647 PaletteWidget* _palette;
649 RedrawManager _redrawManager;
650 DrawingPlanes _drawingPlanes;
651 DrawingQuery _drawingQuery;
652 TextDrawingQuery _textDrawingQuery;
653 DisplayStyle::HSVr _darkening;
654 QPoint _mousePosition;
656 shared_ptr<State> _state;
659 bool _selectionHasChanged;
660 int _delaySelectionChanged;
661 bool _cellModificated;
662 bool _enableRedrawInterrupt;
663 SelectorSet _selectors;
664 Command* _activeCommand;
665 vector<Command*> _commands;
666 size_t _redrawRectCount;
670 friend class RedrawManager;
674 inline void CellWidget::Spot::setShowSpot (
bool show )
675 { _showSpot = show; }
678 inline const QPoint& CellWidget::Spot::getSpotPoint ()
const
679 {
return _spotPoint; }
682 inline void CellWidget::DrawingQuery::setQuery (
const Box& area
683 ,
const Transformation& transformation
684 ,
const BasicLayer* basicLayer
685 , ExtensionSlice::Mask extensionMask
686 ,
unsigned int filter
699 inline void CellWidget::setEnableRedrawInterrupt (
bool state )
700 { _enableRedrawInterrupt = state; }
703 inline void CellWidget::openRefreshSession ()
704 { _redrawManager.openRefreshSession (); }
707 inline void CellWidget::closeRefreshSession ()
708 { _redrawManager.closeRefreshSession (); }
711 inline void CellWidget::DrawingQuery::addDrawExtensionGo (
const Name& name
712 , InitExtensionGo_t* initExtensionGo
713 , DrawExtensionGo_t* drawExtensionGo
715 { _drawExtensionGos[name] = make_pair(initExtensionGo,drawExtensionGo); }
718 inline void CellWidget::DrawingQuery::copyDrawExtensionGos (
const CellWidget::DrawingQuery& other )
719 { _drawExtensionGos = other._drawExtensionGos; }
722 inline void CellWidget::DrawingQuery::resetGoCount ()
726 inline void CellWidget::DrawingQuery::resetExtensionGoCount ()
727 { _extensionGoCount = 0; }
730 inline void CellWidget::DrawingQuery::resetInstanceCount ()
731 { _instanceCount = 0; }
734 inline unsigned int CellWidget::DrawingQuery::getGoCount ()
const
738 inline unsigned int CellWidget::DrawingQuery::getExtensionGoCount ()
const
739 {
return _extensionGoCount; }
742 inline unsigned int CellWidget::DrawingQuery::getInstanceCount ()
const
743 {
return _instanceCount; }
746 inline CellWidget::RedrawEvent::EventType CellWidget::RedrawEvent::getType ()
const
750 inline int CellWidget::RedrawEvent::getShift ()
const
754 inline bool CellWidget::RedrawManager::isProcessing ()
const
755 {
return _processing; }
758 inline void CellWidget::RedrawManager::stopProcessing ()
759 { _processing =
false; }
762 inline size_t CellWidget::RedrawManager::getPendings ()
const
763 {
return _events.size(); }
766 inline void CellWidget::RedrawManager::openRefreshSession ()
767 { _refreshSession++; }
770 inline void CellWidget::RedrawManager::closeRefreshSession ()
773 if ( !_processing && (_refreshSession == 0) ) process ();
777 inline bool CellWidget::RedrawManager::interrupted ()
const
779 #ifdef ALLOW_REQUEST_INTERRUPT
780 return ( _events.size() > 5 ) || _interrupted;
787 inline bool CellWidget::DrawingPlanes::getLineMode ()
const
788 {
return _lineMode; }
791 inline size_t CellWidget::DrawingPlanes::getWorkingPlane ()
const
792 {
return _workingPlane; }
795 inline void CellWidget::DrawingPlanes::pushWorkingPlane ()
796 { _pushWorkingPlane = _workingPlane; }
799 inline void CellWidget::DrawingPlanes::popWorkingPlane ()
800 { _workingPlane = _pushWorkingPlane; }
803 inline int CellWidget::DrawingPlanes::width ()
const
804 {
return _planes[PlaneId::Normal]->width(); }
807 inline int CellWidget::DrawingPlanes::height ()
const
808 {
return _planes[PlaneId::Normal]->height(); }
811 inline QSize CellWidget::DrawingPlanes::size ()
const
812 {
return _planes[PlaneId::Normal]->size(); }
815 inline void CellWidget::DrawingPlanes::select (
size_t i )
816 { _workingPlane = i; }
819 inline QPainter& CellWidget::DrawingPlanes::painter (
size_t i )
820 {
return _painters[ (i>=PlaneId::Working) ? _workingPlane : i ]; }
823 inline void CellWidget::DrawingPlanes::begin (
size_t i )
825 size_t wp = (i>=PlaneId::Working) ? _workingPlane : i;
827 case PlaneId::Normal:
828 case PlaneId::Selection:
829 case PlaneId::AutoCopy: _painters[wp ].begin( _planes[wp] );
break;
830 case PlaneId::Widget: _painters[PlaneId::Widget ].begin( _cellWidget );
break;
831 case PlaneId::Printer: _painters[PlaneId::Printer].begin( _printer );
break;
832 case PlaneId::Image: _painters[PlaneId::Image ].begin( _image );
break;
834 std::cerr <<
"[BUG] Bad plane selection." << std::endl;
839 inline void CellWidget::DrawingPlanes::end (
size_t i )
840 { _painters[(i>=PlaneId::Working)?_workingPlane:i].end (); }
843 inline void CellWidget::DrawingPlanes::buffersBegin ()
845 begin( PlaneId::Normal );
846 begin( PlaneId::Selection );
847 begin( PlaneId::AutoCopy );
851 inline void CellWidget::DrawingPlanes::buffersEnd ()
853 end( PlaneId::Normal );
854 end( PlaneId::Selection );
855 end( PlaneId::AutoCopy );
859 inline void CellWidget::DrawingPlanes::copyToSelect ()
860 { copyToSelect ( 0, 0, width(), height() ); }
863 inline void CellWidget::DrawingPlanes::copyToSelect (
const QRect& r )
864 { copyToSelect ( r.x(), r.y(), r.width(), r.height() ); }
867 inline void CellWidget::DrawingPlanes::copyToScreen ()
868 { copyToScreen ( 0, 0, width(), height() ); }
871 inline void CellWidget::DrawingPlanes::copyToPrinter (
int xpaper,
int ypaper, QPrinter* printer, CellWidget::PainterCb_t& cb )
873 copyToPrinter ( xpaper
877 , _cellWidget->geometry().width()
878 , _cellWidget->geometry().height()
885 inline void CellWidget::DrawingPlanes::copyToImage ( QImage* image, CellWidget::PainterCb_t& cb )
889 , _cellWidget->geometry().width()
890 , _cellWidget->geometry().height()
897 inline void CellWidget::SelectorCriterions::setCellWidget ( CellWidget* cw )
898 { _cellWidget = cw; }
901 inline size_t CellWidget::SelectorCriterions::size ()
const
902 {
return _criterions.size(); }
905 inline const vector<SelectorCriterion*>& CellWidget::SelectorCriterions::getCriterions ()
const
906 {
return _criterions; }
909 inline SelectorCriterion* CellWidget::SelectorCriterions::add ( SelectorCriterion* criterion )
911 _criterions.push_back( criterion );
912 return _criterions.back();
916 inline CellWidget::State::ScaleEntry::ScaleEntry (
float scale,
const Point& topLeft )
917 : _scale(scale), _topLeft(topLeft)
921 inline CellWidget::State::State ( Cell* cell, Path topPath )
924 , _hierarchicalName ()
928 , _cursorStep (DbU::lambda(0.5))
929 , _dbuMode (DbU::Symbolic)
930 , _unitPower (DbU::Nano)
931 , _showBoundaries (true)
932 , _showSelection (false)
933 , _queryFilter (~Query::DoTerminalCells)
936 , _rubberShape (CellWidget::Barycentric)
937 , _cumulativeSelection(false)
940 , _historyEnable (false)
942 _scaleHistory.push_back ( ScaleEntry(1.0,Point(0,0)) );
943 if (_cell) _hierarchicalName = Name( _cell->getHierarchicalName() );
947 inline unsigned int CellWidget::State::getDbuMode ()
const
951 inline bool CellWidget::State::symbolicMode ()
const
955 inline bool CellWidget::State::gridMode ()
const
959 inline bool CellWidget::State::physicalMode ()
const
960 {
return (_dbuMode == DbU::Physical); }
963 inline void CellWidget::State::setCell ( Cell* cell )
966 if (_cell) _hierarchicalName = Name( _cell->getHierarchicalName() );
970 inline void CellWidget::State::setTopPath ( Path topPath )
971 { _topPath = topPath; }
974 inline void CellWidget::State::setCellWidget ( CellWidget* cw )
977 _selection.setCellWidget ( cw );
981 inline void CellWidget::State::setCursorStep (
DbU::Unit step )
982 { _cursorStep = step; }
984 inline DbU::Unit CellWidget::State::getCursorStep ()
const
985 {
return _cursorStep; }
989 {
return _unitPower; }
992 inline void CellWidget::State::setDbuMode (
int mode )
995 switch ( _dbuMode ) {
998 case DbU::Physical: _cursorStep =
DbU::fromGrid (1.0);
break;
1007 inline void CellWidget::State::setShowBoundaries (
bool state )
1008 { _showBoundaries = state; }
1011 inline void CellWidget::State::setShowSelection (
bool state )
1012 { _showSelection = state; }
1015 inline void CellWidget::State::setCumulativeSelection (
bool state )
1016 { _cumulativeSelection = state; }
1021 _scaleHistory[_ihistory]._topLeft.setX(x);
1022 _scaleHistory[_ihistory]._topLeft.setY(y);
1026 inline void CellWidget::State::setTopLeft (
const Point& topLeft )
1027 { _scaleHistory[_ihistory]._topLeft = topLeft; }
1030 inline void CellWidget::State::setQueryFilter ( Query::Mask mask )
1031 { _queryFilter = mask; }
1034 inline void CellWidget::State::setStartLevel (
int level )
1035 { _startLevel = level; }
1038 inline void CellWidget::State::setStopLevel (
int level )
1039 { _stopLevel = level; }
1042 inline void CellWidget::State::setRubberShape ( RubberShape shape )
1043 { _rubberShape = shape; }
1046 inline void CellWidget::State::setHistoryEnable (
bool enable )
1047 { _historyEnable = enable; }
1050 inline Cell* CellWidget::State::getCell ()
const
1054 inline Path CellWidget::State::getTopPath ()
const
1055 {
return _topPath; }
1058 inline Cell* CellWidget::State::getTopCell ()
const
1059 {
return (_topPath.isEmpty()) ? _cell : _topPath.getOwnerCell(); }
1062 inline DbU::Unit CellWidget::State::cursorStep ()
const
1063 {
return _cursorStep; }
1066 inline CellWidget::SelectorCriterions& CellWidget::State::getSelection ()
1067 {
return _selection; }
1070 inline RulerSet& CellWidget::State::getRulers ()
1074 inline bool CellWidget::State::showBoundaries ()
const
1075 {
return _showBoundaries; }
1078 inline bool CellWidget::State::showSelection ()
const
1079 {
return _showSelection; }
1082 inline bool CellWidget::State::cumulativeSelection ()
const
1083 {
return _cumulativeSelection; }
1086 inline bool CellWidget::State::getHistoryEnable ()
const
1087 {
return _historyEnable; }
1090 inline size_t CellWidget::State::getHistorySize ()
const
1091 {
return _scaleHistory.size(); }
1094 inline const Point& CellWidget::State::getTopLeft ()
const
1095 {
return _scaleHistory[_ihistory]._topLeft; }
1098 inline Query::Mask CellWidget::State::getQueryFilter ()
const
1099 {
return _queryFilter; }
1102 inline int CellWidget::State::getStartLevel ()
const
1103 {
return _startLevel; }
1106 inline int CellWidget::State::getStopLevel ()
const
1107 {
return _stopLevel; }
1110 inline CellWidget::RubberShape CellWidget::State::getRubberShape ()
const
1111 {
return _rubberShape; }
1114 inline const float& CellWidget::State::getScale ()
const
1115 {
return _scaleHistory[_ihistory]._scale; }
1118 inline void CellWidget::setPixelThreshold (
int pixelThreshold )
1119 { _pixelThreshold = pixelThreshold; }
1122 inline int CellWidget::getPixelThreshold ()
const
1123 {
return _pixelThreshold; }
1126 inline CellWidget::FindStateName::FindStateName (
const Name& cellHierName )
1127 : unary_function< const shared_ptr<State>&, bool >()
1128 , _cellHierName(cellHierName)
1132 inline bool CellWidget::FindStateName::operator () (
const shared_ptr<State>& state )
1133 {
return state->getName() == _cellHierName; }
1136 inline void CellWidget::setActiveCommand ( Command* command )
1137 { _activeCommand = command; }
1140 inline Command* CellWidget::getActiveCommand ()
const
1141 {
return _activeCommand; }
1144 inline void CellWidget::resetActiveCommand ()
1145 { _activeCommand = NULL; }
1148 inline void CellWidget::setCursorStep (
DbU::Unit step )
1149 { _state->setCursorStep(step); }
1152 inline void CellWidget::setRealSnapGridStep (
DbU::Unit step )
1156 inline shared_ptr<CellWidget::State>& CellWidget::getState ()
1158 _state->setTopLeft ( getTopLeft() );
1163 inline shared_ptr<CellWidget::State> CellWidget::getStateClone ()
1165 _state->setTopLeft ( getTopLeft() );
1166 return shared_ptr<State>( _state->clone() );
1170 inline void CellWidget::addDrawExtensionGo (
const Name& name
1171 , InitExtensionGo_t* initExtensionGo
1172 , DrawExtensionGo_t* drawExtensionGo
1174 { _drawingQuery.addDrawExtensionGo( name, initExtensionGo, drawExtensionGo ); }
1177 inline void CellWidget::copyDrawExtensionGos (
const CellWidget* other )
1178 { _drawingQuery.copyDrawExtensionGos( other->_drawingQuery ); }
1181 inline void CellWidget::setStartLevel (
int level )
1183 _drawingQuery.setStartLevel ( level );
1184 _state->setStartLevel ( level );
1185 emit queryFilterChanged ();
1189 inline void CellWidget::setStopLevel (
int level )
1191 _drawingQuery.setStopLevel ( level );
1192 _state->setStopLevel ( level );
1193 emit queryFilterChanged ();
1197 inline int CellWidget::getStartLevel ()
const
1198 {
return _drawingQuery.getStartLevel (); }
1201 inline int CellWidget::getStopLevel ()
const
1202 {
return _drawingQuery.getStopLevel (); }
1205 inline CellWidget::DrawingPlanes& CellWidget::getDrawingPlanes ()
1206 {
return _drawingPlanes; }
1209 inline SelectorSet& CellWidget::getSelectorSet ()
1210 {
return _selectors; }
1213 Occurrences CellWidget::getOccurrencesUnder (
const QRect& area )
const
1214 {
return getOccurrencesUnder(screenToDbuBox(area)); }
1217 inline void CellWidget::addRuler (
const Point& origin,
const Point& extremity )
1219 _state->getRulers().insert ( shared_ptr<Ruler>(
new Ruler(origin,extremity) ) );
1224 inline void CellWidget::addRuler ( shared_ptr<Ruler> ruler )
1226 _state->getRulers().insert ( ruler );
1231 inline void CellWidget::clearRulers ()
1232 { _state->getRulers().clear (); refresh(); }
1235 inline void CellWidget::refresh ()
1236 { _redrawManager.refresh(); }
1239 inline void CellWidget::redrawSelection ()
1240 { redrawSelection ( QRect(QPoint(0,0),_drawingPlanes.size()) ); }
1243 inline void CellWidget::copyToPrinter (
int xpaper,
int ypaper, QPrinter* printer, CellWidget::PainterCb_t& cb )
1244 { _drawingPlanes.copyToPrinter( xpaper, ypaper, printer, cb ); }
1247 inline void CellWidget::copyToImage ( QImage* image, PainterCb_t& cb )
1248 { _drawingPlanes.copyToImage ( image, cb ); }
1251 inline DbU::Unit CellWidget::toDbu (
float d )
const
1254 switch ( getDbuMode() ) {
1265 inline int CellWidget::dbuToScreenX (
DbU::Unit x )
const
1266 {
return (
int)rint ( (
float)( x - _screenArea.
getXMin() ) * getScale() ); }
1269 inline int CellWidget::dbuToScreenY (
DbU::Unit y )
const
1270 {
return (
int)rint ( (
float)( _screenArea.
getYMax() - y ) * getScale() ); }
1273 inline int CellWidget::dbuToScreenLength (
DbU::Unit length )
const
1274 {
return (
int)rint ( (
float)length * getScale() ); }
1278 {
return QPoint ( dbuToScreenX(x), dbuToScreenY(y) ); }
1281 inline QPoint CellWidget::dbuToScreenPoint (
const Point& point )
const
1282 {
return QPoint ( dbuToScreenX(point.getX()), dbuToScreenY(point.getY()) ); }
1285 inline DbU::Unit CellWidget::screenToDbuX (
int x )
const
1289 inline DbU::Unit CellWidget::screenToDbuY (
int y )
const
1293 inline DbU::Unit CellWidget::screenToDbuLength (
int length )
const
1294 {
return (
int)( (float)length / getScale() ); }
1297 inline Point CellWidget::screenToDbuPoint (
const QPoint& point )
const
1298 {
return Point ( screenToDbuX(point.x()), screenToDbuY(point.y()) ); }
1301 inline Box CellWidget::screenToDbuBox (
const QRect& rect )
const
1303 return Box ( screenToDbuX(rect.x())
1304 , screenToDbuY(rect.y())
1305 , screenToDbuX(rect.x()+rect.width ())
1306 , screenToDbuY(rect.y()+rect.height())
1311 inline Box& CellWidget::pixelInflate ( Box& box,
int pixels )
const
1312 {
return box.inflate(screenToDbuLength(pixels)); }
1315 inline Point CellWidget::getTopLeft ()
const
1319 inline Box CellWidget::getVisibleArea ()
const
1320 {
return computeVisibleArea(getScale()); }
1323 inline Cell* CellWidget::getCell ()
const
1324 {
return _state->getCell(); }
1327 inline Cell* CellWidget::getTopCell ()
const
1328 {
return _state->getTopCell(); }
1331 inline Path CellWidget::getTopPath ()
const
1332 {
return _state->getTopPath(); }
1335 inline PaletteWidget* CellWidget::getPalette ()
1336 {
return _palette; }
1339 inline DbU::Unit CellWidget::cursorStep ()
const
1340 {
return _state->cursorStep(); }
1343 inline unsigned int CellWidget::getDbuMode ()
const
1344 {
return _state->getDbuMode(); }
1347 inline bool CellWidget::gridMode ()
const
1348 {
return _state->gridMode(); }
1351 inline bool CellWidget::symbolicMode ()
const
1352 {
return _state->symbolicMode(); }
1355 inline bool CellWidget::physicalMode ()
const
1356 {
return _state->physicalMode(); }
1360 {
return _state->getUnitPower(); }
1363 inline bool CellWidget::showBoundaries ()
const
1364 {
return _state->showBoundaries(); }
1367 inline bool CellWidget::showSelection ()
const
1368 {
return _state->showSelection(); }
1371 inline bool CellWidget::cumulativeSelection ()
const
1372 {
return _state->cumulativeSelection(); }
1375 inline QPainter& CellWidget::getPainter (
size_t plane )
1376 {
return _drawingPlanes.painter(plane); }
1379 inline const DisplayStyle::HSVr& CellWidget::getDarkening ()
const
1380 {
return _darkening; }
1383 inline const float& CellWidget::getScale ()
const
1384 {
return _state->getScale(); }
1387 inline const QPoint& CellWidget::getMousePosition ()
const
1388 {
return _mousePosition; }
1391 inline void CellWidget::updateMousePosition ()
1393 Point mousePoint = screenToDbuPoint ( _mousePosition );
1394 emit mousePositionChanged ( _onCursorGrid(mousePoint) );
1398 inline void CellWidget::setQueryFilter ( Query::Mask filter )
1400 _state->setQueryFilter ( filter );
1401 emit queryFilterChanged ();
1405 inline Query::Mask CellWidget::getQueryFilter ()
const
1406 {
return _state->getQueryFilter(); }
1409 inline void CellWidget::setDbuMode (
int mode )
1410 { _state->setDbuMode(mode); }
1414 { _state->setUnitPower(p); }
1417 inline void CellWidget::setRubberShape ( RubberShape shape )
1419 _state->setRubberShape ( shape );
1420 _redrawManager.refresh ();
1421 emit queryFilterChanged ();
1425 inline CellWidget::RubberShape CellWidget::getRubberShape ()
const
1426 {
return _state->getRubberShape(); }
1429 inline void CellWidget::setPen (
const QPen& pen,
size_t plane )
1430 { _drawingPlanes.painter(plane).setPen(pen); }
1433 inline void CellWidget::setDarkening (
const DisplayStyle::HSVr& darkening )
1434 { _darkening = darkening; }
1437 inline bool CellWidget::isPrinter ()
const
1438 {
return _isPrinter; }
1441 inline void CellWidget::setPrinter (
bool state )
1442 { _isPrinter = state; }
1445 inline bool CellWidget::timeout (
const char* fname,
const Timer& timer,
double timeout,
bool& timedout )
const
1447 if ( timedout )
return true;
1448 if ( timer.getCombTimeOnTheFly() < timeout )
return false;
1451 cerr << Warning(
"CellWidget::%s(): timeout %.3f (limit:%.1f)."
1452 ,fname,timer.getCombTimeOnTheFly(),timeout) << endl;
1457 inline DbU::Unit CellWidget::_snapGridStep ()
const
1465 inline Point CellWidget::_onSnapGrid (
const Point& p )
const
1466 {
return Point(_onSnapGrid(p.getX()),_onSnapGrid(p.getY())); }
1473 inline Point CellWidget::_onCursorGrid (
const Point& p )
const
1474 {
return Point(_onCursorGrid(p.getX()),_onCursorGrid(p.getY())); }
const DbU::Unit & getYMax() const
const DbU::Unit & getXMin() const
static Unit grid(double value)
static void setRealSnapGridStep(DbU::Unit step)
static Unit fromGrid(double value)
static Unit fromLambda(double value)
static DbU::Unit getSymbolicSnapGridStep()
static DbU::Unit getOnCustomGrid(DbU::Unit u, DbU::Unit step, SnapMode mode=Nearest)
static Unit lambda(double value)
static Unit db(Unit value)
static DbU::Unit getOnSymbolicSnapGrid(DbU::Unit u, SnapMode mode=Nearest)
void setQuery(Cell *cell, const Box &area, const Transformation &transformation, const BasicLayer *basicLayer, ExtensionSlice::Mask extensionMask, Mask filter, DbU::Unit threshold=0)
GenericCollection< Occurrence > Occurrences