Various bug fixes (Selection, Measures/Histogram, helpers).
* Bug: In CRL/python/helpers/__init__.py, in textPythonTrace(), when an ErrorMessage was catched, the trace parameter was not correctly extracted leading to an "exception in exception". * New: In Isobar/PyCell, exported Cell::getNonLeafInstanceOccurrences() collection. * New: In Isobar/PyTransformation, type is now built so the tp_compare is linked to the C++ operator==(). * Change: In Hurricane::SelectionModel, Hurricane::SelectionWidget and CellWidget, no longer use Occurrences but directly the Selector property. We also use the Selector to know if an Occurrence is selected by looking at that property on it's Quark. This avoid a very lengthy search in vector when there is many elements (say > 10000). NOTE: This is a bad implementation as there is a confusion between beeing selected (that is, having a Selector property attached to an Occurrence Quark) and being actually displayed as selected. This lead to awkward implatation of the various "toggle" methods. Have to rethink that more clearly later. * Bug: In CRL::Histogram, the non-inline template full specialisation of Measure<Histogram> must not be put in the header but in the module to avoid multiple definition and link failure. They are actually real, classic functions.
This commit is contained in:
parent
39cd831a57
commit
f38945d200
|
@ -101,9 +101,9 @@ def textPythonTrace ( scriptPath=None, e=None, tryContinue=True ):
|
||||||
s += ' \"%s\"\n' % (filename)
|
s += ' \"%s\"\n' % (filename)
|
||||||
s += ' You should check for simple python errors in this module.\n'
|
s += ' You should check for simple python errors in this module.\n'
|
||||||
|
|
||||||
if isinstance(e,helpers.io.ErrorMessage): trace = e.trace()
|
if isinstance(e,helpers.io.ErrorMessage): trace = e.trace
|
||||||
else: trace = sys.exc_info()[2]
|
else: trace = traceback.extract_tb( sys.exc_info()[2] )
|
||||||
s += textStackTrace( traceback.extract_tb( trace ) )
|
s += textStackTrace( trace )
|
||||||
|
|
||||||
if e:
|
if e:
|
||||||
s += ' Error was:\n'
|
s += ' Error was:\n'
|
||||||
|
|
|
@ -230,4 +230,47 @@ namespace CRL {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Measure<Histogram>::Measure ( const Name& name, Histogram* data )
|
||||||
|
: BaseMeasure(name,0)
|
||||||
|
, _data(data)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
|
||||||
|
Measure<Histogram>::~Measure ()
|
||||||
|
{ delete _data; }
|
||||||
|
|
||||||
|
|
||||||
|
bool Measure<Histogram>::isSimpleData () const
|
||||||
|
{ return false; }
|
||||||
|
|
||||||
|
|
||||||
|
Histogram* Measure<Histogram>::getData () const
|
||||||
|
{ return _data; }
|
||||||
|
|
||||||
|
|
||||||
|
void Measure<Histogram>::setData ( Histogram* data )
|
||||||
|
{ _data=data; }
|
||||||
|
|
||||||
|
|
||||||
|
std::string Measure<Histogram>::toString () const
|
||||||
|
{ return "Unsupported"; }
|
||||||
|
|
||||||
|
|
||||||
|
void Measure<Histogram>::toGnuplot ( std::string basename ) const
|
||||||
|
{ _data->toGnuplot ( basename ); }
|
||||||
|
|
||||||
|
|
||||||
|
std::string Measure<Histogram>::_getString () const
|
||||||
|
{ return "<Measure Histogram>"; }
|
||||||
|
|
||||||
|
|
||||||
|
Record* Measure<Histogram>::_getRecord () const
|
||||||
|
{
|
||||||
|
Record* record = new Record ( _getString() );
|
||||||
|
if ( record ) {
|
||||||
|
record->add ( getSlot("_data",_data) );
|
||||||
|
}
|
||||||
|
return record;
|
||||||
|
}
|
||||||
|
|
||||||
} // End of CRL namespace.
|
} // End of CRL namespace.
|
||||||
|
|
|
@ -69,11 +69,11 @@ namespace CRL {
|
||||||
template<>
|
template<>
|
||||||
class Measure<Histogram> : public BaseMeasure {
|
class Measure<Histogram> : public BaseMeasure {
|
||||||
public:
|
public:
|
||||||
inline Measure ( const Name&, Histogram* );
|
Measure ( const Name&, Histogram* );
|
||||||
virtual ~Measure ();
|
virtual ~Measure ();
|
||||||
virtual bool isSimpleData () const;
|
virtual bool isSimpleData () const;
|
||||||
inline Histogram* getData () const;
|
Histogram* getData () const;
|
||||||
inline void setData ( Histogram* );
|
void setData ( Histogram* );
|
||||||
virtual std::string toString () const;
|
virtual std::string toString () const;
|
||||||
virtual void toGnuplot ( std::string basename ) const;
|
virtual void toGnuplot ( std::string basename ) const;
|
||||||
virtual std::string _getString () const;
|
virtual std::string _getString () const;
|
||||||
|
@ -83,36 +83,6 @@ namespace CRL {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline Measure<Histogram>::Measure ( const Name& name, Histogram* data )
|
|
||||||
: BaseMeasure(name,0), _data(data) { }
|
|
||||||
|
|
||||||
Measure<Histogram>::~Measure () { delete _data; }
|
|
||||||
|
|
||||||
bool Measure<Histogram>::isSimpleData () const { return false; }
|
|
||||||
|
|
||||||
inline Histogram* Measure<Histogram>::getData () const { return _data; }
|
|
||||||
|
|
||||||
inline void Measure<Histogram>::setData ( Histogram* data ) { _data=data; }
|
|
||||||
|
|
||||||
std::string Measure<Histogram>::toString () const
|
|
||||||
{ return "Unsupported"; }
|
|
||||||
|
|
||||||
void Measure<Histogram>::toGnuplot ( std::string basename ) const
|
|
||||||
{ _data->toGnuplot ( basename ); }
|
|
||||||
|
|
||||||
std::string Measure<Histogram>::_getString () const
|
|
||||||
{ return "<Measure Histogram>"; }
|
|
||||||
|
|
||||||
Record* Measure<Histogram>::_getRecord () const
|
|
||||||
{
|
|
||||||
Record* record = new Record ( _getString() );
|
|
||||||
if ( record ) {
|
|
||||||
record->add ( getSlot("_data",_data) );
|
|
||||||
}
|
|
||||||
return record;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // CRL namespace.
|
} // CRL namespace.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -327,24 +327,40 @@ extern "C" {
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// Attribute Method : "PyCell_getLeafInstanceOccurrences()"
|
// Attribute Method : "PyCell_getLeafInstanceOccurrences()"
|
||||||
|
|
||||||
static PyObject* PyCell_getLeafInstanceOccurrences(PyCell *self) {
|
static PyObject* PyCell_getLeafInstanceOccurrences ( PyCell* self)
|
||||||
|
{
|
||||||
cdebug_log(20,0) << "PyCell_getLeafInstanceOccurrences()" << endl;
|
cdebug_log(20,0) << "PyCell_getLeafInstanceOccurrences()" << endl;
|
||||||
|
|
||||||
METHOD_HEAD ( "Cell.getLeafInstanceOccurrences()" )
|
METHOD_HEAD ( "Cell.getLeafInstanceOccurrences()" )
|
||||||
|
|
||||||
PyOccurrenceCollection* pyOccurrenceCollection = NULL;
|
PyOccurrenceCollection* pyOccurrenceCollection = NULL;
|
||||||
|
|
||||||
HTRY
|
HTRY
|
||||||
Occurrences* occurrences = new Occurrences(cell->getLeafInstanceOccurrences());
|
Occurrences* occurrences = new Occurrences(cell->getLeafInstanceOccurrences());
|
||||||
|
|
||||||
pyOccurrenceCollection = PyObject_NEW(PyOccurrenceCollection, &PyTypeOccurrenceCollection);
|
pyOccurrenceCollection = PyObject_NEW(PyOccurrenceCollection, &PyTypeOccurrenceCollection);
|
||||||
if (pyOccurrenceCollection == NULL) {
|
if (pyOccurrenceCollection == NULL) return NULL;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pyOccurrenceCollection->_object = occurrences;
|
pyOccurrenceCollection->_object = occurrences;
|
||||||
HCATCH
|
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;
|
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." }
|
, { "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." }
|
, { "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
|
, { "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
|
, { "getLeafInstanceOccurrencesUnder", (PyCFunction)PyCell_getLeafInstanceOccurrencesUnder, METH_VARARGS
|
||||||
, "Returns the collection of all occurrences belonging to this cell and intersecting the given rectangular area." }
|
, "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." }
|
, { "getReferences" , (PyCFunction)PyCell_getReferences , METH_VARARGS, "Returns the collection of all references belonging to the cell." }
|
||||||
|
|
|
@ -520,8 +520,7 @@ extern "C" {
|
||||||
// x-------------------------------------------------------------x
|
// x-------------------------------------------------------------x
|
||||||
|
|
||||||
DirectDeleteMethod(PyTransformation_DeAlloc,PyTransformation)
|
DirectDeleteMethod(PyTransformation_DeAlloc,PyTransformation)
|
||||||
PyTypeObjectLinkPyTypeNewInit(Transformation)
|
PyTypeObjectLinkPyTypeAsValue(Transformation)
|
||||||
//PyTypeObjectLinkPyType(Transformation)
|
|
||||||
|
|
||||||
|
|
||||||
#else // End of Python Module Code Part.
|
#else // End of Python Module Code Part.
|
||||||
|
|
|
@ -761,6 +761,13 @@ namespace Hurricane {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CellViewer::setCumulativeSelection ( bool state )
|
||||||
|
{
|
||||||
|
_updateState = InternalEmit;
|
||||||
|
_cellWidget->setCumulativeSelection ( state );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CellViewer::raiseToolInterrupt ()
|
void CellViewer::raiseToolInterrupt ()
|
||||||
{ _toolInterrupt = true; }
|
{ _toolInterrupt = true; }
|
||||||
|
|
||||||
|
|
|
@ -1176,6 +1176,13 @@ namespace Hurricane {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CellWidget::detach ( Selector* selector )
|
||||||
|
{
|
||||||
|
getSelectorSet().erase( selector );
|
||||||
|
emit unlinkSelector( selector );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CellWidget::bindCommand ( Command* command )
|
void CellWidget::bindCommand ( Command* command )
|
||||||
{
|
{
|
||||||
for ( size_t i=0 ; i<_commands.size() ; i++ )
|
for ( size_t i=0 ; i<_commands.size() ; i++ )
|
||||||
|
@ -1496,24 +1503,25 @@ namespace Hurricane {
|
||||||
Box redrawBox = screenToDbuBox( redrawArea );
|
Box redrawBox = screenToDbuBox( redrawArea );
|
||||||
SelectorSet::iterator iselector;
|
SelectorSet::iterator iselector;
|
||||||
|
|
||||||
forEach ( BasicLayer*, basicLayer, _technology->getBasicLayers() ) {
|
for ( BasicLayer* basicLayer : _technology->getBasicLayers() ) {
|
||||||
//if ( !isDrawableLayer(basicLayer->getName()) ) continue;
|
//if ( !isDrawableLayer(basicLayer->getName()) ) continue;
|
||||||
|
|
||||||
_drawingPlanes.setPen ( Graphics::getPen (basicLayer->getName()) );
|
_drawingPlanes.setPen ( Graphics::getPen (basicLayer->getName()) );
|
||||||
_drawingPlanes.setBrush ( Graphics::getBrush(basicLayer->getName()) );
|
_drawingPlanes.setBrush ( Graphics::getBrush(basicLayer->getName()) );
|
||||||
|
|
||||||
iselector = _selectors.begin();
|
for ( Selector* selector : _selectors ) {
|
||||||
for ( ; iselector != _selectors.end() ; iselector++ ) {
|
if (not selector->isSelected(this)) continue;
|
||||||
Occurrence occurrence = (*iselector)->getOccurrence();
|
|
||||||
|
Occurrence occurrence = selector->getOccurrence();
|
||||||
Component* component = dynamic_cast<Component*>( occurrence.getEntity() );
|
Component* component = dynamic_cast<Component*>( occurrence.getEntity() );
|
||||||
|
|
||||||
if ( component == NULL ) continue;
|
if (not component) continue;
|
||||||
if (not component->getLayer()) continue;
|
if (not component->getLayer()) continue;
|
||||||
if ( not component->getLayer()->contains(*basicLayer) ) continue;
|
if (not component->getLayer()->contains(basicLayer)) continue;
|
||||||
|
|
||||||
Transformation transformation = occurrence.getPath().getTransformation();
|
Transformation transformation = occurrence.getPath().getTransformation();
|
||||||
_drawingQuery.drawGo ( dynamic_cast<Go*>(occurrence.getEntity())
|
_drawingQuery.drawGo ( dynamic_cast<Go*>(occurrence.getEntity())
|
||||||
, *basicLayer
|
, basicLayer
|
||||||
, redrawBox
|
, redrawBox
|
||||||
, transformation
|
, transformation
|
||||||
);
|
);
|
||||||
|
@ -1523,9 +1531,10 @@ namespace Hurricane {
|
||||||
_drawingPlanes.setPen ( Graphics::getPen ("boundaries") );
|
_drawingPlanes.setPen ( Graphics::getPen ("boundaries") );
|
||||||
_drawingPlanes.setBrush ( Graphics::getBrush("boundaries") );
|
_drawingPlanes.setBrush ( Graphics::getBrush("boundaries") );
|
||||||
|
|
||||||
iselector = _selectors.begin();
|
for ( Selector* selector : _selectors ) {
|
||||||
for ( ; iselector != _selectors.end() ; iselector++ ) {
|
if (not selector->isSelected(this)) continue;
|
||||||
Occurrence occurrence = (*iselector)->getOccurrence();
|
|
||||||
|
Occurrence occurrence = selector->getOccurrence();
|
||||||
Instance* instance = dynamic_cast<Instance*>(occurrence.getEntity());
|
Instance* instance = dynamic_cast<Instance*>(occurrence.getEntity());
|
||||||
if (instance) {
|
if (instance) {
|
||||||
Transformation transformation
|
Transformation transformation
|
||||||
|
@ -1537,12 +1546,13 @@ namespace Hurricane {
|
||||||
_drawingPlanes.setPen ( Graphics::getPen ("rubber") );
|
_drawingPlanes.setPen ( Graphics::getPen ("rubber") );
|
||||||
_drawingPlanes.setBrush( Graphics::getBrush("rubber") );
|
_drawingPlanes.setBrush( Graphics::getBrush("rubber") );
|
||||||
|
|
||||||
iselector = _selectors.begin();
|
for ( Selector* selector : _selectors ) {
|
||||||
for ( ; iselector != _selectors.end() ; iselector++ ) {
|
if (not selector->isSelected(this)) continue;
|
||||||
Occurrence occurrence = (*iselector)->getOccurrence();
|
|
||||||
|
Occurrence occurrence = selector->getOccurrence();
|
||||||
Rubber* rubber = dynamic_cast<Rubber*>(occurrence.getEntity());
|
Rubber* rubber = dynamic_cast<Rubber*>(occurrence.getEntity());
|
||||||
|
|
||||||
if ( rubber == NULL ) continue;
|
if (not rubber) continue;
|
||||||
|
|
||||||
Transformation transformation = occurrence.getPath().getTransformation();
|
Transformation transformation = occurrence.getPath().getTransformation();
|
||||||
_drawingQuery.drawRubber( rubber, redrawBox, transformation );
|
_drawingQuery.drawRubber( rubber, redrawBox, transformation );
|
||||||
|
@ -1550,12 +1560,13 @@ namespace Hurricane {
|
||||||
|
|
||||||
Name extensionName = "";
|
Name extensionName = "";
|
||||||
|
|
||||||
iselector = _selectors.begin();
|
for ( Selector* selector : _selectors ) {
|
||||||
for ( ; iselector != _selectors.end() ; iselector++ ) {
|
if (not selector->isSelected(this)) continue;
|
||||||
Occurrence occurrence = (*iselector)->getOccurrence();
|
|
||||||
|
Occurrence occurrence = selector->getOccurrence();
|
||||||
ExtensionGo* eGo = dynamic_cast<ExtensionGo*>(occurrence.getEntity());
|
ExtensionGo* eGo = dynamic_cast<ExtensionGo*>(occurrence.getEntity());
|
||||||
|
|
||||||
if ( eGo == NULL ) continue;
|
if (not eGo) continue;
|
||||||
|
|
||||||
Transformation transformation = occurrence.getPath().getTransformation();
|
Transformation transformation = occurrence.getPath().getTransformation();
|
||||||
if (eGo->getName() != extensionName) {
|
if (eGo->getName() != extensionName) {
|
||||||
|
@ -2603,8 +2614,8 @@ namespace Hurricane {
|
||||||
// cerr << "Selecting: " << occurrence << endl;
|
// cerr << "Selecting: " << occurrence << endl;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
forEach ( Occurrence, ioccurrence, getOccurrencesUnder(selectArea) )
|
for ( Occurrence occurrence : getOccurrencesUnder(selectArea) )
|
||||||
select ( *ioccurrence );
|
select( occurrence );
|
||||||
} else
|
} else
|
||||||
selected = false;
|
selected = false;
|
||||||
|
|
||||||
|
@ -2636,12 +2647,12 @@ namespace Hurricane {
|
||||||
SelectorCriterion* criterion = _state->getSelection().add( net );
|
SelectorCriterion* criterion = _state->getSelection().add( net );
|
||||||
if ( criterion and (not criterion->isEnabled()) ) {
|
if ( criterion and (not criterion->isEnabled()) ) {
|
||||||
criterion->enable();
|
criterion->enable();
|
||||||
forEach ( Component*, component, net->getComponents() ) {
|
for ( Component* component : net->getComponents() ) {
|
||||||
Occurrence occurrence ( *component );
|
Occurrence occurrence ( component );
|
||||||
select( occurrence );
|
select( occurrence );
|
||||||
}
|
}
|
||||||
forEach ( Rubber*, irubber, net->getRubbers() ) {
|
for ( Rubber* rubber : net->getRubbers() ) {
|
||||||
Occurrence occurrence ( *irubber );
|
Occurrence occurrence ( rubber );
|
||||||
select( occurrence );
|
select( occurrence );
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -2660,7 +2671,7 @@ namespace Hurricane {
|
||||||
|
|
||||||
selector->attachTo( this );
|
selector->attachTo( this );
|
||||||
|
|
||||||
setShowSelection ( true );
|
//setShowSelection( true );
|
||||||
_selectionHasChanged = true;
|
_selectionHasChanged = true;
|
||||||
|
|
||||||
if ( (--_delaySelectionChanged == 0) and selected ) {
|
if ( (--_delaySelectionChanged == 0) and selected ) {
|
||||||
|
@ -2721,10 +2732,10 @@ namespace Hurricane {
|
||||||
void CellWidget::toggleSelection ( Occurrence occurrence )
|
void CellWidget::toggleSelection ( Occurrence occurrence )
|
||||||
{
|
{
|
||||||
if (not occurrence.isValid())
|
if (not occurrence.isValid())
|
||||||
throw Error ( "Can't select occurrence : invalid occurrence" );
|
throw Error( "CellWidget::toggleSelection(): Unable to select invalid occurrence." );
|
||||||
|
|
||||||
if ( occurrence.getOwnerCell() != getCell() )
|
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;
|
Selector* selector = NULL;
|
||||||
|
@ -2735,7 +2746,8 @@ namespace Hurricane {
|
||||||
if (occurrence.getPath().isEmpty()) {
|
if (occurrence.getPath().isEmpty()) {
|
||||||
select( net );
|
select( net );
|
||||||
} else {
|
} else {
|
||||||
cerr << "[UNIMPLEMENTED] Selection of " << occurrence << endl;
|
cerr << "CellWidget::toggleSelection(): Selection of " << occurrence
|
||||||
|
<< " is not implemented." << endl;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
selector = Selector::create( occurrence );
|
selector = Selector::create( occurrence );
|
||||||
|
@ -2744,8 +2756,9 @@ namespace Hurricane {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
selector = dynamic_cast<Selector*>( property );
|
selector = dynamic_cast<Selector*>( property );
|
||||||
if ( !selector )
|
if (not selector)
|
||||||
throw Error ( "Abnormal property named " + getString(Selector::getPropertyName()) );
|
throw Error( "CellWidget::toggleSelection(): Abnormal property named "
|
||||||
|
+ getString(Selector::getPropertyName()) + " in place of Selector." );
|
||||||
|
|
||||||
// Net special case.
|
// Net special case.
|
||||||
Net* net = dynamic_cast<Net*>( occurrence.getEntity() );
|
Net* net = dynamic_cast<Net*>( occurrence.getEntity() );
|
||||||
|
@ -2753,9 +2766,11 @@ namespace Hurricane {
|
||||||
if (occurrence.getPath().isEmpty()) {
|
if (occurrence.getPath().isEmpty()) {
|
||||||
unselect( net );
|
unselect( net );
|
||||||
} else {
|
} else {
|
||||||
cerr << "[UNIMPLEMENTED] Selection of " << occurrence << endl;
|
cerr << "CellWidget::toggleSelection(): Selection of " << occurrence
|
||||||
|
<< " is not implemented." << endl;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (not selector->isToggleByController(this))
|
||||||
selector->detachFrom( this );
|
selector->detachFrom( this );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2763,7 +2778,7 @@ namespace Hurricane {
|
||||||
_selectionHasChanged = true;
|
_selectionHasChanged = true;
|
||||||
if (_state->showSelection()) _redrawManager.refresh ();
|
if (_state->showSelection()) _redrawManager.refresh ();
|
||||||
|
|
||||||
emit selectionToggled ( occurrence );
|
emit selectionToggled( selector );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2807,10 +2822,10 @@ namespace Hurricane {
|
||||||
void CellWidget::_unselectAll ()
|
void CellWidget::_unselectAll ()
|
||||||
{
|
{
|
||||||
SelectorSet::iterator iselector;
|
SelectorSet::iterator iselector;
|
||||||
while ( !_selectors.empty() )
|
while ( not _selectors.empty() )
|
||||||
(*_selectors.begin())->detachFrom( this );
|
(*_selectors.begin())->detachFrom( this );
|
||||||
|
|
||||||
if ( !_selectionHasChanged ) _selectionHasChanged = true;
|
if (not _selectionHasChanged) _selectionHasChanged = true;
|
||||||
if (_state->showSelection()) _redrawManager.refresh ();
|
if (_state->showSelection()) _redrawManager.refresh ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -276,6 +276,9 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DirectSetBoolAttribute(PyCellViewer_setShowSelection,setShowSelection,PyCellViewer,CellViewer)
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// PyCellViewer Attribute Method table.
|
// PyCellViewer Attribute Method table.
|
||||||
|
|
||||||
|
@ -298,6 +301,8 @@ extern "C" {
|
||||||
, "Allow/disallow anonymous nets to be selectables." }
|
, "Allow/disallow anonymous nets to be selectables." }
|
||||||
, { "setLayerVisible" , (PyCFunction)PyCellViewer_setLayerVisible , METH_VARARGS
|
, { "setLayerVisible" , (PyCFunction)PyCellViewer_setLayerVisible , METH_VARARGS
|
||||||
, "Sets the visibility state of the layer <name>." }
|
, "Sets the visibility state of the layer <name>." }
|
||||||
|
, { "setShowSelection" , (PyCFunction)PyCellViewer_setShowSelection , METH_VARARGS
|
||||||
|
, "Display/hide the selection." }
|
||||||
, { "fit" , (PyCFunction)PyCellViewer_fit , METH_NOARGS
|
, { "fit" , (PyCFunction)PyCellViewer_fit , METH_NOARGS
|
||||||
, "Triggers a full redraw of the visible area." }
|
, "Triggers a full redraw of the visible area." }
|
||||||
, { "refresh" , (PyCFunction)PyCellViewer_refresh , METH_NOARGS
|
, { "refresh" , (PyCFunction)PyCellViewer_refresh , METH_NOARGS
|
||||||
|
|
|
@ -30,6 +30,7 @@ namespace Hurricane {
|
||||||
|
|
||||||
SelectionModel::SelectionModel ( QObject* parent )
|
SelectionModel::SelectionModel ( QObject* parent )
|
||||||
: QAbstractTableModel(parent)
|
: QAbstractTableModel(parent)
|
||||||
|
, _cellWidget(NULL)
|
||||||
, _selection ()
|
, _selection ()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
@ -47,95 +48,115 @@ namespace Hurricane {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 ()
|
void SelectionModel::clear ()
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
for ( Selector* selector : _selection ) {
|
||||||
|
selector->resetFlags( _cellWidget, Selector::InModel|Selector::Selected );
|
||||||
|
}
|
||||||
_selection.clear();
|
_selection.clear();
|
||||||
endResetModel();
|
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 )
|
void SelectionModel::setSelection ( const SelectorSet& selection )
|
||||||
{
|
{
|
||||||
|
if (not _cellWidget) return;
|
||||||
|
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
if (not isCumulative()) _selection.clear ();
|
if (not isCumulative()) _selection.clear ();
|
||||||
|
|
||||||
SelectorSet::const_iterator iselector = selection.begin();
|
for ( Selector* selector : selection ) {
|
||||||
vector<OccurrenceItem>::iterator iitem;
|
if (not selector->isInModel(_cellWidget)) {
|
||||||
for ( ; iselector != selection.end() ; iselector++ ) {
|
_selection.push_back( selector );
|
||||||
if ( isCumulative() ) {
|
|
||||||
iitem = find( _selection.begin(), _selection.end(), (*iselector)->getOccurrence() );
|
|
||||||
if ( iitem != _selection.end() ) {
|
|
||||||
(*iitem).setFlags ( OccurrenceItem::Selected );
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
selector->setFlags( _cellWidget, Selector::InModel|Selector::Selected );
|
||||||
_selection.push_back ( OccurrenceItem((*iselector)->getOccurrence()) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SelectionModel::setSelection ( Occurrence occurrence )
|
void SelectionModel::setSelection ( Selector* selector )
|
||||||
{
|
{
|
||||||
|
if (not _cellWidget) return;
|
||||||
|
|
||||||
bool modificated = false;
|
bool modificated = false;
|
||||||
if ( not isCumulative() ) _selection.clear ();
|
if (not isCumulative()) {
|
||||||
|
|
||||||
size_t i = 0;
|
|
||||||
for ( ; i<_selection.size() ; i++ ) {
|
|
||||||
if ( _selection[i]._occurrence == occurrence ) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( i >= _selection.size() ) {
|
|
||||||
modificated = true;
|
modificated = true;
|
||||||
beginResetModel ();
|
beginResetModel ();
|
||||||
_selection.push_back ( OccurrenceItem(occurrence) );
|
_selection.clear ();
|
||||||
}
|
}
|
||||||
else _selection[i].setFlags ( OccurrenceItem::Selected );
|
|
||||||
|
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();
|
if (modificated) endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Occurrence SelectionModel::toggleSelection ( const QModelIndex& oindex )
|
Selector* SelectionModel::toggleSelection ( const QModelIndex& oindex )
|
||||||
{
|
{
|
||||||
if ( oindex.isValid() && ( oindex.row() < (int)_selection.size() ) ) {
|
if ( oindex.isValid() and (oindex.row() < (int)_selection.size()) ) {
|
||||||
_selection[oindex.row()].toggle();
|
_selection[oindex.row()]->toggle( _cellWidget );
|
||||||
emit dataChanged( index(oindex.row(),0), index(oindex.row(),1) );
|
emit dataChanged( index(oindex.row(),0), index(oindex.row(),1) );
|
||||||
|
|
||||||
return _selection[oindex.row()]._occurrence;
|
return _selection[ oindex.row() ];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Occurrence ();
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Occurrence SelectionModel::getOccurrence ( const QModelIndex& index )
|
Selector* SelectionModel::getSelector ( const QModelIndex& index )
|
||||||
{
|
{
|
||||||
if ( index.isValid() && ( index.row() < (int)_selection.size() ) ) {
|
if ( index.isValid() and (index.row() < (int)_selection.size()) ) {
|
||||||
return _selection[index.row()]._occurrence;
|
return _selection[ index.row() ];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Occurrence ();
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SelectionModel::toggleSelection ( Occurrence occurrence )
|
void SelectionModel::toggleSelection ( Selector* selector )
|
||||||
{
|
{
|
||||||
bool found = false;
|
if (not _cellWidget) return;
|
||||||
size_t i = 0;
|
|
||||||
for ( ; i<_selection.size() ; i++ ) {
|
|
||||||
if ( (not found) and (_selection[i]._occurrence == occurrence) ) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( not found ) {
|
selector->toggle( _cellWidget );
|
||||||
_selection.push_back ( OccurrenceItem(occurrence) );
|
|
||||||
}
|
|
||||||
_selection[i].toggle ();
|
|
||||||
|
|
||||||
//emit dataChanged ( index(i,0), index(i,1) );
|
//emit dataChanged ( index(i,0), index(i,1) );
|
||||||
}
|
}
|
||||||
|
@ -173,14 +194,14 @@ namespace Hurricane {
|
||||||
static QFont selectFont = Graphics::getFixedFont( QFont::Bold, false );
|
static QFont selectFont = Graphics::getFixedFont( QFont::Bold, false );
|
||||||
static QFontMetrics entityMetrics = QFontMetrics( selectFont );
|
static QFontMetrics entityMetrics = QFontMetrics( selectFont );
|
||||||
|
|
||||||
if ( !index.isValid() ) return QVariant ();
|
if (not index.isValid()) return QVariant();
|
||||||
|
|
||||||
if (role == Qt::SizeHintRole) {
|
if (role == Qt::SizeHintRole) {
|
||||||
switch ( index.column() ) {
|
switch ( index.column() ) {
|
||||||
case 0: return 200;
|
case 0: return 200;
|
||||||
default:
|
default:
|
||||||
if (index.row() > (int)_selection.size()) return 0;
|
if (index.row() > (int)_selection.size()) return 0;
|
||||||
return entityMetrics.width(getString(_selection[index.row()]._occurrence.getEntity()).c_str());
|
return entityMetrics.width(getString( _selection[index.row()]->getEntity() ).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +212,7 @@ namespace Hurricane {
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case 0: return occurrenceFont;
|
case 0: return occurrenceFont;
|
||||||
case 1:
|
case 1:
|
||||||
if ( _selection[row]._flags & OccurrenceItem::Selected )
|
if (_selection[row]->isSelected(_cellWidget))
|
||||||
return selectFont;
|
return selectFont;
|
||||||
default:
|
default:
|
||||||
return unselectFont;
|
return unselectFont;
|
||||||
|
@ -199,14 +220,14 @@ namespace Hurricane {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( role == Qt::ForegroundRole ) {
|
if ( role == Qt::ForegroundRole ) {
|
||||||
if ( _selection[row]._flags & OccurrenceItem::Selected ) return QVariant();
|
if (_selection[row]->isSelected(_cellWidget)) return QVariant();
|
||||||
return unselectForeground;
|
return unselectForeground;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
switch ( index.column() ) {
|
switch ( index.column() ) {
|
||||||
case 0: return getString(_selection[row]._occurrence.getPath().getName()).c_str();
|
case 0: return getString(_selection[row]->getPath().getName()).c_str();
|
||||||
case 1: return getString(_selection[row]._occurrence.getEntity()).c_str();
|
case 1: return getString(_selection[row]->getEntity()).c_str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@ -235,9 +256,7 @@ namespace Hurricane {
|
||||||
|
|
||||||
|
|
||||||
int SelectionModel::rowCount ( const QModelIndex& parent ) const
|
int SelectionModel::rowCount ( const QModelIndex& parent ) const
|
||||||
{
|
{ return _selection.size(); }
|
||||||
return _selection.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int SelectionModel::columnCount ( const QModelIndex& parent ) const
|
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();
|
if (row >= (int)_selection.size()) return NULL;
|
||||||
|
return _selection[ row ];
|
||||||
return _selection[row]._occurrence;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -152,14 +152,15 @@ namespace Hurricane {
|
||||||
}
|
}
|
||||||
|
|
||||||
_cellWidget = cw;
|
_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&))
|
connect( _cellWidget, SIGNAL(selectionChanged(const SelectorSet&))
|
||||||
, this , SLOT (setSelection (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;
|
_updateState = ExternalEmit;
|
||||||
changeSelectionMode ();
|
changeSelectionMode ();
|
||||||
|
@ -235,19 +236,19 @@ namespace Hurricane {
|
||||||
void SelectionWidget::toggleSelection ( const QModelIndex& index )
|
void SelectionWidget::toggleSelection ( const QModelIndex& index )
|
||||||
{
|
{
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
Occurrence occurrence = _baseModel->toggleSelection ( _sortModel->mapToSource(index) );
|
Selector* selector = _baseModel->toggleSelection( _sortModel->mapToSource(index) );
|
||||||
if ( occurrence.isValid() ) {
|
if (selector) {
|
||||||
_updateState = InternalEmit;
|
_updateState = InternalEmit;
|
||||||
_cellWidget->toggleSelection ( occurrence );
|
_cellWidget->toggleSelection ( selector->getOccurrence() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SelectionWidget::toggleSelection ( Occurrence occurrence )
|
void SelectionWidget::toggleSelection ( Selector* selector )
|
||||||
{
|
{
|
||||||
if (_updateState != InternalEmit) {
|
if (_updateState != InternalEmit) {
|
||||||
_baseModel->toggleSelection ( occurrence );
|
_baseModel->toggleSelection( selector );
|
||||||
}
|
}
|
||||||
_updateState = ExternalEmit;
|
_updateState = ExternalEmit;
|
||||||
}
|
}
|
||||||
|
@ -268,8 +269,8 @@ namespace Hurricane {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SelectionWidget::setSelection ( Occurrence occurrence )
|
void SelectionWidget::setSelection ( Selector* selector )
|
||||||
{ _baseModel->setSelection ( occurrence ); }
|
{ _baseModel->setSelection( selector ); }
|
||||||
|
|
||||||
|
|
||||||
void SelectionWidget::clear ()
|
void SelectionWidget::clear ()
|
||||||
|
@ -296,7 +297,7 @@ namespace Hurricane {
|
||||||
void SelectionWidget::inspect ( const QModelIndex& index )
|
void SelectionWidget::inspect ( const QModelIndex& index )
|
||||||
{
|
{
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
Occurrence occurrence = _baseModel->getOccurrence ( _sortModel->mapToSource(index).row() );
|
Occurrence occurrence = _baseModel->getSelector( _sortModel->mapToSource(index).row() )->getOccurrence();
|
||||||
emit inspect ( occurrence );
|
emit inspect ( occurrence );
|
||||||
} else
|
} else
|
||||||
emit inspect ( NULL );
|
emit inspect ( NULL );
|
||||||
|
|
|
@ -42,34 +42,34 @@ namespace Hurricane {
|
||||||
|
|
||||||
const Component* lhsComponent = dynamic_cast<const Component*>( lhsEntity );
|
const Component* lhsComponent = dynamic_cast<const Component*>( lhsEntity );
|
||||||
const Component* rhsComponent = dynamic_cast<const Component*>( rhsEntity );
|
const Component* rhsComponent = dynamic_cast<const Component*>( rhsEntity );
|
||||||
if ( lhsComponent && rhsComponent ) return lhs < rhs; // lhs & rhs are Components.
|
if ( lhsComponent and rhsComponent) return lhs < rhs; // lhs & rhs are Components.
|
||||||
if ( lhsComponent && !rhsComponent ) return true; // lhs only is an Component.
|
if ( lhsComponent and not rhsComponent) return true; // lhs only is an Component.
|
||||||
if ( !lhsComponent && rhsComponent ) return false; // rhs only is an Component.
|
if (not lhsComponent and rhsComponent) return false; // rhs only is an Component.
|
||||||
|
|
||||||
const Instance* lhsInstance = dynamic_cast<const Instance*>( lhsEntity );
|
const Instance* lhsInstance = dynamic_cast<const Instance*>( lhsEntity );
|
||||||
const Instance* rhsInstance = dynamic_cast<const Instance*>( rhsEntity );
|
const Instance* rhsInstance = dynamic_cast<const Instance*>( rhsEntity );
|
||||||
//cerr << "Instance LHS: " << (void*)lhsInstance << " RHS: " << (void*)rhsInstance << endl;
|
//cerr << "Instance LHS: " << (void*)lhsInstance << " RHS: " << (void*)rhsInstance << endl;
|
||||||
|
|
||||||
if ( lhsInstance && rhsInstance ) return lhs < rhs; // lhs & rhs are Instances.
|
if ( lhsInstance and rhsInstance) return lhs < rhs; // lhs & rhs are Instances.
|
||||||
if ( lhsInstance && !rhsInstance ) return true; // lhs only is an Instance.
|
if ( lhsInstance and not rhsInstance) return true; // lhs only is an Instance.
|
||||||
if ( !lhsInstance && rhsInstance ) return false; // rhs only is an Instance.
|
if (not lhsInstance and rhsInstance) return false; // rhs only is an Instance.
|
||||||
|
|
||||||
const Rubber* lhsRubber = dynamic_cast<const Rubber*>( lhsEntity );
|
const Rubber* lhsRubber = dynamic_cast<const Rubber*>( lhsEntity );
|
||||||
const Rubber* rhsRubber = dynamic_cast<const Rubber*>( rhsEntity );
|
const Rubber* rhsRubber = dynamic_cast<const Rubber*>( rhsEntity );
|
||||||
if ( lhsRubber && rhsRubber ) return lhs < rhs; // lhs & rhs are Rubbers.
|
if ( lhsRubber and rhsRubber) return lhs < rhs; // lhs & rhs are Rubbers.
|
||||||
if ( lhsRubber && !rhsRubber ) return true; // lhs only is an Rubber.
|
if ( lhsRubber and not rhsRubber) return true; // lhs only is an Rubber.
|
||||||
if ( !lhsRubber && rhsRubber ) return false; // rhs only is an Rubber.
|
if (not lhsRubber and rhsRubber) return false; // rhs only is an Rubber.
|
||||||
|
|
||||||
const ExtensionGo* lhsExtensionGo = dynamic_cast<const ExtensionGo*>( lhsEntity );
|
const ExtensionGo* lhsExtensionGo = dynamic_cast<const ExtensionGo*>( lhsEntity );
|
||||||
const ExtensionGo* rhsExtensionGo = dynamic_cast<const ExtensionGo*>( rhsEntity );
|
const ExtensionGo* rhsExtensionGo = dynamic_cast<const ExtensionGo*>( rhsEntity );
|
||||||
if ( lhsExtensionGo && rhsExtensionGo ) { // lhs & rhs are ExtensionGos.
|
if (lhsExtensionGo and rhsExtensionGo) { // lhs & rhs are ExtensionGos.
|
||||||
if (lhsExtensionGo->getName() == rhsExtensionGo->getName())
|
if (lhsExtensionGo->getName() == rhsExtensionGo->getName())
|
||||||
return lhs < rhs;
|
return lhs < rhs;
|
||||||
|
|
||||||
return lhsExtensionGo->getName() < rhsExtensionGo->getName();
|
return lhsExtensionGo->getName() < rhsExtensionGo->getName();
|
||||||
}
|
}
|
||||||
if ( lhsExtensionGo && !rhsExtensionGo ) return true; // lhs only is an ExtensionGo.
|
if ( lhsExtensionGo and not rhsExtensionGo) return true; // lhs only is an ExtensionGo.
|
||||||
if ( !lhsExtensionGo && rhsExtensionGo ) return false; // rhs only is an ExtensionGo.
|
if (not lhsExtensionGo and rhsExtensionGo) return false; // rhs only is an ExtensionGo.
|
||||||
|
|
||||||
return lhs < rhs;
|
return lhs < rhs;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ namespace Hurricane {
|
||||||
// Class : "Hurricane::Selector".
|
// Class : "Hurricane::Selector".
|
||||||
|
|
||||||
|
|
||||||
const Name Selector::_propertyName = _PName ( "Selector" );
|
const Name Selector::_propertyName = Name( "Selector" );
|
||||||
|
|
||||||
|
|
||||||
Selector::Selector () : PrivateProperty()
|
Selector::Selector () : PrivateProperty()
|
||||||
|
@ -88,7 +88,7 @@ namespace Hurricane {
|
||||||
|
|
||||||
|
|
||||||
string Selector::_getTypeName () const
|
string Selector::_getTypeName () const
|
||||||
{ return _TName("Selector"); }
|
{ return "Selector"; }
|
||||||
|
|
||||||
|
|
||||||
const Name& Selector::getPropertyName ()
|
const Name& Selector::getPropertyName ()
|
||||||
|
@ -99,25 +99,13 @@ namespace Hurricane {
|
||||||
{ return Selector::getPropertyName(); }
|
{ return Selector::getPropertyName(); }
|
||||||
|
|
||||||
|
|
||||||
Occurrence Selector::getOccurrence () const
|
|
||||||
{
|
|
||||||
DBo* owner = getOwner();
|
|
||||||
if (!owner) return Occurrence();
|
|
||||||
|
|
||||||
Quark* quark = dynamic_cast<Quark*>(owner);
|
|
||||||
assert ( quark );
|
|
||||||
|
|
||||||
return quark->getOccurrence();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Selector* Selector::create ( Occurrence& occurrence )
|
Selector* Selector::create ( Occurrence& occurrence )
|
||||||
{
|
{
|
||||||
if ( !occurrence.isValid() )
|
if (not occurrence.isValid())
|
||||||
throw Error ( "Can't create " + _TName("Selector") + " : invalid occurrence" );
|
throw Error( "Selector::create(): Can't create Selector, invalid occurrence" );
|
||||||
|
|
||||||
if (occurrence.getProperty(Selector::getPropertyName()))
|
if (occurrence.getProperty(Selector::getPropertyName()))
|
||||||
throw Error ( "Can't create " + _TName("Selector") + " : already exists" );
|
throw Error( "Selector::create(): Can't create Selector, already exists" );
|
||||||
|
|
||||||
Selector* selector = new Selector();
|
Selector* selector = new Selector();
|
||||||
|
|
||||||
|
@ -130,17 +118,14 @@ namespace Hurricane {
|
||||||
|
|
||||||
void Selector::_preDestroy()
|
void Selector::_preDestroy()
|
||||||
{
|
{
|
||||||
set<CellWidget*>::iterator it = _cellWidgets.begin ();
|
for ( auto iwidget : _cellWidgets ) detachFrom( iwidget.first, true );
|
||||||
for ( ; it != _cellWidgets.end() ; it++ )
|
|
||||||
detachFrom ( *it, true );
|
|
||||||
|
|
||||||
PrivateProperty::_preDestroy();
|
PrivateProperty::_preDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string Selector::_getString() const
|
string Selector::_getString() const
|
||||||
{
|
{
|
||||||
return "<" + _TName("Selector") + " " + getString(getOccurrence()) + ">";
|
return "<Selector " + getString(getOccurrence()) + ">";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,37 +139,125 @@ namespace Hurricane {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Quark* Selector::getQuark () const
|
||||||
|
{
|
||||||
|
const Quark* owner = dynamic_cast<const Quark*>( 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
|
bool Selector::isAttachedTo ( CellWidget* widget ) const
|
||||||
{
|
{
|
||||||
if ( !widget )
|
if (not widget)
|
||||||
throw Error ( "Can't attach selector : null CellWidget." );
|
throw Error( "Selector::isAttachedTo(): NULL widget argument." );
|
||||||
|
|
||||||
if ( _cellWidgets.find(widget) == _cellWidgets.end() )
|
return (_cellWidgets.find(widget) != _cellWidgets.end());
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Selector::attachTo ( CellWidget* widget )
|
void Selector::attachTo ( CellWidget* widget )
|
||||||
{
|
{
|
||||||
if ( !widget )
|
if (not widget)
|
||||||
throw Error ( "Can't attach selector : null CellWidget." );
|
throw Error( "Selector::attachTo(): Cannot attach, NULL widget argument." );
|
||||||
|
|
||||||
_cellWidgets.insert ( widget );
|
_cellWidgets.insert( make_pair(widget,0) );
|
||||||
widget->getSelectorSet().insert( this );
|
widget->getSelectorSet().insert( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Selector::detachFrom ( CellWidget* widget, bool inDeletion )
|
void Selector::detachFrom ( CellWidget* widget, bool inDeletion )
|
||||||
{
|
{
|
||||||
if ( !widget )
|
if (not widget)
|
||||||
throw Error ( "Can't detach selector : null CellWidget" );
|
throw Error( "Selector::detachFrom(): Cannot detach, NULL widget argument." );
|
||||||
|
|
||||||
widget->getSelectorSet().erase ( this );
|
widget->detach( this );
|
||||||
_cellWidgets.erase( widget );
|
_cellWidgets.erase( widget );
|
||||||
|
|
||||||
if ( !inDeletion && _cellWidgets.empty() ) destroy();
|
if (not inDeletion and _cellWidgets.empty()) destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t Selector::getFlags ( CellWidget* widget ) const
|
||||||
|
{
|
||||||
|
map<CellWidget*,uint32_t>::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<CellWidget*,uint32_t>::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<CellWidget*,uint32_t>::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<CellWidget*,uint32_t>::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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -141,6 +141,7 @@ namespace Hurricane {
|
||||||
void doGoto ();
|
void doGoto ();
|
||||||
void changeSelectionMode ();
|
void changeSelectionMode ();
|
||||||
void setShowSelection ( bool );
|
void setShowSelection ( bool );
|
||||||
|
void setCumulativeSelection ( bool );
|
||||||
void setState ( shared_ptr<CellWidget::State>& );
|
void setState ( shared_ptr<CellWidget::State>& );
|
||||||
void removeHistory ( Cell* );
|
void removeHistory ( Cell* );
|
||||||
void openHistoryCell ();
|
void openHistoryCell ();
|
||||||
|
|
|
@ -135,6 +135,7 @@ namespace Hurricane {
|
||||||
inline Query::Mask getQueryFilter () const ;
|
inline Query::Mask getQueryFilter () const ;
|
||||||
void bindToPalette ( PaletteWidget* );
|
void bindToPalette ( PaletteWidget* );
|
||||||
void detachFromPalette ();
|
void detachFromPalette ();
|
||||||
|
void detach ( Selector*);
|
||||||
void bindCommand ( Command* );
|
void bindCommand ( Command* );
|
||||||
void unbindCommand ( Command* );
|
void unbindCommand ( Command* );
|
||||||
void resetCommands ();
|
void resetCommands ();
|
||||||
|
@ -249,7 +250,8 @@ namespace Hurricane {
|
||||||
void mousePositionChanged ( const Point& position );
|
void mousePositionChanged ( const Point& position );
|
||||||
void selectionModeChanged ();
|
void selectionModeChanged ();
|
||||||
void selectionChanged ( const SelectorSet& );
|
void selectionChanged ( const SelectorSet& );
|
||||||
void selectionToggled ( Occurrence );
|
void selectionToggled ( Selector* );
|
||||||
|
void unlinkSelector ( Selector* );
|
||||||
void showBoundariesToggled ( bool );
|
void showBoundariesToggled ( bool );
|
||||||
protected:
|
protected:
|
||||||
virtual void paintEvent ( QPaintEvent* );
|
virtual void paintEvent ( QPaintEvent* );
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
// | V L S I B a c k e n d D a t a - B a s e |
|
// | V L S I B a c k e n d D a t a - B a s e |
|
||||||
// | |
|
// | |
|
||||||
// | Author : Jean-Paul CHAPUT |
|
// | 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" |
|
||||||
// +-----------------------------------------------------------------+
|
// +-----------------------------------------------------------------+
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,12 +18,9 @@
|
||||||
#define HURRICANE_SELECTION_MODEL_H
|
#define HURRICANE_SELECTION_MODEL_H
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
|
||||||
|
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
|
|
||||||
#include "hurricane/Commons.h"
|
#include "hurricane/Commons.h"
|
||||||
#include "hurricane/Occurrence.h"
|
#include "hurricane/Occurrence.h"
|
||||||
#include "hurricane/viewer/Graphics.h"
|
#include "hurricane/viewer/Graphics.h"
|
||||||
|
@ -32,42 +29,7 @@
|
||||||
|
|
||||||
namespace Hurricane {
|
namespace Hurricane {
|
||||||
|
|
||||||
|
class CellWidget;
|
||||||
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 SelectionModel : public QAbstractTableModel {
|
class SelectionModel : public QAbstractTableModel {
|
||||||
|
@ -76,26 +38,28 @@ namespace Hurricane {
|
||||||
public:
|
public:
|
||||||
SelectionModel ( QObject* parent=NULL );
|
SelectionModel ( QObject* parent=NULL );
|
||||||
~SelectionModel ();
|
~SelectionModel ();
|
||||||
Occurrence getOccurrence ( const QModelIndex& index );
|
void setCellWidget ( CellWidget* );
|
||||||
|
Selector* getSelector ( const QModelIndex& index );
|
||||||
void setSelection ( const SelectorSet& selection );
|
void setSelection ( const SelectorSet& selection );
|
||||||
void setSelection ( Occurrence occurrence );
|
void setSelection ( Selector* );
|
||||||
void toggleSelection ( Occurrence occurrence );
|
void toggleSelection ( Selector* );
|
||||||
Occurrence toggleSelection ( const QModelIndex& index );
|
Selector* toggleSelection ( const QModelIndex& index );
|
||||||
int rowCount ( const QModelIndex& parent=QModelIndex() ) const;
|
int rowCount ( const QModelIndex& parent=QModelIndex() ) const;
|
||||||
int columnCount ( const QModelIndex& parent=QModelIndex() ) const;
|
int columnCount ( const QModelIndex& parent=QModelIndex() ) const;
|
||||||
QVariant data ( const QModelIndex& index, int role=Qt::DisplayRole ) const;
|
QVariant data ( const QModelIndex& index, int role=Qt::DisplayRole ) const;
|
||||||
QVariant headerData ( int section, Qt::Orientation orientation, 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;
|
bool isCumulative () const;
|
||||||
public slots:
|
public slots:
|
||||||
|
void unlink ( Selector* );
|
||||||
void clear ();
|
void clear ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vector<OccurrenceItem> _selection;
|
CellWidget* _cellWidget;
|
||||||
|
vector<Selector*> _selection;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // Hurricane namespace.
|
} // Hurricane namespace.
|
||||||
|
|
||||||
|
|
||||||
#endif // HURRICANE_SELECTION_MODEL_H
|
#endif // HURRICANE_SELECTION_MODEL_H
|
||||||
|
|
|
@ -1,42 +1,30 @@
|
||||||
|
|
||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
//
|
//
|
||||||
// This file is part of the Coriolis Software.
|
// 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 |
|
// | 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 |
|
// | V L S I B a c k e n d D a t a - B a s e |
|
||||||
// | |
|
// | |
|
||||||
// | Author : Jean-Paul CHAPUT |
|
// | Author : Jean-Paul CHAPUT |
|
||||||
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
|
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||||
// | =============================================================== |
|
// | =============================================================== |
|
||||||
// | C++ Header : "./SelectionWidget.h" |
|
// | C++ Header : "./hurricane/viewer/SelectionWidget.h" |
|
||||||
// | *************************************************************** |
|
// +-----------------------------------------------------------------+
|
||||||
// | U p d a t e s |
|
|
||||||
// | |
|
|
||||||
// x-----------------------------------------------------------------x
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef __HURRICANE_SELECTION_WIDGET__
|
#ifndef HURRICANE_SELECTION_WIDGET_H
|
||||||
#define __HURRICANE_SELECTION_WIDGET__
|
#define HURRICANE_SELECTION_WIDGET_H
|
||||||
|
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
#include "hurricane/Commons.h"
|
#include "hurricane/Commons.h"
|
||||||
#include "hurricane/Occurrence.h"
|
#include "hurricane/Occurrence.h"
|
||||||
#include "hurricane/viewer/SelectionModel.h"
|
#include "hurricane/viewer/SelectionModel.h"
|
||||||
#include "hurricane/viewer/CellWidget.h"
|
#include "hurricane/viewer/CellWidget.h"
|
||||||
|
|
||||||
|
|
||||||
class QCloseEvent;
|
class QCloseEvent;
|
||||||
class QSortFilterProxyModel;
|
class QSortFilterProxyModel;
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
|
@ -49,7 +37,6 @@ class QCheckBox;
|
||||||
|
|
||||||
namespace Hurricane {
|
namespace Hurricane {
|
||||||
|
|
||||||
|
|
||||||
class Selector;
|
class Selector;
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +49,7 @@ namespace Hurricane {
|
||||||
bool cumulativeSelection () const;
|
bool cumulativeSelection () const;
|
||||||
signals:
|
signals:
|
||||||
void selectionModeChanged ();
|
void selectionModeChanged ();
|
||||||
void selectionToggled ( Occurrence );
|
void selectionToggled ( Selector* );
|
||||||
void inspect ( Record* );
|
void inspect ( Record* );
|
||||||
void inspect ( Occurrence& );
|
void inspect ( Occurrence& );
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -73,9 +60,9 @@ namespace Hurricane {
|
||||||
void setCumulativeSelection ( bool );
|
void setCumulativeSelection ( bool );
|
||||||
void selectCurrent ( const QModelIndex& current, const QModelIndex& );
|
void selectCurrent ( const QModelIndex& current, const QModelIndex& );
|
||||||
void setSelection ( const SelectorSet& selection );
|
void setSelection ( const SelectorSet& selection );
|
||||||
void setSelection ( Occurrence );
|
void setSelection ( Selector* );
|
||||||
void toggleSelection ();
|
void toggleSelection ();
|
||||||
void toggleSelection ( Occurrence );
|
void toggleSelection ( Selector* );
|
||||||
void toggleSelection ( const QModelIndex& );
|
void toggleSelection ( const QModelIndex& );
|
||||||
void inspect ();
|
void inspect ();
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -83,7 +70,6 @@ namespace Hurricane {
|
||||||
//void dataChanged ( const QModelIndex&, const QModelIndex& );
|
//void dataChanged ( const QModelIndex&, const QModelIndex& );
|
||||||
protected:
|
protected:
|
||||||
void blockAllSignals ( bool );
|
void blockAllSignals ( bool );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CellWidget* _cellWidget;
|
CellWidget* _cellWidget;
|
||||||
SelectionModel* _baseModel;
|
SelectionModel* _baseModel;
|
||||||
|
@ -97,7 +83,6 @@ namespace Hurricane {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // End of Hurricane namespace.
|
} // Hurricane namespace.
|
||||||
|
|
||||||
|
#endif // HURRICANE_SELECTION_WIDGET_H
|
||||||
#endif // __HURRICANE_SELECTION_WIDGET__
|
|
||||||
|
|
|
@ -34,18 +34,32 @@ namespace Hurricane {
|
||||||
|
|
||||||
|
|
||||||
class Selector : public PrivateProperty {
|
class Selector : public PrivateProperty {
|
||||||
|
public:
|
||||||
|
enum Flags { InModel = (1<<0)
|
||||||
|
, Selected = (1<<1)
|
||||||
|
, ToggledByController = (1<<2)
|
||||||
|
};
|
||||||
public:
|
public:
|
||||||
// Constructor.
|
// Constructor.
|
||||||
static Selector* create ( Occurrence& occurrence );
|
static Selector* create ( Occurrence& occurrence );
|
||||||
// Methods.
|
// Methods.
|
||||||
static const Name& getPropertyName ();
|
static const Name& getPropertyName ();
|
||||||
virtual Name getName () const;
|
virtual Name getName () const;
|
||||||
|
const Quark* getQuark () const;
|
||||||
Occurrence getOccurrence () const;
|
Occurrence getOccurrence () const;
|
||||||
inline set<CellWidget*>& getCellWidgetSet ();
|
Path getPath () const;
|
||||||
|
Entity* getEntity () const;
|
||||||
|
inline map<CellWidget*,uint32_t>& getCellWidgetSet ();
|
||||||
|
inline bool isSelected ( CellWidget* ) const;
|
||||||
|
inline bool isInModel ( CellWidget* ) const;
|
||||||
|
inline bool isToggleByController ( CellWidget* ) const;
|
||||||
bool isAttachedTo ( CellWidget* ) const;
|
bool isAttachedTo ( CellWidget* ) const;
|
||||||
void attachTo ( CellWidget* );
|
void attachTo ( CellWidget* );
|
||||||
void detachFrom ( CellWidget* , bool inDeletion=false );
|
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.
|
// Inspector Managment.
|
||||||
virtual string _getTypeName () const;
|
virtual string _getTypeName () const;
|
||||||
virtual string _getString () const;
|
virtual string _getString () const;
|
||||||
|
@ -54,7 +68,7 @@ namespace Hurricane {
|
||||||
protected:
|
protected:
|
||||||
// Internal: Attributes.
|
// Internal: Attributes.
|
||||||
static const Name _propertyName;
|
static const Name _propertyName;
|
||||||
set<CellWidget*> _cellWidgets;
|
map<CellWidget*,uint32_t> _cellWidgets;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Internal: Constructor.
|
// Internal: Constructor.
|
||||||
|
@ -64,8 +78,10 @@ namespace Hurricane {
|
||||||
|
|
||||||
|
|
||||||
// Inline Functions.
|
// Inline Functions.
|
||||||
inline set<CellWidget*>& Selector::getCellWidgetSet () { return _cellWidgets; }
|
inline map<CellWidget*,uint32_t>& 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<Selector*,SelectorLess> SelectorSet;
|
typedef set<Selector*,SelectorLess> SelectorSet;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue