1 // Copyright (C) 2014-2019 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 email : webmaster.salome@opencascade.com
20 #ifndef PartSet_ExternalObjectsMgr_H
21 #define PartSet_ExternalObjectsMgr_H
25 #include <ModelAPI_CompositeFeature.h>
26 #include <ModelAPI_Object.h>
27 #include <GeomAPI_Shape.h>
29 #include <ModuleBase_Definitions.h>
33 class ModuleBase_IWorkshop;
34 class ModuleBase_ViewerPrs;
39 * Customosation of ModuleBase_WidgetShapeSelector in order to provide
40 * working with sketch specific objects.
42 class PARTSET_EXPORT PartSet_ExternalObjectsMgr
46 /// \param theExternal the external state
47 /// \param theCanCreateExternal the state if it can and should create external features
48 /// \param theDefaultValue the default value for the external object using
49 PartSet_ExternalObjectsMgr(const std::string& theExternal,
50 const std::string& theCanCreateExternal,
51 const bool theDefaultValue);
53 virtual ~PartSet_ExternalObjectsMgr() {}
55 /// Returns the state whether the external object is used
56 bool useExternal() const { return myUseExternal; }
58 /// Returns if new external objects can be created
59 /// \return boolean value
60 bool canCreateExternal() { return myCanCreateExternal;}
62 /// Checks validity of the given object
63 /// \param theObject an object to check
64 /// \return valid or not valid
65 bool isValidObject(const ObjectPtr& theObject);
67 /// Finds or create and external object
68 /// \param theSelectedObject an object
69 /// \param theShape a selected shape, which is used in the selection attribute
70 /// \param theSketch a current sketch
71 /// \param theTemporary the created external object is temporary, execute is not performed for it
72 /// \return the object
73 ObjectPtr externalObject(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape,
74 const CompositeFeaturePtr& theSketch, const bool theTemporary = false);
76 /// Finds or create and external object by selected circle center (PartSet_CenterPrs)
77 /// \param thePrs a selection
78 /// \param theSketch a current sketch
79 /// \param theTemporary the created external object is temporary, execute is not performed for it
80 /// \return the object
81 ObjectPtr externalCenterObject(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
82 const CompositeFeaturePtr& theSketch,
83 const bool theTemporary);
85 /// Returns created external object or NULL
86 /// \return an object instance
87 ObjectPtr getExternalObjectValidated() const { return myExternalObjectValidated; }
89 // Removes the external presentation from the model
90 /// \param theSketch a current sketch
91 /// \param theFeature a current feature
92 /// \param theWorkshop a current workshop
93 /// \param theTemporary if true, a temporary external object is removed overwise all ext objects
94 void removeExternal(const CompositeFeaturePtr& theSketch,
95 const FeaturePtr& theFeature,
96 ModuleBase_IWorkshop* theWorkshop,
97 const bool theTemporary);
99 /// Return an object and geom shape by the viewer presentation
100 /// \param thePrs a selection
101 /// \param theObject an output object
102 /// \param theShape a shape of the selection
103 virtual void getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
104 ObjectPtr& theObject,
105 GeomShapePtr& theShape,
106 ModuleBase_IWorkshop* theWorkshop,
107 const CompositeFeaturePtr& theSketch,
108 const bool isInValidate);
111 /// Delete from the document the feature of the object. It deletes all objects, which refers to
112 /// the deleted one. The parameter feature is ignored even it refer to the deleted object.
113 /// \param theObject a removed object
114 /// \param theSketch a current sketch
115 /// \param theFeature a current feature
116 /// \param theWorkshop a current workshop
117 void removeExternalObject(const ObjectPtr& theObject,
118 const CompositeFeaturePtr& theSketch,
119 const FeaturePtr& theFeature,
120 ModuleBase_IWorkshop* theWorkshop);
122 /// Returns the workshop
123 static XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop);
126 /// An external object
127 ObjectPtr myExternalObjectValidated;
129 /// Boolean value about the neccessity of the external object use
131 /// Boolean value about the necessity of a new external object creation
132 bool myCanCreateExternal;