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::shared_ptr;
71 enum UpdateState { ExternalEmit = 0
88 typedef void ( DrawExtensionGo_t )(
CellWidget*
94 typedef void ( InitExtensionGo_t )(
CellWidget* );
95 typedef boost::function< void(QPainter&) > PainterCb_t;
96 enum RubberShape { Centric=1, Barycentric, Steiner };
97 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, std::shared_ptr<QFont> font=std::shared_ptr<QFont>() );
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 selectSet (
const OccurrenceSet& );
270 void selectSet (
const ComponentSet& );
272 void selectOccurrencesUnder (
Box selectArea );
276 void unselectSet (
const ComponentSet& );
277 void unselectSet (
const OccurrenceSet& );
280 void setShowSelection (
bool state );
281 void setCumulativeSelection (
bool state );
285 void _unselectAll ();
286 inline void addRuler (
const Point&,
const Point& );
287 inline void addRuler ( shared_ptr<Ruler> );
288 inline void clearRulers ();
289 void changeQueryFilter ();
290 void rubberChange ();
292 void setStyle (
int id );
293 void updatePalette ();
294 void cellPreModificate ();
295 void cellPostModificate ();
296 inline void refresh (
bool fullRedraw=
true );
297 void _redraw ( QRect redrawArea );
298 inline void redrawSelection ();
299 void redrawSelection ( QRect redrawArea );
300 void goLeft (
int dx = 0 );
301 void goRight (
int dx = 0 );
302 void goUp (
int dy = 0 );
303 void goDown (
int dy = 0 );
304 void fitToContents (
bool historyEnable=
true );
305 void fitToNet (
const Net*,
bool historyEnable=
true );
306 void setScale (
float );
307 void scaleHistoryUp ();
308 void scaleHistoryDown ();
312 void setShowBoundaries (
bool state );
314 void reframe (
const Box& box,
bool historyEnable=
true );
315 void displayReframe ();
316 void _goLeft (
int dx );
317 void _goRight (
int dx );
318 void _goUp (
int dy );
319 void _goDown (
int dy );
321 std::string _getString ()
const;
327 void setRestore (
bool );
328 inline void setShowSpot (
bool );
329 inline const QPoint& getSpotPoint ()
const;
331 QPoint computeSpotPoint (
const QPoint& );
332 void moveTo (
const QPoint& );
343 enum EventType { GoLeft = 1
350 RedrawEvent ( EventType,
int shift, CellWidget* );
351 inline EventType getType ()
const;
352 inline int getShift ()
const;
359 class RedrawManager {
361 inline RedrawManager ( CellWidget* );
364 void goRight (
int );
369 inline void stopProcessing ();
370 inline bool isProcessing ()
const;
371 inline bool interrupted ()
const;
372 inline size_t getPendings ()
const;
373 inline void openRefreshSession ();
374 inline void closeRefreshSession ();
377 list<RedrawEvent*> _events;
386 enum Ids { Normal = 0
397 class DrawingPlanes {
399 DrawingPlanes (
const QSize& size, CellWidget* cw );
401 inline bool getLineMode ()
const;
402 inline size_t getWorkingPlane ()
const;
403 inline void pushWorkingPlane ();
404 inline void popWorkingPlane ();
405 inline int width ()
const;
406 inline int height ()
const;
407 inline QSize size ()
const;
408 inline void select (
size_t i );
409 inline QPainter& painter (
size_t i=PlaneId::Working );
410 inline void begin (
size_t i=PlaneId::Working );
411 inline void end (
size_t i=PlaneId::Working );
412 inline void buffersBegin ();
413 inline void buffersEnd ();
414 void setLineMode (
bool mode );
415 void setPen (
const QPen& pen );
416 void setBrush (
const QBrush& brush );
417 void setBackground (
const QBrush& brush );
418 void setBackgroundMode ( Qt::BGMode mode );
419 void resize (
const QSize& size );
420 void shiftLeft (
int dx );
421 void shiftRight (
int dx );
422 void shiftUp (
int dy );
423 void shiftDown (
int dy );
424 inline void copyToSelect ();
425 inline void copyToSelect (
const QRect& );
426 void copyToSelect (
int sx,
int sy,
int h,
int w );
427 inline void copyToScreen ();
428 void copyToScreen (
int sx,
int sy,
int h,
int w );
429 inline void copyToPrinter (
int xpaper,
int ypaper, QPrinter*, CellWidget::PainterCb_t& );
430 void copyToPrinter (
int xpaper,
int ypaper,
int sx,
int sy,
int h,
int w, QPrinter*, CellWidget::PainterCb_t& );
431 inline void copyToImage ( QImage*, CellWidget::PainterCb_t& );
432 void copyToImage (
int sx,
int sy,
int h,
int w, QImage*, CellWidget::PainterCb_t& );
434 static const int _cartoucheWidth;
435 static const int _cartoucheHeight;
436 static const int _titleHeight;
437 CellWidget* _cellWidget;
441 QPainter _painters[PlaneId::Working];
445 size_t _workingPlane;
446 size_t _pushWorkingPlane;
449 DrawingPlanes (
const DrawingPlanes& );
450 DrawingPlanes& operator= (
const DrawingPlanes& );
454 class DrawingQuery :
public Query {
456 DrawingQuery ( CellWidget* widget );
457 inline void setQuery (
const Box& area
458 ,
const Transformation& transformation
459 ,
const BasicLayer* basicLayer
460 , ExtensionSlice::Mask extensionMask
461 ,
unsigned int filter
463 inline void addDrawExtensionGo (
const Name&
467 inline void copyDrawExtensionGos (
const DrawingQuery& );
468 void setDrawExtensionGo (
const Name& );
469 virtual bool hasMasterCellCallback ()
const;
470 virtual bool hasGoCallback ()
const;
471 virtual bool hasMarkerCallback ()
const;
472 virtual bool hasRubberCallback ()
const;
473 virtual bool hasExtensionGoCallback ()
const;
474 virtual void masterCellCallback ();
475 virtual void goCallback ( Go* );
476 virtual void rubberCallback ( Rubber* );
477 virtual void markerCallback ( Marker* );
478 virtual void extensionGoCallback ( Go* );
479 void drawMasterCell (
const Cell* cell
480 ,
const Transformation& transformation
482 void drawGo (
const Go* go
483 ,
const BasicLayer* basicLayer
485 ,
const Transformation& transformation
487 void drawRubber (
const Rubber* rubber
489 ,
const Transformation& transformation
491 void drawMarker (
const Marker* marker
493 ,
const Transformation& transformation
495 void drawExtensionGo ( CellWidget* widget
497 ,
const BasicLayer* basicLayer
499 ,
const Transformation& transformation
501 inline unsigned int getGoCount ()
const;
502 inline unsigned int getExtensionGoCount ()
const;
503 inline unsigned int getInstanceCount ()
const;
504 inline void resetGoCount ();
505 inline void resetExtensionGoCount ();
506 inline void resetInstanceCount ();
509 CellWidget* _cellWidget;
510 DrawExtensionGo_t* _drawExtensionGo;
511 map<Name,pair<InitExtensionGo_t*,DrawExtensionGo_t*> >
513 unsigned int _goCount;
514 unsigned int _extensionGoCount;
515 unsigned int _instanceCount;
519 class TextDrawingQuery :
public Query {
521 TextDrawingQuery ( CellWidget* widget );
522 inline void setQuery (
const Box& area
523 ,
const Transformation& transformation
525 virtual bool hasMasterCellCallback ()
const;
526 virtual bool hasGoCallback ()
const;
527 virtual bool hasRubberCallback ()
const;
528 virtual bool hasExtensionGoCallback ()
const;
529 virtual void masterCellCallback ();
530 virtual void goCallback ( Go* go );
531 virtual void extensionGoCallback ( Go* go );
532 virtual void rubberCallback ( Rubber* );
535 CellWidget* _cellWidget;
539 class SelectorCriterions {
541 SelectorCriterions ();
542 ~SelectorCriterions ();
543 inline void setCellWidget ( CellWidget* );
544 inline const vector<SelectorCriterion*>& getCriterions ()
const;
545 SelectorCriterion* add ( Occurrence netOccurrence );
546 SelectorCriterion* add ( Box area );
547 inline SelectorCriterion* add ( SelectorCriterion* );
548 bool remove ( Occurrence netOccurrence );
552 inline size_t size ()
const;
554 CellWidget* _cellWidget;
555 vector<SelectorCriterion*> _criterions;
561 inline State ( Cell* cell=NULL, Path topPath=Path() );
562 State* clone ()
const;
563 inline void setCell ( Cell* );
564 inline void setTopPath ( Path );
565 inline void setCellWidget ( CellWidget* );
569 inline void setDbuMode (
int );
571 inline void setShowBoundaries (
bool );
572 inline void setShowSelection (
bool );
573 inline void setCumulativeSelection (
bool );
574 void setScale (
float );
576 inline void setTopLeft (
const Point& );
577 inline void setQueryFilter ( Query::Mask );
578 inline void setStartLevel (
int );
579 inline void setStopLevel (
int );
580 inline void setRubberShape ( RubberShape );
581 inline void setHistoryEnable (
bool );
582 bool scaleHistoryUp ();
583 bool scaleHistoryDown ();
584 inline Cell* getCell ()
const;
585 inline Cell* getTopCell ()
const;
586 inline Path getTopPath ()
const;
587 const Name& getName ()
const;
588 inline SelectorCriterions& getSelection ();
589 inline RulerSet& getRulers ();
591 inline unsigned int getDbuMode ()
const;
592 inline bool gridMode ()
const;
593 inline bool symbolicMode ()
const;
594 inline bool physicalMode ()
const;
595 inline bool nanoMode ()
const;
596 inline bool microMode ()
const;
597 inline bool showBoundaries ()
const;
598 inline bool showSelection ()
const;
599 inline bool cumulativeSelection ()
const;
600 inline bool getHistoryEnable ()
const;
601 inline size_t getHistorySize ()
const;
602 inline const float& getScale ()
const;
603 inline const Point& getTopLeft ()
const;
604 inline Query::Mask getQueryFilter ()
const;
605 inline int getStartLevel ()
const;
606 inline int getStopLevel ()
const;
607 inline RubberShape getRubberShape ()
const;
612 inline ScaleEntry (
float,
const Point& );
621 Name _hierarchicalName;
622 CellWidget* _cellWidget;
623 SelectorCriterions _selection;
626 unsigned int _dbuMode;
628 bool _showBoundaries;
630 Query::Mask _queryFilter;
633 RubberShape _rubberShape;
634 bool _cumulativeSelection;
635 vector<ScaleEntry> _scaleHistory;
640 class FindStateName {
642 inline FindStateName (
const Name& );
643 inline bool operator() (
const shared_ptr<State>& );
645 const Name _cellHierName;
650 vector<Qt::CursorShape> _cursors;
652 Technology* _technology;
653 PaletteWidget* _palette;
655 RedrawManager _redrawManager;
656 DrawingPlanes _drawingPlanes;
657 DrawingQuery _drawingQuery;
658 TextDrawingQuery _textDrawingQuery;
659 DisplayStyle::HSVr _darkening;
660 QPoint _mousePosition;
662 shared_ptr<State> _state;
666 bool _enableRedrawInterrupt;
667 int _delaySelectionChanged;
668 SelectorSet _selectors;
669 Command* _activeCommand;
670 vector<Command*> _commands;
671 size_t _redrawRectCount;
675 friend class RedrawManager;
679 inline void CellWidget::Spot::setShowSpot (
bool show )
680 { _showSpot = show; }
683 inline const QPoint& CellWidget::Spot::getSpotPoint ()
const
684 {
return _spotPoint; }
687 inline void CellWidget::DrawingQuery::setQuery (
const Box& area
688 ,
const Transformation& transformation
689 ,
const BasicLayer* basicLayer
690 , ExtensionSlice::Mask extensionMask
691 ,
unsigned int filter
704 inline void CellWidget::setEnableRedrawInterrupt (
bool state )
705 { _enableRedrawInterrupt = state; }
708 inline void CellWidget::openRefreshSession ()
709 { _redrawManager.openRefreshSession (); }
712 inline void CellWidget::closeRefreshSession ()
713 { _redrawManager.closeRefreshSession (); }
716 inline void CellWidget::DrawingQuery::addDrawExtensionGo (
const Name& name
717 , InitExtensionGo_t* initExtensionGo
718 , DrawExtensionGo_t* drawExtensionGo
720 { _drawExtensionGos[name] = make_pair(initExtensionGo,drawExtensionGo); }
723 inline void CellWidget::DrawingQuery::copyDrawExtensionGos (
const CellWidget::DrawingQuery& other )
724 { _drawExtensionGos = other._drawExtensionGos; }
727 inline void CellWidget::DrawingQuery::resetGoCount ()
731 inline void CellWidget::DrawingQuery::resetExtensionGoCount ()
732 { _extensionGoCount = 0; }
735 inline void CellWidget::DrawingQuery::resetInstanceCount ()
736 { _instanceCount = 0; }
739 inline unsigned int CellWidget::DrawingQuery::getGoCount ()
const
743 inline unsigned int CellWidget::DrawingQuery::getExtensionGoCount ()
const
744 {
return _extensionGoCount; }
747 inline unsigned int CellWidget::DrawingQuery::getInstanceCount ()
const
748 {
return _instanceCount; }
751 inline CellWidget::RedrawEvent::EventType CellWidget::RedrawEvent::getType ()
const
755 inline int CellWidget::RedrawEvent::getShift ()
const
759 inline bool CellWidget::RedrawManager::isProcessing ()
const
760 {
return _processing; }
763 inline void CellWidget::RedrawManager::stopProcessing ()
764 { _processing =
false; }
767 inline size_t CellWidget::RedrawManager::getPendings ()
const
768 {
return _events.size(); }
771 inline void CellWidget::RedrawManager::openRefreshSession ()
772 { _refreshSession++; }
775 inline void CellWidget::RedrawManager::closeRefreshSession ()
778 if ( !_processing && (_refreshSession == 0) ) process ();
782 inline bool CellWidget::RedrawManager::interrupted ()
const
784 #ifdef ALLOW_REQUEST_INTERRUPT
785 return ( _events.size() > 5 ) || _interrupted;
792 inline bool CellWidget::DrawingPlanes::getLineMode ()
const
793 {
return _lineMode; }
796 inline size_t CellWidget::DrawingPlanes::getWorkingPlane ()
const
797 {
return _workingPlane; }
800 inline void CellWidget::DrawingPlanes::pushWorkingPlane ()
801 { _pushWorkingPlane = _workingPlane; }
804 inline void CellWidget::DrawingPlanes::popWorkingPlane ()
805 { _workingPlane = _pushWorkingPlane; }
808 inline int CellWidget::DrawingPlanes::width ()
const
809 {
return _planes[PlaneId::Normal]->width(); }
812 inline int CellWidget::DrawingPlanes::height ()
const
813 {
return _planes[PlaneId::Normal]->height(); }
816 inline QSize CellWidget::DrawingPlanes::size ()
const
817 {
return _planes[PlaneId::Normal]->size(); }
820 inline void CellWidget::DrawingPlanes::select (
size_t i )
821 { _workingPlane = i; }
824 inline QPainter& CellWidget::DrawingPlanes::painter (
size_t i )
825 {
return _painters[ (i>=PlaneId::Working) ? _workingPlane : i ]; }
828 inline void CellWidget::DrawingPlanes::begin (
size_t i )
830 size_t wp = (i>=PlaneId::Working) ? _workingPlane : i;
832 case PlaneId::Normal:
833 case PlaneId::Selection:
834 case PlaneId::AutoCopy: _painters[wp ].begin( _planes[wp] );
break;
835 case PlaneId::Widget: _painters[PlaneId::Widget ].begin( _cellWidget );
break;
836 case PlaneId::Printer: _painters[PlaneId::Printer].begin( _printer );
break;
837 case PlaneId::Image: _painters[PlaneId::Image ].begin( _image );
break;
839 std::cerr <<
"[BUG] Bad plane selection." << std::endl;
844 inline void CellWidget::DrawingPlanes::end (
size_t i )
845 { _painters[(i>=PlaneId::Working)?_workingPlane:i].end (); }
848 inline void CellWidget::DrawingPlanes::buffersBegin ()
850 begin( PlaneId::Normal );
851 begin( PlaneId::Selection );
852 begin( PlaneId::AutoCopy );
856 inline void CellWidget::DrawingPlanes::buffersEnd ()
858 end( PlaneId::Normal );
859 end( PlaneId::Selection );
860 end( PlaneId::AutoCopy );
864 inline void CellWidget::DrawingPlanes::copyToSelect ()
865 { copyToSelect ( 0, 0, width(), height() ); }
868 inline void CellWidget::DrawingPlanes::copyToSelect (
const QRect& r )
869 { copyToSelect ( r.x(), r.y(), r.width(), r.height() ); }
872 inline void CellWidget::DrawingPlanes::copyToScreen ()
873 { copyToScreen ( 0, 0, width(), height() ); }
876 inline void CellWidget::DrawingPlanes::copyToPrinter (
int xpaper,
int ypaper, QPrinter* printer, CellWidget::PainterCb_t& cb )
878 copyToPrinter ( xpaper
882 , _cellWidget->geometry().width()
883 , _cellWidget->geometry().height()
890 inline void CellWidget::DrawingPlanes::copyToImage ( QImage* image, CellWidget::PainterCb_t& cb )
894 , _cellWidget->geometry().width()
895 , _cellWidget->geometry().height()
902 inline void CellWidget::SelectorCriterions::setCellWidget ( CellWidget* cw )
903 { _cellWidget = cw; }
906 inline size_t CellWidget::SelectorCriterions::size ()
const
907 {
return _criterions.size(); }
910 inline const vector<SelectorCriterion*>& CellWidget::SelectorCriterions::getCriterions ()
const
911 {
return _criterions; }
914 inline SelectorCriterion* CellWidget::SelectorCriterions::add ( SelectorCriterion* criterion )
916 _criterions.push_back( criterion );
917 return _criterions.back();
921 inline CellWidget::State::ScaleEntry::ScaleEntry (
float scale,
const Point& topLeft )
922 : _scale(scale), _topLeft(topLeft)
926 inline CellWidget::State::State ( Cell* cell, Path topPath )
929 , _hierarchicalName ()
933 , _cursorStep (DbU::lambda(0.5))
934 , _dbuMode (DbU::Symbolic)
935 , _unitPower (DbU::Nano)
936 , _showBoundaries (true)
937 , _showSelection (false)
938 , _queryFilter (~Query::DoTerminalCells)
941 , _rubberShape (CellWidget::Barycentric)
942 , _cumulativeSelection(false)
945 , _historyEnable (false)
947 _scaleHistory.push_back ( ScaleEntry(1.0,Point(0,0)) );
948 if (_cell) _hierarchicalName = Name( _cell->getHierarchicalName() );
952 inline unsigned int CellWidget::State::getDbuMode ()
const
956 inline bool CellWidget::State::symbolicMode ()
const
960 inline bool CellWidget::State::gridMode ()
const
964 inline bool CellWidget::State::physicalMode ()
const
965 {
return (_dbuMode == DbU::Physical); }
968 inline void CellWidget::State::setCell ( Cell* cell )
971 if (_cell) _hierarchicalName = Name( _cell->getHierarchicalName() );
975 inline void CellWidget::State::setTopPath ( Path topPath )
976 { _topPath = topPath; }
979 inline void CellWidget::State::setCellWidget ( CellWidget* cw )
982 _selection.setCellWidget ( cw );
986 inline void CellWidget::State::setCursorStep (
DbU::Unit step )
987 { _cursorStep = step; }
989 inline DbU::Unit CellWidget::State::getCursorStep ()
const
990 {
return _cursorStep; }
994 {
return _unitPower; }
997 inline void CellWidget::State::setDbuMode (
int mode )
1000 switch ( _dbuMode ) {
1003 case DbU::Physical: _cursorStep =
DbU::fromGrid (1.0);
break;
1012 inline void CellWidget::State::setShowBoundaries (
bool state )
1013 { _showBoundaries = state; }
1016 inline void CellWidget::State::setShowSelection (
bool state )
1017 { _showSelection = state; }
1020 inline void CellWidget::State::setCumulativeSelection (
bool state )
1021 { _cumulativeSelection = state; }
1026 _scaleHistory[_ihistory]._topLeft.setX(x);
1027 _scaleHistory[_ihistory]._topLeft.setY(y);
1031 inline void CellWidget::State::setTopLeft (
const Point& topLeft )
1032 { _scaleHistory[_ihistory]._topLeft = topLeft; }
1035 inline void CellWidget::State::setQueryFilter ( Query::Mask mask )
1036 { _queryFilter = mask; }
1039 inline void CellWidget::State::setStartLevel (
int level )
1040 { _startLevel = level; }
1043 inline void CellWidget::State::setStopLevel (
int level )
1044 { _stopLevel = level; }
1047 inline void CellWidget::State::setRubberShape ( RubberShape shape )
1048 { _rubberShape = shape; }
1051 inline void CellWidget::State::setHistoryEnable (
bool enable )
1052 { _historyEnable = enable; }
1055 inline Cell* CellWidget::State::getCell ()
const
1059 inline Path CellWidget::State::getTopPath ()
const
1060 {
return _topPath; }
1063 inline Cell* CellWidget::State::getTopCell ()
const
1064 {
return (_topPath.isEmpty()) ? _cell : _topPath.getOwnerCell(); }
1067 inline DbU::Unit CellWidget::State::cursorStep ()
const
1068 {
return _cursorStep; }
1071 inline CellWidget::SelectorCriterions& CellWidget::State::getSelection ()
1072 {
return _selection; }
1075 inline RulerSet& CellWidget::State::getRulers ()
1079 inline bool CellWidget::State::showBoundaries ()
const
1080 {
return _showBoundaries; }
1083 inline bool CellWidget::State::showSelection ()
const
1084 {
return _showSelection; }
1087 inline bool CellWidget::State::cumulativeSelection ()
const
1088 {
return _cumulativeSelection; }
1091 inline bool CellWidget::State::getHistoryEnable ()
const
1092 {
return _historyEnable; }
1095 inline size_t CellWidget::State::getHistorySize ()
const
1096 {
return _scaleHistory.size(); }
1099 inline const Point& CellWidget::State::getTopLeft ()
const
1100 {
return _scaleHistory[_ihistory]._topLeft; }
1103 inline Query::Mask CellWidget::State::getQueryFilter ()
const
1104 {
return _queryFilter; }
1107 inline int CellWidget::State::getStartLevel ()
const
1108 {
return _startLevel; }
1111 inline int CellWidget::State::getStopLevel ()
const
1112 {
return _stopLevel; }
1115 inline CellWidget::RubberShape CellWidget::State::getRubberShape ()
const
1116 {
return _rubberShape; }
1119 inline const float& CellWidget::State::getScale ()
const
1120 {
return _scaleHistory[_ihistory]._scale; }
1123 inline void CellWidget::setPixelThreshold (
int pixelThreshold )
1124 { _pixelThreshold = pixelThreshold; }
1127 inline int CellWidget::getPixelThreshold ()
const
1128 {
return _pixelThreshold; }
1131 inline CellWidget::FindStateName::FindStateName (
const Name& cellHierName )
1132 : _cellHierName(cellHierName)
1136 inline bool CellWidget::FindStateName::operator () (
const shared_ptr<State>& state )
1137 {
return state->getName() == _cellHierName; }
1140 inline void CellWidget::setActiveCommand ( Command* command )
1141 { _activeCommand = command; }
1144 inline Command* CellWidget::getActiveCommand ()
const
1145 {
return _activeCommand; }
1148 inline void CellWidget::resetActiveCommand ()
1149 { _activeCommand = NULL; }
1152 inline void CellWidget::setCursorStep (
DbU::Unit step )
1153 { _state->setCursorStep(step); }
1156 inline void CellWidget::setRealSnapGridStep (
DbU::Unit step )
1160 inline shared_ptr<CellWidget::State>& CellWidget::getState ()
1162 _state->setTopLeft ( getTopLeft() );
1167 inline shared_ptr<CellWidget::State> CellWidget::getStateClone ()
1169 _state->setTopLeft ( getTopLeft() );
1170 return shared_ptr<State>( _state->clone() );
1174 inline void CellWidget::addDrawExtensionGo (
const Name& name
1175 , InitExtensionGo_t* initExtensionGo
1176 , DrawExtensionGo_t* drawExtensionGo
1178 { _drawingQuery.addDrawExtensionGo( name, initExtensionGo, drawExtensionGo ); }
1181 inline void CellWidget::copyDrawExtensionGos (
const CellWidget* other )
1182 { _drawingQuery.copyDrawExtensionGos( other->_drawingQuery ); }
1185 inline void CellWidget::setStartLevel (
int level )
1187 _drawingQuery.setStartLevel ( level );
1188 _state->setStartLevel ( level );
1189 emit queryFilterChanged ();
1193 inline void CellWidget::setStopLevel (
int level )
1195 _drawingQuery.setStopLevel ( level );
1196 _state->setStopLevel ( level );
1197 emit queryFilterChanged ();
1201 inline int CellWidget::getStartLevel ()
const
1202 {
return _drawingQuery.getStartLevel (); }
1205 inline int CellWidget::getStopLevel ()
const
1206 {
return _drawingQuery.getStopLevel (); }
1209 inline CellWidget::DrawingPlanes& CellWidget::getDrawingPlanes ()
1210 {
return _drawingPlanes; }
1213 inline SelectorSet& CellWidget::getSelectorSet ()
1214 {
return _selectors; }
1217 Occurrences CellWidget::getOccurrencesUnder (
const QRect& area )
const
1218 {
return getOccurrencesUnder(screenToDbuBox(area)); }
1221 inline void CellWidget::addRuler (
const Point& origin,
const Point& extremity )
1223 _state->getRulers().insert ( shared_ptr<Ruler>(
new Ruler(origin,extremity) ) );
1228 inline void CellWidget::addRuler ( shared_ptr<Ruler> ruler )
1230 _state->getRulers().insert ( ruler );
1235 inline void CellWidget::clearRulers ()
1236 { _state->getRulers().clear (); refresh(); }
1239 inline void CellWidget::refresh (
bool fullRedraw )
1240 { _fullRedraw |= fullRedraw; _redrawManager.refresh(); }
1243 inline void CellWidget::redrawSelection ()
1244 { redrawSelection ( QRect(QPoint(0,0),_drawingPlanes.size()) ); }
1247 inline void CellWidget::copyToPrinter (
int xpaper,
int ypaper, QPrinter* printer, CellWidget::PainterCb_t& cb )
1248 { _drawingPlanes.copyToPrinter( xpaper, ypaper, printer, cb ); }
1251 inline void CellWidget::copyToImage ( QImage* image, PainterCb_t& cb )
1252 { _drawingPlanes.copyToImage ( image, cb ); }
1255 inline DbU::Unit CellWidget::toDbu (
float d )
const
1258 switch ( getDbuMode() ) {
1269 inline int CellWidget::dbuToScreenX (
DbU::Unit x )
const
1270 {
return (
int)rint ( (
float)( x - _screenArea.
getXMin() ) * getScale() ); }
1273 inline int CellWidget::dbuToScreenY (
DbU::Unit y )
const
1274 {
return (
int)rint ( (
float)( _screenArea.
getYMax() - y ) * getScale() ); }
1277 inline int CellWidget::dbuToScreenLength (
DbU::Unit length )
const
1278 {
return (
int)rint ( (
float)length * getScale() ); }
1282 {
return QPoint ( dbuToScreenX(x), dbuToScreenY(y) ); }
1285 inline QPoint CellWidget::dbuToScreenPoint (
const Point& point )
const
1286 {
return QPoint ( dbuToScreenX(point.getX()), dbuToScreenY(point.getY()) ); }
1289 inline DbU::Unit CellWidget::screenToDbuX (
int x )
const
1293 inline DbU::Unit CellWidget::screenToDbuY (
int y )
const
1297 inline DbU::Unit CellWidget::screenToDbuLength (
int length )
const
1298 {
return (
int)( (float)length / getScale() ); }
1301 inline Point CellWidget::screenToDbuPoint (
const QPoint& point )
const
1302 {
return Point ( screenToDbuX(point.x()), screenToDbuY(point.y()) ); }
1305 inline Box CellWidget::screenToDbuBox (
const QRect& rect )
const
1307 return Box ( screenToDbuX(rect.x())
1308 , screenToDbuY(rect.y())
1309 , screenToDbuX(rect.x()+rect.width ())
1310 , screenToDbuY(rect.y()+rect.height())
1315 inline Box& CellWidget::pixelInflate ( Box& box,
int pixels )
const
1316 {
return box.inflate(screenToDbuLength(pixels)); }
1319 inline Point CellWidget::getTopLeft ()
const
1323 inline Box CellWidget::getVisibleArea ()
const
1324 {
return computeVisibleArea(getScale()); }
1327 inline Cell* CellWidget::getCell ()
const
1328 {
return _state->getCell(); }
1331 inline Cell* CellWidget::getTopCell ()
const
1332 {
return _state->getTopCell(); }
1335 inline Path CellWidget::getTopPath ()
const
1336 {
return _state->getTopPath(); }
1339 inline PaletteWidget* CellWidget::getPalette ()
1340 {
return _palette; }
1343 inline DbU::Unit CellWidget::cursorStep ()
const
1344 {
return _state->cursorStep(); }
1347 inline unsigned int CellWidget::getDbuMode ()
const
1348 {
return _state->getDbuMode(); }
1351 inline bool CellWidget::gridMode ()
const
1352 {
return _state->gridMode(); }
1355 inline bool CellWidget::symbolicMode ()
const
1356 {
return _state->symbolicMode(); }
1359 inline bool CellWidget::physicalMode ()
const
1360 {
return _state->physicalMode(); }
1364 {
return _state->getUnitPower(); }
1367 inline bool CellWidget::showBoundaries ()
const
1368 {
return _state->showBoundaries(); }
1371 inline bool CellWidget::showSelection ()
const
1372 {
return _state->showSelection(); }
1375 inline bool CellWidget::cumulativeSelection ()
const
1376 {
return _state->cumulativeSelection(); }
1379 inline QPainter& CellWidget::getPainter (
size_t plane )
1380 {
return _drawingPlanes.painter(plane); }
1383 inline const DisplayStyle::HSVr& CellWidget::getDarkening ()
const
1384 {
return _darkening; }
1387 inline const float& CellWidget::getScale ()
const
1388 {
return _state->getScale(); }
1391 inline const QPoint& CellWidget::getMousePosition ()
const
1392 {
return _mousePosition; }
1395 inline void CellWidget::updateMousePosition ()
1397 Point mousePoint = screenToDbuPoint ( _mousePosition );
1398 emit mousePositionChanged ( _onCursorGrid(mousePoint) );
1402 inline void CellWidget::setQueryFilter ( Query::Mask filter )
1404 _state->setQueryFilter ( filter );
1405 emit queryFilterChanged ();
1409 inline Query::Mask CellWidget::getQueryFilter ()
const
1410 {
return _state->getQueryFilter(); }
1413 inline void CellWidget::setDbuMode (
int mode )
1414 { _state->setDbuMode(mode); }
1418 { _state->setUnitPower(p); }
1421 inline void CellWidget::setRubberShape ( RubberShape shape )
1423 _state->setRubberShape ( shape );
1425 emit queryFilterChanged ();
1429 inline CellWidget::RubberShape CellWidget::getRubberShape ()
const
1430 {
return _state->getRubberShape(); }
1433 inline void CellWidget::setPen (
const QPen& pen,
size_t plane )
1434 { _drawingPlanes.painter(plane).setPen(pen); }
1437 inline void CellWidget::setDarkening (
const DisplayStyle::HSVr& darkening )
1438 { _darkening = darkening; }
1441 inline bool CellWidget::isPrinter ()
const
1442 {
return _isPrinter; }
1445 inline void CellWidget::setPrinter (
bool state )
1446 { _isPrinter = state; }
1449 inline bool CellWidget::timeout (
const char* fname,
const Timer& timer,
double timeout,
bool& timedout )
const
1451 if ( timedout )
return true;
1452 if ( timer.getCombTimeOnTheFly() < timeout )
return false;
1455 cerr << Warning(
"CellWidget::%s(): timeout %.3f (limit:%.1f)."
1456 ,fname,timer.getCombTimeOnTheFly(),timeout) << endl;
1461 inline DbU::Unit CellWidget::_snapGridStep ()
const
1469 inline Point CellWidget::_onSnapGrid (
const Point& p )
const
1470 {
return Point(_onSnapGrid(p.getX()),_onSnapGrid(p.getY())); }
1477 inline Point CellWidget::_onCursorGrid (
const Point& p )
const
1478 {
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