From d1d2a2ea019d7bac01a50a61a758fc69e3f79c1e Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Sat, 3 Apr 2010 13:56:07 +0000 Subject: [PATCH] * ./hurricane/src/hurricane: - New: In Query, add support for Markers, although they are Go's, are stored in a separate QuadTree directly at Cell level. In a very similar fashion to the ExtensionGos. Sometimes should look if thoses mecanism could be unified. * ./hurricane/src/viewer: - New: In CellWidget, add support for displaying References. Uses the Marker Query. For now labels are displayed centered on the reference point, making that point hard to see. That behavior may be changed later if needs to be. - Bug: In InspectorWidget, the History::push() wasn't updating the ComboBox index. The line was strangely commented out (?). --- hurricane/src/hurricane/Query.cpp | 52 +++++++++++-------- hurricane/src/hurricane/hurricane/Query.h | 8 ++- hurricane/src/viewer/CellWidget.cpp | 52 ++++++++++++++++--- hurricane/src/viewer/DisplayStyle.cpp | 2 + hurricane/src/viewer/InspectorWidget.cpp | 18 +++---- .../src/viewer/hurricane/viewer/CellWidget.h | 6 +++ .../viewer/hurricane/viewer/DisplayStyle.h | 1 + 7 files changed, 97 insertions(+), 42 deletions(-) diff --git a/hurricane/src/hurricane/Query.cpp b/hurricane/src/hurricane/Query.cpp index ba5c5645..a94f92ae 100644 --- a/hurricane/src/hurricane/Query.cpp +++ b/hurricane/src/hurricane/Query.cpp @@ -114,7 +114,7 @@ namespace Hurricane { void Query::doQuery () { - if ( _stack.getTopArea().isEmpty() || !_stack.getTopCell() ) return; + if ( _stack.getTopArea().isEmpty() or not _stack.getTopCell() ) return; //cerr << "Query::doQuery() - " << _stack.getTopCell() << " " << _stack.getTopArea() << " " << _basicLayer << endl; @@ -122,16 +122,16 @@ namespace Hurricane { while ( !_stack.empty() ) { // Process the Components of the current instance. - if ( hasGoCallback() && _basicLayer && (_filter.isSet(DoComponents)) ) { + if ( hasGoCallback() and _basicLayer and (_filter.isSet(DoComponents)) ) { //if ( getInstance() ) // cerr << getTab() << getInstance() << " " << getTransformation() << endl; //else // cerr << " TopCell: " << getMasterCell() << " " << getTransformation() << endl; - if ( !getMasterCell()->isTerminal() || (_filter.isSet(DoTerminalCells)) ) { + if ( not getMasterCell()->isTerminal() or (_filter.isSet(DoTerminalCells)) ) { forEach ( Slice*, islice, getMasterCell()->getSlices() ) { - if ( !(*islice)->getLayer()->contains(getBasicLayer()) ) continue; - if ( !(*islice)->getBoundingBox().intersect(getArea()) ) continue; + if ( not (*islice)->getLayer()->contains(getBasicLayer()) ) continue; + if ( not (*islice)->getBoundingBox().intersect(getArea()) ) continue; forEach ( Go*, igo, (*islice)->getGosUnder(_stack.getArea()) ) goCallback ( *igo ); @@ -139,16 +139,22 @@ namespace Hurricane { } } - if ( !getMasterCell()->isTerminal() && (_filter.isSet(DoRubbers)) ) { + if ( (not getMasterCell()->isTerminal() or (_filter.isSet(DoTerminalCells))) + and _filter.isSet(DoMarkers) ) { + forEach ( Marker*, marker, getMasterCell()->getMarkersUnder(_stack.getArea()) ) + markerCallback ( *marker ); + } + + if ( not getMasterCell()->isTerminal() and (_filter.isSet(DoRubbers)) ) { forEach ( Rubber*, rubber, getMasterCell()->getRubbersUnder(_stack.getArea()) ) rubberCallback ( *rubber ); } - if ( hasExtensionGoCallback() && (_filter.isSet(DoExtensionGos)) ) { - if ( !getMasterCell()->isTerminal() || (_filter.isSet(DoTerminalCells)) ) { + if ( hasExtensionGoCallback() and (_filter.isSet(DoExtensionGos)) ) { + if ( not getMasterCell()->isTerminal() or (_filter.isSet(DoTerminalCells)) ) { forEach ( ExtensionSlice*, islice, getMasterCell()->getExtensionSlices() ) { - if ( !( (*islice)->getMask() & _extensionMask ) ) continue; - if ( !(*islice)->getBoundingBox().intersect(getArea()) ) continue; + if ( not ( (*islice)->getMask() & _extensionMask ) ) continue; + if ( not (*islice)->getBoundingBox().intersect(getArea()) ) continue; forEach ( Go*, igo, (*islice)->getGosUnder(_stack.getArea()) ) extensionGoCallback ( *igo ); @@ -156,7 +162,7 @@ namespace Hurricane { } } - if ( (_filter.isSet(DoMasterCells)) && hasMasterCellCallback() ) + if ( (_filter.isSet(DoMasterCells)) and hasMasterCellCallback() ) masterCellCallback (); _stack.progress (); @@ -165,27 +171,27 @@ namespace Hurricane { bool Query::hasGoCallback () const - { - return false; - } + { return false; } + + + bool Query::hasMarkerCallback () const + { return false; } bool Query::hasRubberCallback () const - { - return false; - } + { return false; } bool Query::hasExtensionGoCallback () const - { - return false; - } + { return false; } bool Query::hasMasterCellCallback () const - { - return false; - } + { return false; } + + + void Query::markerCallback ( Marker* ) + { } void Query::rubberCallback ( Rubber* ) diff --git a/hurricane/src/hurricane/hurricane/Query.h b/hurricane/src/hurricane/hurricane/Query.h index 8203c3d7..38bc64b6 100644 --- a/hurricane/src/hurricane/hurricane/Query.h +++ b/hurricane/src/hurricane/hurricane/Query.h @@ -298,11 +298,13 @@ namespace Hurricane { enum QueryFilter { DoMasterCells = 1 , DoTerminalCells = 2 , DoComponents = 4 - , DoRubbers = 8 - , DoExtensionGos = 16 + , DoMarkers = 8 + , DoRubbers = 16 + , DoExtensionGos = 32 , DoAll = DoMasterCells | DoTerminalCells | DoComponents + | DoMarkers | DoRubbers | DoExtensionGos }; @@ -321,10 +323,12 @@ namespace Hurricane { inline Instance* getInstance (); //inline const Tabulation& getTab () const; virtual bool hasGoCallback () const; + virtual bool hasMarkerCallback () const; virtual bool hasRubberCallback () const; virtual bool hasExtensionGoCallback () const; virtual bool hasMasterCellCallback () const; virtual void goCallback ( Go* ) = 0; + virtual void markerCallback ( Marker* ); virtual void rubberCallback ( Rubber* ); virtual void extensionGoCallback ( Go* ) = 0; virtual void masterCellCallback () = 0; diff --git a/hurricane/src/viewer/CellWidget.cpp b/hurricane/src/viewer/CellWidget.cpp index c2b4b554..6ef009c8 100644 --- a/hurricane/src/viewer/CellWidget.cpp +++ b/hurricane/src/viewer/CellWidget.cpp @@ -844,16 +844,41 @@ namespace Hurricane { } - bool CellWidget::DrawingQuery::hasRubberCallback () const + bool CellWidget::DrawingQuery::hasMarkerCallback () const + { return true; } + + + void CellWidget::DrawingQuery::markerCallback ( Marker* marker ) + { drawMarker ( marker, getArea(), getTransformation() ); } + + + void CellWidget::DrawingQuery::drawMarker ( const Marker* marker + , const Box& area + , const Transformation& transformation + ) { - return true; + static QRect rectangle; + + const Reference* reference = dynamic_cast(marker); + if ( reference ) { + _goCount++; + Box bb = transformation.getBox(reference->getBoundingBox()).inflate(DbU::lambda(5.0)); + rectangle = _cellWidget->dbuToDisplayRect ( bb ); + + if ( _cellWidget->isDrawable("text.reference") and (getDepth() < 2) ) { + const char* refName = reference->getName()._getSharedName()->_getSString().c_str(); + _cellWidget->drawDisplayText ( rectangle, refName, BigFont|Bold|Center|Frame ); + } + } } + bool CellWidget::DrawingQuery::hasRubberCallback () const + { return true; } + + void CellWidget::DrawingQuery::rubberCallback ( Rubber* rubber ) - { - drawRubber ( rubber, getArea(), getTransformation() ); - } + { drawRubber ( rubber, getArea(), getTransformation() ); } void CellWidget::DrawingQuery::drawRubber ( const Rubber* rubber @@ -1381,7 +1406,7 @@ namespace Hurricane { if ( isDrawable((*iLayer)->getName()) ) { _drawingQuery.setBasicLayer ( *iLayer ); - _drawingQuery.setFilter ( getQueryFilter().unset(Query::DoMasterCells|Query::DoRubbers) ); + _drawingQuery.setFilter ( getQueryFilter().unset(Query::DoMasterCells|Query::DoRubbers|Query::DoMarkers) ); _drawingQuery.doQuery (); } if ( _enableRedrawInterrupt ) QApplication::processEvents(); @@ -1398,7 +1423,18 @@ namespace Hurricane { _drawingPlanes.setBrush ( Graphics::getBrush("boundaries",getDarkening()) ); _drawingQuery.setBasicLayer ( NULL ); - _drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents|Query::DoRubbers) ); + _drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents|Query::DoRubbers|Query::DoMarkers) ); + _drawingQuery.doQuery (); + } + } + + if ( /*!timeout("redraw [markers]",timer,10.0,timedout) &&*/ (!_redrawManager.interrupted()) ) { + if ( isDrawable("text.reference") ) { + _drawingPlanes.setPen ( Graphics::getPen ("text.reference",getDarkening()) ); + _drawingPlanes.setBrush ( Graphics::getBrush("text.reference",getDarkening()) ); + + _drawingQuery.setBasicLayer ( NULL ); + _drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents|Query::DoMasterCells) ); _drawingQuery.doQuery (); } } @@ -1409,7 +1445,7 @@ namespace Hurricane { _drawingPlanes.setBrush ( Graphics::getBrush("rubber",getDarkening()) ); _drawingQuery.setBasicLayer ( NULL ); - _drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents|Query::DoMasterCells) ); + _drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents|Query::DoMasterCells|Query::DoMarkers) ); _drawingQuery.doQuery (); } } diff --git a/hurricane/src/viewer/DisplayStyle.cpp b/hurricane/src/viewer/DisplayStyle.cpp index 23de1822..8efce484 100644 --- a/hurricane/src/viewer/DisplayStyle.cpp +++ b/hurricane/src/viewer/DisplayStyle.cpp @@ -53,6 +53,7 @@ namespace Hurricane { const Name DisplayStyle::TextCell = "text.cell"; const Name DisplayStyle::TextInstance = "text.instance"; const Name DisplayStyle::TextComponent = "text.component"; + const Name DisplayStyle::TextReference = "text.reference"; const Name DisplayStyle::Undef = "undef"; @@ -270,6 +271,7 @@ namespace Hurricane { addDrawingStyle ( Viewer, TextCell , "8822441188224411", 255, 255, 255, 0, 1.0 ); addDrawingStyle ( Viewer, TextInstance , "8822441188224411", 255, 255, 255, 0, 1.0 ); addDrawingStyle ( Viewer, TextComponent, "FFFFFFFFFFFFFFFF", 255, 255, 255, 0, 1.0 ); + addDrawingStyle ( Viewer, TextReference, "FFFFFFFFFFFFFFFF", 255, 255, 255, 0, 1.0 ); addDrawingStyle ( Viewer, Undef , "2244118822441188", 238, 130, 238, 0, 1.0 ); } diff --git a/hurricane/src/viewer/InspectorWidget.cpp b/hurricane/src/viewer/InspectorWidget.cpp index 3a314c2c..ef5636f3 100644 --- a/hurricane/src/viewer/InspectorWidget.cpp +++ b/hurricane/src/viewer/InspectorWidget.cpp @@ -66,7 +66,7 @@ namespace Hurricane { _depth++; _slots.push_back ( slot->getClone() ); _comboBox->addItem ( QString("%1: %2").arg(_depth).arg(_slots[_slots.size()-1]->getDataString().c_str())); - //_comboBox->setCurrentIndex ( _depth ); + _comboBox->setCurrentIndex ( _depth ); //cerr << "After History::push()" << endl; } @@ -161,14 +161,14 @@ namespace Hurricane { InspectorWidget::InspectorWidget ( QWidget* parent ) - : QWidget(parent) - , _baseModel(NULL) - , _sortModel(NULL) - , _historyComboBox(NULL) - , _view(NULL) - , _rowHeight(20) - , _history() - , _rootOccurrence() + : QWidget (parent) + , _baseModel (NULL) + , _sortModel (NULL) + , _historyComboBox(NULL) + , _view (NULL) + , _rowHeight (20) + , _history () + , _rootOccurrence () { setAttribute ( Qt::WA_DeleteOnClose ); setAttribute ( Qt::WA_QuitOnClose, false ); diff --git a/hurricane/src/viewer/hurricane/viewer/CellWidget.h b/hurricane/src/viewer/hurricane/viewer/CellWidget.h index a9508896..f4613451 100644 --- a/hurricane/src/viewer/hurricane/viewer/CellWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/CellWidget.h @@ -457,11 +457,13 @@ namespace Hurricane { void setDrawExtensionGo ( const Name& ); virtual bool hasMasterCellCallback () const; virtual bool hasGoCallback () const; + virtual bool hasMarkerCallback () const; virtual bool hasRubberCallback () const; virtual bool hasExtensionGoCallback () const; virtual void masterCellCallback (); virtual void goCallback ( Go* ); virtual void rubberCallback ( Rubber* ); + virtual void markerCallback ( Marker* ); virtual void extensionGoCallback ( Go* ); void drawMasterCell ( const Cell* cell , const Transformation& transformation @@ -475,6 +477,10 @@ namespace Hurricane { , const Box& area , const Transformation& transformation ); + void drawMarker ( const Marker* marker + , const Box& area + , const Transformation& transformation + ); void drawExtensionGo ( CellWidget* widget , const Go* go , const BasicLayer* basicLayer diff --git a/hurricane/src/viewer/hurricane/viewer/DisplayStyle.h b/hurricane/src/viewer/hurricane/viewer/DisplayStyle.h index c50c864a..71479519 100644 --- a/hurricane/src/viewer/hurricane/viewer/DisplayStyle.h +++ b/hurricane/src/viewer/hurricane/viewer/DisplayStyle.h @@ -157,6 +157,7 @@ namespace Hurricane { static const Name TextCell; static const Name TextInstance; static const Name TextComponent; + static const Name TextReference; static const Name Undef; static const Name UnmatchedGroup;