diff --git a/crlcore/python/helpers/__init__.py b/crlcore/python/helpers/__init__.py index 2e4858bc..358ee404 100644 --- a/crlcore/python/helpers/__init__.py +++ b/crlcore/python/helpers/__init__.py @@ -101,9 +101,9 @@ def textPythonTrace ( scriptPath=None, e=None, tryContinue=True ): s += ' \"%s\"\n' % (filename) s += ' You should check for simple python errors in this module.\n' - if isinstance(e,helpers.io.ErrorMessage): trace = e.trace() - else: trace = sys.exc_info()[2] - s += textStackTrace( traceback.extract_tb( trace ) ) + if isinstance(e,helpers.io.ErrorMessage): trace = e.trace + else: trace = traceback.extract_tb( sys.exc_info()[2] ) + s += textStackTrace( trace ) if e: s += ' Error was:\n' diff --git a/crlcore/src/ccore/Histogram.cpp b/crlcore/src/ccore/Histogram.cpp index 6019d3ae..768ebff2 100644 --- a/crlcore/src/ccore/Histogram.cpp +++ b/crlcore/src/ccore/Histogram.cpp @@ -230,4 +230,47 @@ namespace CRL { } + Measure::Measure ( const Name& name, Histogram* data ) + : BaseMeasure(name,0) + , _data(data) + { } + + + Measure::~Measure () + { delete _data; } + + + bool Measure::isSimpleData () const + { return false; } + + + Histogram* Measure::getData () const + { return _data; } + + + void Measure::setData ( Histogram* data ) + { _data=data; } + + + std::string Measure::toString () const + { return "Unsupported"; } + + + void Measure::toGnuplot ( std::string basename ) const + { _data->toGnuplot ( basename ); } + + + std::string Measure::_getString () const + { return ""; } + + + Record* Measure::_getRecord () const + { + Record* record = new Record ( _getString() ); + if ( record ) { + record->add ( getSlot("_data",_data) ); + } + return record; + } + } // End of CRL namespace. diff --git a/crlcore/src/ccore/crlcore/Histogram.h b/crlcore/src/ccore/crlcore/Histogram.h index dd273ce7..b8640dea 100644 --- a/crlcore/src/ccore/crlcore/Histogram.h +++ b/crlcore/src/ccore/crlcore/Histogram.h @@ -59,21 +59,21 @@ namespace CRL { // Inline Functions. - inline void Histogram::setMainTitle ( std::string title ) { _mainTitle=title; } + inline void Histogram::setMainTitle ( std::string title ) { _mainTitle=title; } inline void Histogram::setTitle ( std::string title , size_t iset ) { if (iset<_titles .size()) _titles[iset ] = title; } inline void Histogram::setColor ( std::string color , size_t iset ) { if (iset<_colors .size()) _colors[iset ] = color; } inline void Histogram::setIndent ( std::string indent, size_t iset ) { if (iset<_indents.size()) _indents[iset] = indent; } - inline void Histogram::setFileExtension ( std::string extension ) { _fileExtension=extension; } + inline void Histogram::setFileExtension ( std::string extension ) { _fileExtension=extension; } template<> class Measure : public BaseMeasure { public: - inline Measure ( const Name&, Histogram* ); + Measure ( const Name&, Histogram* ); virtual ~Measure (); virtual bool isSimpleData () const; - inline Histogram* getData () const; - inline void setData ( Histogram* ); + Histogram* getData () const; + void setData ( Histogram* ); virtual std::string toString () const; virtual void toGnuplot ( std::string basename ) const; virtual std::string _getString () const; @@ -83,36 +83,6 @@ namespace CRL { }; - inline Measure::Measure ( const Name& name, Histogram* data ) - : BaseMeasure(name,0), _data(data) { } - - Measure::~Measure () { delete _data; } - - bool Measure::isSimpleData () const { return false; } - - inline Histogram* Measure::getData () const { return _data; } - - inline void Measure::setData ( Histogram* data ) { _data=data; } - - std::string Measure::toString () const - { return "Unsupported"; } - - void Measure::toGnuplot ( std::string basename ) const - { _data->toGnuplot ( basename ); } - - std::string Measure::_getString () const - { return ""; } - - Record* Measure::_getRecord () const - { - Record* record = new Record ( _getString() ); - if ( record ) { - record->add ( getSlot("_data",_data) ); - } - return record; - } - - } // CRL namespace. diff --git a/hurricane/src/isobar/PyCell.cpp b/hurricane/src/isobar/PyCell.cpp index 8c5e0c39..e68d8c4f 100644 --- a/hurricane/src/isobar/PyCell.cpp +++ b/hurricane/src/isobar/PyCell.cpp @@ -327,24 +327,40 @@ extern "C" { // --------------------------------------------------------------- // Attribute Method : "PyCell_getLeafInstanceOccurrences()" - static PyObject* PyCell_getLeafInstanceOccurrences(PyCell *self) { + static PyObject* PyCell_getLeafInstanceOccurrences ( PyCell* self) + { cdebug_log(20,0) << "PyCell_getLeafInstanceOccurrences()" << endl; METHOD_HEAD ( "Cell.getLeafInstanceOccurrences()" ) PyOccurrenceCollection* pyOccurrenceCollection = NULL; - HTRY - Occurrences* occurrences = new Occurrences(cell->getLeafInstanceOccurrences()); - - pyOccurrenceCollection = PyObject_NEW(PyOccurrenceCollection, &PyTypeOccurrenceCollection); - if (pyOccurrenceCollection == NULL) { - return NULL; - } - - pyOccurrenceCollection->_object = occurrences; + Occurrences* occurrences = new Occurrences(cell->getLeafInstanceOccurrences()); + + pyOccurrenceCollection = PyObject_NEW(PyOccurrenceCollection, &PyTypeOccurrenceCollection); + if (pyOccurrenceCollection == NULL) return NULL; + + pyOccurrenceCollection->_object = occurrences; + HCATCH + return (PyObject*)pyOccurrenceCollection; + } + + + static PyObject* PyCell_getNonLeafInstanceOccurrences ( PyCell* self) + { + cdebug_log(20,0) << "PyCell_getNonLeafInstanceOccurrences()" << endl; + + METHOD_HEAD ( "Cell.getLeafNonInstanceOccurrences()" ) + + PyOccurrenceCollection* pyOccurrenceCollection = NULL; + HTRY + Occurrences* occurrences = new Occurrences(cell->getNonLeafInstanceOccurrences()); + + pyOccurrenceCollection = PyObject_NEW(PyOccurrenceCollection, &PyTypeOccurrenceCollection); + if (pyOccurrenceCollection == NULL) return NULL; + + pyOccurrenceCollection->_object = occurrences; HCATCH - return (PyObject*)pyOccurrenceCollection; } @@ -722,7 +738,9 @@ extern "C" { , { "getOccurrences" , (PyCFunction)PyCell_getOccurrences , METH_NOARGS , "Returns the collection of all occurrences belonging to the cell." } , { "getOccurrencesUnder" , (PyCFunction)PyCell_getOccurrencesUnder , METH_VARARGS, "Returns the collection of all occurrences belonging to this cell and intersecting the given rectangular area." } , { "getLeafInstanceOccurrences" , (PyCFunction)PyCell_getLeafInstanceOccurrences , METH_NOARGS - , "Returns the collection of all occurrences belonging to the cell." } + , "Returns the collection all terminal instances occurrences." } + , { "getNonLeafInstanceOccurrences" , (PyCFunction)PyCell_getNonLeafInstanceOccurrences , METH_NOARGS + , "Returns the collection of all non-terminal instances occurrences." } , { "getLeafInstanceOccurrencesUnder", (PyCFunction)PyCell_getLeafInstanceOccurrencesUnder, METH_VARARGS , "Returns the collection of all occurrences belonging to this cell and intersecting the given rectangular area." } , { "getReferences" , (PyCFunction)PyCell_getReferences , METH_VARARGS, "Returns the collection of all references belonging to the cell." } diff --git a/hurricane/src/isobar/PyTransformation.cpp b/hurricane/src/isobar/PyTransformation.cpp index 989f183d..2431584e 100644 --- a/hurricane/src/isobar/PyTransformation.cpp +++ b/hurricane/src/isobar/PyTransformation.cpp @@ -520,8 +520,7 @@ extern "C" { // x-------------------------------------------------------------x DirectDeleteMethod(PyTransformation_DeAlloc,PyTransformation) - PyTypeObjectLinkPyTypeNewInit(Transformation) -//PyTypeObjectLinkPyType(Transformation) + PyTypeObjectLinkPyTypeAsValue(Transformation) #else // End of Python Module Code Part. diff --git a/hurricane/src/viewer/CellViewer.cpp b/hurricane/src/viewer/CellViewer.cpp index 33987eb1..9b5c1dca 100644 --- a/hurricane/src/viewer/CellViewer.cpp +++ b/hurricane/src/viewer/CellViewer.cpp @@ -761,6 +761,13 @@ namespace Hurricane { } + void CellViewer::setCumulativeSelection ( bool state ) + { + _updateState = InternalEmit; + _cellWidget->setCumulativeSelection ( state ); + } + + void CellViewer::raiseToolInterrupt () { _toolInterrupt = true; } diff --git a/hurricane/src/viewer/CellWidget.cpp b/hurricane/src/viewer/CellWidget.cpp index b2f79bee..8ab46913 100644 --- a/hurricane/src/viewer/CellWidget.cpp +++ b/hurricane/src/viewer/CellWidget.cpp @@ -1176,6 +1176,13 @@ namespace Hurricane { } + void CellWidget::detach ( Selector* selector ) + { + getSelectorSet().erase( selector ); + emit unlinkSelector( selector ); + } + + void CellWidget::bindCommand ( Command* command ) { for ( size_t i=0 ; i<_commands.size() ; i++ ) @@ -1492,28 +1499,29 @@ namespace Hurricane { _drawingPlanes.painter().setBackground ( Graphics::getBrush("background") ); _drawingPlanes.painter().setClipRect ( redrawArea ); - if ( getCell() ) { - Box redrawBox = screenToDbuBox ( redrawArea ); + if (getCell()) { + Box redrawBox = screenToDbuBox( redrawArea ); SelectorSet::iterator iselector; - forEach ( BasicLayer*, basicLayer, _technology->getBasicLayers() ) { + for ( BasicLayer* basicLayer : _technology->getBasicLayers() ) { //if ( !isDrawableLayer(basicLayer->getName()) ) continue; _drawingPlanes.setPen ( Graphics::getPen (basicLayer->getName()) ); _drawingPlanes.setBrush ( Graphics::getBrush(basicLayer->getName()) ); - iselector = _selectors.begin(); - for ( ; iselector != _selectors.end() ; iselector++ ) { - Occurrence occurrence = (*iselector)->getOccurrence(); - Component* component = dynamic_cast(occurrence.getEntity()); + for ( Selector* selector : _selectors ) { + if (not selector->isSelected(this)) continue; + + Occurrence occurrence = selector->getOccurrence(); + Component* component = dynamic_cast( occurrence.getEntity() ); - if ( component == NULL ) continue; - if ( not component->getLayer() ) continue; - if ( not component->getLayer()->contains(*basicLayer) ) continue; + if (not component) continue; + if (not component->getLayer()) continue; + if (not component->getLayer()->contains(basicLayer)) continue; Transformation transformation = occurrence.getPath().getTransformation(); _drawingQuery.drawGo ( dynamic_cast(occurrence.getEntity()) - , *basicLayer + , basicLayer , redrawBox , transformation ); @@ -1523,52 +1531,55 @@ namespace Hurricane { _drawingPlanes.setPen ( Graphics::getPen ("boundaries") ); _drawingPlanes.setBrush ( Graphics::getBrush("boundaries") ); - iselector = _selectors.begin(); - for ( ; iselector != _selectors.end() ; iselector++ ) { - Occurrence occurrence = (*iselector)->getOccurrence(); + for ( Selector* selector : _selectors ) { + if (not selector->isSelected(this)) continue; + + Occurrence occurrence = selector->getOccurrence(); Instance* instance = dynamic_cast(occurrence.getEntity()); - if ( instance ) { + if (instance) { Transformation transformation = occurrence.getPath().getTransformation().getTransformation(instance->getTransformation()); - _drawingQuery.drawMasterCell ( instance->getMasterCell(), transformation ); + _drawingQuery.drawMasterCell( instance->getMasterCell(), transformation ); } } - _drawingPlanes.setPen ( Graphics::getPen ("rubber") ); - _drawingPlanes.setBrush ( Graphics::getBrush("rubber") ); + _drawingPlanes.setPen ( Graphics::getPen ("rubber") ); + _drawingPlanes.setBrush( Graphics::getBrush("rubber") ); - iselector = _selectors.begin(); - for ( ; iselector != _selectors.end() ; iselector++ ) { - Occurrence occurrence = (*iselector)->getOccurrence(); + for ( Selector* selector : _selectors ) { + if (not selector->isSelected(this)) continue; + + Occurrence occurrence = selector->getOccurrence(); Rubber* rubber = dynamic_cast(occurrence.getEntity()); - if ( rubber == NULL ) continue; + if (not rubber) continue; Transformation transformation = occurrence.getPath().getTransformation(); - _drawingQuery.drawRubber ( rubber, redrawBox, transformation ); + _drawingQuery.drawRubber( rubber, redrawBox, transformation ); } Name extensionName = ""; - iselector = _selectors.begin(); - for ( ; iselector != _selectors.end() ; iselector++ ) { - Occurrence occurrence = (*iselector)->getOccurrence(); + for ( Selector* selector : _selectors ) { + if (not selector->isSelected(this)) continue; + + Occurrence occurrence = selector->getOccurrence(); ExtensionGo* eGo = dynamic_cast(occurrence.getEntity()); - if ( eGo == NULL ) continue; + if (not eGo) continue; Transformation transformation = occurrence.getPath().getTransformation(); - if ( eGo->getName() != extensionName ) { + if (eGo->getName() != extensionName) { extensionName = eGo->getName(); - _drawingQuery.setDrawExtensionGo ( extensionName ); + _drawingQuery.setDrawExtensionGo( extensionName ); } - if ( isDrawable(extensionName) ) - _drawingQuery.drawExtensionGo ( this, eGo, NULL, redrawBox, transformation ); + if (isDrawable(extensionName)) + _drawingQuery.drawExtensionGo( this, eGo, NULL, redrawBox, transformation ); } } - _drawingPlanes.end (); + _drawingPlanes.end(); _selectionHasChanged = false; } @@ -2589,9 +2600,9 @@ namespace Hurricane { void CellWidget::selectOccurrencesUnder ( Box selectArea ) { if ( (++_delaySelectionChanged == 1) and not _state->cumulativeSelection() ) { - openRefreshSession (); - unselectAll (); - closeRefreshSession (); + openRefreshSession(); + unselectAll(); + closeRefreshSession(); } bool selected = true; @@ -2603,12 +2614,12 @@ namespace Hurricane { // cerr << "Selecting: " << occurrence << endl; //} - forEach ( Occurrence, ioccurrence, getOccurrencesUnder(selectArea) ) - select ( *ioccurrence ); + for ( Occurrence occurrence : getOccurrencesUnder(selectArea) ) + select( occurrence ); } else selected = false; - if ( (--_delaySelectionChanged == 0) and selected ) emit selectionChanged(_selectors); + if ( (--_delaySelectionChanged == 0) and selected ) emit selectionChanged( _selectors ); } @@ -2620,29 +2631,29 @@ namespace Hurricane { closeRefreshSession (); } - if ( not occurrence.isValid() ) + if (not occurrence.isValid()) throw Error ( "Can't select occurrence : invalid occurrence" ); - if ( occurrence.getOwnerCell() != getCell() ) { - string s1 = Graphics::toHtml ( getString(getCell()) ); - string s2 = Graphics::toHtml ( getString(occurrence.getOwnerCell()) ); + if (occurrence.getOwnerCell() != getCell()) { + string s1 = Graphics::toHtml( getString(getCell()) ); + string s2 = Graphics::toHtml( getString(occurrence.getOwnerCell()) ); throw Error ( "Can't select occurrence : incompatible occurrence %s vs. %s" , s1.c_str(), s2.c_str() ); } bool selected = true; - const Net* net = dynamic_cast(occurrence.getEntity()); + const Net* net = dynamic_cast( occurrence.getEntity() ); if ( net ) { - SelectorCriterion* criterion = _state->getSelection().add ( 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 ); + criterion->enable(); + for ( Component* component : net->getComponents() ) { + Occurrence occurrence ( component ); + select( occurrence ); } - forEach ( Rubber*, irubber, net->getRubbers() ) { - Occurrence occurrence ( *irubber ); - select ( occurrence ); + for ( Rubber* rubber : net->getRubbers() ) { + Occurrence occurrence ( rubber ); + select( occurrence ); } } else selected = false; @@ -2654,13 +2665,13 @@ namespace Hurricane { selector = Selector::create ( occurrence ); else { selector = dynamic_cast(property); - if ( not selector ) + if (not selector) throw Error ( "Abnormal property named " + getString(Selector::getPropertyName()) ); } - selector->attachTo(this); + selector->attachTo( this ); - setShowSelection ( true ); + //setShowSelection( true ); _selectionHasChanged = true; if ( (--_delaySelectionChanged == 0) and selected ) { @@ -2720,50 +2731,54 @@ namespace Hurricane { void CellWidget::toggleSelection ( Occurrence occurrence ) { - if ( not occurrence.isValid() ) - throw Error ( "Can't select occurrence : invalid occurrence" ); + if (not occurrence.isValid()) + throw Error( "CellWidget::toggleSelection(): Unable to select invalid occurrence." ); if ( occurrence.getOwnerCell() != getCell() ) - throw Error ( "Can't select occurrence : incompatible occurrence" ); + throw Error( "CellWidget::toggleSelection(): Occurrence do not belong to the loaded cell." ); - Property* property = occurrence.getProperty ( Selector::getPropertyName() ); + Property* property = occurrence.getProperty( Selector::getPropertyName() ); Selector* selector = NULL; - if ( not property ) { + if (not property) { // Net special case. - Net* net = dynamic_cast(occurrence.getEntity()); - if ( net ) { - if ( occurrence.getPath().isEmpty() ) { - select ( net ); + Net* net = dynamic_cast( occurrence.getEntity() ); + if (net) { + if (occurrence.getPath().isEmpty()) { + select( net ); } else { - cerr << "[UNIMPLEMENTED] Selection of " << occurrence << endl; + cerr << "CellWidget::toggleSelection(): Selection of " << occurrence + << " is not implemented." << endl; } } else { - selector = Selector::create ( occurrence ); - selector->attachTo ( this ); - setShowSelection ( true ); + selector = Selector::create( occurrence ); + selector->attachTo( this ); + setShowSelection( true ); } } else { - selector = dynamic_cast(property); - if ( !selector ) - throw Error ( "Abnormal property named " + getString(Selector::getPropertyName()) ); + selector = dynamic_cast( property ); + if (not selector) + throw Error( "CellWidget::toggleSelection(): Abnormal property named " + + getString(Selector::getPropertyName()) + " in place of Selector." ); // Net special case. - Net* net = dynamic_cast(occurrence.getEntity()); - if ( net ) { - if ( occurrence.getPath().isEmpty() ) { - unselect ( net ); + Net* net = dynamic_cast( occurrence.getEntity() ); + if (net) { + if (occurrence.getPath().isEmpty()) { + unselect( net ); } else { - cerr << "[UNIMPLEMENTED] Selection of " << occurrence << endl; + cerr << "CellWidget::toggleSelection(): Selection of " << occurrence + << " is not implemented." << endl; } } else { - selector->detachFrom ( this ); + if (not selector->isToggleByController(this)) + selector->detachFrom( this ); } } _selectionHasChanged = true; - if ( _state->showSelection() ) _redrawManager.refresh (); + if (_state->showSelection()) _redrawManager.refresh (); - emit selectionToggled ( occurrence ); + emit selectionToggled( selector ); } @@ -2807,11 +2822,11 @@ namespace Hurricane { void CellWidget::_unselectAll () { SelectorSet::iterator iselector; - while ( !_selectors.empty() ) - (*_selectors.begin())->detachFrom ( this ); + while ( not _selectors.empty() ) + (*_selectors.begin())->detachFrom( this ); - if ( !_selectionHasChanged ) _selectionHasChanged = true; - if ( _state->showSelection() ) _redrawManager.refresh (); + if (not _selectionHasChanged) _selectionHasChanged = true; + if (_state->showSelection()) _redrawManager.refresh (); } diff --git a/hurricane/src/viewer/PyCellViewer.cpp b/hurricane/src/viewer/PyCellViewer.cpp index f7bd4300..136b5c98 100644 --- a/hurricane/src/viewer/PyCellViewer.cpp +++ b/hurricane/src/viewer/PyCellViewer.cpp @@ -276,6 +276,9 @@ extern "C" { } + DirectSetBoolAttribute(PyCellViewer_setShowSelection,setShowSelection,PyCellViewer,CellViewer) + + // --------------------------------------------------------------- // PyCellViewer Attribute Method table. @@ -298,6 +301,8 @@ extern "C" { , "Allow/disallow anonymous nets to be selectables." } , { "setLayerVisible" , (PyCFunction)PyCellViewer_setLayerVisible , METH_VARARGS , "Sets the visibility state of the layer ." } + , { "setShowSelection" , (PyCFunction)PyCellViewer_setShowSelection , METH_VARARGS + , "Display/hide the selection." } , { "fit" , (PyCFunction)PyCellViewer_fit , METH_NOARGS , "Triggers a full redraw of the visible area." } , { "refresh" , (PyCFunction)PyCellViewer_refresh , METH_NOARGS diff --git a/hurricane/src/viewer/SelectionModel.cpp b/hurricane/src/viewer/SelectionModel.cpp index ae0a487d..cc5dafbe 100644 --- a/hurricane/src/viewer/SelectionModel.cpp +++ b/hurricane/src/viewer/SelectionModel.cpp @@ -30,7 +30,8 @@ namespace Hurricane { SelectionModel::SelectionModel ( QObject* parent ) : QAbstractTableModel(parent) - , _selection() + , _cellWidget(NULL) + , _selection () { } @@ -41,101 +42,121 @@ namespace Hurricane { bool SelectionModel::isCumulative () const { SelectionWidget* widget = qobject_cast(QObject::parent()); - if ( widget ) + if (widget) return widget->cumulativeSelection(); return false; } + void SelectionModel::setCellWidget ( CellWidget* w ) + { + if (_cellWidget) { + disconnect( _cellWidget, 0, this , 0 ); + disconnect( this , 0, _cellWidget, 0 ); + } + + _cellWidget = w; + if (not _cellWidget) return; + + connect( _cellWidget, SIGNAL(unlinkSelector(Selector*)), this, SLOT(unlink(Selector*)) ); + connect( _cellWidget, SIGNAL(cellPreModificated()) , this, SLOT(clear()) ); + } + + void SelectionModel::clear () { beginResetModel(); + for ( Selector* selector : _selection ) { + selector->resetFlags( _cellWidget, Selector::InModel|Selector::Selected ); + } _selection.clear(); endResetModel(); } + void SelectionModel::unlink ( Selector* selector ) + { + beginResetModel(); + for ( auto it=_selection.begin() ; it != _selection.end() ; ++it ) { + if ((*it) == selector) { + _selection.erase( it ); + break; + } + } + endResetModel(); + } + + void SelectionModel::setSelection ( const SelectorSet& selection ) { + if (not _cellWidget) return; + beginResetModel(); - if ( not isCumulative() ) _selection.clear (); + if (not isCumulative()) _selection.clear (); - SelectorSet::const_iterator iselector = selection.begin(); - vector::iterator iitem; - for ( ; iselector != selection.end() ; iselector++ ) { - if ( isCumulative() ) { - iitem = find( _selection.begin(), _selection.end(), (*iselector)->getOccurrence() ); - if ( iitem != _selection.end() ) { - (*iitem).setFlags ( OccurrenceItem::Selected ); - continue; - } + for ( Selector* selector : selection ) { + if (not selector->isInModel(_cellWidget)) { + _selection.push_back( selector ); } - _selection.push_back ( OccurrenceItem((*iselector)->getOccurrence()) ); + selector->setFlags( _cellWidget, Selector::InModel|Selector::Selected ); } endResetModel(); } - void SelectionModel::setSelection ( Occurrence occurrence ) + void SelectionModel::setSelection ( Selector* selector ) { + if (not _cellWidget) return; + 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() ) { + if (not isCumulative()) { modificated = true; beginResetModel (); - _selection.push_back ( OccurrenceItem(occurrence) ); - } - else _selection[i].setFlags ( OccurrenceItem::Selected ); - - if ( modificated ) endResetModel (); - } - - - 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; + _selection.clear (); } - return Occurrence (); - } - - - Occurrence SelectionModel::getOccurrence ( const QModelIndex& index ) - { - if ( index.isValid() && ( index.row() < (int)_selection.size() ) ) { - return _selection[index.row()]._occurrence; - } - - return Occurrence (); - } - - - 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; - break; + if (not selector->isInModel(_cellWidget)) { + if (not modificated) { + modificated = true; + beginResetModel (); } + _selection.push_back( selector ); + } + selector->setFlags( _cellWidget, Selector::InModel|Selector::Selected ); + + if (modificated) endResetModel(); + } + + + Selector* SelectionModel::toggleSelection ( const QModelIndex& oindex ) + { + if ( oindex.isValid() and (oindex.row() < (int)_selection.size()) ) { + _selection[oindex.row()]->toggle( _cellWidget ); + emit dataChanged( index(oindex.row(),0), index(oindex.row(),1) ); + + return _selection[ oindex.row() ]; } - if ( not found ) { - _selection.push_back ( OccurrenceItem(occurrence) ); + return NULL; + } + + + Selector* SelectionModel::getSelector ( const QModelIndex& index ) + { + if ( index.isValid() and (index.row() < (int)_selection.size()) ) { + return _selection[ index.row() ]; } - _selection[i].toggle (); + + return NULL; + } + + + void SelectionModel::toggleSelection ( Selector* selector ) + { + if (not _cellWidget) return; + + selector->toggle( _cellWidget ); //emit dataChanged ( index(i,0), index(i,1) ); } @@ -167,31 +188,31 @@ namespace Hurricane { QVariant SelectionModel::data ( const QModelIndex& index, int role ) const { - 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); + 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 (); + if (not index.isValid()) return QVariant(); - if ( role == Qt::SizeHintRole ) { - switch (index.column()) { + if (role == Qt::SizeHintRole) { + switch ( index.column() ) { case 0: return 200; default: - if ( index.row() > (int)_selection.size() ) return 0; - return entityMetrics.width(getString(_selection[index.row()]._occurrence.getEntity()).c_str()); + if (index.row() > (int)_selection.size()) return 0; + return entityMetrics.width(getString( _selection[index.row()]->getEntity() ).c_str()); } } int row = index.row (); - if ( row >= (int)_selection.size() ) return QVariant (); + if (row >= (int)_selection.size()) return QVariant (); - if ( role == Qt::FontRole ) { + if (role == Qt::FontRole) { switch (index.column()) { case 0: return occurrenceFont; case 1: - if ( _selection[row]._flags & OccurrenceItem::Selected ) + if (_selection[row]->isSelected(_cellWidget)) return selectFont; default: return unselectFont; @@ -199,14 +220,14 @@ namespace Hurricane { } if ( role == Qt::ForegroundRole ) { - if ( _selection[row]._flags & OccurrenceItem::Selected ) return QVariant(); + if (_selection[row]->isSelected(_cellWidget)) return QVariant(); return unselectForeground; } - if ( role == Qt::DisplayRole ) { + if (role == Qt::DisplayRole) { switch ( index.column() ) { - case 0: return getString(_selection[row]._occurrence.getPath().getName()).c_str(); - case 1: return getString(_selection[row]._occurrence.getEntity()).c_str(); + case 0: return getString(_selection[row]->getPath().getName()).c_str(); + case 1: return getString(_selection[row]->getEntity()).c_str(); } } return QVariant(); @@ -214,8 +235,8 @@ namespace Hurricane { QVariant SelectionModel::headerData ( int section - , Qt::Orientation orientation - , int role ) const + , Qt::Orientation orientation + , int role ) const { if ( orientation == Qt::Vertical ) return QVariant(); @@ -235,9 +256,7 @@ namespace Hurricane { int SelectionModel::rowCount ( const QModelIndex& parent ) const - { - return _selection.size(); - } + { return _selection.size(); } int SelectionModel::columnCount ( const QModelIndex& parent ) const @@ -246,11 +265,10 @@ namespace Hurricane { } - const Occurrence SelectionModel::getOccurrence ( int row ) + const Selector* SelectionModel::getSelector ( int row ) { - if ( row >= (int)_selection.size() ) return Occurrence(); - - return _selection[row]._occurrence; + if (row >= (int)_selection.size()) return NULL; + return _selection[ row ]; } diff --git a/hurricane/src/viewer/SelectionWidget.cpp b/hurricane/src/viewer/SelectionWidget.cpp index cc4435c6..360edf4f 100644 --- a/hurricane/src/viewer/SelectionWidget.cpp +++ b/hurricane/src/viewer/SelectionWidget.cpp @@ -146,20 +146,21 @@ namespace Hurricane { void SelectionWidget::setCellWidget ( CellWidget* cw ) { - if ( _cellWidget ) { - disconnect ( _cellWidget, 0, this , 0 ); - disconnect ( this , 0, _cellWidget, 0 ); + if (_cellWidget) { + disconnect( _cellWidget, 0, this , 0 ); + disconnect( this , 0, _cellWidget, 0 ); } _cellWidget = cw; - if ( !_cellWidget ) return; + _baseModel->setCellWidget( cw ); + if (not _cellWidget) return; - connect ( _cellWidget, SIGNAL(selectionModeChanged()), this, SLOT(changeSelectionMode()) ); + connect( _cellWidget, SIGNAL(selectionModeChanged()), this, SLOT(changeSelectionMode()) ); - connect ( _cellWidget, SIGNAL(selectionChanged(const SelectorSet&)) - , this , SLOT (setSelection (const SelectorSet&)) ); + connect( _cellWidget, SIGNAL(selectionChanged(const SelectorSet&)) + , this , SLOT (setSelection (const SelectorSet&)) ); - connect ( _cellWidget, SIGNAL(selectionToggled(Occurrence)), this, SLOT(toggleSelection(Occurrence)) ); + connect( _cellWidget, SIGNAL(selectionToggled(Selector*)), this , SLOT(toggleSelection(Selector*)) ); _updateState = ExternalEmit; changeSelectionMode (); @@ -234,20 +235,20 @@ namespace Hurricane { void SelectionWidget::toggleSelection ( const QModelIndex& index ) { - if ( index.isValid() ) { - Occurrence occurrence = _baseModel->toggleSelection ( _sortModel->mapToSource(index) ); - if ( occurrence.isValid() ) { + if (index.isValid()) { + Selector* selector = _baseModel->toggleSelection( _sortModel->mapToSource(index) ); + if (selector) { _updateState = InternalEmit; - _cellWidget->toggleSelection ( occurrence ); + _cellWidget->toggleSelection ( selector->getOccurrence() ); } } } - void SelectionWidget::toggleSelection ( Occurrence occurrence ) + void SelectionWidget::toggleSelection ( Selector* selector ) { - if ( _updateState != InternalEmit ) { - _baseModel->toggleSelection ( occurrence ); + if (_updateState != InternalEmit) { + _baseModel->toggleSelection( selector ); } _updateState = ExternalEmit; } @@ -268,15 +269,15 @@ namespace Hurricane { } - void SelectionWidget::setSelection ( Occurrence occurrence ) - { _baseModel->setSelection ( occurrence ); } + void SelectionWidget::setSelection ( Selector* selector ) + { _baseModel->setSelection( selector ); } void SelectionWidget::clear () - { - _baseModel->clear (); - _view->selectionModel()->clearSelection (); - if ( _cellWidget ) + { + _baseModel->clear(); + _view->selectionModel()->clearSelection(); + if (_cellWidget) _cellWidget->unselectAll(); } @@ -295,8 +296,8 @@ namespace Hurricane { void SelectionWidget::inspect ( const QModelIndex& index ) { - if ( index.isValid() ) { - Occurrence occurrence = _baseModel->getOccurrence ( _sortModel->mapToSource(index).row() ); + if (index.isValid()) { + Occurrence occurrence = _baseModel->getSelector( _sortModel->mapToSource(index).row() )->getOccurrence(); emit inspect ( occurrence ); } else emit inspect ( NULL ); diff --git a/hurricane/src/viewer/Selector.cpp b/hurricane/src/viewer/Selector.cpp index 728158b5..dfdb010f 100644 --- a/hurricane/src/viewer/Selector.cpp +++ b/hurricane/src/viewer/Selector.cpp @@ -40,36 +40,36 @@ namespace Hurricane { const Entity* lhsEntity = lhs->getOccurrence().getEntity(); const Entity* rhsEntity = rhs->getOccurrence().getEntity(); - const Component* lhsComponent = dynamic_cast ( lhsEntity ); - const Component* rhsComponent = dynamic_cast ( rhsEntity ); - if ( lhsComponent && rhsComponent ) return lhs < rhs; // lhs & rhs are Components. - if ( lhsComponent && !rhsComponent ) return true; // lhs only is an Component. - if ( !lhsComponent && rhsComponent ) return false; // rhs only is an Component. + const Component* lhsComponent = dynamic_cast( lhsEntity ); + const Component* rhsComponent = dynamic_cast( rhsEntity ); + if ( lhsComponent and rhsComponent) return lhs < rhs; // lhs & rhs are Components. + if ( lhsComponent and not rhsComponent) return true; // lhs only is an Component. + if (not lhsComponent and rhsComponent) return false; // rhs only is an Component. - const Instance* lhsInstance = dynamic_cast ( lhsEntity ); - const Instance* rhsInstance = dynamic_cast ( rhsEntity ); + const Instance* lhsInstance = dynamic_cast( lhsEntity ); + const Instance* rhsInstance = dynamic_cast( rhsEntity ); //cerr << "Instance LHS: " << (void*)lhsInstance << " RHS: " << (void*)rhsInstance << endl; - if ( lhsInstance && rhsInstance ) return lhs < rhs; // lhs & rhs are Instances. - if ( lhsInstance && !rhsInstance ) return true; // lhs only is an Instance. - if ( !lhsInstance && rhsInstance ) return false; // rhs only is an Instance. + if ( lhsInstance and rhsInstance) return lhs < rhs; // lhs & rhs are Instances. + if ( lhsInstance and not rhsInstance) return true; // lhs only is an Instance. + if (not lhsInstance and rhsInstance) return false; // rhs only is an Instance. - const Rubber* lhsRubber = dynamic_cast ( lhsEntity ); - const Rubber* rhsRubber = dynamic_cast ( rhsEntity ); - if ( lhsRubber && rhsRubber ) return lhs < rhs; // lhs & rhs are Rubbers. - if ( lhsRubber && !rhsRubber ) return true; // lhs only is an Rubber. - if ( !lhsRubber && rhsRubber ) return false; // rhs only is an Rubber. + const Rubber* lhsRubber = dynamic_cast( lhsEntity ); + const Rubber* rhsRubber = dynamic_cast( rhsEntity ); + if ( lhsRubber and rhsRubber) return lhs < rhs; // lhs & rhs are Rubbers. + if ( lhsRubber and not rhsRubber) return true; // lhs only is an Rubber. + if (not lhsRubber and rhsRubber) return false; // rhs only is an Rubber. - const ExtensionGo* lhsExtensionGo = dynamic_cast ( lhsEntity ); - const ExtensionGo* rhsExtensionGo = dynamic_cast ( rhsEntity ); - if ( lhsExtensionGo && rhsExtensionGo ) { // lhs & rhs are ExtensionGos. - if ( lhsExtensionGo->getName() == rhsExtensionGo->getName() ) + const ExtensionGo* lhsExtensionGo = dynamic_cast( lhsEntity ); + const ExtensionGo* rhsExtensionGo = dynamic_cast( rhsEntity ); + if (lhsExtensionGo and rhsExtensionGo) { // lhs & rhs are ExtensionGos. + if (lhsExtensionGo->getName() == rhsExtensionGo->getName()) return lhs < rhs; return lhsExtensionGo->getName() < rhsExtensionGo->getName(); } - if ( lhsExtensionGo && !rhsExtensionGo ) return true; // lhs only is an ExtensionGo. - if ( !lhsExtensionGo && rhsExtensionGo ) return false; // rhs only is an ExtensionGo. + if ( lhsExtensionGo and not rhsExtensionGo) return true; // lhs only is an ExtensionGo. + if (not lhsExtensionGo and rhsExtensionGo) return false; // rhs only is an ExtensionGo. return lhs < rhs; } @@ -79,7 +79,7 @@ namespace Hurricane { // Class : "Hurricane::Selector". - const Name Selector::_propertyName = _PName ( "Selector" ); + const Name Selector::_propertyName = Name( "Selector" ); Selector::Selector () : PrivateProperty() @@ -88,10 +88,10 @@ namespace Hurricane { string Selector::_getTypeName () const - { return _TName("Selector"); } + { return "Selector"; } - const Name& Selector::getPropertyName () + const Name& Selector::getPropertyName () { return _propertyName; } @@ -99,30 +99,18 @@ namespace Hurricane { { return Selector::getPropertyName(); } - Occurrence Selector::getOccurrence () const - { - DBo* owner = getOwner(); - if (!owner) return Occurrence(); - - Quark* quark = dynamic_cast(owner); - assert ( quark ); - - return quark->getOccurrence(); - } - - Selector* Selector::create ( Occurrence& occurrence ) { - if ( !occurrence.isValid() ) - throw Error ( "Can't create " + _TName("Selector") + " : invalid occurrence" ); + if (not occurrence.isValid()) + throw Error( "Selector::create(): Can't create Selector, invalid occurrence" ); - if ( occurrence.getProperty(Selector::getPropertyName()) ) - throw Error ( "Can't create " + _TName("Selector") + " : already exists" ); + if (occurrence.getProperty(Selector::getPropertyName())) + throw Error( "Selector::create(): Can't create Selector, already exists" ); Selector* selector = new Selector(); selector->_postCreate(); - occurrence.put ( selector ); + occurrence.put( selector ); return selector; } @@ -130,61 +118,146 @@ namespace Hurricane { void Selector::_preDestroy() { - set::iterator it = _cellWidgets.begin (); - for ( ; it != _cellWidgets.end() ; it++ ) - detachFrom ( *it, true ); - + for ( auto iwidget : _cellWidgets ) detachFrom( iwidget.first, true ); PrivateProperty::_preDestroy(); } string Selector::_getString() const { - return "<" + _TName("Selector") + " " + getString(getOccurrence()) + ">"; + return ""; } Record* Selector::_getRecord () const { Record* record = PrivateProperty::_getRecord(); - if ( record ) + if (record) record->add(getSlot("_cellWidgets", &_cellWidgets)); return record; } + const Quark* Selector::getQuark () const + { + const Quark* owner = dynamic_cast( getOwner() ); + if (not owner) { + cerr << Error( "Selector::getQuark(): Selector Property is not owned by a Quark." ) << endl; + return NULL; + } + return owner; + } + + + Occurrence Selector::getOccurrence () const + { + const Quark* quark = getQuark(); + return (quark) ? quark->getOccurrence() : Occurrence(); + } + + + Path Selector::getPath () const + { + const Quark* quark = getQuark(); + return (quark) ? quark->getOccurrence().getPath() : Path(); + } + + + Entity* Selector::getEntity () const + { + const Quark* quark = getQuark(); + return (quark) ? quark->getOccurrence().getEntity() : NULL; + } + + + bool Selector::isAttachedTo ( CellWidget* widget ) const { - if ( !widget ) - throw Error ( "Can't attach selector : null CellWidget." ); + if (not widget) + throw Error( "Selector::isAttachedTo(): NULL widget argument." ); - if ( _cellWidgets.find(widget) == _cellWidgets.end() ) - return false; - - return true; + return (_cellWidgets.find(widget) != _cellWidgets.end()); } void Selector::attachTo ( CellWidget* widget ) { - if ( !widget ) - throw Error ( "Can't attach selector : null CellWidget." ); + if (not widget) + throw Error( "Selector::attachTo(): Cannot attach, NULL widget argument." ); - _cellWidgets.insert ( widget ); - widget->getSelectorSet().insert ( this ); + _cellWidgets.insert( make_pair(widget,0) ); + widget->getSelectorSet().insert( this ); } void Selector::detachFrom ( CellWidget* widget, bool inDeletion ) { - if ( !widget ) - throw Error ( "Can't detach selector : null CellWidget" ); + if (not widget) + throw Error( "Selector::detachFrom(): Cannot detach, NULL widget argument." ); - widget->getSelectorSet().erase ( this ); - _cellWidgets.erase ( widget ); + widget->detach( this ); + _cellWidgets.erase( widget ); - if ( !inDeletion && _cellWidgets.empty() ) destroy(); + if (not inDeletion and _cellWidgets.empty()) destroy(); + } + + + uint32_t Selector::getFlags ( CellWidget* widget ) const + { + map::const_iterator iw = _cellWidgets.find( widget ); + if (iw == _cellWidgets.end()) { + cerr << Error( "Selector::getFlags(): %s is not attached to %s." + , getString(this).c_str() + , getString(widget).c_str() + ) << endl; + return 0; + } + return (*iw).second; + } + + + void Selector::setFlags ( CellWidget* widget , uint32_t flags ) + { + map::iterator iw = _cellWidgets.find( widget ); + if (iw == _cellWidgets.end()) { + cerr << Error( "Selector::setFlags(): %s is not attached to %s." + , getString(this).c_str() + , getString(widget).c_str() + ) << endl; + return; + } + (*iw).second |= flags; + } + + + void Selector::resetFlags ( CellWidget* widget , uint32_t flags ) + { + map::iterator iw = _cellWidgets.find( widget ); + if (iw == _cellWidgets.end()) { + cerr << Error( "Selector::resetFlags(): %s is not attached to %s." + , getString(this).c_str() + , getString(widget).c_str() + ) << endl; + return; + } + (*iw).second &= ~flags; + } + + + void Selector::toggle ( CellWidget* widget ) + { + map::iterator iw = _cellWidgets.find( widget ); + if (iw == _cellWidgets.end()) { + cerr << Error( "Selector::toggle(): %s is not attached to %s." + , getString(this).c_str() + , getString(widget).c_str() + ) << endl; + return; + } + if ((*iw).second & Selected) (*iw).second &= ~Selected; + else (*iw).second |= Selected; + (*iw).second |= ToggledByController; } diff --git a/hurricane/src/viewer/hurricane/viewer/CellViewer.h b/hurricane/src/viewer/hurricane/viewer/CellViewer.h index 6ad78ffe..2a65a28a 100644 --- a/hurricane/src/viewer/hurricane/viewer/CellViewer.h +++ b/hurricane/src/viewer/hurricane/viewer/CellViewer.h @@ -141,6 +141,7 @@ namespace Hurricane { void doGoto (); void changeSelectionMode (); void setShowSelection ( bool ); + void setCumulativeSelection ( bool ); void setState ( shared_ptr& ); void removeHistory ( Cell* ); void openHistoryCell (); diff --git a/hurricane/src/viewer/hurricane/viewer/CellWidget.h b/hurricane/src/viewer/hurricane/viewer/CellWidget.h index 507af8be..6d26f7be 100644 --- a/hurricane/src/viewer/hurricane/viewer/CellWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/CellWidget.h @@ -135,6 +135,7 @@ namespace Hurricane { inline Query::Mask getQueryFilter () const ; void bindToPalette ( PaletteWidget* ); void detachFromPalette (); + void detach ( Selector*); void bindCommand ( Command* ); void unbindCommand ( Command* ); void resetCommands (); @@ -249,7 +250,8 @@ namespace Hurricane { void mousePositionChanged ( const Point& position ); void selectionModeChanged (); void selectionChanged ( const SelectorSet& ); - void selectionToggled ( Occurrence ); + void selectionToggled ( Selector* ); + void unlinkSelector ( Selector* ); void showBoundariesToggled ( bool ); protected: virtual void paintEvent ( QPaintEvent* ); diff --git a/hurricane/src/viewer/hurricane/viewer/SelectionModel.h b/hurricane/src/viewer/hurricane/viewer/SelectionModel.h index 16c44ada..fdf1a80c 100644 --- a/hurricane/src/viewer/hurricane/viewer/SelectionModel.h +++ b/hurricane/src/viewer/hurricane/viewer/SelectionModel.h @@ -8,66 +8,28 @@ // | 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@asim.lip6.fr | +// | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | -// | C++ Header : "./SelectionModel.h" | +// | C++ Header : "./hurricane/viewer/SelectionModel.h" | // +-----------------------------------------------------------------+ #ifndef HURRICANE_SELECTION_MODEL_H #define HURRICANE_SELECTION_MODEL_H -#include -#include - -#include -#include -#include - -#include "hurricane/Commons.h" -#include "hurricane/Occurrence.h" -#include "hurricane/viewer/Graphics.h" -#include "hurricane/viewer/Selector.h" +#include +#include +#include +#include +#include "hurricane/Commons.h" +#include "hurricane/Occurrence.h" +#include "hurricane/viewer/Graphics.h" +#include "hurricane/viewer/Selector.h" namespace Hurricane { - - class OccurrenceItem { - public: - 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: - unsigned int _flags; - Occurrence _occurrence; - }; - - - inline OccurrenceItem::OccurrenceItem ( Occurrence occurrence, unsigned int flags ) - : _flags(flags) - , _occurrence(occurrence) - { } - - - inline void OccurrenceItem::setFlags ( unsigned int flags ) - { _flags |= flags; } - - - inline void OccurrenceItem::toggle () - { - if ( _flags & Selected ) _flags &= ~Selected; - else _flags |= Selected; - } - - - inline bool OccurrenceItem::operator== ( const OccurrenceItem& other ) const - { - return _occurrence == other._occurrence; - } + class CellWidget; class SelectionModel : public QAbstractTableModel { @@ -76,26 +38,28 @@ namespace Hurricane { public: SelectionModel ( QObject* parent=NULL ); ~SelectionModel (); - Occurrence getOccurrence ( const QModelIndex& index ); + void setCellWidget ( CellWidget* ); + Selector* getSelector ( const QModelIndex& index ); void setSelection ( const SelectorSet& selection ); - void setSelection ( Occurrence occurrence ); - void toggleSelection ( Occurrence occurrence ); - Occurrence toggleSelection ( const QModelIndex& index ); + void setSelection ( Selector* ); + void toggleSelection ( Selector* ); + Selector* toggleSelection ( const QModelIndex& index ); int rowCount ( const QModelIndex& parent=QModelIndex() ) const; int columnCount ( const QModelIndex& parent=QModelIndex() ) const; QVariant data ( const QModelIndex& index, int role=Qt::DisplayRole ) const; QVariant headerData ( int section, Qt::Orientation orientation, int role=Qt::DisplayRole ) const; - const Occurrence getOccurrence ( int row ); + const Selector* getSelector ( int row ); bool isCumulative () const; public slots: + void unlink ( Selector* ); void clear (); private: - vector _selection; + CellWidget* _cellWidget; + vector _selection; }; } // Hurricane namespace. - #endif // HURRICANE_SELECTION_MODEL_H diff --git a/hurricane/src/viewer/hurricane/viewer/SelectionWidget.h b/hurricane/src/viewer/hurricane/viewer/SelectionWidget.h index 87398c1b..916b78a5 100644 --- a/hurricane/src/viewer/hurricane/viewer/SelectionWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/SelectionWidget.h @@ -1,42 +1,30 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2018, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2019, All Rights Reserved // -// =================================================================== -// -// $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@asim.lip6.fr | +// | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | -// | C++ Header : "./SelectionWidget.h" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// | C++ Header : "./hurricane/viewer/SelectionWidget.h" | +// +-----------------------------------------------------------------+ -#ifndef __HURRICANE_SELECTION_WIDGET__ -#define __HURRICANE_SELECTION_WIDGET__ - +#ifndef HURRICANE_SELECTION_WIDGET_H +#define HURRICANE_SELECTION_WIDGET_H #include #include #include - #include "hurricane/Commons.h" #include "hurricane/Occurrence.h" #include "hurricane/viewer/SelectionModel.h" #include "hurricane/viewer/CellWidget.h" - class QCloseEvent; class QSortFilterProxyModel; class QModelIndex; @@ -49,7 +37,6 @@ class QCheckBox; namespace Hurricane { - class Selector; @@ -62,7 +49,7 @@ namespace Hurricane { bool cumulativeSelection () const; signals: void selectionModeChanged (); - void selectionToggled ( Occurrence ); + void selectionToggled ( Selector* ); void inspect ( Record* ); void inspect ( Occurrence& ); public slots: @@ -73,9 +60,9 @@ namespace Hurricane { void setCumulativeSelection ( bool ); void selectCurrent ( const QModelIndex& current, const QModelIndex& ); void setSelection ( const SelectorSet& selection ); - void setSelection ( Occurrence ); + void setSelection ( Selector* ); void toggleSelection (); - void toggleSelection ( Occurrence ); + void toggleSelection ( Selector* ); void toggleSelection ( const QModelIndex& ); void inspect (); private slots: @@ -83,7 +70,6 @@ namespace Hurricane { //void dataChanged ( const QModelIndex&, const QModelIndex& ); protected: void blockAllSignals ( bool ); - private: CellWidget* _cellWidget; SelectionModel* _baseModel; @@ -97,7 +83,6 @@ namespace Hurricane { }; -} // End of Hurricane namespace. +} // Hurricane namespace. - -#endif // __HURRICANE_SELECTION_WIDGET__ +#endif // HURRICANE_SELECTION_WIDGET_H diff --git a/hurricane/src/viewer/hurricane/viewer/Selector.h b/hurricane/src/viewer/hurricane/viewer/Selector.h index 05e85795..a8f7f302 100644 --- a/hurricane/src/viewer/hurricane/viewer/Selector.h +++ b/hurricane/src/viewer/hurricane/viewer/Selector.h @@ -34,27 +34,41 @@ namespace Hurricane { class Selector : public PrivateProperty { - + public: + enum Flags { InModel = (1<<0) + , Selected = (1<<1) + , ToggledByController = (1<<2) + }; public: // Constructor. - static Selector* create ( Occurrence& occurrence ); - // Methods. - static const Name& getPropertyName (); - virtual Name getName () const; - Occurrence getOccurrence () const; - inline set& getCellWidgetSet (); - bool isAttachedTo ( CellWidget* ) const; - void attachTo ( CellWidget* ); - void detachFrom ( CellWidget* , bool inDeletion=false ); - // Inspector Managment. - virtual string _getTypeName () const; - virtual string _getString () const; - virtual Record* _getRecord () const; + static Selector* create ( Occurrence& occurrence ); + // Methods. + static const Name& getPropertyName (); + virtual Name getName () const; + const Quark* getQuark () const; + Occurrence getOccurrence () const; + Path getPath () const; + Entity* getEntity () const; + inline map& getCellWidgetSet (); + inline bool isSelected ( CellWidget* ) const; + inline bool isInModel ( CellWidget* ) const; + inline bool isToggleByController ( CellWidget* ) const; + bool isAttachedTo ( CellWidget* ) const; + void attachTo ( CellWidget* ); + void detachFrom ( CellWidget* , bool inDeletion=false ); + uint32_t getFlags ( CellWidget* ) const; + void setFlags ( CellWidget* , uint32_t ); + void resetFlags ( CellWidget* , uint32_t ); + void toggle ( CellWidget* ); + // Inspector Managment. + virtual string _getTypeName () const; + virtual string _getString () const; + virtual Record* _getRecord () const; protected: // Internal: Attributes. - static const Name _propertyName; - set _cellWidgets; + static const Name _propertyName; + map _cellWidgets; protected: // Internal: Constructor. @@ -64,8 +78,10 @@ namespace Hurricane { // Inline Functions. - inline set& Selector::getCellWidgetSet () { return _cellWidgets; } - + inline map& Selector::getCellWidgetSet () { return _cellWidgets; } + inline bool Selector::isInModel ( CellWidget* w ) const { return getFlags(w) & InModel ; } + inline bool Selector::isSelected ( CellWidget* w ) const { return getFlags(w) & Selected; } + inline bool Selector::isToggleByController ( CellWidget* w ) const { return getFlags(w) & ToggledByController; } typedef set SelectorSet;