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
109 enum Flag { NoFlags =0x0000
110 , NoResetCommands=0x0001
120 void setCell (
Cell*,
Path topPath=
Path(),
unsigned int flags=NoFlags );
121 inline Cell* getCell ()
const;
122 inline Cell* getTopCell ()
const;
123 inline Path getTopPath ()
const;
124 inline shared_ptr<State>& getState ();
125 inline shared_ptr<State> getStateClone ();
126 inline PaletteWidget* getPalette ();
127 inline Occurrences getOccurrencesUnder (
const QRect& )
const;
129 inline SelectorSet& getSelectorSet ();
130 inline RulerSet& getRulerSet ();
131 inline RubberShape getRubberShape ()
const;
132 inline int getStartLevel ()
const;
133 inline int getStopLevel ()
const;
134 inline Query::Mask getQueryFilter ()
const ;
135 void bindToPalette ( PaletteWidget* );
136 void detachFromPalette ();
137 void detach ( Selector*);
138 void bindCommand ( Command* );
139 void unbindCommand ( Command* );
140 void resetCommands ();
141 inline void setActiveCommand ( Command* );
142 inline Command* getActiveCommand ()
const;
143 Command* getCommand (
const std::string& )
const;
144 inline void resetActiveCommand ();
146 inline void setRealSnapGridStep (
DbU::Unit step );
147 inline unsigned int getDbuMode ()
const;
148 inline bool gridMode ()
const;
149 inline bool symbolicMode ()
const;
150 inline bool physicalMode ()
const;
152 inline bool showBoundaries ()
const;
153 inline bool showSelection ()
const;
154 inline bool cumulativeSelection ()
const;
155 inline void setPixelThreshold (
int );
156 inline void setDbuMode (
int );
158 inline void setRubberShape ( RubberShape );
159 inline void setStartLevel (
int );
160 inline void setStopLevel (
int );
161 inline void setQueryFilter ( Query::Mask );
162 inline bool timeout (
const char*,
const Timer&,
double timeout,
bool& timedout )
const;
164 inline void setEnableRedrawInterrupt (
bool );
165 inline void addDrawExtensionGo (
const Name&, InitExtensionGo_t*, DrawExtensionGo_t* );
166 inline void copyDrawExtensionGos (
const CellWidget* );
167 inline QPainter& getPainter (
size_t plane=PlaneId::Working );
168 inline const DisplayStyle::HSVr& getDarkening ()
const;
169 inline void copyToPrinter (
int xpaper,
int ypaper, QPrinter*, PainterCb_t& );
170 inline void copyToImage ( QImage*, PainterCb_t& );
171 inline int getPixelThreshold ()
const;
172 inline const float& getScale ()
const;
173 inline const QPoint& getMousePosition ()
const;
174 inline void updateMousePosition ();
175 void setLayerVisible (
const Name& layer,
bool visible );
176 bool isLayerVisible (
const Name& );
177 bool isDrawable (
const Name& );
178 bool isDrawableLayer (
const Name& );
179 bool isDrawableExtension (
const Name& );
180 bool isSelectable (
const Name& )
const;
181 bool isSelectable (
const Layer* )
const;
182 bool isPrinter ()
const;
183 void setPrinter (
bool );
184 inline void setDarkening (
const DisplayStyle::HSVr& );
185 inline void setPen (
const QPen& ,
size_t plane=PlaneId::Working );
187 void drawBox (
const Box& );
188 void drawBoxBorder (
const Box& );
190 void drawLine (
const Point&,
const Point&,
bool mode=
true );
191 void drawText (
const Point&,
const char*,
unsigned int flags=0,
int angle=0 );
192 void drawGrid ( QRect );
194 void drawRuler ( shared_ptr<Ruler> );
195 void drawRulers ( QRect );
196 void drawDisplayText (
const QRect& ,
const char*,
unsigned int flags=0 );
197 void drawDisplayText (
const QPoint&,
const char*,
unsigned int flags=0,
int angle=0, std::shared_ptr<QFont> font=std::shared_ptr<QFont>() );
198 void drawScreenPolygon (
const QPoint*,
int count,
size_t plane=PlaneId::Working );
199 void drawScreenPolygon (
const QPolygon&,
size_t plane=PlaneId::Working );
200 void drawScreenLine (
const QPoint&,
const QPoint&,
size_t plane=PlaneId::Working,
bool mode=
true );
201 void drawScreenRect (
const QPoint&,
const QPoint&,
size_t plane=PlaneId::Working );
202 void drawScreenRect (
const QRect& ,
size_t plane=PlaneId::Working );
203 void drawScreenPolyline (
const QPoint*,
int,
int,
size_t plane=PlaneId::Working );
207 QRect dbuToScreenRect (
const Box& box ,
bool usePoint=
true )
const;
208 inline int dbuToScreenX (
DbU::Unit x )
const;
209 inline int dbuToScreenY (
DbU::Unit y )
const;
210 inline int dbuToScreenLength (
DbU::Unit length )
const;
212 inline QPoint dbuToScreenPoint (
const Point& point )
const;
213 inline DbU::Unit screenToDbuLength (
int length )
const;
214 inline DbU::Unit screenToDbuX (
int x )
const;
215 inline DbU::Unit screenToDbuY (
int y )
const;
216 inline Point screenToDbuPoint (
const QPoint& point )
const;
217 inline Box screenToDbuBox (
const QRect& rect )
const;
218 inline Box& pixelInflate (
Box&,
int pixels )
const;
219 inline Point getTopLeft ()
const;
220 inline Box getVisibleArea ()
const;
221 Box computeVisibleArea (
float scale )
const;
222 Box computeVisibleArea (
float scale,
const Point& topLeft )
const;
223 Box computeVisibleArea (
const Box&,
float& scale )
const;
225 inline bool _underDetailedGridThreshold()
const;
228 inline Point _onSnapGrid (
const Point& )
const;
230 inline Point _onCursorGrid (
const Point& )
const;
232 void pushCursor ( Qt::CursorShape cursor );
234 virtual QSize minimumSizeHint ()
const;
235 virtual void showEvent ( QShowEvent* );
236 virtual void resizeEvent ( QResizeEvent* );
237 virtual void wheelEvent ( QWheelEvent* );
238 virtual void keyPressEvent ( QKeyEvent* );
239 virtual void keyReleaseEvent ( QKeyEvent* );
240 virtual void mouseMoveEvent ( QMouseEvent* );
241 virtual void mousePressEvent ( QMouseEvent* );
242 virtual void mouseReleaseEvent ( QMouseEvent* );
244 void cellChanged (
Cell* );
245 void cellPreModificated ();
246 void cellPostModificated ();
247 void stateChanged ( shared_ptr<CellWidget::State>& );
248 void styleChanged ();
249 void queryFilterChanged ();
251 void updatePalette (
Cell* );
252 void mousePositionChanged (
const Point& position );
253 void selectionModeChanged ();
254 void selectionChanged (
const SelectorSet& );
255 void selectionToggled ( Selector* );
256 void unlinkSelector ( Selector* );
257 void showBoundariesToggled (
bool );
259 virtual void paintEvent ( QPaintEvent* );
262 void setState ( shared_ptr<CellWidget::State>&
263 ,
unsigned int flags=NoFlags );
264 inline void openRefreshSession ();
265 inline void closeRefreshSession ();
266 inline DrawingPlanes& getDrawingPlanes ();
270 void selectSet (
const OccurrenceSet& );
271 void selectSet (
const ComponentSet& );
273 void selectOccurrencesUnder (
Box selectArea );
277 void unselectSet (
const ComponentSet& );
278 void unselectSet (
const OccurrenceSet& );
281 void setShowSelection (
bool state );
282 void setCumulativeSelection (
bool state );
286 void _unselectAll ();
287 inline void addRuler (
const Point&,
const Point& );
288 inline void addRuler ( shared_ptr<Ruler> );
289 inline void clearRulers ();
290 void changeQueryFilter ();
291 void rubberChange ();
293 void setStyle (
int id );
294 void updatePalette ();
295 void cellPreModificate ();
296 void cellPostModificate ();
297 inline void refresh (
bool fullRedraw=
true );
298 void _redraw ( QRect redrawArea );
299 inline void redrawSelection ();
300 void redrawSelection ( QRect redrawArea );
301 void goLeft (
int dx = 0 );
302 void goRight (
int dx = 0 );
303 void goUp (
int dy = 0 );
304 void goDown (
int dy = 0 );
305 void fitToContents (
bool historyEnable=
true );
306 void fitToNet (
const Net*,
bool historyEnable=
true );
307 void setScale (
float );
308 void scaleHistoryUp ();
309 void scaleHistoryDown ();
313 void setShowBoundaries (
bool state );
315 void reframe (
const Box& box,
bool historyEnable=
true );
316 void displayReframe ();
317 void _goLeft (
int dx );
318 void _goRight (
int dx );
319 void _goUp (
int dy );
320 void _goDown (
int dy );
322 std::string _getString ()
const;
328 void setRestore (
bool );
329 inline void setShowSpot (
bool );
330 inline const QPoint& getSpotPoint ()
const;
332 QPoint computeSpotPoint (
const QPoint& );
333 void moveTo (
const QPoint& );
344 enum EventType { GoLeft = 1
351 RedrawEvent ( EventType,
int shift, CellWidget* );
352 inline EventType getType ()
const;
353 inline int getShift ()
const;
360 class RedrawManager {
362 inline RedrawManager ( CellWidget* );
365 void goRight (
int );
370 inline void stopProcessing ();
371 inline bool isProcessing ()
const;
372 inline bool interrupted ()
const;
373 inline size_t getPendings ()
const;
374 inline void openRefreshSession ();
375 inline void closeRefreshSession ();
378 list<RedrawEvent*> _events;
387 enum Ids { Normal = 0
398 class DrawingPlanes {
400 DrawingPlanes (
const QSize& size, CellWidget* cw );
402 inline bool getLineMode ()
const;
403 inline size_t getWorkingPlane ()
const;
404 inline void pushWorkingPlane ();
405 inline void popWorkingPlane ();
406 inline int width ()
const;
407 inline int height ()
const;
408 inline QSize size ()
const;
409 inline void select (
size_t i );
410 inline QPainter& painter (
size_t i=PlaneId::Working );
411 inline void begin (
size_t i=PlaneId::Working );
412 inline void end (
size_t i=PlaneId::Working );
413 inline void buffersBegin ();
414 inline void buffersEnd ();
415 void setLineMode (
bool mode );
416 void setPen (
const QPen& pen );
417 void setBrush (
const QBrush& brush );
418 void setBackground (
const QBrush& brush );
419 void setBackgroundMode ( Qt::BGMode mode );
420 void resize (
const QSize& size );
421 void shiftLeft (
int dx );
422 void shiftRight (
int dx );
423 void shiftUp (
int dy );
424 void shiftDown (
int dy );
425 inline void copyToSelect ();
426 inline void copyToSelect (
const QRect& );
427 void copyToSelect (
int sx,
int sy,
int h,
int w );
428 inline void copyToScreen ();
429 void copyToScreen (
int sx,
int sy,
int h,
int w );
430 inline void copyToPrinter (
int xpaper,
int ypaper, QPrinter*, CellWidget::PainterCb_t& );
431 void copyToPrinter (
int xpaper,
int ypaper,
int sx,
int sy,
int h,
int w, QPrinter*, CellWidget::PainterCb_t& );
432 inline void copyToImage ( QImage*, CellWidget::PainterCb_t& );
433 void copyToImage (
int sx,
int sy,
int h,
int w, QImage*, CellWidget::PainterCb_t& );
435 static const int _cartoucheWidth;
436 static const int _cartoucheHeight;
437 static const int _titleHeight;
438 CellWidget* _cellWidget;
442 QPainter _painters[PlaneId::Working];
446 size_t _workingPlane;
447 size_t _pushWorkingPlane;
450 DrawingPlanes (
const DrawingPlanes& );
451 DrawingPlanes& operator= (
const DrawingPlanes& );
455 class DrawingQuery :
public Query {
457 DrawingQuery ( CellWidget* widget );
458 inline void setQuery (
const Box& area
459 ,
const Transformation& transformation
460 ,
const BasicLayer* basicLayer
461 , ExtensionSlice::Mask extensionMask
462 ,
unsigned int filter
464 inline void addDrawExtensionGo (
const Name&
468 inline void copyDrawExtensionGos (
const DrawingQuery& );
469 void setDrawExtensionGo (
const Name& );
470 virtual bool hasMasterCellCallback ()
const;
471 virtual bool hasGoCallback ()
const;
472 virtual bool hasMarkerCallback ()
const;
473 virtual bool hasRubberCallback ()
const;
474 virtual bool hasExtensionGoCallback ()
const;
475 virtual void masterCellCallback ();
476 virtual void goCallback ( Go* );
477 virtual void rubberCallback ( Rubber* );
478 virtual void markerCallback ( Marker* );
479 virtual void extensionGoCallback ( Go* );
480 void drawMasterCell (
const Cell* cell
481 ,
const Transformation& transformation
483 void drawGo (
const Go* go
484 ,
const BasicLayer* basicLayer
486 ,
const Transformation& transformation
488 void drawRubber (
const Rubber* rubber
490 ,
const Transformation& transformation
492 void drawMarker (
const Marker* marker
494 ,
const Transformation& transformation
496 void drawExtensionGo ( CellWidget* widget
498 ,
const BasicLayer* basicLayer
500 ,
const Transformation& transformation
502 inline unsigned int getGoCount ()
const;
503 inline unsigned int getExtensionGoCount ()
const;
504 inline unsigned int getInstanceCount ()
const;
505 inline void resetGoCount ();
506 inline void resetExtensionGoCount ();
507 inline void resetInstanceCount ();
510 CellWidget* _cellWidget;
511 DrawExtensionGo_t* _drawExtensionGo;
512 map<Name,pair<InitExtensionGo_t*,DrawExtensionGo_t*> >
514 unsigned int _goCount;
515 unsigned int _extensionGoCount;
516 unsigned int _instanceCount;
520 class TextDrawingQuery :
public Query {
522 TextDrawingQuery ( CellWidget* widget );
523 inline void setQuery (
const Box& area
524 ,
const Transformation& transformation
526 virtual bool hasMasterCellCallback ()
const;
527 virtual bool hasGoCallback ()
const;
528 virtual bool hasRubberCallback ()
const;
529 virtual bool hasExtensionGoCallback ()
const;
530 virtual void masterCellCallback ();
531 virtual void goCallback ( Go* go );
532 virtual void extensionGoCallback ( Go* go );
533 virtual void rubberCallback ( Rubber* );
536 CellWidget* _cellWidget;
540 class SelectorCriterions {
542 SelectorCriterions ();
543 ~SelectorCriterions ();
544 inline void setCellWidget ( CellWidget* );
545 inline const vector<SelectorCriterion*>& getCriterions ()
const;
546 SelectorCriterion* add ( Occurrence netOccurrence );
547 SelectorCriterion* add ( Box area );
548 inline SelectorCriterion* add ( SelectorCriterion* );
549 bool remove ( Occurrence netOccurrence );
553 inline size_t size ()
const;
555 CellWidget* _cellWidget;
556 vector<SelectorCriterion*> _criterions;
562 inline State ( Cell* cell=NULL, Path topPath=Path() );
563 State* clone ()
const;
564 inline void setCell ( Cell* );
565 inline void setTopPath ( Path );
566 inline void setCellWidget ( CellWidget* );
570 inline void setDbuMode (
int );
572 inline void setShowBoundaries (
bool );
573 inline void setShowSelection (
bool );
574 inline void setCumulativeSelection (
bool );
575 void setScale (
float );
577 inline void setTopLeft (
const Point& );
578 inline void setQueryFilter ( Query::Mask );
579 inline void setStartLevel (
int );
580 inline void setStopLevel (
int );
581 inline void setRubberShape ( RubberShape );
582 inline void setHistoryEnable (
bool );
583 bool scaleHistoryUp ();
584 bool scaleHistoryDown ();
585 inline Cell* getCell ()
const;
586 inline Cell* getTopCell ()
const;
587 inline Path getTopPath ()
const;
588 const Name& getName ()
const;
589 inline SelectorCriterions& getSelection ();
590 inline RulerSet& getRulers ();
592 inline unsigned int getDbuMode ()
const;
593 inline bool gridMode ()
const;
594 inline bool symbolicMode ()
const;
595 inline bool physicalMode ()
const;
596 inline bool nanoMode ()
const;
597 inline bool microMode ()
const;
598 inline bool showBoundaries ()
const;
599 inline bool showSelection ()
const;
600 inline bool cumulativeSelection ()
const;
601 inline bool getHistoryEnable ()
const;
602 inline size_t getHistorySize ()
const;
603 inline const float& getScale ()
const;
604 inline const Point& getTopLeft ()
const;
605 inline Query::Mask getQueryFilter ()
const;
606 inline int getStartLevel ()
const;
607 inline int getStopLevel ()
const;
608 inline RubberShape getRubberShape ()
const;
613 inline ScaleEntry (
float,
const Point& );
622 Name _hierarchicalName;
623 CellWidget* _cellWidget;
624 SelectorCriterions _selection;
627 unsigned int _dbuMode;
629 bool _showBoundaries;
631 Query::Mask _queryFilter;
634 RubberShape _rubberShape;
635 bool _cumulativeSelection;
636 vector<ScaleEntry> _scaleHistory;
641 class FindStateName :
public unary_function< const shared_ptr<State>&, bool > {
643 inline FindStateName (
const Name& );
644 inline bool operator() (
const shared_ptr<State>& );
646 const Name _cellHierName;
651 vector<Qt::CursorShape> _cursors;
653 Technology* _technology;
654 PaletteWidget* _palette;
656 RedrawManager _redrawManager;
657 DrawingPlanes _drawingPlanes;
658 DrawingQuery _drawingQuery;
659 TextDrawingQuery _textDrawingQuery;
660 DisplayStyle::HSVr _darkening;
661 QPoint _mousePosition;
663 shared_ptr<State> _state;
667 bool _enableRedrawInterrupt;
668 int _delaySelectionChanged;
669 SelectorSet _selectors;
670 Command* _activeCommand;
671 vector<Command*> _commands;
672 size_t _redrawRectCount;
676 friend class RedrawManager;
680 inline void CellWidget::Spot::setShowSpot (
bool show )
681 { _showSpot = show; }
684 inline const QPoint& CellWidget::Spot::getSpotPoint ()
const
685 {
return _spotPoint; }
688 inline void CellWidget::DrawingQuery::setQuery (
const Box& area
689 ,
const Transformation& transformation
690 ,
const BasicLayer* basicLayer
691 , ExtensionSlice::Mask extensionMask
692 ,
unsigned int filter
705 inline void CellWidget::setEnableRedrawInterrupt (
bool state )
706 { _enableRedrawInterrupt = state; }
709 inline void CellWidget::openRefreshSession ()
710 { _redrawManager.openRefreshSession (); }
713 inline void CellWidget::closeRefreshSession ()
714 { _redrawManager.closeRefreshSession (); }
717 inline void CellWidget::DrawingQuery::addDrawExtensionGo (
const Name& name
718 , InitExtensionGo_t* initExtensionGo
719 , DrawExtensionGo_t* drawExtensionGo
721 { _drawExtensionGos[name] = make_pair(initExtensionGo,drawExtensionGo); }
724 inline void CellWidget::DrawingQuery::copyDrawExtensionGos (
const CellWidget::DrawingQuery& other )
725 { _drawExtensionGos = other._drawExtensionGos; }
728 inline void CellWidget::DrawingQuery::resetGoCount ()
732 inline void CellWidget::DrawingQuery::resetExtensionGoCount ()
733 { _extensionGoCount = 0; }
736 inline void CellWidget::DrawingQuery::resetInstanceCount ()
737 { _instanceCount = 0; }
740 inline unsigned int CellWidget::DrawingQuery::getGoCount ()
const
744 inline unsigned int CellWidget::DrawingQuery::getExtensionGoCount ()
const
745 {
return _extensionGoCount; }
748 inline unsigned int CellWidget::DrawingQuery::getInstanceCount ()
const
749 {
return _instanceCount; }
752 inline CellWidget::RedrawEvent::EventType CellWidget::RedrawEvent::getType ()
const
756 inline int CellWidget::RedrawEvent::getShift ()
const
760 inline bool CellWidget::RedrawManager::isProcessing ()
const
761 {
return _processing; }
764 inline void CellWidget::RedrawManager::stopProcessing ()
765 { _processing =
false; }
768 inline size_t CellWidget::RedrawManager::getPendings ()
const
769 {
return _events.size(); }
772 inline void CellWidget::RedrawManager::openRefreshSession ()
773 { _refreshSession++; }
776 inline void CellWidget::RedrawManager::closeRefreshSession ()
779 if ( !_processing && (_refreshSession == 0) ) process ();
783 inline bool CellWidget::RedrawManager::interrupted ()
const
785 #ifdef ALLOW_REQUEST_INTERRUPT
786 return ( _events.size() > 5 ) || _interrupted;
793 inline bool CellWidget::DrawingPlanes::getLineMode ()
const
794 {
return _lineMode; }
797 inline size_t CellWidget::DrawingPlanes::getWorkingPlane ()
const
798 {
return _workingPlane; }
801 inline void CellWidget::DrawingPlanes::pushWorkingPlane ()
802 { _pushWorkingPlane = _workingPlane; }
805 inline void CellWidget::DrawingPlanes::popWorkingPlane ()
806 { _workingPlane = _pushWorkingPlane; }
809 inline int CellWidget::DrawingPlanes::width ()
const
810 {
return _planes[PlaneId::Normal]->width(); }
813 inline int CellWidget::DrawingPlanes::height ()
const
814 {
return _planes[PlaneId::Normal]->height(); }
817 inline QSize CellWidget::DrawingPlanes::size ()
const
818 {
return _planes[PlaneId::Normal]->size(); }
821 inline void CellWidget::DrawingPlanes::select (
size_t i )
822 { _workingPlane = i; }
825 inline QPainter& CellWidget::DrawingPlanes::painter (
size_t i )
826 {
return _painters[ (i>=PlaneId::Working) ? _workingPlane : i ]; }
829 inline void CellWidget::DrawingPlanes::begin (
size_t i )
831 size_t wp = (i>=PlaneId::Working) ? _workingPlane : i;
833 case PlaneId::Normal:
834 case PlaneId::Selection:
835 case PlaneId::AutoCopy: _painters[wp ].begin( _planes[wp] );
break;
836 case PlaneId::Widget: _painters[PlaneId::Widget ].begin( _cellWidget );
break;
837 case PlaneId::Printer: _painters[PlaneId::Printer].begin( _printer );
break;
838 case PlaneId::Image: _painters[PlaneId::Image ].begin( _image );
break;
840 std::cerr <<
"[BUG] Bad plane selection." << std::endl;
845 inline void CellWidget::DrawingPlanes::end (
size_t i )
846 { _painters[(i>=PlaneId::Working)?_workingPlane:i].end (); }
849 inline void CellWidget::DrawingPlanes::buffersBegin ()
851 begin( PlaneId::Normal );
852 begin( PlaneId::Selection );
853 begin( PlaneId::AutoCopy );
857 inline void CellWidget::DrawingPlanes::buffersEnd ()
859 end( PlaneId::Normal );
860 end( PlaneId::Selection );
861 end( PlaneId::AutoCopy );
865 inline void CellWidget::DrawingPlanes::copyToSelect ()
866 { copyToSelect ( 0, 0, width(), height() ); }
869 inline void CellWidget::DrawingPlanes::copyToSelect (
const QRect& r )
870 { copyToSelect ( r.x(), r.y(), r.width(), r.height() ); }
873 inline void CellWidget::DrawingPlanes::copyToScreen ()
874 { copyToScreen ( 0, 0, width(), height() ); }
877 inline void CellWidget::DrawingPlanes::copyToPrinter (
int xpaper,
int ypaper, QPrinter* printer, CellWidget::PainterCb_t& cb )
879 copyToPrinter ( xpaper
883 , _cellWidget->geometry().width()
884 , _cellWidget->geometry().height()
891 inline void CellWidget::DrawingPlanes::copyToImage ( QImage* image, CellWidget::PainterCb_t& cb )
895 , _cellWidget->geometry().width()
896 , _cellWidget->geometry().height()
903 inline void CellWidget::SelectorCriterions::setCellWidget ( CellWidget* cw )
904 { _cellWidget = cw; }
907 inline size_t CellWidget::SelectorCriterions::size ()
const
908 {
return _criterions.size(); }
911 inline const vector<SelectorCriterion*>& CellWidget::SelectorCriterions::getCriterions ()
const
912 {
return _criterions; }
915 inline SelectorCriterion* CellWidget::SelectorCriterions::add ( SelectorCriterion* criterion )
917 _criterions.push_back( criterion );
918 return _criterions.back();
922 inline CellWidget::State::ScaleEntry::ScaleEntry (
float scale,
const Point& topLeft )
923 : _scale(scale), _topLeft(topLeft)
927 inline CellWidget::State::State ( Cell* cell, Path topPath )
930 , _hierarchicalName ()
934 , _cursorStep (DbU::lambda(0.5))
935 , _dbuMode (DbU::Symbolic)
936 , _unitPower (DbU::Nano)
937 , _showBoundaries (true)
938 , _showSelection (false)
939 , _queryFilter (~Query::DoTerminalCells)
942 , _rubberShape (CellWidget::Barycentric)
943 , _cumulativeSelection(false)
946 , _historyEnable (false)
948 _scaleHistory.push_back ( ScaleEntry(1.0,Point(0,0)) );
949 if (_cell) _hierarchicalName = Name( _cell->getHierarchicalName() );
953 inline unsigned int CellWidget::State::getDbuMode ()
const
957 inline bool CellWidget::State::symbolicMode ()
const
961 inline bool CellWidget::State::gridMode ()
const
965 inline bool CellWidget::State::physicalMode ()
const
966 {
return (_dbuMode == DbU::Physical); }
969 inline void CellWidget::State::setCell ( Cell* cell )
972 if (_cell) _hierarchicalName = Name( _cell->getHierarchicalName() );
976 inline void CellWidget::State::setTopPath ( Path topPath )
977 { _topPath = topPath; }
980 inline void CellWidget::State::setCellWidget ( CellWidget* cw )
983 _selection.setCellWidget ( cw );
987 inline void CellWidget::State::setCursorStep (
DbU::Unit step )
988 { _cursorStep = step; }
990 inline DbU::Unit CellWidget::State::getCursorStep ()
const
991 {
return _cursorStep; }
995 {
return _unitPower; }
998 inline void CellWidget::State::setDbuMode (
int mode )
1001 switch ( _dbuMode ) {
1004 case DbU::Physical: _cursorStep =
DbU::fromGrid (1.0);
break;
1013 inline void CellWidget::State::setShowBoundaries (
bool state )
1014 { _showBoundaries = state; }
1017 inline void CellWidget::State::setShowSelection (
bool state )
1018 { _showSelection = state; }
1021 inline void CellWidget::State::setCumulativeSelection (
bool state )
1022 { _cumulativeSelection = state; }
1027 _scaleHistory[_ihistory]._topLeft.setX(x);
1028 _scaleHistory[_ihistory]._topLeft.setY(y);
1032 inline void CellWidget::State::setTopLeft (
const Point& topLeft )
1033 { _scaleHistory[_ihistory]._topLeft = topLeft; }
1036 inline void CellWidget::State::setQueryFilter ( Query::Mask mask )
1037 { _queryFilter = mask; }
1040 inline void CellWidget::State::setStartLevel (
int level )
1041 { _startLevel = level; }
1044 inline void CellWidget::State::setStopLevel (
int level )
1045 { _stopLevel = level; }
1048 inline void CellWidget::State::setRubberShape ( RubberShape shape )
1049 { _rubberShape = shape; }
1052 inline void CellWidget::State::setHistoryEnable (
bool enable )
1053 { _historyEnable = enable; }
1056 inline Cell* CellWidget::State::getCell ()
const
1060 inline Path CellWidget::State::getTopPath ()
const
1061 {
return _topPath; }
1064 inline Cell* CellWidget::State::getTopCell ()
const
1065 {
return (_topPath.isEmpty()) ? _cell : _topPath.getOwnerCell(); }
1068 inline DbU::Unit CellWidget::State::cursorStep ()
const
1069 {
return _cursorStep; }
1072 inline CellWidget::SelectorCriterions& CellWidget::State::getSelection ()
1073 {
return _selection; }
1076 inline RulerSet& CellWidget::State::getRulers ()
1080 inline bool CellWidget::State::showBoundaries ()
const
1081 {
return _showBoundaries; }
1084 inline bool CellWidget::State::showSelection ()
const
1085 {
return _showSelection; }
1088 inline bool CellWidget::State::cumulativeSelection ()
const
1089 {
return _cumulativeSelection; }
1092 inline bool CellWidget::State::getHistoryEnable ()
const
1093 {
return _historyEnable; }
1096 inline size_t CellWidget::State::getHistorySize ()
const
1097 {
return _scaleHistory.size(); }
1100 inline const Point& CellWidget::State::getTopLeft ()
const
1101 {
return _scaleHistory[_ihistory]._topLeft; }
1104 inline Query::Mask CellWidget::State::getQueryFilter ()
const
1105 {
return _queryFilter; }
1108 inline int CellWidget::State::getStartLevel ()
const
1109 {
return _startLevel; }
1112 inline int CellWidget::State::getStopLevel ()
const
1113 {
return _stopLevel; }
1116 inline CellWidget::RubberShape CellWidget::State::getRubberShape ()
const
1117 {
return _rubberShape; }
1120 inline const float& CellWidget::State::getScale ()
const
1121 {
return _scaleHistory[_ihistory]._scale; }
1124 inline void CellWidget::setPixelThreshold (
int pixelThreshold )
1125 { _pixelThreshold = pixelThreshold; }
1128 inline int CellWidget::getPixelThreshold ()
const
1129 {
return _pixelThreshold; }
1132 inline CellWidget::FindStateName::FindStateName (
const Name& cellHierName )
1133 : unary_function< const shared_ptr<State>&, bool >()
1134 , _cellHierName(cellHierName)
1138 inline bool CellWidget::FindStateName::operator () (
const shared_ptr<State>& state )
1139 {
return state->getName() == _cellHierName; }
1142 inline void CellWidget::setActiveCommand ( Command* command )
1143 { _activeCommand = command; }
1146 inline Command* CellWidget::getActiveCommand ()
const
1147 {
return _activeCommand; }
1150 inline void CellWidget::resetActiveCommand ()
1151 { _activeCommand = NULL; }
1154 inline void CellWidget::setCursorStep (
DbU::Unit step )
1155 { _state->setCursorStep(step); }
1158 inline void CellWidget::setRealSnapGridStep (
DbU::Unit step )
1162 inline shared_ptr<CellWidget::State>& CellWidget::getState ()
1164 _state->setTopLeft ( getTopLeft() );
1169 inline shared_ptr<CellWidget::State> CellWidget::getStateClone ()
1171 _state->setTopLeft ( getTopLeft() );
1172 return shared_ptr<State>( _state->clone() );
1176 inline void CellWidget::addDrawExtensionGo (
const Name& name
1177 , InitExtensionGo_t* initExtensionGo
1178 , DrawExtensionGo_t* drawExtensionGo
1180 { _drawingQuery.addDrawExtensionGo( name, initExtensionGo, drawExtensionGo ); }
1183 inline void CellWidget::copyDrawExtensionGos (
const CellWidget* other )
1184 { _drawingQuery.copyDrawExtensionGos( other->_drawingQuery ); }
1187 inline void CellWidget::setStartLevel (
int level )
1189 _drawingQuery.setStartLevel ( level );
1190 _state->setStartLevel ( level );
1191 emit queryFilterChanged ();
1195 inline void CellWidget::setStopLevel (
int level )
1197 _drawingQuery.setStopLevel ( level );
1198 _state->setStopLevel ( level );
1199 emit queryFilterChanged ();
1203 inline int CellWidget::getStartLevel ()
const
1204 {
return _drawingQuery.getStartLevel (); }
1207 inline int CellWidget::getStopLevel ()
const
1208 {
return _drawingQuery.getStopLevel (); }
1211 inline CellWidget::DrawingPlanes& CellWidget::getDrawingPlanes ()
1212 {
return _drawingPlanes; }
1215 inline SelectorSet& CellWidget::getSelectorSet ()
1216 {
return _selectors; }
1219 Occurrences CellWidget::getOccurrencesUnder (
const QRect& area )
const
1220 {
return getOccurrencesUnder(screenToDbuBox(area)); }
1223 inline void CellWidget::addRuler (
const Point& origin,
const Point& extremity )
1225 _state->getRulers().insert ( shared_ptr<Ruler>(
new Ruler(origin,extremity) ) );
1230 inline void CellWidget::addRuler ( shared_ptr<Ruler> ruler )
1232 _state->getRulers().insert ( ruler );
1237 inline void CellWidget::clearRulers ()
1238 { _state->getRulers().clear (); refresh(); }
1241 inline void CellWidget::refresh (
bool fullRedraw )
1242 { _fullRedraw |= fullRedraw; _redrawManager.refresh(); }
1245 inline void CellWidget::redrawSelection ()
1246 { redrawSelection ( QRect(QPoint(0,0),_drawingPlanes.size()) ); }
1249 inline void CellWidget::copyToPrinter (
int xpaper,
int ypaper, QPrinter* printer, CellWidget::PainterCb_t& cb )
1250 { _drawingPlanes.copyToPrinter( xpaper, ypaper, printer, cb ); }
1253 inline void CellWidget::copyToImage ( QImage* image, PainterCb_t& cb )
1254 { _drawingPlanes.copyToImage ( image, cb ); }
1257 inline DbU::Unit CellWidget::toDbu (
float d )
const
1260 switch ( getDbuMode() ) {
1271 inline int CellWidget::dbuToScreenX (
DbU::Unit x )
const
1272 {
return (
int)rint ( (
float)( x - _screenArea.
getXMin() ) * getScale() ); }
1275 inline int CellWidget::dbuToScreenY (
DbU::Unit y )
const
1276 {
return (
int)rint ( (
float)( _screenArea.
getYMax() - y ) * getScale() ); }
1279 inline int CellWidget::dbuToScreenLength (
DbU::Unit length )
const
1280 {
return (
int)rint ( (
float)length * getScale() ); }
1284 {
return QPoint ( dbuToScreenX(x), dbuToScreenY(y) ); }
1287 inline QPoint CellWidget::dbuToScreenPoint (
const Point& point )
const
1288 {
return QPoint ( dbuToScreenX(point.getX()), dbuToScreenY(point.getY()) ); }
1291 inline DbU::Unit CellWidget::screenToDbuX (
int x )
const
1295 inline DbU::Unit CellWidget::screenToDbuY (
int y )
const
1299 inline DbU::Unit CellWidget::screenToDbuLength (
int length )
const
1300 {
return (
int)( (float)length / getScale() ); }
1303 inline Point CellWidget::screenToDbuPoint (
const QPoint& point )
const
1304 {
return Point ( screenToDbuX(point.x()), screenToDbuY(point.y()) ); }
1307 inline Box CellWidget::screenToDbuBox (
const QRect& rect )
const
1309 return Box ( screenToDbuX(rect.x())
1310 , screenToDbuY(rect.y())
1311 , screenToDbuX(rect.x()+rect.width ())
1312 , screenToDbuY(rect.y()+rect.height())
1317 inline Box& CellWidget::pixelInflate ( Box& box,
int pixels )
const
1318 {
return box.inflate(screenToDbuLength(pixels)); }
1321 inline Point CellWidget::getTopLeft ()
const
1325 inline Box CellWidget::getVisibleArea ()
const
1326 {
return computeVisibleArea(getScale()); }
1329 inline Cell* CellWidget::getCell ()
const
1330 {
return _state->getCell(); }
1333 inline Cell* CellWidget::getTopCell ()
const
1334 {
return _state->getTopCell(); }
1337 inline Path CellWidget::getTopPath ()
const
1338 {
return _state->getTopPath(); }
1341 inline PaletteWidget* CellWidget::getPalette ()
1342 {
return _palette; }
1345 inline DbU::Unit CellWidget::cursorStep ()
const
1346 {
return _state->cursorStep(); }
1349 inline unsigned int CellWidget::getDbuMode ()
const
1350 {
return _state->getDbuMode(); }
1353 inline bool CellWidget::gridMode ()
const
1354 {
return _state->gridMode(); }
1357 inline bool CellWidget::symbolicMode ()
const
1358 {
return _state->symbolicMode(); }
1361 inline bool CellWidget::physicalMode ()
const
1362 {
return _state->physicalMode(); }
1366 {
return _state->getUnitPower(); }
1369 inline bool CellWidget::showBoundaries ()
const
1370 {
return _state->showBoundaries(); }
1373 inline bool CellWidget::showSelection ()
const
1374 {
return _state->showSelection(); }
1377 inline bool CellWidget::cumulativeSelection ()
const
1378 {
return _state->cumulativeSelection(); }
1381 inline QPainter& CellWidget::getPainter (
size_t plane )
1382 {
return _drawingPlanes.painter(plane); }
1385 inline const DisplayStyle::HSVr& CellWidget::getDarkening ()
const
1386 {
return _darkening; }
1389 inline const float& CellWidget::getScale ()
const
1390 {
return _state->getScale(); }
1393 inline const QPoint& CellWidget::getMousePosition ()
const
1394 {
return _mousePosition; }
1397 inline void CellWidget::updateMousePosition ()
1399 Point mousePoint = screenToDbuPoint ( _mousePosition );
1400 emit mousePositionChanged ( _onCursorGrid(mousePoint) );
1404 inline void CellWidget::setQueryFilter ( Query::Mask filter )
1406 _state->setQueryFilter ( filter );
1407 emit queryFilterChanged ();
1411 inline Query::Mask CellWidget::getQueryFilter ()
const
1412 {
return _state->getQueryFilter(); }
1415 inline void CellWidget::setDbuMode (
int mode )
1416 { _state->setDbuMode(mode); }
1420 { _state->setUnitPower(p); }
1423 inline void CellWidget::setRubberShape ( RubberShape shape )
1425 _state->setRubberShape ( shape );
1427 emit queryFilterChanged ();
1431 inline CellWidget::RubberShape CellWidget::getRubberShape ()
const
1432 {
return _state->getRubberShape(); }
1435 inline void CellWidget::setPen (
const QPen& pen,
size_t plane )
1436 { _drawingPlanes.painter(plane).setPen(pen); }
1439 inline void CellWidget::setDarkening (
const DisplayStyle::HSVr& darkening )
1440 { _darkening = darkening; }
1443 inline bool CellWidget::isPrinter ()
const
1444 {
return _isPrinter; }
1447 inline void CellWidget::setPrinter (
bool state )
1448 { _isPrinter = state; }
1451 inline bool CellWidget::timeout (
const char* fname,
const Timer& timer,
double timeout,
bool& timedout )
const
1453 if ( timedout )
return true;
1454 if ( timer.getCombTimeOnTheFly() < timeout )
return false;
1457 cerr << Warning(
"CellWidget::%s(): timeout %.3f (limit:%.1f)."
1458 ,fname,timer.getCombTimeOnTheFly(),timeout) << endl;
1463 inline DbU::Unit CellWidget::_snapGridStep ()
const
1471 inline Point CellWidget::_onSnapGrid (
const Point& p )
const
1472 {
return Point(_onSnapGrid(p.getX()),_onSnapGrid(p.getY())); }
1479 inline Point CellWidget::_onCursorGrid (
const Point& p )
const
1480 {
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