diff --git a/hurricane/src/viewer/CellWidget.cpp b/hurricane/src/viewer/CellWidget.cpp index 5e5e30d3..13b0d5bd 100644 --- a/hurricane/src/viewer/CellWidget.cpp +++ b/hurricane/src/viewer/CellWidget.cpp @@ -377,7 +377,7 @@ namespace Hurricane { _normalPen.setWidth( 2 ); _linePen.setWidth( 2 ); #else - _linePen.setWidth( 1 ); + // _linePen.setWidth( 1 ); #endif if (_lineMode) painter().setPen( _linePen ); @@ -640,7 +640,8 @@ namespace Hurricane { ) { Box bbox = transformation.getBox(cell->getAbutmentBox()); - _cellWidget->drawBox ( bbox ); + //_cellWidget->drawBoxBorder( bbox ); + _cellWidget->drawBox( bbox ); } @@ -1344,6 +1345,7 @@ namespace Hurricane { _drawingPlanes.painter().eraseRect ( redrawArea ); setDarkening( (_state->showSelection()) ? Graphics::getDarkening() : DisplayStyle::HSVr() ); + if (isDrawable("grid")) drawGrid( redrawArea ); if (getCell()) { Box redrawBox = screenToDbuBox( redrawArea ); @@ -1456,7 +1458,6 @@ namespace Hurricane { _cellModificated = false; } - if (isDrawable("grid")) drawGrid ( redrawArea ); if (isDrawable("text.ruler")) drawRulers( redrawArea ); setDarkening( 100 ); @@ -1668,6 +1669,15 @@ namespace Hurricane { } + void CellWidget::drawBoxBorder ( const Box& box ) + { + drawLine( box.getXMin(), box.getYMin(), box.getXMin(), box.getYMax(), true ); + drawLine( box.getXMin(), box.getYMax(), box.getXMax(), box.getYMax(), true ); + drawLine( box.getXMax(), box.getYMax(), box.getXMax(), box.getYMin(), true ); + drawLine( box.getXMax(), box.getYMin(), box.getXMin(), box.getYMin(), true ); + } + + void CellWidget::drawText ( const Point& point, const char* text, unsigned int flags, int angle ) { drawDisplayText ( dbuToScreenPoint(point), text, flags, angle ); @@ -1807,55 +1817,82 @@ namespace Hurricane { bool CellWidget::_underDetailedGridThreshold () const { - if ( symbolicMode() ) - return Graphics::getThreshold("grid")/DbU::lambda(1.0) < getScale()/5; - return Graphics::getThreshold("grid")/DbU::grid(10.0) < getScale()/5; + // if (symbolicMode()) return 5*Graphics::getThreshold("grid")/DbU::getSymbolicSnapGridStep() < getScale(); + // if (physicalMode()) return 5*Graphics::getThreshold("grid")/DbU::getRealSnapGridStep() < getScale(); + // return 5*Graphics::getThreshold("grid")/DbU::grid(10.0) < getScale(); + DbU::Unit gridLength = 0; + if (symbolicMode()) gridLength = DbU::getSymbolicSnapGridStep(); + else if (physicalMode()) gridLength = 10*DbU::getRealSnapGridStep(); + else gridLength = 10*DbU::fromGrid(1.0); + double pixelLength = dbuToScreenLength( gridLength ); + return pixelLength > 50; } void CellWidget::drawGrid ( QRect redrawArea ) { - _drawingPlanes.select ( PlaneId::Normal ); - _drawingPlanes.begin (); - _drawingPlanes.painter ().setClipRect ( redrawArea ); - _drawingPlanes.painter ().setPen ( Graphics::getPen("grid") ); - - Box redrawBox = screenToDbuBox ( redrawArea ).inflate ( DbU::lambda(1.0) ); + // _drawingPlanes.select ( PlaneId::Normal ); + // _drawingPlanes.begin (); + // _drawingPlanes.painter().setClipRect( redrawArea ); + _drawingPlanes.setPen ( Graphics::getPen (("grid"), getDarkening() )); + _drawingPlanes.setBrush( Graphics::getBrush(("grid"), getDarkening() )); + Box redrawBox = screenToDbuBox( redrawArea ).inflate( DbU::lambda(1.0) ); bool detailedGrid = _underDetailedGridThreshold(); - DbU::Unit gridStep = _snapGridStep(); - DbU::Unit superGridStep = gridStep*5; + DbU::Unit gridStep = ((symbolicMode()) ? 1 : 10) * _snapGridStep(); + DbU::Unit superGridStep = gridStep*10; DbU::Unit xGrid; DbU::Unit yGrid; QPoint center; - for ( yGrid = _onSnapGrid(redrawBox.getYMin()) +#if 0 + cerr << "CellWidget::drawGrid() step:" << DbU::getValueString(gridStep) + << " superStep:" << DbU::getValueString(superGridStep) + << " pixels:" << dbuToScreenLength(gridStep) + << " draw:" << detailedGrid << endl; + + for ( yGrid = DbU::getOnCustomGrid(redrawBox.getYMin(),gridStep,DbU::SnapMode::Superior) ; yGrid < redrawBox.getYMax() ; yGrid += gridStep ) { - for ( xGrid = _onSnapGrid(redrawBox.getXMin()) + for ( xGrid = DbU::getOnCustomGrid(redrawBox.getXMin(),gridStep,DbU::SnapMode::Superior) ; xGrid < redrawBox.getXMax() ; xGrid += gridStep ) { - center = dbuToScreenPoint(xGrid,yGrid); - if ( (xGrid % superGridStep) || (yGrid % superGridStep) ) { - if ( detailedGrid ) { - _drawingPlanes.painter().drawPoint ( center ); + center = dbuToScreenPoint( xGrid, yGrid ); + if ( (xGrid % superGridStep) or (yGrid % superGridStep) ) { + if (detailedGrid) { + _drawingPlanes.painter().drawPoint( center ); } } else { - if ( detailedGrid ) { - _drawingPlanes.painter().drawLine ( center.x()-3, center.y() , center.x()+3, center.y() ); - _drawingPlanes.painter().drawLine ( center.x() , center.y()-3, center.x() , center.y()+3 ); + if (detailedGrid) { + _drawingPlanes.painter().drawLine( center.x()-3, center.y() , center.x()+3, center.y() ); + _drawingPlanes.painter().drawLine( center.x() , center.y()-3, center.x() , center.y()+3 ); } else { - _drawingPlanes.painter().drawPoint ( center ); + _drawingPlanes.painter().drawPoint( center ); } } } } +#endif - _drawingPlanes.copyToSelect ( redrawArea ); - _drawingPlanes.end (); + for ( xGrid = DbU::getOnCustomGrid(redrawBox.getXMin(),superGridStep,DbU::SnapMode::Superior) + ; xGrid < redrawBox.getXMax() + ; xGrid += superGridStep + ) { + drawLine( Point(xGrid,redrawBox.getYMin()), Point(xGrid,redrawBox.getYMax()) ); + } + + for ( yGrid = DbU::getOnCustomGrid(redrawBox.getYMin(),superGridStep,DbU::SnapMode::Superior) + ; yGrid < redrawBox.getYMax() + ; yGrid += superGridStep + ) { + drawLine( Point(redrawBox.getXMin(),yGrid), Point(redrawBox.getXMax(),yGrid) ); + } + + // _drawingPlanes.copyToSelect( redrawArea ); + // _drawingPlanes.end (); } @@ -2503,6 +2540,7 @@ namespace Hurricane { openRefreshSession(); shared_ptr state ( new State(cell,topPath) ); + state->setDbuMode( getDbuMode() ); setState( state, flags ); if ( cell and cell->isTerminal() ) setQueryFilter( ~0 ); //setRealMode (); diff --git a/hurricane/src/viewer/PyCellViewer.cpp b/hurricane/src/viewer/PyCellViewer.cpp index fa6171a6..b816ba68 100644 --- a/hurricane/src/viewer/PyCellViewer.cpp +++ b/hurricane/src/viewer/PyCellViewer.cpp @@ -173,6 +173,22 @@ extern "C" { } + static PyObject* PyCellViewer_setDbuMode ( PyCellViewer* self, PyObject* args ) + { + cdebug_log(20,0) << "PyCellViewer_setDbuMode ()" << endl; + HTRY + METHOD_HEAD( "CellViewer.setDbuMode()" ) + int dbuMode = DbU::Symbolic; + if (not PyArg_ParseTuple(args,"i:CellViewer.setDbuMode()", &dbuMode)) { + PyErr_SetString ( ConstructorError, "CellViewer.setDbuMode(): Takes exactly one argument." ); + return NULL; + } + cw->setDbuMode ( dbuMode ); + HCATCH + Py_RETURN_NONE; + } + + static PyObject* PyCellViewer_setApplicationName ( PyCellViewer* self, PyObject* args ) { cdebug_log(20,0) << "PyCellViewer_setApplicationName ()" << endl; @@ -370,6 +386,8 @@ extern "C" { , "Load a Cell into the viewer." } , { "setApplicationName" , (PyCFunction)PyCellViewer_setApplicationName , METH_VARARGS , "Sets the application (binary) name." } + , { "setDbuMode" , (PyCFunction)PyCellViewer_setDbuMode , METH_VARARGS + , "Sets how the length will be displayed (lambda,physical,grid)." } , { "setAnonNetSelectable" , (PyCFunction)PyCellViewer_setAnonNetSelectable , METH_VARARGS , "Allow/disallow anonymous nets to be selectables." } , { "setLayerVisible" , (PyCFunction)PyCellViewer_setLayerVisible , METH_VARARGS diff --git a/hurricane/src/viewer/hurricane/viewer/CellViewer.h b/hurricane/src/viewer/hurricane/viewer/CellViewer.h index fbf5864b..49e183e7 100644 --- a/hurricane/src/viewer/hurricane/viewer/CellViewer.h +++ b/hurricane/src/viewer/hurricane/viewer/CellViewer.h @@ -116,6 +116,7 @@ namespace Hurricane { , QString beforePath="" ); inline void setEnableRedrawInterrupt ( bool ); inline void setApplicationName ( const QString& ); + inline void setDbuMode ( int ); inline Observer* getCellObserver (); Cell* getCell () const; virtual void setCell ( Cell* ); @@ -218,6 +219,9 @@ namespace Hurricane { inline void CellViewer::setEnableRedrawInterrupt ( bool state ) { _cellWidget->setEnableRedrawInterrupt(state); } + inline void CellViewer::setDbuMode ( int mode ) + { _cellWidget->setDbuMode(mode); } + } // Hurricane namespace. diff --git a/hurricane/src/viewer/hurricane/viewer/CellWidget.h b/hurricane/src/viewer/hurricane/viewer/CellWidget.h index 338a0f95..2536d3a9 100644 --- a/hurricane/src/viewer/hurricane/viewer/CellWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/CellWidget.h @@ -182,6 +182,7 @@ namespace Hurricane { inline void setPen ( const QPen& , size_t plane=PlaneId::Working ); void drawBox ( DbU::Unit, DbU::Unit, DbU::Unit, DbU::Unit ); void drawBox ( const Box& ); + void drawBoxBorder ( const Box& ); void drawLine ( DbU::Unit, DbU::Unit, DbU::Unit, DbU::Unit, bool mode=true ); void drawLine ( const Point&, const Point&, bool mode=true ); void drawText ( const Point&, const char*, unsigned int flags=0, int angle=0 ); @@ -990,9 +991,9 @@ namespace Hurricane { { _dbuMode = mode; switch ( _dbuMode ) { - case DbU::Symbolic: _cursorStep = DbU::lambda(0.5); break; - case DbU::Grid: _cursorStep = DbU::grid (1.0); break; - case DbU::Physical: _cursorStep = DbU::grid (1.0); break; + case DbU::Symbolic: _cursorStep = DbU::fromLambda(0.5); break; + case DbU::Grid: _cursorStep = DbU::fromGrid (1.0); break; + case DbU::Physical: _cursorStep = DbU::fromGrid (1.0); break; } }