1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSet_ExternalObjectsMgr.h
4 // Created: 15 Apr 2015
5 // Author: Natalia Ermolaeva
8 #ifndef PartSet_ExternalObjectsMgr_H
9 #define PartSet_ExternalObjectsMgr_H
13 #include <ModelAPI_CompositeFeature.h>
14 #include <ModelAPI_Object.h>
15 #include <GeomAPI_Shape.h>
17 #include <ModuleBase_Definitions.h>
21 class ModuleBase_IWorkshop;
22 class ModuleBase_ViewerPrs;
27 * Customosation of ModuleBase_WidgetShapeSelector in order to provide
28 * working with sketch specific objects.
30 class PARTSET_EXPORT PartSet_ExternalObjectsMgr
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);
41 virtual ~PartSet_ExternalObjectsMgr() {}
43 /// Returns the state whether the external object is used
44 bool useExternal() const { return myUseExternal; }
46 /// Returns if new external objects can be created
47 /// \return boolean value
48 bool canCreateExternal() { return myCanCreateExternal;}
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);
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);
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);
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,
80 GeomShapePtr& theShape,
81 ModuleBase_IWorkshop* theWorkshop,
82 const CompositeFeaturePtr& theSketch,
83 const bool isInValidate);
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);
97 /// Returns the workshop
98 static XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop);
101 /// An external object
102 ObjectPtr myExternalObjectValidated;
104 /// Boolean value about the neccessity of the external object use
106 /// Boolean value about the necessity of a new external object creation
107 bool myCanCreateExternal;