Added Hierarchy browser to the Controller.

* New: In Hurricane, added hierarchy browser in the controller.
    The hierarchy is presented as a tree. New MVC, HierarchyInformations,
    HierarchyModel and HierarchyBrowser.
      When using a data model which is not directly connect inside the
    model, we must use the internalPointer field of the QModelIndex.
    But this field is also used by the QSortFilterproxymodel, this
    prevent using it with a Tree model.
      The filter is directly implemented and is specific to each
    Instance entry.
* Change: In CellWidget & CellWidget::State, now store the Cell and
    a Path, this way we can keep track of the hierarchy when browsing.
    The Path is in the State and so propagated back to the Controller.
* Change: In HierarchyCommand, use the Path with setCell().
This commit is contained in:
Jean-Paul Chaput 2015-07-23 00:44:56 +02:00
parent ae6eeb8f56
commit ff69a2ef74
21 changed files with 1420 additions and 221 deletions

View File

@ -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".

View File

@ -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; }

View File

@ -245,6 +245,19 @@ void Path::setNameSeparator(char nameSeparator)
SharedPath::setNameSeparator(nameSeparator);
}
string Path::getCompactString() const
// **********************************
{
if (isEmpty()) return "<empty>";
string s = "<";
s += getString(getOwnerCell()->getName());
s += ":";
s += getString(_sharedPath->getName()) + ":";
s += getString(getMasterCell()->getName()) + ">";
return s;
}
string Path::_getString() const
// ****************************
{

View File

@ -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; }

View File

@ -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;

View File

@ -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

View File

@ -550,7 +550,10 @@ namespace Hurricane {
list< shared_ptr<CellWidget::State> >::iterator istate = _cellHistory.begin();
for ( size_t i=0 ; i<CellHistorySize ; i++ ) {
if ( istate != _cellHistory.end() ) {
QString entry = tr("&%1: %2").arg(i+1).arg( getString((*istate)->getName()).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<QAction*> ( sender() );
if ( historyAction ) {
QAction* historyAction = qobject_cast<QAction*>( sender() );
if (historyAction) {
list< shared_ptr<CellWidget::State> >::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 );
}
}

View File

@ -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,38 +2417,45 @@ 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> state ( new State(cell) );
setState ( state );
if ( cell and cell->isTerminal() ) setQueryFilter ( ~0 );
openRefreshSession();
shared_ptr<State> 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>& state )
void CellWidget::setState ( shared_ptr<State>& state, unsigned int flags )
{
//cerr << "CellWidget::setState() - " << state->getName() << endl;
if ( state == _state ) return;
if (state == _state) return;
openRefreshSession ();
cellPreModificate ();
openRefreshSession();
cellPreModificate();
if (not (flags & NoResetCommands)) resetCommands();
_state->getSelection ().clear ();
_state->setCellWidget ( NULL );
_state->setCellWidget( NULL );
_state->setTopLeft ( getTopLeft() );
_cellChanged = true;
@ -2453,23 +2467,22 @@ namespace Hurricane {
// << DbU::getValueString(_state->getTopLeft().getX()) << ","
// << DbU::getValueString(_state->getTopLeft().getY()) << ")" << endl;
_state->setHistoryEnable ( false );
_state->setHistoryEnable( false );
_state->setCellWidget ( this );
_drawingQuery .setCell ( getCell() );
_drawingQuery .setStartLevel ( _state->getStartLevel() );
_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 queryFilterChanged();
cellPostModificate ();
closeRefreshSession ();
cellPostModificate();
closeRefreshSession();
}

View File

@ -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 <QKeyEvent>
#include <QMouseEvent>
#include <QWheelEvent>
#include <hurricane/viewer/CellWidget.h>
#include <hurricane/viewer/Command.h>
@ -68,6 +58,7 @@ namespace Hurricane {
void Command::mousePressEvent ( QMouseEvent* ) { }
void Command::mouseReleaseEvent ( QMouseEvent* ) { }
void Command::draw () { }
void Command::reset () { }
} // End of Hurricane namespace.

View File

@ -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 <hurricane/viewer/PaletteWidget.h>
#include <hurricane/viewer/DisplayFilterWidget.h>
#include <hurricane/viewer/NetlistWidget.h>
#include <hurricane/viewer/HierarchyWidget.h>
#include <hurricane/viewer/SelectionWidget.h>
#include <hurricane/viewer/InspectorWidget.h>
#include <hurricane/viewer/ControllerWidget.h>
@ -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") );
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->setObjectName( "controller.action.hideShow" );
toggleShow->setShortcut ( QKeySequence(tr("CTRL+I")) );
addAction ( toggleShow );
addAction( toggleShow );
connect ( toggleShow, SIGNAL(triggered()) , this, SLOT(toggleShow()) );
connect ( this , SIGNAL(currentChanged(int)), this, SLOT(updateTab(int)) );
connect ( _tabSelection->getSelection(), SIGNAL(inspect(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 )

View File

@ -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 <QMouseEvent>
@ -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 );
}
}
}

View File

@ -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 <QObject>
#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 "<Top Cell>";
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<Instance*>(getInstance()) );
}
// -------------------------------------------------------------------
// Class : "LeafHierarchyInfos"
const vector<HierarchyInfos*> 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<HierarchyInfos*>& LeafHierarchyInfos::getInstances () const { return _instances; }
QString LeafHierarchyInfos::getFilterPattern () const { return "<Not avalaible for leaf instances>"; }
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<HierarchyInfos*>& InstHierarchyInfos::getInstances () const { return _instances; }
QString InstHierarchyInfos::getFilterPattern () const { return _filter.pattern(); }
int InstHierarchyInfos::size () const
{
if (_flags & HierarchyInfos::Collapsed) {
const_cast<InstHierarchyInfos*>(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<HierarchyInfos*>().swap( _instances );
}
const HierarchyInfos* InstHierarchyInfos::getRow ( int row ) const
{
if (_flags & HierarchyInfos::Collapsed) {
const_cast<InstHierarchyInfos*>(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<HierarchyInfos*>& RootHierarchyInfos::getInstances () const { return _instances; }
QString RootHierarchyInfos::getFilterPattern () const { return "<Not avalaible for Root>"; }
void RootHierarchyInfos::setFilterPattern ( const QString& ) { }
void RootHierarchyInfos::expand () { }
void RootHierarchyInfos::collapse () { }
void RootHierarchyInfos::setCell ( Cell* topCell ) { dynamic_cast<TopCellHierarchyInfos*>(_instances[0])->setCell(topCell); }
} // End of Hurricane namespace.

View File

@ -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 <QFont>
#include <QApplication>
#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.

View File

@ -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 <QFontMetrics>
#include <QLabel>
#include <QLineEdit>
#include <QHeaderView>
#include <QKeyEvent>
#include <QGroupBox>
#include <QVBoxLayout>
#include <QAction>
#include <QModelIndex>
#include <QTreeView>
#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<HierarchyInfos*>(_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<HierarchyInfos*>( _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<HierarchyInfos*>(_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<HierarchyInfos*>(_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<HierarchyInfos*>(_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<HierarchyInfos*>(_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<HierarchyWidget*>( parent() );
if (not owner) return false;
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(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<HierarchyInfos*>(owner->_baseModel->infosFromIndex(index));
if (infos) {
if (owner->getCellWidget()) {
owner->getCellWidget()->setCell( infos->getMasterCell(), infos->getPath() );
}
}
}
}
}
return QObject::eventFilter( object, event );
}
} // Hurricane namespace.

