- Adding function to correctly display routingGraph in knik

The dbuToDisplayRect function now has a boolean argument which is true by default and define the way the rectangle is passed to display.
    If true, it's like we pass 2 corners to define the rectangle
    If false, it's like we pass the bottom left corner, width and height (directly QT compliant)
This commit is contained in:
Damien Dupuis 2009-01-08 14:09:46 +00:00
parent 5afca323b2
commit ddc3e541f1
2 changed files with 43 additions and 10 deletions

View File

@ -541,6 +541,7 @@ namespace Hurricane {
, _cellWidget(widget) , _cellWidget(widget)
, _drawExtensionGo(NULL) , _drawExtensionGo(NULL)
, _goCount(0) , _goCount(0)
, _goExtensionCount(0)
, _instanceCount(0) , _instanceCount(0)
{ } { }
@ -631,9 +632,11 @@ namespace Hurricane {
, const Transformation& transformation , const Transformation& transformation
) )
{ {
if ( _drawExtensionGo ) if ( _drawExtensionGo ) {
_goExtensionCount++;
_drawExtensionGo ( widget, go, basicLayer, area, transformation ); _drawExtensionGo ( widget, go, basicLayer, area, transformation );
} }
}
bool CellWidget::DrawingQuery::hasRubberCallback () const bool CellWidget::DrawingQuery::hasRubberCallback () const
@ -1026,6 +1029,7 @@ namespace Hurricane {
Box redrawBox = displayToDbuBox ( redrawArea ); Box redrawBox = displayToDbuBox ( redrawArea );
_drawingQuery.resetGoCount (); _drawingQuery.resetGoCount ();
_drawingQuery.resetGoExtensionCount();
_drawingQuery.resetInstanceCount(); _drawingQuery.resetInstanceCount();
_drawingQuery.setExtensionMask ( 0 ); _drawingQuery.setExtensionMask ( 0 );
_drawingQuery.setArea ( redrawBox ); _drawingQuery.setArea ( redrawBox );
@ -1125,6 +1129,11 @@ namespace Hurricane {
<< " (" << setprecision(3) << (timer.getCombTime()/_drawingQuery.getGoCount()) << " s/go)"; << " (" << setprecision(3) << (timer.getCombTime()/_drawingQuery.getGoCount()) << " s/go)";
else else
cerr << " 0 Gos"; cerr << " 0 Gos";
if ( _drawingQuery.getGoExtensionCount() )
cerr << " " << _drawingQuery.getGoExtensionCount()
<< " (" << setprecision(3) << (timer.getCombTime()/_drawingQuery.getGoExtensionCount()) << " s/ego)";
else
cerr << " 0 eGos";
if ( _drawingQuery.getInstanceCount() ) if ( _drawingQuery.getInstanceCount() )
cerr << " " << _drawingQuery.getInstanceCount() cerr << " " << _drawingQuery.getInstanceCount()
<< " (" << setprecision(3) << (timer.getCombTime()/_drawingQuery.getInstanceCount()) << " s/inst)"; << " (" << setprecision(3) << (timer.getCombTime()/_drawingQuery.getInstanceCount()) << " s/inst)";
@ -1740,22 +1749,35 @@ namespace Hurricane {
} }
QRect CellWidget::dbuToDisplayRect ( DbU::Unit x1, DbU::Unit y1, DbU::Unit x2, DbU::Unit y2 ) const QRect CellWidget::dbuToDisplayRect ( DbU::Unit x1, DbU::Unit y1, DbU::Unit x2, DbU::Unit y2, bool usePoint ) const
{ {
if ( usePoint ) {
int width = dbuToDisplayX(x2) - dbuToDisplayX(x1);
int height = dbuToDisplayY(y1) - dbuToDisplayY(y2);
return QRect ( dbuToDisplayX(x1) return QRect ( dbuToDisplayX(x1)
, dbuToDisplayY(y2) , dbuToDisplayY(y2)
, dbuToDisplayX(x2) - dbuToDisplayX(x1) , width?width:1
, dbuToDisplayY(y1) - dbuToDisplayY(y2) , height?height:1
); );
} else {
int width = dbuToDisplayLength ( x2 - x1 );
int height = dbuToDisplayLength ( y2 - y1 );
return QRect ( dbuToDisplayX(x1)
, dbuToDisplayY(y2)
, width?width:1
, height?height:1
);
}
} }
QRect CellWidget::dbuToDisplayRect ( const Box& box ) const QRect CellWidget::dbuToDisplayRect ( const Box& box, bool usePoint ) const
{ {
return dbuToDisplayRect ( box.getXMin() return dbuToDisplayRect ( box.getXMin()
, box.getYMin() , box.getYMin()
, box.getXMax() , box.getXMax()
, box.getYMax() , box.getYMax()
, usePoint
); );
} }

View File

@ -150,8 +150,8 @@ namespace Hurricane {
void drawScreenRect ( const QRect& , size_t plane=PlaneId::Working ); void drawScreenRect ( const QRect& , size_t plane=PlaneId::Working );
void drawScreenPolyline ( const QPoint*, int, int, size_t plane=PlaneId::Working ); void drawScreenPolyline ( const QPoint*, int, int, size_t plane=PlaneId::Working );
// Geometric conversions. // Geometric conversions.
QRect dbuToDisplayRect ( DbU::Unit x1, DbU::Unit y1, DbU::Unit x2, DbU::Unit y2 ) const; QRect dbuToDisplayRect ( DbU::Unit x1, DbU::Unit y1, DbU::Unit x2, DbU::Unit y2, bool usePoint=true ) const;
QRect dbuToDisplayRect ( const Box& box ) const; QRect dbuToDisplayRect ( const Box& box , bool usePoint=true ) const;
QPoint dbuToDisplayPoint ( DbU::Unit x, DbU::Unit y ) const; QPoint dbuToDisplayPoint ( DbU::Unit x, DbU::Unit y ) const;
QPoint dbuToDisplayPoint ( const Point& point ) const; QPoint dbuToDisplayPoint ( const Point& point ) const;
inline int dbuToDisplayX ( DbU::Unit x ) const; inline int dbuToDisplayX ( DbU::Unit x ) const;
@ -386,8 +386,10 @@ namespace Hurricane {
, const Transformation& transformation , const Transformation& transformation
); );
inline unsigned int getGoCount () const; inline unsigned int getGoCount () const;
inline unsigned int getGoExtensionCount () const;
inline unsigned int getInstanceCount () const; inline unsigned int getInstanceCount () const;
inline void resetGoCount (); inline void resetGoCount ();
inline void resetGoExtensionCount ();
inline void resetInstanceCount (); inline void resetInstanceCount ();
protected: protected:
@ -396,6 +398,7 @@ namespace Hurricane {
map<Name,pair<InitExtensionGo_t*,DrawExtensionGo_t*> > map<Name,pair<InitExtensionGo_t*,DrawExtensionGo_t*> >
_drawExtensionGos; _drawExtensionGos;
unsigned int _goCount; unsigned int _goCount;
unsigned int _goExtensionCount;
unsigned int _instanceCount; unsigned int _instanceCount;
}; };
@ -508,6 +511,10 @@ namespace Hurricane {
{ _goCount = 0; } { _goCount = 0; }
inline void CellWidget::DrawingQuery::resetGoExtensionCount ()
{ _goExtensionCount = 0; }
inline void CellWidget::DrawingQuery::resetInstanceCount () inline void CellWidget::DrawingQuery::resetInstanceCount ()
{ _instanceCount = 0; } { _instanceCount = 0; }
@ -516,6 +523,10 @@ namespace Hurricane {
{ return _goCount; } { return _goCount; }
inline unsigned int CellWidget::DrawingQuery::getGoExtensionCount () const
{ return _goExtensionCount; }
inline unsigned int CellWidget::DrawingQuery::getInstanceCount () const inline unsigned int CellWidget::DrawingQuery::getInstanceCount () const
{ return _instanceCount; } { return _instanceCount; }