From: vsv Date: Fri, 10 Apr 2015 14:33:05 +0000 (+0300) Subject: Remove sketch_constraint_shape_selector and use_external flag is created X-Git-Tag: V_1.1.0~48^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b43fa9a0ae1129db4149ba584807ce448449b48a;p=modules%2Fshaper.git Remove sketch_constraint_shape_selector and use_external flag is created --- diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 8b85b15c6..76fc4c119 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -12,7 +12,6 @@ SET(PROJECT_HEADERS PartSet_WidgetSketchLabel.h PartSet_Validators.h PartSet_WidgetPoint2d.h - PartSet_WidgetConstraintShapeSelector.h PartSet_WidgetEditor.h PartSet_WidgetPoint2dDistance.h PartSet_WidgetShapeSelector.h @@ -27,7 +26,6 @@ SET(PROJECT_SOURCES PartSet_Tools.cpp PartSet_WidgetSketchLabel.cpp PartSet_Validators.cpp - PartSet_WidgetConstraintShapeSelector.cpp PartSet_WidgetEditor.cpp PartSet_WidgetPoint2d.cpp PartSet_WidgetPoint2dDistance.cpp diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index b81a64bb3..60ab634a7 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include "PartSet_SketcherMgr.h" #include "PartSet_MenuMgr.h" @@ -472,11 +471,6 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId); aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch()); aWgt = aShapeSelectorWgt; - } if (theType == "sketch_constraint_shape_selector") { - PartSet_WidgetConstraintShapeSelector* aConstraintShapeSelectorWgt = - new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId); - aConstraintShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch()); - aWgt = aConstraintShapeSelectorWgt; } if (theType == WDG_DOUBLEVALUE_EDITOR) { aWgt = new PartSet_WidgetEditor(theParent, workshop(), theWidgetApi, theParentId); } diff --git a/src/PartSet/PartSet_WidgetConstraintShapeSelector.cpp b/src/PartSet/PartSet_WidgetConstraintShapeSelector.cpp deleted file mode 100644 index f3799357c..000000000 --- a/src/PartSet/PartSet_WidgetConstraintShapeSelector.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// 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::setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape) -{ - // initially the method is wrote to create an external object. Since the parent widget creates it, - // the redefinition is not necessary anymore. - // TODO: remove the widget and use the parent one insted of it - return PartSet_WidgetShapeSelector::setObject(theSelectedObject, theShape); - /*ObjectPtr aSelectedObject = theSelectedObject; - - FeaturePtr aFeature = ModelAPI_Feature::feature(aSelectedObject); - if (aFeature) { - std::shared_ptr aSPFeature = - std::dynamic_pointer_cast(aFeature); - if ((!aSPFeature) && (!theShape->isNull())) { - createExternal(theSelectedObject, theShape); - - if (myExternalObject) { - aSelectedObject = myExternalObject; - } else - return false; - } - } - return ModuleBase_WidgetShapeSelector::setObject(aSelectedObject, theShape);*/ -} diff --git a/src/PartSet/PartSet_WidgetConstraintShapeSelector.h b/src/PartSet/PartSet_WidgetConstraintShapeSelector.h deleted file mode 100644 index 9a69e4384..000000000 --- a/src/PartSet/PartSet_WidgetConstraintShapeSelector.h +++ /dev/null @@ -1,57 +0,0 @@ -// 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 PartSet_WidgetShapeSelector in order to provide -* working with constraints. -*/ -class PARTSET_EXPORT PartSet_WidgetConstraintShapeSelector: public PartSet_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) - : PartSet_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: - /// Store the values to the model attribute of the widget. It casts this attribute to - /// the specific type and set the given values - /// \param theSelectedObject an object - /// \param theShape a selected shape, which is used in the selection attribute - virtual bool setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape); - -//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 cd659c04d..089bd98a6 100644 --- a/src/PartSet/PartSet_WidgetShapeSelector.cpp +++ b/src/PartSet/PartSet_WidgetShapeSelector.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -23,8 +24,13 @@ PartSet_WidgetShapeSelector::PartSet_WidgetShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData, const std::string& theParentId) -: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId) +: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId), myUseExternal(true) { + QString aIsExternal(theData->getProperty("use_external").c_str()); + if (!aIsExternal.isEmpty()) { + QString aStr = aIsExternal.toUpper(); + myUseExternal = (aStr == "TRUE") || (aStr == "YES"); + } } bool PartSet_WidgetShapeSelector::setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape) @@ -35,9 +41,15 @@ bool PartSet_WidgetShapeSelector::setObject(ObjectPtr theSelectedObject, GeomSha FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(aSelectedObject); if (aSelectedFeature == myFeature) // In order to avoid selection of the same object return false; + // Do check using of external feature std::shared_ptr aSPFeature = std::dynamic_pointer_cast(aSelectedFeature); - if (aSPFeature.get() == NULL && aShape.get() != NULL && !aShape->isNull()) { + + // Do check that we can use external feature + if ((aSPFeature.get() != NULL) && aSPFeature->isExternal() && (!myUseExternal)) + return false; + + if (aSPFeature.get() == NULL && aShape.get() != NULL && !aShape->isNull() && myUseExternal) { aSelectedObject = PartSet_Tools::findFixedObjectByExternal(theShape->impl(), theSelectedObject, mySketch); if (!aSelectedObject.get()) { diff --git a/src/PartSet/PartSet_WidgetShapeSelector.h b/src/PartSet/PartSet_WidgetShapeSelector.h index fb32bff9c..b10c8a06f 100644 --- a/src/PartSet/PartSet_WidgetShapeSelector.h +++ b/src/PartSet/PartSet_WidgetShapeSelector.h @@ -63,6 +63,8 @@ protected: /// An external object ObjectPtr myExternalObject; + + bool myUseExternal; }; #endif \ No newline at end of file diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 382bd3d61..b42b4af66 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -102,18 +102,18 @@ - - + - - + @@ -121,20 +121,20 @@ - - + - - + @@ -159,19 +159,19 @@ - + - + - + - + @@ -179,28 +179,28 @@ - - + - - + - - + - - + @@ -210,13 +210,13 @@ - - + - - + @@ -229,10 +229,10 @@ id="SketchConstraintMirror" title="Mirror" icon=":icons/mirror.png" tooltip="Create constraint, mirroring group of objects"> - - +