1 // Copyright (C) 2014-2017 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<mailto: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 // Removes the external presentation from the model
77 /// \param theSketch a current sketch
78 /// \param theFeature a current feature
79 /// \param theWorkshop a current workshop
80 /// \param theTemporary if true, a temporary external object is removed overwise all ext objects
81 void removeExternal(const CompositeFeaturePtr& theSketch,
82 const FeaturePtr& theFeature,
83 ModuleBase_IWorkshop* theWorkshop,
84 const bool theTemporary);
86 /// Return an object and geom shape by the viewer presentation
87 /// \param thePrs a selection
88 /// \param theObject an output object
89 /// \param theShape a shape of the selection
90 virtual void getGeomSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
92 GeomShapePtr& theShape,
93 ModuleBase_IWorkshop* theWorkshop,
94 const CompositeFeaturePtr& theSketch,
95 const bool isInValidate);
98 /// Delete from the document the feature of the object. It deletes all objects, which refers to
99 /// the deleted one. The parameter feature is ignored even it refer to the deleted object.
100 /// \param theObject a removed object
101 /// \param theSketch a current sketch
102 /// \param theFeature a current feature
103 /// \param theWorkshop a current workshop
104 void removeExternalObject(const ObjectPtr& theObject,
105 const CompositeFeaturePtr& theSketch,
106 const FeaturePtr& theFeature,
107 ModuleBase_IWorkshop* theWorkshop);
109 /// Returns the workshop
110 static XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop);
113 /// An external object
114 ObjectPtr myExternalObjectValidated;
116 /// Boolean value about the neccessity of the external object use
118 /// Boolean value about the necessity of a new external object creation
119 bool myCanCreateExternal;