Salome HOME
03b8097301c22bb44a5697b1288adb47623d50be
[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 /**
22 * \ingroup Modules
23 * Customosation of ModuleBase_WidgetShapeSelector in order to provide 
24 * working with sketch specific objects.
25 */
26 class PARTSET_EXPORT PartSet_ExternalObjectsMgr
27 {
28  public:
29   /// Constructor
30   /// \param theExternal the external state
31   /// \param theDefaultValue the default value for the external object using
32   PartSet_ExternalObjectsMgr(const std::string& theExternal, const bool theDefaultValue);
33
34   virtual ~PartSet_ExternalObjectsMgr() {}
35
36   /// Returns the state whether the external object is used
37   bool useExternal() const { return myUseExternal; }
38
39   bool isValidObject(const ObjectPtr& theObject);
40
41   /// Finds or create and external object
42   /// \param theSelectedObject an object
43   /// \param theShape a selected shape, which is used in the selection attribute
44   /// \param theSketch a current sketch
45   /// \return the object
46   ObjectPtr externalObject(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape,
47                            const CompositeFeaturePtr& theSketch);
48
49   ObjectPtr externalObjectValidated(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape,
50                            const CompositeFeaturePtr& theSketch);
51
52   // Removes the external presentation from the model
53   /// \param theSketch a current sketch
54   /// \param theFeature a current feature
55   void removeExternal(const CompositeFeaturePtr& theSketch,
56                       const FeaturePtr& theFeature);
57
58   void removeExternalValidated(const CompositeFeaturePtr& theSketch,
59                                const FeaturePtr& theFeature);
60
61   void removeUnusedExternalObjects(const QObjectPtrList& theIgnoreObjects,
62                             const CompositeFeaturePtr& theSketch,
63                             const FeaturePtr& theFeature);
64
65 protected:
66   void removeExternalObject(const ObjectPtr& theObject,
67                             const CompositeFeaturePtr& theSketch,
68                             const FeaturePtr& theFeature);
69
70 protected:
71   /// An external object
72   QObjectPtrList myExternalObjects;
73
74   /// An external object
75   ObjectPtr myExternalObjectValidated;
76
77   /// Boolean value about the neccessity of the external object use
78   bool myUseExternal;
79 };
80
81 #endif