Correct the garbled screen when shifting right in CellWidget.

* Bug: In Hurricane, In CellViewer, pass by a temporary pixmap when
    shitfing right (and bottom). We were already using the AutoCopy
    buffer for the opposites moves... Seems that the drawPixmap()
    may have changed of implementation.
      Explanation of the diagonal lines, see QTBUG-31579 that affect
    Qt 4.8.5. Temporary work around, force the pen to have a width
    of 2 pixels (for _normalPen & _linePen).
* Change: In Hurricane, in CellViewer remove the redraw by whole
    strip mechanism (offsetVA).
* New: In Hurricane, In CellViewer::DrawingPLanes add a tracking of
    the brush offset to avoid small irregularities at the border of
    two separately drawed areas.
* Bug: In Hurricane, in Graphics, display a warning about the
    diagonal lines when using Qt 4.8.5.
This commit is contained in:
Jean-Paul Chaput 2015-04-05 19:21:20 +02:00
parent c63ee783ed
commit d7ca2fb299
6 changed files with 219 additions and 314 deletions

View File

@ -207,14 +207,14 @@ namespace Hurricane {
{ {
#ifdef ALLOW_REQUEST_INTERRUPT #ifdef ALLOW_REQUEST_INTERRUPT
list<RedrawEvent*>::iterator ievent = _events.end(); list<RedrawEvent*>::iterator ievent = _events.end();
if ( !_events.empty() && (_events.back()->getType() == RedrawEvent::Refresh) ) if ( not _events.empty() && (_events.back()->getType() == RedrawEvent::Refresh) )
--ievent; --ievent;
_events.insert ( ievent, new RedrawEvent(RedrawEvent::GoLeft,shift,_widget) ); _events.insert( ievent, new RedrawEvent(RedrawEvent::GoLeft,shift,_widget) );
#else #else
_events.push_back ( new RedrawEvent(RedrawEvent::GoLeft,shift,_widget) ); _events.push_back( new RedrawEvent(RedrawEvent::GoLeft,shift,_widget) );
#endif #endif
if ( !_processing ) process (); if (not _processing) process();
} }
@ -222,14 +222,14 @@ namespace Hurricane {
{ {
#ifdef ALLOW_REQUEST_INTERRUPT #ifdef ALLOW_REQUEST_INTERRUPT
list<RedrawEvent*>::iterator ievent = _events.end(); list<RedrawEvent*>::iterator ievent = _events.end();
if ( !_events.empty() && (_events.back()->getType() == RedrawEvent::Refresh) ) if ( not _events.empty() && (_events.back()->getType() == RedrawEvent::Refresh) )
--ievent; --ievent;
_events.insert ( ievent, new RedrawEvent(RedrawEvent::GoRight,shift,_widget) ); _events.insert( ievent, new RedrawEvent(RedrawEvent::GoRight,shift,_widget) );
#else #else
_events.push_back ( new RedrawEvent(RedrawEvent::GoRight,shift,_widget) ); _events.push_back( new RedrawEvent(RedrawEvent::GoRight,shift,_widget) );
#endif #endif
if ( !_processing ) process (); if (not _processing) process();
} }
@ -344,7 +344,8 @@ namespace Hurricane {
, _image (NULL) , _image (NULL)
, _normalPen () , _normalPen ()
, _linePen () , _linePen ()
, _workingPlane(0) , _brushOrigin ()
, _workingPlane(PlaneId::Normal)
, _lineMode (false) , _lineMode (false)
{ {
for ( size_t i=0 ; i<3 ; i++ ) for ( size_t i=0 ; i<3 ; i++ )
@ -365,31 +366,39 @@ namespace Hurricane {
{ {
_normalPen = pen; _normalPen = pen;
_linePen = pen; _linePen = pen;
_linePen.setStyle ( Qt::SolidLine ); _linePen.setStyle( Qt::SolidLine );
_linePen.setWidth ( 1 );
if ( _lineMode ) painter().setPen ( _linePen ); #if (QT_VERSION == QT_VERSION_CHECK(4,8,5))
else painter().setPen ( _normalPen ); //cerr << "CellWidget::DrawingPlanes::setPen() Buggy 4.8.5 Qt, diagonal lines may appears..." << endl;
_normalPen.setWidth( 0 );
_linePen.setWidth( 2 );
#else
_linePen.setWidth( 1 );
#endif
if (_lineMode) painter().setPen( _linePen );
else painter().setPen( _normalPen );
} }
void CellWidget::DrawingPlanes::setBrush ( const QBrush& brush ) void CellWidget::DrawingPlanes::setBrush ( const QBrush& brush )
{ {
painter().setBrush ( brush ); painter().setBrush( brush );
painter().setBrushOrigin( _brushOrigin );
} }
void CellWidget::DrawingPlanes::setBackground ( const QBrush& brush ) void CellWidget::DrawingPlanes::setBackground ( const QBrush& brush )
{ {
painter().setBackground ( brush ); painter().setBackground( brush );
painter().setBackground ( brush ); painter().setBackground( brush );
} }
void CellWidget::DrawingPlanes::setBackgroundMode ( Qt::BGMode mode ) void CellWidget::DrawingPlanes::setBackgroundMode ( Qt::BGMode mode )
{ {
painter().setBackgroundMode ( mode ); painter().setBackgroundMode( mode );
painter().setBackgroundMode ( mode ); painter().setBackgroundMode( mode );
} }
@ -419,42 +428,64 @@ namespace Hurricane {
void CellWidget::DrawingPlanes::shiftLeft ( int dx ) void CellWidget::DrawingPlanes::shiftLeft ( int dx )
{ {
_brushOrigin.rx() += dx;
buffersBegin (); buffersBegin ();
_painters[PlaneId::AutoCopy ].drawPixmap( dx, 0, *_planes[PlaneId::Normal ], 0, 0, width()-dx, height() ); _painters[PlaneId::AutoCopy ].drawPixmap( dx, 0, *_planes[PlaneId::Normal ], 0, 0, width()-dx, height() );
_painters[PlaneId::Normal ].drawPixmap( 0, 0, *_planes[PlaneId::AutoCopy ], 0, 0, width() , height() ); _painters[PlaneId::Normal ].drawPixmap( 0, 0, *_planes[PlaneId::AutoCopy ], 0, 0, width() , height() );
if (_cellWidget->showSelection()) {
_painters[PlaneId::AutoCopy ].drawPixmap( dx, 0, *_planes[PlaneId::Selection], 0, 0, width()-dx, height() ); _painters[PlaneId::AutoCopy ].drawPixmap( dx, 0, *_planes[PlaneId::Selection], 0, 0, width()-dx, height() );
_painters[PlaneId::Selection].drawPixmap( 0, 0, *_planes[PlaneId::AutoCopy ], 0, 0, width() , height() ); _painters[PlaneId::Selection].drawPixmap( 0, 0, *_planes[PlaneId::AutoCopy ], 0, 0, width() , height() );
}
buffersEnd (); buffersEnd ();
} }
void CellWidget::DrawingPlanes::shiftRight ( int dx ) void CellWidget::DrawingPlanes::shiftRight ( int dx )
{ {
_brushOrigin.rx() -= dx;
buffersBegin (); buffersBegin ();
_painters[PlaneId::Normal ].drawPixmap ( 0, 0, *_planes[PlaneId::Normal ], dx, 0, width()-dx, height() ); _painters[PlaneId::AutoCopy ].drawPixmap( 0, 0, *_planes[PlaneId::Normal ], dx, 0, width()-dx, height() );
_painters[PlaneId::Selection].drawPixmap ( 0, 0, *_planes[PlaneId::Selection], dx, 0, width()-dx, height() ); _painters[PlaneId::Normal ].drawPixmap( 0, 0, *_planes[PlaneId::AutoCopy ], 0, 0, width()-dx, height() );
if (_cellWidget->showSelection()) {
_painters[PlaneId::AutoCopy ].drawPixmap( 0, 0, *_planes[PlaneId::Selection], dx, 0, width()-dx, height() );
_painters[PlaneId::Selection].drawPixmap( 0, 0, *_planes[PlaneId::AutoCopy ], 0, 0, width()-dx, height() );
}
buffersEnd (); buffersEnd ();
} }
void CellWidget::DrawingPlanes::shiftUp ( int dy ) void CellWidget::DrawingPlanes::shiftUp ( int dy )
{ {
buffersBegin (); _brushOrigin.ry() += dy;
_painters[PlaneId::AutoCopy ].drawPixmap ( 0, dy, *_planes[PlaneId::Normal ], 0, 0, width(), height()-dy );
_painters[PlaneId::Normal ].drawPixmap ( 0, 0, *_planes[PlaneId::AutoCopy ], 0, 0, width(), height() );
_painters[PlaneId::AutoCopy ].drawPixmap ( 0, dy, *_planes[PlaneId::Selection], 0, 0, width(), height()-dy ); buffersBegin ();
_painters[PlaneId::Selection].drawPixmap ( 0, 0, *_planes[PlaneId::AutoCopy ], 0, 0, width(), height() ); _painters[PlaneId::AutoCopy ].drawPixmap( 0, dy, *_planes[PlaneId::Normal ], 0, 0, width(), height()-dy );
_painters[PlaneId::Normal ].drawPixmap( 0, 0, *_planes[PlaneId::AutoCopy ], 0, 0, width(), height() );
if (_cellWidget->showSelection()) {
_painters[PlaneId::AutoCopy ].drawPixmap( 0, dy, *_planes[PlaneId::Selection], 0, 0, width(), height()-dy );
_painters[PlaneId::Selection].drawPixmap( 0, 0, *_planes[PlaneId::AutoCopy ], 0, 0, width(), height() );
}
buffersEnd (); buffersEnd ();
} }
void CellWidget::DrawingPlanes::shiftDown ( int dy ) void CellWidget::DrawingPlanes::shiftDown ( int dy )
{ {
_brushOrigin.ry() -= dy;
buffersBegin (); buffersBegin ();
_painters[PlaneId::Normal ].drawPixmap ( 0, 0, *_planes[PlaneId::Normal ], 0, dy, width(), height()-dy ); _painters[PlaneId::AutoCopy ].drawPixmap( 0, 0, *_planes[PlaneId::Normal ], 0, dy, width(), height()-dy );
_painters[PlaneId::Selection].drawPixmap ( 0, 0, *_planes[PlaneId::Selection], 0, dy, width(), height()-dy ); _painters[PlaneId::Normal ].drawPixmap( 0, 0, *_planes[PlaneId::AutoCopy ], 0, 0, width(), height()-dy );
if (_cellWidget->showSelection()) {
_painters[PlaneId::AutoCopy ].drawPixmap( 0, 0, *_planes[PlaneId::Selection], 0, dy, width(), height()-dy );
_painters[PlaneId::Selection].drawPixmap( 0, 0, *_planes[PlaneId::AutoCopy ], 0, 0, width(), height()-dy );
}
buffersEnd (); buffersEnd ();
} }
@ -477,14 +508,14 @@ namespace Hurricane {
_painters[PlaneId::Widget].drawPixmap _painters[PlaneId::Widget].drawPixmap
( sx, sy ( sx, sy
, *_planes[PlaneId::Selection] , *_planes[PlaneId::Selection]
, _cellWidget->getOffsetVA().rx()+sx, _cellWidget->getOffsetVA().ry()+sy , sx, sy
, w, h , w, h
); );
else else
_painters[PlaneId::Widget].drawPixmap _painters[PlaneId::Widget].drawPixmap
( sx, sy ( sx, sy
, *_planes[PlaneId::Normal] , *_planes[PlaneId::Normal]
, _cellWidget->getOffsetVA().rx()+sx, _cellWidget->getOffsetVA().ry()+sy , sx, sy
, w, h , w, h
); );
} }
@ -501,8 +532,6 @@ namespace Hurricane {
{ {
if (printer == NULL) return; if (printer == NULL) return;
cerr << "offsetVA:" << _cellWidget->getOffsetVA().rx() << "," << _cellWidget->getOffsetVA().ry() << endl;
_printer = printer; _printer = printer;
begin( PlaneId::Printer ); begin( PlaneId::Printer );
@ -510,14 +539,14 @@ namespace Hurricane {
_painters[PlaneId::Printer].drawPixmap _painters[PlaneId::Printer].drawPixmap
( xpaper, ypaper ( xpaper, ypaper
, *_planes[PlaneId::Selection] , *_planes[PlaneId::Selection]
, _cellWidget->getOffsetVA().rx()+sx, _cellWidget->getOffsetVA().ry()+sy , sx, sy
, w, h , w, h
); );
else else
_painters[PlaneId::Printer].drawPixmap _painters[PlaneId::Printer].drawPixmap
( xpaper, ypaper ( xpaper, ypaper
, *_planes[PlaneId::Normal] , *_planes[PlaneId::Normal]
, _cellWidget->getOffsetVA().rx()+sx, _cellWidget->getOffsetVA().ry()+sy , sx, sy
, w, h , w, h
); );
@ -543,7 +572,7 @@ namespace Hurricane {
_painters[PlaneId::Image].drawPixmap _painters[PlaneId::Image].drawPixmap
( ximage, yimage ( ximage, yimage
, *_planes[PlaneId::Selection] , *_planes[PlaneId::Selection]
, _cellWidget->getOffsetVA().rx()+sx, _cellWidget->getOffsetVA().ry()+sy , sx, sy
, w, h , w, h
); );
} }
@ -551,7 +580,7 @@ namespace Hurricane {
_painters[PlaneId::Image].drawPixmap _painters[PlaneId::Image].drawPixmap
( ximage, yimage ( ximage, yimage
, *_planes[PlaneId::Normal] , *_planes[PlaneId::Normal]
, _cellWidget->getOffsetVA().rx()+sx, _cellWidget->getOffsetVA().ry()+sy , sx, sy
, w, h , w, h
); );
} }
@ -638,7 +667,7 @@ namespace Hurricane {
if ( component ) { if ( component ) {
_goCount++; _goCount++;
Box bb = transformation.getBox(component->getBoundingBox(basicLayer)); Box bb = transformation.getBox(component->getBoundingBox(basicLayer));
rectangle = _cellWidget->dbuToDisplayRect ( bb ); rectangle = _cellWidget->dbuToScreenRect ( bb );
state = ( (rectangle.width() > 2) ? 1:0) | ( (rectangle.height() > 2) ? 2:0); state = ( (rectangle.width() > 2) ? 1:0) | ( (rectangle.height() > 2) ? 2:0);
switch ( state ) { switch ( state ) {
case 0: break; case 0: break;
@ -708,11 +737,11 @@ namespace Hurricane {
unsigned int flags = BigFont|Bold|Frame; unsigned int flags = BigFont|Bold|Frame;
Box bb = transformation.getBox ( reference->getBoundingBox() ); Box bb = transformation.getBox ( reference->getBoundingBox() );
rectangle = _cellWidget->dbuToDisplayRect ( bb ); rectangle = _cellWidget->dbuToScreenRect ( bb );
//rectangle.adjust ( 10, 10, 10, 10 ); //rectangle.adjust ( 10, 10, 10, 10 );
if ( reference->getType() == Reference::Position ) { if ( reference->getType() == Reference::Position ) {
QPoint point = _cellWidget->dbuToDisplayPoint ( reference->getPoint() ); QPoint point = _cellWidget->dbuToScreenPoint ( reference->getPoint() );
rectangle.translate ( point.x() - rectangle.x(), point.y() - rectangle.y() ); rectangle.translate ( point.x() - rectangle.x(), point.y() - rectangle.y() );
flags |= Left; flags |= Left;
@ -755,9 +784,9 @@ namespace Hurricane {
switch ( _cellWidget->getRubberShape() ) { switch ( _cellWidget->getRubberShape() ) {
case CellWidget::Steiner: case CellWidget::Steiner:
center = _cellWidget->dbuToDisplayPoint(transformation.getPoint(rubber->getBarycenter())); center = _cellWidget->dbuToScreenPoint(transformation.getPoint(rubber->getBarycenter()));
forEach ( Hook*, hook, rubber->getHooks() ) { forEach ( Hook*, hook, rubber->getHooks() ) {
extremity = _cellWidget->dbuToDisplayPoint extremity = _cellWidget->dbuToScreenPoint
( transformation.getPoint(hook->getComponent()->getCenter()) ); ( transformation.getPoint(hook->getComponent()->getCenter()) );
steiner = QPoint ( extremity.x(), center.y() ); steiner = QPoint ( extremity.x(), center.y() );
_cellWidget->drawScreenLine ( center , steiner , PlaneId::Working, false ); _cellWidget->drawScreenLine ( center , steiner , PlaneId::Working, false );
@ -765,18 +794,18 @@ namespace Hurricane {
} }
break; break;
case CellWidget::Barycentric: case CellWidget::Barycentric:
center = _cellWidget->dbuToDisplayPoint(transformation.getPoint(rubber->getBarycenter())); center = _cellWidget->dbuToScreenPoint(transformation.getPoint(rubber->getBarycenter()));
forEach ( Hook*, hook, rubber->getHooks() ) { forEach ( Hook*, hook, rubber->getHooks() ) {
extremity = _cellWidget->dbuToDisplayPoint extremity = _cellWidget->dbuToScreenPoint
( transformation.getPoint(hook->getComponent()->getCenter()) ); ( transformation.getPoint(hook->getComponent()->getCenter()) );
_cellWidget->drawScreenLine ( center, extremity, PlaneId::Working, false ); _cellWidget->drawScreenLine ( center, extremity, PlaneId::Working, false );
} }
break; break;
case CellWidget::Centric: case CellWidget::Centric:
default: default:
center = _cellWidget->dbuToDisplayPoint(transformation.getPoint(rubber->getCenter())); center = _cellWidget->dbuToScreenPoint(transformation.getPoint(rubber->getCenter()));
forEach ( Hook*, hook, rubber->getHooks() ) { forEach ( Hook*, hook, rubber->getHooks() ) {
extremity = _cellWidget->dbuToDisplayPoint extremity = _cellWidget->dbuToScreenPoint
( transformation.getPoint(hook->getComponent()->getCenter()) ); ( transformation.getPoint(hook->getComponent()->getCenter()) );
_cellWidget->drawScreenLine ( center, extremity, PlaneId::Working, false ); _cellWidget->drawScreenLine ( center, extremity, PlaneId::Working, false );
} }
@ -1011,19 +1040,16 @@ namespace Hurricane {
// Class : "Hurricane::CellWidget". // Class : "Hurricane::CellWidget".
const int CellWidget::_stripWidth = 10; const int CellWidget::_initialSide = 400;
const int CellWidget::_initialSide = (400/_stripWidth)*_stripWidth;
CellWidget::CellWidget ( QWidget* parent ) CellWidget::CellWidget ( QWidget* parent )
: QWidget (parent) : QWidget (parent)
, _technology (NULL) , _technology (NULL)
, _palette (NULL) , _palette (NULL)
, _displayArea (0,0,_initialSide+2*_stripWidth,_initialSide+2*_stripWidth) , _screenArea (0,0,_initialSide,_initialSide)
, _visibleArea (_stripWidth,_stripWidth,_initialSide,_initialSide)
, _offsetVA (_stripWidth,_stripWidth)
, _redrawManager (this) , _redrawManager (this)
, _drawingPlanes (QSize(_initialSide+2*_stripWidth,_initialSide+2*_stripWidth),this) , _drawingPlanes (QSize(_initialSide,_initialSide),this)
, _drawingQuery (this) , _drawingQuery (this)
, _textDrawingQuery (this) , _textDrawingQuery (this)
, _darkening (DisplayStyle::HSVr()) , _darkening (DisplayStyle::HSVr())
@ -1262,11 +1288,11 @@ namespace Hurricane {
setDarkening ( (_state->showSelection()) ? Graphics::getDarkening() : DisplayStyle::HSVr() ); setDarkening ( (_state->showSelection()) ? Graphics::getDarkening() : DisplayStyle::HSVr() );
if ( getCell() ) { if ( getCell() ) {
Box redrawBox = displayToDbuBox ( redrawArea ); Box redrawBox = screenToDbuBox ( redrawArea );
_drawingQuery.resetGoCount (); _drawingQuery.resetGoCount ();
_drawingQuery.resetExtensionGoCount(); _drawingQuery.resetExtensionGoCount();
_drawingQuery.resetInstanceCount(); _drawingQuery.resetInstanceCount ();
_drawingQuery.setExtensionMask ( 0 ); _drawingQuery.setExtensionMask ( 0 );
_drawingQuery.setArea ( redrawBox ); _drawingQuery.setArea ( redrawBox );
_drawingQuery.setTransformation ( Transformation() ); _drawingQuery.setTransformation ( Transformation() );
@ -1410,7 +1436,7 @@ namespace Hurricane {
_drawingPlanes.painter().setClipRect ( redrawArea ); _drawingPlanes.painter().setClipRect ( redrawArea );
if ( getCell() ) { if ( getCell() ) {
Box redrawBox = displayToDbuBox ( redrawArea ); Box redrawBox = screenToDbuBox ( redrawArea );
SelectorSet::iterator iselector; SelectorSet::iterator iselector;
forEach ( BasicLayer*, basicLayer, _technology->getBasicLayers() ) { forEach ( BasicLayer*, basicLayer, _technology->getBasicLayers() ) {
@ -1555,7 +1581,7 @@ namespace Hurricane {
{ {
_redrawRectCount++; _redrawRectCount++;
_drawingPlanes.setLineMode ( false ); _drawingPlanes.setLineMode ( false );
_drawingPlanes.painter().drawRect ( dbuToDisplayRect(x1,y1,x2,y2) ); _drawingPlanes.painter().drawRect ( dbuToScreenRect(x1,y1,x2,y2) );
} }
@ -1563,13 +1589,13 @@ namespace Hurricane {
{ {
_redrawRectCount++; _redrawRectCount++;
_drawingPlanes.setLineMode ( false ); _drawingPlanes.setLineMode ( false );
_drawingPlanes.painter().drawRect ( dbuToDisplayRect(box) ); _drawingPlanes.painter().drawRect ( dbuToScreenRect(box) );
} }
void CellWidget::drawText ( const Point& point, const char* text, unsigned int flags, int angle ) void CellWidget::drawText ( const Point& point, const char* text, unsigned int flags, int angle )
{ {
drawDisplayText ( dbuToDisplayPoint(point), text, flags, angle ); drawDisplayText ( dbuToScreenPoint(point), text, flags, angle );
} }
@ -1643,7 +1669,7 @@ namespace Hurricane {
{ {
_redrawRectCount++; _redrawRectCount++;
_drawingPlanes.setLineMode ( mode ); _drawingPlanes.setLineMode ( mode );
_drawingPlanes.painter().drawLine ( dbuToDisplayPoint(x1,y1), dbuToDisplayPoint(x2,y2) ); _drawingPlanes.painter().drawLine ( dbuToScreenPoint(x1,y1), dbuToScreenPoint(x2,y2) );
} }
@ -1651,7 +1677,7 @@ namespace Hurricane {
{ {
_redrawRectCount++; _redrawRectCount++;
_drawingPlanes.setLineMode ( mode ); _drawingPlanes.setLineMode ( mode );
_drawingPlanes.painter().drawLine ( dbuToDisplayPoint(p1), dbuToDisplayPoint(p2) ); _drawingPlanes.painter().drawLine ( dbuToScreenPoint(p1), dbuToScreenPoint(p2) );
} }
@ -1713,7 +1739,7 @@ namespace Hurricane {
_drawingPlanes.painter ().setClipRect ( redrawArea ); _drawingPlanes.painter ().setClipRect ( redrawArea );
_drawingPlanes.painter ().setPen ( Graphics::getPen("grid") ); _drawingPlanes.painter ().setPen ( Graphics::getPen("grid") );
Box redrawBox = displayToDbuBox ( redrawArea ).inflate ( DbU::lambda(1.0) ); Box redrawBox = screenToDbuBox ( redrawArea ).inflate ( DbU::lambda(1.0) );
bool detailedGrid = _underDetailedGridThreshold(); bool detailedGrid = _underDetailedGridThreshold();
@ -1731,7 +1757,7 @@ namespace Hurricane {
; xGrid < redrawBox.getXMax() ; xGrid < redrawBox.getXMax()
; xGrid += gridStep ; xGrid += gridStep
) { ) {
center = dbuToDisplayPoint(xGrid,yGrid); center = dbuToScreenPoint(xGrid,yGrid);
if ( (xGrid % superGridStep) || (yGrid % superGridStep) ) { if ( (xGrid % superGridStep) || (yGrid % superGridStep) ) {
if ( detailedGrid ) { if ( detailedGrid ) {
_drawingPlanes.painter().drawPoint ( center ); _drawingPlanes.painter().drawPoint ( center );
@ -1759,7 +1785,7 @@ namespace Hurricane {
_drawingPlanes.painter ().setClipRect ( redrawArea ); _drawingPlanes.painter ().setClipRect ( redrawArea );
redrawArea.adjust ( -50, -50, 50, 50 ); redrawArea.adjust ( -50, -50, 50, 50 );
Box redrawBox = displayToDbuBox ( redrawArea ); Box redrawBox = screenToDbuBox ( redrawArea );
redrawArea.adjust ( 50, 50, -50, -50 ); redrawArea.adjust ( 50, 50, -50, -50 );
RulerSet::iterator iruler = _state->getRulers().begin(); RulerSet::iterator iruler = _state->getRulers().begin();
@ -1787,23 +1813,16 @@ namespace Hurricane {
QPoint pxOrigin; QPoint pxOrigin;
QPoint pxExtremity; QPoint pxExtremity;
QPoint pxAngle; QPoint pxAngle;
bool onScreen = ( _drawingPlanes.getWorkingPlane() > PlaneId::Selection );
// Never less than 5 pixels between two graduations ticks. // Never less than 5 pixels between two graduations ticks.
if ( symbolicMode() ) if ( symbolicMode() )
gradStep = DbU::lambda(pow(10.0,ceil(log10(DbU::getLambda(displayToDbuLength(50))))))/10; gradStep = DbU::lambda(pow(10.0,ceil(log10(DbU::getLambda(screenToDbuLength(50))))))/10;
else else
gradStep = DbU::grid(pow(10.0,ceil(log10(DbU::getGrid(displayToDbuLength(50))))))/10; gradStep = DbU::grid(pow(10.0,ceil(log10(DbU::getGrid(screenToDbuLength(50))))))/10;
if ( onScreen ) {
pxOrigin = dbuToScreenPoint ( origin ); pxOrigin = dbuToScreenPoint ( origin );
pxExtremity = dbuToScreenPoint ( extremity ); pxExtremity = dbuToScreenPoint ( extremity );
pxAngle = dbuToScreenPoint ( angle ); pxAngle = dbuToScreenPoint ( angle );
} else {
pxOrigin = dbuToDisplayPoint ( origin );
pxExtremity = dbuToDisplayPoint ( extremity );
pxAngle = dbuToDisplayPoint ( angle );
}
bool hRuler = ( abs(pxAngle.x() - pxOrigin.x()) >= abs(pxAngle.y() - pxOrigin.y()) ); bool hRuler = ( abs(pxAngle.x() - pxOrigin.x()) >= abs(pxAngle.y() - pxOrigin.y()) );
int pxGrad; int pxGrad;
@ -1830,8 +1849,7 @@ namespace Hurricane {
} else } else
if ( graduation <= angle.getX() ) break; if ( graduation <= angle.getX() ) break;
if ( onScreen ) pxGrad = dbuToScreenX ( graduation ); pxGrad = dbuToScreenX ( graduation );
else pxGrad = dbuToDisplayX ( graduation );
if ( tick % 10 ) { if ( tick % 10 ) {
@ -1892,8 +1910,7 @@ namespace Hurricane {
} else } else
if ( graduation <= angle.getY() ) break; if ( graduation <= angle.getY() ) break;
if ( onScreen ) pyGrad = dbuToScreenY ( graduation ); pyGrad = dbuToScreenY ( graduation );
else pyGrad = dbuToDisplayY ( graduation );
if ( tick % 10 ) { if ( tick % 10 ) {
_drawingPlanes.painter().drawLine ( pxOrigin.x() , pyGrad _drawingPlanes.painter().drawLine ( pxOrigin.x() , pyGrad
@ -1940,55 +1957,48 @@ namespace Hurricane {
void CellWidget::goLeft ( int dx ) void CellWidget::goLeft ( int dx )
{ {
if ( !dx ) dx = geometry().size().width() / 4; if (not dx) dx = geometry().size().width() / 4;
_redrawManager.goLeft( dx );
_redrawManager.goLeft ( dx );
} }
void CellWidget::goRight ( int dx ) void CellWidget::goRight ( int dx )
{ {
if ( !dx ) dx = geometry().size().width() / 4; if (not dx ) dx = geometry().size().width() / 4;
_redrawManager.goRight( dx );
_redrawManager.goRight ( dx );
} }
void CellWidget::goUp ( int dy ) void CellWidget::goUp ( int dy )
{ {
if ( !dy ) dy = geometry().size().height() / 4; if (not dy) dy = geometry().size().height() / 4;
_redrawManager.goUp( dy );
_redrawManager.goUp ( dy );
} }
void CellWidget::goDown ( int dy ) void CellWidget::goDown ( int dy )
{ {
if ( !dy ) dy = geometry().size().height() / 4; if (not dy) dy = geometry().size().height() / 4;
_redrawManager.goDown( dy );
_redrawManager.goDown ( dy );
} }
void CellWidget::displayReframe () void CellWidget::displayReframe ()
{ {
_offsetVA.rx() = _stripWidth; DbU::Unit xmin = (DbU::Unit)( _screenArea.getXMin() );
_offsetVA.ry() = _stripWidth;
DbU::Unit xmin = (DbU::Unit)( _visibleArea.getXMin() - ((float)_offsetVA.x()/getScale()) );
DbU::Unit xmax = (DbU::Unit)( xmin + ((float)_drawingPlanes.width()/getScale()) ) ; DbU::Unit xmax = (DbU::Unit)( xmin + ((float)_drawingPlanes.width()/getScale()) ) ;
DbU::Unit ymax = (DbU::Unit)( _visibleArea.getYMax() + ((float)_offsetVA.y()/getScale()) ); DbU::Unit ymax = (DbU::Unit)( _screenArea.getYMax() );
DbU::Unit ymin = (DbU::Unit)( ymax - ((float)_drawingPlanes.height()/getScale()) ) ; DbU::Unit ymin = (DbU::Unit)( ymax - ((float)_drawingPlanes.height()/getScale()) ) ;
_displayArea = Box ( xmin, ymin, xmax, ymax ); _screenArea = Box( xmin, ymin, xmax, ymax );
_redrawManager.refresh (); _redrawManager.refresh();
} }
Box CellWidget::computeVisibleArea ( float scale ) const Box CellWidget::computeVisibleArea ( float scale ) const
{ {
Point center = _visibleArea.getCenter(); Point center = _screenArea.getCenter();
//cerr << "center: " << center << " + scale:" << scale << endl; //cerr << "center: " << center << " + scale:" << scale << endl;
@ -2037,12 +2047,9 @@ namespace Hurricane {
//cerr << "CellWidget::setScale() - " << scale << endl; //cerr << "CellWidget::setScale() - " << scale << endl;
_state->setTopLeft ( getTopLeft() ); _state->setTopLeft ( getTopLeft() );
_visibleArea = computeVisibleArea ( scale ); _screenArea = computeVisibleArea ( scale );
_state->setScale ( scale ); _state->setScale ( scale );
//cerr << "_visibleArea: " << _visibleArea << " (offset: " << _offsetVA.x() << ")" << endl;
//cerr << " " << center << endl;
displayReframe (); displayReframe ();
} }
@ -2051,7 +2058,7 @@ namespace Hurricane {
{ {
_state->setTopLeft ( getTopLeft() ); _state->setTopLeft ( getTopLeft() );
if ( _state->scaleHistoryUp () ) { if ( _state->scaleHistoryUp () ) {
_visibleArea = computeVisibleArea ( _state->getScale(), _state->getTopLeft() ); _screenArea = computeVisibleArea ( _state->getScale(), _state->getTopLeft() );
displayReframe (); displayReframe ();
} }
} }
@ -2061,7 +2068,7 @@ namespace Hurricane {
{ {
_state->setTopLeft ( getTopLeft() ); _state->setTopLeft ( getTopLeft() );
if ( _state->scaleHistoryDown () ) { if ( _state->scaleHistoryDown () ) {
_visibleArea = computeVisibleArea ( _state->getScale(), _state->getTopLeft() ); _screenArea = computeVisibleArea ( _state->getScale(), _state->getTopLeft() );
displayReframe (); displayReframe ();
} }
} }
@ -2072,7 +2079,7 @@ namespace Hurricane {
//cerr << "CellWidget::reframe() - scale:" << _state->getScale() //cerr << "CellWidget::reframe() - scale:" << _state->getScale()
// << " topLeft:" << _state->getTopLeft() << endl; // << " topLeft:" << _state->getTopLeft() << endl;
_visibleArea = computeVisibleArea ( _state->getScale(), _state->getTopLeft() ); _screenArea = computeVisibleArea ( _state->getScale(), _state->getTopLeft() );
displayReframe (); displayReframe ();
} }
@ -2089,13 +2096,11 @@ namespace Hurricane {
_state->setTopLeft ( getTopLeft() ); _state->setTopLeft ( getTopLeft() );
float scale; float scale;
_visibleArea = computeVisibleArea ( box, scale ); _screenArea = computeVisibleArea ( box, scale );
_state->setScale ( scale ); _state->setScale ( scale );
displayReframe (); displayReframe ();
_state->setHistoryEnable ( backupHistoryEnable ); _state->setHistoryEnable ( backupHistoryEnable );
//cerr << " _displayArea: " << _displayArea << " (offset: " << _offsetVA.x() << ")" << endl;
} }
@ -2143,121 +2148,69 @@ namespace Hurricane {
void CellWidget::_goLeft ( int dx ) void CellWidget::_goLeft ( int dx )
{ {
//cerr << "CellWidget::_goLeft() - dx: " << dx << " (offset: " << _offsetVA.rx() << ")" << endl; //cerr << "CellWidget::_goLeft() - dx: " << dx << endl;
_visibleArea.translate ( - (DbU::Unit)( dx / getScale() ) , 0 ); _screenArea.translate( - (DbU::Unit)( dx / getScale() ) , 0 );
if ( _offsetVA.rx() - dx >= 0 ) { if (dx >= _drawingPlanes.width()) {
_offsetVA.rx() -= dx; _redrawManager.refresh();
repaint ();
return;
}
int shift = ( 1 + ( dx - _offsetVA.rx() ) / _stripWidth ) * _stripWidth;
_displayArea.translate ( - (DbU::Unit)( shift / getScale() ) , 0 );
_offsetVA.rx() -= dx - shift;
if ( shift >= _drawingPlanes.width() ) {
_redrawManager.refresh ();
} else { } else {
_drawingPlanes.shiftLeft ( shift ); _drawingPlanes.shiftLeft( dx );
_redraw ( QRect ( QPoint(0,0), QSize(shift,_drawingPlanes.height()) ) ); _redraw( QRect( QPoint(0,0), QSize(dx,_drawingPlanes.height()) ) );
} }
assert ( _offsetVA.rx() >= 0 );
} }
void CellWidget::_goRight ( int dx ) void CellWidget::_goRight ( int dx )
{ {
//cerr << "CellWidget::_goRight() - dx: " << dx << " (offset: " << _offsetVA.rx() << ")" << endl; //cerr << "CellWidget::_goRight() - dx: " << dx << endl;
_visibleArea.translate ( (DbU::Unit)( dx / getScale() ) , 0 ); _screenArea.translate( (DbU::Unit)( dx / getScale() ) , 0 );
if ( _offsetVA.rx() + dx < 2*_stripWidth ) { if (dx >= _drawingPlanes.width())
_offsetVA.rx() += dx;
repaint ();
return;
}
int shift = ( ( _offsetVA.rx() + dx ) / _stripWidth ) * _stripWidth;
_displayArea.translate ( (DbU::Unit)( shift / getScale() ) , 0 );
_offsetVA.rx() += dx - shift;
if ( shift >= _drawingPlanes.width() )
_redrawManager.refresh (); _redrawManager.refresh ();
else { else {
_drawingPlanes.shiftRight ( shift ); _drawingPlanes.shiftRight( dx );
_redraw ( QRect ( QPoint(_drawingPlanes.width()-shift,0) _redraw( QRect( QPoint(_drawingPlanes.width()-dx,0)
, QSize (shift,_drawingPlanes.height()) ) ); , QSize (dx,_drawingPlanes.height()) ) );
} }
assert ( _offsetVA.rx() >= 0 );
} }
void CellWidget::_goUp ( int dy ) void CellWidget::_goUp ( int dy )
{ {
//cerr << "CellWidget::_goUp() - " << dy << " (offset: " << _offsetVA.ry() << ")" << endl; //cerr << "CellWidget::_goUp() - " << dy << endl;
_visibleArea.translate ( 0, (DbU::Unit)( dy / getScale() ) ); _screenArea.translate( 0, (DbU::Unit)( dy / getScale() ) );
if ( _offsetVA.ry() - dy >= 0 ) { if (dy >= _drawingPlanes.height())
_offsetVA.ry() -= dy; _redrawManager.refresh();
repaint ();
return;
}
int shift = ( 1 + ( dy - _offsetVA.ry() ) / _stripWidth ) * _stripWidth;
_displayArea.translate ( 0, (DbU::Unit)( shift / getScale() ) );
_offsetVA.ry() -= dy - shift;
if ( shift >= _drawingPlanes.height() )
_redrawManager.refresh ();
else { else {
_drawingPlanes.shiftUp ( shift ); _drawingPlanes.shiftUp( dy );
_redraw ( QRect ( QPoint(0,0), QSize(_drawingPlanes.width(),shift) ) ); _redraw( QRect( QPoint(0,0), QSize(_drawingPlanes.width(),dy) ) );
} }
assert ( _offsetVA.ry() >= 0 );
} }
void CellWidget::_goDown ( int dy ) void CellWidget::_goDown ( int dy )
{ {
//cerr << "CellWidget::_goDown() - " << dy << " (offset: " << _offsetVA.ry() << ")" << endl; //cerr << "CellWidget::_goDown() - " << dy << endl;
_visibleArea.translate ( 0, - (DbU::Unit)( dy / getScale() ) ); _screenArea.translate( 0, - (DbU::Unit)( dy / getScale() ) );
if ( _offsetVA.ry() + dy < 2*_stripWidth ) { if (dy >= _drawingPlanes.height())
_offsetVA.ry() += dy; _redrawManager.refresh();
repaint ();
return;
}
int shift = ( ( _offsetVA.ry() + dy ) / _stripWidth ) * _stripWidth;
_displayArea.translate ( 0, - (DbU::Unit)( shift / getScale() ) );
_offsetVA.ry() += dy - shift;
if ( shift >= _drawingPlanes.height() )
_redrawManager.refresh ();
else { else {
_drawingPlanes.shiftDown ( shift ); _drawingPlanes.shiftDown( dy );
_redraw ( QRect ( QPoint (0,_drawingPlanes.height()-shift) _redraw( QRect( QPoint (0,_drawingPlanes.height()-dy)
, QSize (_drawingPlanes.width(), shift) ) ); , QSize (_drawingPlanes.width(), dy) ) );
} }
assert ( _offsetVA.ry() >= 0 );
} }
void CellWidget::_refresh () void CellWidget::_refresh ()
{ {
_redraw ( QRect(QPoint(0,0),_drawingPlanes.size()) ); _redraw( QRect(QPoint(0,0),_drawingPlanes.size()) );
} }
@ -2271,6 +2224,12 @@ namespace Hurricane {
void CellWidget::paintEvent ( QPaintEvent* event ) void CellWidget::paintEvent ( QPaintEvent* event )
{ {
// cerr << "CellWidget::paintEvent() - <QRect" << event->rect().x()
// << " " << event->rect().y()
// << " " << event->rect().width()
// << " " << event->rect().height()
// << ">" << endl;
// static Timer timer; // static Timer timer;
// static time_t prevTime = 0; // static time_t prevTime = 0;
// static time_t currTime = 0; // static time_t currTime = 0;
@ -2305,22 +2264,16 @@ namespace Hurricane {
QSize uaDelta ( 0, 0 ); QSize uaDelta ( 0, 0 );
QSize uaSize = geometry().size(); QSize uaSize = geometry().size();
uaSize.rwidth () += 2*_stripWidth; if (uaSize.width () > _drawingPlanes.width ())
uaSize.rheight() += 2*_stripWidth;
if ( uaSize.width () > _drawingPlanes.width () )
uaDelta.rwidth () = uaSize.width () - _drawingPlanes.width (); uaDelta.rwidth () = uaSize.width () - _drawingPlanes.width ();
if ( uaSize.height() > _drawingPlanes.height() ) if (uaSize.height() > _drawingPlanes.height())
uaDelta.rheight() = uaSize.height() - _drawingPlanes.height(); uaDelta.rheight() = uaSize.height() - _drawingPlanes.height();
if ( uaDelta.width() || uaDelta.height() ) { if (uaDelta.width() or uaDelta.height()) {
_displayArea.inflate ( 0, 0, (DbU::Unit)(uaDelta.width()/getScale()), (DbU::Unit)(uaDelta.height()/getScale()) ); _screenArea.inflate ( 0, (DbU::Unit)(uaDelta.height()/getScale()), (DbU::Unit)(uaDelta.width()/getScale()), 0 );
_visibleArea.inflate ( 0, 0, (DbU::Unit)(uaDelta.width()/getScale()), (DbU::Unit)(uaDelta.height()/getScale()) );
QSize bufferSize ( ( ( uaSize.width () / _stripWidth ) + 1 ) * _stripWidth _drawingPlanes.resize ( uaSize );
, ( ( uaSize.height() / _stripWidth ) + 1 ) * _stripWidth );
_drawingPlanes.resize ( bufferSize );
} }
_redrawManager.refresh (); _redrawManager.refresh ();
@ -2422,41 +2375,29 @@ namespace Hurricane {
} }
QPoint CellWidget::dbuToDisplayPoint ( DbU::Unit x, DbU::Unit y ) const QRect CellWidget::dbuToScreenRect ( DbU::Unit x1, DbU::Unit y1, DbU::Unit x2, DbU::Unit y2, bool usePoint ) const
{
return QPoint ( dbuToDisplayX(x), dbuToDisplayY(y) );
}
QPoint CellWidget::dbuToDisplayPoint ( const Point& point ) const
{
return dbuToDisplayPoint ( point.getX(), point.getY() );
}
QRect CellWidget::dbuToDisplayRect ( DbU::Unit x1, DbU::Unit y1, DbU::Unit x2, DbU::Unit y2, bool usePoint ) const
{ {
int width, height; int width, height;
if ( usePoint ) { if ( usePoint ) {
width = dbuToDisplayX(x2) - dbuToDisplayX(x1); width = dbuToScreenX(x2) - dbuToScreenX(x1);
height = dbuToDisplayY(y1) - dbuToDisplayY(y2); height = dbuToScreenY(y1) - dbuToScreenY(y2);
} else { } else {
width = dbuToDisplayLength ( x2 - x1 ); width = dbuToScreenLength ( x2 - x1 );
height = dbuToDisplayLength ( y2 - y1 ); height = dbuToScreenLength ( y2 - y1 );
} }
return QRect ( dbuToDisplayX(x1) return QRect ( dbuToScreenX(x1)
, dbuToDisplayY(y2) , dbuToScreenY(y2)
, width ? width : 1 , width ? width : 1
, height ? height : 1 , height ? height : 1
); );
} }
QRect CellWidget::dbuToDisplayRect ( const Box& box, bool usePoint ) const QRect CellWidget::dbuToScreenRect ( const Box& box, bool usePoint ) const
{ {
return dbuToDisplayRect ( box.getXMin() return dbuToScreenRect ( box.getXMin()
, box.getYMin() , box.getYMin()
, box.getXMax() , box.getXMax()
, box.getYMax() , box.getYMax()
@ -2465,12 +2406,6 @@ namespace Hurricane {
} }
QPoint CellWidget::dbuToScreenPoint ( DbU::Unit x, DbU::Unit y ) const
{
return QPoint ( dbuToScreenX(x), dbuToScreenY(y) );
}
void CellWidget::setCell ( Cell* cell ) void CellWidget::setCell ( Cell* cell )
{ {
//cerr << "CellWidget::setCell() - " << cell << endl; //cerr << "CellWidget::setCell() - " << cell << endl;

View File

@ -21,6 +21,7 @@
#include <QApplication> #include <QApplication>
#include "hurricane/Name.h" #include "hurricane/Name.h"
#include "hurricane/Exception.h" #include "hurricane/Exception.h"
#include "hurricane/Warning.h"
#include "hurricane/viewer/DisplayStyle.h" #include "hurricane/viewer/DisplayStyle.h"
#include "hurricane/viewer/Graphics.h" #include "hurricane/viewer/Graphics.h"
@ -69,13 +70,18 @@ namespace Hurricane {
Graphics* Graphics::getGraphics () Graphics* Graphics::getGraphics ()
{ {
if ( !_singleton ) { if (not _singleton) {
_singleton = new Graphics (); #if (QT_VERSION == QT_VERSION_CHECK(4,8,5))
DisplayStyle* fallback = new DisplayStyle("Fallback"); cerr << Warning( "Graphics::getGraphics() Using buggy Qt 4.8.5.\n"
fallback->setDescription ( "Builtin fallback style" ); " Diagonal lines may appears...") << endl;
_singleton->_addStyle ( fallback ); #endif
Exception::setHtmlTranslator ( _singleton->_getHtmlTranslator() ); _singleton = new Graphics ();
DisplayStyle* fallback = new DisplayStyle( "Fallback" );
fallback->setDescription( "Builtin fallback style" );
_singleton->_addStyle( fallback );
Exception::setHtmlTranslator( _singleton->_getHtmlTranslator() );
} }
return _singleton; return _singleton;

View File

@ -190,21 +190,14 @@ namespace Hurricane {
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.
inline DbU::Unit toDbu ( float ) const; inline DbU::Unit toDbu ( float ) const;
QRect dbuToDisplayRect ( DbU::Unit x1, DbU::Unit y1, DbU::Unit x2, DbU::Unit y2, bool usePoint=true ) const; QRect dbuToScreenRect ( DbU::Unit x1, DbU::Unit y1, DbU::Unit x2, DbU::Unit y2, bool usePoint=true ) const;
QRect dbuToDisplayRect ( const Box& box , bool usePoint=true ) const; QRect dbuToScreenRect ( const Box& box , bool usePoint=true ) const;
QPoint dbuToDisplayPoint ( DbU::Unit x, DbU::Unit y ) const;
QPoint dbuToDisplayPoint ( const Point& point ) const;
inline int dbuToDisplayX ( DbU::Unit x ) const;
inline int dbuToDisplayY ( DbU::Unit y ) const;
inline int dbuToDisplayLength ( DbU::Unit length ) const;
inline int dbuToScreenX ( DbU::Unit x ) const; inline int dbuToScreenX ( DbU::Unit x ) const;
inline int dbuToScreenY ( DbU::Unit y ) const; inline int dbuToScreenY ( DbU::Unit y ) const;
QPoint dbuToScreenPoint ( DbU::Unit x, DbU::Unit y ) const; inline int dbuToScreenLength ( DbU::Unit length ) const;
inline QPoint dbuToScreenPoint ( DbU::Unit x, DbU::Unit y ) const;
inline QPoint dbuToScreenPoint ( const Point& point ) const; inline QPoint dbuToScreenPoint ( const Point& point ) const;
inline DbU::Unit displayToDbuX ( int x ) const; inline DbU::Unit screenToDbuLength ( int length ) const;
inline DbU::Unit displayToDbuY ( int y ) const;
inline DbU::Unit displayToDbuLength ( int length ) const;
inline Box displayToDbuBox ( const QRect& rect ) const;
inline DbU::Unit screenToDbuX ( int x ) const; inline DbU::Unit screenToDbuX ( int x ) const;
inline DbU::Unit screenToDbuY ( int y ) const; inline DbU::Unit screenToDbuY ( int y ) const;
inline Point screenToDbuPoint ( const QPoint& point ) const; inline Point screenToDbuPoint ( const QPoint& point ) const;
@ -256,7 +249,6 @@ namespace Hurricane {
inline void openRefreshSession (); inline void openRefreshSession ();
inline void closeRefreshSession (); inline void closeRefreshSession ();
inline DrawingPlanes& getDrawingPlanes (); inline DrawingPlanes& getDrawingPlanes ();
inline QPoint& getOffsetVA ();
// void select ( const Net* ); // void select ( const Net* );
void select ( Occurrence ); void select ( Occurrence );
bool isSelected ( Occurrence ); bool isSelected ( Occurrence );
@ -372,7 +364,7 @@ namespace Hurricane {
public: public:
enum Ids { Normal = 0 // _planes[0] enum Ids { Normal = 0 // _planes[0]
, Selection = 1 // _planes[1] , Selection = 1 // _planes[1]
, AutoCopy = 2 // _plabes[2] , AutoCopy = 2 // _planes[2]
, Widget = 3 , Widget = 3
, Printer = 4 , Printer = 4
, Image = 5 , Image = 5
@ -428,6 +420,7 @@ namespace Hurricane {
QPainter _painters[PlaneId::Working]; QPainter _painters[PlaneId::Working];
QPen _normalPen; QPen _normalPen;
QPen _linePen; QPen _linePen;
QPoint _brushOrigin;
size_t _workingPlane; size_t _workingPlane;
size_t _pushWorkingPlane; size_t _pushWorkingPlane;
bool _lineMode; bool _lineMode;
@ -625,15 +618,12 @@ namespace Hurricane {
protected: protected:
// Internal: Attributes. // Internal: Attributes.
static const int _stripWidth;
static const int _initialSide; static const int _initialSide;
vector<Qt::CursorShape> _cursors; vector<Qt::CursorShape> _cursors;
// MapView* _mapView; // MapView* _mapView;
Technology* _technology; Technology* _technology;
PaletteWidget* _palette; PaletteWidget* _palette;
Box _displayArea; Box _screenArea;
Box _visibleArea;
QPoint _offsetVA;
RedrawManager _redrawManager; RedrawManager _redrawManager;
DrawingPlanes _drawingPlanes; DrawingPlanes _drawingPlanes;
DrawingQuery _drawingQuery; DrawingQuery _drawingQuery;
@ -1155,10 +1145,6 @@ namespace Hurricane {
{ return getOccurrencesUnder(screenToDbuBox(area)); } { return getOccurrencesUnder(screenToDbuBox(area)); }
inline QPoint& CellWidget::getOffsetVA ()
{ return _offsetVA; }
inline void CellWidget::addRuler ( const Point& origin, const Point& extremity ) inline void CellWidget::addRuler ( const Point& origin, const Point& extremity )
{ {
_state->getRulers().insert ( shared_ptr<Ruler>( new Ruler(origin,extremity) ) ); _state->getRulers().insert ( shared_ptr<Ruler>( new Ruler(origin,extremity) ) );
@ -1207,58 +1193,36 @@ namespace Hurricane {
} }
inline int CellWidget::dbuToDisplayX ( DbU::Unit x ) const
{ return (int)rint ( (float)( x - _displayArea.getXMin() ) * getScale() ); }
inline int CellWidget::dbuToDisplayY ( DbU::Unit y ) const
{ return (int)rint ( (float)( _displayArea.getYMax() - y ) * getScale() ); }
inline int CellWidget::dbuToDisplayLength ( DbU::Unit length ) const
{ return (int)rint ( (float)length * getScale() ); }
inline int CellWidget::dbuToScreenX ( DbU::Unit x ) const inline int CellWidget::dbuToScreenX ( DbU::Unit x ) const
{ return (int)rint ( (float)( x - _displayArea.getXMin() ) * getScale() ) - _offsetVA.x(); } { return (int)rint ( (float)( x - _screenArea.getXMin() ) * getScale() ); }
inline int CellWidget::dbuToScreenY ( DbU::Unit y ) const inline int CellWidget::dbuToScreenY ( DbU::Unit y ) const
{ return (int)rint ( (float)( _displayArea.getYMax() - y ) * getScale() ) - _offsetVA.y(); } { return (int)rint ( (float)( _screenArea.getYMax() - y ) * getScale() ); }
inline int CellWidget::dbuToScreenLength ( DbU::Unit length ) const
{ return (int)rint ( (float)length * getScale() ); }
inline QPoint CellWidget::dbuToScreenPoint ( DbU::Unit x, DbU::Unit y ) const
{ return QPoint ( dbuToScreenX(x), dbuToScreenY(y) ); }
inline QPoint CellWidget::dbuToScreenPoint ( const Point& point ) const inline QPoint CellWidget::dbuToScreenPoint ( const Point& point ) const
{ return QPoint ( dbuToScreenX(point.getX()), dbuToScreenY(point.getY()) ); } { return QPoint ( dbuToScreenX(point.getX()), dbuToScreenY(point.getY()) ); }
inline DbU::Unit CellWidget::displayToDbuX ( int x ) const
{ return (DbU::Unit)(x/getScale()) + _displayArea.getXMin(); }
inline DbU::Unit CellWidget::displayToDbuY ( int y ) const
{ return _displayArea.getYMax() - (DbU::Unit)(y/getScale()); }
inline DbU::Unit CellWidget::displayToDbuLength ( int length ) const
{ return (int)( (float)length / getScale() ); }
inline Box CellWidget::displayToDbuBox ( const QRect& rect ) const
{
return Box ( displayToDbuX(rect.x())
, displayToDbuY(rect.y())
, displayToDbuX(rect.x()+rect.width ())
, displayToDbuY(rect.y()+rect.height())
);
}
inline DbU::Unit CellWidget::screenToDbuX ( int x ) const inline DbU::Unit CellWidget::screenToDbuX ( int x ) const
{ return displayToDbuX(x+_offsetVA.x()); } { return (DbU::Unit)(x/getScale()) + _screenArea.getXMin(); }
inline DbU::Unit CellWidget::screenToDbuY ( int y ) const inline DbU::Unit CellWidget::screenToDbuY ( int y ) const
{ return displayToDbuY(y+_offsetVA.y()); } { return _screenArea.getYMax() - (DbU::Unit)(y/getScale()); }
inline DbU::Unit CellWidget::screenToDbuLength ( int length ) const
{ return (int)( (float)length / getScale() ); }
inline Point CellWidget::screenToDbuPoint ( const QPoint& point ) const inline Point CellWidget::screenToDbuPoint ( const QPoint& point ) const
@ -1276,11 +1240,11 @@ namespace Hurricane {
inline Box& CellWidget::pixelInflate ( Box& box, int pixels ) const inline Box& CellWidget::pixelInflate ( Box& box, int pixels ) const
{ return box.inflate(displayToDbuLength(pixels)); } { return box.inflate(screenToDbuLength(pixels)); }
inline Point CellWidget::getTopLeft () const inline Point CellWidget::getTopLeft () const
{ return Point(_visibleArea.getXMin(),_visibleArea.getYMax()); } { return Point(_screenArea.getXMin(),_screenArea.getYMax()); }
inline Box CellWidget::getVisibleArea () const inline Box CellWidget::getVisibleArea () const

View File

@ -108,7 +108,7 @@ namespace Kite {
painter.setBrush painter.setBrush
( Graphics::getColorScale(ColorScale::Fire).getBrush(density,widget->getDarkening()) ); ( Graphics::getColorScale(ColorScale::Fire).getBrush(density,widget->getDarkening()) );
painter.drawRect painter.drawRect
( widget->dbuToDisplayRect(gcell->getBoundingBox().inflate(0 ( widget->dbuToScreenRect(gcell->getBoundingBox().inflate(0
,0 ,0
,gcell->getTopRightShrink() ,gcell->getTopRightShrink()
,gcell->getTopRightShrink())) ); ,gcell->getTopRightShrink())) );

View File

@ -73,7 +73,7 @@ namespace Knik {
painter.setPen (DisplayStyle::darken(color,widget->getDarkening())); painter.setPen (DisplayStyle::darken(color,widget->getDarkening()));
} }
painter.setBrush ( Graphics::getColorScale(ColorScale::Fire).getBrush(occupancy,widget->getDarkening()) ); painter.setBrush ( Graphics::getColorScale(ColorScale::Fire).getBrush(occupancy,widget->getDarkening()) );
painter.drawRect ( widget->dbuToDisplayRect(edge->getBoundingBox(), false) ); painter.drawRect ( widget->dbuToScreenRect(edge->getBoundingBox(), false) );
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);
// affichage des infos de l'arete // affichage des infos de l'arete
@ -93,13 +93,13 @@ namespace Knik {
if ( edge->isVertical() ) { if ( edge->isVertical() ) {
painter.save(); painter.save();
Box bbox = edge->getBoundingBox(); Box bbox = edge->getBoundingBox();
painter.translate (widget->dbuToDisplayPoint(bbox.getXMin(), bbox.getYMin())); painter.translate (widget->dbuToScreenPoint(bbox.getXMin(), bbox.getYMin()));
painter.rotate(-90); painter.rotate(-90);
painter.drawText (QRect(0,0,widget->dbuToDisplayLength(bbox.getHeight()),widget->dbuToDisplayLength(bbox.getWidth())), text, QTextOption(Qt::AlignCenter)); painter.drawText (QRect(0,0,widget->dbuToScreenLength(bbox.getHeight()),widget->dbuToScreenLength(bbox.getWidth())), text, QTextOption(Qt::AlignCenter));
//painter.drawText (0, 0, text); //painter.drawText (0, 0, text);
painter.restore(); painter.restore();
} else } else
painter.drawText ( widget->dbuToDisplayRect ( edge->getBoundingBox(),false ), text, QTextOption (Qt::AlignCenter) ); painter.drawText ( widget->dbuToScreenRect ( edge->getBoundingBox(),false ), text, QTextOption (Qt::AlignCenter) );
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);
} }
} }
@ -127,7 +127,7 @@ namespace Knik {
QPen pen (DisplayStyle::darken(color,widget->getDarkening())); QPen pen (DisplayStyle::darken(color,widget->getDarkening()));
pen.setWidth(2); pen.setWidth(2);
widget->setPen(pen); widget->setPen(pen);
painter.drawEllipse ( widget->dbuToDisplayRect ( vertex->getBoundingBox(), false ) ); painter.drawEllipse ( widget->dbuToScreenRect ( vertex->getBoundingBox(), false ) );
if ( vertex->hasInfo() ) { if ( vertex->hasInfo() ) {
QColor color (Qt::blue); QColor color (Qt::blue);
@ -140,7 +140,7 @@ namespace Knik {
QString text = QString("%1 / %2").arg(vertex->getConnexID()).arg(vertex->getDistance()); QString text = QString("%1 / %2").arg(vertex->getConnexID()).arg(vertex->getDistance());
//Point center = vertex->getPosition(); //Point center = vertex->getPosition();
Box textBox = Box(vertex->getXMin(), vertex->getYMin(), vertex->getXMax(), vertex->getYMax()); Box textBox = Box(vertex->getXMin(), vertex->getYMin(), vertex->getXMax(), vertex->getYMax());
painter.drawText ( widget->dbuToDisplayRect ( textBox,false ), text, QTextOption (Qt::AlignCenter) ); painter.drawText ( widget->dbuToScreenRect ( textBox,false ), text, QTextOption (Qt::AlignCenter) );
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);
} }
} }

View File

@ -99,7 +99,7 @@ namespace Solstice {
c = DisplayStyle::darken(c,widget->getDarkening()); c = DisplayStyle::darken(c,widget->getDarkening());
painter.setPen (QPen(c,15)); painter.setPen (QPen(c,15));
painter.setBrush(c); painter.setBrush(c);
painter.drawRect ( widget->dbuToDisplayRect(error->getBoundingBox()) ); painter.drawRect ( widget->dbuToScreenRect(error->getBoundingBox()) );
} }