View File

@ -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<State>& getState ();
inline shared_ptr<State> 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<CellWidget::State>& );
void setState ( shared_ptr<CellWidget::State>&
, 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; }

View File

@ -1,28 +1,25 @@
// -*- 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__
#ifndef HURRICANE_COMMAND_H
#define HURRICANE_COMMAND_H
#include <string>
#include <map>
class QKeyEvent;
class QMouseEvent;
class QWheelEvent;
@ -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& );

View File

@ -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".
@ -274,6 +299,7 @@ namespace Hurricane {
inline PaletteWidget* getPalette ();
inline DisplayFilterWidget* getDisplayFilter ();
inline NetlistWidget* getNetlistBrowser ();
inline HierarchyWidget* getHierarchyBrowser ();
inline SelectionWidget* getSelection ();
inline InspectorWidget* getInspectorWidget ();
inline TabSettings* getSettings ();
@ -292,6 +318,7 @@ namespace Hurricane {
TabPalette* _tabPalette;
TabDisplayFilter* _tabDisplayFilter;
TabNetlist* _tabNetlist;
TabHierarchy* _tabHierarchy;
TabSelection* _tabSelection;
TabInspector* _tabInspector;
TabSettings* _tabSettings;
@ -303,6 +330,7 @@ namespace Hurricane {
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; }

View File

@ -1,36 +1,25 @@
// -*- 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__
#ifndef HURRICANE_HIERARCHY_COMMAND_H
#define HURRICANE_HIERARCHY_COMMAND_H
#include <set>
#include <QObject>
#include <QPoint>
class QAction;
#include "hurricane/Occurrence.h"
@ -38,12 +27,8 @@ class QAction;
#include "hurricane/viewer/CellWidget.h"
using namespace std;
namespace Hurricane {
class Cell;
@ -51,37 +36,20 @@ namespace Hurricane {
public:
HierarchyCommand ();
virtual ~HierarchyCommand ();
virtual const string& getName () const;
virtual const std::string& getName () const;
virtual void reset ();
virtual void keyReleaseEvent ( QKeyEvent* );
private:
HierarchyCommand ( const HierarchyCommand& );
HierarchyCommand& operator= ( const HierarchyCommand& );
private:
class HistoryEntry {
public:
inline HistoryEntry ( Instance*, shared_ptr<CellWidget::State> );
public:
Instance* _instance;
shared_ptr<CellWidget::State> _state;
};
private:
static string _name;
vector<HistoryEntry> _history;
static std::string _name;
std::vector< std::shared_ptr<CellWidget::State> > _history;
size_t _historyIndex;
};
// Inline Functions.
inline HierarchyCommand::HistoryEntry::HistoryEntry ( Instance* instance
, shared_ptr<CellWidget::State> state
)
: _instance(instance)
, _state (state)
{ }
} // Hurricane namespace.
} // End of Hurricane namespace.
#endif
#endif // HURRICANE_HIERARCHY_COMMAND_H

View File

@ -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 <vector>
#include <QRegExp>
#include <QVariant>
#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<HierarchyInfos*>& 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<HierarchyInfos*>& 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<HierarchyInfos*> _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<HierarchyInfos*>& 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<HierarchyInfos*> _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<HierarchyInfos*>& getInstances () const;
virtual void setFilterPattern ( const QString& );
virtual QString getFilterPattern () const;
virtual void expand ();
virtual void collapse ();
void setCell ( Cell* );
protected:
std::vector<HierarchyInfos*> _instances;
};
} // Hurricane namespace.
#endif // HURRICANE_HIERARCHY_INFORMATIONS_H

View File

@ -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 <vector>
#include <QFont>
#include <QApplication>
#include <QAbstractTableModel>
#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<HierarchyInfos*>(index.internalPointer());
return &_root;
}
} // End of Hurricane namespace.
#endif // HURRICANE_HIERARCHY_MODEL_H

View File

@ -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 <set>
#include <QWidget>
#include <QTreeView>
#include <QItemDelegate>
#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