Add support for selection by ComponentSet in CellWidget.
* New: In Component, typedef ComponentSet (set sorted on Ids). * New: CellWidget::selectSet() & CellWidget::unselectSet() select/unselect a whole set of component.
This commit is contained in:
parent
8f387620cb
commit
50a9036d28
|
@ -21,6 +21,7 @@
|
|||
#ifndef HURRICANE_COMPONENT_H
|
||||
#define HURRICANE_COMPONENT_H
|
||||
|
||||
#include <set>
|
||||
#include "hurricane/Points.h"
|
||||
#include "hurricane/Go.h"
|
||||
#include "hurricane/Components.h"
|
||||
|
@ -170,6 +171,9 @@ namespace Hurricane {
|
|||
};
|
||||
|
||||
|
||||
typedef std::set<Component*,DBo::CompareById> ComponentSet;
|
||||
|
||||
|
||||
} // Hurricane namespace.
|
||||
|
||||
|
||||
|
|
|
@ -1625,31 +1625,31 @@ extern "C" {
|
|||
catch ( const Warning& w ) { \
|
||||
std::string message = getString(w); \
|
||||
PyErr_Warn ( HurricaneWarning, const_cast<char*>(message.c_str()) ); \
|
||||
std::cerr << message << std::endl; \
|
||||
std::cerr << message << std::endl; \
|
||||
} \
|
||||
catch ( const Error& e ) { \
|
||||
std::string message = getString(e); \
|
||||
if (not e.where().empty()) message += "\n" + e.where(); \
|
||||
PyErr_SetString ( HurricaneError, message.c_str() ); \
|
||||
std::cerr << message << std::endl; \
|
||||
std::cerr << message << std::endl; \
|
||||
return NULL; \
|
||||
} \
|
||||
catch ( const Bug& e ) { \
|
||||
std::string message = getString(e); \
|
||||
PyErr_SetString ( HurricaneError, message.c_str() ); \
|
||||
std::cerr << message << std::endl; \
|
||||
std::cerr << message << std::endl; \
|
||||
return NULL; \
|
||||
} \
|
||||
catch ( const Exception& e ) { \
|
||||
std::string message = "Unknown Hurricane::Exception"; \
|
||||
PyErr_SetString ( HurricaneError, message.c_str() ); \
|
||||
std::cerr << message << std::endl; \
|
||||
std::cerr << message << std::endl; \
|
||||
return NULL; \
|
||||
} \
|
||||
catch ( const std::exception& e ) { \
|
||||
std::string message = std::string(e.what()); \
|
||||
PyErr_SetString ( HurricaneError, message.c_str() ); \
|
||||
std::cerr << message << std::endl; \
|
||||
std::cerr << message << std::endl; \
|
||||
return NULL; \
|
||||
} \
|
||||
catch ( ... ) { \
|
||||
|
@ -1657,7 +1657,7 @@ extern "C" {
|
|||
"Unmanaged exception, neither a Hurricane::Error nor" \
|
||||
" a std::exception."; \
|
||||
PyErr_SetString ( HurricaneError, message.c_str() ); \
|
||||
std::cerr << message << std::endl; \
|
||||
std::cerr << message << std::endl; \
|
||||
return NULL; \
|
||||
} \
|
||||
|
||||
|
|
|
@ -2687,6 +2687,31 @@ namespace Hurricane {
|
|||
}
|
||||
|
||||
|
||||
void CellWidget::selectSet ( const ComponentSet& components )
|
||||
{
|
||||
if ( (++_delaySelectionChanged == 1) and not _state->cumulativeSelection() ) {
|
||||
openRefreshSession();
|
||||
unselectAll();
|
||||
closeRefreshSession();
|
||||
}
|
||||
|
||||
bool selected = true;
|
||||
// SelectorCriterion* criterion = _state->getSelection().add ( selectArea );
|
||||
// if ( criterion and (not criterion->isEnabled()) ) {
|
||||
// criterion->enable();
|
||||
|
||||
for ( Component* component : components ) {
|
||||
if (component->getCell() == getCell()) {
|
||||
select( Occurrence( component ));
|
||||
}
|
||||
}
|
||||
// } else
|
||||
// selected = false;
|
||||
|
||||
if ( (--_delaySelectionChanged == 0) and selected ) emit selectionChanged( _selectors );
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::select ( Occurrence occurrence )
|
||||
{
|
||||
if ( (++_delaySelectionChanged == 1) and not _state->cumulativeSelection() ) {
|
||||
|
@ -2786,6 +2811,18 @@ namespace Hurricane {
|
|||
}
|
||||
|
||||
|
||||
void CellWidget::unselectSet ( const ComponentSet& components )
|
||||
{
|
||||
++_delaySelectionChanged;
|
||||
for ( Component* component : components ) {
|
||||
if (component->getCell() == getCell()) {
|
||||
unselect( Occurrence( component ));
|
||||
}
|
||||
}
|
||||
if ( --_delaySelectionChanged == 0 ) emit selectionChanged( _selectors );
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::unselectAll ()
|
||||
{
|
||||
++_delaySelectionChanged;
|
||||
|
|
|
@ -265,10 +265,12 @@ namespace Hurricane {
|
|||
inline DrawingPlanes& getDrawingPlanes ();
|
||||
// void select ( const Net* );
|
||||
void select ( Occurrence );
|
||||
void selectSet ( const ComponentSet& );
|
||||
bool isSelected ( Occurrence );
|
||||
void selectOccurrencesUnder ( Box selectArea );
|
||||
// void unselect ( const Net* );
|
||||
void unselect ( Occurrence );
|
||||
void unselectSet ( const ComponentSet& );
|
||||
void unselectAll ();
|
||||
void toggleSelection ( Occurrence );
|
||||
void setShowSelection ( bool state );
|
||||
|
|
Loading…
Reference in New Issue