From 1f6b8646d28bdfa596e27e351bbf3bc600a2f236 Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 4 Jun 2014 12:18:14 +0400 Subject: [PATCH] Edit extrusion object --- .../ConstructionPlugin_Extrusion.h | 2 +- src/ConstructionPlugin/extrusion_widget.xml | 2 +- src/Model/Model_AttributeReference.cpp | 2 +- src/ModuleBase/ModuleBase_Operation.cpp | 3 ++- src/ModuleBase/ModuleBase_Operation.h | 7 +++---- src/ModuleBase/ModuleBase_SelectorWidget.cpp | 14 +++++++++++++- src/PartSet/PartSet_Module.cpp | 6 ++++-- 7 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h b/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h index 6d557a3ab..b7db8e011 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h +++ b/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h @@ -9,7 +9,7 @@ #include /// attribute name of referenced face -const std::string EXTRUSION_FACE = "extrusion_select_face"; +const std::string EXTRUSION_FACE = "extrusion_face"; /// attribute name of extrusion size const std::string EXTRUSION_SIZE = "extrusion_size"; diff --git a/src/ConstructionPlugin/extrusion_widget.xml b/src/ConstructionPlugin/extrusion_widget.xml index ed08edc35..f368a68cd 100644 --- a/src/ConstructionPlugin/extrusion_widget.xml +++ b/src/ConstructionPlugin/extrusion_widget.xml @@ -1,5 +1,5 @@ - theF if (myRef.IsNull()) { boost::shared_ptr aMyData = boost::dynamic_pointer_cast(owner()->data()); - TDF_Reference::Set(aMyData->label(), aData->label()); + myRef = TDF_Reference::Set(aMyData->label(), aData->label()); } else { myRef->Set(aData->label()); } diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index 8bf69185c..600c27a34 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -80,7 +80,8 @@ void ModuleBase_Operation::storeCustomValue() void ModuleBase_Operation::startOperation() { - setFeature(createFeature()); + if (!myFeature) + setFeature(createFeature()); //emit callSlot(); //commit(); } diff --git a/src/ModuleBase/ModuleBase_Operation.h b/src/ModuleBase/ModuleBase_Operation.h index 833dbf57c..73e00f663 100644 --- a/src/ModuleBase/ModuleBase_Operation.h +++ b/src/ModuleBase/ModuleBase_Operation.h @@ -70,6 +70,9 @@ public: virtual void keyReleased(std::string theName, QKeyEvent* theEvent) {}; + /// Sets the operation feature + void setFeature(boost::shared_ptr theFeature); + protected: /// Virtual method called when operation started (see start() method for more description) /// Default impl calls corresponding slot and commits immediately. @@ -93,10 +96,6 @@ protected: /// \returns the created feature virtual boost::shared_ptr createFeature(const bool theFlushMessage = true); - /// Returns the operation feature - /// \return the feature - void setFeature(boost::shared_ptr theFeature); - private: boost::shared_ptr myFeature; /// the operation feature to be handled }; diff --git a/src/ModuleBase/ModuleBase_SelectorWidget.cpp b/src/ModuleBase/ModuleBase_SelectorWidget.cpp index f47911d83..7ac7ba946 100644 --- a/src/ModuleBase/ModuleBase_SelectorWidget.cpp +++ b/src/ModuleBase/ModuleBase_SelectorWidget.cpp @@ -6,6 +6,9 @@ #include "ModuleBase_SelectorWidget.h" #include "ModuleBase_IWorkshop.h" +#include +#include + #include #include #include @@ -72,8 +75,11 @@ bool ModuleBase_SelectorWidget::storeValue(FeaturePtr theFeature) boost::shared_ptr aRef = boost::dynamic_pointer_cast(aData->attribute(myFeatureAttributeID)); - aRef->setFeature(mySelectedFeature); + bool isBlocked = this->blockSignals(true); + aRef->setValue(mySelectedFeature); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); + this->blockSignals(isBlocked); return true; } @@ -84,8 +90,11 @@ bool ModuleBase_SelectorWidget::restoreValue(FeaturePtr theFeature) boost::shared_ptr aRef = boost::dynamic_pointer_cast(aData->attribute(myFeatureAttributeID)); + bool isBlocked = this->blockSignals(true); mySelectedFeature = aRef->value(); updateSelectionName(); + + this->blockSignals(isBlocked); return true; } @@ -122,6 +131,9 @@ void ModuleBase_SelectorWidget::onSelectionChanged() return; // TODO: Check that the selection corresponds to selection type + if (aFeature->getKind().compare("Sketch") != 0) + return; + mySelectedFeature = aFeature; if (mySelectedFeature) { updateSelectionName(); diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index e9bba754f..bb72bb118 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -230,6 +230,8 @@ void PartSet_Module::onLaunchOperation(std::string theName, boost::shared_ptr aSelected = aDisplayer->GetSelected(TopAbs_VERTEX); std::list aHighlighted = aDisplayer->GetHighlighted(TopAbs_VERTEX); aPreviewOp->init(theFeature, aSelected, aHighlighted); + } else { + anOperation->setFeature(theFeature); } sendOperation(anOperation); myWorkshop->actionsMgr()->updateCheckState(); @@ -459,7 +461,7 @@ void PartSet_Module::editFeature(FeaturePtr theFeature) if (!theFeature) return; - if (theFeature->getKind() == "Sketch") { +// if (theFeature->getKind() == "Sketch") { FeaturePtr aFeature = theFeature; if (XGUI_Tools::isModelObject(aFeature)) { ObjectPtr aObject = boost::dynamic_pointer_cast(aFeature); @@ -470,5 +472,5 @@ void PartSet_Module::editFeature(FeaturePtr theFeature) onLaunchOperation(aFeature->getKind(), aFeature); updateCurrentPreview(aFeature->getKind()); } - } +// } } -- 2.39.2