1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_ISelection.h
4 // Created: 2 June 2014
5 // Author: Vitaly Smetannikov
7 #ifndef ModuleBase_ISelection_H
8 #define ModuleBase_ISelection_H
10 #include "ModuleBase.h"
11 #include "ModuleBase_Definitions.h"
13 #include <ModelAPI_Result.h>
14 #include <GeomAPI_Shape.h>
15 #include <GeomAPI_Vertex.h>
17 #include <QModelIndexList>
18 #include <AIS_ListOfInteractive.hxx>
19 #include <NCollection_List.hxx>
20 #include <TopoDS_Shape.hxx>
24 class ModuleBase_ViewerPrs;
25 class Handle_SelectMgr_EntityOwner;
29 * A class which provides access to selection.
30 * A selection can be obtained as from a viewer as from Object browser in various forms
32 class ModuleBase_ISelection
35 /// Types of the selection place, where the selection is obtained
36 enum SelectionPlace { Browser, Viewer, AllControls };
38 /// Returns a list of viewer selected presentations
39 /// \return list of presentations
40 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getSelected(const SelectionPlace& thePlace = Browser) const = 0;
42 /// The values are appended to the first parameter list if the first list does not contain an item
43 /// with the same object
44 /// \param theValues a list of new values
45 /// \param theValuesTo a list, that will be changed
46 static void appendSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs>> theValues,
47 QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValuesTo);
49 /// Returns a list of viewer highlited presentations
50 /// \return list of presentations
51 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getHighlighted() const = 0;
53 /// Fills the viewer presentation parameters by the parameters from the owner
54 /// \param thePrs a container for selection
55 /// \param theOwner a selection owner
56 virtual void fillPresentation(std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
57 const Handle_SelectMgr_EntityOwner& theOwner) const = 0;
60 * Returns list of features currently selected in object browser
62 virtual QObjectPtrList selectedObjects() const = 0;
64 /// Set selected objects list
65 virtual void setSelectedObjects( const QObjectPtrList& ) const = 0;
68 * Returns list of currently selected results
70 virtual QObjectPtrList selectedPresentations() const = 0;
72 //! Returns list of currently selected QModelIndexes
73 virtual QModelIndexList selectedIndexes() const = 0;
75 //! Returns list of currently selected AIS objects
76 //! \param theList returning list of selected AIS objects
77 virtual void selectedAISObjects(AIS_ListOfInteractive& theList) const = 0;
79 //! Returns list of currently selected QModelIndexes
80 virtual ObjectPtr getSelectableObject(const Handle_SelectMgr_EntityOwner& theOwner) const = 0;
82 //! Return the shape from the viewer presentation.
83 //! If the shape is equal to the shape of selected object, it returns an empty shape
84 //! \param thePrs a selected object
86 MODULEBASE_EXPORT ResultPtr getResult(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
88 //! Return the shape from the viewer presentation.
89 //! If the shape is equal to the shape of selected object, it returns an empty shape
90 //! \param thePrs a selected object
92 MODULEBASE_EXPORT GeomShapePtr getShape(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
94 //! Return the IO from the viewer presentation.
95 //! \param thePrs a selected object
96 //! \return an interactive object
97 virtual MODULEBASE_EXPORT Handle(AIS_InteractiveObject) getIO(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs) = 0;
99 //! Wraps the object list into the viewer prs list
100 //! \param theObjects a list of objects
101 //! \return a list of prs, where only object is not empty
102 static MODULEBASE_EXPORT QList<std::shared_ptr<ModuleBase_ViewerPrs>> getViewerPrs(
103 const QObjectPtrList& theObjects);
105 /// Removes selection items where owners have equal vertices. The first
106 /// owner with the qual vertex stays in the list.
107 static MODULEBASE_EXPORT void filterSelectionOnEqualPoints
108 (QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theSelected);
110 /// Find vertex shape build by a Brep owner of the presentation if it exists
111 /// \param thePrs a viewer presentation
112 /// \return GeomAPI wrap of vertex
113 static std::shared_ptr<GeomAPI_Vertex> getPresentationVertex(
114 const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);