diff --git a/crlcore/src/ccore/Catalog.cpp b/crlcore/src/ccore/Catalog.cpp index 26bb3723..8f691bd8 100644 --- a/crlcore/src/ccore/Catalog.cpp +++ b/crlcore/src/ccore/Catalog.cpp @@ -27,7 +27,7 @@ using namespace std; namespace CRL { - const char* MissingStateProperty = "%s:\n\n Missing Catalog State Property in cell \"%s\".\n"; + const char* MissingStateProperty = "%s:\n\n Missing Catalog State Property in cell \"%s\".\n"; // ------------------------------------------------------------------- @@ -41,6 +41,17 @@ namespace CRL { } + Cell* Catalog::State::setCell ( Cell* cell ) + { + _cell = cell; + if (_cell) { + if (isPad ()) _cell->setPad ( true ); + if (isFeed()) _cell->setFeed( true ); + } + return _cell; + } + + void Catalog::State::merge ( const State& other ) { if ( (_cell ==NULL) && other._cell ) _cell = other._cell; @@ -78,7 +89,6 @@ namespace CRL { return record; } - // ------------------------------------------------------------------- // Class : "Catalog". diff --git a/crlcore/src/ccore/crlcore/Catalog.h b/crlcore/src/ccore/crlcore/Catalog.h index 73a9f4ed..0b272450 100644 --- a/crlcore/src/ccore/crlcore/Catalog.h +++ b/crlcore/src/ccore/crlcore/Catalog.h @@ -112,7 +112,7 @@ namespace CRL { inline unsigned int getDepth () const; // Modifiers. inline void merge ( const State& other ); - inline Cell* setCell ( Cell* cell ); + Cell* setCell ( Cell* cell ); inline Library* setLibrary ( Library* library ); inline void setDepth ( unsigned int depth ); // Hurricane Management. @@ -193,7 +193,6 @@ namespace CRL { inline bool Catalog::State::setDelete ( bool value ) { return setFlags(Delete ,value); } inline bool Catalog::State::setPhysical ( bool value ) { return setFlags(Physical ,value); } inline bool Catalog::State::setLogical ( bool value ) { return setFlags(Logical ,value); } - inline Cell* Catalog::State::setCell ( Cell* cell ) { return _cell = cell; } inline Library* Catalog::State::setLibrary ( Library* library ) { return _library = library; } inline void Catalog::State::setDepth ( unsigned int depth ) { _depth = depth; } inline Cell* Catalog::State::getCell () const { return _cell; } diff --git a/hurricane/src/hurricane/Path.cpp b/hurricane/src/hurricane/Path.cpp index 72c0253d..36a17c38 100644 --- a/hurricane/src/hurricane/Path.cpp +++ b/hurricane/src/hurricane/Path.cpp @@ -245,6 +245,19 @@ void Path::setNameSeparator(char nameSeparator) SharedPath::setNameSeparator(nameSeparator); } +string Path::getCompactString() const +// ********************************** +{ + if (isEmpty()) return ""; + + string s = "<"; + s += getString(getOwnerCell()->getName()); + s += ":"; + s += getString(_sharedPath->getName()) + ":"; + s += getString(getMasterCell()->getName()) + ">"; + return s; +} + string Path::_getString() const // **************************** { diff --git a/hurricane/src/hurricane/hurricane/Cell.h b/hurricane/src/hurricane/hurricane/Cell.h index 9ef539dd..0ea136a4 100644 --- a/hurricane/src/hurricane/hurricane/Cell.h +++ b/hurricane/src/hurricane/hurricane/Cell.h @@ -88,11 +88,12 @@ class Cell : public Entity { , Terminal = 0x00001000 , FlattenLeaf = 0x00002000 , Pad = 0x00004000 - , FlattenedNets = 0x00008000 - , Placed = 0x00010000 - , Routed = 0x00020000 - , MergedQuadTree = 0x00040000 - , Materialized = 0x00080000 + , Feed = 0x00008000 + , FlattenedNets = 0x00010000 + , Placed = 0x00020000 + , Routed = 0x00040000 + , MergedQuadTree = 0x00080000 + , Materialized = 0x00100000 }; public: @@ -391,6 +392,7 @@ class Cell : public Entity { public: bool isUniquified() const; public: bool isUniquifyMaster() const; public: bool isPad() const {return _flags.isset(Flags::Pad);}; + public: bool isFeed() const {return _flags.isset(Flags::Feed);}; public: bool isFlattenedNets() const {return _flags.isset(Flags::FlattenedNets);}; public: bool isPlaced() const {return _flags.isset(Flags::Placed);}; public: bool isRouted() const {return _flags.isset(Flags::Routed);}; @@ -406,6 +408,7 @@ class Cell : public Entity { public: void setTerminal(bool isTerminal) {_flags.set(Flags::Terminal,isTerminal);}; public: void setFlattenLeaf(bool isFlattenLeaf) {_flags.set(Flags::FlattenLeaf,isFlattenLeaf);}; public: void setPad(bool isPad) {_flags.set(Flags::Pad,isPad);}; + public: void setFeed(bool isFeed) {_flags.set(Flags::Feed,isFeed);}; public: void flattenNets(unsigned int flags=Flags::BuildRings); public: void createRoutingPadRings(unsigned int flags=Flags::BuildRings); public: void setFlags(unsigned int flags) { _flags |= flags; } diff --git a/hurricane/src/hurricane/hurricane/Path.h b/hurricane/src/hurricane/hurricane/Path.h index 80dca474..bd5d4fc6 100644 --- a/hurricane/src/hurricane/hurricane/Path.h +++ b/hurricane/src/hurricane/hurricane/Path.h @@ -97,6 +97,7 @@ class Path { // Others // ****** + public: string getCompactString() const; public: string _getTypeName() const { return _TName("Occurrence"); }; public: string _getString() const; public: Record* _getRecord() const; diff --git a/hurricane/src/viewer/CMakeLists.txt b/hurricane/src/viewer/CMakeLists.txt index 25aed97f..344b80eb 100644 --- a/hurricane/src/viewer/CMakeLists.txt +++ b/hurricane/src/viewer/CMakeLists.txt @@ -36,6 +36,8 @@ hurricane/viewer/SelectionWidget.h hurricane/viewer/NetlistModel.h hurricane/viewer/NetlistWidget.h + hurricane/viewer/HierarchyModel.h + hurricane/viewer/HierarchyWidget.h hurricane/viewer/DisplayFilterWidget.h hurricane/viewer/ControllerWidget.h hurricane/viewer/ScriptWidget.h @@ -104,6 +106,9 @@ NetInformations.cpp NetlistModel.cpp NetlistWidget.cpp + HierarchyInformations.cpp + HierarchyModel.cpp + HierarchyWidget.cpp DisplayFilterWidget.cpp ControllerWidget.cpp ScriptWidget.cpp diff --git a/hurricane/src/viewer/CellViewer.cpp b/hurricane/src/viewer/CellViewer.cpp index 226af418..f7dff57d 100644 --- a/hurricane/src/viewer/CellViewer.cpp +++ b/hurricane/src/viewer/CellViewer.cpp @@ -550,7 +550,10 @@ namespace Hurricane { list< shared_ptr >::iterator istate = _cellHistory.begin(); for ( size_t i=0 ; igetName()).c_str() ); + QString entry = tr("&%1: %2 %3") + .arg(i+1) + .arg( getString((*istate)->getName()).c_str() ) + .arg( (*istate)->getTopPath().getCompactString().c_str() ); _cellHistoryAction[i]->setText ( entry ); _cellHistoryAction[i]->setVisible ( true ); istate++; @@ -689,12 +692,11 @@ namespace Hurricane { void CellViewer::openHistoryCell () { - QAction* historyAction = qobject_cast ( sender() ); - if ( historyAction ) { + QAction* historyAction = qobject_cast( sender() ); + if (historyAction) { list< shared_ptr >::iterator istate = _cellHistory.begin(); - //size_t index = historyAction->data().toUInt(); - //for ( ; index>0 ; index--, istate++ ) - // cerr << "History: " << (*istate)->getName() << endl; + size_t index = historyAction->data().toUInt(); + for ( ; index>0 ; index--, ++istate ); emit stateChanged ( *istate ); } } diff --git a/hurricane/src/viewer/CellWidget.cpp b/hurricane/src/viewer/CellWidget.cpp index 8981c15e..4a4a99d9 100644 --- a/hurricane/src/viewer/CellWidget.cpp +++ b/hurricane/src/viewer/CellWidget.cpp @@ -977,6 +977,7 @@ namespace Hurricane { State* clone = new State(); clone->setCell ( getCell() ); + clone->setTopPath ( getTopPath() ); clone->setCursorStep ( getCursorStep() ); clone->setUnitPower ( getUnitPower() ); clone->setDbuMode ( getDbuMode() ); @@ -1173,6 +1174,12 @@ namespace Hurricane { } + void CellWidget::resetCommands () + { + for ( size_t i=0 ; i<_commands.size() ; ++i ) _commands[i]->reset(); + } + + void CellWidget::pushCursor ( Qt::CursorShape cursor ) { setCursor ( cursor ); @@ -2410,39 +2417,46 @@ namespace Hurricane { } - void CellWidget::setCell ( Cell* cell ) + void CellWidget::setCell ( Cell* cell, Path topPath, unsigned int flags ) { //cerr << "CellWidget::setCell() - " << cell << endl; - if ( cell == getCell() ) return; + if (cell == getCell()) return; - openRefreshSession (); + if (not topPath.isEmpty() and (topPath.getTailInstance()->getMasterCell() != cell)) { + cerr << Warning( "CellWidget::setCell(): Incompatible Path %s with %s." + , topPath.getCompactString().c_str() + , getString(cell->getName()).c_str() ) << endl; + topPath = Path(); + } - shared_ptr state ( new State(cell) ); - setState ( state ); - if ( cell and cell->isTerminal() ) setQueryFilter ( ~0 ); + openRefreshSession(); + + shared_ptr state ( new State(cell,topPath) ); + setState( state, flags ); + if ( cell and cell->isTerminal() ) setQueryFilter( ~0 ); //setRealMode (); - fitToContents ( false ); + fitToContents( false ); - _state->setHistoryEnable ( true ); + _state->setHistoryEnable( true ); - closeRefreshSession (); + closeRefreshSession(); } - void CellWidget::setState ( shared_ptr& state ) + void CellWidget::setState ( shared_ptr& state, unsigned int flags ) { //cerr << "CellWidget::setState() - " << state->getName() << endl; - if ( state == _state ) return; + if (state == _state) return; - openRefreshSession (); - - cellPreModificate (); - _state->getSelection ().clear (); - _state->setCellWidget ( NULL ); - _state->setTopLeft ( getTopLeft() ); + openRefreshSession(); + cellPreModificate(); + if (not (flags & NoResetCommands)) resetCommands(); + _state->getSelection ().clear (); + _state->setCellWidget( NULL ); + _state->setTopLeft ( getTopLeft() ); _cellChanged = true; _state = state; @@ -2453,23 +2467,22 @@ namespace Hurricane { // << DbU::getValueString(_state->getTopLeft().getX()) << "," // << DbU::getValueString(_state->getTopLeft().getY()) << ")" << endl; - _state->setHistoryEnable ( false ); - _state->setCellWidget ( this ); - _drawingQuery .setCell ( getCell() ); - _drawingQuery .setStartLevel ( _state->getStartLevel() ); - _drawingQuery .setStopLevel ( _state->getStopLevel() ); - _textDrawingQuery.setCell ( getCell() ); + _state->setHistoryEnable( false ); + _state->setCellWidget ( this ); + _drawingQuery .setCell ( getCell() ); + _drawingQuery .setStartLevel( _state->getStartLevel() ); + _drawingQuery .setStopLevel ( _state->getStopLevel() ); + _textDrawingQuery.setCell ( getCell() ); - reframe (); - _state->setHistoryEnable ( true ); + reframe(); + _state->setHistoryEnable( true ); - emit cellChanged ( getCell() ); - emit stateChanged ( _state ); - emit queryFilterChanged (); + emit cellChanged ( getCell() ); + emit stateChanged ( _state ); + emit queryFilterChanged(); - cellPostModificate (); - - closeRefreshSession (); + cellPostModificate(); + closeRefreshSession(); } diff --git a/hurricane/src/viewer/Command.cpp b/hurricane/src/viewer/Command.cpp index f7949edb..271f311f 100644 --- a/hurricane/src/viewer/Command.cpp +++ b/hurricane/src/viewer/Command.cpp @@ -1,32 +1,22 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2015, All Rights Reserved +// Copyright (c) UPMC 2008-2015, All Rights Reserved // -// =================================================================== -// -// $Id$ -// -// x-----------------------------------------------------------------x -// | | +// +-----------------------------------------------------------------+ // | H U R R I C A N E | // | V L S I B a c k e n d D a t a - B a s e | // | | // | Author : Jean-Paul CHAPUT | -// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | // | C++ Module : "./Command.cpp" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// +-----------------------------------------------------------------+ #include #include #include - #include #include @@ -68,6 +58,7 @@ namespace Hurricane { void Command::mousePressEvent ( QMouseEvent* ) { } void Command::mouseReleaseEvent ( QMouseEvent* ) { } void Command::draw () { } + void Command::reset () { } } // End of Hurricane namespace. diff --git a/hurricane/src/viewer/ControllerWidget.cpp b/hurricane/src/viewer/ControllerWidget.cpp index ad15f900..d657919e 100644 --- a/hurricane/src/viewer/ControllerWidget.cpp +++ b/hurricane/src/viewer/ControllerWidget.cpp @@ -8,7 +8,7 @@ // | V L S I B a c k e n d D a t a - B a s e | // | | // | Author : Jean-Paul CHAPUT | -// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | // | C++ Module : "./ControllerWidget.cpp" | // +-----------------------------------------------------------------+ @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -267,6 +268,62 @@ namespace Hurricane { } +// ------------------------------------------------------------------- +// Class : "Hurricane::TabNetlist". + + + TabHierarchy::TabHierarchy ( QWidget* parent ) + : ControllerTab (parent) + , _hierarchyBrowser (new HierarchyWidget()) + { + _hierarchyBrowser->setObjectName ( "controller.tabHierarchy.hierarchyBrowser" ); + + QVBoxLayout* wLayout = new QVBoxLayout (); + wLayout->setContentsMargins ( 10, 0, 10, 0 ); + wLayout->setSpacing ( 0 ); + + QFrame* separator = new QFrame (); + separator->setFrameShape ( QFrame::HLine ); + separator->setFrameShadow ( QFrame::Sunken ); + wLayout->addWidget ( separator ); + wLayout->addWidget ( _hierarchyBrowser ); + + setLayout ( wLayout ); + } + + + void TabHierarchy::setCell ( Cell* cell ) + { } + + + void TabHierarchy::setCellWidget ( CellWidget* cellWidget ) + { + if (getCellWidget() != cellWidget) { + ControllerTab::setCellWidget( cellWidget ); + _hierarchyBrowser->setCellWidget( cellWidget ); + if (getCellWidget()) { + connect( getCellWidget(), SIGNAL(cellChanged(Cell*)), this, SLOT(setCell(Cell*)) ); + } + } + } + + + void TabHierarchy::cellPreModificate () + { } + + + void TabHierarchy::cellPostModificate () + { + CellWidget* cw = getCellWidget(); + Cell* topCell = cw->getTopCell(); + if (not topCell) topCell = cw->getCell(); + _hierarchyBrowser->setCell( topCell ); + + if (not cw->getTopPath().isEmpty()) + _hierarchyBrowser->rexpand( cw->getTopPath() ); + } + + // ------------------------------------------------------------------- // Class : "Hurricane::TabSelection". @@ -475,48 +532,51 @@ namespace Hurricane { , _tabPalette (new TabPalette()) , _tabDisplayFilter(new TabDisplayFilter()) , _tabNetlist (new TabNetlist()) + , _tabHierarchy (new TabHierarchy()) , _tabSelection (new TabSelection()) , _tabInspector (new TabInspector()) , _tabSettings (new TabSettings()) { - setObjectName ( "controller" ); - setAttribute ( Qt::WA_QuitOnClose, false ); - setWindowTitle ( tr("Controller") ); + setObjectName ( "controller" ); + setAttribute ( Qt::WA_QuitOnClose, false ); + setWindowTitle( tr("Controller") ); //connect ( _netlistBrowser, SIGNAL(destroyed()), this, SLOT(netlistBrowserDestroyed()) ); - _tabGraphics ->setObjectName ( "controller.graphics" ); - _tabPalette ->setObjectName ( "controller.palette" ); - _tabDisplayFilter->setObjectName ( "controller.displayFilter" ); - _tabNetlist ->setObjectName ( "controller.tabNetlist" ); - _tabSelection ->setObjectName ( "controller.tabSelection" ); - _tabInspector ->setObjectName ( "controller.tabInspector" ); - _tabSettings ->setObjectName ( "controller.tabSettings" ); + _tabGraphics ->setObjectName( "controller.graphics" ); + _tabPalette ->setObjectName( "controller.palette" ); + _tabDisplayFilter->setObjectName( "controller.displayFilter" ); + _tabNetlist ->setObjectName( "controller.tabNetlist" ); + _tabHierarchy ->setObjectName( "controller.tabHierarchy" ); + _tabSelection ->setObjectName( "controller.tabSelection" ); + _tabInspector ->setObjectName( "controller.tabInspector" ); + _tabSettings ->setObjectName( "controller.tabSettings" ); - addTab ( _tabGraphics , "Look" ); - addTab ( _tabDisplayFilter , "Filter" ); - addTab ( _tabPalette , "Layers&&Gos" ); - addTab ( _tabNetlist , "Netlist" ); - addTab ( _tabSelection , "Selection" ); - addTab ( _tabInspector , "Inspector" ); - addTab ( _tabSettings , "Settings" ); + addTab( _tabGraphics , "Look" ); + addTab( _tabDisplayFilter , "Filter" ); + addTab( _tabPalette , "Layers&&Gos" ); + addTab( _tabHierarchy , "Hierarchy" ); + addTab( _tabNetlist , "Netlist" ); + addTab( _tabSelection , "Selection" ); + addTab( _tabInspector , "Inspector" ); + addTab( _tabSettings , "Settings" ); QAction* toggleShow = new QAction ( tr("Controller"), this ); - toggleShow->setObjectName ( "controller.action.hideShow" ); - toggleShow->setShortcut ( QKeySequence(tr("CTRL+I")) ); - addAction ( toggleShow ); + toggleShow->setObjectName( "controller.action.hideShow" ); + toggleShow->setShortcut ( QKeySequence(tr("CTRL+I")) ); + addAction( toggleShow ); - connect ( toggleShow, SIGNAL(triggered()) , this, SLOT(toggleShow()) ); - connect ( this , SIGNAL(currentChanged(int)), this, SLOT(updateTab(int)) ); - connect ( _tabSelection->getSelection(), SIGNAL(inspect(Occurrence&)) - , _tabInspector , SLOT (setSelectionOccurrence(Occurrence&)) ); + connect( toggleShow, SIGNAL(triggered()) , this, SLOT(toggleShow()) ); + connect( this , SIGNAL(currentChanged(int)), this, SLOT(updateTab(int)) ); + connect( _tabSelection->getSelection(), SIGNAL(inspect(Occurrence&)) + , _tabInspector , SLOT (setSelectionOccurrence(Occurrence&)) ); - resize ( Graphics::toHighDpi(600), Graphics::toHighDpi(500) ); + resize( Graphics::toHighDpi(600), Graphics::toHighDpi(500) ); } void ControllerWidget::toggleShow () - { setVisible ( !isVisible() ); } + { setVisible( !isVisible() ); } void ControllerWidget::setCellWidget ( CellWidget* cellWidget ) diff --git a/hurricane/src/viewer/HierarchyCommand.cpp b/hurricane/src/viewer/HierarchyCommand.cpp index bc66dfa2..179e5d08 100644 --- a/hurricane/src/viewer/HierarchyCommand.cpp +++ b/hurricane/src/viewer/HierarchyCommand.cpp @@ -1,26 +1,17 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2015, All Rights Reserved +// Copyright (c) UPMC 2008-2015, All Rights Reserved // -// =================================================================== -// -// $Id$ -// -// x-----------------------------------------------------------------x -// | | +// +-----------------------------------------------------------------+ // | H U R R I C A N E | // | V L S I B a c k e n d D a t a - B a s e | // | | // | Author : Jean-Paul CHAPUT | -// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | // | C++ Module : "./HierarchyCommand.cpp" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// +-----------------------------------------------------------------+ # include @@ -58,41 +49,53 @@ namespace Hurricane { { return _name; } + void HierarchyCommand::reset () + { + _history.clear(); + _historyIndex = 0; + } + + void HierarchyCommand::keyReleaseEvent ( QKeyEvent* event ) { bool control = (event->modifiers() & Qt::ControlModifier); bool shift = (event->modifiers() & Qt::ShiftModifier ); - if ( !shift && !control ) return; - if ( !_cellWidget->getCell() ) return; + if (not shift and not control) return; + if (not _cellWidget->getCell()) return; QPoint position ( _cellWidget->mapFromGlobal(QCursor::pos()) ); Box pointBox ( _cellWidget->screenToDbuBox(QRect(position,QSize(1,1))) ); switch ( event->key() ) { case Qt::Key_Up: - if ( ( _historyIndex > 0 ) && (shift || control) ) { - _cellWidget->setState ( _history[--_historyIndex]._state ); + if ( (_historyIndex > 0) and (shift or control) ) { + _cellWidget->setState ( _history[--_historyIndex], CellWidget::NoResetCommands ); } break; case Qt::Key_Down: { - if ( control ) { - if ( _history.empty() ) - _history.push_back ( HistoryEntry ( NULL, _cellWidget->getState() ) ); + if (control) { + Path topPath; + if (_history.empty()) { + _history.push_back( _cellWidget->getState() ); + topPath = _cellWidget->getState()->getTopPath(); + } else if (_historyIndex > 0) { + topPath = _history[_historyIndex-1]->getTopPath(); + } - Instances instances = _cellWidget->getCell()->getInstancesUnder ( pointBox ); - if ( !instances.isEmpty() ) { - _history.erase ( _history.begin()+_historyIndex+1, _history.end() ); + Instances instances = _cellWidget->getCell()->getInstancesUnder( pointBox ); + if (not instances.isEmpty()) { + _history.erase( _history.begin()+_historyIndex+1, _history.end() ); - Instance* instance = instances.getFirst (); - _cellWidget->setCell ( instance->getMasterCell() ); - _history.push_back ( HistoryEntry ( instance, _cellWidget->getState() ) ); + topPath = Path( topPath, instances.getFirst() ); + _cellWidget->setCell( topPath.getMasterCell(), topPath, CellWidget::NoResetCommands ); + _history.push_back( _cellWidget->getState() ); _historyIndex++; } - } else if ( shift ) { - if ( _historyIndex+1 < _history.size() ) { - _cellWidget->setState ( _history[++_historyIndex]._state ); + } else if (shift) { + if (_historyIndex+1 < _history.size()) { + _cellWidget->setState( _history[++_historyIndex], CellWidget::NoResetCommands ); } } } diff --git a/hurricane/src/viewer/HierarchyInformations.cpp b/hurricane/src/viewer/HierarchyInformations.cpp new file mode 100644 index 00000000..4a8a31fb --- /dev/null +++ b/hurricane/src/viewer/HierarchyInformations.cpp @@ -0,0 +1,288 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2015-2015, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | H U R R I C A N E | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./HierarchyInformations.cpp" | +// +-----------------------------------------------------------------+ + + +#include +#include "hurricane/Name.h" +#include "hurricane/Cell.h" +#include "hurricane/Instance.h" +#include "hurricane/viewer/HierarchyInformations.h" + + +namespace Hurricane { + + +// ------------------------------------------------------------------- +// Class : "HierarchyInfos" + + HierarchyInfos::HierarchyInfos ( HierarchyInfos* parent, size_t rowInParent ) + : _parent (parent) + , _rowInParent(rowInParent) + { } + + + HierarchyInfos::~HierarchyInfos () + { } + + + int HierarchyInfos::getColumnCount () + { return 2; } + + + QVariant HierarchyInfos::getColumnName ( int column ) + { + switch ( column ) { + case 0: return QVariant(QObject::tr("Instance")); + case 1: return QVariant(QObject::tr("Model/Cell")); + } + return QVariant(QObject::tr("Column Out of Bound")); + } + + + QVariant HierarchyInfos::getColumn ( int column ) const + { + if (isRoot()) return QVariant(QObject::tr("RootItem")); + + const Instance* instance = getInstance(); + if (instance) { + switch ( column ) { + case 0: return getString(instance->getName()).c_str(); + case 1: return getString(instance->getMasterCell()->getName()).c_str(); + } + } else { + switch ( column ) { + case 0: return ""; + case 1: return getString(getMasterCell()->getName()).c_str(); + } + } + + return QVariant(QObject::tr("Column Out of Bound")); + } + + + Path HierarchyInfos::getPath () const + { + if (isRoot() or not getInstance()) return Path(); + + return Path( getParent()->getPath(), const_cast(getInstance()) ); + } + + +// ------------------------------------------------------------------- +// Class : "LeafHierarchyInfos" + + + const vector LeafHierarchyInfos::_instances; + + + LeafHierarchyInfos::LeafHierarchyInfos ( const Instance* instance + , HierarchyInfos* parent + , size_t rowInParent ) + : HierarchyInfos(parent,rowInParent) + , _instance(instance) + { } + + + LeafHierarchyInfos::~LeafHierarchyInfos () + { } + + + bool LeafHierarchyInfos::isRoot () const { return false; } + bool LeafHierarchyInfos::isLeaf () const { return true; } + bool LeafHierarchyInfos::isCollapsed () const { return true; } + const HierarchyInfos* LeafHierarchyInfos::getRow ( int row ) const { return NULL; } + int LeafHierarchyInfos::size () const { return 0; } + Cell* LeafHierarchyInfos::getMasterCell () const { return _instance->getMasterCell(); } + const Instance* LeafHierarchyInfos::getInstance () const { return _instance; } + const std::vector& LeafHierarchyInfos::getInstances () const { return _instances; } + QString LeafHierarchyInfos::getFilterPattern () const { return ""; } + void LeafHierarchyInfos::setFilterPattern ( const QString& ) { } + void LeafHierarchyInfos::expand () { } + void LeafHierarchyInfos::collapse () { } + + +// ------------------------------------------------------------------- +// Class : "InstHierarchyInfos" + + InstHierarchyInfos::InstHierarchyInfos ( const Instance* instance + , HierarchyInfos* parent + , size_t rowInParent ) + : HierarchyInfos(parent,rowInParent) + , _flags (HierarchyInfos::Collapsed) + , _instance (instance) + , _instances() + { } + + + InstHierarchyInfos::~InstHierarchyInfos () + { + collapse(); + } + + + bool InstHierarchyInfos::isRoot () const { return false; } + bool InstHierarchyInfos::isLeaf () const { return false; } + bool InstHierarchyInfos::isCollapsed () const { return _flags & HierarchyInfos::Collapsed; } + Cell* InstHierarchyInfos::getMasterCell () const { return _instance->getMasterCell(); } + const Instance* InstHierarchyInfos::getInstance () const { return _instance; } + const std::vector& InstHierarchyInfos::getInstances () const { return _instances; } + QString InstHierarchyInfos::getFilterPattern () const { return _filter.pattern(); } + + + int InstHierarchyInfos::size () const + { + if (_flags & HierarchyInfos::Collapsed) { + const_cast(this)->expand(); + } + return _instances.size(); + } + + + void InstHierarchyInfos::setFilterPattern ( const QString& pattern ) + { + _filter.setPattern( pattern ); + + if (_flags & HierarchyInfos::Collapsed) return; + + size_t i = 0; + for ( Instance* instance : getMasterCell()->getInstances() ) { + if (instance->getMasterCell()->isFeed()) continue; + + if ( (i < _instances.size()) and (instance == _instances[i]->getInstance()) ) { + // The instance *is already* in the list. + if ( not _filter.isEmpty() and (_filter.indexIn(getString(instance->getName()).c_str()) < 0) ) { + delete _instances[i]; + _instances.erase( _instances.begin()+i ); + } else { + ++i; + } + } else { + // The instance *is not* in the list. + if (_filter.isEmpty() or (_filter.indexIn(getString(instance->getName()).c_str()) >= 0) ) { + HierarchyInfos* infos = NULL; + if (instance->isLeaf()) infos = new LeafHierarchyInfos( instance, this, 0 ); + else infos = new InstHierarchyInfos( instance, this, 0 ); + + _instances.insert( _instances.begin()+i, infos ); + ++i; + } + } + } + + for ( size_t i=0 ; i<_instances.size() ; ++i ) _instances[i]->setRowInParent( i ); + } + + + void InstHierarchyInfos::expand () + { + if (not (_flags & HierarchyInfos::Collapsed)) return; + _flags &= ~HierarchyInfos::Collapsed; + + if (not getMasterCell()) return; + + for ( Instance* instance : getMasterCell()->getInstances() ) { + if (instance->getMasterCell()->isFeed()) continue; + if (not _filter.isEmpty()) { + if (_filter.indexIn(getString(instance->getName()).c_str()) < 0) continue; + } + + HierarchyInfos* infos = NULL; + if (instance->isLeaf()) infos = new LeafHierarchyInfos( instance, this, _instances.size() ); + else infos = new InstHierarchyInfos( instance, this, _instances.size() ); + + _instances.push_back( infos ); + } + } + + + void InstHierarchyInfos::collapse () + { + if (_flags & HierarchyInfos::Collapsed) return; + _flags |= HierarchyInfos::Collapsed; + + for ( HierarchyInfos* info : _instances ) delete info; + + vector().swap( _instances ); + } + + + const HierarchyInfos* InstHierarchyInfos::getRow ( int row ) const + { + if (_flags & HierarchyInfos::Collapsed) { + const_cast(this)->expand(); + } + + if (row >= (int)_instances.size()) return NULL; + return _instances[row]; + } + + +// ------------------------------------------------------------------- +// Class : "TopCellHierarchyInfos" + + TopCellHierarchyInfos::TopCellHierarchyInfos ( Cell* cell, HierarchyInfos* parent ) + : InstHierarchyInfos(NULL,parent,0) + , _rootCell(cell) + { expand(); } + + + TopCellHierarchyInfos::~TopCellHierarchyInfos () + { collapse(); } + + + bool TopCellHierarchyInfos::isRoot () const { return false; } + Cell* TopCellHierarchyInfos::getMasterCell () const { return _rootCell; } + const Instance* TopCellHierarchyInfos::getInstance () const { return NULL; } + + + void TopCellHierarchyInfos::setCell ( Cell* rootCell ) + { + collapse(); + _rootCell = rootCell; + expand(); + } + + +// ------------------------------------------------------------------- +// Class : "RootHierarchyInfos" + + + RootHierarchyInfos::RootHierarchyInfos ( Cell* cell ) + : HierarchyInfos(NULL,0) + , _instances() + { + _instances.push_back( new TopCellHierarchyInfos(cell,this) ); + } + + + RootHierarchyInfos::~RootHierarchyInfos () + { delete _instances[0]; } + + + bool RootHierarchyInfos::isRoot () const { return true; } + bool RootHierarchyInfos::isLeaf () const { return false; } + bool RootHierarchyInfos::isCollapsed () const { return false; } + int RootHierarchyInfos::size () const { return _instances.size(); } + const HierarchyInfos* RootHierarchyInfos::getRow ( int row ) const { return (row==0) ? _instances[0] : NULL; } + Cell* RootHierarchyInfos::getMasterCell () const { return _instances[0]->getMasterCell(); } + const Instance* RootHierarchyInfos::getInstance () const { return NULL; } + const std::vector& RootHierarchyInfos::getInstances () const { return _instances; } + QString RootHierarchyInfos::getFilterPattern () const { return ""; } + void RootHierarchyInfos::setFilterPattern ( const QString& ) { } + void RootHierarchyInfos::expand () { } + void RootHierarchyInfos::collapse () { } + void RootHierarchyInfos::setCell ( Cell* topCell ) { dynamic_cast(_instances[0])->setCell(topCell); } + +} // End of Hurricane namespace. diff --git a/hurricane/src/viewer/HierarchyModel.cpp b/hurricane/src/viewer/HierarchyModel.cpp new file mode 100644 index 00000000..2dd8bf60 --- /dev/null +++ b/hurricane/src/viewer/HierarchyModel.cpp @@ -0,0 +1,146 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2015-2015, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | H U R R I C A N E | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./HierarchyModel.cpp" | +// +-----------------------------------------------------------------+ + + +#include +#include +#include "hurricane/Name.h" +#include "hurricane/Net.h" +#include "hurricane/Cell.h" +#include "hurricane/viewer/Graphics.h" +#include "hurricane/viewer/HierarchyInformations.h" +#include "hurricane/viewer/HierarchyModel.h" + + +namespace Hurricane { + + + HierarchyModel::HierarchyModel ( QObject* parent ) + : QAbstractItemModel(parent) + , _root (NULL) + { } + + + HierarchyModel::~HierarchyModel () + { } + + + bool HierarchyModel::hasChildren ( const QModelIndex& parent ) const + { + if (not parent.isValid()) return true; + + const HierarchyInfos* infos = infosFromIndex(parent); + if (not infos) return true; + + return not infos->isLeaf(); + } + + + QVariant HierarchyModel::data ( const QModelIndex& index, int role ) const + { + static QFont nameFont = Graphics::getFixedFont( QFont::Bold ); + static QFont valueFont = Graphics::getFixedFont( QFont::Normal, true ); + + if (role == Qt::FontRole) { + switch (index.column()) { + case 0: return nameFont; + default: return valueFont; + } + return QVariant(); + } + + if (not index.isValid()) return QVariant(); + + if (role == Qt::DisplayRole) { + const HierarchyInfos* infos = infosFromIndex( index ); + if (infos) + return infos->getColumn( index.column() ); + } + return QVariant(); + } + + + QVariant HierarchyModel::headerData ( int section + , Qt::Orientation orientation + , int role ) const + { + if (orientation == Qt::Vertical) return QVariant(); + + static QFont headerFont = Graphics::getFixedFont( QFont::Bold, false, false, +0 ); + + if (role == Qt::FontRole ) return headerFont; + if (role != Qt::DisplayRole ) return QVariant(); + if (role == Qt::SizeHintRole) return (Graphics::isHighDpi()) ? 600 : 300; + + return HierarchyInfos::getColumnName( section ); + } + + + int HierarchyModel::rowCount ( const QModelIndex& parent ) const + { + const HierarchyInfos* infos = infosFromIndex( parent ); + if (not infos) return 0; + + if (infos->isCollapsed()) { + cerr << "HierarchyModel::rowCount(): collapsed " << infos->size() << " " << infos->getInstance() << endl; + } + + return infos->size(); + } + + + int HierarchyModel::columnCount ( const QModelIndex& parent ) const + { return _root.getColumnCount(); } + + + QModelIndex HierarchyModel::index ( int row, int column, const QModelIndex& parent ) const + { + if (not _root.getMasterCell() or (row < 0) or (column < 0)) return QModelIndex(); + + const HierarchyInfos* parentInfos = infosFromIndex( parent ); + const HierarchyInfos* childInfos = parentInfos->getRow( row ); + + if (not childInfos) return QModelIndex(); + + QModelIndex index = createIndex( row, column, (void*)childInfos ); + // cerr << "HierarchyModel::index(): " << index.row() << "+" << index.column() + // << ":" << index.internalPointer() + // << " " << childInfos->getMasterCell() << endl; + + return index; + } + + + QModelIndex HierarchyModel::parent ( const QModelIndex& child ) const + { + const HierarchyInfos* childInfos = infosFromIndex( child ); + if (not childInfos) return QModelIndex(); + + const HierarchyInfos* parentInfos = childInfos->getParent(); + if (not parentInfos) return QModelIndex(); + + const HierarchyInfos* grandParentInfos = parentInfos->getParent(); + if (not grandParentInfos) return QModelIndex(); + + QModelIndex index = createIndex( parentInfos->getRowInParent(), 0, (void*)parentInfos ); + // cerr << "HierarchyModel::index(): " << index.row() << "+" << index.column() + // << ":" << index.internalPointer() + // << " " << childInfos->getMasterCell() << endl; + + return index; + } + + +} // Hurricane namespace. diff --git a/hurricane/src/viewer/HierarchyWidget.cpp b/hurricane/src/viewer/HierarchyWidget.cpp new file mode 100644 index 00000000..b92cc485 --- /dev/null +++ b/hurricane/src/viewer/HierarchyWidget.cpp @@ -0,0 +1,265 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2015-2015, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | H U R R I C A N E | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./HierarchyWidget.cpp" | +// +-----------------------------------------------------------------+ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "hurricane/Commons.h" +#include "hurricane/Warning.h" +#include "hurricane/Net.h" +#include "hurricane/viewer/Graphics.h" +#include "hurricane/viewer/HierarchyModel.h" +#include "hurricane/viewer/HierarchyWidget.h" + + +namespace Hurricane { + + +// ------------------------------------------------------------------- +// Class : "HierarchyWidget". + + + HierarchyWidget::HierarchyWidget ( QWidget* parent ) + : QWidget (parent) + , _cellWidget (NULL) + , _cell (NULL) + , _baseModel (new HierarchyModel(this)) + , _view (new QTreeView(this)) + , _filterPatternLineEdit(new QLineEdit(this)) + , _rowHeight (20) + { + setAttribute( Qt::WA_DeleteOnClose ); + setAttribute( Qt::WA_QuitOnClose, false ); + setContextMenuPolicy( Qt::ActionsContextMenu ); + + _rowHeight = QFontMetrics( Graphics::getFixedFont() ).height() + 4; + + //_view->setShowGrid ( false ); + _view->setAlternatingRowColors( true ); + _view->setSelectionBehavior ( QAbstractItemView::SelectRows ); + _view->setSelectionMode ( QAbstractItemView::SingleSelection ); + _view->setSortingEnabled ( true ); + _view->setModel ( _baseModel ); + //_view->resizeColumnToContents ( 1 ); + + QHeaderView* horizontalHeader = _view->header(); + horizontalHeader->setDefaultAlignment ( Qt::AlignHCenter ); + horizontalHeader->setMinimumSectionSize( (Graphics::isHighDpi()) ? 600 : 300 ); + horizontalHeader->setResizeMode ( 0, QHeaderView::Interactive ); + horizontalHeader->setResizeMode ( 1, QHeaderView::Interactive ); + horizontalHeader->setStretchLastSection( true ); + + QLabel* filterPatternLabel = new QLabel(tr("&Filter pattern:"), this); + filterPatternLabel->setBuddy( _filterPatternLineEdit ); + + QGridLayout* gLayout = new QGridLayout(); + gLayout->addWidget( _view , 1, 0, 1, 2 ); + gLayout->addWidget( filterPatternLabel , 2, 0 ); + gLayout->addWidget(_filterPatternLineEdit, 2, 1); + + setLayout( gLayout ); + + connect ( _view, SIGNAL(collapsed (const QModelIndex&)) + , this , SLOT (collapseHook(const QModelIndex& )) ); + connect ( _filterPatternLineEdit , SIGNAL(returnPressed ()) + , this , SLOT (textFilterChanged()) ); + connect ( _view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)) + , this , SLOT (followSelected (const QItemSelection&,const QItemSelection&)) ); + + TreeKeyFilter* filter = new TreeKeyFilter( this ); + _view->installEventFilter( filter ); + + resize(300, 300); + } + + + void HierarchyWidget::setCell ( Cell* cell ) + { + if (_cell == cell) return; + + _cell = cell; + _view->setVisible( false ); + _view->selectionModel()->clear(); + _baseModel->setCell( cell ); + + string windowTitle = "Hierarchy" + getString(cell); + setWindowTitle( tr(windowTitle.c_str()) ); + + _view->selectionModel()->select( _baseModel->index(0,0,_view->rootIndex()) + , QItemSelectionModel::Select|QItemSelectionModel::Rows ); + _view->resizeColumnToContents( 0 ); + _view->setVisible( true ); + } + + + bool HierarchyWidget::isRSelected ( const QModelIndex& index ) const + { + HierarchyInfos* infos = const_cast(_baseModel->infosFromIndex(index)); + for ( size_t row=0 ; row < infos->getInstances().size() ; ++row ) { + QModelIndex childIndex = _baseModel->index( row, 0, index ); + if (_view->selectionModel()->isSelected(childIndex)) + return true; + + if (not infos->isCollapsed() and isRSelected(childIndex)) return true; + } + + return false; + } + + + void HierarchyWidget::rexpand ( Path path ) + { + if (path.isEmpty()) return; + + QModelIndex index = _baseModel->index( 0, 0, QModelIndex() ); + do { + Instance* head = path.getHeadInstance(); + path = path.getTailPath(); + + _view->expand( index ); + HierarchyInfos* parentInfos = const_cast( _baseModel->infosFromIndex(index) ); + HierarchyInfos* childInfos = NULL; + + for ( HierarchyInfos* child : parentInfos->getInstances() ) { + if (child->getInstance() == head) { + childInfos = child; + break; + } + } + if (not childInfos) { + cerr << Warning("HierarchyWidget::rexpand(): discrepency between Path and Hierarchy.") << endl; + return; + } + + index = _baseModel->index( childInfos->getRowInParent(), 0, index ); + } while (not path.isEmpty()); + + _view->selectionModel()->clear(); + _view->selectionModel()->select( index, QItemSelectionModel::Select|QItemSelectionModel::Rows ); + _view->setCurrentIndex( index ); + } + + + void HierarchyWidget::rexpand ( const QModelIndex& index ) + { + HierarchyInfos* infos = const_cast(_baseModel->infosFromIndex(index)); + if (infos) { + if (not infos->isCollapsed()) { + _view->expand( index ); + for ( HierarchyInfos* child : infos->getInstances() ) { + rexpand( _baseModel->index( child->getRowInParent(), 0, index ) ); + } + } + } + } + + + void HierarchyWidget::collapseHook ( const QModelIndex& index ) + { + if (isRSelected(index)) { + _view->selectionModel()->clear(); + _view->selectionModel()->select( index, QItemSelectionModel::Select|QItemSelectionModel::Rows ); + } + + HierarchyInfos* infos = const_cast(_baseModel->infosFromIndex(index)); + infos->collapse(); + } + + + void HierarchyWidget::textFilterChanged () + { + QModelIndexList selecteds = _view->selectionModel()->selectedIndexes(); + + if (not selecteds.isEmpty()) { + QModelIndex index = selecteds[0]; + HierarchyInfos* infos = const_cast(_baseModel->infosFromIndex(index)); + infos->setFilterPattern( _filterPatternLineEdit->text() ); + _view->reset(); + rexpand( _view->rootIndex() ); + _view->selectionModel()->select( index, QItemSelectionModel::Select|QItemSelectionModel::Rows ); + _view->setCurrentIndex( index ); + } + } + + + void HierarchyWidget::followSelected ( const QItemSelection& selecteds, const QItemSelection& deselecteds ) + { + if (selecteds.indexes().isEmpty()) { + //cerr << Warning("HierarchyWidget::followSelected(): Selection should never be empty.") << endl; + return; + } + + QModelIndex index = selecteds.indexes()[0]; + HierarchyInfos* infos = const_cast(_baseModel->infosFromIndex(index)); + _filterPatternLineEdit->setText( infos->getFilterPattern() ); + } + + + void HierarchyWidget::goTo ( int delta ) + { + if (delta == 0) return; + + QModelIndex newIndex = _baseModel->index( _view->currentIndex().row()+delta, 0, QModelIndex() ); + + //if (newIndex.isValid()) + // _view->selectRow( newIndex.row() ); + } + + +// ------------------------------------------------------------------- +// Class : "TreeKeyFilter". + + + TreeKeyFilter::TreeKeyFilter ( QObject* parent ) + : QObject(parent) + { } + + + bool TreeKeyFilter::eventFilter ( QObject* object, QEvent* event ) + { + if (event->type() == QEvent::KeyPress) { + HierarchyWidget* owner = qobject_cast( parent() ); + if (not owner) return false; + + QKeyEvent* keyEvent = static_cast(event); + + if (keyEvent->key() == Qt::Key_Return) { + QModelIndexList selecteds = owner->_view->selectionModel()->selectedIndexes(); + + if (not selecteds.isEmpty()) { + QModelIndex index = selecteds[0]; + HierarchyInfos* infos = const_cast(owner->_baseModel->infosFromIndex(index)); + if (infos) { + if (owner->getCellWidget()) { + owner->getCellWidget()->setCell( infos->getMasterCell(), infos->getPath() ); + } + } + } + } + } + + return QObject::eventFilter( object, event ); + } + + +} // Hurricane namespace. diff --git a/hurricane/src/viewer/hurricane/viewer/CellWidget.h b/hurricane/src/viewer/hurricane/viewer/CellWidget.h index 2be1da63..69d9fc6f 100644 --- a/hurricane/src/viewer/hurricane/viewer/CellWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/CellWidget.h @@ -97,15 +97,18 @@ namespace Hurricane { typedef void ( InitExtensionGo_t )( CellWidget* ); typedef boost::function< void(QPainter&) > PainterCb_t; enum RubberShape { Centric=1, Barycentric, Steiner }; - enum TextFlag { Bold =0x001 - , BigFont =0x002 - , Reverse =0x004 - , Frame =0x008 - , Rounded =0x010 - , Center =0x020 - , Left =0x040 - , Right =0x080 - , Top =0x100 + enum TextFlag { Bold =0x0001 + , BigFont =0x0002 + , Reverse =0x0004 + , Frame =0x0008 + , Rounded =0x0010 + , Center =0x0020 + , Left =0x0040 + , Right =0x0080 + , Top =0x0100 + }; + enum Flag { NoFlags =0x0000 + , NoResetCommands=0x0001 }; public: enum ResolutionMode { Res_CellMode=1, Res_DesignMode=2 }; @@ -115,8 +118,10 @@ namespace Hurricane { virtual ~CellWidget (); // Accessors. // MapView* getMapView () { return _mapView; }; - void setCell ( Cell* ); + void setCell ( Cell*, Path topPath=Path(), unsigned int flags=NoFlags ); inline Cell* getCell () const; + inline Cell* getTopCell () const; + inline Path getTopPath () const; inline shared_ptr& getState (); inline shared_ptr getStateClone (); inline PaletteWidget* getPalette (); @@ -132,6 +137,7 @@ namespace Hurricane { void detachFromPalette (); void bindCommand ( Command* ); void unbindCommand ( Command* ); + void resetCommands (); inline void setActiveCommand ( Command* ); inline Command* getActiveCommand () const; Command* getCommand ( const std::string& ) const; @@ -245,7 +251,8 @@ namespace Hurricane { virtual void paintEvent ( QPaintEvent* ); public slots: // Qt QWidget Slots Overload & CellWidget Specifics. - void setState ( shared_ptr& ); + void setState ( shared_ptr& + , unsigned int flags=NoFlags ); inline void openRefreshSession (); inline void closeRefreshSession (); inline DrawingPlanes& getDrawingPlanes (); @@ -534,9 +541,10 @@ namespace Hurricane { public: class State { public: - inline State ( Cell* cell=NULL ); + inline State ( Cell* cell=NULL, Path topPath=Path() ); State* clone () const; inline void setCell ( Cell* ); + inline void setTopPath ( Path ); inline void setCellWidget ( CellWidget* ); inline void setCursorStep ( DbU::Unit ); inline DbU::Unit getCursorStep () const; @@ -557,6 +565,8 @@ namespace Hurricane { bool scaleHistoryUp (); bool scaleHistoryDown (); inline Cell* getCell () const; + inline Cell* getTopCell () const; + inline Path getTopPath () const; const Name& getName () const; inline SelectorCriterions& getSelection (); inline RulerSet& getRulers (); @@ -590,6 +600,7 @@ namespace Hurricane { private: Cell* _cell; + Path _topPath; CellWidget* _cellWidget; SelectorCriterions _selection; RulerSet _rulers; @@ -879,8 +890,9 @@ namespace Hurricane { { } - inline CellWidget::State::State ( Cell* cell ) + inline CellWidget::State::State ( Cell* cell, Path topPath ) : _cell (cell) + , _topPath (topPath) , _cellWidget (NULL) , _selection () , _rulers () @@ -922,6 +934,10 @@ namespace Hurricane { { _cell = cell; } + inline void CellWidget::State::setTopPath ( Path topPath ) + { _topPath = topPath; } + + inline void CellWidget::State::setCellWidget ( CellWidget* cw ) { _cellWidget = cw; @@ -1002,6 +1018,14 @@ namespace Hurricane { { return _cell; } + inline Path CellWidget::State::getTopPath () const + { return _topPath; } + + + inline Cell* CellWidget::State::getTopCell () const + { return (_topPath.isEmpty()) ? _cell : _topPath.getOwnerCell(); } + + inline DbU::Unit CellWidget::State::cursorStep () const { return _cursorStep; } @@ -1255,6 +1279,14 @@ namespace Hurricane { { return _state->getCell(); } + inline Cell* CellWidget::getTopCell () const + { return _state->getTopCell(); } + + + inline Path CellWidget::getTopPath () const + { return _state->getTopPath(); } + + inline PaletteWidget* CellWidget::getPalette () { return _palette; } diff --git a/hurricane/src/viewer/hurricane/viewer/Command.h b/hurricane/src/viewer/hurricane/viewer/Command.h index eef67714..b6296e3d 100644 --- a/hurricane/src/viewer/hurricane/viewer/Command.h +++ b/hurricane/src/viewer/hurricane/viewer/Command.h @@ -1,27 +1,24 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2012, All Rights Reserved +// Copyright (c) UPMC 2008-2015, All Rights Reserved // // +-----------------------------------------------------------------+ // | H U R R I C A N E | // | V L S I B a c k e n d D a t a - B a s e | // | | // | Author : Jean-Paul CHAPUT | -// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | // | C++ Header : "./hurricane/viewer/Command.h" | // +-----------------------------------------------------------------+ -#ifndef __HURRICANE_COMMAND_H__ -#define __HURRICANE_COMMAND_H__ - - -#include -#include +#ifndef HURRICANE_COMMAND_H +#define HURRICANE_COMMAND_H +#include +#include class QKeyEvent; class QMouseEvent; @@ -54,6 +51,7 @@ namespace Hurricane { virtual void mousePressEvent ( QMouseEvent* ); virtual void mouseReleaseEvent ( QMouseEvent* ); virtual void draw (); + virtual void reset (); private: Command ( const Command& ); Command& operator= ( const Command& ); diff --git a/hurricane/src/viewer/hurricane/viewer/ControllerWidget.h b/hurricane/src/viewer/hurricane/viewer/ControllerWidget.h index be9f7873..ae95f958 100644 --- a/hurricane/src/viewer/hurricane/viewer/ControllerWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/ControllerWidget.h @@ -9,7 +9,7 @@ // | V L S I B a c k e n d D a t a - B a s e | // | | // | Author : Jean-Paul CHAPUT | -// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | // | C++ Header : "./hurricane/viewer/ControllerWidget.h" | // +-----------------------------------------------------------------+ @@ -42,6 +42,7 @@ namespace Hurricane { class GraphicsWidget; class DisplayFilterWidget; class NetlistWidget; + class HierarchyWidget; class SelectionWidget; class InspectorWidget; @@ -167,6 +168,30 @@ namespace Hurricane { inline QCheckBox* TabNetlist::getSyncSelection () { return _syncSelection; } +// ------------------------------------------------------------------- +// Class : "Hurricane::TabHierarchy". + + + class TabHierarchy : public ControllerTab { + Q_OBJECT; + + public: + TabHierarchy ( QWidget* parent=NULL ); + inline HierarchyWidget* getHierarchyBrowser (); + virtual void cellPreModificate (); + virtual void cellPostModificate (); + public slots: + virtual void setCell ( Cell* ); + virtual void setCellWidget ( CellWidget* ); + + protected: + HierarchyWidget* _hierarchyBrowser; + }; + + + inline HierarchyWidget* TabHierarchy::getHierarchyBrowser () { return _hierarchyBrowser; } + + // ------------------------------------------------------------------- // Class : "Hurricane::TabSelection". @@ -268,23 +293,24 @@ namespace Hurricane { Q_OBJECT; public: - ControllerWidget ( QWidget* parent=NULL ); - inline CellWidget* getCellWidget (); - inline GraphicsWidget* getGraphics (); - inline PaletteWidget* getPalette (); - inline DisplayFilterWidget* getDisplayFilter (); - inline NetlistWidget* getNetlistBrowser (); - inline SelectionWidget* getSelection (); - inline InspectorWidget* getInspectorWidget (); - inline TabSettings* getSettings (); - void setCellWidget ( CellWidget* ); - //inline int addSetting ( QWidget* page, const QString& label ); - public slots: - void cellPreModificate (); - void cellPostModificate (); - void cellChanged ( Cell* ); - void updateTab ( int index ); - void toggleShow (); + ControllerWidget ( QWidget* parent=NULL ); + inline CellWidget* getCellWidget (); + inline GraphicsWidget* getGraphics (); + inline PaletteWidget* getPalette (); + inline DisplayFilterWidget* getDisplayFilter (); + inline NetlistWidget* getNetlistBrowser (); + inline HierarchyWidget* getHierarchyBrowser (); + inline SelectionWidget* getSelection (); + inline InspectorWidget* getInspectorWidget (); + inline TabSettings* getSettings (); + void setCellWidget ( CellWidget* ); + //inline int addSetting ( QWidget* page, const QString& label ); + public slots: + void cellPreModificate (); + void cellPostModificate (); + void cellChanged ( Cell* ); + void updateTab ( int index ); + void toggleShow (); protected: CellWidget* _cellWidget; @@ -292,21 +318,23 @@ namespace Hurricane { TabPalette* _tabPalette; TabDisplayFilter* _tabDisplayFilter; TabNetlist* _tabNetlist; + TabHierarchy* _tabHierarchy; TabSelection* _tabSelection; TabInspector* _tabInspector; TabSettings* _tabSettings; }; - inline CellWidget* ControllerWidget::getCellWidget () { return _cellWidget; } - inline GraphicsWidget* ControllerWidget::getGraphics () { return _tabGraphics->getGraphics(); } - inline PaletteWidget* ControllerWidget::getPalette () { return _tabPalette->getPalette(); } - inline DisplayFilterWidget* ControllerWidget::getDisplayFilter () { return _tabDisplayFilter->getDisplayFilter(); } - inline NetlistWidget* ControllerWidget::getNetlistBrowser () { return _tabNetlist->getNetlistBrowser(); } - inline SelectionWidget* ControllerWidget::getSelection () { return _tabSelection->getSelection(); } - inline InspectorWidget* ControllerWidget::getInspectorWidget () { return _tabInspector->getInspectorWidget(); } - inline TabSettings* ControllerWidget::getSettings () { return _tabSettings; } -//inline int ControllerWidget::addSetting ( QWidget* page, const QString& label ) { return _tabSettings->addSetting(page,label); } + inline CellWidget* ControllerWidget::getCellWidget () { return _cellWidget; } + inline GraphicsWidget* ControllerWidget::getGraphics () { return _tabGraphics->getGraphics(); } + inline PaletteWidget* ControllerWidget::getPalette () { return _tabPalette->getPalette(); } + inline DisplayFilterWidget* ControllerWidget::getDisplayFilter () { return _tabDisplayFilter->getDisplayFilter(); } + inline NetlistWidget* ControllerWidget::getNetlistBrowser () { return _tabNetlist->getNetlistBrowser(); } + inline HierarchyWidget* ControllerWidget::getHierarchyBrowser () { return _tabHierarchy->getHierarchyBrowser(); } + inline SelectionWidget* ControllerWidget::getSelection () { return _tabSelection->getSelection(); } + inline InspectorWidget* ControllerWidget::getInspectorWidget () { return _tabInspector->getInspectorWidget(); } + inline TabSettings* ControllerWidget::getSettings () { return _tabSettings; } +//inline int ControllerWidget::addSetting ( QWidget* page, const QString& label ) { return _tabSettings->addSetting(page,label); } } // End of Hurricane namespace. diff --git a/hurricane/src/viewer/hurricane/viewer/HierarchyCommand.h b/hurricane/src/viewer/hurricane/viewer/HierarchyCommand.h index db74882b..201063de 100644 --- a/hurricane/src/viewer/hurricane/viewer/HierarchyCommand.h +++ b/hurricane/src/viewer/hurricane/viewer/HierarchyCommand.h @@ -1,87 +1,55 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2015, All Rights Reserved +// Copyright (c) UPMC 2008-2015, All Rights Reserved // -// =================================================================== -// -// $Id$ -// -// x-----------------------------------------------------------------x -// | | +// +-----------------------------------------------------------------+ // | H U R R I C A N E | // | V L S I B a c k e n d D a t a - B a s e | // | | // | Author : Jean-Paul CHAPUT | -// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | // | C++ Header : "./HierarchyCommand.h" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// +-----------------------------------------------------------------+ -#ifndef __HURRICANE_HIERARCHY_COMMAND__ -#define __HURRICANE_HIERARCHY_COMMAND__ - -#include - -#include -#include +#ifndef HURRICANE_HIERARCHY_COMMAND_H +#define HURRICANE_HIERARCHY_COMMAND_H +#include +#include +#include class QAction; -#include "hurricane/Occurrence.h" -#include "hurricane/viewer/Command.h" -#include "hurricane/viewer/CellWidget.h" - - -using namespace std; +#include "hurricane/Occurrence.h" +#include "hurricane/viewer/Command.h" +#include "hurricane/viewer/CellWidget.h" namespace Hurricane { - class Cell; class HierarchyCommand : public Command { public: - HierarchyCommand (); - virtual ~HierarchyCommand (); - virtual const string& getName () const; - virtual void keyReleaseEvent ( QKeyEvent* ); + HierarchyCommand (); + virtual ~HierarchyCommand (); + virtual const std::string& getName () const; + virtual void reset (); + virtual void keyReleaseEvent ( QKeyEvent* ); private: - HierarchyCommand ( const HierarchyCommand& ); - HierarchyCommand& operator= ( const HierarchyCommand& ); + HierarchyCommand ( const HierarchyCommand& ); + HierarchyCommand& operator= ( const HierarchyCommand& ); private: - class HistoryEntry { - public: - inline HistoryEntry ( Instance*, shared_ptr ); - public: - Instance* _instance; - shared_ptr _state; - }; - private: - static string _name; - vector _history; - size_t _historyIndex; + static std::string _name; + std::vector< std::shared_ptr > _history; + size_t _historyIndex; }; -// Inline Functions. - inline HierarchyCommand::HistoryEntry::HistoryEntry ( Instance* instance - , shared_ptr state - ) - : _instance(instance) - , _state (state) - { } +} // Hurricane namespace. - -} // End of Hurricane namespace. - - -#endif +#endif // HURRICANE_HIERARCHY_COMMAND_H diff --git a/hurricane/src/viewer/hurricane/viewer/HierarchyInformations.h b/hurricane/src/viewer/hurricane/viewer/HierarchyInformations.h new file mode 100644 index 00000000..9a44cf11 --- /dev/null +++ b/hurricane/src/viewer/hurricane/viewer/HierarchyInformations.h @@ -0,0 +1,178 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2015-2015, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | H U R R I C A N E | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./hurricane/viewer/HierarchyInformations.h" | +// +-----------------------------------------------------------------+ + + +#ifndef HURRICANE_HIERARCHY_INFORMATIONS_H +#define HURRICANE_HIERARCHY_INFORMATIONS_H + +#include +#include +#include +#include "hurricane/Commons.h" +#include "hurricane/Path.h" + + +namespace Hurricane { + + class Instance; + class Cell; + + +// ------------------------------------------------------------------- +// Class : "HierarchyInfos" + + + class HierarchyInfos { + public: + enum Flags { NoFlags=0x0000, Collapsed=0x0001 }; + public: + HierarchyInfos ( HierarchyInfos* parent, size_t rowInParent ); + virtual ~HierarchyInfos (); + virtual bool isRoot () const = 0; + virtual bool isLeaf () const = 0; + virtual bool isCollapsed () const = 0; + static int getColumnCount (); + static QVariant getColumnName ( int column ); + QVariant getColumn ( int column ) const; + virtual const HierarchyInfos* getRow ( int row ) const = 0; + inline const HierarchyInfos* getParent () const; + inline size_t getRowInParent () const; + virtual int size () const = 0; + virtual Cell* getMasterCell () const = 0; + virtual const Instance* getInstance () const = 0; + virtual const std::vector& getInstances () const = 0; + inline const Name getName () const; + virtual Path getPath () const; + virtual QString getFilterPattern () const = 0; + virtual void setFilterPattern ( const QString& ) = 0; + inline void setRowInParent ( size_t ); + virtual void expand () = 0; + virtual void collapse () = 0; + protected: + HierarchyInfos* _parent; + size_t _rowInParent; + }; + + + inline size_t HierarchyInfos::getRowInParent () const { return _rowInParent; } + inline const HierarchyInfos* HierarchyInfos::getParent () const { return _parent; } + inline const Name HierarchyInfos::getName () const { return isRoot() ? Name("Root") : getInstance()->getName(); } + inline void HierarchyInfos::setRowInParent ( size_t rowInParent ) { _rowInParent=rowInParent; } + + +// ------------------------------------------------------------------- +// Class : "LeafHierarchyInfos" + + + class LeafHierarchyInfos : public HierarchyInfos { + public: + LeafHierarchyInfos ( const Instance* + , HierarchyInfos* parent + , size_t rowInParent ); + virtual ~LeafHierarchyInfos (); + virtual bool isRoot () const; + virtual bool isLeaf () const; + virtual bool isCollapsed () const; + virtual const HierarchyInfos* getRow ( int row ) const; + virtual int size () const; + virtual Cell* getMasterCell () const; + virtual const Instance* getInstance () const; + virtual const std::vector& getInstances () const; + virtual void setFilterPattern ( const QString& ); + virtual QString getFilterPattern () const; + virtual void expand (); + virtual void collapse (); + protected: + const Instance* _instance; + static const std::vector _instances; + }; + + +// ------------------------------------------------------------------- +// Class : "InstHierarchyInfos" + + + class InstHierarchyInfos : public HierarchyInfos { + public: + InstHierarchyInfos ( const Instance* + , HierarchyInfos* parent + , size_t rowInParent ); + virtual ~InstHierarchyInfos (); + virtual bool isRoot () const; + virtual bool isLeaf () const; + virtual bool isCollapsed () const; + virtual const HierarchyInfos* getRow ( int row ) const; + virtual int size () const; + virtual Cell* getMasterCell () const; + virtual const Instance* getInstance () const; + virtual const std::vector& getInstances () const; + virtual void setFilterPattern ( const QString& ); + virtual QString getFilterPattern () const; + virtual void expand (); + virtual void collapse (); + protected: + unsigned int _flags; + const Instance* _instance; + std::vector _instances; + QRegExp _filter; + }; + + +// ------------------------------------------------------------------- +// Class : "TopCellHierarchyInfos" + + + class TopCellHierarchyInfos : public InstHierarchyInfos { + public: + TopCellHierarchyInfos ( Cell*, HierarchyInfos* parent ); + virtual ~TopCellHierarchyInfos (); + virtual bool isRoot () const; + virtual Cell* getMasterCell () const; + virtual const Instance* getInstance () const; + void setCell ( Cell* ); + protected: + Cell* _rootCell; + }; + + +// ------------------------------------------------------------------- +// Class : "RootHierarchyInfos" + + + class RootHierarchyInfos : public HierarchyInfos { + public: + RootHierarchyInfos ( Cell* ); + virtual ~RootHierarchyInfos (); + virtual bool isRoot () const; + virtual bool isLeaf () const; + virtual bool isCollapsed () const; + virtual const HierarchyInfos* getRow ( int row ) const; + virtual int size () const; + virtual Cell* getMasterCell () const; + virtual const Instance* getInstance () const; + virtual const std::vector& getInstances () const; + virtual void setFilterPattern ( const QString& ); + virtual QString getFilterPattern () const; + virtual void expand (); + virtual void collapse (); + void setCell ( Cell* ); + protected: + std::vector _instances; + }; + + +} // Hurricane namespace. + +#endif // HURRICANE_HIERARCHY_INFORMATIONS_H diff --git a/hurricane/src/viewer/hurricane/viewer/HierarchyModel.h b/hurricane/src/viewer/hurricane/viewer/HierarchyModel.h new file mode 100644 index 00000000..2229f5f9 --- /dev/null +++ b/hurricane/src/viewer/hurricane/viewer/HierarchyModel.h @@ -0,0 +1,85 @@ +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2015-2015, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | H U R R I C A N E | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./hurricane/viewer/HierarchyModel.h" | +// +-----------------------------------------------------------------+ + + +#ifndef HURRICANE_HIERARCHY_MODEL_H +#define HURRICANE_HIERARCHY_MODEL_H + +#include +#include +#include +#include +#include "hurricane/Commons.h" +#include "hurricane/Name.h" +#include "hurricane/Net.h" +#include "hurricane/Cell.h" +#include "hurricane/viewer/Graphics.h" +#include "hurricane/viewer/HierarchyInformations.h" + + +namespace Hurricane { + + class Net; + class Cell; + + + class HierarchyModel : public QAbstractItemModel { + Q_OBJECT; + + public: + HierarchyModel ( QObject* parent=NULL ); + ~HierarchyModel (); + inline void setRootCell ( Cell* cell ); + virtual bool hasChildren ( const QModelIndex& parent=QModelIndex() ) const; + QModelIndex index ( int row, int column, const QModelIndex& parent ) const; + QModelIndex parent ( const QModelIndex& child ) const; + int rowCount ( const QModelIndex& parent=QModelIndex() ) const; + int columnCount ( const QModelIndex& parent=QModelIndex() ) const; + QVariant data ( const QModelIndex& index, int role=Qt::DisplayRole ) const; + QVariant headerData ( int section, Qt::Orientation orientation, int role=Qt::DisplayRole ) const; + inline Cell* getCell (); + inline HierarchyInfos* getRoot (); + inline void setCell ( Cell* ); + inline const HierarchyInfos* infosFromIndex ( const QModelIndex& ) const; + private: + RootHierarchyInfos _root; + }; + + +// Inline Functions. + + inline Cell* HierarchyModel::getCell () { return _root.getMasterCell(); } + inline HierarchyInfos* HierarchyModel::getRoot () { return &_root; } + + + inline void HierarchyModel::setCell ( Cell* cell ) + { + _root.setCell( cell ); + reset(); + } + + + inline const HierarchyInfos* HierarchyModel::infosFromIndex ( const QModelIndex& index ) const + { + if (index.isValid()) + return static_cast(index.internalPointer()); + return &_root; + } + + +} // End of Hurricane namespace. + + +#endif // HURRICANE_HIERARCHY_MODEL_H diff --git a/hurricane/src/viewer/hurricane/viewer/HierarchyWidget.h b/hurricane/src/viewer/hurricane/viewer/HierarchyWidget.h new file mode 100644 index 00000000..f643eefd --- /dev/null +++ b/hurricane/src/viewer/hurricane/viewer/HierarchyWidget.h @@ -0,0 +1,111 @@ + +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2015-2015, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | H U R R I C A N E | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./hurricane/viewer/HierarchyWidget.h" | +// +-----------------------------------------------------------------+ + + +#ifndef HURRICANE_HIERARCHY_WIDGET_H +#define HURRICANE_HIERARCHY_WIDGET_H + +#include +#include +#include +#include +#include "hurricane/Commons.h" +#include "hurricane/Bug.h" +#include "hurricane/viewer/HierarchyModel.h" +#include "hurricane/viewer/CellWidget.h" + + +class QModelIndex; +class QItemSelection; +class QLineEdit; +class QComboBox; +class QHeaderView; + + +namespace Hurricane { + + using std::set; + class Net; + class Cell; + + +// ------------------------------------------------------------------- +// Class : "TreeKeyFilter". + + + class TreeKeyFilter : public QObject { + Q_OBJECT; + + public: + TreeKeyFilter ( QObject* parent ); + bool eventFilter ( QObject*, QEvent* ); + }; + + +// ------------------------------------------------------------------- +// Class : "HierarchyWidget". + + + class HierarchyWidget : public QWidget { + Q_OBJECT; + + friend class TreeKeyFilter; + public: + HierarchyWidget ( QWidget* parent=NULL ); + bool isRSelected ( const QModelIndex& index ) const; + inline CellWidget* getCellWidget (); + void rexpand ( Path path ); + void rexpand ( const QModelIndex& index ); + inline Cell* getCell (); + inline void setCellWidget ( CellWidget* ); + void setCell ( Cell* ); + void goTo ( int ); + private slots: + void collapseHook ( const QModelIndex& ); + void textFilterChanged (); + void followSelected ( const QItemSelection&, const QItemSelection& ); + private: + CellWidget* _cellWidget; + Cell* _cell; + HierarchyModel* _baseModel; + QTreeView* _view; + QLineEdit* _filterPatternLineEdit; + int _rowHeight; + }; + + + inline Cell* HierarchyWidget::getCell () { return _cell; } + inline CellWidget* HierarchyWidget::getCellWidget () { return _cellWidget; } + + + inline void HierarchyWidget::setCellWidget ( CellWidget* cw ) + { + if (_cellWidget) { + disconnect( this, 0, _cellWidget, 0 ); + } + + _cellWidget = cw; + if (_cellWidget) { + if (_cellWidget->getTopCell()) setCell( _cellWidget->getTopCell() ); + else setCell( _cellWidget->getCell() ); + } else + setCell( NULL ); + } + + +} // Hurricane namespace. + +#endif // HURRICANE_HIERARCHY_WIDGET_H