1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef ModuleBase_ResultPrs_H
21 #define ModuleBase_ResultPrs_H
23 #include "ModuleBase.h"
25 #include <ModelAPI_Result.h>
27 #include <BRep_Builder.hxx>
28 #include <NCollection_List.hxx>
29 #include <ViewerData_AISShape.hxx>
30 #include <Standard_DefineHandle.hxx>
31 #include <TopoDS_Compound.hxx>
35 class AIS_ColoredDrawer;
36 class AIS_InteractiveContext;
38 DEFINE_STANDARD_HANDLE(ModuleBase_ResultPrs, ViewerData_AISShape)
42 * A redefinition of standard AIS Interactive Object in order to provide specific behaviour
43 * for wire presentations based in a one plane
45 class ModuleBase_ResultPrs: public ViewerData_AISShape
49 Sel_Result = TopAbs_SHAPE + 1 /// it should be combined with Compsolid results, so it is not
50 /// the Shape type. It is not defined in XML as compound type
51 /// because this type is processed as shape with compounds inside.
56 /// \param theResult a result object
57 Standard_EXPORT ModuleBase_ResultPrs(ResultPtr theResult);
59 //! Method which draws selected owners ( for fast presentation draw )
60 Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM,
61 const SelectMgr_SequenceOfOwner& theOwners);
63 //! Method which hilight an owner belonging to
64 //! this selectable object ( for fast presentation draw )
65 Standard_EXPORT virtual void HilightOwnerWithColor(
66 const Handle(PrsMgr_PresentationManager3d)& thePM,
67 const Handle(Prs3d_Drawer)& theStyle,
68 const Handle(SelectMgr_EntityOwner)& theOwner);
70 /// Returns result object
71 Standard_EXPORT ResultPtr getResult() const { return myResult; }
73 /// Returns selection priorities that will be added to created selection owner
74 /// \return integer value
75 Standard_EXPORT int getAdditionalSelectionPriority() const
76 { return myAdditionalSelectionPriority; }
78 /// Appends a special priority for the mode of selection
79 /// \param theSelectionMode a mode of selection, used in ComputeSelection
80 /// \param thePriority a new priority value
81 Standard_EXPORT void setAdditionalSelectionPriority(const int thePriority);
83 //! Updates color of sub shape drawer
84 Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor);
86 /// Change presentation to have given shape hidden.
87 /// It suports FACE type of the shape to be hidden.
88 /// If presentation type is greater than FACE, the SHELL with be shown with the FACE hidden
89 /// It is possible to hide more than one FACE by calling the method with given FACES
90 /// Visual state of the face is controlled by the second parameter
91 /// \param theShapes a container of shape objects
92 /// \returns true if the presentation is changed, or false (if for example it was hidden)
93 Standard_EXPORT bool setSubShapeHidden(const NCollection_List<TopoDS_Shape>& theShapes);
95 /// Returns true if parameter shape has been hidden
96 /// \param theShape sub-shape of the presentation shape
97 /// \return boolean value
98 Standard_EXPORT bool isSubShapeHidden(const TopoDS_Shape& theShape);
100 /// Returns true if there are no hidden sub shapes or original shape has at least one not hidden
101 /// \param theShapesToSkip container of shape to be hidden in the presentation (faces)
102 /// \return boolean value
103 Standard_EXPORT bool hasSubShapeVisible(const NCollection_List<TopoDS_Shape>& theShapesToSkip);
105 /// Set transparency of hidden sub shapes: if value is 1, shapes are entirely hidden
106 /// \param theTransparency transparency value
107 /// \return false if parameter is out of [0, 1]
108 Standard_EXPORT bool setHiddenSubShapeTransparency(double theTransparency);
110 Standard_EXPORT TopoDS_Shape originalShape() const { return myOriginalShape; }
112 Standard_EXPORT bool isSubstituted() const { return myIsSubstituted; }
115 DEFINE_STANDARD_RTTIEXT(ModuleBase_ResultPrs, ViewerData_AISShape)
118 /// Redefinition of virtual function
119 Standard_EXPORT virtual void Compute(
120 const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
121 const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
123 /// Redefinition of virtual function
124 Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
125 const Standard_Integer theMode) ;
128 /// If the shape of this presentation is Vertex, it appends custom sensitive and owners for it.
129 /// Owner is a usual Brep owner with "isDecomposite" in true. It is necessary to have "Ring"
130 /// highlight/selected marker.
131 /// \param theSelection a current filled selection
132 /// \param theMode a selection mode
133 /// \return true if the owner is created
134 bool appendVertexSelection(const Handle(SelectMgr_Selection)& aSelection,
135 const Standard_Integer theMode);
137 /// Creates compound of vertices, edges and faces.
138 /// If the shape is COMPOUND, iterate by sub-shapes.
139 /// If the shape is SOLID/SHEL, explore shape by FACES,
140 /// If the shape is WIRE, explore shape by EDGES
141 /// \param theBuilder result compound builder
142 /// \param theCompound the result shape
143 /// \param theShape the processed shape
144 /// \param theHiddenSubShapes container of shapes to be skipped (faces)
145 void collectSubShapes(BRep_Builder& theBuilder, TopoDS_Shape& theCompound,
146 const TopoDS_Shape& theShape, const NCollection_List<TopoDS_Shape>& theHiddenSubShapes);
148 void setEdgesDefaultColor();
151 /// Reference to result object
154 /// Original shape of the result object
155 TopoDS_Shape myOriginalShape;
157 bool myIsSubstituted;
159 /// Container of original Shape sub shape to be hidden and not selectable
160 NCollection_List<TopoDS_Shape> myHiddenSubShapes;
161 TopoDS_Compound myHiddenCompound; /// compound of hidden sub shapes
162 double myTransparency; ///< transparency of hidden shapes, where 0 - there is no transparency
163 Handle(AIS_ColoredDrawer) myHiddenSubShapesDrawer; ///< drawer for hidden sub shapes
165 /// selection priority that will be added to the standard
166 /// selection priority of the selection entity
167 int myAdditionalSelectionPriority;