From 78be633226188dfd2ab8fd571e17cb2d96b2cff2 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Tue, 3 Feb 2009 15:05:05 +0000 Subject: [PATCH] * ./hurricane/src/hviewer : - Change: modifie GraphicsWidget, PaletteWidget, NetlistWidget & SelectionWidget to comply to the "star" model. --- hurricane/src/hviewer/CellViewer.cpp | 35 +++-- hurricane/src/hviewer/CellWidget.cpp | 36 ++--- hurricane/src/hviewer/ControllerWidget.cpp | 33 +---- hurricane/src/hviewer/DisplayFilterWidget.cpp | 26 ++-- hurricane/src/hviewer/GraphicsWidget.cpp | 41 +++++- hurricane/src/hviewer/NetlistWidget.cpp | 21 ++- hurricane/src/hviewer/PaletteItem.cpp | 6 +- hurricane/src/hviewer/PaletteLayerItem.cpp | 11 +- hurricane/src/hviewer/PaletteWidget.cpp | 8 +- hurricane/src/hviewer/SelectCommand.cpp | 16 +-- hurricane/src/hviewer/SelectionModel.cpp | 2 +- hurricane/src/hviewer/SelectionWidget.cpp | 134 ++++++++++++------ .../src/hviewer/hurricane/viewer/CellViewer.h | 2 + .../src/hviewer/hurricane/viewer/CellWidget.h | 14 +- .../hurricane/viewer/DisplayFilterWidget.h | 11 +- .../hviewer/hurricane/viewer/GraphicsWidget.h | 12 +- .../hviewer/hurricane/viewer/NetlistWidget.h | 34 ++++- .../hviewer/hurricane/viewer/PaletteItem.h | 5 +- .../hurricane/viewer/PaletteLayerItem.h | 27 ++-- .../hviewer/hurricane/viewer/PaletteWidget.h | 2 +- .../hviewer/hurricane/viewer/SelectCommand.h | 1 - .../hurricane/viewer/SelectionWidget.h | 53 +++---- 22 files changed, 300 insertions(+), 230 deletions(-) diff --git a/hurricane/src/hviewer/CellViewer.cpp b/hurricane/src/hviewer/CellViewer.cpp index 37ee4540..2cf15215 100644 --- a/hurricane/src/hviewer/CellViewer.cpp +++ b/hurricane/src/hviewer/CellViewer.cpp @@ -75,6 +75,7 @@ namespace Hurricane { , _hierarchyCommand() , _cellHistory() , _firstShow(false) + , _updateState(ExternalEmit) { setObjectName("viewer"); @@ -227,8 +228,6 @@ namespace Hurricane { _cellWidget->bindCommand ( &_hierarchyCommand ); _controller->setCellWidget ( _cellWidget ); - _selectCommand.bindToAction ( _showSelectionAction ); - MousePositionWidget* _mousePosition = new MousePositionWidget (); statusBar()->addPermanentWidget ( _mousePosition ); @@ -259,10 +258,8 @@ namespace Hurricane { connect ( _cellWidget , SIGNAL(mousePositionChanged(const Point&)) , _mousePosition , SLOT(setPosition(const Point&)) ); - connect ( this , SIGNAL(showSelectionToggled(bool)) - , _cellWidget , SLOT (setShowSelection (bool)) ); - connect ( _cellWidget , SIGNAL(showSelectionToggled(bool)) - , this , SLOT (setShowSelection (bool)) ); + connect ( _cellWidget , SIGNAL(selectionModeChanged()) + , this , SLOT (changeSelectionMode ()) ); connect ( &_selectCommand , SIGNAL(selectionToggled (Occurrence)) , _cellWidget , SLOT (toggleSelection (Occurrence)) ); @@ -366,21 +363,21 @@ namespace Hurricane { } + void CellViewer::changeSelectionMode () + { + if ( _updateState != InternalEmit ) { + _showSelectionAction->blockSignals ( true ); + _showSelectionAction->setChecked ( _cellWidget->getState()->cumulativeSelection() ); + _showSelectionAction->blockSignals ( false ); + } + _updateState = ExternalEmit; + } + + void CellViewer::setShowSelection ( bool state ) { - static bool isEmitter = false; - - if ( sender() == _showSelectionAction ) { - isEmitter = true; - emit showSelectionToggled ( state ); - } else { - if ( !isEmitter ) { - _showSelectionAction->blockSignals ( true ); - _showSelectionAction->setChecked ( state ); - _showSelectionAction->blockSignals ( false ); - } else - isEmitter = false; - } + _updateState = InternalEmit; + _cellWidget->setShowSelection ( state ); } diff --git a/hurricane/src/hviewer/CellWidget.cpp b/hurricane/src/hviewer/CellWidget.cpp index ab7a1c4e..39c9808e 100644 --- a/hurricane/src/hviewer/CellWidget.cpp +++ b/hurricane/src/hviewer/CellWidget.cpp @@ -71,7 +71,6 @@ namespace Hurricane { typedef Hurricane::Collection OccurrenceHC; - // ------------------------------------------------------------------- // Class : "Occurrences_IsSelectable". @@ -967,10 +966,12 @@ namespace Hurricane { } - void CellWidget::styleChange ( void* emitter ) + void CellWidget::setStyle ( int id ) { + Graphics::setStyle ( (size_t)id ); refresh (); - emit styleChanged(emitter); + + emit styleChanged (); } @@ -988,7 +989,7 @@ namespace Hurricane { connect ( _palette, SIGNAL(paletteChanged()) , this , SLOT(refresh()) ); connect ( this , SIGNAL(cellChanged(Cell*)) , _palette, SLOT(updateExtensions(Cell*)) ); connect ( this , SIGNAL(updatePalette(Cell*)), _palette, SLOT(updateExtensions(Cell*)) ); - connect ( this , SIGNAL(styleChanged(void*)) , _palette, SLOT(styleChange(void*)) ); + connect ( this , SIGNAL(styleChanged()) , _palette, SLOT(changeStyle()) ); } @@ -1066,7 +1067,7 @@ namespace Hurricane { _selectionHasChanged = false; refresh (); - emit showSelectionToggled ( state ); + emit selectionModeChanged (); } } @@ -1075,7 +1076,7 @@ namespace Hurricane { { if ( state != _state->cumulativeSelection() ) { _state->setCumulativeSelection ( state ); - emit cumulativeSelectionToggled ( state ); + emit selectionModeChanged (); } } @@ -2062,14 +2063,9 @@ namespace Hurricane { { ++_delaySelectionChanged; - if ( !_state->cumulativeSelection() ) { - openRefreshSession (); - unselectAll (); - closeRefreshSession (); - } bool added = _state->getSelection().add ( net ); - if ( !--_delaySelectionChanged && added ) emit selectionChanged(_selectors,getCell()); + if ( !--_delaySelectionChanged && added ) emit selectionChanged(_selectors); } @@ -2109,8 +2105,6 @@ namespace Hurricane { , s1.c_str(), s2.c_str() ); } - //if ( !_state->cumulativeSelection() ) unselectAll ( true ); - Property* property = occurrence.getProperty ( Selector::getPropertyName() ); Selector* selector = NULL; if ( !property ) @@ -2124,7 +2118,7 @@ namespace Hurricane { selector->attachTo(this); _selectionHasChanged = true; - if ( !_delaySelectionChanged ) emit selectionChanged(_selectors,getCell()); + if ( !_delaySelectionChanged ) emit selectionChanged(_selectors); } @@ -2139,7 +2133,7 @@ namespace Hurricane { } bool added = _state->getSelection().add ( selectArea ); - if ( !--_delaySelectionChanged && added ) emit selectionChanged(_selectors,getCell()); + if ( !--_delaySelectionChanged && added ) emit selectionChanged(_selectors); } @@ -2148,7 +2142,7 @@ namespace Hurricane { ++_delaySelectionChanged; bool removed = _state->getSelection().remove ( net ); - if ( !--_delaySelectionChanged && removed ) emit selectionChanged(_selectors,getCell()); + if ( !--_delaySelectionChanged && removed ) emit selectionChanged(_selectors); } @@ -2170,7 +2164,7 @@ namespace Hurricane { } _selectionHasChanged = true; - if ( !_delaySelectionChanged ) emit selectionChanged(_selectors,getCell()); + if ( !_delaySelectionChanged ) emit selectionChanged(_selectors); } @@ -2181,7 +2175,7 @@ namespace Hurricane { _state->getSelection().clear (); _unselectAll (); - if ( !--_delaySelectionChanged ) emit selectionChanged(_selectors,getCell()); + if ( !--_delaySelectionChanged ) emit selectionChanged(_selectors); } @@ -2265,7 +2259,7 @@ namespace Hurricane { openRefreshSession (); _unselectAll (); - emit selectionChanged(_selectors,getCell()); + emit selectionChanged(_selectors); emit cellPreModificated (); closeRefreshSession (); @@ -2284,7 +2278,7 @@ namespace Hurricane { _redrawManager.refresh (); --_delaySelectionChanged; - emit selectionChanged(_selectors,getCell()); + emit selectionChanged(_selectors); emit cellPostModificated (); closeRefreshSession (); diff --git a/hurricane/src/hviewer/ControllerWidget.cpp b/hurricane/src/hviewer/ControllerWidget.cpp index bfe4f72e..254c400e 100644 --- a/hurricane/src/hviewer/ControllerWidget.cpp +++ b/hurricane/src/hviewer/ControllerWidget.cpp @@ -97,9 +97,7 @@ namespace Hurricane { { if ( getCellWidget() != cellWidget ) { ControllerTab::setCellWidget ( cellWidget ); - if ( getCellWidget() ) { - connect ( _graphics, SIGNAL(styleChanged(void*)), getCellWidget(), SLOT(styleChange(void*)) ); - } + _graphics->setCellWidget ( cellWidget ); } } @@ -226,8 +224,7 @@ namespace Hurricane { getCellWidget()->unselectAll (); getCellWidget()->closeRefreshSession (); } - getCellWidget()->setCumulativeSelection ( true ); - getCellWidget()->setShowSelection ( 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 { @@ -249,14 +246,9 @@ namespace Hurricane { { if ( getCellWidget() != cellWidget ) { ControllerTab::setCellWidget ( cellWidget ); + _netlistBrowser->setCellWidget ( cellWidget ); if ( getCellWidget() ) { - connect ( _netlistBrowser, SIGNAL(refreshSessionOpened()) - , getCellWidget(), SLOT (openRefreshSession()) ); - connect ( _netlistBrowser, SIGNAL(refreshSessionClosed()) - , getCellWidget(), SLOT (closeRefreshSession()) ); connect ( getCellWidget(), SIGNAL(cellChanged(Cell*)), this, SLOT(setCell(Cell*)) ); - connect ( _netlistBrowser, SIGNAL(netFitted(const Net*)) - , getCellWidget(), SLOT (fitToNet (const Net*)) ); } setSyncNetlist ( _syncNetlist->isChecked() ); } @@ -296,22 +288,7 @@ namespace Hurricane { { if ( getCellWidget() != cellWidget ) { ControllerTab::setCellWidget ( cellWidget ); - if ( getCellWidget() ) { - connect ( getCellWidget(), SIGNAL(selectionChanged(const SelectorSet&,Cell*)) - , _selection , SLOT (setSelection (const SelectorSet&,Cell*)) ); - connect ( _selection , SIGNAL(selectionToggled(Occurrence)) - , getCellWidget(), SLOT (toggleSelection (Occurrence)) ); - connect ( getCellWidget(), SIGNAL(selectionToggled(Occurrence)) - , _selection , SLOT (toggleSelection (Occurrence)) ); - connect ( _selection , SIGNAL(cumulativeToggled (bool)) - , getCellWidget(), SLOT (setCumulativeSelection(bool)) ); - connect ( _selection , SIGNAL(selectionCleared()) - , getCellWidget(), SLOT (unselectAll ()) ); - connect ( _selection , SIGNAL(showSelectionToggled(bool)) - , getCellWidget(), SLOT (setShowSelection (bool)) ); - connect ( getCellWidget(), SIGNAL(showSelectionToggled(bool)) - , _selection , SLOT (setShowSelection (bool)) ); - } + _selection->setCellWidget ( cellWidget ); } } @@ -335,7 +312,7 @@ namespace Hurricane { { //updateTab (); if ( getCellWidget() && getCellWidget()->getCell() ) { - _selection->setSelection ( getCellWidget()->getSelectorSet(), getCellWidget()->getCell() ); + _selection->setSelection ( getCellWidget()->getSelectorSet() ); } else _selection->clear (); } diff --git a/hurricane/src/hviewer/DisplayFilterWidget.cpp b/hurricane/src/hviewer/DisplayFilterWidget.cpp index d38512bf..e2eecdc0 100644 --- a/hurricane/src/hviewer/DisplayFilterWidget.cpp +++ b/hurricane/src/hviewer/DisplayFilterWidget.cpp @@ -55,7 +55,7 @@ namespace Hurricane { , _steiner (new QRadioButton()) , _centric (new QRadioButton()) , _barycentric (new QRadioButton()) - , _updateState (External) + , _updateState (ExternalEmit) { setAttribute ( Qt::WA_QuitOnClose, false ); setWindowTitle ( tr("Display Filter") ); @@ -145,28 +145,26 @@ namespace Hurricane { connect ( _startSpinBox, SIGNAL(valueChanged(int)), this, SLOT(startLevelChanged(int)) ); connect ( _stopSpinBox , SIGNAL(valueChanged(int)), this, SLOT(stopLevelChanged (int)) ); + connect ( _steiner , SIGNAL(clicked()) , this, SLOT(setRubberSteiner()) ); + connect ( _centric , SIGNAL(clicked()) , this, SLOT(setRubberCentric()) ); + connect ( _barycentric , SIGNAL(clicked()) , this, SLOT(setRubberBarycentric()) ); } void DisplayFilterWidget::setCellWidget ( CellWidget* cw ) { - if ( !cw ) { - if ( _cellWidget ) { - disconnect ( this , SIGNAL(queryFilterChanged()), _cellWidget, SLOT(changeQueryFilter()) ); - disconnect ( _cellWidget , SIGNAL(queryFilterChanged()), this , SLOT(changeQueryFilter()) ); - } - _cellWidget = NULL; - return; + if ( _cellWidget ) { + disconnect ( this , SIGNAL(queryFilterChanged()), _cellWidget, SLOT(changeQueryFilter()) ); + disconnect ( _cellWidget , SIGNAL(queryFilterChanged()), this , SLOT(changeQueryFilter()) ); } _cellWidget = cw; + if ( !_cellWidget ) return; + connect ( this , SIGNAL(queryFilterChanged()), _cellWidget, SLOT(changeQueryFilter()) ); connect ( _cellWidget , SIGNAL(queryFilterChanged()), this , SLOT(changeQueryFilter()) ); - connect ( _steiner , SIGNAL(clicked()) , this , SLOT(setRubberSteiner()) ); - connect ( _centric , SIGNAL(clicked()) , this , SLOT(setRubberCentric()) ); - connect ( _barycentric, SIGNAL(clicked()) , this , SLOT(setRubberBarycentric()) ); - _updateState = External; + _updateState = ExternalEmit; changeQueryFilter (); } @@ -179,7 +177,7 @@ namespace Hurricane { _updateState = InternalReceive; emit queryFilterChanged (); } else { - if ( _updateState == External ) { + if ( _updateState == ExternalEmit ) { blockAllSignals ( true ); _startSpinBox->setValue ( _cellWidget->getStartLevel() ); @@ -196,7 +194,7 @@ namespace Hurricane { } blockAllSignals ( false ); } - _updateState = External; + _updateState = ExternalEmit; } } diff --git a/hurricane/src/hviewer/GraphicsWidget.cpp b/hurricane/src/hviewer/GraphicsWidget.cpp index 5fd13f3d..21c1b833 100644 --- a/hurricane/src/hviewer/GraphicsWidget.cpp +++ b/hurricane/src/hviewer/GraphicsWidget.cpp @@ -43,7 +43,9 @@ namespace Hurricane { GraphicsWidget::GraphicsWidget ( QWidget* parent ) - : QWidget(parent) + : QWidget (parent) + , _cellWidget (NULL) + , _updateState(ExternalEmit) { setAttribute ( Qt::WA_QuitOnClose, false ); setWindowTitle ( tr("Display Styles") ); @@ -79,15 +81,42 @@ namespace Hurricane { wLayout->addStretch (); setLayout ( wLayout ); - connect ( group, SIGNAL(buttonClicked(int)), this, SLOT(styleChange(int)) ); + connect ( group, SIGNAL(buttonClicked(int)), this, SLOT(setStyle(int)) ); } - void GraphicsWidget::styleChange ( int id ) + void GraphicsWidget::setCellWidget ( CellWidget* cw ) { - Graphics::setStyle ( (size_t)id ); - //cerr << "GraphicsWidget::setStyle() - " << getString(Graphics::getStyle()->getName()) << endl; - emit styleChanged ( (void*)this ); + if ( _cellWidget ) { + disconnect ( _cellWidget, 0, this , 0 ); + disconnect ( this , 0, _cellWidget, 0 ); + } + + _cellWidget = cw; + if ( !_cellWidget ) return; + + connect ( _cellWidget, SIGNAL(styleChanged()), this, SLOT(changeStyle()) ); + + _updateState = ExternalEmit; + changeStyle (); + } + + + void GraphicsWidget::changeStyle () + { + if ( _updateState != InternalEmit ) { + // Should read style here and sets the widget accordingly. + } + _updateState = ExternalEmit; + } + + + void GraphicsWidget::setStyle ( int id ) + { + if ( _cellWidget ) { + _updateState = InternalEmit; + _cellWidget->setStyle ( (size_t)id ); + } } diff --git a/hurricane/src/hviewer/NetlistWidget.cpp b/hurricane/src/hviewer/NetlistWidget.cpp index a67152a1..5b667953 100644 --- a/hurricane/src/hviewer/NetlistWidget.cpp +++ b/hurricane/src/hviewer/NetlistWidget.cpp @@ -52,13 +52,14 @@ namespace Hurricane { NetlistWidget::NetlistWidget ( QWidget* parent ) - : QWidget (parent) - , _cell (NULL) - , _baseModel(new NetlistModel(this)) - , _sortModel(new QSortFilterProxyModel(this)) - , _view (new QTableView(this)) - , _rowHeight(20) - , _selecteds() + : QWidget (parent) + , _cellWidget(NULL) + , _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 ); @@ -131,8 +132,7 @@ namespace Hurricane { void NetlistWidget::updateSelecteds ( const QItemSelection& , const QItemSelection& ) { - cerr << "open refresh session" << endl; - emit refreshSessionOpened (); + if ( _cellWidget ) _cellWidget->openRefreshSession (); _selecteds.resetAccesses (); @@ -165,8 +165,7 @@ namespace Hurricane { ++isel; } - emit refreshSessionClosed (); - cerr << "close refresh session" << endl; + if ( _cellWidget ) _cellWidget->closeRefreshSession (); } diff --git a/hurricane/src/hviewer/PaletteItem.cpp b/hurricane/src/hviewer/PaletteItem.cpp index e05f8c59..c36a4340 100644 --- a/hurricane/src/hviewer/PaletteItem.cpp +++ b/hurricane/src/hviewer/PaletteItem.cpp @@ -90,10 +90,8 @@ namespace Hurricane { { } - void PaletteItem::styleChange () - { - emit styleChanged (); - } + void PaletteItem::changeStyle () + { } } // End of Hurricane namespace. diff --git a/hurricane/src/hviewer/PaletteLayerItem.cpp b/hurricane/src/hviewer/PaletteLayerItem.cpp index 18275869..40d2a2b2 100644 --- a/hurricane/src/hviewer/PaletteLayerItem.cpp +++ b/hurricane/src/hviewer/PaletteLayerItem.cpp @@ -40,12 +40,12 @@ namespace Hurricane { , _basicLayer(basicLayer) , _visible (new QCheckBox()) , _selectable(new QCheckBox()) + , _sample (new DrawingStyleSample(this)) { QHBoxLayout* layout = new QHBoxLayout (); layout->setContentsMargins ( 0, 0, 0, 0 ); - DrawingStyleSample* sample = new DrawingStyleSample(this); - layout->addWidget ( sample ); + layout->addWidget ( _sample ); _visible->setChecked ( visible ); _visible->setText ( getString(getName()).c_str() ); @@ -63,7 +63,6 @@ namespace Hurricane { setLayout ( layout ); - connect ( this , SIGNAL(styleChanged()), sample, SLOT (redraw ()) ); connect ( _visible , SIGNAL(clicked ()), this , SIGNAL(visibleToggled ()) ); connect ( _selectable, SIGNAL(clicked ()), this , SIGNAL(selectableToggled()) ); } @@ -82,6 +81,12 @@ namespace Hurricane { } + void PaletteLayerItem::changeStyle () + { + _sample->redraw (); + } + + bool PaletteLayerItem::isItemVisible () const { return _visible->isChecked (); diff --git a/hurricane/src/hviewer/PaletteWidget.cpp b/hurricane/src/hviewer/PaletteWidget.cpp index e2b6d4d3..ff5fae6a 100644 --- a/hurricane/src/hviewer/PaletteWidget.cpp +++ b/hurricane/src/hviewer/PaletteWidget.cpp @@ -377,17 +377,15 @@ namespace Hurricane { } - void PaletteWidget::styleChange ( void* emitter ) + void PaletteWidget::changeStyle () { - if ( emitter == this ) return; - PaletteItems::iterator iitem = _layerItems.begin(); for ( ; iitem != _layerItems.end() ; iitem++ ) - iitem->second->styleChange (); + iitem->second->changeStyle (); iitem = _extensionGoItems.begin(); for ( ; iitem != _extensionGoItems.end() ; iitem++ ) - iitem->second->styleChange (); + iitem->second->changeStyle (); } diff --git a/hurricane/src/hviewer/SelectCommand.cpp b/hurricane/src/hviewer/SelectCommand.cpp index ac393763..47c3117f 100644 --- a/hurricane/src/hviewer/SelectCommand.cpp +++ b/hurricane/src/hviewer/SelectCommand.cpp @@ -43,7 +43,6 @@ namespace Hurricane { SelectCommand::SelectCommand () : AreaCommand() - , _selectAction(NULL) , _selectionPopup(NULL) { _selectionPopup = new SelectionPopup (); @@ -59,12 +58,6 @@ namespace Hurricane { } - void SelectCommand::bindToAction ( QAction* action ) - { - _selectAction = action; - } - - bool SelectCommand::mousePressEvent ( CellWidget* widget, QMouseEvent* event ) { if ( isActive() ) return true; @@ -105,15 +98,10 @@ namespace Hurricane { //widget->unselectAll (); widget->selectOccurrencesUnder ( widget->screenToDbuBox(selectArea) ); - if ( _selectAction ) { - if ( !_selectAction->isChecked() ) - _selectAction->setChecked ( true ); - else - widget->refresh (); - } else { + if ( !widget->getState()->showSelection() ) widget->setShowSelection ( true ); + else widget->refresh (); - } return false; } diff --git a/hurricane/src/hviewer/SelectionModel.cpp b/hurricane/src/hviewer/SelectionModel.cpp index 4ec144da..bb62290f 100644 --- a/hurricane/src/hviewer/SelectionModel.cpp +++ b/hurricane/src/hviewer/SelectionModel.cpp @@ -52,7 +52,7 @@ namespace Hurricane { { SelectionWidget* widget = qobject_cast(QObject::parent()); if ( widget ) - return widget->isCumulative(); + return widget->cumulativeSelection(); return true; } diff --git a/hurricane/src/hviewer/SelectionWidget.cpp b/hurricane/src/hviewer/SelectionWidget.cpp index 630a3b42..628d349f 100644 --- a/hurricane/src/hviewer/SelectionWidget.cpp +++ b/hurricane/src/hviewer/SelectionWidget.cpp @@ -40,6 +40,7 @@ #include "hurricane/viewer/Graphics.h" #include "hurricane/viewer/SelectionModel.h" #include "hurricane/viewer/SelectionWidget.h" +#include "hurricane/viewer/CellWidget.h" namespace Hurricane { @@ -48,6 +49,7 @@ namespace Hurricane { SelectionWidget::SelectionWidget ( QWidget* parent ) : QWidget (parent) + , _cellWidget (NULL) , _baseModel (new SelectionModel(this)) , _sortModel (new QSortFilterProxyModel(this)) , _view (new QTableView(this)) @@ -55,7 +57,7 @@ namespace Hurricane { , _cumulative (new QCheckBox()) , _showSelection (new QCheckBox()) , _rowHeight (20) - , _isEmitter (false) + , _updateState (ExternalEmit) { setAttribute ( Qt::WA_DeleteOnClose ); setAttribute ( Qt::WA_QuitOnClose, false ); @@ -118,12 +120,14 @@ namespace Hurricane { setLayout ( vLayout ); connect ( _filterPatternLineEdit, SIGNAL(textChanged(const QString &)) - , this , SLOT(textFilterChanged()) ); - connect ( _baseModel , SIGNAL(layoutChanged()), this, SLOT (forceRowHeight()) ); - connect ( _cumulative , SIGNAL(toggled(bool)) , this, SIGNAL(cumulativeToggled(bool)) ); - connect ( _showSelection, SIGNAL(toggled(bool)) , this, SLOT (setShowSelection(bool)) ); - connect ( clear , SIGNAL(clicked()) , this, SIGNAL(selectionCleared()) ); + , this , SLOT (textFilterChanged()) ); + + connect ( _baseModel , SIGNAL(layoutChanged()), this , SLOT(forceRowHeight()) ); + connect ( _showSelection, SIGNAL(toggled(bool)) , this , SLOT(setShowSelection(bool)) ); + connect ( _cumulative , SIGNAL(toggled(bool)) , this , SLOT(setCumulativeSelection(bool)) ); connect ( clear , SIGNAL(clicked()) , _baseModel, SLOT(clear()) ); + connect ( clear , SIGNAL(clicked()) , this , SLOT(clear()) ); + connect ( _view->selectionModel(), SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&)) , this , SLOT (selectCurrent (const QModelIndex&,const QModelIndex&)) ); @@ -132,12 +136,6 @@ namespace Hurricane { } - void SelectionWidget::hideEvent ( QHideEvent* event ) - { - //emit showSelected(false); - } - - void SelectionWidget::forceRowHeight () { for ( int rows=_sortModel->rowCount()-1; rows >= 0 ; rows-- ) @@ -158,6 +156,77 @@ namespace Hurricane { } + void SelectionWidget::setCellWidget ( CellWidget* cw ) + { + if ( _cellWidget ) { + disconnect ( _cellWidget, 0, this , 0 ); + disconnect ( this , 0, _cellWidget, 0 ); + } + + _cellWidget = cw; + if ( !_cellWidget ) return; + + connect ( _cellWidget, SIGNAL(selectionModeChanged()), this , SLOT(changeSelectionMode()) ); + + connect ( _cellWidget, SIGNAL(selectionChanged(const SelectorSet&)) + , this , SLOT (setSelection (const SelectorSet&)) ); + + connect ( _cellWidget, SIGNAL(selectionToggled(Occurrence)), this, SLOT(toggleSelection(Occurrence)) ); + + _updateState = ExternalEmit; + changeSelectionMode (); + } + + + void SelectionWidget::changeSelectionMode () + { + if ( !_cellWidget ) return; + + if ( _updateState == InternalEmit ) { + _updateState = InternalReceive; + emit selectionModeChanged (); + } else { + if ( _updateState == ExternalEmit ) { + blockAllSignals ( true ); + + _showSelection->setChecked ( _cellWidget->getState()->showSelection () ); + _cumulative ->setChecked ( _cellWidget->getState()->cumulativeSelection() ); + + blockAllSignals ( false ); + } + _updateState = ExternalEmit; + } + } + + + void SelectionWidget::blockAllSignals ( bool state ) + { + _showSelection->blockSignals ( state ); + _cumulative ->blockSignals ( state ); + _baseModel ->blockSignals ( state ); + } + + + void SelectionWidget::setShowSelection ( bool state ) + { + _updateState = InternalEmit; + _cellWidget->setShowSelection ( state ); + } + + + void SelectionWidget::setCumulativeSelection ( bool state ) + { + _updateState = InternalEmit; + _cellWidget->setCumulativeSelection ( state ); + } + + + bool SelectionWidget::cumulativeSelection () const + { + return _cumulative->isChecked (); + } + + void SelectionWidget::textFilterChanged () { _sortModel->setFilterRegExp ( _filterPatternLineEdit->text() ); @@ -165,62 +234,39 @@ namespace Hurricane { } - bool SelectionWidget::isCumulative () const - { - return _cumulative->isChecked(); - } - - void SelectionWidget::toggleSelection ( const QModelIndex& index ) { Occurrence occurrence = _baseModel->toggleSelection ( index ); if ( occurrence.isValid() ) { - _isEmitter = true; - emit selectionToggled ( occurrence ); + _updateState = InternalEmit; + _cellWidget->toggleSelection ( occurrence ); } } void SelectionWidget::toggleSelection ( Occurrence occurrence ) { - if ( !_isEmitter ) { + if ( _updateState != InternalEmit ) { + blockAllSignals ( true ); _baseModel->toggleSelection ( occurrence ); - _isEmitter = false; + blockAllSignals ( false ); } + _updateState = ExternalEmit; } - void SelectionWidget::setShowSelection ( bool state ) - { - static bool isEmitter = false; - - if ( sender() == _showSelection ) { - isEmitter = true; - emit showSelectionToggled ( state ); - } else { - if ( !isEmitter ) { - _showSelection->blockSignals ( true ); - _showSelection->setChecked ( state ); - _showSelection->blockSignals ( false ); - } else - isEmitter = false; - } - } - - - void SelectionWidget::setSelection ( const SelectorSet& selection, Cell* cell ) + void SelectionWidget::setSelection ( const SelectorSet& selection ) { _baseModel->setSelection ( selection ); string windowTitle = "Selection"; + Cell* cell = (_cellWidget) ? _cellWidget->getCell() : NULL; if ( cell ) windowTitle += getString(cell); else windowTitle += ""; setWindowTitle ( tr(windowTitle.c_str()) ); _view->selectRow ( 0 ); _view->resizeColumnToContents ( 0 ); - - //if ( !_cumulative->isChecked() ) emit inspect ( NULL ); } @@ -228,6 +274,8 @@ namespace Hurricane { { _baseModel->clear (); _view->selectionModel()->clearSelection (); + if ( _cellWidget ) + _cellWidget->unselectAll(); } diff --git a/hurricane/src/hviewer/hurricane/viewer/CellViewer.h b/hurricane/src/hviewer/hurricane/viewer/CellViewer.h index a9da8993..f50ab6a6 100644 --- a/hurricane/src/hviewer/hurricane/viewer/CellViewer.h +++ b/hurricane/src/hviewer/hurricane/viewer/CellViewer.h @@ -79,6 +79,7 @@ namespace Hurricane { void unselect ( Occurrence& ); void unselectAll (); public slots: + void changeSelectionMode (); void setShowSelection ( bool ); void setState ( shared_ptr& ); void showController (); @@ -121,6 +122,7 @@ namespace Hurricane { list< shared_ptr > _cellHistory; bool _firstShow; + UpdateState _updateState; protected: void createActions (); diff --git a/hurricane/src/hviewer/hurricane/viewer/CellWidget.h b/hurricane/src/hviewer/hurricane/viewer/CellWidget.h index eae3dfa0..d734d751 100644 --- a/hurricane/src/hviewer/hurricane/viewer/CellWidget.h +++ b/hurricane/src/hviewer/hurricane/viewer/CellWidget.h @@ -85,6 +85,11 @@ namespace Hurricane { class Command; //class MapView; + enum UpdateState { ExternalEmit = 0 + , InternalEmit + , InternalReceive + }; + class CellWidget : public QWidget { Q_OBJECT; @@ -201,14 +206,13 @@ namespace Hurricane { void cellPreModificated (); void cellPostModificated (); void stateChanged ( shared_ptr& ); - void styleChanged ( void* emitter ); + void styleChanged (); void queryFilterChanged (); void updatePalette ( Cell* ); void mousePositionChanged ( const Point& position ); - void selectionChanged ( const SelectorSet&, Cell* ); + void selectionModeChanged (); + void selectionChanged ( const SelectorSet& ); void selectionToggled ( Occurrence ); - void showSelectionToggled ( bool ); - void cumulativeSelectionToggled ( bool ); void showBoundariesToggled ( bool ); public slots: // Qt QWidget Slots Overload & CellWidget Specifics. @@ -233,7 +237,7 @@ namespace Hurricane { void _unselectAll (); void changeQueryFilter (); void rubberChange (); - void styleChange ( void* emitter ); + void setStyle ( int id ); void updatePalette (); void cellPreModificate (); void cellPostModificate (); diff --git a/hurricane/src/hviewer/hurricane/viewer/DisplayFilterWidget.h b/hurricane/src/hviewer/hurricane/viewer/DisplayFilterWidget.h index 9895a95f..20d38138 100644 --- a/hurricane/src/hviewer/hurricane/viewer/DisplayFilterWidget.h +++ b/hurricane/src/hviewer/hurricane/viewer/DisplayFilterWidget.h @@ -33,13 +33,12 @@ class QSpinBox; class QCheckBox; class QRadioButton; +#include "hurricane/viewer/CellWidget.h" + namespace Hurricane { - class CellWidget; - - class DisplayFilterWidget : public QWidget { Q_OBJECT; @@ -61,12 +60,6 @@ namespace Hurricane { protected: void blockAllSignals ( bool state ); - protected: - enum UpdateState { External = 0 - , InternalEmit - , InternalReceive - }; - protected: CellWidget* _cellWidget; QSpinBox* _startSpinBox; diff --git a/hurricane/src/hviewer/hurricane/viewer/GraphicsWidget.h b/hurricane/src/hviewer/hurricane/viewer/GraphicsWidget.h index 68b6588f..1363a161 100644 --- a/hurricane/src/hviewer/hurricane/viewer/GraphicsWidget.h +++ b/hurricane/src/hviewer/hurricane/viewer/GraphicsWidget.h @@ -29,6 +29,8 @@ #include +#include "hurricane/viewer/CellWidget.h" + namespace Hurricane { @@ -38,10 +40,14 @@ namespace Hurricane { public: GraphicsWidget ( QWidget* parent=NULL ); - signals: - void styleChanged ( void* emitter ); + void setCellWidget ( CellWidget* ); public slots: - void styleChange ( int id ); + void changeStyle (); + void setStyle ( int id ); + + protected: + CellWidget* _cellWidget; + UpdateState _updateState; }; diff --git a/hurricane/src/hviewer/hurricane/viewer/NetlistWidget.h b/hurricane/src/hviewer/hurricane/viewer/NetlistWidget.h index 2d8edd6e..3b30a238 100644 --- a/hurricane/src/hviewer/hurricane/viewer/NetlistWidget.h +++ b/hurricane/src/hviewer/hurricane/viewer/NetlistWidget.h @@ -37,6 +37,7 @@ #include "hurricane/Bug.h" #include "hurricane/viewer/CellWidget.h" #include "hurricane/viewer/NetlistModel.h" +#include "hurricane/viewer/CellWidget.h" class QSortFilterProxyModel; @@ -55,6 +56,10 @@ namespace Hurricane { class Cell; +// ------------------------------------------------------------------- +// Class : "SelectedNet". + + class SelectedNet { public: inline SelectedNet (); @@ -88,6 +93,10 @@ namespace Hurricane { } +// ------------------------------------------------------------------- +// Class : "SelectedNetSet". + + class SelectedNetSet : public set{ public: void insert ( const Net* ); @@ -112,18 +121,22 @@ namespace Hurricane { } +// ------------------------------------------------------------------- +// Class : "NetlistWidget". + + class NetlistWidget : public QWidget { Q_OBJECT; public: NetlistWidget ( QWidget* parent=NULL ); inline Cell* getCell (); + template + void setCellWidget ( CellWidget* ); template void setCell ( Cell* ); void goTo ( int ); signals: - void refreshSessionOpened (); - void refreshSessionClosed (); void netSelected ( const Net* ); void netUnselected ( const Net* ); void netFitted ( const Net* ); @@ -135,6 +148,7 @@ namespace Hurricane { void fitToNet (); private: + CellWidget* _cellWidget; Cell* _cell; NetlistModel* _baseModel; QSortFilterProxyModel* _sortModel; @@ -145,6 +159,22 @@ namespace Hurricane { }; + template + void NetlistWidget::setCellWidget ( CellWidget* cw ) + { + if ( _cellWidget ) { + disconnect ( this, 0, _cellWidget, 0 ); + } + + _cellWidget = cw; + if ( _cellWidget ) { + setCell ( _cellWidget->getCell() ); + connect ( this, SIGNAL(netFitted(const Net*)), _cellWidget, SLOT(fitToNet (const Net*)) ); + } else + setCell ( NULL ); + } + + template void NetlistWidget::setCell ( Cell* cell ) { diff --git a/hurricane/src/hviewer/hurricane/viewer/PaletteItem.h b/hurricane/src/hviewer/hurricane/viewer/PaletteItem.h index bfbc28b7..8651a551 100644 --- a/hurricane/src/hviewer/hurricane/viewer/PaletteItem.h +++ b/hurricane/src/hviewer/hurricane/viewer/PaletteItem.h @@ -55,7 +55,7 @@ namespace Hurricane { protected: QPixmap _sample; PaletteItem* _entry; - protected slots: + public slots: void redraw (); void paintEvent ( QPaintEvent* ); }; @@ -75,9 +75,8 @@ namespace Hurricane { virtual void setItemVisible ( bool ) = 0; virtual void setItemSelectable ( bool ); public slots: - virtual void styleChange (); + virtual void changeStyle (); signals: - void styleChanged (); void visibleToggled (); void selectableToggled (); protected: diff --git a/hurricane/src/hviewer/hurricane/viewer/PaletteLayerItem.h b/hurricane/src/hviewer/hurricane/viewer/PaletteLayerItem.h index 540c0ecb..ed1fc363 100644 --- a/hurricane/src/hviewer/hurricane/viewer/PaletteLayerItem.h +++ b/hurricane/src/hviewer/hurricane/viewer/PaletteLayerItem.h @@ -42,22 +42,25 @@ namespace Hurricane { Q_OBJECT; public: - static PaletteLayerItem* create ( BasicLayer*, bool visible=true ); - virtual const Name& getName () const; - virtual bool isItemVisible () const; - virtual bool isItemSelectable () const; - virtual void setItemVisible ( bool state ); - virtual void setItemSelectable ( bool state ); + static PaletteLayerItem* create ( BasicLayer*, bool visible=true ); + virtual const Name& getName () const; + virtual bool isItemVisible () const; + virtual bool isItemSelectable () const; + virtual void setItemVisible ( bool state ); + virtual void setItemSelectable ( bool state ); + public slots: + virtual void changeStyle (); protected: - BasicLayer* _basicLayer; - QCheckBox* _visible; - QCheckBox* _selectable; + BasicLayer* _basicLayer; + QCheckBox* _visible; + QCheckBox* _selectable; + DrawingStyleSample* _sample; protected: - PaletteLayerItem ( BasicLayer*, bool visible ); - PaletteLayerItem ( const PaletteLayerItem& ); - PaletteLayerItem& operator= ( const PaletteLayerItem& ); + PaletteLayerItem ( BasicLayer*, bool visible ); + PaletteLayerItem ( const PaletteLayerItem& ); + PaletteLayerItem& operator= ( const PaletteLayerItem& ); }; diff --git a/hurricane/src/hviewer/hurricane/viewer/PaletteWidget.h b/hurricane/src/hviewer/hurricane/viewer/PaletteWidget.h index fc2d12df..f70a3afc 100644 --- a/hurricane/src/hviewer/hurricane/viewer/PaletteWidget.h +++ b/hurricane/src/hviewer/hurricane/viewer/PaletteWidget.h @@ -68,7 +68,7 @@ namespace Hurricane { void updateExtensions ( Cell* cell ); void showAll (); void hideAll (); - void styleChange ( void* emitter ); + void changeStyle (); protected: PaletteItems _layerItems; diff --git a/hurricane/src/hviewer/hurricane/viewer/SelectCommand.h b/hurricane/src/hviewer/hurricane/viewer/SelectCommand.h index 21740a12..53968e5a 100644 --- a/hurricane/src/hviewer/hurricane/viewer/SelectCommand.h +++ b/hurricane/src/hviewer/hurricane/viewer/SelectCommand.h @@ -60,7 +60,6 @@ namespace Hurricane { signals: void selectionToggled ( Occurrence occurrence ); private: - QAction* _selectAction; SelectionPopup* _selectionPopup; private: SelectCommand ( const SelectCommand& ); diff --git a/hurricane/src/hviewer/hurricane/viewer/SelectionWidget.h b/hurricane/src/hviewer/hurricane/viewer/SelectionWidget.h index cd1712ec..096f81af 100644 --- a/hurricane/src/hviewer/hurricane/viewer/SelectionWidget.h +++ b/hurricane/src/hviewer/hurricane/viewer/SelectionWidget.h @@ -34,8 +34,10 @@ #include "hurricane/Commons.h" #include "hurricane/Occurrence.h" #include "hurricane/viewer/SelectionModel.h" +#include "hurricane/viewer/CellWidget.h" +class QCloseEvent; class QSortFilterProxyModel; class QModelIndex; class QTableView; @@ -49,38 +51,39 @@ namespace Hurricane { class Selector; - class QCloseEvent; class SelectionWidget : public QWidget { Q_OBJECT; public: - SelectionWidget ( QWidget* parent=NULL ); - void inspect ( const QModelIndex& index ); - bool isCumulative () const; - signals: - void showSelectionToggled ( bool ); - void selectionToggled ( Occurrence ); - void cumulativeToggled ( bool ); - void selectionCleared (); - void inspect ( Record* ); - void inspect ( Occurrence& ); - public slots: - void clear (); - void setShowSelection ( bool ); - void selectCurrent ( const QModelIndex& current, const QModelIndex& ); - void setSelection ( const SelectorSet& selection, Cell* cell=NULL ); - void toggleSelection ( Occurrence occurrence ); - void toggleSelection ( const QModelIndex& index ); - void forceRowHeight (); - private slots: - void textFilterChanged (); - protected: - virtual bool eventFilter ( QObject*, QEvent* ); - virtual void hideEvent ( QHideEvent* event ); + SelectionWidget ( QWidget* parent=NULL ); + void inspect ( const QModelIndex& index ); + bool cumulativeSelection () const; + signals: + void selectionModeChanged (); + void selectionToggled ( Occurrence ); + void inspect ( Record* ); + void inspect ( Occurrence& ); + public slots: + void setCellWidget ( CellWidget* ); + void clear (); + void changeSelectionMode (); + void setShowSelection ( bool ); + void setCumulativeSelection ( bool ); + void selectCurrent ( const QModelIndex& current, const QModelIndex& ); + void setSelection ( const SelectorSet& selection ); + void toggleSelection ( Occurrence ); + void toggleSelection ( const QModelIndex& ); + void forceRowHeight (); + private slots: + void textFilterChanged (); + protected: + void blockAllSignals ( bool ); + virtual bool eventFilter ( QObject*, QEvent* ); private: + CellWidget* _cellWidget; SelectionModel* _baseModel; QSortFilterProxyModel* _sortModel; QTableView* _view; @@ -88,7 +91,7 @@ namespace Hurricane { QCheckBox* _cumulative; QCheckBox* _showSelection; int _rowHeight; - bool _isEmitter; + UpdateState _updateState; };