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