diff --git a/hurricane/src/hurricane/Query.cpp b/hurricane/src/hurricane/Query.cpp index c91dc472..bb5b2668 100644 --- a/hurricane/src/hurricane/Query.cpp +++ b/hurricane/src/hurricane/Query.cpp @@ -79,7 +79,7 @@ namespace Hurricane { , const Transformation& transformation , const BasicLayer* basicLayer , ExtensionSlice::Mask mask - , unsigned int filter + , Mask filter ) { _basicLayer = basicLayer; @@ -102,13 +102,13 @@ namespace Hurricane { while ( !_stack.empty() ) { // Process the Components of the current instance. - if ( hasGoCallback() && _basicLayer && (_filter & DoComponents) ) { + if ( hasGoCallback() && _basicLayer && (_filter.isSet(DoComponents)) ) { //if ( getInstance() ) // cerr << getTab() << getInstance() << " " << getTransformation() << endl; //else // cerr << " TopCell: " << getMasterCell() << " " << getTransformation() << endl; - if ( !getMasterCell()->isTerminal() || (_filter & DoTerminalCells) ) { + if ( !getMasterCell()->isTerminal() || (_filter.isSet(DoTerminalCells)) ) { forEach ( Slice*, islice, getMasterCell()->getSlices() ) { if ( !(*islice)->getLayer()->contains(getBasicLayer()) ) continue; if ( !(*islice)->getBoundingBox().intersect(getArea()) ) continue; @@ -119,13 +119,13 @@ namespace Hurricane { } } - if ( !getMasterCell()->isTerminal() && (_filter & DoRubbers) ) { + if ( !getMasterCell()->isTerminal() && (_filter.isSet(DoRubbers)) ) { forEach ( Rubber*, rubber, getMasterCell()->getRubbersUnder(_stack.getArea()) ) rubberCallback ( *rubber ); } - if ( hasExtensionGoCallback() && (_filter & DoExtensionGos) ) { - if ( !getMasterCell()->isTerminal() || (_filter & DoTerminalCells) ) { + if ( hasExtensionGoCallback() && (_filter.isSet(DoExtensionGos)) ) { + if ( !getMasterCell()->isTerminal() || (_filter.isSet(DoTerminalCells)) ) { forEach ( ExtensionSlice*, islice, getMasterCell()->getExtensionSlices() ) { if ( !( (*islice)->getMask() & _extensionMask ) ) continue; if ( !(*islice)->getBoundingBox().intersect(getArea()) ) continue; @@ -136,7 +136,7 @@ namespace Hurricane { } } - if ( (_filter & DoMasterCells) && hasMasterCellCallback() ) + if ( (_filter.isSet(DoMasterCells)) && hasMasterCellCallback() ) masterCellCallback (); _stack.progress (); diff --git a/hurricane/src/hurricane/hurricane/Mask.h b/hurricane/src/hurricane/hurricane/Mask.h index 72a3881a..6a960125 100644 --- a/hurricane/src/hurricane/hurricane/Mask.h +++ b/hurricane/src/hurricane/hurricane/Mask.h @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved // // =================================================================== // @@ -41,6 +41,7 @@ namespace Hurricane { inline bool zero () const; inline Mask& set ( const Mask mask ); inline Mask& unset ( const Mask mask ); + inline bool isSet ( const Mask mask ) const; inline bool contains ( const Mask mask ) const; inline bool intersect ( const Mask mask ) const; inline Mask& merge ( const Mask mask ) const; @@ -85,6 +86,10 @@ namespace Hurricane { inline Mask& Mask::unset ( const Mask mask ) { _mask &= ~mask._mask; return *this; } + template + inline bool Mask::isSet ( const Mask mask ) const + { return _mask & mask._mask; } + template inline bool Mask::contains ( const Mask mask ) const { return (_mask & mask._mask) && !(~_mask & mask._mask); } diff --git a/hurricane/src/hurricane/hurricane/Query.h b/hurricane/src/hurricane/hurricane/Query.h index 9e24ede6..4b6d7acd 100644 --- a/hurricane/src/hurricane/hurricane/Query.h +++ b/hurricane/src/hurricane/hurricane/Query.h @@ -1,36 +1,9 @@ // -*- C++ -*- // -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved // -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag // =================================================================== // // $Id$ @@ -303,6 +276,8 @@ namespace Hurricane { class Query { + public: + typedef Hurricane::Mask Mask; public: // Types. enum QueryFilter { DoMasterCells = 1 @@ -344,14 +319,14 @@ namespace Hurricane { , const Transformation& transformation , const BasicLayer* basicLayer , ExtensionSlice::Mask extensionMask - , unsigned int filter + , Mask filter ); inline void setCell ( Cell* cell ); inline void setArea ( const Box& area ); inline void setTransformation ( const Transformation& transformation ); inline void setBasicLayer ( const BasicLayer* basicLayer ); inline void setExtensionMask ( ExtensionSlice::Mask mode ); - inline void setFilter ( unsigned int mode ); + inline void setFilter ( Mask mode ); inline void setStartLevel ( unsigned int level ); inline void setStopLevel ( unsigned int level ); void doQuery (); @@ -361,7 +336,7 @@ namespace Hurricane { QueryStack _stack; const BasicLayer* _basicLayer; ExtensionSlice::Mask _extensionMask; - unsigned int _filter; + Mask _filter; }; @@ -371,7 +346,7 @@ namespace Hurricane { inline void Query::setArea ( const Box& area ) { _stack.setTopArea(area); } inline void Query::setTransformation ( const Transformation& transformation ) { _stack.setTopTransformation(transformation); } inline void Query::setBasicLayer ( const BasicLayer* basicLayer ) { _basicLayer = basicLayer; } - inline void Query::setFilter ( unsigned int filter ) { _filter = filter; } + inline void Query::setFilter ( Mask filter ) { _filter = filter; } inline void Query::setExtensionMask ( ExtensionSlice::Mask mask ) { _extensionMask = mask; } inline void Query::setStartLevel ( unsigned int level ) { _stack.setStartLevel(level); } inline void Query::setStopLevel ( unsigned int level ) { _stack.setStopLevel(level); } diff --git a/hurricane/src/hviewer/AreaCommand.cpp b/hurricane/src/hviewer/AreaCommand.cpp index 723565bc..5cbed54c 100644 --- a/hurricane/src/hviewer/AreaCommand.cpp +++ b/hurricane/src/hviewer/AreaCommand.cpp @@ -1,36 +1,9 @@ // -*- C++ -*- // -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved // -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag // =================================================================== // // $Id$ @@ -69,6 +42,7 @@ namespace Hurricane { : Command() , _startPoint() , _stopPoint() + , _drawingThreshold(10) , _drawingEnabled(false) { } @@ -93,10 +67,13 @@ namespace Hurricane { { if ( !_drawingEnabled ) return; - widget->setPen ( Graphics::getPen("grid"), 2 ); - widget->drawScreenRect ( _startPoint, _stopPoint, 2 ); - drawCorner ( widget, true ); - drawCorner ( widget, false ); + if ( ( abs(_stopPoint.x()-_startPoint.x()) > _drawingThreshold ) + && ( abs(_stopPoint.y()-_startPoint.y()) > _drawingThreshold ) ) { + widget->setPen ( Graphics::getPen("grid"), 2 ); + widget->drawScreenRect ( _startPoint, _stopPoint, 2 ); + drawCorner ( widget, true ); + drawCorner ( widget, false ); + } } diff --git a/hurricane/src/hviewer/CellWidget.cpp b/hurricane/src/hviewer/CellWidget.cpp index c763ec2e..ab7a1c4e 100644 --- a/hurricane/src/hviewer/CellWidget.cpp +++ b/hurricane/src/hviewer/CellWidget.cpp @@ -196,10 +196,11 @@ namespace Hurricane { CellWidget::RedrawManager::RedrawManager ( CellWidget* widget ) - : _widget (widget) - , _events () - , _processing (false) - , _interrupted(false) + : _widget (widget) + , _events () + , _refreshSession(0) + , _processing (false) + , _interrupted (false) { } @@ -283,14 +284,25 @@ namespace Hurricane { if ( !_processing ) process (); } #else - _events.push_back ( new RedrawEvent(RedrawEvent::Refresh,0,_widget) ); + bool addRefresh = true; + if ( _refreshSession ) { + list::iterator ievent = _events.begin(); + for ( ; ievent != _events.end() ; ievent++ ) { + if ( (_events.back()->getType() == RedrawEvent::Refresh) ) { + addRefresh = false; + break; + } + } + } + if ( addRefresh ) + _events.push_back ( new RedrawEvent(RedrawEvent::Refresh,0,_widget) ); - if ( !_processing ) process (); + if ( !_processing && (_refreshSession == 0) ) process (); #endif } - inline void CellWidget::RedrawManager::process () + void CellWidget::RedrawManager::process () { _processing = true; @@ -780,12 +792,12 @@ namespace Hurricane { } - bool CellWidget::SelectorCriterions::add ( const Net* net, bool delayRedraw ) + bool CellWidget::SelectorCriterions::add ( const Net* net ) { if ( !_cellWidget ) return false; if ( !_cellWidget->isSelected(Occurrence(net)) ) { _criterions.push_back ( new NetSelectorCriterion(net) ); - _criterions.back()->doSelection ( _cellWidget, delayRedraw ); + _criterions.back()->doSelection ( _cellWidget ); return true; } return false; @@ -796,12 +808,12 @@ namespace Hurricane { { if ( !_cellWidget ) return false; _criterions.push_back ( new AreaSelectorCriterion(area) ); - _criterions.back()->doSelection ( _cellWidget, true ); + _criterions.back()->doSelection ( _cellWidget ); return true; } - bool CellWidget::SelectorCriterions::remove ( const Net* net, bool delayRedraw ) + bool CellWidget::SelectorCriterions::remove ( const Net* net ) { if ( !_cellWidget ) return false; if ( !_cellWidget->isSelected(Occurrence(net)) ) return false; @@ -812,7 +824,7 @@ namespace Hurricane { if ( i < _criterions.size() ) { swap ( _criterions[i], *(_criterions.end()-1) ); - _criterions.back()->undoSelection ( _cellWidget, delayRedraw ); + _criterions.back()->undoSelection ( _cellWidget ); _criterions.pop_back (); } else return false; @@ -838,7 +850,7 @@ namespace Hurricane { size_t last = _criterions.size (); while ( i < last ) { if ( _criterions[i]->isValid(_cellWidget) ) { - _criterions[i]->doSelection ( _cellWidget, true ); + _criterions[i]->doSelection ( _cellWidget ); ++i; } else swap ( _criterions[i], _criterions[--last] ); @@ -912,7 +924,6 @@ namespace Hurricane { , _drawingPlanes (QSize(_initialSide+2*_stripWidth,_initialSide+2*_stripWidth),this) , _drawingQuery (this) , _textDrawingQuery (this) - , _queryFilter (~Query::DoTerminalCells) , _darkening (100) , _mousePosition (0,0) , _spot (this) @@ -926,7 +937,6 @@ namespace Hurricane { , _commands () , _redrawRectCount (0) , _textFontHeight (20) - , _rubberShape (Steiner) { //setBackgroundRole ( QPalette::Dark ); //setAutoFillBackground ( false ); @@ -1046,7 +1056,6 @@ namespace Hurricane { case Barycentric: setRubberShape(Steiner ); break; case Steiner: setRubberShape(Centric ); break; } - emit settingsChanged(); } @@ -1082,11 +1091,18 @@ namespace Hurricane { } + void CellWidget::changeQueryFilter () + { + _redrawManager.refresh (); + emit queryFilterChanged (); + } + + void CellWidget::_redraw ( QRect redrawArea ) { // cerr << "CellWidget::redraw() - start " // << _selectionHasChanged << " filter:" -// << _queryFilter << endl; +// << _state->getQueryFilter() << endl; // static bool timedout; // static Timer timer; @@ -1130,7 +1146,7 @@ namespace Hurricane { if ( isDrawable((*iLayer)->getName()) ) { _drawingQuery.setBasicLayer ( *iLayer ); - _drawingQuery.setFilter ( _queryFilter & ~(Query::DoMasterCells|Query::DoRubbers) ); + _drawingQuery.setFilter ( getQueryFilter().unset(Query::DoMasterCells|Query::DoRubbers) ); _drawingQuery.doQuery (); } if ( _enableRedrawInterrupt ) QApplication::processEvents(); @@ -1147,7 +1163,7 @@ namespace Hurricane { _drawingPlanes.setBrush ( Graphics::getBrush("boundaries",getDarkening()) ); _drawingQuery.setBasicLayer ( NULL ); - _drawingQuery.setFilter ( _queryFilter & ~(Query::DoComponents|Query::DoRubbers) ); + _drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents|Query::DoRubbers) ); _drawingQuery.doQuery (); } } @@ -1158,7 +1174,7 @@ namespace Hurricane { _drawingPlanes.setBrush ( Graphics::getBrush("rubber",getDarkening()) ); _drawingQuery.setBasicLayer ( NULL ); - _drawingQuery.setFilter ( _queryFilter & ~(Query::DoComponents|Query::DoMasterCells) ); + _drawingQuery.setFilter ( getQueryFilter().unset(Query::DoComponents|Query::DoMasterCells) ); _drawingQuery.doQuery (); } } @@ -1175,7 +1191,7 @@ namespace Hurricane { } } - //_drawingQuery.setFilter ( _queryFilter & ~Query::DoMasterCells ); + //_drawingQuery.setFilter ( getQueryFilter() & ~Query::DoMasterCells ); forEach ( ExtensionSlice*, islice, getCell()->getExtensionSlices() ) { if ( _enableRedrawInterrupt ) QApplication::processEvents(); if ( /*timeout("redraw [extension]",timer,10.0,timedout) ||*/ (_redrawManager.interrupted()) ) break; @@ -1517,7 +1533,7 @@ namespace Hurricane { } - void CellWidget::displayReframe ( bool delayed ) + void CellWidget::displayReframe () { _offsetVA.rx() = _stripWidth; _offsetVA.ry() = _stripWidth; @@ -1529,7 +1545,7 @@ namespace Hurricane { _displayArea = Box ( xmin, ymin, xmax, ymax ); - if ( !delayed ) _redrawManager.refresh (); + _redrawManager.refresh (); } @@ -1612,41 +1628,42 @@ namespace Hurricane { } - void CellWidget::reframe ( bool delayed ) + void CellWidget::reframe () { //cerr << "CellWidget::reframe() - scale:" << _state->getScale() // << " topLeft:" << _state->getTopLeft() << endl; _visibleArea = computeVisibleArea ( _state->getScale(), _state->getTopLeft() ); - displayReframe ( delayed ); + displayReframe (); } - void CellWidget::reframe ( const Box& box, bool delayed ) + void CellWidget::reframe ( const Box& box, bool historyEnable ) { //cerr << "CellWidget::reframe() - " << box << endl; //cerr << " widget size := " << _drawingPlanes.width() << "x" << _drawingPlanes.height() << endl; //cerr << " CellWidget::reframe() - widget size := " << width() << "x" << height() << endl; - float scale; + bool backupHistoryEnable = _state->getHistoryEnable (); + _state->setHistoryEnable ( historyEnable ); + _state->setTopLeft ( getTopLeft() ); - _state->setTopLeft ( getTopLeft() ); + float scale; _visibleArea = computeVisibleArea ( box, scale ); _state->setScale ( scale ); - displayReframe ( delayed ); + displayReframe (); + + _state->setHistoryEnable ( backupHistoryEnable ); //cerr << " _displayArea: " << _displayArea << " (offset: " << _offsetVA.x() << ")" << endl; } - void CellWidget::fitToContents ( bool delayed, bool historyEnable ) + void CellWidget::fitToContents ( bool historyEnable ) { //cerr << "CellWidget::fitToContents()" << endl; - bool backupHistoryEnable = _state->getHistoryEnable (); - _state->setHistoryEnable ( historyEnable ); - Box boundingBox = Box ( DbU::lambda(0) , DbU::lambda(0) , DbU::lambda(10) @@ -1654,9 +1671,26 @@ namespace Hurricane { ); if ( getCell() ) boundingBox = getCell()->getBoundingBox(); - reframe ( boundingBox, delayed ); + reframe ( boundingBox, historyEnable ); + } - _state->setHistoryEnable ( backupHistoryEnable ); + + void CellWidget::fitToNet ( const Net* net, bool historyEnable ) + { + if ( !net ) + throw Error ( "CellWidget::fitToNet(): NULL net argument." ); + + if ( net->getCell() != getCell() ) + throw Error ( "CellWidget::fitToNet():
" + "Net %s (cell: %s) do not belong to Cell %s" + , Graphics::toHtml(getString(net->getName())).c_str() + , Graphics::toHtml(getString(net->getCell()->getName())).c_str() + , Graphics::toHtml(getString(getCell()->getName())).c_str() + ); + + Box boundingBox = net->getBoundingBox (); + if ( !boundingBox.isEmpty() ) + reframe ( boundingBox, historyEnable ); } @@ -1782,7 +1816,7 @@ namespace Hurricane { { //cerr << "CellWidget::showEvent() - size: " << geometry().width() << "x" << geometry().height() << endl; if ( _cellChanged ) - fitToContents ( false, false ); + fitToContents ( false ); } @@ -1963,12 +1997,16 @@ namespace Hurricane { if ( cell == getCell() ) return; + openRefreshSession (); + shared_ptr state ( new State(cell) ); setState ( state ); - fitToContents ( false, false ); + fitToContents ( false ); _state->setHistoryEnable ( true ); + + closeRefreshSession (); } @@ -1978,6 +2016,8 @@ namespace Hurricane { if ( state == _state ) return; + openRefreshSession (); + cellPreModificate (); _state->getSelection ().clear (); _state->setCellWidget ( NULL ); @@ -1994,16 +2034,21 @@ namespace Hurricane { _state->setHistoryEnable ( false ); _state->setCellWidget ( this ); - _drawingQuery .setCell ( getCell() ); - _textDrawingQuery.setCell ( getCell() ); + _drawingQuery .setCell ( getCell() ); + _drawingQuery .setStartLevel ( _state->getStartLevel() ); + _drawingQuery .setStopLevel ( _state->getStopLevel() ); + _textDrawingQuery.setCell ( getCell() ); - reframe ( true ); + reframe (); _state->setHistoryEnable ( true ); - emit cellChanged ( getCell() ); - emit stateChanged ( _state ); + emit cellChanged ( getCell() ); + emit stateChanged ( _state ); + emit queryFilterChanged (); cellPostModificate (); + + closeRefreshSession (); } @@ -2013,12 +2058,16 @@ namespace Hurricane { } - void CellWidget::select ( const Net* net, bool delayRedraw ) + void CellWidget::select ( const Net* net ) { ++_delaySelectionChanged; - if ( !_state->cumulativeSelection() ) unselectAll ( true ); - bool added = _state->getSelection().add ( net, delayRedraw ); + if ( !_state->cumulativeSelection() ) { + openRefreshSession (); + unselectAll (); + closeRefreshSession (); + } + bool added = _state->getSelection().add ( net ); if ( !--_delaySelectionChanged && added ) emit selectionChanged(_selectors,getCell()); } @@ -2083,18 +2132,22 @@ namespace Hurricane { { ++_delaySelectionChanged; - if ( !_state->cumulativeSelection() ) unselectAll ( true ); + if ( !_state->cumulativeSelection() ) { + openRefreshSession (); + unselectAll (); + closeRefreshSession (); + } bool added = _state->getSelection().add ( selectArea ); if ( !--_delaySelectionChanged && added ) emit selectionChanged(_selectors,getCell()); } - void CellWidget::unselect ( const Net* net, bool delayRedraw ) + void CellWidget::unselect ( const Net* net ) { ++_delaySelectionChanged; - bool removed = _state->getSelection().remove ( net, delayRedraw ); + bool removed = _state->getSelection().remove ( net ); if ( !--_delaySelectionChanged && removed ) emit selectionChanged(_selectors,getCell()); } @@ -2121,12 +2174,12 @@ namespace Hurricane { } - void CellWidget::unselectAll ( bool delayRedraw ) + void CellWidget::unselectAll () { ++_delaySelectionChanged; _state->getSelection().clear (); - _unselectAll ( delayRedraw ); + _unselectAll (); if ( !--_delaySelectionChanged ) emit selectionChanged(_selectors,getCell()); } @@ -2159,7 +2212,7 @@ namespace Hurricane { } - void CellWidget::_select ( const Net* net, bool delayRedraw ) + void CellWidget::_select ( const Net* net ) { select ( Occurrence(net) ); forEach ( Component*, component, net->getComponents() ) { @@ -2170,11 +2223,11 @@ namespace Hurricane { Occurrence occurrence ( *rubber ); select ( occurrence ); } - if ( !delayRedraw && _state->showSelection() ) _redrawManager.refresh (); + if ( _state->showSelection() ) _redrawManager.refresh (); } - void CellWidget::_unselect ( const Net* net, bool delayRedraw ) + void CellWidget::_unselect ( const Net* net ) { unselect ( Occurrence(net) ); forEach ( Component*, component, net->getComponents() ) { @@ -2185,7 +2238,7 @@ namespace Hurricane { Occurrence occurrence ( *rubber ); unselect ( occurrence ); } - if ( !delayRedraw && _state->showSelection() ) _redrawManager.refresh (); + if ( _state->showSelection() ) _redrawManager.refresh (); } @@ -2196,28 +2249,32 @@ namespace Hurricane { } - void CellWidget::_unselectAll ( bool delayRedraw ) + void CellWidget::_unselectAll () { SelectorSet::iterator iselector; while ( !_selectors.empty() ) (*_selectors.begin())->detachFrom ( this ); if ( !_selectionHasChanged ) _selectionHasChanged = true; - if ( !delayRedraw && _state->showSelection() ) _redrawManager.refresh (); + if ( _state->showSelection() ) _redrawManager.refresh (); } void CellWidget::cellPreModificate () { - _unselectAll ( true ); + openRefreshSession (); + _unselectAll (); emit selectionChanged(_selectors,getCell()); emit cellPreModificated (); + + closeRefreshSession (); } void CellWidget::cellPostModificate () { + openRefreshSession (); _cellModificated = true; ++_delaySelectionChanged; @@ -2229,6 +2286,8 @@ namespace Hurricane { --_delaySelectionChanged; emit selectionChanged(_selectors,getCell()); emit cellPostModificated (); + + closeRefreshSession (); } diff --git a/hurricane/src/hviewer/ControllerWidget.cpp b/hurricane/src/hviewer/ControllerWidget.cpp index 205e849c..bfe4f72e 100644 --- a/hurricane/src/hviewer/ControllerWidget.cpp +++ b/hurricane/src/hviewer/ControllerWidget.cpp @@ -221,8 +221,11 @@ namespace Hurricane { { if ( state && getCellWidget() && _syncNetlist->isChecked() ) { _cwCumulativeSelection = getCellWidget()->cumulativeSelection(); - if ( !_cwCumulativeSelection ) - getCellWidget()->unselectAll ( true ); + if ( !_cwCumulativeSelection ) { + getCellWidget()->openRefreshSession (); + getCellWidget()->unselectAll (); + getCellWidget()->closeRefreshSession (); + } getCellWidget()->setCumulativeSelection ( true ); getCellWidget()->setShowSelection ( true ); connect ( _netlistBrowser, SIGNAL(netSelected (const Net*)), getCellWidget(), SLOT(select (const Net*)) ); @@ -247,7 +250,13 @@ namespace Hurricane { if ( getCellWidget() != cellWidget ) { ControllerTab::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() ); } diff --git a/hurricane/src/hviewer/DisplayFilterWidget.cpp b/hurricane/src/hviewer/DisplayFilterWidget.cpp index 4d7a2872..d38512bf 100644 --- a/hurricane/src/hviewer/DisplayFilterWidget.cpp +++ b/hurricane/src/hviewer/DisplayFilterWidget.cpp @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved // // =================================================================== // @@ -55,8 +55,7 @@ namespace Hurricane { , _steiner (new QRadioButton()) , _centric (new QRadioButton()) , _barycentric (new QRadioButton()) - , _queryFilter (Query::DoAll) - , _signalEmitter (false) + , _updateState (External) { setAttribute ( Qt::WA_QuitOnClose, false ); setWindowTitle ( tr("Display Filter") ); @@ -152,55 +151,79 @@ namespace Hurricane { void DisplayFilterWidget::setCellWidget ( CellWidget* cw ) { if ( !cw ) { - if ( _cellWidget ) - disconnect ( _cellWidget, SLOT(refresh()) ); + if ( _cellWidget ) { + disconnect ( this , SIGNAL(queryFilterChanged()), _cellWidget, SLOT(changeQueryFilter()) ); + disconnect ( _cellWidget , SIGNAL(queryFilterChanged()), this , SLOT(changeQueryFilter()) ); + } _cellWidget = NULL; return; } _cellWidget = cw; - connect ( this , SIGNAL(filterChanged()) , _cellWidget, SLOT(refresh()) ); - connect ( _cellWidget , SIGNAL(settingsChanged()), this , SLOT(syncFromCellWidget()) ); - connect ( _steiner , SIGNAL(clicked()) , this , SLOT(setRubberSteiner()) ); - connect ( _centric , SIGNAL(clicked()) , this , SLOT(setRubberCentric()) ); - connect ( _barycentric, SIGNAL(clicked()) , this , SLOT(setRubberBarycentric()) ); + 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()) ); - _signalEmitter = false; - syncFromCellWidget (); + _updateState = External; + changeQueryFilter (); } - void DisplayFilterWidget::syncFromCellWidget () + void DisplayFilterWidget::changeQueryFilter() { - if ( !_cellWidget ) return; - if ( _signalEmitter ) { - _signalEmitter = false; - return; - } + if ( !_cellWidget ) return; - _doMasterCells ->setChecked ( _cellWidget->getQueryFilter() & Query::DoMasterCells ); - _doTerminalCells->setChecked ( _cellWidget->getQueryFilter() & Query::DoTerminalCells ); - _doComponents ->setChecked ( _cellWidget->getQueryFilter() & Query::DoComponents ); + if ( _updateState == InternalEmit ) { + _updateState = InternalReceive; + emit queryFilterChanged (); + } else { + if ( _updateState == External ) { + blockAllSignals ( true ); - switch ( _cellWidget->getRubberShape() ) { - case CellWidget::Steiner: _steiner->setChecked(true); break; - case CellWidget::Centric: _centric->setChecked(true); break; - case CellWidget::Barycentric: _barycentric->setChecked(true); break; + _startSpinBox->setValue ( _cellWidget->getStartLevel() ); + _stopSpinBox ->setValue ( _cellWidget->getStopLevel() ); + + _doMasterCells ->setChecked ( _cellWidget->getQueryFilter().isSet(Query::DoMasterCells ) ); + _doTerminalCells->setChecked ( _cellWidget->getQueryFilter().isSet(Query::DoTerminalCells) ); + _doComponents ->setChecked ( _cellWidget->getQueryFilter().isSet(Query::DoComponents ) ); + + switch ( _cellWidget->getRubberShape() ) { + case CellWidget::Steiner: _steiner->setChecked(true); break; + case CellWidget::Centric: _centric->setChecked(true); break; + case CellWidget::Barycentric: _barycentric->setChecked(true); break; + } + blockAllSignals ( false ); + } + _updateState = External; } - _signalEmitter = false; + } + + + void DisplayFilterWidget::blockAllSignals ( bool state ) + { + _startSpinBox ->blockSignals ( state ); + _stopSpinBox ->blockSignals ( state ); + _doMasterCells ->blockSignals ( state ); + _doTerminalCells->blockSignals ( state ); + _doComponents ->blockSignals ( state ); + _steiner ->blockSignals ( state ); + _centric ->blockSignals ( state ); + _barycentric ->blockSignals ( state ); } void DisplayFilterWidget::startLevelChanged ( int level ) { if ( _cellWidget ) { - _cellWidget->setStartLevel ( level ); if ( _stopSpinBox->value() < level ) { - _stopSpinBox->setValue ( level ); - return; + _stopSpinBox->blockSignals ( true ); + _stopSpinBox->setValue ( level ); + _stopSpinBox->blockSignals ( false ); } - _signalEmitter = true; - emit filterChanged(); + _updateState = InternalEmit; + _cellWidget->setStartLevel ( level ); } } @@ -208,59 +231,66 @@ namespace Hurricane { void DisplayFilterWidget::stopLevelChanged ( int level ) { if ( _cellWidget ) { - _cellWidget->setStopLevel ( level ); if ( _startSpinBox->value() > level ) { - _startSpinBox->setValue ( level ); - return; + _startSpinBox->blockSignals ( true ); + _startSpinBox->setValue ( level ); + _startSpinBox->blockSignals ( false ); } - _signalEmitter = true; - emit filterChanged(); + _updateState = InternalEmit; + _cellWidget->setStopLevel ( level ); } } void DisplayFilterWidget::setDoMasterCells ( int state ) { - if ( state != Qt::Unchecked ) _queryFilter |= Query::DoMasterCells; - else _queryFilter &= ~Query::DoMasterCells; + if ( _cellWidget ) { + _updateState = InternalEmit; + Query::Mask queryFilter = _cellWidget->getQueryFilter(); + + if ( state != Qt::Unchecked ) queryFilter.set ( Query::DoMasterCells ); + else queryFilter.unset ( Query::DoMasterCells ); - _cellWidget->setQueryFilter ( _queryFilter ); - - _signalEmitter = true; - emit filterChanged(); + _cellWidget->setQueryFilter ( queryFilter ); + } } void DisplayFilterWidget::setDoTerminalCells ( int state ) { - if ( state != Qt::Unchecked ) _queryFilter |= Query::DoTerminalCells; - else _queryFilter &= ~Query::DoTerminalCells; + if ( _cellWidget ) { + _updateState = InternalEmit; + Query::Mask queryFilter = _cellWidget->getQueryFilter(); + + if ( state != Qt::Unchecked ) queryFilter.set ( Query::DoTerminalCells ); + else queryFilter.unset ( Query::DoTerminalCells ); - _cellWidget->setQueryFilter ( _queryFilter ); - - _signalEmitter = true; - emit filterChanged(); + _cellWidget->setQueryFilter ( queryFilter ); + } } void DisplayFilterWidget::setDoComponents ( int state ) { - if ( state != Qt::Unchecked ) _queryFilter |= Query::DoComponents; - else _queryFilter &= ~Query::DoComponents; + if ( _cellWidget ) { + _updateState = InternalEmit; + Query::Mask queryFilter = _cellWidget->getQueryFilter(); + + if ( state != Qt::Unchecked ) queryFilter.set ( Query::DoComponents ); + else queryFilter.unset ( Query::DoComponents ); - _cellWidget->setQueryFilter ( _queryFilter ); - - _signalEmitter = true; - emit filterChanged(); + _cellWidget->setQueryFilter ( queryFilter ); + } } void DisplayFilterWidget::setRubberSteiner () { if ( _cellWidget ) { - if ( _cellWidget->getRubberShape() != CellWidget::Steiner ) + if ( _cellWidget->getRubberShape() != CellWidget::Steiner ) { + _updateState = InternalEmit; _cellWidget->setRubberShape ( CellWidget::Steiner ); - //emit filterChanged(); + } } } @@ -268,9 +298,10 @@ namespace Hurricane { void DisplayFilterWidget::setRubberCentric () { if ( _cellWidget ) { - if ( _cellWidget->getRubberShape() != CellWidget::Centric ) + if ( _cellWidget->getRubberShape() != CellWidget::Centric ) { + _updateState = InternalEmit; _cellWidget->setRubberShape ( CellWidget::Centric ); - //emit filterChanged(); + } } } @@ -278,9 +309,10 @@ namespace Hurricane { void DisplayFilterWidget::setRubberBarycentric () { if ( _cellWidget ) { - if ( _cellWidget->getRubberShape() != CellWidget::Barycentric ) + if ( _cellWidget->getRubberShape() != CellWidget::Barycentric ) { + _updateState = InternalEmit; _cellWidget->setRubberShape ( CellWidget::Barycentric ); - //emit filterChanged(); + } } } diff --git a/hurricane/src/hviewer/HierarchyCommand.cpp b/hurricane/src/hviewer/HierarchyCommand.cpp index 9709f610..2dede1f1 100644 --- a/hurricane/src/hviewer/HierarchyCommand.cpp +++ b/hurricane/src/hviewer/HierarchyCommand.cpp @@ -65,12 +65,12 @@ namespace Hurricane { Box pointBox ( widget->screenToDbuBox(QRect(position,QSize(1,1))) ); switch ( event->key() ) { - case Qt::Key_U: + case Qt::Key_Up: if ( ( _historyIndex > 0 ) && (shift || control) ) { widget->setState ( _history[--_historyIndex]._state ); } break; - case Qt::Key_D: + case Qt::Key_Down: { if ( control ) { if ( _history.empty() ) diff --git a/hurricane/src/hviewer/InspectorWidget.cpp b/hurricane/src/hviewer/InspectorWidget.cpp index 8970740e..743079ad 100644 --- a/hurricane/src/hviewer/InspectorWidget.cpp +++ b/hurricane/src/hviewer/InspectorWidget.cpp @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved // // =================================================================== // @@ -177,6 +177,7 @@ namespace Hurricane { _view->setAlternatingRowColors(true); _view->setSelectionBehavior(QAbstractItemView::SelectRows); _view->setSortingEnabled(true); + _view->installEventFilter(this); QHeaderView* horizontalHeader = _view->horizontalHeader (); horizontalHeader->setStretchLastSection ( true ); @@ -302,23 +303,27 @@ namespace Hurricane { } - void InspectorWidget::keyPressEvent ( QKeyEvent *event ) + bool InspectorWidget::eventFilter ( QObject* object, QEvent* event ) { - if ( event->key() == Qt::Key_Right ) { - QModelIndex index = _view->currentIndex(); - if ( index.isValid() ) { - Slot* slot = _baseModel->getRecord()->getSlot(_sortModel->mapToSource(index).row()); + if ( event->type() == QEvent::KeyPress ) { + QKeyEvent* keyEvent = static_cast(event); - if ( slot ) - pushSlot ( slot ); + if ( keyEvent->key() == Qt::Key_Right ) { + QModelIndex index = _view->currentIndex(); + if ( index.isValid() ) { + Slot* slot = _baseModel->getRecord()->getSlot(_sortModel->mapToSource(index).row()); + + if ( slot ) + pushSlot ( slot ); + } + } else if ( keyEvent->key() == Qt::Key_Left ) { + back (); + } else if ( keyEvent->key() == Qt::Key_O ) { + forkInspector ( _view->currentIndex() ); } - } else if ( event->key() == Qt::Key_Left ) { - back (); - } else if ( event->key() == Qt::Key_O ) { - forkInspector ( _view->currentIndex() ); - } else { - QWidget::keyPressEvent ( event ); } + + return QObject::eventFilter ( object, event ); } diff --git a/hurricane/src/hviewer/MoveCommand.cpp b/hurricane/src/hviewer/MoveCommand.cpp index 8217679d..5f296154 100644 --- a/hurricane/src/hviewer/MoveCommand.cpp +++ b/hurricane/src/hviewer/MoveCommand.cpp @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved // // =================================================================== // @@ -51,6 +51,9 @@ namespace Hurricane { bool MoveCommand::keyPressEvent ( CellWidget* widget, QKeyEvent* event ) { + if ( event->modifiers() & (Qt::ControlModifier|Qt::ShiftModifier) ) + return false; + switch ( event->key() ) { case Qt::Key_Up: widget->goUp (); return true; case Qt::Key_Down: widget->goDown (); return true; diff --git a/hurricane/src/hviewer/NetlistWidget.cpp b/hurricane/src/hviewer/NetlistWidget.cpp index 2576a535..a67152a1 100644 --- a/hurricane/src/hviewer/NetlistWidget.cpp +++ b/hurricane/src/hviewer/NetlistWidget.cpp @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved // // =================================================================== // @@ -29,6 +29,7 @@ #include #include #include +#include #include "hurricane/Commons.h" #include "hurricane/Net.h" @@ -61,6 +62,7 @@ namespace Hurricane { { setAttribute ( Qt::WA_DeleteOnClose ); setAttribute ( Qt::WA_QuitOnClose, false ); + setContextMenuPolicy ( Qt::ActionsContextMenu ); _rowHeight = QFontMetrics(Graphics::getFixedFont()).height() + 4; @@ -93,11 +95,17 @@ namespace Hurricane { setLayout ( gLayout ); + QAction* fitAction = new QAction ( tr("&Fit to Net"), this ); + fitAction->setShortcut ( QKeySequence(tr("CTRL+F")) ); + fitAction->setStatusTip ( tr("Fit the view to the Net's bounding box") ); + addAction ( fitAction ); + connect ( _filterPatternLineEdit , SIGNAL(textChanged(const QString &)) , 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()) ); + connect ( _baseModel, SIGNAL(layoutChanged()), this, SLOT(forceRowHeight()) ); + connect ( fitAction , SIGNAL(triggered ()), this, SLOT(fitToNet ()) ); resize(300, 300); } @@ -123,10 +131,12 @@ namespace Hurricane { void NetlistWidget::updateSelecteds ( const QItemSelection& , const QItemSelection& ) { - const Net* net; + cerr << "open refresh session" << endl; + emit refreshSessionOpened (); _selecteds.resetAccesses (); + const Net* net; QModelIndexList iList = _view->selectionModel()->selectedRows(); for ( int i=0 ; igetNet ( _sortModel->mapToSource(iList[i]).row() ); @@ -154,12 +164,9 @@ namespace Hurricane { } ++isel; } - } - - void NetlistWidget::keyPressEvent ( QKeyEvent* event ) - { - QWidget::keyPressEvent ( event ); + emit refreshSessionClosed (); + cerr << "close refresh session" << endl; } @@ -170,4 +177,12 @@ namespace Hurricane { } + void NetlistWidget::fitToNet () + { + const Net* net = _baseModel->getNet ( _sortModel->mapToSource(_view->currentIndex()).row() ); + + if ( net ) emit netFitted ( net ); + } + + } // End of Hurricane namespace. diff --git a/hurricane/src/hviewer/SelectionPopup.cpp b/hurricane/src/hviewer/SelectionPopup.cpp index a6528b8f..4f98e223 100644 --- a/hurricane/src/hviewer/SelectionPopup.cpp +++ b/hurricane/src/hviewer/SelectionPopup.cpp @@ -98,6 +98,8 @@ namespace Hurricane { void SelectionPopup::keyPressEvent ( QKeyEvent* event ) { + cerr << "SelectionPopup::keyPressEvent()" << endl; + QWidget::keyPressEvent ( event ); } diff --git a/hurricane/src/hviewer/SelectionWidget.cpp b/hurricane/src/hviewer/SelectionWidget.cpp index 45270cdd..630a3b42 100644 --- a/hurricane/src/hviewer/SelectionWidget.cpp +++ b/hurricane/src/hviewer/SelectionWidget.cpp @@ -99,6 +99,7 @@ namespace Hurricane { _view->setSortingEnabled(true); _view->setModel ( _sortModel ); _view->horizontalHeader()->setStretchLastSection ( true ); + _view->installEventFilter(this); QHeaderView* horizontalHeader = _view->horizontalHeader (); horizontalHeader->setStretchLastSection ( true ); @@ -144,11 +145,16 @@ namespace Hurricane { } - void SelectionWidget::keyPressEvent ( QKeyEvent* event ) + bool SelectionWidget::eventFilter ( QObject* object, QEvent* event ) { - if ( event->key() == Qt::Key_I ) { inspect ( _view->currentIndex() ); } - else if ( event->key() == Qt::Key_T ) { toggleSelection ( _view->currentIndex() ); } - else QWidget::keyPressEvent ( event ); + if ( event->type() == QEvent::KeyPress ) { + QKeyEvent* keyEvent = static_cast(event); + + if ( keyEvent->key() == Qt::Key_I ) { inspect ( _view->currentIndex() ); } + else if ( keyEvent->key() == Qt::Key_T ) { toggleSelection ( _view->currentIndex() ); } + } + + return QObject::eventFilter ( object, event ); } @@ -189,8 +195,8 @@ namespace Hurricane { static bool isEmitter = false; if ( sender() == _showSelection ) { - isEmitter = true; - emit showSelectionToggled ( state ); + isEmitter = true; + emit showSelectionToggled ( state ); } else { if ( !isEmitter ) { _showSelection->blockSignals ( true ); diff --git a/hurricane/src/hviewer/SelectorCriterion.cpp b/hurricane/src/hviewer/SelectorCriterion.cpp index 8b6c2306..e02c19a5 100644 --- a/hurricane/src/hviewer/SelectorCriterion.cpp +++ b/hurricane/src/hviewer/SelectorCriterion.cpp @@ -42,7 +42,7 @@ namespace Hurricane { { return NULL; } - void SelectorCriterion::undoSelection ( CellWidget* cw, bool delayRedraw ) + void SelectorCriterion::undoSelection ( CellWidget* cw ) { } @@ -72,15 +72,15 @@ namespace Hurricane { } - void NetSelectorCriterion::doSelection ( CellWidget* cw, bool delayRedraw ) + void NetSelectorCriterion::doSelection ( CellWidget* cw ) { - cw->_select ( _net, delayRedraw ); + cw->_select ( _net ); } - void NetSelectorCriterion::undoSelection ( CellWidget* cw, bool delayRedraw ) + void NetSelectorCriterion::undoSelection ( CellWidget* cw ) { - cw->_unselect ( _net, delayRedraw ); + cw->_unselect ( _net ); } @@ -124,7 +124,7 @@ namespace Hurricane { { return true; } - void AreaSelectorCriterion::doSelection ( CellWidget* cw, bool delayRedraw ) + void AreaSelectorCriterion::doSelection ( CellWidget* cw ) { cw->_selectOccurrencesUnder ( _area ); } diff --git a/hurricane/src/hviewer/ZoomCommand.cpp b/hurricane/src/hviewer/ZoomCommand.cpp index a08e0906..9de42df6 100644 --- a/hurricane/src/hviewer/ZoomCommand.cpp +++ b/hurricane/src/hviewer/ZoomCommand.cpp @@ -59,11 +59,17 @@ namespace Hurricane { bool ZoomCommand::keyPressEvent ( CellWidget* widget, QKeyEvent* event ) { + bool control = (event->modifiers() & Qt::ControlModifier); + switch ( event->key() ) { - case Qt::Key_Z: widget->setScale ( widget->getScale()*2.0 ); return true; - case Qt::Key_M: widget->setScale ( widget->getScale()/2.0 ); return true; - case Qt::Key_U: widget->scaleHistoryUp (); return true; - case Qt::Key_D: widget->scaleHistoryDown(); return true; + case Qt::Key_Z: + if ( control ) widget->scaleHistoryDown(); + else widget->setScale ( widget->getScale()*2.0 ); + return true; + case Qt::Key_M: + if ( control ) widget->scaleHistoryUp (); + else widget->setScale ( widget->getScale()/2.0 ); + return true; } return false; } @@ -91,12 +97,13 @@ namespace Hurricane { setDrawingEnabled ( false ); QRect zoomArea = QRect ( _startPoint, _stopPoint ); - if ( ( abs(zoomArea.width()) > 10 ) && ( abs(zoomArea.height()) > 10 ) ) + if ( ( abs(zoomArea.width ()) > getDrawingThreshold() ) + && ( abs(zoomArea.height()) > getDrawingThreshold() ) ) widget->reframe ( widget->screenToDbuBox(zoomArea) ); - else { - cerr << Warning("Rejecting too small zoom request.") << endl; - widget->update (); - } + //else { + // cerr << Warning("Rejecting too small zoom request.") << endl; + // widget->update (); + //} return false; } diff --git a/hurricane/src/hviewer/hurricane/viewer/AreaCommand.h b/hurricane/src/hviewer/hurricane/viewer/AreaCommand.h index c9b3804b..c428ee23 100644 --- a/hurricane/src/hviewer/hurricane/viewer/AreaCommand.h +++ b/hurricane/src/hviewer/hurricane/viewer/AreaCommand.h @@ -1,36 +1,9 @@ // -*- C++ -*- // -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved // -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag // =================================================================== // // $Id$ @@ -50,8 +23,8 @@ // x-----------------------------------------------------------------x -#ifndef __HURRICANE_AREA_COMMAND_H__ -#define __HURRICANE_AREA_COMMAND_H__ +#ifndef __HURRICANE_AREA_COMMAND__ +#define __HURRICANE_AREA_COMMAND__ #include @@ -68,14 +41,17 @@ namespace Hurricane { inline void setStartPoint ( const QPoint& start ); inline void setStopPoint ( const QPoint& stop ); inline void setDrawingEnabled ( bool state ); + inline void setDrawingThreshold ( int ); virtual void draw ( CellWidget* widget ); virtual void drawCorner ( CellWidget* widget, bool bottomLeft ); virtual bool mouseMoveEvent ( CellWidget* widget, QMouseEvent* event ); inline bool isDrawingEnabled () const; + inline int getDrawingThreshold () const; protected: QPoint _startPoint; QPoint _stopPoint; QPoint _cornerPoints[3]; + int _drawingThreshold; bool _drawingEnabled; private: AreaCommand ( const AreaCommand& ); @@ -95,10 +71,18 @@ namespace Hurricane { { _drawingEnabled = state; } + inline void AreaCommand::setDrawingThreshold ( int threshold ) + { _drawingThreshold = threshold; } + + inline bool AreaCommand::isDrawingEnabled () const { return _drawingEnabled; } + inline int AreaCommand::getDrawingThreshold () const + { return _drawingThreshold; } + + } diff --git a/hurricane/src/hviewer/hurricane/viewer/CellWidget.h b/hurricane/src/hviewer/hurricane/viewer/CellWidget.h index 495a9f87..eae3dfa0 100644 --- a/hurricane/src/hviewer/hurricane/viewer/CellWidget.h +++ b/hurricane/src/hviewer/hurricane/viewer/CellWidget.h @@ -114,6 +114,13 @@ namespace Hurricane { inline Cell* getCell () const; inline shared_ptr& getState (); inline PaletteWidget* getPalette (); + inline Occurrences getOccurrencesUnder ( const QRect& ) const; + Occurrences getOccurrencesUnder ( const Box& ) const; + inline SelectorSet& getSelectorSet (); + inline RubberShape getRubberShape () const; + inline int getStartLevel () const; + inline int getStopLevel () const; + inline Query::Mask getQueryFilter () const ; void bindToPalette ( PaletteWidget* ); void detachFromPalette (); void bindCommand ( Command* ); @@ -121,22 +128,17 @@ namespace Hurricane { inline bool showBoundaries () const; inline bool showSelection () const; inline bool cumulativeSelection () const; - inline Occurrences getOccurrencesUnder ( const QRect& ) const; - Occurrences getOccurrencesUnder ( const Box& ) const; - inline SelectorSet& getSelectorSet (); inline void setRubberShape ( RubberShape ); - inline RubberShape getRubberShape () const; inline void setStartLevel ( int ); inline void setStopLevel ( int ); - inline void setQueryFilter ( int ); - inline int getQueryFilter () const ; + inline void setQueryFilter ( Query::Mask ); inline bool timeout ( const char*, const Timer&, double timeout, bool& timedout ) const; // Painter control & Hurricane objects drawing primitives. inline void setEnableRedrawInterrupt ( bool ); inline void addDrawExtensionGo ( const Name&, InitExtensionGo_t*, DrawExtensionGo_t* ); inline QPainter& getPainter ( size_t plane=PlaneId::Working ); inline int getDarkening () const; - inline void copyToPrinter ( QPrinter* printer ); + inline void copyToPrinter ( QPrinter* ); inline const float& getScale () const; inline const QPoint& getMousePosition () const; bool isDrawable ( const Name& ); @@ -199,8 +201,8 @@ namespace Hurricane { void cellPreModificated (); void cellPostModificated (); void stateChanged ( shared_ptr& ); - void settingsChanged (); void styleChanged ( void* emitter ); + void queryFilterChanged (); void updatePalette ( Cell* ); void mousePositionChanged ( const Point& position ); void selectionChanged ( const SelectorSet&, Cell* ); @@ -211,22 +213,25 @@ namespace Hurricane { public slots: // Qt QWidget Slots Overload & CellWidget Specifics. void setState ( shared_ptr& ); + inline void openRefreshSession (); + inline void closeRefreshSession (); inline DrawingPlanes& getDrawingPlanes (); inline QPoint& getOffsetVA (); - void select ( const Net* net, bool delayRedraw=false ); - void select ( Occurrence occurence ); - bool isSelected ( Occurrence occurence ); + void select ( const Net* ); + void select ( Occurrence ); + bool isSelected ( Occurrence ); void selectOccurrencesUnder ( Box selectArea ); - void unselect ( const Net* net, bool delayRedraw=false ); - void unselect ( Occurrence occurence ); - void unselectAll ( bool delayRedraw=false ); - void toggleSelection ( Occurrence occurence ); + void unselect ( const Net* ); + void unselect ( Occurrence ); + void unselectAll (); + void toggleSelection ( Occurrence ); 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 _select ( const Net* ); + void _unselect ( const Net* ); void _selectOccurrencesUnder ( Box selectArea ); - void _unselectAll ( bool delayRedraw ); + void _unselectAll (); + void changeQueryFilter (); void rubberChange (); void styleChange ( void* emitter ); void updatePalette (); @@ -240,14 +245,15 @@ namespace Hurricane { void goRight ( int dx = 0 ); void goUp ( int dy = 0 ); void goDown ( int dy = 0 ); - void fitToContents ( bool delayed=false, bool historyEnable=true ); + void fitToContents ( bool historyEnable=true ); + void fitToNet ( const Net*, bool historyEnable=true ); void setScale ( float ); void scaleHistoryUp (); void scaleHistoryDown (); void setShowBoundaries ( bool state ); - void reframe ( bool delayed=false ); - void reframe ( const Box& box, bool delayed=false ); - void displayReframe ( bool delayed=false ); + void reframe (); + void reframe ( const Box& box, bool historyEnable=true ); + void displayReframe (); void _goLeft ( int dx ); void _goRight ( int dx ); void _goUp ( int dy ); @@ -292,21 +298,24 @@ namespace Hurricane { private: class RedrawManager { public: - inline RedrawManager ( CellWidget* ); - ~RedrawManager (); - void goLeft ( int ); - void goRight ( int ); - void goUp ( int ); - void goDown ( int ); - void refresh (); - void process (); - inline void stopProcessing (); - inline bool isProcessing () const; - inline bool interrupted () const; - inline size_t getPendings () const; + inline RedrawManager ( CellWidget* ); + ~RedrawManager (); + void goLeft ( int ); + void goRight ( int ); + void goUp ( int ); + void goDown ( int ); + void refresh (); + void process (); + inline void stopProcessing (); + inline bool isProcessing () const; + inline bool interrupted () const; + inline size_t getPendings () const; + inline void openRefreshSession (); + inline void closeRefreshSession (); private: CellWidget* _widget; list _events; + int _refreshSession; bool _processing; bool _interrupted; }; @@ -449,9 +458,9 @@ namespace Hurricane { SelectorCriterions (); ~SelectorCriterions (); inline void setCellWidget ( CellWidget* ); - bool add ( const Net* net, bool delayRedraw ); + bool add ( const Net* net ); bool add ( Box area ); - bool remove ( const Net* net, bool delayRedraw ); + bool remove ( const Net* net ); void clear (); void revalidate (); inline size_t size () const; @@ -472,6 +481,10 @@ namespace Hurricane { void setScale ( float ); inline void setTopLeft ( DbU::Unit, DbU::Unit ); inline void setTopLeft ( const Point& ); + inline void setQueryFilter ( Query::Mask ); + inline void setStartLevel ( int ); + inline void setStopLevel ( int ); + inline void setRubberShape ( RubberShape ); inline void setHistoryEnable ( bool ); bool scaleHistoryUp (); bool scaleHistoryDown (); @@ -485,6 +498,10 @@ namespace Hurricane { inline size_t getHistorySize () const; inline const float& getScale () const; inline const Point& getTopLeft () const; + inline Query::Mask getQueryFilter () const; + inline int getStartLevel () const; + inline int getStopLevel () const; + inline RubberShape getRubberShape () const; private: class ScaleEntry { @@ -501,6 +518,10 @@ namespace Hurricane { SelectorCriterions _selection; bool _showBoundaries; bool _showSelection; + Query::Mask _queryFilter; + int _startLevel; + int _stopLevel; + RubberShape _rubberShape; bool _cumulativeSelection; vector _scaleHistory; size_t _ihistory; @@ -530,7 +551,6 @@ namespace Hurricane { DrawingPlanes _drawingPlanes; DrawingQuery _drawingQuery; TextDrawingQuery _textDrawingQuery; - int _queryFilter; int _darkening; QPoint _mousePosition; Spot _spot; @@ -544,7 +564,6 @@ namespace Hurricane { vector _commands; size_t _redrawRectCount; int _textFontHeight; - RubberShape _rubberShape; friend class RedrawManager; }; @@ -579,6 +598,14 @@ namespace Hurricane { { _enableRedrawInterrupt = state; } + inline void CellWidget::openRefreshSession () + { _redrawManager.openRefreshSession (); } + + + inline void CellWidget::closeRefreshSession () + { _redrawManager.closeRefreshSession (); } + + inline void CellWidget::DrawingQuery::addDrawExtensionGo ( const Name& name , InitExtensionGo_t* initExtensionGo , DrawExtensionGo_t* drawExtensionGo @@ -630,6 +657,17 @@ namespace Hurricane { { return _events.size(); } + inline void CellWidget::RedrawManager::openRefreshSession () + { _refreshSession++; } + + + inline void CellWidget::RedrawManager::closeRefreshSession () + { + _refreshSession--; + if ( !_processing && (_refreshSession == 0) ) process (); + } + + inline bool CellWidget::RedrawManager::interrupted () const { #ifdef ALLOW_REQUEST_INTERRUPT @@ -733,6 +771,10 @@ namespace Hurricane { inline CellWidget::State::State ( Cell* cell ) : _cell (cell) , _selection () + , _queryFilter (~Query::DoTerminalCells) + , _startLevel (0) + , _stopLevel (99) + , _rubberShape (CellWidget::Steiner) , _showBoundaries (true) , _showSelection (false) , _cumulativeSelection(false) @@ -775,9 +817,23 @@ namespace Hurricane { inline void CellWidget::State::setTopLeft ( const Point& topLeft ) - { - _scaleHistory[_ihistory]._topLeft = topLeft; - } + { _scaleHistory[_ihistory]._topLeft = topLeft; } + + + inline void CellWidget::State::setQueryFilter ( Query::Mask mask ) + { _queryFilter = mask; } + + + inline void CellWidget::State::setStartLevel ( int level ) + { _startLevel = level; } + + + inline void CellWidget::State::setStopLevel ( int level ) + { _stopLevel = level; } + + + inline void CellWidget::State::setRubberShape ( RubberShape shape ) + { _rubberShape = shape; } inline void CellWidget::State::setHistoryEnable ( bool enable ) @@ -816,6 +872,22 @@ namespace Hurricane { { return _scaleHistory[_ihistory]._topLeft; } + inline Query::Mask CellWidget::State::getQueryFilter () const + { return _queryFilter; } + + + inline int CellWidget::State::getStartLevel () const + { return _startLevel; } + + + inline int CellWidget::State::getStopLevel () const + { return _stopLevel; } + + + inline CellWidget::RubberShape CellWidget::State::getRubberShape () const + { return _rubberShape; } + + inline const float& CellWidget::State::getScale () const { return _scaleHistory[_ihistory]._scale; } @@ -845,11 +917,27 @@ namespace Hurricane { inline void CellWidget::setStartLevel ( int level ) - { _drawingQuery.setStartLevel ( level ); } + { + _drawingQuery.setStartLevel ( level ); + _state->setStartLevel ( level ); + emit queryFilterChanged (); + } inline void CellWidget::setStopLevel ( int level ) - { _drawingQuery.setStopLevel ( level ); } + { + _drawingQuery.setStopLevel ( level ); + _state->setStopLevel ( level ); + emit queryFilterChanged (); + } + + + inline int CellWidget::getStartLevel () const + { return _drawingQuery.getStartLevel (); } + + + inline int CellWidget::getStopLevel () const + { return _drawingQuery.getStopLevel (); } inline CellWidget::DrawingPlanes& CellWidget::getDrawingPlanes () @@ -988,23 +1076,26 @@ namespace Hurricane { { return _mousePosition; } - inline void CellWidget::setQueryFilter ( int filter ) - { _queryFilter = filter; } + inline void CellWidget::setQueryFilter ( Query::Mask filter ) + { + _state->setQueryFilter ( filter ); + emit queryFilterChanged (); + } - inline int CellWidget::getQueryFilter () const - { return _queryFilter; } + inline Query::Mask CellWidget::getQueryFilter () const + { return _state->getQueryFilter(); } inline void CellWidget::setRubberShape ( RubberShape shape ) { - _rubberShape = shape; - refresh (); + _state->setRubberShape ( shape ); + emit queryFilterChanged (); } inline CellWidget::RubberShape CellWidget::getRubberShape () const - { return _rubberShape; } + { return _state->getRubberShape(); } inline void CellWidget::setPen ( const QPen& pen, size_t plane ) diff --git a/hurricane/src/hviewer/hurricane/viewer/ControllerWidget.h b/hurricane/src/hviewer/hurricane/viewer/ControllerWidget.h index 976e30df..21bb38ab 100644 --- a/hurricane/src/hviewer/hurricane/viewer/ControllerWidget.h +++ b/hurricane/src/hviewer/hurricane/viewer/ControllerWidget.h @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved // // =================================================================== // diff --git a/hurricane/src/hviewer/hurricane/viewer/DisplayFilterWidget.h b/hurricane/src/hviewer/hurricane/viewer/DisplayFilterWidget.h index 48ae6a71..9895a95f 100644 --- a/hurricane/src/hviewer/hurricane/viewer/DisplayFilterWidget.h +++ b/hurricane/src/hviewer/hurricane/viewer/DisplayFilterWidget.h @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved // // =================================================================== // @@ -46,12 +46,10 @@ namespace Hurricane { public: DisplayFilterWidget ( QWidget* parent=NULL ); void setCellWidget ( CellWidget* ); - signals: - void filterChanged (); - + void queryFilterChanged (); public slots: - void syncFromCellWidget (); + void changeQueryFilter (); void startLevelChanged ( int level ); void stopLevelChanged ( int level ); void setDoMasterCells ( int state ); @@ -60,6 +58,14 @@ namespace Hurricane { void setRubberSteiner (); void setRubberCentric (); void setRubberBarycentric (); + protected: + void blockAllSignals ( bool state ); + + protected: + enum UpdateState { External = 0 + , InternalEmit + , InternalReceive + }; protected: CellWidget* _cellWidget; @@ -71,8 +77,7 @@ namespace Hurricane { QRadioButton* _steiner; QRadioButton* _centric; QRadioButton* _barycentric; - int _queryFilter; - bool _signalEmitter; + UpdateState _updateState; }; diff --git a/hurricane/src/hviewer/hurricane/viewer/InspectorWidget.h b/hurricane/src/hviewer/hurricane/viewer/InspectorWidget.h index d2991dc8..ae34b555 100644 --- a/hurricane/src/hviewer/hurricane/viewer/InspectorWidget.h +++ b/hurricane/src/hviewer/hurricane/viewer/InspectorWidget.h @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved // // =================================================================== // @@ -88,7 +88,7 @@ namespace Hurricane { void historyChanged ( int depth ); void forkInspector ( const QModelIndex& ); protected: - void keyPressEvent ( QKeyEvent* ); + bool eventFilter ( QObject*, QEvent* ); private: void _setRootRecord ( Record* ); void pushSlot ( Slot* ); diff --git a/hurricane/src/hviewer/hurricane/viewer/NetlistWidget.h b/hurricane/src/hviewer/hurricane/viewer/NetlistWidget.h index 8fd30515..2d8edd6e 100644 --- a/hurricane/src/hviewer/hurricane/viewer/NetlistWidget.h +++ b/hurricane/src/hviewer/hurricane/viewer/NetlistWidget.h @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved // // =================================================================== // @@ -116,23 +116,23 @@ namespace Hurricane { Q_OBJECT; public: - NetlistWidget ( QWidget* parent=NULL ); - inline Cell* getCell (); - template - void setCell ( Cell* ); - void goTo ( int ); + NetlistWidget ( QWidget* parent=NULL ); + inline Cell* getCell (); + template + void setCell ( Cell* ); + 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 updateSelecteds ( const QItemSelection& , const QItemSelection& ); - protected: - void keyPressEvent ( QKeyEvent* ); + void refreshSessionOpened (); + void refreshSessionClosed (); + void netSelected ( const Net* ); + void netUnselected ( const Net* ); + void netFitted ( const Net* ); + public slots: + void forceRowHeight (); + private slots: + void textFilterChanged (); + void updateSelecteds ( const QItemSelection& , const QItemSelection& ); + void fitToNet (); private: Cell* _cell; diff --git a/hurricane/src/hviewer/hurricane/viewer/SelectionWidget.h b/hurricane/src/hviewer/hurricane/viewer/SelectionWidget.h index b63ea0fc..cd1712ec 100644 --- a/hurricane/src/hviewer/hurricane/viewer/SelectionWidget.h +++ b/hurricane/src/hviewer/hurricane/viewer/SelectionWidget.h @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved // // =================================================================== // @@ -77,7 +77,7 @@ namespace Hurricane { private slots: void textFilterChanged (); protected: - virtual void keyPressEvent ( QKeyEvent * event ); + virtual bool eventFilter ( QObject*, QEvent* ); virtual void hideEvent ( QHideEvent* event ); private: diff --git a/hurricane/src/hviewer/hurricane/viewer/SelectorCriterion.h b/hurricane/src/hviewer/hurricane/viewer/SelectorCriterion.h index fcb28772..ae4384e1 100644 --- a/hurricane/src/hviewer/hurricane/viewer/SelectorCriterion.h +++ b/hurricane/src/hviewer/hurricane/viewer/SelectorCriterion.h @@ -44,8 +44,8 @@ namespace Hurricane { 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 void doSelection ( CellWidget* ) = 0; + virtual void undoSelection ( CellWidget* ); virtual Record* _getRecord () const = 0; virtual string _getString () const = 0; virtual string _getTypeName () const = 0; @@ -58,8 +58,8 @@ namespace Hurricane { 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 void doSelection ( CellWidget* ); + virtual void undoSelection ( CellWidget* ); virtual Record* _getRecord () const; virtual string _getString () const; virtual string _getTypeName () const; @@ -75,7 +75,7 @@ namespace Hurricane { virtual ~AreaSelectorCriterion (); const Box& getArea () const; virtual bool isValid ( CellWidget* ) const; - virtual void doSelection ( CellWidget*, bool delayRedraw ); + virtual void doSelection ( CellWidget* ); virtual Record* _getRecord () const; virtual string _getString () const; virtual string _getTypeName () const;