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 PartSet_OperationPrs_H
21 #define PartSet_OperationPrs_H
25 #include <ModelAPI_Object.h>
26 #include <ModelAPI_Feature.h>
27 #include <ModelAPI_Result.h>
28 #include <ModelAPI_Attribute.h>
30 #include <ModuleBase_IWorkshop.h>
32 #include <GeomAPI_Shape.h>
34 #include <ViewerData_AISShape.hxx>
35 #include <Standard_DefineHandle.hxx>
37 #include <Quantity_Color.hxx>
38 #include <NCollection_List.hxx>
39 #include <NCollection_DataMap.hxx>
40 #include <TopoDS_Shape.hxx>
41 #include <AIS_InteractiveObject.hxx>
48 DEFINE_STANDARD_HANDLE(PartSet_OperationPrs, ViewerData_AISShape)
51 class SelectMgr_Selection;
55 * A redefinition of standard AIS Interactive Object in order to provide colored presentation of
56 * a list of shapes. It contains a shapes where the parameter feature refers. It processes the following
57 * types of attributes: ModelAPI_AttributeSelectionList, ModelAPI_AttributeRefAttr,
58 * ModelAPI_AttributeSelection and ModelAPI_AttributeReference.
59 * The selection for this presentation is absent.
61 class PartSet_OperationPrs : public ViewerData_AISShape
65 Standard_EXPORT PartSet_OperationPrs(ModuleBase_IWorkshop* theWorkshop);
67 /// Returns true if the feature contains shapes or results
70 /// Sets the colors for the presentation compute
71 /// \param theColor an argument shapes color
72 void setShapeColor(const Quantity_Color& theColor);
74 /// Switch on using of the AIS presentation with of the shape object increased on the delta
77 DEFINE_STANDARD_RTTIEXT(PartSet_OperationPrs, ViewerData_AISShape)
80 /// Redefinition of virtual function
81 Standard_EXPORT virtual void Compute(
82 const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
83 const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
85 /// Redefinition of virtual function
86 Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
87 const Standard_Integer aMode) ;
90 /// list of visualized shapes
91 /// \return a map of shapes
92 NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)>& shapesMap();
95 /// Fills the map by the feature object and shapes, which should be visuaziled
96 /// Gets feature attributes, collect objects to whom the attributes refer
97 /// \param theFeature a current feature
98 /// \param theWorkshop a current workshop
99 /// \param theObjectShapes an output map
100 /// \param theObjectShape an output map of objects
101 static void getFeatureShapes(const FeaturePtr& theFeature,
102 ModuleBase_IWorkshop* theWorkshop,
103 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
105 /// Fills the map by the feature object and shapes, which should be visuaziled
106 /// Gets feature attributes, collect objects to whom the attributes refer
107 /// \param theFeature a current feature
108 /// \param theWorkshop a current workshop
109 /// \param theObjectShapes an output map
110 /// \param theObjectShape an output map of objects
111 static void getResultShapes(const FeaturePtr& theFeature,
112 ModuleBase_IWorkshop* theWorkshop,
113 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes,
114 const bool theListShouldBeCleared = true);
116 /// Fills the map by the feature presentation if the feature is presentable
117 /// \param theFeature a current feature
118 /// \param theWorkshop a current workshop
119 /// \param theObjectShapes an output map
120 /// \param theObjectShape an output map of objects
121 static void getPresentationShapes(const FeaturePtr& theFeature,
122 ModuleBase_IWorkshop* theWorkshop,
123 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes,
124 const bool theListShouldBeCleared = true);
126 /// Fills the map by the feature object and shapes, which should be visuaziled
127 /// Gets the active widget, obtain the highlighted presentations if it has such and
128 /// fill map by object and shapes
129 /// \param theWorkshop a current workshop
130 /// \param theObjectShapes an output map of objects
131 static void getHighlightedShapes(ModuleBase_IWorkshop* theWorkshop,
132 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
134 /// Returns true if the attribute type belong to reference attribute
135 /// \param theAttribute an attribute
136 /// \return a boolean value
137 static bool isSelectionAttribute(const AttributePtr& theAttribute);
139 /// Appends the shape for the result into the container if the result is visible and
140 /// the shape is not null.
141 /// \param theWorkshop a current workshop
142 /// \param theResult an object to be appended
143 /// \param theGeomShape a shape to be appended
144 /// \param theObjectShapes a filled container
145 static void addValue(const ObjectPtr& theObject, const GeomShapePtr& theShape,
146 const FeaturePtr& theFeature, ModuleBase_IWorkshop* theWorkshop,
147 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
149 /// Appends the shape for the result into the container if the result is visible and
150 /// the shape is not null.
151 /// \param theWorkshop a current workshop
152 /// \param theObject an object to be appended
153 /// \param theGeomShape a shape to be appended
154 /// \param theObjectShapes a filled container
155 static void appendShapeIfVisible(ModuleBase_IWorkshop* theWorkshop,
156 const ObjectPtr& theObject,
157 GeomShapePtr theGeomShape,
158 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
160 /// Fills the list of shapes by map of model objects
161 /// \param theFeatureShape a container to find shapes
162 /// \param theShapesMap an out container
163 static void fillShapeList(const QMap<ObjectPtr, QList<GeomShapePtr> >& theFeatureShapes,
164 ModuleBase_IWorkshop* theWorkshop,
165 NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)>& theShapeToPrsMap);
168 /// list of visualized shapes
169 NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)> myShapeToPrsMap;
171 ModuleBase_IWorkshop* myWorkshop; /// current workshop
172 Quantity_Color myShapeColor; /// color of feature depended shapes
174 /// flag if the width of a shape object should be used for the shape visualization
177 friend class PartSet_CustomPrs;