1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef PartSet_OperationPrs_H
22 #define PartSet_OperationPrs_H
26 #include <ModelAPI_Object.h>
27 #include <ModelAPI_Feature.h>
28 #include <ModelAPI_Result.h>
29 #include <ModelAPI_Attribute.h>
31 #include <ModuleBase_IWorkshop.h>
33 #include <GeomAPI_Shape.h>
35 #include <ViewerData_AISShape.hxx>
36 #include <Standard_DefineHandle.hxx>
38 #include <Quantity_Color.hxx>
39 #include <NCollection_List.hxx>
40 #include <NCollection_DataMap.hxx>
41 #include <TopoDS_Shape.hxx>
42 #include <AIS_InteractiveObject.hxx>
49 DEFINE_STANDARD_HANDLE(PartSet_OperationPrs, ViewerData_AISShape)
52 class SelectMgr_Selection;
56 * A redefinition of standard AIS Interactive Object in order to provide colored presentation of
57 * a list of shapes. It contains a shapes where the parameter feature refers. It processes the following
58 * types of attributes: ModelAPI_AttributeSelectionList, ModelAPI_AttributeRefAttr,
59 * ModelAPI_AttributeSelection and ModelAPI_AttributeReference.
60 * The selection for this presentation is absent.
62 class PartSet_OperationPrs : public ViewerData_AISShape
66 Standard_EXPORT PartSet_OperationPrs(ModuleBase_IWorkshop* theWorkshop);
68 /// Returns true if the feature contains shapes or results
71 /// Sets the colors for the presentation compute
72 /// \param theColor an argument shapes color
73 void setShapeColor(const Quantity_Color& theColor);
75 /// Switch on using of the AIS presentation with of the shape object increased on the delta
78 DEFINE_STANDARD_RTTIEXT(PartSet_OperationPrs, ViewerData_AISShape)
81 /// Redefinition of virtual function
82 Standard_EXPORT virtual void Compute(
83 const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
84 const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
86 /// Redefinition of virtual function
87 Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
88 const Standard_Integer aMode) ;
91 /// list of visualized shapes
92 /// \return a map of shapes
93 NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)>& shapesMap();
96 /// Fills the map by the feature object and shapes, which should be visuaziled
97 /// Gets feature attributes, collect objects to whom the attributes refer
98 /// \param theFeature a current feature
99 /// \param theWorkshop a current workshop
100 /// \param theObjectShapes an output map
101 /// \param theObjectShape an output map of objects
102 static void getFeatureShapes(const FeaturePtr& theFeature,
103 ModuleBase_IWorkshop* theWorkshop,
104 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
106 /// Fills the map by the feature object and shapes, which should be visuaziled
107 /// Gets feature attributes, collect objects to whom the attributes refer
108 /// \param theFeature a current feature
109 /// \param theWorkshop a current workshop
110 /// \param theObjectShapes an output map
111 /// \param theObjectShape an output map of objects
112 static void getResultShapes(const FeaturePtr& theFeature,
113 ModuleBase_IWorkshop* theWorkshop,
114 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes,
115 const bool theListShouldBeCleared = true);
117 /// Fills the map by the feature presentation if the feature is presentable
118 /// \param theFeature a current feature
119 /// \param theWorkshop a current workshop
120 /// \param theObjectShapes an output map
121 /// \param theObjectShape an output map of objects
122 static void getPresentationShapes(const FeaturePtr& theFeature,
123 ModuleBase_IWorkshop* theWorkshop,
124 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes,
125 const bool theListShouldBeCleared = true);
127 /// Fills the map by the feature object and shapes, which should be visuaziled
128 /// Gets the active widget, obtain the highlighted presentations if it has such and
129 /// fill map by object and shapes
130 /// \param theWorkshop a current workshop
131 /// \param theObjectShapes an output map of objects
132 static void getHighlightedShapes(ModuleBase_IWorkshop* theWorkshop,
133 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
135 /// Returns true if the attribute type belong to reference attribute
136 /// \param theAttribute an attribute
137 /// \return a boolean value
138 static bool isSelectionAttribute(const AttributePtr& theAttribute);
140 /// Appends the shape for the result into the container if the result is visible and
141 /// the shape is not null.
142 /// \param theWorkshop a current workshop
143 /// \param theResult an object to be appended
144 /// \param theGeomShape a shape to be appended
145 /// \param theObjectShapes a filled container
146 static void addValue(const ObjectPtr& theObject, const GeomShapePtr& theShape,
147 const FeaturePtr& theFeature, ModuleBase_IWorkshop* theWorkshop,
148 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
150 /// Appends the shape for the result into the container if the result is visible and
151 /// the shape is not null.
152 /// \param theWorkshop a current workshop
153 /// \param theObject an object to be appended
154 /// \param theGeomShape a shape to be appended
155 /// \param theObjectShapes a filled container
156 static void appendShapeIfVisible(ModuleBase_IWorkshop* theWorkshop,
157 const ObjectPtr& theObject,
158 GeomShapePtr theGeomShape,
159 QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
161 /// Fills the list of shapes by map of model objects
162 /// \param theFeatureShape a container to find shapes
163 /// \param theShapesMap an out container
164 static void fillShapeList(const QMap<ObjectPtr, QList<GeomShapePtr> >& theFeatureShapes,
165 ModuleBase_IWorkshop* theWorkshop,
166 NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)>& theShapeToPrsMap);
169 /// list of visualized shapes
170 NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)> myShapeToPrsMap;
172 ModuleBase_IWorkshop* myWorkshop; /// current workshop
173 Quantity_Color myShapeColor; /// color of feature depended shapes
175 /// flag if the width of a shape object should be used for the shape visualization
178 friend class PartSet_CustomPrs;