* ./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:
parent
e5f5ce3592
commit
4bc6940b39
|
@ -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".
|
||||
|
||||
|
@ -429,7 +506,7 @@ namespace Hurricane {
|
|||
, _delaySelectionChanged(0)
|
||||
, _cellModificated(true)
|
||||
, _selectors()
|
||||
, _selectorCommands()
|
||||
, _selection(this)
|
||||
, _commands()
|
||||
, _redrawRectCount(0)
|
||||
, _textFontHeight(20)
|
||||
|
@ -460,8 +537,6 @@ namespace Hurricane {
|
|||
{
|
||||
cerr << "CellWidget::~CellWidget()" << endl;
|
||||
|
||||
clearSelectorCommands ();
|
||||
|
||||
for ( size_t i=0 ; i<_commands.size() ; 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 )
|
||||
{
|
||||
setCursor ( cursor );
|
||||
|
@ -1192,6 +1258,8 @@ namespace Hurricane {
|
|||
|
||||
void CellWidget::setCell ( Cell* cell )
|
||||
{
|
||||
cellPreModificate ();
|
||||
|
||||
_cell = cell;
|
||||
_drawingQuery.setCell ( cell );
|
||||
_textDrawingQuery.setCell ( cell );
|
||||
|
@ -1199,6 +1267,8 @@ namespace Hurricane {
|
|||
emit cellChanged ( cell );
|
||||
|
||||
fitToContents ();
|
||||
|
||||
cellPostModificate ();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1207,11 +1277,29 @@ namespace Hurricane {
|
|||
++_delaySelectionChanged;
|
||||
|
||||
if ( !_cumulativeSelection ) unselectAll ( true );
|
||||
// ToDo: Check here if the Net is already in the Selection.
|
||||
_selectorCommands.push_back ( new NetSelectorCommand(net) );
|
||||
_selectorCommands.back()->doSelection ( this, delayRedraw );
|
||||
bool added = _selection.add ( net, 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;
|
||||
|
||||
if ( !_cumulativeSelection ) unselectAll ( true );
|
||||
bool added = _selection.add ( selectArea );
|
||||
|
||||
_selectorCommands.push_back ( new AreaSelectorCommand(selectArea) );
|
||||
_selectorCommands.back()->doSelection ( this, true );
|
||||
if ( !--_delaySelectionChanged && added ) emit selectionChanged(_selectors,_cell);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
clearSelectorCommands ();
|
||||
_selection.clear ();
|
||||
_unselectAll ( delayRedraw );
|
||||
|
||||
if ( !--_delaySelectionChanged ) emit selectionChanged(_selectors,_cell);
|
||||
|
@ -1317,6 +1412,7 @@ namespace Hurricane {
|
|||
|
||||
void CellWidget::_select ( const Net* net, bool delayRedraw )
|
||||
{
|
||||
select ( Occurrence(net) );
|
||||
forEach ( Component*, component, net->getComponents() ) {
|
||||
Occurrence occurrence ( *component );
|
||||
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 )
|
||||
{
|
||||
forEach ( Occurrence, ioccurrence, _cell->getOccurrencesUnder(selectArea) )
|
||||
|
@ -1357,9 +1464,7 @@ namespace Hurricane {
|
|||
_cellModificated = true;
|
||||
|
||||
++_delaySelectionChanged;
|
||||
vector<SelectorCommand*>::iterator icommand = _selectorCommands.begin ();
|
||||
for ( ; icommand != _selectorCommands.end() ; icommand++ )
|
||||
(*icommand)->doSelection ( this, true );
|
||||
_selection.revalidate ();
|
||||
|
||||
updatePalette ();
|
||||
redraw ();
|
||||
|
|
|
@ -166,9 +166,11 @@ namespace Hurricane {
|
|||
|
||||
|
||||
TabNetlist::TabNetlist ( QWidget* parent )
|
||||
: ControllerTab (parent)
|
||||
, _netlistBrowser(new NetlistWidget())
|
||||
, _synchronize (new QCheckBox())
|
||||
: ControllerTab (parent)
|
||||
, _netlistBrowser (new NetlistWidget())
|
||||
, _syncNetlist (new QCheckBox())
|
||||
, _syncSelection (new QCheckBox())
|
||||
, _cwCumulativeSelection(false)
|
||||
{
|
||||
_netlistBrowser->setObjectName ( "controller.tabNetlist.netlistBrowser" );
|
||||
|
||||
|
@ -176,15 +178,22 @@ namespace Hurricane {
|
|||
wLayout->setContentsMargins ( 10, 0, 10, 0 );
|
||||
wLayout->setSpacing ( 0 );
|
||||
|
||||
_synchronize->setText ( tr("Synchronize Netlist") );
|
||||
_synchronize->setChecked ( false );
|
||||
_synchronize->setFont ( Graphics::getFixedFont(QFont::Bold,false,false) );
|
||||
connect ( _synchronize, SIGNAL(toggled(bool)), this, SLOT(setSynchronize(bool)) );
|
||||
_syncNetlist->setText ( tr("Sync Netlist") );
|
||||
_syncNetlist->setChecked ( false );
|
||||
_syncNetlist->setFont ( Graphics::getFixedFont(QFont::Bold,false,false) );
|
||||
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 ();
|
||||
commands->setContentsMargins ( 0, 0, 0, 0 );
|
||||
commands->addStretch ();
|
||||
commands->addWidget ( _synchronize );
|
||||
commands->addWidget ( _syncNetlist );
|
||||
commands->addStretch ();
|
||||
commands->addWidget ( _syncSelection );
|
||||
commands->addStretch ();
|
||||
wLayout->addLayout ( commands );
|
||||
|
||||
|
@ -198,7 +207,7 @@ namespace Hurricane {
|
|||
}
|
||||
|
||||
|
||||
void TabNetlist::setSynchronize ( bool state )
|
||||
void TabNetlist::setSyncNetlist ( bool state )
|
||||
{
|
||||
if ( state && getCellWidget() ) {
|
||||
_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 )
|
||||
{
|
||||
setSynchronize ( _synchronize->isChecked() );
|
||||
setSyncNetlist ( _syncNetlist->isChecked() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -220,9 +248,8 @@ namespace Hurricane {
|
|||
ControllerTab::setCellWidget ( cellWidget );
|
||||
if ( getCellWidget() ) {
|
||||
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 ()
|
||||
{
|
||||
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 )
|
||||
{
|
||||
if ( getCellWidget() != cellWidget ) {
|
||||
ControllerTab::setCellWidget ( cellWidget );
|
||||
if ( getCellWidget() ) {
|
||||
connect ( getCellWidget() , SIGNAL(cellChanged(Cell*))
|
||||
, this , SLOT(setCell(Cell*)) );
|
||||
connect ( getCellWidget(), SIGNAL(selectionChanged(const set<Selector*>&,Cell*))
|
||||
, _selection , SLOT (setSelection (const set<Selector*>&,Cell*)) );
|
||||
connect ( _selection , SIGNAL(occurrenceToggled(Occurrence,bool))
|
||||
|
@ -299,17 +318,17 @@ namespace Hurricane {
|
|||
|
||||
void TabSelection::cellPreModificate ()
|
||||
{
|
||||
_selection->setSelection ( set<Selector*>() );
|
||||
_selection->clear ();
|
||||
}
|
||||
|
||||
|
||||
void TabSelection::cellPostModificate ()
|
||||
{
|
||||
//updateTab ();
|
||||
if ( getCellWidget() && getCellWidget()->getCell() )
|
||||
if ( getCellWidget() && getCellWidget()->getCell() ) {
|
||||
_selection->setSelection ( getCellWidget()->getSelectorSet(), getCellWidget()->getCell() );
|
||||
else
|
||||
_selection->setSelection ( set<Selector*>() );
|
||||
} else
|
||||
_selection->clear ();
|
||||
}
|
||||
|
||||
|
||||
|
@ -456,10 +475,8 @@ namespace Hurricane {
|
|||
addTab ( _tabInspector , "Inspector" );
|
||||
|
||||
connect ( this, SIGNAL(currentChanged(int)), this, SLOT(updateTab(int)) );
|
||||
//connect ( _tabNetlist->getNetlistBrowser(), SIGNAL(netSelected(const Net*))
|
||||
// , _tabSelection , SLOT(setUpdateFromNetlist(const Net*)) );
|
||||
connect ( _tabSelection->getSelection() , SIGNAL(inspect(Occurrence&))
|
||||
, _tabInspector , SLOT(setSelectionOccurrence(Occurrence&)) );
|
||||
connect ( _tabSelection->getSelection(), SIGNAL(inspect(Occurrence&))
|
||||
, _tabInspector , SLOT (setSelectionOccurrence(Occurrence&)) );
|
||||
|
||||
resize ( 540, 540 );
|
||||
}
|
||||
|
|
|
@ -38,31 +38,36 @@
|
|||
#include "hurricane/viewer/NetlistWidget.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
using namespace Hurricane;
|
||||
|
||||
|
||||
} // End of anonymous namespace.
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
|
||||
NetlistWidget::NetlistWidget ( QWidget* parent )
|
||||
: QWidget(parent)
|
||||
, _cell(NULL)
|
||||
, _baseModel(NULL)
|
||||
, _sortModel(NULL)
|
||||
, _view(NULL)
|
||||
: QWidget (parent)
|
||||
, _cell (NULL)
|
||||
, _baseModel(new NetlistModel(this))
|
||||
, _sortModel(new QSortFilterProxyModel(this))
|
||||
, _view (new QTableView(this))
|
||||
, _rowHeight(20)
|
||||
, _selecteds()
|
||||
{
|
||||
setAttribute ( Qt::WA_DeleteOnClose );
|
||||
setAttribute ( Qt::WA_QuitOnClose, false );
|
||||
|
||||
_rowHeight = QFontMetrics(Graphics::getFixedFont()).height() + 4;
|
||||
|
||||
_baseModel = new NetlistModel ( this );
|
||||
|
||||
_sortModel = new QSortFilterProxyModel ( this );
|
||||
_sortModel->setSourceModel ( _baseModel );
|
||||
_sortModel->setDynamicSortFilter ( true );
|
||||
_sortModel->setFilterKeyColumn ( 0 );
|
||||
|
||||
_view = new QTableView(this);
|
||||
_view->setShowGrid(false);
|
||||
_view->setAlternatingRowColors(true);
|
||||
_view->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
|
@ -89,13 +94,9 @@ namespace Hurricane {
|
|||
setLayout ( gLayout );
|
||||
|
||||
connect ( _filterPatternLineEdit , SIGNAL(textChanged(const QString &))
|
||||
, this , SLOT(textFilterChanged())
|
||||
);
|
||||
connect ( _view , SIGNAL(activated(const QModelIndex&))
|
||||
, this , SLOT(selectNet(const QModelIndex&))
|
||||
);
|
||||
// connect ( _view->selectionModel(), SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&))
|
||||
// , this , SLOT(selectCurrent (const QModelIndex&,const QModelIndex&)) );
|
||||
, this , SLOT (textFilterChanged()) );
|
||||
connect ( _view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&))
|
||||
, this , SLOT (updateSelecteds (const QItemSelection&,const QItemSelection&)) );
|
||||
connect ( _baseModel , SIGNAL(layoutChanged()), this, SLOT(forceRowHeight()) );
|
||||
|
||||
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 ();
|
||||
|
||||
if ( net )
|
||||
emit netSelected ( net );
|
||||
}
|
||||
QModelIndexList iList = _view->selectionModel()->selectedRows();
|
||||
for ( int i=0 ; i<iList.size() ; i++ ) {
|
||||
net = _baseModel->getNet ( _sortModel->mapToSource(iList[i]).row() );
|
||||
if ( net )
|
||||
_selecteds.insert ( net );
|
||||
}
|
||||
|
||||
|
||||
void NetlistWidget::selectCurrent ( const QModelIndex& current, const QModelIndex& )
|
||||
{
|
||||
selectNet ( current );
|
||||
SelectedNetSet::iterator remove;
|
||||
SelectedNetSet::iterator isel = _selecteds.begin ();
|
||||
while ( isel != _selecteds.end() ) {
|
||||
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 )
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -203,6 +203,12 @@ namespace Hurricane {
|
|||
}
|
||||
|
||||
|
||||
void SelectionWidget::clear ()
|
||||
{
|
||||
_baseModel->clear ();
|
||||
}
|
||||
|
||||
|
||||
void SelectionWidget::selectCurrent ( const QModelIndex& current, const QModelIndex& )
|
||||
{
|
||||
inspect ( current );
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
if ( !widget )
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
// | Author : Jean-Paul CHAPUT |
|
||||
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
|
||||
// | =============================================================== |
|
||||
// | C++ Header : "./SelectorCommand.cpp" |
|
||||
// | C++ Header : "./SelectorCriterion.cpp" |
|
||||
// | *************************************************************** |
|
||||
// | U p d a t e s |
|
||||
// | |
|
||||
|
@ -24,6 +24,7 @@
|
|||
|
||||
|
||||
#include "hurricane/viewer/CellWidget.h"
|
||||
//#include "hurricane/viewer/SelectorCriterion.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)
|
||||
, _name(_net->getName())
|
||||
{ }
|
||||
|
||||
|
||||
NetSelectorCommand::~NetSelectorCommand ()
|
||||
NetSelectorCriterion::~NetSelectorCriterion ()
|
||||
{ }
|
||||
|
||||
|
||||
const Net* NetSelectorCommand::getNet () const
|
||||
const Net* NetSelectorCriterion::getNet () const
|
||||
{ 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 );
|
||||
}
|
||||
|
||||
|
||||
string NetSelectorCommand::_getTypeName () const
|
||||
{ return "NetSelectorCommand"; }
|
||||
void NetSelectorCriterion::undoSelection ( CellWidget* cw, bool delayRedraw )
|
||||
{
|
||||
cw->_unselect ( _net, delayRedraw );
|
||||
}
|
||||
|
||||
|
||||
string NetSelectorCommand::_getString () const
|
||||
string NetSelectorCriterion::_getTypeName () const
|
||||
{ return "NetSelectorCriterion"; }
|
||||
|
||||
|
||||
string NetSelectorCriterion::_getString () const
|
||||
{
|
||||
string s = "<" + _getTypeName() + " " + getString(_net) + ">";
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
Record* NetSelectorCommand::_getRecord () const
|
||||
Record* NetSelectorCriterion::_getRecord () const
|
||||
{
|
||||
Record* record = new Record ( _getString() );
|
||||
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)
|
||||
{ }
|
||||
|
||||
|
||||
AreaSelectorCommand::~AreaSelectorCommand ()
|
||||
AreaSelectorCriterion::~AreaSelectorCriterion ()
|
||||
{ }
|
||||
|
||||
|
||||
const Box& AreaSelectorCommand::getArea () const
|
||||
const Box& AreaSelectorCriterion::getArea () const
|
||||
{ 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 );
|
||||
}
|
||||
|
||||
|
||||
string AreaSelectorCommand::_getTypeName () const
|
||||
{ return "AreaSelectorCommand"; }
|
||||
string AreaSelectorCriterion::_getTypeName () const
|
||||
{ return "AreaSelectorCriterion"; }
|
||||
|
||||
|
||||
string AreaSelectorCommand::_getString () const
|
||||
string AreaSelectorCriterion::_getString () const
|
||||
{
|
||||
string s = "<" + _getTypeName() + " " + getString(_area) + ">";
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
Record* AreaSelectorCommand::_getRecord () const
|
||||
Record* AreaSelectorCriterion::_getRecord () const
|
||||
{
|
||||
Record* record = new Record ( _getString() );
|
||||
record->add ( getSlot("_area",&_area) );
|
||||
|
|
|
@ -52,6 +52,7 @@ class QAction;
|
|||
#include "hurricane/viewer/DisplayStyle.h"
|
||||
#include "hurricane/viewer/CellWidgets.h"
|
||||
#include "hurricane/viewer/Selector.h"
|
||||
//#include "hurricane/viewer/SelectorCriterion.h"
|
||||
#include "hurricane/viewer/SelectorCommand.h"
|
||||
|
||||
|
||||
|
@ -102,10 +103,10 @@ namespace Hurricane {
|
|||
void detachFromPalette ();
|
||||
void bindCommand ( Command* );
|
||||
void unbindCommand ( Command* );
|
||||
void clearSelectorCommands ();
|
||||
inline bool showBoundaries () const;
|
||||
inline set<Selector*>& getSelectorSet ();
|
||||
inline bool showSelection () const;
|
||||
inline bool cumulativeSelection () const;
|
||||
inline set<Selector*>& getSelectorSet ();
|
||||
inline void setStartLevel ( int );
|
||||
inline void setStopLevel ( int );
|
||||
inline void setQueryFilter ( int );
|
||||
|
@ -169,13 +170,16 @@ namespace Hurricane {
|
|||
inline QPoint& getOffsetVA ();
|
||||
void select ( const Net* net, bool delayRedraw=false );
|
||||
void select ( Occurrence occurence );
|
||||
bool isSelected ( Occurrence occurence );
|
||||
void selectOccurrencesUnder ( Box selectArea );
|
||||
void unselect ( const Net* net, bool delayRedraw=false );
|
||||
void unselect ( Occurrence occurence );
|
||||
void unselectAll ( bool delayRedraw=false );
|
||||
void toggleSelect ( Occurrence occurence, bool fromPopup );
|
||||
void setShowSelection ( bool state );
|
||||
void setCumulativeSelection ( bool state );
|
||||
void _select ( const Net* net, bool delayRedraw=false );
|
||||
void _unselect ( const Net* net, bool delayRedraw=false );
|
||||
void _selectOccurrencesUnder ( Box selectArea );
|
||||
void _unselectAll ( bool delayRedraw );
|
||||
void updatePalette ();
|
||||
|
@ -313,35 +317,50 @@ namespace Hurricane {
|
|||
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:
|
||||
// Internal: Attributes.
|
||||
static const int _stripWidth;
|
||||
vector<Qt::CursorShape> _cursors;
|
||||
// MapView* _mapView;
|
||||
Technology* _technology;
|
||||
PaletteWidget* _palette;
|
||||
Box _displayArea;
|
||||
Box _visibleArea;
|
||||
float _scale;
|
||||
QPoint _offsetVA;
|
||||
DrawingPlanes _drawingPlanes;
|
||||
DrawingQuery _drawingQuery;
|
||||
TextDrawingQuery _textDrawingQuery;
|
||||
int _queryFilter;
|
||||
QPoint _mousePosition;
|
||||
Spot _spot;
|
||||
Cell* _cell;
|
||||
bool _showBoundaries;
|
||||
bool _showSelection;
|
||||
bool _cumulativeSelection;
|
||||
bool _selectionHasChanged;
|
||||
int _delaySelectionChanged;
|
||||
bool _cellModificated;
|
||||
set<Selector*> _selectors;
|
||||
vector<SelectorCommand*> _selectorCommands;
|
||||
vector<Command*> _commands;
|
||||
size_t _redrawRectCount;
|
||||
int _textFontHeight;
|
||||
static const int _stripWidth;
|
||||
vector<Qt::CursorShape> _cursors;
|
||||
// MapView* _mapView;
|
||||
Technology* _technology;
|
||||
PaletteWidget* _palette;
|
||||
Box _displayArea;
|
||||
Box _visibleArea;
|
||||
float _scale;
|
||||
QPoint _offsetVA;
|
||||
DrawingPlanes _drawingPlanes;
|
||||
DrawingQuery _drawingQuery;
|
||||
TextDrawingQuery _textDrawingQuery;
|
||||
int _queryFilter;
|
||||
QPoint _mousePosition;
|
||||
Spot _spot;
|
||||
Cell* _cell;
|
||||
bool _showBoundaries;
|
||||
bool _showSelection;
|
||||
bool _cumulativeSelection;
|
||||
bool _selectionHasChanged;
|
||||
int _delaySelectionChanged;
|
||||
bool _cellModificated;
|
||||
set<Selector*> _selectors;
|
||||
SelectorCriterions _selection;
|
||||
vector<Command*> _commands;
|
||||
size_t _redrawRectCount;
|
||||
int _textFontHeight;
|
||||
};
|
||||
|
||||
|
||||
|
@ -569,6 +588,10 @@ namespace Hurricane {
|
|||
{ return _showSelection; }
|
||||
|
||||
|
||||
inline bool CellWidget::cumulativeSelection () const
|
||||
{ return _cumulativeSelection; }
|
||||
|
||||
|
||||
inline QPainter& CellWidget::getPainter ()
|
||||
{ return _drawingPlanes.painter(); }
|
||||
|
||||
|
|
|
@ -147,22 +147,27 @@ namespace Hurricane {
|
|||
public:
|
||||
TabNetlist ( QWidget* parent=NULL );
|
||||
inline NetlistWidget* getNetlistBrowser ();
|
||||
inline QCheckBox* getSyncButton ();
|
||||
inline QCheckBox* getSyncNetlist ();
|
||||
inline QCheckBox* getSyncSelection ();
|
||||
virtual void cellPreModificate ();
|
||||
virtual void cellPostModificate ();
|
||||
public slots:
|
||||
virtual void setCell ( Cell* );
|
||||
virtual void setCellWidget ( CellWidget* );
|
||||
virtual void setSynchronize ( bool );
|
||||
virtual void setSyncNetlist ( bool );
|
||||
virtual void setSyncSelection ( bool );
|
||||
|
||||
protected:
|
||||
NetlistWidget* _netlistBrowser;
|
||||
QCheckBox* _synchronize;
|
||||
QCheckBox* _syncNetlist;
|
||||
QCheckBox* _syncSelection;
|
||||
bool _cwCumulativeSelection;
|
||||
};
|
||||
|
||||
|
||||
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 cellPostModificate ();
|
||||
public slots:
|
||||
virtual void setCell ( Cell* );
|
||||
virtual void setCellWidget ( CellWidget* );
|
||||
|
||||
protected:
|
||||
|
|
|
@ -27,11 +27,14 @@
|
|||
#define __HURRICANE_NETLIST_WIDGET__
|
||||
|
||||
|
||||
#include <set>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTableView>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include "hurricane/Commons.h"
|
||||
#include "hurricane/Bug.h"
|
||||
#include "hurricane/viewer/CellWidget.h"
|
||||
#include "hurricane/viewer/NetlistModel.h"
|
||||
|
||||
|
@ -47,10 +50,68 @@ class QHeaderView;
|
|||
namespace Hurricane {
|
||||
|
||||
|
||||
using std::set;
|
||||
class Net;
|
||||
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 {
|
||||
Q_OBJECT;
|
||||
|
||||
|
@ -62,12 +123,14 @@ namespace Hurricane {
|
|||
void goTo ( int );
|
||||
signals:
|
||||
void netSelected ( const Net* );
|
||||
void netUnselected ( const Net* );
|
||||
public slots:
|
||||
void forceRowHeight ();
|
||||
private slots:
|
||||
void textFilterChanged ();
|
||||
void selectNet ( const QModelIndex& );
|
||||
void selectCurrent ( const QModelIndex& , const QModelIndex& );
|
||||
// void selectNet ( const QModelIndex& );
|
||||
// void selectCurrent ( const QModelIndex& , const QModelIndex& );
|
||||
void updateSelecteds ( const QItemSelection& , const QItemSelection& );
|
||||
protected:
|
||||
void keyPressEvent ( QKeyEvent* );
|
||||
|
||||
|
@ -78,6 +141,7 @@ namespace Hurricane {
|
|||
QTableView* _view;
|
||||
QLineEdit* _filterPatternLineEdit;
|
||||
int _rowHeight;
|
||||
SelectedNetSet _selecteds;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ namespace Hurricane {
|
|||
SelectionWidget ( QWidget* parent=NULL );
|
||||
void inspect ( const QModelIndex& index );
|
||||
bool isCumulative () const;
|
||||
void clear ();
|
||||
signals:
|
||||
void showSelection ( bool );
|
||||
void occurrenceToggled ( Occurrence, bool );
|
||||
|
|
|
@ -48,8 +48,9 @@ namespace Hurricane {
|
|||
virtual Name getName () const;
|
||||
Occurrence getOccurrence () const;
|
||||
inline set<CellWidget*>& getCellWidgetSet ();
|
||||
void attachTo ( CellWidget* widget );
|
||||
void detachFrom ( CellWidget* widget, bool inDeletion=false );
|
||||
bool isAttachedTo ( CellWidget* ) const;
|
||||
void attachTo ( CellWidget* );
|
||||
void detachFrom ( CellWidget* , bool inDeletion=false );
|
||||
// Inspector Managment.
|
||||
virtual string _getTypeName () const;
|
||||
virtual string _getString () const;
|
||||
|
|
|
@ -16,19 +16,20 @@
|
|||
// | Author : Jean-Paul CHAPUT |
|
||||
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
|
||||
// | =============================================================== |
|
||||
// | C++ Header : "./SelectorCommand.h" |
|
||||
// | C++ Header : "./SelectorCriterion.h" |
|
||||
// | *************************************************************** |
|
||||
// | U p d a t e s |
|
||||
// | |
|
||||
// x-----------------------------------------------------------------x
|
||||
|
||||
|
||||
#ifndef __HURRICANE_SELECTOR_COMMAND__
|
||||
#define __HURRICANE_SELECTOR_COMMAND__
|
||||
#ifndef __HURRICANE_SELECTOR_CRITERION__
|
||||
#define __HURRICANE_SELECTOR_CRITERION__
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "hurricane/Commons.h"
|
||||
#include "hurricane/Name.h"
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
@ -38,39 +39,46 @@ namespace Hurricane {
|
|||
class CellWidget;
|
||||
|
||||
|
||||
class SelectorCommand {
|
||||
class SelectorCriterion {
|
||||
public:
|
||||
virtual ~SelectorCommand ();
|
||||
virtual void doSelection ( CellWidget*, bool delayRedraw ) = 0;
|
||||
virtual Record* _getRecord () const = 0;
|
||||
virtual string _getString () const = 0;
|
||||
virtual string _getTypeName () const = 0;
|
||||
virtual ~SelectorCriterion ();
|
||||
virtual bool isValid ( CellWidget* ) const = 0;
|
||||
virtual const Net* getNet () const;
|
||||
virtual void doSelection ( CellWidget*, bool delayRedraw ) = 0;
|
||||
virtual void undoSelection ( CellWidget*, bool delayRedraw );
|
||||
virtual Record* _getRecord () const = 0;
|
||||
virtual string _getString () const = 0;
|
||||
virtual string _getTypeName () const = 0;
|
||||
};
|
||||
|
||||
|
||||
class NetSelectorCommand : public SelectorCommand {
|
||||
class NetSelectorCriterion : public SelectorCriterion {
|
||||
public:
|
||||
NetSelectorCommand ( const Net* );
|
||||
virtual ~NetSelectorCommand ();
|
||||
const Net* getNet () const;
|
||||
virtual void doSelection ( CellWidget*, bool delayRedraw );
|
||||
virtual Record* _getRecord () const;
|
||||
virtual string _getString () const;
|
||||
virtual string _getTypeName () const;
|
||||
NetSelectorCriterion ( const Net* );
|
||||
virtual ~NetSelectorCriterion ();
|
||||
virtual const Net* getNet () const;
|
||||
virtual bool isValid ( CellWidget* ) const;
|
||||
virtual void doSelection ( CellWidget*, bool delayRedraw );
|
||||
virtual void undoSelection ( CellWidget*, bool delayRedraw );
|
||||
virtual Record* _getRecord () const;
|
||||
virtual string _getString () const;
|
||||
virtual string _getTypeName () const;
|
||||
protected:
|
||||
const Net* _net;
|
||||
const Name _name;
|
||||
};
|
||||
|
||||
|
||||
class AreaSelectorCommand : public SelectorCommand {
|
||||
class AreaSelectorCriterion : public SelectorCriterion {
|
||||
public:
|
||||
AreaSelectorCommand ( const Box& );
|
||||
virtual ~AreaSelectorCommand ();
|
||||
const Box& getArea () const;
|
||||
virtual void doSelection ( CellWidget*, bool delayRedraw );
|
||||
virtual Record* _getRecord () const;
|
||||
virtual string _getString () const;
|
||||
virtual string _getTypeName () const;
|
||||
AreaSelectorCriterion ( const Box& );
|
||||
virtual ~AreaSelectorCriterion ();
|
||||
const Box& getArea () const;
|
||||
virtual bool isValid ( CellWidget* ) const;
|
||||
virtual void doSelection ( CellWidget*, bool delayRedraw );
|
||||
virtual Record* _getRecord () const;
|
||||
virtual string _getString () const;
|
||||
virtual string _getTypeName () const;
|
||||
protected:
|
||||
const Box _area;
|
||||
};
|
||||
|
@ -79,7 +87,7 @@ namespace Hurricane {
|
|||
}
|
||||
|
||||
|
||||
INSPECTOR_P_SUPPORT(Hurricane::SelectorCommand);
|
||||
INSPECTOR_P_SUPPORT(Hurricane::SelectorCriterion);
|
||||
|
||||
|
||||
#endif // __HURRICANE_SELECTOR_COMMAND__
|
||||
#endif // __HURRICANE_SELECTOR_CRITERION__
|
||||
|
|
Loading…
Reference in New Issue