1- #include " Utils/SelectionManager.h"
1+ #include " Internal/SelectionManager.h"
2+ #include " Internal/SelectionHelper.h"
23#include " Utils/Common.h"
34#include " Utils/DisplayProperties.h"
45
@@ -20,7 +21,7 @@ using namespace std;
2021/* ----------------------------------------------------------------------------*/
2122namespace Mgx3D {
2223/* ----------------------------------------------------------------------------*/
23- namespace Utils {
24+ namespace Internal {
2425/* ----------------------------------------------------------------------------*/
2526
2627
@@ -89,7 +90,7 @@ void SelectionManagerObserver::selectionCleared ( )
8990} // SelectionManagerObserver::selectionCleared
9091
9192
92- void SelectionManagerObserver::entitiesAddedToSelection (const vector<Entity*>&)
93+ void SelectionManagerObserver::entitiesAddedToSelection (const vector<Utils:: Entity*>&)
9394{
9495} // SelectionManagerObserver::entitiesAddedToSelection
9596
@@ -98,7 +99,7 @@ void SelectionManagerObserver::entitiesAddedToSelection (const vector<string>& u
9899} // SelectionManagerObserver::entitiesAddedToSelection
99100
100101
101- void SelectionManagerObserver::entitiesRemovedFromSelection (const vector<Entity*>& entities, bool clear)
102+ void SelectionManagerObserver::entitiesRemovedFromSelection (const vector<Utils:: Entity*>& entities, bool clear)
102103{
103104} // SelectionManagerObserver::entitiesRemovedFromSelection
104105
@@ -198,7 +199,7 @@ void SelectionManager::getBounds (double bounds [6])
198199
199200 AutoMutex autoMutex (getMutex ( ));
200201
201- for (vector<Entity*>::iterator it = _entities.begin ( ); _entities.end ( ) != it; it++)
202+ for (vector<Utils:: Entity*>::iterator it = _entities.begin ( ); _entities.end ( ) != it; it++)
202203 {
203204 double entityBounds [6 ];
204205 (*it)->getBounds (entityBounds);
@@ -217,17 +218,17 @@ bool SelectionManager::isSelectionEmpty ( ) const
217218} // SelectionManager::isSelectionEmpty
218219
219220
220- vector<Entity*> SelectionManager::getEntities ( ) const
221+ vector<Utils:: Entity*> SelectionManager::getEntities ( ) const
221222{
222223 return _entities;
223224} // SelectionManager::getMeshes
224225
225226vector<unsigned long > SelectionManager::getEntitiesIds ( ) const
226227{
227228 vector<unsigned long > ids;
228- const vector<Entity*> entities = getEntities ( );
229+ const vector<Utils:: Entity*> entities = getEntities ( );
229230
230- for (vector<Entity*>::const_iterator it = entities.begin ( );
231+ for (vector<Utils:: Entity*>::const_iterator it = entities.begin ( );
231232 entities.end ( ) != it; it++)
232233 ids.push_back ((*it)->getUniqueId ( ));
233234
@@ -243,7 +244,7 @@ std::vector<std::string> SelectionManager::getEntitiesNames ( ) const
243244 return entites;
244245}
245246
246- std::vector<Mgx3D::Utils::Entity*> SelectionManager::getEntities (Entity::objectType type) const
247+ std::vector<Mgx3D::Utils::Entity*> SelectionManager::getEntities (Utils:: Entity::objectType type) const
247248{
248249 std::vector<Mgx3D::Utils::Entity*> entites_filtrees;
249250
@@ -255,7 +256,7 @@ std::vector<Mgx3D::Utils::Entity*> SelectionManager::getEntities (Entity::object
255256}
256257
257258
258- std::vector<std::string> SelectionManager::getEntitiesNames (Entity::objectType type) const
259+ std::vector<std::string> SelectionManager::getEntitiesNames (Utils:: Entity::objectType type) const
259260{
260261 std::vector<std::string> entites_filtrees;
261262
@@ -267,7 +268,7 @@ std::vector<std::string> SelectionManager::getEntitiesNames (Entity::objectType
267268}
268269
269270
270- std::vector<std::string> SelectionManager::getEntitiesNames (FilterEntity::objectType mask) const
271+ std::vector<std::string> SelectionManager::getEntitiesNames (Utils:: FilterEntity::objectType mask) const
271272{
272273 std::vector<std::string> entites_filtrees;
273274
@@ -279,19 +280,19 @@ std::vector<std::string> SelectionManager::getEntitiesNames (FilterEntity::objec
279280}
280281
281282
282- void SelectionManager::addToSelection (const vector<Entity*>& entities)
283+ void SelectionManager::addToSelection (const vector<Utils:: Entity*>& entities)
283284{
284285 addToSelection (entities, true );
285286} // SelectionManager::addToSelection
286287
287288
288- void SelectionManager::removeFromSelection (const vector<Entity*>& entities)
289+ void SelectionManager::removeFromSelection (const vector<Utils:: Entity*>& entities)
289290{
290291 removeFromSelection (entities, true );
291292} // SelectionManager::removeFromSelection
292293
293294
294- bool SelectionManager::isSelected (const Entity& entity) const
295+ bool SelectionManager::isSelected (const Utils:: Entity& entity) const
295296{
296297 // TODO [EB]: {Optimisation} partie pouvant être couteuse il me semble
297298 // [CP] : OPTIMISATION
@@ -301,7 +302,7 @@ bool SelectionManager::isSelected (const Entity& entity) const
301302 // A priori on ne devrait pas passer ci-dessous :
302303 AutoMutex autoMutex (getMutex ( ));
303304
304- for (vector<Entity*>::const_iterator it = _entities.begin ( ); _entities.end ( ) != it; it++)
305+ for (vector<Utils:: Entity*>::const_iterator it = _entities.begin ( ); _entities.end ( ) != it; it++)
305306 if (*it == &entity)
306307 return true ;
307308
@@ -386,7 +387,7 @@ bool SelectionManager::isRedoable ( ) const
386387} // SelectionManager::isRedoable
387388
388389
389- void SelectionManager::addToSelection (const vector<Entity*>& entities, bool undoable)
390+ void SelectionManager::addToSelection (const vector<Utils:: Entity*>& entities, bool undoable)
390391{
391392 AutoMutex autoMutex (getMutex ( ));
392393
@@ -398,13 +399,13 @@ void SelectionManager::addToSelection (const vector<Entity*>& entities, bool und
398399 UTF8String message (Charset::UTF_8);
399400 message << (1 == entities.size ( ) ? " Sélection de l'entité " : " Sélection des entités " );
400401
401- for (vector<Entity*>::const_iterator it = entities.begin ( ); entities.end ( ) != it; it++)
402+ for (vector<Utils:: Entity*>::const_iterator it = entities.begin ( ); entities.end ( ) != it; it++)
402403 {
403404 CHECK_NULL_PTR_ERROR (*it)
404405
405406 // On filtre, certaines entités peuvent être présentes 2 fois (acteurs VTK filaire + isofilaire par ex) :
406- vector<Entity*>::const_iterator itnext = it; itnext++;
407- vector<Entity*>::const_iterator itfound = find (itnext, entities.end ( ), *it);
407+ vector<Utils:: Entity*>::const_iterator itnext = it; itnext++;
408+ vector<Utils:: Entity*>::const_iterator itfound = find (itnext, entities.end ( ), *it);
408409 if (entities.end ( ) != itfound)
409410 continue ; // La dernière occurence sera ajoutée
410411
@@ -439,7 +440,7 @@ void SelectionManager::addToSelection (const vector<Entity*>& entities, bool und
439440} // SelectionManager::addToSelection
440441
441442
442- void SelectionManager::removeFromSelection (const vector<Entity*>& entities, bool undoable)
443+ void SelectionManager::removeFromSelection (const vector<Utils:: Entity*>& entities, bool undoable)
443444{
444445 AutoMutex autoMutex (getMutex ( ));
445446
@@ -451,12 +452,12 @@ void SelectionManager::removeFromSelection (const vector<Entity*>& entities, boo
451452 UTF8String message (Charset::UTF_8);
452453 message << (1 == entities.size ( ) ? " Désélection de l'entité " : " Désélection des entités " );
453454
454- for (vector<Entity*>::const_iterator it1 = entities.begin ( ); entities.end ( ) != it1; it1++)
455+ for (vector<Utils:: Entity*>::const_iterator it1 = entities.begin ( ); entities.end ( ) != it1; it1++)
455456 {
456457 CHECK_NULL_PTR_ERROR (*it1)
457458
458459 bool removed = false ;
459- for (vector<Entity*>::iterator it2 = _entities.begin ( ); _entities.end ( ) != it2; it2++)
460+ for (vector<Utils:: Entity*>::iterator it2 = _entities.begin ( ); _entities.end ( ) != it2; it2++)
460461 {
461462 if (*it1 == *it2)
462463 {
@@ -504,7 +505,7 @@ void SelectionManager::clearSelection (bool undoable)
504505 // effet, ceux-ci peuvent etre tentés d'effectuer des requêtes auprès de ce gestionnaire de sélection, notamment un removeFromSelection. C'est
505506 // par exemple le cas d'un observateur Qt où il est difficile de savoir si l'évènement de désenregistrement provient de ce gestionnaire ou d'un
506507 // évenement au niveau de l'IHM.
507- const vector<Entity*> unselected = _entities;
508+ const vector<Utils:: Entity*> unselected = _entities;
508509 if (0 != _entities.size ( ))
509510 {
510511 _entities.clear ( );
@@ -634,15 +635,15 @@ int SelectionManager::dimensionsToDimension (SelectionManager::DIM dimensions)
634635} // SelectionManager::dimensionsToDimension
635636
636637
637- bool SelectionManager::isSelectionActivated (const Entity& e) const
638+ bool SelectionManager::isSelectionActivated (const Utils:: Entity& e) const
638639{
639640 return false ;
640641} // SelectionManager::isSelectionActivated
641642
642643
643- FilterEntity::objectType SelectionManager::getFilteredTypes ( ) const
644+ Utils:: FilterEntity::objectType SelectionManager::getFilteredTypes ( ) const
644645{
645- return FilterEntity::NoneEntity;
646+ return Utils:: FilterEntity::NoneEntity;
646647} // SelectionManager::getFilteredTypes
647648
648649
@@ -676,7 +677,7 @@ bool SelectionManager::is3DSelectionActivated ( ) const
676677} // SelectionManager::is3DSelectionActivated
677678
678679
679- void SelectionManager::activateSelection (SelectionManager::DIM dimensions, FilterEntity::objectType mask)
680+ void SelectionManager::activateSelection (SelectionManager::DIM dimensions, Utils:: FilterEntity::objectType mask)
680681{
681682} // SelectionManager::activate3DSelection
682683
@@ -734,6 +735,47 @@ void SelectionManager::notifyObserversForNewPolicy (void* smp)
734735} // SelectionManager::notifyObserversForNewPolicy
735736
736737
738+ void SelectionManager::selectSheet (Utils::Entity* e, double * point){
739+ // We need to filter to topoEntities
740+ std::vector<Utils::Entity::objectType> validTypes =
741+ {Utils::Entity::TopoBlock,Utils::Entity::TopoFace,Utils::Entity::TopoCoFace,
742+ Utils::Entity::TopoEdge,Utils::Entity::TopoCoEdge};
743+
744+ if (std::find (validTypes.begin (), validTypes.end (),e->getType ()) != validTypes.end ()) {
745+ std::vector<Topo::TopoEntity *> topoEntities =
746+ Internal::SelectionHelper::selectSheet (dynamic_cast <Topo::TopoEntity *>(e), point);
747+
748+ std::vector<Utils::Entity *> entities;
749+ entities.reserve (topoEntities.size ());
750+ for (auto topoEntity: topoEntities) {
751+ entities.push_back (topoEntity);
752+ }
753+
754+ addToSelection (entities);
755+ }
756+ // If not topoEntity do nothing
757+ }
758+
759+ void SelectionManager::selectChord (Utils::Entity* e, double * point){
760+ // We need to filter to topoEntities
761+ std::vector<Utils::Entity::objectType> validTypes =
762+ {Utils::Entity::TopoBlock,Utils::Entity::TopoFace,Utils::Entity::TopoCoFace,
763+ Utils::Entity::TopoEdge,Utils::Entity::TopoCoEdge};
764+
765+ if (std::find (validTypes.begin (), validTypes.end (),e->getType ()) != validTypes.end ()) {
766+ std::vector<Topo::TopoEntity *> topoEntities =
767+ Internal::SelectionHelper::selectChord (dynamic_cast <Topo::TopoEntity *>(e), point);
768+
769+ std::vector<Utils::Entity *> entities;
770+ entities.reserve (topoEntities.size ());
771+ for (auto topoEntity: topoEntities) {
772+ entities.push_back (topoEntity);
773+ }
774+
775+ addToSelection (entities);
776+ }
777+ // If not topoEntity do nothing
778+ }
737779/* ----------------------------------------------------------------------------*/
738780} // end namespace Utils
739781/* ----------------------------------------------------------------------------*/
0 commit comments