* ./hurricane/src/hviewer :

- New feature : full uses of SelectionModel in NetlistWidget, allow multiple
        selection. New option to automatically select Nets from the Netlist
        browser into the SelectionWidget (temporarily set up in cumulative
        mode).
    - Rename : SelectorCommand into SelectorCriterion (file name renaming in
        next commit).
    - Reorganisazion : in CellWidget, SelectorCommand/SelectorCriterions operations
        are gathered in a single object : SelectionCriterions.
This commit is contained in:
Jean-Paul Chaput 2008-11-28 23:10:39 +00:00
parent e5f5ce3592
commit 4bc6940b39
12 changed files with 455 additions and 172 deletions

View File

@ -401,6 +401,83 @@ namespace Hurricane {
{ } { }
// -------------------------------------------------------------------
// Class : "Hurricane::CellWidget::SelectorCriterions".
CellWidget::SelectorCriterions::SelectorCriterions ( CellWidget* cw )
: _cellWidget(cw)
, _criterions()
{ }
CellWidget::SelectorCriterions::~SelectorCriterions ()
{
clear ();
}
bool CellWidget::SelectorCriterions::add ( const Net* net, bool delayRedraw )
{
if ( !_cellWidget->isSelected(Occurrence(net)) ) {
_criterions.push_back ( new NetSelectorCriterion(net) );
_criterions.back()->doSelection ( _cellWidget, delayRedraw );
return true;
}
return false;
}
bool CellWidget::SelectorCriterions::add ( Box area )
{
_criterions.push_back ( new AreaSelectorCriterion(area) );
_criterions.back()->doSelection ( _cellWidget, true );
return true;
}
bool CellWidget::SelectorCriterions::remove ( const Net* net, bool delayRedraw )
{
if ( !_cellWidget->isSelected(Occurrence(net)) ) return false;
size_t i=0;
for ( ; i<_criterions.size() ; i++ )
if ( _criterions[i]->getNet() == net ) break;
if ( i < _criterions.size() ) {
swap ( _criterions[i], *(_criterions.end()-1) );
_criterions.back()->undoSelection ( _cellWidget, delayRedraw );
_criterions.pop_back ();
} else
return false;
return true;
}
void CellWidget::SelectorCriterions::clear ()
{
for ( size_t i=0 ; i<_criterions.size() ; i++ )
delete _criterions[i];
_criterions.clear ();
}
void CellWidget::SelectorCriterions::revalidate ()
{
size_t i = 0;
size_t last = _criterions.size ();
while ( i < last ) {
if ( _criterions[i]->isValid(_cellWidget) ) {
_criterions[i]->doSelection ( _cellWidget, true );
++i;
} else
swap ( _criterions[i], _criterions[--last] );
}
_criterions.erase ( _criterions.begin()+last, _criterions.end() );
}
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "Hurricane::CellWidget". // Class : "Hurricane::CellWidget".
@ -429,7 +506,7 @@ namespace Hurricane {
, _delaySelectionChanged(0) , _delaySelectionChanged(0)
, _cellModificated(true) , _cellModificated(true)
, _selectors() , _selectors()
, _selectorCommands() , _selection(this)
, _commands() , _commands()
, _redrawRectCount(0) , _redrawRectCount(0)
, _textFontHeight(20) , _textFontHeight(20)
@ -460,8 +537,6 @@ namespace Hurricane {
{ {
cerr << "CellWidget::~CellWidget()" << endl; cerr << "CellWidget::~CellWidget()" << endl;
clearSelectorCommands ();
for ( size_t i=0 ; i<_commands.size() ; i++ ) for ( size_t i=0 ; i<_commands.size() ; i++ )
unbindCommand ( _commands[i] ); unbindCommand ( _commands[i] );
} }
@ -517,15 +592,6 @@ namespace Hurricane {
} }
void CellWidget::clearSelectorCommands ()
{
while ( !_selectorCommands.empty() ) {
delete _selectorCommands.back();
_selectorCommands.pop_back ();
}
}
void CellWidget::pushCursor ( Qt::CursorShape cursor ) void CellWidget::pushCursor ( Qt::CursorShape cursor )
{ {
setCursor ( cursor ); setCursor ( cursor );
@ -1192,6 +1258,8 @@ namespace Hurricane {
void CellWidget::setCell ( Cell* cell ) void CellWidget::setCell ( Cell* cell )
{ {
cellPreModificate ();
_cell = cell; _cell = cell;
_drawingQuery.setCell ( cell ); _drawingQuery.setCell ( cell );
_textDrawingQuery.setCell ( cell ); _textDrawingQuery.setCell ( cell );
@ -1199,6 +1267,8 @@ namespace Hurricane {
emit cellChanged ( cell ); emit cellChanged ( cell );
fitToContents (); fitToContents ();
cellPostModificate ();
} }
@ -1207,11 +1277,29 @@ namespace Hurricane {
++_delaySelectionChanged; ++_delaySelectionChanged;
if ( !_cumulativeSelection ) unselectAll ( true ); if ( !_cumulativeSelection ) unselectAll ( true );
// ToDo: Check here if the Net is already in the Selection. bool added = _selection.add ( net, delayRedraw );
_selectorCommands.push_back ( new NetSelectorCommand(net) );
_selectorCommands.back()->doSelection ( this, delayRedraw );
if ( !--_delaySelectionChanged ) emit selectionChanged(_selectors,_cell); if ( !--_delaySelectionChanged && added ) emit selectionChanged(_selectors,_cell);
}
bool CellWidget::isSelected ( Occurrence occurrence )
{
if ( !occurrence.isValid() )
throw Error ( "Can't select occurrence : invalid occurrence" );
if ( occurrence.getOwnerCell() != getCell() )
throw Error ( "Can't select occurrence : incompatible occurrence" );
Property* property = occurrence.getProperty ( Selector::getPropertyName() );
if ( !property )
return false;
Selector* selector = dynamic_cast<Selector*>(property);
if ( !selector )
throw Error ( "Abnormal property named " + getString(Selector::getPropertyName()) );
return selector->isAttachedTo(this);
} }
@ -1247,11 +1335,18 @@ namespace Hurricane {
++_delaySelectionChanged; ++_delaySelectionChanged;
if ( !_cumulativeSelection ) unselectAll ( true ); if ( !_cumulativeSelection ) unselectAll ( true );
bool added = _selection.add ( selectArea );
_selectorCommands.push_back ( new AreaSelectorCommand(selectArea) ); if ( !--_delaySelectionChanged && added ) emit selectionChanged(_selectors,_cell);
_selectorCommands.back()->doSelection ( this, true ); }
if ( !--_delaySelectionChanged ) emit selectionChanged(_selectors,_cell);
void CellWidget::unselect ( const Net* net, bool delayRedraw )
{
++_delaySelectionChanged;
bool removed = _selection.remove ( net, delayRedraw );
if ( !--_delaySelectionChanged && removed ) emit selectionChanged(_selectors,_cell);
} }
@ -1281,7 +1376,7 @@ namespace Hurricane {
{ {
++_delaySelectionChanged; ++_delaySelectionChanged;
clearSelectorCommands (); _selection.clear ();
_unselectAll ( delayRedraw ); _unselectAll ( delayRedraw );
if ( !--_delaySelectionChanged ) emit selectionChanged(_selectors,_cell); if ( !--_delaySelectionChanged ) emit selectionChanged(_selectors,_cell);
@ -1317,6 +1412,7 @@ namespace Hurricane {
void CellWidget::_select ( const Net* net, bool delayRedraw ) void CellWidget::_select ( const Net* net, bool delayRedraw )
{ {
select ( Occurrence(net) );
forEach ( Component*, component, net->getComponents() ) { forEach ( Component*, component, net->getComponents() ) {
Occurrence occurrence ( *component ); Occurrence occurrence ( *component );
select ( occurrence ); select ( occurrence );
@ -1325,6 +1421,17 @@ namespace Hurricane {
} }
void CellWidget::_unselect ( const Net* net, bool delayRedraw )
{
unselect ( Occurrence(net) );
forEach ( Component*, component, net->getComponents() ) {
Occurrence occurrence ( *component );
unselect ( occurrence );
}
if ( !delayRedraw && _showSelection ) redraw ();
}
void CellWidget::_selectOccurrencesUnder ( Box selectArea ) void CellWidget::_selectOccurrencesUnder ( Box selectArea )
{ {
forEach ( Occurrence, ioccurrence, _cell->getOccurrencesUnder(selectArea) ) forEach ( Occurrence, ioccurrence, _cell->getOccurrencesUnder(selectArea) )
@ -1357,9 +1464,7 @@ namespace Hurricane {
_cellModificated = true; _cellModificated = true;
++_delaySelectionChanged; ++_delaySelectionChanged;
vector<SelectorCommand*>::iterator icommand = _selectorCommands.begin (); _selection.revalidate ();
for ( ; icommand != _selectorCommands.end() ; icommand++ )
(*icommand)->doSelection ( this, true );
updatePalette (); updatePalette ();
redraw (); redraw ();

View File

@ -167,8 +167,10 @@ namespace Hurricane {
TabNetlist::TabNetlist ( QWidget* parent ) TabNetlist::TabNetlist ( QWidget* parent )
: ControllerTab (parent) : ControllerTab (parent)
, _netlistBrowser(new NetlistWidget()) , _netlistBrowser (new NetlistWidget())
, _synchronize (new QCheckBox()) , _syncNetlist (new QCheckBox())
, _syncSelection (new QCheckBox())
, _cwCumulativeSelection(false)
{ {
_netlistBrowser->setObjectName ( "controller.tabNetlist.netlistBrowser" ); _netlistBrowser->setObjectName ( "controller.tabNetlist.netlistBrowser" );
@ -176,15 +178,22 @@ namespace Hurricane {
wLayout->setContentsMargins ( 10, 0, 10, 0 ); wLayout->setContentsMargins ( 10, 0, 10, 0 );
wLayout->setSpacing ( 0 ); wLayout->setSpacing ( 0 );
_synchronize->setText ( tr("Synchronize Netlist") ); _syncNetlist->setText ( tr("Sync Netlist") );
_synchronize->setChecked ( false ); _syncNetlist->setChecked ( false );
_synchronize->setFont ( Graphics::getFixedFont(QFont::Bold,false,false) ); _syncNetlist->setFont ( Graphics::getFixedFont(QFont::Bold,false,false) );
connect ( _synchronize, SIGNAL(toggled(bool)), this, SLOT(setSynchronize(bool)) ); connect ( _syncNetlist, SIGNAL(toggled(bool)), this, SLOT(setSyncNetlist(bool)) );
_syncSelection->setText ( tr("Sync Selection") );
_syncSelection->setChecked ( false );
_syncSelection->setFont ( Graphics::getFixedFont(QFont::Bold,false,false) );
connect ( _syncSelection, SIGNAL(toggled(bool)), this, SLOT(setSyncSelection(bool)) );
QHBoxLayout* commands = new QHBoxLayout (); QHBoxLayout* commands = new QHBoxLayout ();
commands->setContentsMargins ( 0, 0, 0, 0 ); commands->setContentsMargins ( 0, 0, 0, 0 );
commands->addStretch (); commands->addStretch ();
commands->addWidget ( _synchronize ); commands->addWidget ( _syncNetlist );
commands->addStretch ();
commands->addWidget ( _syncSelection );
commands->addStretch (); commands->addStretch ();
wLayout->addLayout ( commands ); wLayout->addLayout ( commands );
@ -198,7 +207,7 @@ namespace Hurricane {
} }
void TabNetlist::setSynchronize ( bool state ) void TabNetlist::setSyncNetlist ( bool state )
{ {
if ( state && getCellWidget() ) { if ( state && getCellWidget() ) {
_netlistBrowser->setCell<SimpleNetInformations> ( getCellWidget()->getCell() ); _netlistBrowser->setCell<SimpleNetInformations> ( getCellWidget()->getCell() );
@ -208,9 +217,28 @@ namespace Hurricane {
} }
void TabNetlist::setSyncSelection ( bool state )
{
if ( state && getCellWidget() && _syncNetlist->isChecked() ) {
_cwCumulativeSelection = getCellWidget()->cumulativeSelection();
if ( !_cwCumulativeSelection )
getCellWidget()->unselectAll ( true );
getCellWidget()->setCumulativeSelection ( true );
getCellWidget()->setShowSelection ( true );
connect ( _netlistBrowser, SIGNAL(netSelected (const Net*)), getCellWidget(), SLOT(select (const Net*)) );
connect ( _netlistBrowser, SIGNAL(netUnselected(const Net*)), getCellWidget(), SLOT(unselect(const Net*)) );
} else {
getCellWidget()->setShowSelection ( false );
getCellWidget()->setCumulativeSelection ( _cwCumulativeSelection );
_netlistBrowser->disconnect ( getCellWidget(), SLOT(select (const Net*)) );
_netlistBrowser->disconnect ( getCellWidget(), SLOT(unselect(const Net*)) );
}
}
void TabNetlist::setCell ( Cell* cell ) void TabNetlist::setCell ( Cell* cell )
{ {
setSynchronize ( _synchronize->isChecked() ); setSyncNetlist ( _syncNetlist->isChecked() );
} }
@ -220,9 +248,8 @@ namespace Hurricane {
ControllerTab::setCellWidget ( cellWidget ); ControllerTab::setCellWidget ( cellWidget );
if ( getCellWidget() ) { if ( getCellWidget() ) {
connect ( getCellWidget(), SIGNAL(cellChanged(Cell*)) , this , SLOT(setCell(Cell*)) ); connect ( getCellWidget(), SIGNAL(cellChanged(Cell*)) , this , SLOT(setCell(Cell*)) );
connect ( _netlistBrowser, SIGNAL(netSelected(const Net*)), getCellWidget(), SLOT(select(const Net*)) );
} }
setSynchronize ( _synchronize->isChecked() ); setSyncNetlist ( _syncNetlist->isChecked() );
} }
} }
@ -235,7 +262,7 @@ namespace Hurricane {
void TabNetlist::cellPostModificate () void TabNetlist::cellPostModificate ()
{ {
setSynchronize ( _synchronize->isChecked() ); setSyncNetlist ( _syncNetlist->isChecked() );
} }
@ -256,19 +283,11 @@ namespace Hurricane {
} }
void TabSelection::setCell ( Cell* cell )
{
_selection->setSelection ( set<Selector*>() );
}
void TabSelection::setCellWidget ( CellWidget* cellWidget ) void TabSelection::setCellWidget ( CellWidget* cellWidget )
{ {
if ( getCellWidget() != cellWidget ) { if ( getCellWidget() != cellWidget ) {
ControllerTab::setCellWidget ( cellWidget ); ControllerTab::setCellWidget ( cellWidget );
if ( getCellWidget() ) { if ( getCellWidget() ) {
connect ( getCellWidget() , SIGNAL(cellChanged(Cell*))
, this , SLOT(setCell(Cell*)) );
connect ( getCellWidget(), SIGNAL(selectionChanged(const set<Selector*>&,Cell*)) connect ( getCellWidget(), SIGNAL(selectionChanged(const set<Selector*>&,Cell*))
, _selection , SLOT (setSelection (const set<Selector*>&,Cell*)) ); , _selection , SLOT (setSelection (const set<Selector*>&,Cell*)) );
connect ( _selection , SIGNAL(occurrenceToggled(Occurrence,bool)) connect ( _selection , SIGNAL(occurrenceToggled(Occurrence,bool))
@ -299,17 +318,17 @@ namespace Hurricane {
void TabSelection::cellPreModificate () void TabSelection::cellPreModificate ()
{ {
_selection->setSelection ( set<Selector*>() ); _selection->clear ();
} }
void TabSelection::cellPostModificate () void TabSelection::cellPostModificate ()
{ {
//updateTab (); //updateTab ();
if ( getCellWidget() && getCellWidget()->getCell() ) if ( getCellWidget() && getCellWidget()->getCell() ) {
_selection->setSelection ( getCellWidget()->getSelectorSet(), getCellWidget()->getCell() ); _selection->setSelection ( getCellWidget()->getSelectorSet(), getCellWidget()->getCell() );
else } else
_selection->setSelection ( set<Selector*>() ); _selection->clear ();
} }
@ -456,10 +475,8 @@ namespace Hurricane {
addTab ( _tabInspector , "Inspector" ); addTab ( _tabInspector , "Inspector" );
connect ( this, SIGNAL(currentChanged(int)), this, SLOT(updateTab(int)) ); connect ( this, SIGNAL(currentChanged(int)), this, SLOT(updateTab(int)) );
//connect ( _tabNetlist->getNetlistBrowser(), SIGNAL(netSelected(const Net*)) connect ( _tabSelection->getSelection(), SIGNAL(inspect(Occurrence&))
// , _tabSelection , SLOT(setUpdateFromNetlist(const Net*)) ); , _tabInspector , SLOT (setSelectionOccurrence(Occurrence&)) );
connect ( _tabSelection->getSelection() , SIGNAL(inspect(Occurrence&))
, _tabInspector , SLOT(setSelectionOccurrence(Occurrence&)) );
resize ( 540, 540 ); resize ( 540, 540 );
} }

View File

@ -38,31 +38,36 @@
#include "hurricane/viewer/NetlistWidget.h" #include "hurricane/viewer/NetlistWidget.h"
namespace {
using namespace Hurricane;
} // End of anonymous namespace.
namespace Hurricane { namespace Hurricane {
NetlistWidget::NetlistWidget ( QWidget* parent ) NetlistWidget::NetlistWidget ( QWidget* parent )
: QWidget(parent) : QWidget (parent)
, _cell(NULL) , _cell (NULL)
, _baseModel(NULL) , _baseModel(new NetlistModel(this))
, _sortModel(NULL) , _sortModel(new QSortFilterProxyModel(this))
, _view(NULL) , _view (new QTableView(this))
, _rowHeight(20) , _rowHeight(20)
, _selecteds()
{ {
setAttribute ( Qt::WA_DeleteOnClose ); setAttribute ( Qt::WA_DeleteOnClose );
setAttribute ( Qt::WA_QuitOnClose, false ); setAttribute ( Qt::WA_QuitOnClose, false );
_rowHeight = QFontMetrics(Graphics::getFixedFont()).height() + 4; _rowHeight = QFontMetrics(Graphics::getFixedFont()).height() + 4;
_baseModel = new NetlistModel ( this );
_sortModel = new QSortFilterProxyModel ( this );
_sortModel->setSourceModel ( _baseModel ); _sortModel->setSourceModel ( _baseModel );
_sortModel->setDynamicSortFilter ( true ); _sortModel->setDynamicSortFilter ( true );
_sortModel->setFilterKeyColumn ( 0 ); _sortModel->setFilterKeyColumn ( 0 );
_view = new QTableView(this);
_view->setShowGrid(false); _view->setShowGrid(false);
_view->setAlternatingRowColors(true); _view->setAlternatingRowColors(true);
_view->setSelectionBehavior(QAbstractItemView::SelectRows); _view->setSelectionBehavior(QAbstractItemView::SelectRows);
@ -89,13 +94,9 @@ namespace Hurricane {
setLayout ( gLayout ); setLayout ( gLayout );
connect ( _filterPatternLineEdit , SIGNAL(textChanged(const QString &)) connect ( _filterPatternLineEdit , SIGNAL(textChanged(const QString &))
, this , SLOT(textFilterChanged()) , this , SLOT (textFilterChanged()) );
); connect ( _view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&))
connect ( _view , SIGNAL(activated(const QModelIndex&)) , this , SLOT (updateSelecteds (const QItemSelection&,const QItemSelection&)) );
, this , SLOT(selectNet(const QModelIndex&))
);
// connect ( _view->selectionModel(), SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&))
// , this , SLOT(selectCurrent (const QModelIndex&,const QModelIndex&)) );
connect ( _baseModel , SIGNAL(layoutChanged()), this, SLOT(forceRowHeight()) ); connect ( _baseModel , SIGNAL(layoutChanged()), this, SLOT(forceRowHeight()) );
resize(300, 300); resize(300, 300);
@ -120,31 +121,44 @@ namespace Hurricane {
} }
void NetlistWidget::selectNet ( const QModelIndex& index ) void NetlistWidget::updateSelecteds ( const QItemSelection& , const QItemSelection& )
{ {
if ( !index.isValid() ) return; const Net* net;
const Net* net = _baseModel->getNet ( _sortModel->mapToSource(index).row() ); _selecteds.resetAccesses ();
QModelIndexList iList = _view->selectionModel()->selectedRows();
for ( int i=0 ; i<iList.size() ; i++ ) {
net = _baseModel->getNet ( _sortModel->mapToSource(iList[i]).row() );
if ( net ) if ( net )
emit netSelected ( net ); _selecteds.insert ( net );
} }
SelectedNetSet::iterator remove;
void NetlistWidget::selectCurrent ( const QModelIndex& current, const QModelIndex& ) SelectedNetSet::iterator isel = _selecteds.begin ();
{ while ( isel != _selecteds.end() ) {
selectNet ( current ); switch ( isel->getAccesses() ) {
case 1: break;
case 64:
emit netSelected ( isel->getNet() );
break;
case 0:
emit netUnselected ( isel->getNet() );
remove = isel;
++isel;
_selecteds.erase ( remove );
continue;
default:
cerr << Bug("NetlistWidget::updateSelecteds(): invalid code %d"
,isel->getAccesses()) << endl;
}
++isel;
}
} }
void NetlistWidget::keyPressEvent ( QKeyEvent* event ) void NetlistWidget::keyPressEvent ( QKeyEvent* event )
{ {
if ( event->key() == Qt::Key_Asterisk ) { selectNet(_view->currentIndex()); }
else if ( event->key() == Qt::Key_Plus ) { goTo( 1); selectNet(_view->currentIndex()); }
else if ( event->key() == Qt::Key_Minus ) { goTo(-1); selectNet(_view->currentIndex()); }
else {
event->ignore();
}
} }

View File

@ -203,6 +203,12 @@ namespace Hurricane {
} }
void SelectionWidget::clear ()
{
_baseModel->clear ();
}
void SelectionWidget::selectCurrent ( const QModelIndex& current, const QModelIndex& ) void SelectionWidget::selectCurrent ( const QModelIndex& current, const QModelIndex& )
{ {
inspect ( current ); inspect ( current );

View File

@ -115,6 +115,18 @@ namespace Hurricane {
} }
bool Selector::isAttachedTo ( CellWidget* widget ) const
{
if ( !widget )
throw Error ( "Can't attach selector : null CellWidget." );
if ( _cellWidgets.find(widget) == _cellWidgets.end() )
return false;
return true;
}
void Selector::attachTo ( CellWidget* widget ) void Selector::attachTo ( CellWidget* widget )
{ {
if ( !widget ) if ( !widget )

View File

@ -16,7 +16,7 @@
// | Author : Jean-Paul CHAPUT | // | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Header : "./SelectorCommand.cpp" | // | C++ Header : "./SelectorCriterion.cpp" |
// | *************************************************************** | // | *************************************************************** |
// | U p d a t e s | // | U p d a t e s |
// | | // | |
@ -24,6 +24,7 @@
#include "hurricane/viewer/CellWidget.h" #include "hurricane/viewer/CellWidget.h"
//#include "hurricane/viewer/SelectorCriterion.h"
#include "hurricane/viewer/SelectorCommand.h" #include "hurricane/viewer/SelectorCommand.h"
@ -31,48 +32,71 @@ namespace Hurricane {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "Hurricane::SelectorCommand". // Class : "Hurricane::SelectorCriterion".
SelectorCommand::~SelectorCommand () SelectorCriterion::~SelectorCriterion ()
{ }
const Net* SelectorCriterion::getNet () const
{ return NULL; }
void SelectorCriterion::undoSelection ( CellWidget* cw, bool delayRedraw )
{ } { }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "Hurricane::NetSelectorCommand". // Class : "Hurricane::NetSelectorCriterion".
NetSelectorCommand::NetSelectorCommand ( const Net* net ) NetSelectorCriterion::NetSelectorCriterion ( const Net* net )
: _net(net) : _net(net)
, _name(_net->getName())
{ } { }
NetSelectorCommand::~NetSelectorCommand () NetSelectorCriterion::~NetSelectorCriterion ()
{ } { }
const Net* NetSelectorCommand::getNet () const const Net* NetSelectorCriterion::getNet () const
{ return _net; } { return _net; }
void NetSelectorCommand::doSelection ( CellWidget* cw, bool delayRedraw ) bool NetSelectorCriterion::isValid ( CellWidget* cw ) const
{
if ( !cw->getCell() ) return false;
if ( !cw->getCell()->getNet(_name) ) return false;
return true;
}
void NetSelectorCriterion::doSelection ( CellWidget* cw, bool delayRedraw )
{ {
cw->_select ( _net, delayRedraw ); cw->_select ( _net, delayRedraw );
} }
string NetSelectorCommand::_getTypeName () const void NetSelectorCriterion::undoSelection ( CellWidget* cw, bool delayRedraw )
{ return "NetSelectorCommand"; } {
cw->_unselect ( _net, delayRedraw );
}
string NetSelectorCommand::_getString () const string NetSelectorCriterion::_getTypeName () const
{ return "NetSelectorCriterion"; }
string NetSelectorCriterion::_getString () const
{ {
string s = "<" + _getTypeName() + " " + getString(_net) + ">"; string s = "<" + _getTypeName() + " " + getString(_net) + ">";
return s; return s;
} }
Record* NetSelectorCommand::_getRecord () const Record* NetSelectorCriterion::_getRecord () const
{ {
Record* record = new Record ( _getString() ); Record* record = new Record ( _getString() );
record->add ( getSlot("_net",_net) ); record->add ( getSlot("_net",_net) );
@ -81,40 +105,44 @@ namespace Hurricane {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "Hurricane::AreaSelectorCommand". // Class : "Hurricane::AreaSelectorCriterion".
AreaSelectorCommand::AreaSelectorCommand ( const Box& area ) AreaSelectorCriterion::AreaSelectorCriterion ( const Box& area )
: _area(area) : _area(area)
{ } { }
AreaSelectorCommand::~AreaSelectorCommand () AreaSelectorCriterion::~AreaSelectorCriterion ()
{ } { }
const Box& AreaSelectorCommand::getArea () const const Box& AreaSelectorCriterion::getArea () const
{ return _area; } { return _area; }
void AreaSelectorCommand::doSelection ( CellWidget* cw, bool delayRedraw ) bool AreaSelectorCriterion::isValid ( CellWidget* ) const
{ return true; }
void AreaSelectorCriterion::doSelection ( CellWidget* cw, bool delayRedraw )
{ {
cw->_selectOccurrencesUnder ( _area ); cw->_selectOccurrencesUnder ( _area );
} }
string AreaSelectorCommand::_getTypeName () const string AreaSelectorCriterion::_getTypeName () const
{ return "AreaSelectorCommand"; } { return "AreaSelectorCriterion"; }
string AreaSelectorCommand::_getString () const string AreaSelectorCriterion::_getString () const
{ {
string s = "<" + _getTypeName() + " " + getString(_area) + ">"; string s = "<" + _getTypeName() + " " + getString(_area) + ">";
return s; return s;
} }
Record* AreaSelectorCommand::_getRecord () const Record* AreaSelectorCriterion::_getRecord () const
{ {
Record* record = new Record ( _getString() ); Record* record = new Record ( _getString() );
record->add ( getSlot("_area",&_area) ); record->add ( getSlot("_area",&_area) );

View File

@ -52,6 +52,7 @@ class QAction;
#include "hurricane/viewer/DisplayStyle.h" #include "hurricane/viewer/DisplayStyle.h"
#include "hurricane/viewer/CellWidgets.h" #include "hurricane/viewer/CellWidgets.h"
#include "hurricane/viewer/Selector.h" #include "hurricane/viewer/Selector.h"
//#include "hurricane/viewer/SelectorCriterion.h"
#include "hurricane/viewer/SelectorCommand.h" #include "hurricane/viewer/SelectorCommand.h"
@ -102,10 +103,10 @@ namespace Hurricane {
void detachFromPalette (); void detachFromPalette ();
void bindCommand ( Command* ); void bindCommand ( Command* );
void unbindCommand ( Command* ); void unbindCommand ( Command* );
void clearSelectorCommands ();
inline bool showBoundaries () const; inline bool showBoundaries () const;
inline set<Selector*>& getSelectorSet ();
inline bool showSelection () const; inline bool showSelection () const;
inline bool cumulativeSelection () const;
inline set<Selector*>& getSelectorSet ();
inline void setStartLevel ( int ); inline void setStartLevel ( int );
inline void setStopLevel ( int ); inline void setStopLevel ( int );
inline void setQueryFilter ( int ); inline void setQueryFilter ( int );
@ -169,13 +170,16 @@ namespace Hurricane {
inline QPoint& getOffsetVA (); inline QPoint& getOffsetVA ();
void select ( const Net* net, bool delayRedraw=false ); void select ( const Net* net, bool delayRedraw=false );
void select ( Occurrence occurence ); void select ( Occurrence occurence );
bool isSelected ( Occurrence occurence );
void selectOccurrencesUnder ( Box selectArea ); void selectOccurrencesUnder ( Box selectArea );
void unselect ( const Net* net, bool delayRedraw=false );
void unselect ( Occurrence occurence ); void unselect ( Occurrence occurence );
void unselectAll ( bool delayRedraw=false ); void unselectAll ( bool delayRedraw=false );
void toggleSelect ( Occurrence occurence, bool fromPopup ); void toggleSelect ( Occurrence occurence, bool fromPopup );
void setShowSelection ( bool state ); void setShowSelection ( bool state );
void setCumulativeSelection ( bool state ); void setCumulativeSelection ( bool state );
void _select ( const Net* net, bool delayRedraw=false ); void _select ( const Net* net, bool delayRedraw=false );
void _unselect ( const Net* net, bool delayRedraw=false );
void _selectOccurrencesUnder ( Box selectArea ); void _selectOccurrencesUnder ( Box selectArea );
void _unselectAll ( bool delayRedraw ); void _unselectAll ( bool delayRedraw );
void updatePalette (); void updatePalette ();
@ -313,6 +317,21 @@ namespace Hurricane {
CellWidget* _cellWidget; CellWidget* _cellWidget;
}; };
private:
class SelectorCriterions {
public:
SelectorCriterions ( CellWidget* );
~SelectorCriterions ();
bool add ( const Net* net, bool delayRedraw );
bool add ( Box area );
bool remove ( const Net* net, bool delayRedraw );
void clear ();
void revalidate ();
private:
CellWidget* _cellWidget;
vector<SelectorCriterion*> _criterions;
};
protected: protected:
// Internal: Attributes. // Internal: Attributes.
static const int _stripWidth; static const int _stripWidth;
@ -338,7 +357,7 @@ namespace Hurricane {
int _delaySelectionChanged; int _delaySelectionChanged;
bool _cellModificated; bool _cellModificated;
set<Selector*> _selectors; set<Selector*> _selectors;
vector<SelectorCommand*> _selectorCommands; SelectorCriterions _selection;
vector<Command*> _commands; vector<Command*> _commands;
size_t _redrawRectCount; size_t _redrawRectCount;
int _textFontHeight; int _textFontHeight;
@ -569,6 +588,10 @@ namespace Hurricane {
{ return _showSelection; } { return _showSelection; }
inline bool CellWidget::cumulativeSelection () const
{ return _cumulativeSelection; }
inline QPainter& CellWidget::getPainter () inline QPainter& CellWidget::getPainter ()
{ return _drawingPlanes.painter(); } { return _drawingPlanes.painter(); }

View File

@ -147,22 +147,27 @@ namespace Hurricane {
public: public:
TabNetlist ( QWidget* parent=NULL ); TabNetlist ( QWidget* parent=NULL );
inline NetlistWidget* getNetlistBrowser (); inline NetlistWidget* getNetlistBrowser ();
inline QCheckBox* getSyncButton (); inline QCheckBox* getSyncNetlist ();
inline QCheckBox* getSyncSelection ();
virtual void cellPreModificate (); virtual void cellPreModificate ();
virtual void cellPostModificate (); virtual void cellPostModificate ();
public slots: public slots:
virtual void setCell ( Cell* ); virtual void setCell ( Cell* );
virtual void setCellWidget ( CellWidget* ); virtual void setCellWidget ( CellWidget* );
virtual void setSynchronize ( bool ); virtual void setSyncNetlist ( bool );
virtual void setSyncSelection ( bool );
protected: protected:
NetlistWidget* _netlistBrowser; NetlistWidget* _netlistBrowser;
QCheckBox* _synchronize; QCheckBox* _syncNetlist;
QCheckBox* _syncSelection;
bool _cwCumulativeSelection;
}; };
inline NetlistWidget* TabNetlist::getNetlistBrowser () { return _netlistBrowser; } inline NetlistWidget* TabNetlist::getNetlistBrowser () { return _netlistBrowser; }
inline QCheckBox* TabNetlist::getSyncButton () { return _synchronize; } inline QCheckBox* TabNetlist::getSyncNetlist () { return _syncNetlist; }
inline QCheckBox* TabNetlist::getSyncSelection () { return _syncSelection; }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -179,7 +184,6 @@ namespace Hurricane {
virtual void cellPreModificate (); virtual void cellPreModificate ();
virtual void cellPostModificate (); virtual void cellPostModificate ();
public slots: public slots:
virtual void setCell ( Cell* );
virtual void setCellWidget ( CellWidget* ); virtual void setCellWidget ( CellWidget* );
protected: protected:

View File

@ -27,11 +27,14 @@
#define __HURRICANE_NETLIST_WIDGET__ #define __HURRICANE_NETLIST_WIDGET__
#include <set>
#include <QWidget> #include <QWidget>
#include <QTableView> #include <QTableView>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include "hurricane/Commons.h" #include "hurricane/Commons.h"
#include "hurricane/Bug.h"
#include "hurricane/viewer/CellWidget.h" #include "hurricane/viewer/CellWidget.h"
#include "hurricane/viewer/NetlistModel.h" #include "hurricane/viewer/NetlistModel.h"
@ -47,10 +50,68 @@ class QHeaderView;
namespace Hurricane { namespace Hurricane {
using std::set;
class Net; class Net;
class Cell; class Cell;
class SelectedNet {
public:
inline SelectedNet ();
inline SelectedNet ( const Net*, size_t access=0 );
inline const Net* getNet () const;
inline size_t getAccesses () const;
inline void incAccesses () const;
inline void resetAccesses () const;
private:
const Net* _net;
mutable size_t _accesses;
};
inline SelectedNet::SelectedNet () : _net(NULL), _accesses(0) { }
inline SelectedNet::SelectedNet ( const Net* net, size_t accesses ) : _net(net), _accesses(accesses) { }
inline const Net* SelectedNet::getNet () const { return _net; }
inline size_t SelectedNet::getAccesses () const { return _accesses; }
inline void SelectedNet::incAccesses () const { ++_accesses; }
inline void SelectedNet::resetAccesses () const { _accesses = 0; }
struct SelectedNetCompare {
inline bool operator() ( const SelectedNet& lhs, const SelectedNet& rhs );
};
inline bool SelectedNetCompare::operator() ( const SelectedNet& lhs, const SelectedNet& rhs )
{
return lhs.getNet()->getName() < rhs.getNet()->getName();
}
class SelectedNetSet : public set<SelectedNet,SelectedNetCompare>{
public:
void insert ( const Net* );
void resetAccesses ();
};
inline void SelectedNetSet::insert ( const Net* net )
{
iterator iselected = find(SelectedNet(net));
if ( iselected != end() )
iselected->incAccesses ();
else
set<SelectedNet,SelectedNetCompare>::insert ( SelectedNet(net,64) );
}
inline void SelectedNetSet::resetAccesses ()
{
for ( iterator iselected=begin() ; iselected != end() ; ++iselected )
iselected->resetAccesses ();
}
class NetlistWidget : public QWidget { class NetlistWidget : public QWidget {
Q_OBJECT; Q_OBJECT;
@ -62,12 +123,14 @@ namespace Hurricane {
void goTo ( int ); void goTo ( int );
signals: signals:
void netSelected ( const Net* ); void netSelected ( const Net* );
void netUnselected ( const Net* );
public slots: public slots:
void forceRowHeight (); void forceRowHeight ();
private slots: private slots:
void textFilterChanged (); void textFilterChanged ();
void selectNet ( const QModelIndex& ); // void selectNet ( const QModelIndex& );
void selectCurrent ( const QModelIndex& , const QModelIndex& ); // void selectCurrent ( const QModelIndex& , const QModelIndex& );
void updateSelecteds ( const QItemSelection& , const QItemSelection& );
protected: protected:
void keyPressEvent ( QKeyEvent* ); void keyPressEvent ( QKeyEvent* );
@ -78,6 +141,7 @@ namespace Hurricane {
QTableView* _view; QTableView* _view;
QLineEdit* _filterPatternLineEdit; QLineEdit* _filterPatternLineEdit;
int _rowHeight; int _rowHeight;
SelectedNetSet _selecteds;
}; };

View File

@ -59,6 +59,7 @@ namespace Hurricane {
SelectionWidget ( QWidget* parent=NULL ); SelectionWidget ( QWidget* parent=NULL );
void inspect ( const QModelIndex& index ); void inspect ( const QModelIndex& index );
bool isCumulative () const; bool isCumulative () const;
void clear ();
signals: signals:
void showSelection ( bool ); void showSelection ( bool );
void occurrenceToggled ( Occurrence, bool ); void occurrenceToggled ( Occurrence, bool );

View File

@ -48,8 +48,9 @@ namespace Hurricane {
virtual Name getName () const; virtual Name getName () const;
Occurrence getOccurrence () const; Occurrence getOccurrence () const;
inline set<CellWidget*>& getCellWidgetSet (); inline set<CellWidget*>& getCellWidgetSet ();
void attachTo ( CellWidget* widget ); bool isAttachedTo ( CellWidget* ) const;
void detachFrom ( CellWidget* widget, bool inDeletion=false ); void attachTo ( CellWidget* );
void detachFrom ( CellWidget* , bool inDeletion=false );
// Inspector Managment. // Inspector Managment.
virtual string _getTypeName () const; virtual string _getTypeName () const;
virtual string _getString () const; virtual string _getString () const;

View File

@ -16,19 +16,20 @@
// | Author : Jean-Paul CHAPUT | // | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Header : "./SelectorCommand.h" | // | C++ Header : "./SelectorCriterion.h" |
// | *************************************************************** | // | *************************************************************** |
// | U p d a t e s | // | U p d a t e s |
// | | // | |
// x-----------------------------------------------------------------x // x-----------------------------------------------------------------x
#ifndef __HURRICANE_SELECTOR_COMMAND__ #ifndef __HURRICANE_SELECTOR_CRITERION__
#define __HURRICANE_SELECTOR_COMMAND__ #define __HURRICANE_SELECTOR_CRITERION__
#include <string> #include <string>
#include "hurricane/Commons.h" #include "hurricane/Commons.h"
#include "hurricane/Name.h"
namespace Hurricane { namespace Hurricane {
@ -38,35 +39,42 @@ namespace Hurricane {
class CellWidget; class CellWidget;
class SelectorCommand { class SelectorCriterion {
public: public:
virtual ~SelectorCommand (); virtual ~SelectorCriterion ();
virtual bool isValid ( CellWidget* ) const = 0;
virtual const Net* getNet () const;
virtual void doSelection ( CellWidget*, bool delayRedraw ) = 0; virtual void doSelection ( CellWidget*, bool delayRedraw ) = 0;
virtual void undoSelection ( CellWidget*, bool delayRedraw );
virtual Record* _getRecord () const = 0; virtual Record* _getRecord () const = 0;
virtual string _getString () const = 0; virtual string _getString () const = 0;
virtual string _getTypeName () const = 0; virtual string _getTypeName () const = 0;
}; };
class NetSelectorCommand : public SelectorCommand { class NetSelectorCriterion : public SelectorCriterion {
public: public:
NetSelectorCommand ( const Net* ); NetSelectorCriterion ( const Net* );
virtual ~NetSelectorCommand (); virtual ~NetSelectorCriterion ();
const Net* getNet () const; virtual const Net* getNet () const;
virtual bool isValid ( CellWidget* ) const;
virtual void doSelection ( CellWidget*, bool delayRedraw ); virtual void doSelection ( CellWidget*, bool delayRedraw );
virtual void undoSelection ( CellWidget*, bool delayRedraw );
virtual Record* _getRecord () const; virtual Record* _getRecord () const;
virtual string _getString () const; virtual string _getString () const;
virtual string _getTypeName () const; virtual string _getTypeName () const;
protected: protected:
const Net* _net; const Net* _net;
const Name _name;
}; };
class AreaSelectorCommand : public SelectorCommand { class AreaSelectorCriterion : public SelectorCriterion {
public: public:
AreaSelectorCommand ( const Box& ); AreaSelectorCriterion ( const Box& );
virtual ~AreaSelectorCommand (); virtual ~AreaSelectorCriterion ();
const Box& getArea () const; const Box& getArea () const;
virtual bool isValid ( CellWidget* ) const;
virtual void doSelection ( CellWidget*, bool delayRedraw ); virtual void doSelection ( CellWidget*, bool delayRedraw );
virtual Record* _getRecord () const; virtual Record* _getRecord () const;
virtual string _getString () const; virtual string _getString () const;
@ -79,7 +87,7 @@ namespace Hurricane {
} }
INSPECTOR_P_SUPPORT(Hurricane::SelectorCommand); INSPECTOR_P_SUPPORT(Hurricane::SelectorCriterion);
#endif // __HURRICANE_SELECTOR_COMMAND__ #endif // __HURRICANE_SELECTOR_CRITERION__