]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_ISelection.h
Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / ModuleBase / ModuleBase_ISelection.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
18 //
19
20 #ifndef ModuleBase_ISelection_H
21 #define ModuleBase_ISelection_H
22
23 #include "ModuleBase.h"
24 #include "ModuleBase_Definitions.h"
25
26 #include <ModelAPI_Result.h>
27 #include <GeomAPI_Shape.h>
28 #include <GeomAPI_Vertex.h>
29
30 #include <QModelIndexList>
31 #include <AIS_ListOfInteractive.hxx>
32 #include <NCollection_List.hxx>
33 #include <TopoDS_Shape.hxx>
34
35 #include <QList>
36
37 class ModuleBase_ViewerPrs;
38 class SelectMgr_EntityOwner;
39
40 /**
41 * \ingroup GUI
42 * A class which provides access to selection.
43 * A selection can be obtained as from a viewer as from Object browser in various forms
44 */
45 class ModuleBase_ISelection
46 {
47  public:
48    /// Types of the selection place, where the selection is obtained
49    enum SelectionPlace { Browser, Viewer, AllControls };
50
51   /// Returns a list of viewer selected presentations
52   /// \return list of presentations
53   virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>>
54     getSelected(const SelectionPlace& thePlace = Browser) const = 0;
55
56   /// The values are appended to the first parameter list if the first list does not contain
57   /// an item with the same object
58   /// \param theValues a list of new values
59   /// \param theValuesTo a list, that will be changed
60   static void appendSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs>> theValues,
61                              QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValuesTo);
62
63   /// Returns a list of viewer highlited presentations
64   /// \return list of presentations
65   virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getHighlighted() const = 0;
66
67   /// Fills the viewer presentation parameters by the parameters from the owner
68   /// \param thePrs a container for selection
69   /// \param theOwner a selection owner
70   virtual void fillPresentation(std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
71                                 const Handle(SelectMgr_EntityOwner)& theOwner) const = 0;
72
73   /**
74    * Returns list of features currently selected in object browser
75    */
76   virtual QObjectPtrList selectedObjects() const = 0;
77
78   /// Set selected objects list
79   virtual void setSelectedObjects( const QObjectPtrList& ) const = 0;
80
81   /**
82    * Returns list of currently selected results
83    */
84   virtual QObjectPtrList selectedPresentations() const = 0;
85
86   //! Returns list of currently selected QModelIndexes
87   virtual QModelIndexList selectedIndexes() const = 0;
88
89   //! Returns list of currently selected AIS objects
90   //! \param theList returning list of selected AIS objects
91   virtual void selectedAISObjects(AIS_ListOfInteractive& theList) const = 0;
92
93   //! Returns list of currently selected QModelIndexes
94   virtual ObjectPtr getSelectableObject(const Handle(SelectMgr_EntityOwner)& theOwner) const = 0;
95
96   //! Return the shape from the viewer presentation.
97   //! If the shape is equal to the shape of selected object, it returns an empty shape
98   //! \param thePrs a selected object
99   //! \return a shape
100   MODULEBASE_EXPORT ResultPtr getResult(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
101
102   //! Return the shape from the viewer presentation.
103   //! If the shape is equal to the shape of selected object, it returns an empty shape
104   //! \param thePrs a selected object
105   //! \return a shape
106   MODULEBASE_EXPORT GeomShapePtr getShape(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
107
108   //! Return the IO from the viewer presentation.
109   //! \param thePrs a selected object
110   //! \return an interactive object
111   virtual MODULEBASE_EXPORT
112     Handle(AIS_InteractiveObject) getIO(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs) = 0;
113
114   //! Wraps the object list into the viewer prs list
115   //! \param theObjects a list of objects
116   //! \return a list of prs, where only object is not empty
117   static MODULEBASE_EXPORT QList<std::shared_ptr<ModuleBase_ViewerPrs>> getViewerPrs(
118                                                        const QObjectPtrList& theObjects);
119
120   /// Removes selection items where owners have equal vertices. The first
121   /// owner with the qual vertex stays in the list.
122   static MODULEBASE_EXPORT void filterSelectionOnEqualPoints
123                                       (QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theSelected);
124 private:
125   /// Find vertex shape build by a Brep owner of the presentation if it exists
126   /// \param thePrs a viewer presentation
127   /// \return GeomAPI wrap of vertex
128   static std::shared_ptr<GeomAPI_Vertex> getPresentationVertex(
129                                                const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
130 };
131
132 #endif