From 828b1d6b6ff5bdc7a1c67169f354055fc74bf7d7 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Sat, 4 Dec 2010 15:22:54 +0000 Subject: [PATCH] * ./hurricane/src/hurricane: - New: Torus object. To allow a simpler management of a chip's corona, the toric area between the pads and the core. - Change: In HyperNet/LeafPlugOccurrences, change the instance stop criterions from "isLeaf()", which means "contains no instances" to "isTerminal()" which can be programmatically changed. This has to be done for the Pads which are non-leaf due to "padreal" but still must be considered for their connectors. This modification is coupled with one in the Ap parser. - Change: In Backtrace, enable support for Apple backtrace. This is a blind test as I can't check by myself. * ./hurricane/src/viewer: - Change: In CellWidget/SelectionModel/SelectionWidget, rewrite the Gos selec- tion mechanism. Now ExtensionGo could be selecteds as they ought to be. Also adopt a more standard way of how objetcs are selecteds. Prefer "dataChanged()" signal over "reset()" or "layoutChanged()" as it keeps the selection instead of resetting it. Unselecteds entry in the window (toggled with 't') are now shown in red for better readability. --- hurricane/src/hurricane/Backtrace.cpp | 16 ++ hurricane/src/hurricane/CMakeLists.txt | 4 +- hurricane/src/hurricane/HyperNet.cpp | 3 +- hurricane/src/hurricane/Torus.cpp | 100 ++++++++ hurricane/src/hurricane/hurricane/Torus.h | 81 +++++++ hurricane/src/viewer/CellViewer.cpp | 4 +- hurricane/src/viewer/CellWidget.cpp | 228 +++++++++++------- hurricane/src/viewer/ControllerWidget.cpp | 4 +- hurricane/src/viewer/NetlistWidget.cpp | 4 +- hurricane/src/viewer/SelectCommand.cpp | 2 +- hurricane/src/viewer/SelectionModel.cpp | 108 +++++++-- hurricane/src/viewer/SelectionWidget.cpp | 13 +- hurricane/src/viewer/SelectorCriterion.cpp | 18 +- .../src/viewer/hurricane/viewer/CellWidget.h | 29 +-- .../viewer/hurricane/viewer/NetlistWidget.h | 4 +- .../viewer/hurricane/viewer/SelectionModel.h | 7 + .../viewer/hurricane/viewer/SelectionWidget.h | 2 + .../hurricane/viewer/SelectorCriterion.h | 15 +- 18 files changed, 497 insertions(+), 145 deletions(-) create mode 100644 hurricane/src/hurricane/Torus.cpp create mode 100644 hurricane/src/hurricane/hurricane/Torus.h diff --git a/hurricane/src/hurricane/Backtrace.cpp b/hurricane/src/hurricane/Backtrace.cpp index c01b98f6..63cc2880 100644 --- a/hurricane/src/hurricane/Backtrace.cpp +++ b/hurricane/src/hurricane/Backtrace.cpp @@ -98,7 +98,23 @@ namespace Hurricane { #else # ifdef __APPLE__ boost::regex re ( "(\\d+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S)\\s+\\+\\s+(\\d+)" ); + boost::cmatch match; + for ( size_t i=0 ; i )"; + _stack.push_back ( reformated ); + } + } else { + _stack.push_back ( symbols[i] ); + } + } # else _stack.push_back ( "Backtrace only supported under Linux & OSX." ); # endif diff --git a/hurricane/src/hurricane/CMakeLists.txt b/hurricane/src/hurricane/CMakeLists.txt index 344bf114..7953e229 100644 --- a/hurricane/src/hurricane/CMakeLists.txt +++ b/hurricane/src/hurricane/CMakeLists.txt @@ -9,7 +9,8 @@ hurricane/ContactLayer.h hurricane/DiffusionLayer.h hurricane/TransistorLayer.h hurricane/TransistorLayers.h - hurricane/Boxes.h hurricane/Box.h + hurricane/Box.h hurricane/Boxes.h + hurricane/Torus.h hurricane/Cell.h hurricane/Cells.h hurricane/Collection.h hurricane/Commons.h @@ -100,6 +101,7 @@ DbU.cpp Point.cpp Box.cpp + Torus.cpp Interval.cpp Transformation.cpp Name.cpp diff --git a/hurricane/src/hurricane/HyperNet.cpp b/hurricane/src/hurricane/HyperNet.cpp index 514a43bf..b32c918b 100644 --- a/hurricane/src/hurricane/HyperNet.cpp +++ b/hurricane/src/hurricane/HyperNet.cpp @@ -989,7 +989,8 @@ void HyperNet_LeafPlugOccurrences::Locator::progress() _netOccurrenceLocator.progress(); Net* net = (Net*)netOccurrence.getEntity(); Path path = netOccurrence.getPath(); - if (!path.isEmpty() && net->getCell()->isLeaf()) + + if (!path.isEmpty() && net->getCell()->isTerminal()) { Instance *instance = path.getTailInstance(); Plug *plug=instance->getPlug(net); diff --git a/hurricane/src/hurricane/Torus.cpp b/hurricane/src/hurricane/Torus.cpp new file mode 100644 index 00000000..3e485185 --- /dev/null +++ b/hurricane/src/hurricane/Torus.cpp @@ -0,0 +1,100 @@ + +// -*- C++ -*- +// +// Copyright (c) BULL S.A. 2000-2010, All Rights Reserved +// +// This file is part of Hurricane. +// +// Hurricane is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// Hurricane is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- +// TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU +// General Public License for more details. +// +// You should have received a copy of the Lesser GNU General Public +// License along with Hurricane. If not, see +// . +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | H U R R I C A N E | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./Torus.cpp" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#include +#include "hurricane/Torus.h" + + +namespace Hurricane { + + using std::string; + using std::ostringstream; + + + Torus::Torus () + : _outerBox() + , _innerBox() + { } + + + Torus::Torus ( const Box& outer, const Box& inner ) + : _outerBox(outer) + , _innerBox(inner) + { } + + + bool Torus::contains ( const Box& box ) const + { + if ( isEmpty() ) return false; + + return _outerBox.contains (box) + and not _innerBox.contains (box) + and not _innerBox.intersect(box); + } + + + string Torus::_getString () const + { + ostringstream s; + s << "add(getSlot("_outerBox", &_outerBox)); + record->add(getSlot("_innerBox", &_innerBox)); + return record; +} + + + +} // End of Hurricane namespace. diff --git a/hurricane/src/hurricane/hurricane/Torus.h b/hurricane/src/hurricane/hurricane/Torus.h new file mode 100644 index 00000000..f8b5731d --- /dev/null +++ b/hurricane/src/hurricane/hurricane/Torus.h @@ -0,0 +1,81 @@ + +// -*- C++ -*- +// +// Copyright (c) BULL S.A. 2000-2010, All Rights Reserved +// +// This file is part of Hurricane. +// +// Hurricane is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// Hurricane is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- +// TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU +// General Public License for more details. +// +// You should have received a copy of the Lesser GNU General Public +// License along with Hurricane. If not, see +// . +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | H U R R I C A N E | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./hurricane/Torus.h" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#ifndef __HURRICANE_TORUS__ +#define __HURRICANE_TORUS__ + +#include "hurricane/Box.h" + + +namespace Hurricane { + + + class Torus { + public: + Torus (); + Torus ( const Box& outer, const Box& inner ); + inline bool isEmpty () const; + inline const Box& getBoundingBox () const; + inline const Box& getOuterBox () const; + inline const Box& getInnerBox () const; + bool contains ( const Box& ) const; + inline std::string _getTypeName () const; + std::string _getString () const; + Record* _getRecord () const; + private: + Box _outerBox; + Box _innerBox; + }; + + +// Inline Functions. + inline bool Torus::isEmpty () const { return _outerBox.isEmpty(); } + inline const Box& Torus::getBoundingBox () const { return getOuterBox(); } + inline const Box& Torus::getOuterBox () const { return _outerBox; } + inline const Box& Torus::getInnerBox () const { return _innerBox; } + inline std::string Torus::_getTypeName () const { return "Torus"; } + + +} // End of Hurricane namespace. + + +INSPECTOR_PV_SUPPORT(Hurricane::Torus); + +#endif // __HURRICANE_TORUS__ diff --git a/hurricane/src/viewer/CellViewer.cpp b/hurricane/src/viewer/CellViewer.cpp index 46cde454..a9775090 100644 --- a/hurricane/src/viewer/CellViewer.cpp +++ b/hurricane/src/viewer/CellViewer.cpp @@ -338,8 +338,10 @@ namespace Hurricane { connect ( _cellWidget , SIGNAL(selectionModeChanged()) , this , SLOT (changeSelectionMode ()) ); + // connect ( &_selectCommand , SIGNAL(selectionToggled (Occurrence)) + // , _cellWidget , SLOT (toggleSelection (Occurrence)) ); connect ( &_selectCommand , SIGNAL(selectionToggled (Occurrence)) - , _cellWidget , SLOT (toggleSelection (Occurrence)) ); + , _cellWidget , SLOT (select (Occurrence)) ); connect ( _cellWidget , SIGNAL(stateChanged(shared_ptr&)) , this , SLOT (setState (shared_ptr&)) ); diff --git a/hurricane/src/viewer/CellWidget.cpp b/hurricane/src/viewer/CellWidget.cpp index 41567843..558b83ee 100644 --- a/hurricane/src/viewer/CellWidget.cpp +++ b/hurricane/src/viewer/CellWidget.cpp @@ -1008,29 +1008,34 @@ namespace Hurricane { CellWidget::SelectorCriterions::~SelectorCriterions () - { - clear (); - } + { clear (); } - bool CellWidget::SelectorCriterions::add ( const Net* net ) + SelectorCriterion* CellWidget::SelectorCriterions::add ( const Net* net ) { - if ( _cellWidget == NULL ) return false; + if ( _cellWidget == NULL ) return NULL; if ( not _cellWidget->isSelected(Occurrence(net)) ) { _criterions.push_back ( new NetSelectorCriterion(net) ); - _criterions.back()->doSelection ( _cellWidget ); - return true; + //_criterions.back()->doSelection ( _cellWidget ); + return _criterions.back(); } - return false; + for ( size_t i=0 ; i<_criterions.size() ; ++i ) { + if ( _criterions[i]->getNet() == net ) return _criterions[i]; + } + return NULL; } - bool CellWidget::SelectorCriterions::add ( Box area ) + SelectorCriterion* CellWidget::SelectorCriterions::add ( Box area ) { - if ( _cellWidget == NULL ) return false; + if ( _cellWidget == NULL ) return NULL; + + for ( size_t i=0 ; i<_criterions.size() ; ++i ) { + if ( _criterions[i]->getArea() == area ) return _criterions[i]; + } _criterions.push_back ( new AreaSelectorCriterion(area) ); - _criterions.back()->doSelection ( _cellWidget ); - return true; + //_criterions.back()->doSelection ( _cellWidget ); + return _criterions.back(); } @@ -1045,7 +1050,7 @@ namespace Hurricane { if ( i < _criterions.size() ) { swap ( _criterions[i], *(_criterions.end()-1) ); - _criterions.back()->undoSelection ( _cellWidget ); + //_criterions.back()->undoSelection ( _cellWidget ); _criterions.pop_back (); } else return false; @@ -1063,6 +1068,16 @@ namespace Hurricane { } + void CellWidget::SelectorCriterions::invalidate () + { + if ( _cellWidget == NULL ) return; + + for ( size_t i=0 ; i<_criterions.size() ; i++ ) { + _criterions[i]->disable(); + } + } + + void CellWidget::SelectorCriterions::revalidate () { if ( _cellWidget == NULL ) return; @@ -2629,16 +2644,6 @@ namespace Hurricane { } - void CellWidget::select ( const Net* net ) - { - ++_delaySelectionChanged; - - bool added = _state->getSelection().add ( net ); - - if ( !--_delaySelectionChanged && added ) emit selectionChanged(_selectors); - } - - bool CellWidget::isSelected ( Occurrence occurrence ) { if ( !occurrence.isValid() ) @@ -2663,9 +2668,51 @@ namespace Hurricane { } + // void CellWidget::select ( const Net* net ) + // { + // if ( (++_delaySelectionChanged == 1) and not _state->cumulativeSelection() ) { + // openRefreshSession (); + // unselectAll (); + // closeRefreshSession (); + // } + + // bool added = _state->getSelection().add ( net ); + + // if ( (--_delaySelectionChanged == 0) and added ) emit selectionChanged(_selectors); + // } + + + void CellWidget::selectOccurrencesUnder ( Box selectArea ) + { + if ( (++_delaySelectionChanged == 1) and not _state->cumulativeSelection() ) { + openRefreshSession (); + unselectAll (); + closeRefreshSession (); + } + + bool selected = true; + SelectorCriterion* criterion = _state->getSelection().add ( selectArea ); + if ( criterion and (not criterion->isEnabled()) ) { + criterion->enable(); + + forEach ( Occurrence, ioccurrence, getOccurrencesUnder(selectArea) ) + select ( *ioccurrence ); + } else + selected = false; + + if ( (--_delaySelectionChanged == 0) and selected ) emit selectionChanged(_selectors); + } + + void CellWidget::select ( Occurrence occurrence ) { - if ( !occurrence.isValid() ) + if ( (++_delaySelectionChanged == 1) and not _state->cumulativeSelection() ) { + openRefreshSession (); + unselectAll (); + closeRefreshSession (); + } + + if ( not occurrence.isValid() ) throw Error ( "Can't select occurrence : invalid occurrence" ); if ( occurrence.getOwnerCell() != getCell() ) { @@ -2675,13 +2722,31 @@ namespace Hurricane { , s1.c_str(), s2.c_str() ); } + bool selected = true; + const Net* net = dynamic_cast(occurrence.getEntity()); + if ( net ) { + SelectorCriterion* criterion = _state->getSelection().add ( net ); + if ( criterion and (not criterion->isEnabled()) ) { + criterion->enable (); + forEach ( Component*, component, net->getComponents() ) { + Occurrence occurrence ( *component ); + select ( occurrence ); + } + forEach ( Rubber*, irubber, net->getRubbers() ) { + Occurrence occurrence ( *irubber ); + select ( occurrence ); + } + } else + selected = false; + } + Property* property = occurrence.getProperty ( Selector::getPropertyName() ); Selector* selector = NULL; - if ( !property ) + if ( not property ) selector = Selector::create ( occurrence ); else { selector = dynamic_cast(property); - if ( !selector ) + if ( not selector ) throw Error ( "Abnormal property named " + getString(Selector::getPropertyName()) ); } @@ -2689,53 +2754,48 @@ namespace Hurricane { setShowSelection ( true ); _selectionHasChanged = true; - if ( !_delaySelectionChanged ) emit selectionChanged(_selectors); - } - - void CellWidget::selectOccurrencesUnder ( Box selectArea ) - { - ++_delaySelectionChanged; - - if ( !_state->cumulativeSelection() ) { - openRefreshSession (); - unselectAll (); - closeRefreshSession (); + if ( (--_delaySelectionChanged == 0) and selected ) { + if ( _state->showSelection() ) _redrawManager.refresh (); + emit selectionChanged(_selectors); } - bool added = _state->getSelection().add ( selectArea ); - - if ( !--_delaySelectionChanged && added ) emit selectionChanged(_selectors); } - void CellWidget::unselect ( const Net* net ) - { - ++_delaySelectionChanged; + // void CellWidget::unselect ( const Net* net ) + // { + // ++_delaySelectionChanged; - bool removed = _state->getSelection().remove ( net ); - if ( !--_delaySelectionChanged && removed ) emit selectionChanged(_selectors); - } + // bool removed = _state->getSelection().remove ( net ); + // if ( (--_delaySelectionChanged == 0) and removed ) emit selectionChanged(_selectors); + // } void CellWidget::unselect ( Occurrence occurrence ) { - if ( !occurrence.isValid() ) + if ( not occurrence.isValid() ) throw Error ( "Can't unselect occurrence : invalid occurrence" ); if ( occurrence.getOwnerCell() != getCell() ) throw Error ( "Can't unselect occurrence : incompatible occurrence" ); + bool unselected = true; + const Net* net = dynamic_cast(occurrence.getEntity()); + if ( net ) { + unselected = _state->getSelection().remove ( net ); + } + Property* property = occurrence.getProperty ( Selector::getPropertyName() ); if ( property ) { Selector* selector = dynamic_cast(property); - if ( !selector ) + if ( not selector ) throw Error ( "Abnormal property named " + getString(Selector::getPropertyName()) ); selector->detachFrom(this); } _selectionHasChanged = true; - if ( !_delaySelectionChanged ) emit selectionChanged(_selectors); + if ( (_delaySelectionChanged == 0) and unselected ) emit selectionChanged(_selectors); } @@ -2746,13 +2806,13 @@ namespace Hurricane { _state->getSelection().clear (); _unselectAll (); - if ( !--_delaySelectionChanged ) emit selectionChanged(_selectors); + if ( --_delaySelectionChanged == 0 ) emit selectionChanged(_selectors); } void CellWidget::toggleSelection ( Occurrence occurrence ) { - if ( !occurrence.isValid() ) + if ( not occurrence.isValid() ) throw Error ( "Can't select occurrence : invalid occurrence" ); if ( occurrence.getOwnerCell() != getCell() ) @@ -2760,7 +2820,7 @@ namespace Hurricane { Property* property = occurrence.getProperty ( Selector::getPropertyName() ); Selector* selector = NULL; - if ( !property ) { + if ( not property ) { // Net special case. Net* net = dynamic_cast(occurrence.getEntity()); if ( net ) { @@ -2799,41 +2859,41 @@ namespace Hurricane { } - void CellWidget::_select ( const Net* net ) - { - select ( Occurrence(net) ); - forEach ( Component*, component, net->getComponents() ) { - Occurrence occurrence ( *component ); - select ( occurrence ); - } - forEach ( Rubber*, irubber, net->getRubbers() ) { - Occurrence occurrence ( *irubber ); - select ( occurrence ); - } - if ( _state->showSelection() ) _redrawManager.refresh (); - } + // void CellWidget::_select ( const Net* net ) + // { + // //select ( Occurrence(net) ); + // forEach ( Component*, component, net->getComponents() ) { + // Occurrence occurrence ( *component ); + // select ( occurrence ); + // } + // forEach ( Rubber*, irubber, net->getRubbers() ) { + // Occurrence occurrence ( *irubber ); + // select ( occurrence ); + // } + // if ( _state->showSelection() ) _redrawManager.refresh (); + // } - void CellWidget::_unselect ( const Net* net ) - { - unselect ( Occurrence(net) ); - forEach ( Component*, component, net->getComponents() ) { - Occurrence occurrence ( *component ); - unselect ( occurrence ); - } - forEach ( Rubber*, rubber, net->getRubbers() ) { - Occurrence occurrence ( *rubber ); - unselect ( occurrence ); - } - if ( _state->showSelection() ) _redrawManager.refresh (); - } + // void CellWidget::_unselect ( const Net* net ) + // { + // //unselect ( Occurrence(net) ); + // forEach ( Component*, component, net->getComponents() ) { + // Occurrence occurrence ( *component ); + // unselect ( occurrence ); + // } + // forEach ( Rubber*, rubber, net->getRubbers() ) { + // Occurrence occurrence ( *rubber ); + // unselect ( occurrence ); + // } + // if ( _state->showSelection() ) _redrawManager.refresh (); + // } - void CellWidget::_selectOccurrencesUnder ( Box selectArea ) - { - forEach ( Occurrence, ioccurrence, getOccurrencesUnder(selectArea) ) - select ( *ioccurrence ); - } + // void CellWidget::_selectOccurrencesUnder ( Box selectArea ) + // { + // forEach ( Occurrence, ioccurrence, getOccurrencesUnder(selectArea) ) + // select ( *ioccurrence ); + // } void CellWidget::_unselectAll () @@ -2850,6 +2910,7 @@ namespace Hurricane { void CellWidget::cellPreModificate () { openRefreshSession (); + _state->getSelection().invalidate (); _unselectAll (); emit selectionChanged(_selectors); @@ -2871,6 +2932,7 @@ namespace Hurricane { _redrawManager.refresh (); --_delaySelectionChanged; + emit selectionChanged(_selectors); emit cellPostModificated (); diff --git a/hurricane/src/viewer/ControllerWidget.cpp b/hurricane/src/viewer/ControllerWidget.cpp index e660f28e..fb804da5 100644 --- a/hurricane/src/viewer/ControllerWidget.cpp +++ b/hurricane/src/viewer/ControllerWidget.cpp @@ -233,8 +233,8 @@ namespace Hurricane { getCellWidget()->closeRefreshSession (); } 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*)) ); + connect ( _netlistBrowser, SIGNAL(netSelected (Occurrence)), getCellWidget(), SLOT(select (Occurrence)) ); + connect ( _netlistBrowser, SIGNAL(netUnselected(Occurrence)), getCellWidget(), SLOT(unselect(Occurrence)) ); _netlistBrowser->updateSelecteds (); } else { getCellWidget()->setShowSelection ( false ); diff --git a/hurricane/src/viewer/NetlistWidget.cpp b/hurricane/src/viewer/NetlistWidget.cpp index f433f19c..d8df5562 100644 --- a/hurricane/src/viewer/NetlistWidget.cpp +++ b/hurricane/src/viewer/NetlistWidget.cpp @@ -166,10 +166,10 @@ namespace Hurricane { switch ( isel->getAccesses() ) { case 1: break; case 64: - emit netSelected ( isel->getNet() ); + emit netSelected ( Occurrence(isel->getNet()) ); break; case 0: - emit netUnselected ( isel->getNet() ); + emit netUnselected ( Occurrence(isel->getNet()) ); remove = isel; ++isel; _selecteds.erase ( remove ); diff --git a/hurricane/src/viewer/SelectCommand.cpp b/hurricane/src/viewer/SelectCommand.cpp index e91612d8..a160d460 100644 --- a/hurricane/src/viewer/SelectCommand.cpp +++ b/hurricane/src/viewer/SelectCommand.cpp @@ -281,7 +281,7 @@ namespace Hurricane { //_cellWidget->unselectAll (); _cellWidget->selectOccurrencesUnder ( _cellWidget->screenToDbuBox(selectArea) ); - bool somethingSelected = !_cellWidget->getSelectorSet().empty(); + bool somethingSelected = not _cellWidget->getSelectorSet().empty(); if ( _cellWidget->showSelection() != somethingSelected ) _cellWidget->setShowSelection ( somethingSelected ); diff --git a/hurricane/src/viewer/SelectionModel.cpp b/hurricane/src/viewer/SelectionModel.cpp index 036a4fbf..ec113c4f 100644 --- a/hurricane/src/viewer/SelectionModel.cpp +++ b/hurricane/src/viewer/SelectionModel.cpp @@ -54,21 +54,21 @@ namespace Hurricane { SelectionWidget* widget = qobject_cast(QObject::parent()); if ( widget ) return widget->cumulativeSelection(); - - return true; + return false; } void SelectionModel::clear () { _selection.clear (); - emit layoutChanged (); + reset (); } void SelectionModel::setSelection ( const SelectorSet& selection ) { - if ( !isCumulative() ) _selection.clear (); + bool modificated = true; + if ( not isCumulative() ) _selection.clear (); SelectorSet::const_iterator iselector = selection.begin(); vector::iterator iitem; @@ -76,23 +76,54 @@ namespace Hurricane { if ( isCumulative() ) { iitem = find( _selection.begin(), _selection.end(), (*iselector)->getOccurrence() ); if ( iitem != _selection.end() ) { - (*iitem)._flags |= OccurrenceItem::Selected; + (*iitem).setFlags ( OccurrenceItem::Selected ); continue; } } + modificated = true; _selection.push_back ( OccurrenceItem((*iselector)->getOccurrence()) ); } - emit layoutChanged (); + if ( modificated ) reset (); } - Occurrence SelectionModel::toggleSelection ( const QModelIndex& index ) + void SelectionModel::setSelection ( Occurrence occurrence ) + { + bool modificated = false; + if ( not isCumulative() ) _selection.clear (); + + size_t i = 0; + for ( ; i<_selection.size() ; i++ ) { + if ( _selection[i]._occurrence == occurrence ) break; + } + + if ( i >= _selection.size() ) { + modificated = true; + _selection.push_back ( OccurrenceItem(occurrence) ); + } + else _selection[i].setFlags ( OccurrenceItem::Selected ); + + if ( modificated ) reset (); + } + + + Occurrence SelectionModel::toggleSelection ( const QModelIndex& oindex ) + { + if ( oindex.isValid() && ( oindex.row() < (int)_selection.size() ) ) { + _selection[oindex.row()].toggle(); + emit dataChanged ( index(oindex.row(),0), index(oindex.row(),1) ); + + return _selection[oindex.row()]._occurrence; + } + + return Occurrence (); + } + + + Occurrence SelectionModel::getOccurrence ( const QModelIndex& index ) { if ( index.isValid() && ( index.row() < (int)_selection.size() ) ) { - _selection[index.row()].toggle(); - emit layoutChanged (); - return _selection[index.row()]._occurrence; } @@ -105,30 +136,52 @@ namespace Hurricane { bool found = false; size_t i = 0; for ( ; i<_selection.size() ; i++ ) { - if ( !found && (_selection[i]._occurrence == occurrence) ) { + if ( (not found) and (_selection[i]._occurrence == occurrence) ) { found = true; - if ( isCumulative() ) break; + break; } - if ( found && ( i < _selection.size()-1 ) ) - _selection[i] = _selection[i+1]; } - if ( !found ) + if ( not found ) { _selection.push_back ( OccurrenceItem(occurrence) ); - else { - if ( isCumulative() ) _selection[i].toggle (); - else _selection.pop_back (); } + _selection[i].toggle (); - emit layoutChanged (); + //emit dataChanged ( index(i,0), index(i,1) ); } + // void SelectionModel::toggleSelection ( Occurrence occurrence ) + // { + // bool found = false; + // size_t i = 0; + // for ( ; i<_selection.size() ; i++ ) { + // if ( (not found) and (_selection[i]._occurrence == occurrence) ) { + // found = true; + // if ( isCumulative() ) break; + // } + // if ( found and ( i < _selection.size()-1 ) ) + // _selection[i] = _selection[i+1]; + // } + + // if ( not found ) { + // _selection.push_back ( OccurrenceItem(occurrence) ); + // } else { + // if ( isCumulative() ) _selection[i].toggle (); + // else _selection.pop_back (); + // } + + // reset (); + // } + + QVariant SelectionModel::data ( const QModelIndex& index, int role ) const { - static QFont occurrenceFont = Graphics::getFixedFont ( QFont::Normal ); - static QFont entityFont = Graphics::getFixedFont ( QFont::Bold, false ); - static QFontMetrics entityMetrics = QFontMetrics(entityFont); + static QBrush unselectForeground = QBrush ( QColor(255,0,0) ); + static QFont occurrenceFont = Graphics::getFixedFont ( QFont::Normal ); + static QFont unselectFont = Graphics::getFixedFont ( QFont::Normal, true ); + static QFont selectFont = Graphics::getFixedFont ( QFont::Bold, false ); + static QFontMetrics entityMetrics = QFontMetrics(selectFont); if ( !index.isValid() ) return QVariant (); @@ -150,12 +203,17 @@ namespace Hurricane { case 0: return occurrenceFont; case 1: if ( _selection[row]._flags & OccurrenceItem::Selected ) - return entityFont; + return selectFont; default: - return occurrenceFont; + return unselectFont; } } + if ( role == Qt::ForegroundRole ) { + if ( _selection[row]._flags & OccurrenceItem::Selected ) return QVariant(); + return unselectForeground; + } + if ( role == Qt::DisplayRole ) { switch ( index.column() ) { case 0: return getString(_selection[row]._occurrence.getPath().getName()).c_str(); @@ -166,7 +224,7 @@ namespace Hurricane { } - QVariant SelectionModel::headerData ( int section + QVariant SelectionModel::headerData ( int section , Qt::Orientation orientation , int role ) const { diff --git a/hurricane/src/viewer/SelectionWidget.cpp b/hurricane/src/viewer/SelectionWidget.cpp index 1d394956..232e602d 100644 --- a/hurricane/src/viewer/SelectionWidget.cpp +++ b/hurricane/src/viewer/SelectionWidget.cpp @@ -133,6 +133,8 @@ namespace Hurricane { connect ( _view->selectionModel(), SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&)) , this , SLOT (selectCurrent (const QModelIndex&,const QModelIndex&)) ); + //connect ( _baseModel , SIGNAL(dataChanged (const QModelIndex&,const QModelIndex&)) + // , this , SLOT (dataChanged (const QModelIndex&,const QModelIndex&)) ); QAction* toggleAction = new QAction ( tr("&Toggle Selection"), this ); toggleAction->setShortcut ( QKeySequence(tr("T")) ); @@ -229,6 +231,11 @@ namespace Hurricane { } + // void SelectionWidget::dataChanged ( const QModelIndex&, const QModelIndex& ) + // { + // } + + void SelectionWidget::toggleSelection () { toggleSelection ( _view->currentIndex() ); @@ -250,9 +257,7 @@ namespace Hurricane { void SelectionWidget::toggleSelection ( Occurrence occurrence ) { if ( _updateState != InternalEmit ) { - blockAllSignals ( true ); _baseModel->toggleSelection ( occurrence ); - blockAllSignals ( false ); } _updateState = ExternalEmit; } @@ -273,6 +278,10 @@ namespace Hurricane { } + void SelectionWidget::setSelection ( Occurrence occurrence ) + { _baseModel->setSelection ( occurrence ); } + + void SelectionWidget::clear () { _baseModel->clear (); diff --git a/hurricane/src/viewer/SelectorCriterion.cpp b/hurricane/src/viewer/SelectorCriterion.cpp index e70c7259..7e802b39 100644 --- a/hurricane/src/viewer/SelectorCriterion.cpp +++ b/hurricane/src/viewer/SelectorCriterion.cpp @@ -42,6 +42,10 @@ namespace Hurricane { { return NULL; } + const Box& SelectorCriterion::getArea () const + { static const Box empty; return empty; } + + void SelectorCriterion::undoSelection ( CellWidget* cw ) { } @@ -51,7 +55,7 @@ namespace Hurricane { NetSelectorCriterion::NetSelectorCriterion ( const Net* net ) - : _net(net) + : _net (net) , _name(_net->getName()) { } @@ -73,15 +77,11 @@ namespace Hurricane { void NetSelectorCriterion::doSelection ( CellWidget* cw ) - { - cw->_select ( _net ); - } + { cw->select ( Occurrence(_net) ); } void NetSelectorCriterion::undoSelection ( CellWidget* cw ) - { - cw->_unselect ( _net ); - } + { cw->unselect ( Occurrence(_net) ); } string NetSelectorCriterion::_getTypeName () const @@ -125,9 +125,7 @@ namespace Hurricane { void AreaSelectorCriterion::doSelection ( CellWidget* cw ) - { - cw->_selectOccurrencesUnder ( _area ); - } + { cw->selectOccurrencesUnder ( _area ); } string AreaSelectorCriterion::_getTypeName () const diff --git a/hurricane/src/viewer/hurricane/viewer/CellWidget.h b/hurricane/src/viewer/hurricane/viewer/CellWidget.h index 91b4977b..9e69f8d0 100644 --- a/hurricane/src/viewer/hurricane/viewer/CellWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/CellWidget.h @@ -266,19 +266,19 @@ namespace Hurricane { inline void closeRefreshSession (); inline DrawingPlanes& getDrawingPlanes (); inline QPoint& getOffsetVA (); - void select ( const Net* ); + // void select ( const Net* ); void select ( Occurrence ); bool isSelected ( Occurrence ); void selectOccurrencesUnder ( Box selectArea ); - void unselect ( const Net* ); + // void unselect ( const Net* ); void unselect ( Occurrence ); void unselectAll (); void toggleSelection ( Occurrence ); void setShowSelection ( bool state ); void setCumulativeSelection ( bool state ); - void _select ( const Net* ); - void _unselect ( const Net* ); - void _selectOccurrencesUnder ( Box selectArea ); + // void _select ( const Net* ); + // void _unselect ( const Net* ); + // void _selectOccurrencesUnder ( Box selectArea ); void _unselectAll (); inline void addRuler ( const Point&, const Point& ); inline void addRuler ( shared_ptr ); @@ -536,15 +536,16 @@ namespace Hurricane { private: class SelectorCriterions { public: - SelectorCriterions (); - ~SelectorCriterions (); - inline void setCellWidget ( CellWidget* ); - bool add ( const Net* net ); - bool add ( Box area ); - bool remove ( const Net* net ); - void clear (); - void revalidate (); - inline size_t size () const; + SelectorCriterions (); + ~SelectorCriterions (); + inline void setCellWidget ( CellWidget* ); + SelectorCriterion* add ( const Net* net ); + SelectorCriterion* add ( Box area ); + bool remove ( const Net* net ); + void clear (); + void invalidate (); + void revalidate (); + inline size_t size () const; private: CellWidget* _cellWidget; vector _criterions; diff --git a/hurricane/src/viewer/hurricane/viewer/NetlistWidget.h b/hurricane/src/viewer/hurricane/viewer/NetlistWidget.h index a49d3a97..96d0f315 100644 --- a/hurricane/src/viewer/hurricane/viewer/NetlistWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/NetlistWidget.h @@ -149,8 +149,8 @@ namespace Hurricane { void goTo ( int ); void updateSelecteds (); signals: - void netSelected ( const Net* ); - void netUnselected ( const Net* ); + void netSelected ( Occurrence ); + void netUnselected ( Occurrence ); void netFitted ( const Net* ); private slots: void textFilterChanged (); diff --git a/hurricane/src/viewer/hurricane/viewer/SelectionModel.h b/hurricane/src/viewer/hurricane/viewer/SelectionModel.h index b2845007..1ca3829d 100644 --- a/hurricane/src/viewer/hurricane/viewer/SelectionModel.h +++ b/hurricane/src/viewer/hurricane/viewer/SelectionModel.h @@ -47,6 +47,7 @@ namespace Hurricane { enum Flags { Selected=1 }; public: inline OccurrenceItem ( Occurrence occurrence, unsigned int flags=Selected ); + inline void setFlags ( unsigned int ); inline void toggle (); inline bool operator== ( const OccurrenceItem& other ) const; public: @@ -61,6 +62,10 @@ namespace Hurricane { { } + inline void OccurrenceItem::setFlags ( unsigned int flags ) + { _flags |= flags; } + + inline void OccurrenceItem::toggle () { if ( _flags & Selected ) _flags &= ~Selected; @@ -80,7 +85,9 @@ namespace Hurricane { public: SelectionModel ( QObject* parent=NULL ); ~SelectionModel (); + Occurrence getOccurrence ( const QModelIndex& index ); void setSelection ( const SelectorSet& selection ); + void setSelection ( Occurrence occurrence ); void toggleSelection ( Occurrence occurrence ); Occurrence toggleSelection ( const QModelIndex& index ); int rowCount ( const QModelIndex& parent=QModelIndex() ) const; diff --git a/hurricane/src/viewer/hurricane/viewer/SelectionWidget.h b/hurricane/src/viewer/hurricane/viewer/SelectionWidget.h index 562863f0..bbc1d351 100644 --- a/hurricane/src/viewer/hurricane/viewer/SelectionWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/SelectionWidget.h @@ -73,12 +73,14 @@ namespace Hurricane { void setCumulativeSelection ( bool ); void selectCurrent ( const QModelIndex& current, const QModelIndex& ); void setSelection ( const SelectorSet& selection ); + void setSelection ( Occurrence ); void toggleSelection (); void toggleSelection ( Occurrence ); void toggleSelection ( const QModelIndex& ); void inspect (); private slots: void textFilterChanged (); + //void dataChanged ( const QModelIndex&, const QModelIndex& ); protected: void blockAllSignals ( bool ); diff --git a/hurricane/src/viewer/hurricane/viewer/SelectorCriterion.h b/hurricane/src/viewer/hurricane/viewer/SelectorCriterion.h index ae4384e1..83998d83 100644 --- a/hurricane/src/viewer/hurricane/viewer/SelectorCriterion.h +++ b/hurricane/src/viewer/hurricane/viewer/SelectorCriterion.h @@ -41,17 +41,30 @@ namespace Hurricane { class SelectorCriterion { public: + inline SelectorCriterion (); virtual ~SelectorCriterion (); virtual bool isValid ( CellWidget* ) const = 0; + inline bool isEnabled () const; virtual const Net* getNet () const; + virtual const Box& getArea () const; + inline void enable (); + inline void disable (); virtual void doSelection ( CellWidget* ) = 0; virtual void undoSelection ( CellWidget* ); virtual Record* _getRecord () const = 0; virtual string _getString () const = 0; virtual string _getTypeName () const = 0; + private: + bool _isEnabled; }; + inline SelectorCriterion::SelectorCriterion () : _isEnabled(false) { } + inline bool SelectorCriterion::isEnabled () const { return _isEnabled; } + inline void SelectorCriterion::enable () { _isEnabled=true; } + inline void SelectorCriterion::disable () { _isEnabled=false; } + + class NetSelectorCriterion : public SelectorCriterion { public: NetSelectorCriterion ( const Net* ); @@ -73,7 +86,7 @@ namespace Hurricane { public: AreaSelectorCriterion ( const Box& ); virtual ~AreaSelectorCriterion (); - const Box& getArea () const; + virtual const Box& getArea () const; virtual bool isValid ( CellWidget* ) const; virtual void doSelection ( CellWidget* ); virtual Record* _getRecord () const;