From: nds Date: Fri, 27 Feb 2015 09:44:27 +0000 (+0300) Subject: Issue #353 constraint on 2 segments from not acive sketches X-Git-Tag: V_1.1.0~160 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2bd6fc6a681285914fe4252aab5811d8942d079f;p=modules%2Fshaper.git Issue #353 constraint on 2 segments from not acive sketches It moves the widget constraint shape selector in a separate file. --- diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 280c107f6..60388bb2b 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -12,6 +12,7 @@ SET(PROJECT_HEADERS PartSet_WidgetSketchLabel.h PartSet_Validators.h PartSet_WidgetPoint2d.h + PartSet_WidgetConstraintShapeSelector.h PartSet_WidgetPoint2dDistance.h PartSet_WidgetShapeSelector.h PartSet_Filters.h @@ -23,6 +24,7 @@ SET(PROJECT_SOURCES PartSet_Tools.cpp PartSet_WidgetSketchLabel.cpp PartSet_Validators.cpp + PartSet_WidgetConstraintShapeSelector.cpp PartSet_WidgetPoint2d.cpp PartSet_WidgetPoint2dDistance.cpp PartSet_WidgetShapeSelector.cpp diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index a73034a95..1b693e125 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/src/PartSet/PartSet_WidgetConstraintShapeSelector.cpp b/src/PartSet/PartSet_WidgetConstraintShapeSelector.cpp new file mode 100644 index 000000000..5e1ebe923 --- /dev/null +++ b/src/PartSet/PartSet_WidgetConstraintShapeSelector.cpp @@ -0,0 +1,34 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: PartSet_WidgetShapeSelector.cpp +// Created: 27 Nov 2014 +// Author: Vitaly Smetannikov + +#include "PartSet_WidgetConstraintShapeSelector.h" + +#include +#include + +#include +#include + + +//********************************************* +bool PartSet_WidgetConstraintShapeSelector::storeValueCustom() const +{ + FeaturePtr aFeature = ModelAPI_Feature::feature(mySelectedObject); + if (aFeature) { + std::shared_ptr aSPFeature = + std::dynamic_pointer_cast(aFeature); + if ((!aSPFeature) && (!myShape->isNull())) { + ObjectPtr aObj = PartSet_Tools::createFixedObjectByExternal(myShape->impl(), + mySelectedObject, mySketch); + if (aObj) { + PartSet_WidgetConstraintShapeSelector* that = (PartSet_WidgetConstraintShapeSelector*) this; + that->mySelectedObject = aObj; + } else + return false; + } + } + return ModuleBase_WidgetShapeSelector::storeValueCustom(); +} diff --git a/src/PartSet/PartSet_WidgetConstraintShapeSelector.h b/src/PartSet/PartSet_WidgetConstraintShapeSelector.h new file mode 100644 index 000000000..900e4ce30 --- /dev/null +++ b/src/PartSet/PartSet_WidgetConstraintShapeSelector.h @@ -0,0 +1,55 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: PartSet_WidgetShapeSelector.h +// Created: 27 Nov 2014 +// Author: Vitaly Smetannikov + + +#ifndef PartSet_WidgetConstraintShapeSelector_H +#define PartSet_WidgetConstraintShapeSelector_H + +#include "PartSet.h" + +#include + +#include + + +/** +* \ingroup Modules +* Customosation of ModuleBase_WidgetShapeSelector in order to provide +* working with constraints. +*/ +class PARTSET_EXPORT PartSet_WidgetConstraintShapeSelector: public ModuleBase_WidgetShapeSelector +{ +Q_OBJECT + public: + /// Constructor + /// \param theParent the parent object + /// \param theWorkshop instance of workshop interface + /// \param theData the widget configuation. The attribute of the model widget is obtained from + /// \param theParentId is Id of a parent of the current attribute + PartSet_WidgetConstraintShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, + const Config_WidgetAPI* theData, const std::string& theParentId) + : ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId) {} + + virtual ~PartSet_WidgetConstraintShapeSelector() {} + + /// Set sketcher + /// \param theSketch a sketcher object + void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; } + + /// Retrurns installed sketcher + CompositeFeaturePtr sketch() const { return mySketch; } + +protected: + /// Saves the internal parameters to the given feature + /// \return True in success + virtual bool storeValueCustom() const; + +private: + /// Pointer to a sketch + CompositeFeaturePtr mySketch; +}; + +#endif \ No newline at end of file diff --git a/src/PartSet/PartSet_WidgetShapeSelector.cpp b/src/PartSet/PartSet_WidgetShapeSelector.cpp index 76561e4e6..bd9e1ce81 100644 --- a/src/PartSet/PartSet_WidgetShapeSelector.cpp +++ b/src/PartSet/PartSet_WidgetShapeSelector.cpp @@ -125,22 +125,3 @@ bool PartSet_WidgetShapeSelector::isValid(ObjectPtr theObj, std::shared_ptr aSPFeature = - std::dynamic_pointer_cast(aFeature); - if ((!aSPFeature) && (!myShape->isNull())) { - ObjectPtr aObj = PartSet_Tools::createFixedObjectByExternal(myShape->impl(), - mySelectedObject, mySketch); - if (aObj) { - PartSet_WidgetConstraintShapeSelector* that = (PartSet_WidgetConstraintShapeSelector*) this; - that->mySelectedObject = aObj; - } else - return false; - } - } - return ModuleBase_WidgetShapeSelector::storeValueCustom(); -} diff --git a/src/PartSet/PartSet_WidgetShapeSelector.h b/src/PartSet/PartSet_WidgetShapeSelector.h index e38cdf798..b69c66648 100644 --- a/src/PartSet/PartSet_WidgetShapeSelector.h +++ b/src/PartSet/PartSet_WidgetShapeSelector.h @@ -55,41 +55,4 @@ private: CompositeFeaturePtr mySketch; }; -/** -* \ingroup Modules -* Customosation of ModuleBase_WidgetShapeSelector in order to provide -* working with constraints. -*/ -class PARTSET_EXPORT PartSet_WidgetConstraintShapeSelector: public ModuleBase_WidgetShapeSelector -{ -Q_OBJECT - public: - /// Constructor - /// \param theParent the parent object - /// \param theWorkshop instance of workshop interface - /// \param theData the widget configuation. The attribute of the model widget is obtained from - /// \param theParentId is Id of a parent of the current attribute - PartSet_WidgetConstraintShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, - const Config_WidgetAPI* theData, const std::string& theParentId) - : ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId) {} - - virtual ~PartSet_WidgetConstraintShapeSelector() {} - - /// Set sketcher - /// \param theSketch a sketcher object - void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; } - - /// Retrurns installed sketcher - CompositeFeaturePtr sketch() const { return mySketch; } - -protected: - /// Saves the internal parameters to the given feature - /// \return True in success - virtual bool storeValueCustom() const; - -private: - /// Pointer to a sketch - CompositeFeaturePtr mySketch; -}; - #endif \ No newline at end of file