]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_ExternalObjectsMgr.h
Salome HOME
Issue #2120 - Crash when creating an arc passing through the arc connected to both...
[modules/shaper.git] / src / PartSet / PartSet_ExternalObjectsMgr.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_ExternalObjectsMgr.h
4 // Created:     15 Apr 2015
5 // Author:      Natalia Ermolaeva
6
7
8 #ifndef PartSet_ExternalObjectsMgr_H
9 #define PartSet_ExternalObjectsMgr_H
10
11 #include "PartSet.h"
12
13 #include <ModelAPI_CompositeFeature.h>
14 #include <ModelAPI_Object.h>
15 #include <GeomAPI_Shape.h>
16
17 #include <ModuleBase_Definitions.h>
18
19 #include <string>
20
21 class ModuleBase_IWorkshop;
22 class ModuleBase_ViewerPrs;
23 class XGUI_Workshop;
24
25 /**
26 * \ingroup Modules
27 * Customosation of ModuleBase_WidgetShapeSelector in order to provide 
28 * working with sketch specific objects.
29 */
30 class PARTSET_EXPORT PartSet_ExternalObjectsMgr
31 {
32  public:
33   /// Constructor
34   /// \param theExternal the external state
35   /// \param theCanCreateExternal the state if it can and should create external features
36   /// \param theDefaultValue the default value for the external object using
37   PartSet_ExternalObjectsMgr(const std::string& theExternal,
38                              const std::string& theCanCreateExternal,
39                              const bool theDefaultValue);
40
41   virtual ~PartSet_ExternalObjectsMgr() {}
42
43   /// Returns the state whether the external object is used
44   bool useExternal() const { return myUseExternal; }
45
46   /// Returns if new external objects can be created
47   /// \return boolean value
48   bool canCreateExternal() { return myCanCreateExternal;}
49
50   /// Checks validity of the given object
51   /// \param theObject an object to check
52   /// \return valid or not valid
53   bool isValidObject(const ObjectPtr& theObject);
54
55   /// Finds or create and external object
56   /// \param theSelectedObject an object
57   /// \param theShape a selected shape, which is used in the selection attribute
58   /// \param theSketch a current sketch
59   /// \param theTemporary the created external object is temporary, execute is not performed for it
60   /// \return the object
61   ObjectPtr externalObject(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape,
62                            const CompositeFeaturePtr& theSketch, const bool theTemporary = false);
63
64   // Removes the external presentation from the model
65   /// \param theSketch a current sketch
66   /// \param theFeature a current feature
67   /// \param theWorkshop a current workshop
68   /// \param theTemporary if true, a temporary external object is removed overwise all ext objects
69   void removeExternal(const CompositeFeaturePtr& theSketch,
70                       const FeaturePtr& theFeature,
71                       ModuleBase_IWorkshop* theWorkshop,
72                       const bool theTemporary);
73
74   /// Return an object and geom shape by the viewer presentation
75   /// \param thePrs a selection
76   /// \param theObject an output object
77   /// \param theShape a shape of the selection
78   virtual void getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
79                                 ObjectPtr& theObject,
80                                 GeomShapePtr& theShape,
81                                 ModuleBase_IWorkshop* theWorkshop,
82                                 const CompositeFeaturePtr& theSketch,
83                                 const bool isInValidate);
84
85 protected:
86   /// Delete from the document the feature of the object. It deletes all objects, which refers to
87   /// the deleted one. The parameter feature is ignored even it refer to the deleted object.
88   /// \param theObject a removed object
89   /// \param theSketch a current sketch
90   /// \param theFeature a current feature
91   /// \param theWorkshop a current workshop
92   void removeExternalObject(const ObjectPtr& theObject,
93                             const CompositeFeaturePtr& theSketch,
94                             const FeaturePtr& theFeature,
95                             ModuleBase_IWorkshop* theWorkshop);
96
97   /// Returns the workshop
98   static XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop);
99
100 protected:
101   /// An external object
102   ObjectPtr myExternalObjectValidated;
103
104   /// Boolean value about the neccessity of the external object use
105   bool myUseExternal;
106   /// Boolean value about the necessity of a new external object creation
107   bool myCanCreateExternal;
108 };
109
110 #endif