Skip to content

Commit 33e6e2b

Browse files
authored
Merge pull request #162 from LIHPC-Computational-Geometry/sheet_and_chord_selection
Sheet and chord selection
2 parents 53b47c2 + bf321f2 commit 33e6e2b

File tree

72 files changed

+569
-172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+569
-172
lines changed

Docs/pages/raccourcis.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ suivants :
9090

9191
- **Sélection** d’une entité : touche **P** (ou **clic gauche**
9292
souris). Possibilité d’étendre la sélection en pressant simultanément
93-
la touche **CTRL**.
93+
la touche **CTRL**. La combinaison **ALT+clic gauche** permet la sélection
94+
de feuillets en fonction du filtre de sélection appliqué. La combinaison
95+
**SHIFT+clic gauche** permet la sélection de corde en fonction du filtre
96+
de sélection appliqué.
9497

9598
Il est possible d'annuler la dernière opération de sélection effectuée : combinaison de touches **SHIFT-Z**
9699

src/Core/Group/GroupManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,10 @@ Group0D* GroupManager::getGroup0D(const std::string& gr_name, const bool excepti
320320
return gr;
321321
}
322322
/*----------------------------------------------------------------------------*/
323-
void GroupManager::getGroups(std::vector<GroupEntity*>& grp, Utils::SelectionManager::DIM dimensions, const bool onlyLive) const
323+
void GroupManager::getGroups(std::vector<GroupEntity*>& grp, Internal::SelectionManager::DIM dimensions, const bool onlyLive) const
324324
{
325325
for (int i = 0; i < 4; i++){
326-
const Utils::SelectionManager::DIM dim = Utils::SelectionManager::dimensionToDimensions(i);
326+
const Internal::SelectionManager::DIM dim = Internal::SelectionManager::dimensionToDimensions(i);
327327
if (0 == (dimensions&dim))
328328
continue;
329329
switch (i)

src/Core/Internal/Context.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ Context::Context(const std::string& name, bool withStdOutputs)
344344
Mgx3D::Utils::GraphicalRepresentationFactoryIfc::setInstance (
345345
new Mgx3D::Utils::DefaultGraphicalRepresentationFactory ( ));
346346

347-
Utils::SelectionManager* selectionManager =
348-
new Utils::SelectionManager (createName ("SelectionManager"), getLogStream ( ));
347+
Internal::SelectionManager* selectionManager =
348+
new Internal::SelectionManager (createName ("SelectionManager"), getLogStream ( ));
349349
m_selection_manager = selectionManager;
350350
Utils::CommandManager* commandManager =
351351
new Utils::CommandManager (createName ("CommandManager"));
@@ -867,19 +867,19 @@ Mgx3D::Utils::CommandManager& Context::getLocalCommandManager()
867867
return *manager;
868868
}
869869
/*----------------------------------------------------------------------------*/
870-
Mgx3D::Utils::SelectionManager& Context::getSelectionManager ( )
870+
Mgx3D::Internal::SelectionManager& Context::getSelectionManager ( )
871871
{
872872
CHECK_NULL_PTR_ERROR (m_selection_manager)
873873
return *m_selection_manager;
874874
}
875875
/*----------------------------------------------------------------------------*/
876-
const Mgx3D::Utils::SelectionManager& Context::getSelectionManager ( ) const
876+
const Mgx3D::Internal::SelectionManager& Context::getSelectionManager ( ) const
877877
{
878878
CHECK_NULL_PTR_ERROR (m_selection_manager)
879879
return *m_selection_manager;
880880
}
881881
/*----------------------------------------------------------------------------*/
882-
void Context::setSelectionManager (Mgx3D::Utils::SelectionManager* mgr)
882+
void Context::setSelectionManager (Mgx3D::Internal::SelectionManager* mgr)
883883
{
884884
delete m_selection_manager;
885885
m_selection_manager = mgr;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//
2+
// Created by calderans on 06/08/25.
3+
//
4+
#include "Internal/Context.h"
5+
#include "Internal/SelectionHelper.h"
6+
#include "Topo/TopoEntity.h"
7+
#include "Topo/TopoHelper.h"
8+
9+
/*----------------------------------------------------------------------------*/
10+
namespace Mgx3D {
11+
/*----------------------------------------------------------------------------*/
12+
namespace Internal {
13+
/*------------------------------------------------------------------------*/
14+
SelectionHelper::SelectionHelper() {
15+
MGX_FORBIDDEN("SelectionHelper::SelectionHelper is not allowed.");
16+
} // SelectionHelper::SelectionHelper
17+
18+
/*----------------------------------------------------------------------------*/
19+
SelectionHelper::SelectionHelper(const SelectionHelper &) {
20+
MGX_FORBIDDEN("SelectionHelper::SelectionHelper is not allowed.");
21+
} // SelectionHelper::SelectionHelper(const SelectionHelper&)
22+
23+
/*----------------------------------------------------------------------------*/
24+
SelectionHelper &SelectionHelper::operator=(const SelectionHelper &) {
25+
MGX_FORBIDDEN("SelectionHelper::operator = is not allowed.");
26+
return *this;
27+
} // SelectionHelper::operator =
28+
29+
/*----------------------------------------------------------------------------*/
30+
SelectionHelper::~SelectionHelper() {
31+
MGX_FORBIDDEN("SelectionHelper::~SelectionHelper is not allowed.");
32+
} // SelectionHelper::~SelectionHelper
33+
34+
/*------------------------------------------------------------------------*/
35+
36+
std::vector<Topo::TopoEntity*> SelectionHelper::selectSheet(Topo::TopoEntity *entity, double* point) {
37+
return Topo::TopoHelper::getSheet(entity, point);
38+
}
39+
40+
/*------------------------------------------------------------------------*/
41+
42+
std::vector<Topo::TopoEntity*> SelectionHelper::selectChord(Topo::TopoEntity *entity, double* point) {
43+
return Topo::TopoHelper::getChord(entity, point);
44+
}
45+
}
46+
}
47+
48+

src/Utils/SelectionManager.cpp renamed to src/Core/Internal/SelectionManager.cpp

Lines changed: 69 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
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
/*----------------------------------------------------------------------------*/
2122
namespace 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

225226
vector<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
/*----------------------------------------------------------------------------*/

src/Utils/SelectionManagerDimFilter.cpp renamed to src/Core/Internal/SelectionManagerDimFilter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* \date 14/10/2013
55
*/
66

7-
#include "Utils/SelectionManagerDimFilter.h"
7+
#include "Internal/SelectionManagerDimFilter.h"
88

99
#include <TkUtil/UTF8String.h>
1010
#include <TkUtil/Exception.h>
@@ -22,7 +22,7 @@ using namespace std;
2222
namespace Mgx3D {
2323

2424
/*----------------------------------------------------------------------------*/
25-
namespace Utils {
25+
namespace Internal {
2626

2727
/*----------------------------------------------------------------------------*/
2828

0 commit comments

Comments
 (0)