From 9f69230837934bcf0674460b6f51844b51737d99 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Wed, 20 Feb 2019 18:24:43 +0100 Subject: [PATCH] Correct CellWidget & CellPrinter to be really WYSIWYG. * Change: In Hurricane::CellWidget, new "isPrinter" attribute to know if the CellWidget is used as a device for printing. New function copyExtensionsGos() to duplicate the ExtensionGo drawing callbacks. This is a temporary hack until the ExtensionGo are made static to be shared by all CellWidgets. In _redraw(), the DrawingQuery flags were not correctly reset between different stage of the drawing. This was resulting of uneeded walkthough of the slicing tree, along with incorrect display of some of the layers (i.e. rubbers where diplayeds when ExtensionGos where active). * Change: In GraphicKatanaEngine, fine tune the display of GCells for printing CellWidget. * Change: In Hurricane::CellPrinter, copy all the settings from the palette of the reference (graphic) CellWidget into the printer CellWidget. Also copy the ExtensionGos callbacks so we can print them. Use the new CellWidget attribute "isPrinter" for the callbacks to be able to adapt to Printer settings. * Change: In Hurricane::Time::getStringTime(), only print two decimals for time durations. --- crlcore/etc/common/display.conf | 4 +- hurricane/src/hurricane/Timer.cpp | 7 +- hurricane/src/viewer/CellPrinter.cpp | 64 +++++-- hurricane/src/viewer/CellWidget.cpp | 168 +++++++++--------- .../src/viewer/hurricane/viewer/CellWidget.h | 23 ++- katana/src/GraphicKatanaEngine.cpp | 62 ++++--- 6 files changed, 202 insertions(+), 126 deletions(-) diff --git a/crlcore/etc/common/display.conf b/crlcore/etc/common/display.conf index cde60d96..d0832f59 100644 --- a/crlcore/etc/common/display.conf +++ b/crlcore/etc/common/display.conf @@ -403,7 +403,7 @@ stylesTable = \ , (Drawing, 'gmetalh' , { 'color':'128,255,200', 'pattern':'light_antihash0.8' , 'border':1 }) , (Drawing, 'gmetalv' , { 'color':'200,200,255', 'pattern':'light_antihash1.8' , 'border':1 }) , (Drawing, 'gcut' , { 'color':'255,255,190', 'border':1 }) - , (Drawing, 'Anabatic::Edge' , { 'color':'255,255,190', 'pattern':'0000000000000000', 'border':4 }) - , (Drawing, 'Anabatic::GCell', { 'color':'255,255,190', 'pattern':'0000000000000000', 'border':4 }) + , (Drawing, 'Anabatic::Edge' , { 'color':'255,255,190', 'pattern':'0000000000000000', 'border':2 }) + , (Drawing, 'Anabatic::GCell', { 'color':'Black' , 'pattern':'0000000000000000', 'border':2, 'threshold':0.80*scale }) ) ) diff --git a/hurricane/src/hurricane/Timer.cpp b/hurricane/src/hurricane/Timer.cpp index 3507b219..4155863e 100644 --- a/hurricane/src/hurricane/Timer.cpp +++ b/hurricane/src/hurricane/Timer.cpp @@ -249,18 +249,19 @@ namespace Hurricane { string s; unsigned int hours = (unsigned int)duration / 3600; - if ( hours ) + if (hours) s += getString(hours) + "h "; unsigned int minutes = ((unsigned int)duration % 3600) / 60; - if ( hours || minutes ) + if (hours or minutes) s += getString(minutes) + "m "; double seconds = duration; - if ( hours || minutes ) { + if (hours or minutes) { minutes = ((unsigned int)duration) / 60; seconds = duration - ((float)minutes * 60.0); } + seconds = std::round(seconds * 100.0) / 100.0; s += getString((float)seconds) + "s"; diff --git a/hurricane/src/viewer/CellPrinter.cpp b/hurricane/src/viewer/CellPrinter.cpp index 8a18a9c0..ff05e88c 100644 --- a/hurricane/src/viewer/CellPrinter.cpp +++ b/hurricane/src/viewer/CellPrinter.cpp @@ -14,18 +14,21 @@ // +-----------------------------------------------------------------+ -#include -#include -#include -#include -#include -#include -#include "vlsisapd/configuration/Configuration.h" -#include "hurricane/DataBase.h" -#include "hurricane/Cell.h" -#include "hurricane/viewer/Graphics.h" -#include "hurricane/viewer/CellPrinter.h" -#include "hurricane/viewer/PaletteWidget.h" +#include +#include +#include +#include +#include +#include +#include "vlsisapd/configuration/Configuration.h" +#include "hurricane/DataBase.h" +#include "hurricane/BasicLayer.h" +#include "hurricane/Technology.h" +#include "hurricane/ExtensionSlice.h" +#include "hurricane/Cell.h" +#include "hurricane/viewer/Graphics.h" +#include "hurricane/viewer/CellPrinter.h" +#include "hurricane/viewer/PaletteWidget.h" namespace Hurricane { @@ -79,6 +82,7 @@ namespace Hurricane { setCentralWidget( _cellWidget ); _palette->readGraphics (); + _cellWidget->setPrinter( true ); _cellWidget->bindToPalette( _palette ); _cellWidget->refresh(); } @@ -88,12 +92,38 @@ namespace Hurricane { { _screenCellWidget = cellWidget; + array labels = { "fallback" + , "rubber" + , "phantom" + , "boundaries" + , "marker" + , "grid" + , "spot" + , "ghost" + , "text.ruler" + , "text.cell" + , "text.instance" + , "text.components" + , "text.references" + , "undef" + }; + + for ( string label : labels ) + _cellWidget->setLayerVisible( label + , _screenCellWidget->isLayerVisible(label) ); + + for ( const BasicLayer* layer : DataBase::getDB()->getTechnology()->getBasicLayers() ) + _cellWidget->setLayerVisible( layer->getName() + , _screenCellWidget->isLayerVisible( layer->getName() )); + shared_ptr clone ( _screenCellWidget->getStateClone() ); - _cellWidget->setState ( clone ); - _cellWidget->setLayerVisible("grid" , _screenCellWidget->isLayerVisible("grid" )); - _cellWidget->setLayerVisible("text.instance" , _screenCellWidget->isLayerVisible("text.instance" )); - _cellWidget->setLayerVisible("text.component", _screenCellWidget->isLayerVisible("text.component")); - _cellWidget->setLayerVisible("rubber" , _screenCellWidget->isLayerVisible("rubber" )); + _cellWidget->setState( clone ); + + _cellWidget->copyDrawExtensionGos( _screenCellWidget ); + + for ( ExtensionSlice* extension : cellWidget->getCell()->getExtensionSlices() ) + _cellWidget->setLayerVisible( extension->getName() + , _screenCellWidget->isLayerVisible( extension->getName() )); } diff --git a/hurricane/src/viewer/CellWidget.cpp b/hurricane/src/viewer/CellWidget.cpp index e0983de3..e73c1812 100644 --- a/hurricane/src/viewer/CellWidget.cpp +++ b/hurricane/src/viewer/CellWidget.cpp @@ -1094,6 +1094,7 @@ namespace Hurricane { , _mousePosition (0,0) , _spot (this) , _state (new State(NULL)) + , _isPrinter (false) , _cellChanged (true) , _selectionHasChanged (false) , _delaySelectionChanged(0) @@ -1312,10 +1313,10 @@ namespace Hurricane { //static bool timedout; //static Timer timer; - if ( not isVisible() ) return; + if (not isVisible()) return; DataBase* database = DataBase::getDB(); - if ( database ) _technology = database->getTechnology (); + if (database) _technology = database->getTechnology(); //timer.start (); //timedout = false; @@ -1323,22 +1324,22 @@ namespace Hurricane { _cellChanged = false; _redrawRectCount = 0; - pushCursor ( Qt::BusyCursor ); + pushCursor( Qt::BusyCursor ); - if ( not ( _selectionHasChanged and _state->showSelection() ) or _cellModificated ) { - _spot.setRestore ( false ); + if ( not (_selectionHasChanged and _state->showSelection()) or _cellModificated ) { + _spot.setRestore( false ); //_drawingPlanes.copyToSelect ( redrawArea ); _drawingPlanes.select ( PlaneId::Normal ); _drawingPlanes.begin (); - _drawingPlanes.painter().setPen ( Qt::NoPen ); - _drawingPlanes.painter().setBackground ( Graphics::getBrush("background") ); - _drawingPlanes.painter().setClipRect ( redrawArea ); - _drawingPlanes.painter().eraseRect ( redrawArea ); + _drawingPlanes.painter().setPen ( Qt::NoPen ); + _drawingPlanes.painter().setBackground( Graphics::getBrush("background") ); + _drawingPlanes.painter().setClipRect ( redrawArea ); + _drawingPlanes.painter().eraseRect ( redrawArea ); - setDarkening ( (_state->showSelection()) ? Graphics::getDarkening() : DisplayStyle::HSVr() ); + setDarkening( (_state->showSelection()) ? Graphics::getDarkening() : DisplayStyle::HSVr() ); - if ( getCell() ) { - Box redrawBox = screenToDbuBox ( redrawArea ); + if (getCell()) { + Box redrawBox = screenToDbuBox( redrawArea ); _drawingQuery.resetGoCount (); _drawingQuery.resetExtensionGoCount(); @@ -1347,106 +1348,112 @@ namespace Hurricane { _drawingQuery.setArea ( redrawBox ); _drawingQuery.setTransformation ( Transformation() ); - forEach ( BasicLayer*, iLayer, _technology->getBasicLayers() ) { - _drawingPlanes.setPen ( Graphics::getPen ((*iLayer)->getName(),getDarkening()) ); - _drawingPlanes.setBrush ( Graphics::getBrush((*iLayer)->getName(),getDarkening()) ); + for ( BasicLayer* layer : _technology->getBasicLayers() ) { + _drawingPlanes.setPen ( Graphics::getPen (layer->getName(),getDarkening()) ); + _drawingPlanes.setBrush( Graphics::getBrush(layer->getName(),getDarkening()) ); - if ( isDrawable((*iLayer)->getName()) ) { - _drawingQuery.setBasicLayer ( *iLayer ); - _drawingQuery.setFilter ( getQueryFilter().unset(Query::DoMasterCells - |Query::DoRubbers - |Query::DoMarkers - |Query::DoExtensionGos) ); - _drawingQuery.doQuery (); + if ( isDrawable(layer->getName()) ) { + _drawingQuery.setBasicLayer( layer ); + _drawingQuery.setFilter ( getQueryFilter().unset(Query::DoMasterCells + |Query::DoRubbers + |Query::DoMarkers + |Query::DoExtensionGos) ); + _drawingQuery.doQuery (); } - if ( _enableRedrawInterrupt ) QApplication::processEvents(); - if ( _redrawManager.interrupted() ) { - //cerr << "CellWidget::redraw() - interrupt after " << (*iLayer)->getName() << endl; + if (_enableRedrawInterrupt) QApplication::processEvents(); + if (_redrawManager.interrupted()) { + //cerr << "CellWidget::redraw() - interrupt after " << layer->getName() << endl; break; } //if ( timeout("redraw [layer]",timer,10.0,timedout) ) break; } if ( /*not timeout("redraw [boundaries]",timer,10.0,timedout) and*/ (not _redrawManager.interrupted()) ) { - if ( isDrawable("boundaries") ) { - _drawingPlanes.setPen ( Graphics::getPen ("boundaries",getDarkening()) ); - _drawingPlanes.setBrush ( Graphics::getBrush("boundaries",getDarkening()) ); + if (isDrawable("boundaries")) { + _drawingPlanes.setPen ( Graphics::getPen ("boundaries",getDarkening()) ); + _drawingPlanes.setBrush( Graphics::getBrush("boundaries",getDarkening()) ); - _drawingQuery.setBasicLayer ( NULL ); - _drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents - |Query::DoRubbers - |Query::DoMarkers - |Query::DoExtensionGos) ); - _drawingQuery.doQuery (); + _drawingQuery.setBasicLayer( NULL ); + _drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents + |Query::DoRubbers + |Query::DoMarkers + |Query::DoExtensionGos) ); + _drawingQuery.doQuery (); } } if ( /*not timeout("redraw [markers]",timer,10.0,timedout) and*/ (not _redrawManager.interrupted()) ) { if ( isDrawable("text.reference") ) { - _drawingPlanes.setPen ( Graphics::getPen ("text.reference",getDarkening()) ); - _drawingPlanes.setBrush ( Graphics::getBrush("text.reference",getDarkening()) ); + _drawingPlanes.setPen ( Graphics::getPen ("text.reference",getDarkening()) ); + _drawingPlanes.setBrush( Graphics::getBrush("text.reference",getDarkening()) ); - _drawingQuery.setBasicLayer ( NULL ); - _drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents - |Query::DoExtensionGos - |Query::DoMasterCells) ); - _drawingQuery.doQuery (); + _drawingQuery.setBasicLayer( NULL ); + _drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents + |Query::DoRubbers + |Query::DoMarkers + |Query::DoExtensionGos + |Query::DoMasterCells) ); + _drawingQuery.doQuery (); } } if ( /*not timeout("redraw [rubbers]",timer,10.0,timedout) and*/ (not _redrawManager.interrupted()) ) { - if ( isDrawable("rubber") ) { - _drawingPlanes.setPen ( Graphics::getPen ("rubber",getDarkening()) ); - _drawingPlanes.setBrush ( Graphics::getBrush("rubber",getDarkening()) ); + if (isDrawable("rubber")) { + _drawingPlanes.setPen ( Graphics::getPen ("rubber",getDarkening()) ); + _drawingPlanes.setBrush( Graphics::getBrush("rubber",getDarkening()) ); - _drawingQuery.setBasicLayer ( NULL ); - _drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents - |Query::DoExtensionGos - |Query::DoMasterCells - |Query::DoMarkers) ); - _drawingQuery.doQuery (); + _drawingQuery.setBasicLayer( NULL ); + _drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents + |Query::DoMarkers + |Query::DoExtensionGos + |Query::DoMasterCells) ); + _drawingQuery.doQuery (); } } - if ( _enableRedrawInterrupt ) QApplication::processEvents(); + if (_enableRedrawInterrupt) QApplication::processEvents(); if ( /*not timeout("redraw [text.instances]",timer,10.0,timedout) and*/ (not _redrawManager.interrupted()) ) { - if ( isDrawable("text.instance") ) { - _drawingPlanes.setPen ( Graphics::getPen ("text.instance",getDarkening()) ); - _drawingPlanes.setBrush ( Graphics::getBrush("text.instance",getDarkening()) ); - _drawingPlanes.setBackground ( Graphics::getBrush("boundaries" ,getDarkening()) ); - _textDrawingQuery.setArea ( redrawBox ); - _textDrawingQuery.setTransformation ( Transformation() ); - _textDrawingQuery.doQuery (); + if (isDrawable("text.instance")) { + _drawingPlanes.setPen ( Graphics::getPen ("text.instance",getDarkening()) ); + _drawingPlanes.setBrush ( Graphics::getBrush("text.instance",getDarkening()) ); + _drawingPlanes.setBackground ( Graphics::getBrush("boundaries" ,getDarkening()) ); + _textDrawingQuery.setArea ( redrawBox ); + _textDrawingQuery.setTransformation( Transformation() ); + _textDrawingQuery.doQuery (); } } //_drawingQuery.setFilter ( getQueryFilter() & ~Query::DoMasterCells ); - forEach ( ExtensionSlice*, islice, getCell()->getExtensionSlices() ) { - if ( _enableRedrawInterrupt ) QApplication::processEvents(); + for ( ExtensionSlice* slice : getCell()->getExtensionSlices() ) { + if (_enableRedrawInterrupt) QApplication::processEvents(); if ( /*timeout("redraw [extension]",timer,10.0,timedout) or*/ (_redrawManager.interrupted()) ) break; - if ( isDrawableExtension((*islice)->getName()) ) { - _drawingQuery.setExtensionMask ( (*islice)->getMask() ); - _drawingQuery.setDrawExtensionGo ( (*islice)->getName() ); - _drawingQuery.setFilter ( getQueryFilter().set(Query::DoExtensionGos).unset(Query::DoMasterCells) ); - _drawingQuery.doQuery (); + if (isDrawableExtension(slice->getName())) { + _drawingQuery.setExtensionMask ( slice->getMask() ); + _drawingQuery.setDrawExtensionGo( slice->getName() ); + _drawingQuery.setFilter ( getQueryFilter().set (Query::DoExtensionGos) + .unset(Query::DoComponents + |Query::DoRubbers + |Query::DoMarkers + |Query::DoMasterCells) ); + _drawingQuery.doQuery (); } } } - _drawingPlanes.end (); + _drawingPlanes.end(); _cellModificated = false; } - if ( isDrawable("grid") ) drawGrid ( redrawArea ); - if ( isDrawable("text.ruler") ) drawRulers ( redrawArea ); + if (isDrawable("grid")) drawGrid ( redrawArea ); + if (isDrawable("text.ruler")) drawRulers( redrawArea ); - setDarkening ( 100 ); - if ( _state->showSelection() ) - redrawSelection ( redrawArea ); + setDarkening( 100 ); + if (_state->showSelection()) + redrawSelection( redrawArea ); - popCursor (); - repaint (); + popCursor(); + repaint(); //timer.stop (); //cerr << "CellWidget::redraw() - " << _redrawRectCount @@ -1568,8 +1575,8 @@ namespace Hurricane { void CellWidget::setLayerVisible ( const Name& layer, bool visible ) { - if ( !_palette ) return; - _palette->setItemVisible ( layer, visible ); + if (not _palette) return; + _palette->setItemVisible( layer, visible ); } @@ -1586,8 +1593,8 @@ namespace Hurricane { //DbU::Unit unity = symbolicMode() ? DbU::lambda(1.0) : DbU::grid(10.0); DbU::Unit unity = DbU::lambda(1.0); - return (!item || item->isItemVisible()) - && ( Graphics::getThreshold(name) < getScale()*unity ); + if (not item) return false; + return item->isItemVisible() and (Graphics::getThreshold(name) < getScale()*unity); } @@ -1595,7 +1602,8 @@ namespace Hurricane { { PaletteItem* item = (_palette) ? _palette->find(layerName) : NULL; - return !item || item->isItemVisible(); + if (not item) return false; + return item->isItemVisible(); } @@ -1604,8 +1612,8 @@ namespace Hurricane { PaletteItem* item = (_palette) ? _palette->find(extensionName) : NULL; DbU::Unit unity = DbU::lambda(1.0); - return (not item or item->isItemVisible()) - and ( Graphics::getThreshold(extensionName) < getScale()*unity ); + if (not item) return false; + return item->isItemVisible() and (Graphics::getThreshold(extensionName) < getScale()*unity); } diff --git a/hurricane/src/viewer/hurricane/viewer/CellWidget.h b/hurricane/src/viewer/hurricane/viewer/CellWidget.h index 5fc41f07..a176e958 100644 --- a/hurricane/src/viewer/hurricane/viewer/CellWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/CellWidget.h @@ -162,6 +162,7 @@ namespace Hurricane { // Painter control & Hurricane objects drawing primitives. inline void setEnableRedrawInterrupt ( bool ); inline void addDrawExtensionGo ( const Name&, InitExtensionGo_t*, DrawExtensionGo_t* ); + inline void copyDrawExtensionGos ( const CellWidget* ); inline QPainter& getPainter ( size_t plane=PlaneId::Working ); inline const DisplayStyle::HSVr& getDarkening () const; inline void copyToPrinter ( int xpaper, int ypaper, QPrinter*, PainterCb_t& ); @@ -176,6 +177,8 @@ namespace Hurricane { bool isDrawableExtension ( const Name& ); bool isSelectable ( const Name& ) const; bool isSelectable ( const Layer* ) const; + bool isPrinter () const; + void setPrinter ( bool ); inline void setDarkening ( const DisplayStyle::HSVr& ); inline void setPen ( const QPen& , size_t plane=PlaneId::Working ); void drawBox ( DbU::Unit, DbU::Unit, DbU::Unit, DbU::Unit ); @@ -452,6 +455,7 @@ namespace Hurricane { , InitExtensionGo_t* , DrawExtensionGo_t* ); + inline void copyDrawExtensionGos ( const DrawingQuery& ); void setDrawExtensionGo ( const Name& ); virtual bool hasMasterCellCallback () const; virtual bool hasGoCallback () const; @@ -647,6 +651,7 @@ namespace Hurricane { QPoint _mousePosition; Spot _spot; shared_ptr _state; + bool _isPrinter; bool _cellChanged; bool _selectionHasChanged; int _delaySelectionChanged; @@ -706,6 +711,10 @@ namespace Hurricane { { _drawExtensionGos[name] = make_pair(initExtensionGo,drawExtensionGo); } + inline void CellWidget::DrawingQuery::copyDrawExtensionGos ( const CellWidget::DrawingQuery& other ) + { _drawExtensionGos = other._drawExtensionGos; } + + inline void CellWidget::DrawingQuery::resetGoCount () { _goCount = 0; } @@ -1145,7 +1154,11 @@ namespace Hurricane { , InitExtensionGo_t* initExtensionGo , DrawExtensionGo_t* drawExtensionGo ) - { _drawingQuery.addDrawExtensionGo ( name, initExtensionGo, drawExtensionGo ); } + { _drawingQuery.addDrawExtensionGo( name, initExtensionGo, drawExtensionGo ); } + + + inline void CellWidget::copyDrawExtensionGos ( const CellWidget* other ) + { _drawingQuery.copyDrawExtensionGos( other->_drawingQuery ); } inline void CellWidget::setStartLevel ( int level ) @@ -1404,6 +1417,14 @@ namespace Hurricane { { _darkening = darkening; } + inline bool CellWidget::isPrinter () const + { return _isPrinter; } + + + inline void CellWidget::setPrinter ( bool state ) + { _isPrinter = state; } + + inline bool CellWidget::timeout ( const char* fname, const Timer& timer, double timeout, bool& timedout ) const { if ( timedout ) return true; diff --git a/katana/src/GraphicKatanaEngine.cpp b/katana/src/GraphicKatanaEngine.cpp index 5a826b9d..d0012e2f 100644 --- a/katana/src/GraphicKatanaEngine.cpp +++ b/katana/src/GraphicKatanaEngine.cpp @@ -92,28 +92,36 @@ namespace Katana { painter.setBrush( Graphics::getColorScale( ColorScale::Fire ).getBrush( density, widget->getDarkening() ) ); painter.drawRect( pixelBb ); } else { - if ( (pixelBb.width() > 150) or (pixelBb.height() > 150) ) { - painter.setPen ( pen ); - painter.setBrush( Graphics::getBrush("Anabatic::GCell",widget->getDarkening()) ); - painter.drawRect( pixelBb ); + int fontScale = 0; + int halfHeight = 20; + int halfWidth = 80; + if (widget->isPrinter()) { + fontScale = -5; + halfHeight = 9; + halfWidth = 39; + + } + + painter.setPen ( pen ); + painter.setBrush( Graphics::getBrush("Anabatic::GCell",widget->getDarkening()) ); + painter.drawRect( pixelBb ); - if ( (pixelBb.width() > 300) and (pixelBb.height() > 100) ) { - QString text = QString("id:%1").arg(gcell->getId()); - QFont font = Graphics::getFixedFont( QFont::Bold ); - painter.setFont(font); + if ( (pixelBb.width() > 2*halfWidth) and (pixelBb.height() > 2*halfHeight) ) { + QString text = QString("%1").arg(gcell->getId()); + QFont font = Graphics::getFixedFont( QFont::Normal, false, false, fontScale ); + painter.setFont(font); - pen.setWidth( 1 ); - painter.setPen( pen ); + pen.setWidth( 1 ); + painter.setPen( pen ); - painter.save (); - painter.translate( widget->dbuToScreenPoint(bb.getCenter().getX(), bb.getCenter().getY()) ); - painter.drawRect ( QRect( -80, -25, 160, 50 ) ); - painter.drawText ( QRect( -80, -25, 160, 50 ) - , text - , QTextOption(Qt::AlignCenter) - ); - painter.restore (); - } + painter.save (); + painter.translate( widget->dbuToScreenPoint(bb.getCenter().getX(), bb.getCenter().getY()) ); + painter.drawRect ( QRect( -halfWidth, -halfHeight, 2*halfWidth, 2*halfHeight ) ); + painter.drawText ( QRect( -halfWidth, -halfHeight, 2*halfWidth, 2*halfHeight ) + , text + , QTextOption(Qt::AlignCenter) + ); + painter.restore (); } } } @@ -140,11 +148,16 @@ namespace Katana { if (edge) { Box bb = edge->getBoundingBox(); uint32_t occupancy = 255; - if (edge->getRealOccupancy() < edge->getCapacity()) - occupancy = (uint32_t)( 255.0 * ( (float)edge->getRealOccupancy() / (float)edge->getCapacity() ) ); + //if (edge->getRealOccupancy() < edge->getCapacity()) + // occupancy = (uint32_t)( 255.0 * ( (float)edge->getRealOccupancy() / (float)edge->getCapacity() ) ); + + float edgeOccupancy = edge->getEstimateOccupancy() + (float)edge->getRealOccupancy(); + + if ((unsigned int)edgeOccupancy < edge->getCapacity()) + occupancy = (uint32_t)( 255.0 * (edgeOccupancy / (float)edge->getCapacity()) ); QPainter& painter = widget->getPainter(); - if (edge->getRealOccupancy() > edge->getCapacity()) { + if ((unsigned int)edgeOccupancy > edge->getCapacity()) { QColor color ( Qt::cyan ); painter.setPen( DisplayStyle::darken(color,widget->getDarkening()) ); } @@ -160,7 +173,10 @@ namespace Katana { if (fontHeight > ((edge->isHorizontal()) ? pixelBb.height() : pixelBb.width()) + 4) return; - QString text = QString("%1/%2").arg(edge->getRealOccupancy()).arg(edge->getCapacity()); + //QString text = QString("%1/%2").arg(edge->getRealOccupancy()).arg(edge->getCapacity()); + QString text = QString("%1/%2") + .arg( edgeOccupancy ) + .arg( edge->getCapacity() ); QColor color ( (occupancy > 170) ? Qt::black : Qt::white ); painter.setPen (DisplayStyle::darken(color,widget->getDarkening())); painter.setFont(font);