Change the way the grid is drawn in CellWidget.

* Change: In CellWidget::drawGrid(), for the "super-grid", now use
    lines instead of small crosses. The super-grid is set to 10 point
    of the snap grid in all cases (symbolic, real, foundry grid).
* New: Export CellWidget::setDbuMode() to CellViewer, and into it's
    Python wrapper.
* Bug: In CellWidget::setCell(), keep the dbuMode when loading a new
    cell instead of reverting to default.
This commit is contained in:
Jean-Paul Chaput 2020-10-25 12:05:54 +01:00
parent aadd7744ee
commit 3993f948b7
4 changed files with 90 additions and 29 deletions

View File

@ -377,7 +377,7 @@ namespace Hurricane {
_normalPen.setWidth( 2 ); _normalPen.setWidth( 2 );
_linePen.setWidth( 2 ); _linePen.setWidth( 2 );
#else #else
_linePen.setWidth( 1 ); // _linePen.setWidth( 1 );
#endif #endif
if (_lineMode) painter().setPen( _linePen ); if (_lineMode) painter().setPen( _linePen );
@ -640,6 +640,7 @@ namespace Hurricane {
) )
{ {
Box bbox = transformation.getBox(cell->getAbutmentBox()); Box bbox = transformation.getBox(cell->getAbutmentBox());
//_cellWidget->drawBoxBorder( bbox );
_cellWidget->drawBox( bbox ); _cellWidget->drawBox( bbox );
} }
@ -1344,6 +1345,7 @@ namespace Hurricane {
_drawingPlanes.painter().eraseRect ( redrawArea ); _drawingPlanes.painter().eraseRect ( redrawArea );
setDarkening( (_state->showSelection()) ? Graphics::getDarkening() : DisplayStyle::HSVr() ); setDarkening( (_state->showSelection()) ? Graphics::getDarkening() : DisplayStyle::HSVr() );
if (isDrawable("grid")) drawGrid( redrawArea );
if (getCell()) { if (getCell()) {
Box redrawBox = screenToDbuBox( redrawArea ); Box redrawBox = screenToDbuBox( redrawArea );
@ -1456,7 +1458,6 @@ namespace Hurricane {
_cellModificated = false; _cellModificated = false;
} }
if (isDrawable("grid")) drawGrid ( redrawArea );
if (isDrawable("text.ruler")) drawRulers( redrawArea ); if (isDrawable("text.ruler")) drawRulers( redrawArea );
setDarkening( 100 ); 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 ) void CellWidget::drawText ( const Point& point, const char* text, unsigned int flags, int angle )
{ {
drawDisplayText ( dbuToScreenPoint(point), text, flags, angle ); drawDisplayText ( dbuToScreenPoint(point), text, flags, angle );
@ -1807,39 +1817,51 @@ namespace Hurricane {
bool CellWidget::_underDetailedGridThreshold () const bool CellWidget::_underDetailedGridThreshold () const
{ {
if ( symbolicMode() ) // if (symbolicMode()) return 5*Graphics::getThreshold("grid")/DbU::getSymbolicSnapGridStep() < getScale();
return Graphics::getThreshold("grid")/DbU::lambda(1.0) < getScale()/5; // if (physicalMode()) return 5*Graphics::getThreshold("grid")/DbU::getRealSnapGridStep() < getScale();
return Graphics::getThreshold("grid")/DbU::grid(10.0) < getScale()/5; // 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 ) void CellWidget::drawGrid ( QRect redrawArea )
{ {
_drawingPlanes.select ( PlaneId::Normal ); // _drawingPlanes.select ( PlaneId::Normal );
_drawingPlanes.begin (); // _drawingPlanes.begin ();
_drawingPlanes.painter ().setClipRect ( redrawArea ); // _drawingPlanes.painter().setClipRect( redrawArea );
_drawingPlanes.painter ().setPen ( Graphics::getPen("grid") ); _drawingPlanes.setPen ( Graphics::getPen (("grid"), getDarkening() ));
_drawingPlanes.setBrush( Graphics::getBrush(("grid"), getDarkening() ));
Box redrawBox = screenToDbuBox( redrawArea ).inflate( DbU::lambda(1.0) ); Box redrawBox = screenToDbuBox( redrawArea ).inflate( DbU::lambda(1.0) );
bool detailedGrid = _underDetailedGridThreshold(); bool detailedGrid = _underDetailedGridThreshold();
DbU::Unit gridStep = _snapGridStep(); DbU::Unit gridStep = ((symbolicMode()) ? 1 : 10) * _snapGridStep();
DbU::Unit superGridStep = gridStep*5; DbU::Unit superGridStep = gridStep*10;
DbU::Unit xGrid; DbU::Unit xGrid;
DbU::Unit yGrid; DbU::Unit yGrid;
QPoint center; 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 < redrawBox.getYMax()
; yGrid += gridStep ; yGrid += gridStep
) { ) {
for ( xGrid = _onSnapGrid(redrawBox.getXMin()) for ( xGrid = DbU::getOnCustomGrid(redrawBox.getXMin(),gridStep,DbU::SnapMode::Superior)
; xGrid < redrawBox.getXMax() ; xGrid < redrawBox.getXMax()
; xGrid += gridStep ; xGrid += gridStep
) { ) {
center = dbuToScreenPoint( xGrid, yGrid ); center = dbuToScreenPoint( xGrid, yGrid );
if ( (xGrid % superGridStep) || (yGrid % superGridStep) ) { if ( (xGrid % superGridStep) or (yGrid % superGridStep) ) {
if (detailedGrid) { if (detailedGrid) {
_drawingPlanes.painter().drawPoint( center ); _drawingPlanes.painter().drawPoint( center );
} }
@ -1853,9 +1875,24 @@ namespace Hurricane {
} }
} }
} }
#endif
_drawingPlanes.copyToSelect ( redrawArea ); for ( xGrid = DbU::getOnCustomGrid(redrawBox.getXMin(),superGridStep,DbU::SnapMode::Superior)
_drawingPlanes.end (); ; 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(); openRefreshSession();
shared_ptr<State> state ( new State(cell,topPath) ); shared_ptr<State> state ( new State(cell,topPath) );
state->setDbuMode( getDbuMode() );
setState( state, flags ); setState( state, flags );
if ( cell and cell->isTerminal() ) setQueryFilter( ~0 ); if ( cell and cell->isTerminal() ) setQueryFilter( ~0 );
//setRealMode (); //setRealMode ();

View File

@ -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 ) static PyObject* PyCellViewer_setApplicationName ( PyCellViewer* self, PyObject* args )
{ {
cdebug_log(20,0) << "PyCellViewer_setApplicationName ()" << endl; cdebug_log(20,0) << "PyCellViewer_setApplicationName ()" << endl;
@ -370,6 +386,8 @@ extern "C" {
, "Load a Cell into the viewer." } , "Load a Cell into the viewer." }
, { "setApplicationName" , (PyCFunction)PyCellViewer_setApplicationName , METH_VARARGS , { "setApplicationName" , (PyCFunction)PyCellViewer_setApplicationName , METH_VARARGS
, "Sets the application (binary) name." } , "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 , { "setAnonNetSelectable" , (PyCFunction)PyCellViewer_setAnonNetSelectable , METH_VARARGS
, "Allow/disallow anonymous nets to be selectables." } , "Allow/disallow anonymous nets to be selectables." }
, { "setLayerVisible" , (PyCFunction)PyCellViewer_setLayerVisible , METH_VARARGS , { "setLayerVisible" , (PyCFunction)PyCellViewer_setLayerVisible , METH_VARARGS

View File

@ -116,6 +116,7 @@ namespace Hurricane {
, QString beforePath="" ); , QString beforePath="" );
inline void setEnableRedrawInterrupt ( bool ); inline void setEnableRedrawInterrupt ( bool );
inline void setApplicationName ( const QString& ); inline void setApplicationName ( const QString& );
inline void setDbuMode ( int );
inline Observer<CellViewer>* getCellObserver (); inline Observer<CellViewer>* getCellObserver ();
Cell* getCell () const; Cell* getCell () const;
virtual void setCell ( Cell* ); virtual void setCell ( Cell* );
@ -218,6 +219,9 @@ namespace Hurricane {
inline void CellViewer::setEnableRedrawInterrupt ( bool state ) inline void CellViewer::setEnableRedrawInterrupt ( bool state )
{ _cellWidget->setEnableRedrawInterrupt(state); } { _cellWidget->setEnableRedrawInterrupt(state); }
inline void CellViewer::setDbuMode ( int mode )
{ _cellWidget->setDbuMode(mode); }
} // Hurricane namespace. } // Hurricane namespace.

View File

@ -182,6 +182,7 @@ namespace Hurricane {
inline void setPen ( const QPen& , size_t plane=PlaneId::Working ); inline void setPen ( const QPen& , size_t plane=PlaneId::Working );
void drawBox ( DbU::Unit, DbU::Unit, DbU::Unit, DbU::Unit ); void drawBox ( DbU::Unit, DbU::Unit, DbU::Unit, DbU::Unit );
void drawBox ( const Box& ); void drawBox ( const Box& );
void drawBoxBorder ( const Box& );
void drawLine ( DbU::Unit, DbU::Unit, DbU::Unit, DbU::Unit, bool mode=true ); void drawLine ( DbU::Unit, DbU::Unit, DbU::Unit, DbU::Unit, bool mode=true );
void drawLine ( const Point&, const Point&, 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 ); void drawText ( const Point&, const char*, unsigned int flags=0, int angle=0 );
@ -990,9 +991,9 @@ namespace Hurricane {
{ {
_dbuMode = mode; _dbuMode = mode;
switch ( _dbuMode ) { switch ( _dbuMode ) {
case DbU::Symbolic: _cursorStep = DbU::lambda(0.5); break; case DbU::Symbolic: _cursorStep = DbU::fromLambda(0.5); break;
case DbU::Grid: _cursorStep = DbU::grid (1.0); break; case DbU::Grid: _cursorStep = DbU::fromGrid (1.0); break;
case DbU::Physical: _cursorStep = DbU::grid (1.0); break; case DbU::Physical: _cursorStep = DbU::fromGrid (1.0); break;
} }
} }