X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_ExternalObjectsMgr.h;h=375b5b8f0b46a727bb55d3e632eec3103fef6a58;hb=ae42afe3e35f7d69b26ef66323c54eb9e2fe45fe;hp=6451751dee3dda3e01d0e659f079de9f3583d918;hpb=9d9ff3badaec1d230a701582d588b1e75c0fc09c;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_ExternalObjectsMgr.h b/src/PartSet/PartSet_ExternalObjectsMgr.h index 6451751de..375b5b8f0 100644 --- a/src/PartSet/PartSet_ExternalObjectsMgr.h +++ b/src/PartSet/PartSet_ExternalObjectsMgr.h @@ -1,9 +1,21 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: PartSet_ExternalObjectsMgr.h -// Created: 15 Apr 2015 -// Author: Natalia Ermolaeva - +// Copyright (C) 2014-2021 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #ifndef PartSet_ExternalObjectsMgr_H #define PartSet_ExternalObjectsMgr_H @@ -18,6 +30,10 @@ #include +class ModuleBase_IWorkshop; +class ModuleBase_ViewerPrs; +class XGUI_Workshop; + /** * \ingroup Modules * Customosation of ModuleBase_WidgetShapeSelector in order to provide @@ -28,34 +44,92 @@ class PARTSET_EXPORT PartSet_ExternalObjectsMgr public: /// Constructor /// \param theExternal the external state + /// \param theCanCreateExternal the state if it can and should create external features /// \param theDefaultValue the default value for the external object using - PartSet_ExternalObjectsMgr(const std::string& theExternal, const bool theDefaultValue); + PartSet_ExternalObjectsMgr(const std::string& theExternal, + const std::string& theCanCreateExternal, + const bool theDefaultValue); virtual ~PartSet_ExternalObjectsMgr() {} /// Returns the state whether the external object is used bool useExternal() const { return myUseExternal; } + /// Returns if new external objects can be created + /// \return boolean value + bool canCreateExternal() { return myCanCreateExternal;} + + /// Checks validity of the given object + /// \param theObject an object to check + /// \return valid or not valid + bool isValidObject(const ObjectPtr& theObject); + /// Finds or create and external object /// \param theSelectedObject an object /// \param theShape a selected shape, which is used in the selection attribute /// \param theSketch a current sketch + /// \param theTemporary the created external object is temporary, execute is not performed for it /// \return the object ObjectPtr externalObject(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape, - const CompositeFeaturePtr& theSketch); + const CompositeFeaturePtr& theSketch, const bool theTemporary = false); + + /// Finds or create and external object by selected circle center (PartSet_CenterPrs) + /// \param thePrs a selection + /// \param theSketch a current sketch + /// \param theTemporary the created external object is temporary, execute is not performed for it + /// \return the object + ObjectPtr externalCenterObject(const std::shared_ptr& thePrs, + const CompositeFeaturePtr& theSketch, + const bool theTemporary); + + /// Returns created external object or NULL + /// \return an object instance + ObjectPtr getExternalObjectValidated() const { return myExternalObjectValidated; } // Removes the external presentation from the model /// \param theSketch a current sketch /// \param theFeature a current feature + /// \param theWorkshop a current workshop + /// \param theTemporary if true, a temporary external object is removed overwise all ext objects void removeExternal(const CompositeFeaturePtr& theSketch, - const FeaturePtr& theFeature); + const FeaturePtr& theFeature, + ModuleBase_IWorkshop* theWorkshop, + const bool theTemporary); + + /// Return an object and geom shape by the viewer presentation + /// \param thePrs a selection + /// \param theObject an output object + /// \param theShape a shape of the selection + virtual void getGeomSelection(const std::shared_ptr& thePrs, + ObjectPtr& theObject, + GeomShapePtr& theShape, + ModuleBase_IWorkshop* theWorkshop, + const CompositeFeaturePtr& theSketch, + const bool isInValidate); + +protected: + /// Delete from the document the feature of the object. It deletes all objects, which refers to + /// the deleted one. The parameter feature is ignored even it refer to the deleted object. + /// \param theObject a removed object + /// \param theSketch a current sketch + /// \param theFeature a current feature + /// \param theWorkshop a current workshop + void removeExternalObject(const ObjectPtr& theObject, + const CompositeFeaturePtr& theSketch, + const FeaturePtr& theFeature, + ModuleBase_IWorkshop* theWorkshop); + + /// Returns the workshop + static XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop); protected: /// An external object - QObjectPtrList myExternalObjects; + ObjectPtr myExternalObjectValidated; /// Boolean value about the neccessity of the external object use bool myUseExternal; + /// Boolean value about the necessity of a new external object creation + bool myCanCreateExternal; }; #endif \ No newline at end of file