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 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>>
41 getSelected(const SelectionPlace& thePlace = Browser) const = 0;
43 /// The values are appended to the first parameter list if the first list does not contain
44 /// an item with the same object
45 /// \param theValues a list of new values
46 /// \param theValuesTo a list, that will be changed
47 static void appendSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs>> theValues,
48 QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValuesTo);
50 /// Returns a list of viewer highlited presentations
51 /// \return list of presentations
52 virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getHighlighted() const = 0;
54 /// Fills the viewer presentation parameters by the parameters from the owner
55 /// \param thePrs a container for selection
56 /// \param theOwner a selection owner
57 virtual void fillPresentation(std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
58 const Handle(SelectMgr_EntityOwner)& theOwner) const = 0;
61 * Returns list of features currently selected in object browser
63 virtual QObjectPtrList selectedObjects() const = 0;
65 /// Set selected objects list
66 virtual void setSelectedObjects( const QObjectPtrList& ) const = 0;
69 * Returns list of currently selected results
71 virtual QObjectPtrList selectedPresentations() const = 0;
73 //! Returns list of currently selected QModelIndexes
74 virtual QModelIndexList selectedIndexes() const = 0;
76 //! Returns list of currently selected AIS objects
77 //! \param theList returning list of selected AIS objects
78 virtual void selectedAISObjects(AIS_ListOfInteractive& theList) const = 0;
80 //! Returns list of currently selected QModelIndexes
81 virtual ObjectPtr getSelectableObject(const Handle(SelectMgr_EntityOwner)& theOwner) const = 0;
83 //! Return the shape from the viewer presentation.
84 //! If the shape is equal to the shape of selected object, it returns an empty shape
85 //! \param thePrs a selected object
87 MODULEBASE_EXPORT ResultPtr getResult(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
89 //! Return the shape from the viewer presentation.
90 //! If the shape is equal to the shape of selected object, it returns an empty shape
91 //! \param thePrs a selected object
93 MODULEBASE_EXPORT GeomShapePtr getShape(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
95 //! Return the IO from the viewer presentation.
96 //! \param thePrs a selected object
97 //! \return an interactive object
98 virtual MODULEBASE_EXPORT
99 Handle(AIS_InteractiveObject) getIO(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs) = 0;
101 //! Wraps the object list into the viewer prs list
102 //! \param theObjects a list of objects
103 //! \return a list of prs, where only object is not empty
104 static MODULEBASE_EXPORT QList<std::shared_ptr<ModuleBase_ViewerPrs>> getViewerPrs(
105 const QObjectPtrList& theObjects);
107 /// Removes selection items where owners have equal vertices. The first
108 /// owner with the qual vertex stays in the list.
109 static MODULEBASE_EXPORT void filterSelectionOnEqualPoints
110 (QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theSelected);
112 /// Find vertex shape build by a Brep owner of the presentation if it exists
113 /// \param thePrs a viewer presentation
114 /// \return GeomAPI wrap of vertex
115 static std::shared_ptr<GeomAPI_Vertex> getPresentationVertex(
116 const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);