Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / ModuleBase / ModuleBase_ResultPrs.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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef ModuleBase_ResultPrs_H
22 #define ModuleBase_ResultPrs_H
23
24 #include "ModuleBase.h"
25
26 #include <ModelAPI_Result.h>
27
28 #include <ViewerData_AISShape.hxx>
29 #include <Standard_DefineHandle.hxx>
30 #include <StdSelect_BRepOwner.hxx>
31
32 #include <QMap>
33
34 DEFINE_STANDARD_HANDLE(ModuleBase_BRepOwner, StdSelect_BRepOwner)
35
36 /**
37 * \ingroup GUI
38 * A redefinition of standard BRep Owner in order to provide specific selection
39 * of CompSolid objects. This owner is created only for selection mode TopAbs_COMPSOLID
40 */
41 class ModuleBase_BRepOwner: public StdSelect_BRepOwner
42 {
43 public:
44   /// Constructor
45   /// \param aShape an owner shape
46   /// \param aPriority drawig priority
47   /// \param ComesFromDecomposition decomposition flag
48   ModuleBase_BRepOwner(const TopoDS_Shape& aShape,
49     const Standard_Integer aPriority = 0,
50     const Standard_Boolean ComesFromDecomposition = Standard_False)
51     : StdSelect_BRepOwner(aShape, aPriority, ComesFromDecomposition) {}
52
53   /// Highlight the presentation with the given color
54   /// \param aPM a presentations manager
55   /// \param theStyle a style of presentation
56   /// \param aMode a drawing mode
57   virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& aPM,
58     const Handle(Graphic3d_HighlightStyle)& theStyle, const Standard_Integer aMode = 0)
59   {
60     Selectable()->HilightOwnerWithColor(aPM, theStyle, this);
61   }
62
63   DEFINE_STANDARD_RTTIEXT(ModuleBase_BRepOwner, StdSelect_BRepOwner)
64 };
65
66
67
68 DEFINE_STANDARD_HANDLE(ModuleBase_ResultPrs, ViewerData_AISShape)
69
70 /**
71 * \ingroup GUI
72 * A redefinition of standard AIS Interactive Object in order to provide specific behaviour 
73 * for wire presentations based in a one plane
74 */
75 class ModuleBase_ResultPrs: public ViewerData_AISShape
76 {
77 public:
78   enum SelectionModes {
79     Sel_Result = TopAbs_SHAPE + 1 /// it should be combined with Compsolid results, so it is not
80                                   /// the Shape type. It is not defined in XML as compound type
81                                   /// because this type is processed as shape with compounds inside.
82   };
83
84 public:
85   /// Constructor
86   /// \param theResult a result object
87   Standard_EXPORT ModuleBase_ResultPrs(ResultPtr theResult);
88
89   //! Method which draws selected owners ( for fast presentation draw )
90   Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM,
91                                                const SelectMgr_SequenceOfOwner& theOwners);
92
93   //! Method which hilight an owner belonging to
94   //! this selectable object  ( for fast presentation draw )
95   Standard_EXPORT virtual void HilightOwnerWithColor(
96                                         const Handle(PrsMgr_PresentationManager3d)& thePM,
97                                         const Handle(Graphic3d_HighlightStyle)& theStyle,
98                                         const Handle(SelectMgr_EntityOwner)& theOwner);
99
100   /// Returns result object
101   Standard_EXPORT ResultPtr getResult() const { return myResult; }
102
103   /// Returns selection priorities that will be added to created selection owner
104   /// \return integer value
105   Standard_EXPORT int getAdditionalSelectionPriority() const
106   { return myAdditionalSelectionPriority; }
107
108   /// Appends a special priority for the mode of selection
109   /// \param theSelectionMode a mode of selection, used in ComputeSelection
110   /// \param thePriority a new priority value
111   Standard_EXPORT void setAdditionalSelectionPriority(const int thePriority);
112
113   DEFINE_STANDARD_RTTIEXT(ModuleBase_ResultPrs, ViewerData_AISShape)
114 protected:
115   /// Redefinition of virtual function
116   Standard_EXPORT virtual void Compute(
117     const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
118     const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
119
120   /// Redefinition of virtual function
121   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
122     const Standard_Integer aMode) ;
123
124 private:
125   /// Appens sensitive and owners for wires of the given shape into selection
126   /// \param theSelection a current filled selection
127   /// \param theShape a shape
128   void appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection,
129                             const TopoDS_Shape& theShape);
130
131   /// Reference to result object
132   ResultPtr myResult;
133
134   /// Original shape of the result object
135   TopoDS_Shape myOriginalShape;
136
137   /// selection priority that will be added to the standard
138   /// selection priority of the selection entity
139   int myAdditionalSelectionPriority;
140 };
141
142
143 #endif