Salome HOME
Visualize feature result in green when the create/edit operation for the feature...
[modules/shaper.git] / src / PartSet / PartSet_OperationPrs.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_OperationPrs.h
4 // Created:     01 Jul 2015
5 // Author:      Natalia ERMOLAEVA
6
7 #ifndef PartSet_OperationPrs_H
8 #define PartSet_OperationPrs_H
9
10 #include "PartSet.h"
11
12 #include <ModelAPI_Object.h>
13 #include <ModelAPI_Feature.h>
14 #include <ModelAPI_Result.h>
15 #include <ModelAPI_Attribute.h>
16
17 #include <ModuleBase_IWorkshop.h>
18
19 #include <GeomAPI_Shape.h>
20
21 #include <ViewerData_AISShape.hxx>
22 #include <Standard_DefineHandle.hxx>
23
24 #include <QMap>
25 #include <QList>
26
27 #include <list>
28
29 DEFINE_STANDARD_HANDLE(PartSet_OperationPrs, ViewerData_AISShape)
30
31 class XGUI_Workshop;
32 class XGUI_Displayer;
33
34 /**
35 * \ingroup GUI
36 * A redefinition of standard AIS Interactive Object in order to provide colored presentation of
37 * a list of shapes. It contains a shapes where the parameter feature refers. It processes the following
38 * types of attributes: ModelAPI_AttributeSelectionList, ModelAPI_AttributeRefAttr,
39 * ModelAPI_AttributeSelection and ModelAPI_AttributeReference.
40 * The selection for this presentation is absent.
41 */
42 class PartSet_OperationPrs : public ViewerData_AISShape
43 {
44 public:
45   /// Constructor
46   Standard_EXPORT PartSet_OperationPrs(ModuleBase_IWorkshop* theWorkshop);
47
48   /// Returns true if the feature contains attributes, which has references to other features
49   /// \param theFeature a feature
50   /// \return boolean result
51   bool canActivate(const FeaturePtr& theFeature);
52
53   /// Sets the operation feature. It is used in Compute method to group the feature parameter shapes
54   /// theFeature a feature
55   void setFeature(const FeaturePtr& theFeature);
56
57   /// Returns true if the presentation 
58   bool dependOn(const ObjectPtr& theObject);
59
60   // Recompute internal list of shaped dependent on the current feature
61   void updateShapes();
62
63   DEFINE_STANDARD_RTTI(PartSet_OperationPrs)
64
65 protected:
66   /// Redefinition of virtual function
67   Standard_EXPORT virtual void Compute(
68             const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
69             const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
70
71   /// Redefinition of virtual function
72   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
73                                                 const Standard_Integer aMode) ;
74 private:
75   /// Return true if the object is visible. If the object is feature, it returns true
76   /// if all results of the feature are shown
77   /// \param theDisplayer a displayer
78   /// \param theObject an object
79   /// \return a boolean value
80   bool isVisible(XGUI_Displayer* theDislayer, const ObjectPtr& theObject);
81
82   /// Fills the map by the feature object and shapes, which should be visuaziled
83   /// Gets the feature attribute, collect objects to whom the attribute refers
84   /// \param theObjectShape an output map of objects
85   void getFeatureShapes(QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
86
87   /// Returns true if the attribute type belong to reference attribute
88   /// \param theAttribute an attribute
89   /// \return a boolean value
90   static bool isSelectionAttribute(const AttributePtr& theAttribute);
91
92   /// Converts the current workshop to XGUI workshop
93   /// \return a workshop instance
94   XGUI_Workshop* workshop() const;
95
96 private:
97   ModuleBase_IWorkshop* myWorkshop;
98   FeaturePtr myFeature; /// Reference to a feature object
99   QMap<ObjectPtr, QList<GeomShapePtr> > myFeatureShapes; /// visualized shapes
100   std::list<ResultPtr> myFeatureResults; /// visualized feature results
101 };
102
103
104 #endif