Salome HOME
Merge branch 'python_parametric_api' of https://git.salome-platform.org/git/modules...
[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 XGUI_Workshop;
23
24 /**
25 * \ingroup Modules
26 * Customosation of ModuleBase_WidgetShapeSelector in order to provide 
27 * working with sketch specific objects.
28 */
29 class PARTSET_EXPORT PartSet_ExternalObjectsMgr
30 {
31  public:
32   /// Constructor
33   /// \param theExternal the external state
34   /// \param theDefaultValue the default value for the external object using
35   PartSet_ExternalObjectsMgr(const std::string& theExternal, const bool theDefaultValue);
36
37   virtual ~PartSet_ExternalObjectsMgr() {}
38
39   /// Returns the state whether the external object is used
40   bool useExternal() const { return myUseExternal; }
41
42   /// Checks validity of the given object
43   /// \param theObject an object to check
44   /// \return valid or not valid
45   bool isValidObject(const ObjectPtr& theObject);
46
47   /// Finds or create and external object
48   /// \param theSelectedObject an object
49   /// \param theShape a selected shape, which is used in the selection attribute
50   /// \param theSketch a current sketch
51   /// \param theTemporary the created external object is temporary, execute is not performed for it
52   /// \return the object
53   ObjectPtr externalObject(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape,
54                            const CompositeFeaturePtr& theSketch, const bool theTemporary = false);
55
56   // Removes the external presentation from the model
57   /// \param theSketch a current sketch
58   /// \param theFeature a current feature
59   /// \param theWorkshop a current workshop
60   /// \param theTemporary if true, a temporary external object is removed overwise all ext objects
61   void removeExternal(const CompositeFeaturePtr& theSketch,
62                       const FeaturePtr& theFeature,
63                       ModuleBase_IWorkshop* theWorkshop,
64                       const bool theTemporary);
65
66 protected:
67   /// Delete from the document the feature of the object. It deletes all objects, which refers to
68   /// the deleted one. The parameter feature is ignored even it refer to the deleted object.
69   /// \param theObject a removed object
70   /// \param theSketch a current sketch
71   /// \param theFeature a current feature
72   /// \param theWorkshop a current workshop
73   void removeExternalObject(const ObjectPtr& theObject,
74                             const CompositeFeaturePtr& theSketch,
75                             const FeaturePtr& theFeature,
76                             ModuleBase_IWorkshop* theWorkshop);
77
78   /// Returns the workshop
79   static XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop);
80
81 protected:
82   /// An external object
83   ObjectPtr myExternalObjectValidated;
84
85   /// Boolean value about the neccessity of the external object use
86   bool myUseExternal;
87 };
88
89 #endif