From c533d1d93579c5841081a310616b1e232baa23c6 Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 6 Oct 2014 18:45:09 +0400 Subject: [PATCH] Working with pre-selection in all operations --- src/FeaturesPlugin/extrusion_widget.xml | 2 +- src/ModuleBase/ModuleBase_Operation.cpp | 8 +---- src/ModuleBase/ModuleBase_Operation.h | 2 +- .../ModuleBase_WidgetShapeSelector.cpp | 2 +- src/PartSet/PartSet_OperationSketchBase.cpp | 29 +++++++++++++++++++ src/PartSet/PartSet_OperationSketchBase.h | 3 ++ 6 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml index 698905a7f..0bcf41643 100644 --- a/src/FeaturesPlugin/extrusion_widget.xml +++ b/src/FeaturesPlugin/extrusion_widget.xml @@ -6,7 +6,7 @@ activate="true" shape_types="face" /> - + diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index 718ded61a..d8f50a4cd 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -238,13 +238,7 @@ void ModuleBase_Operation::activateByPreselection() aValue.setObject(aPrs.object()); if (aActiveWgt->setValue(&aValue)) { myPreSelection.remove(aPrs); - if(isValid()) { - //myActiveWidget = NULL; - commit(); - } else { - myPropertyPanel->activateNextWidget(); - //emit activateNextWidget(myActiveWidget); - } + myPropertyPanel->activateNextWidget(); } // If preselection is enough to make a valid feature - apply it immediately } diff --git a/src/ModuleBase/ModuleBase_Operation.h b/src/ModuleBase/ModuleBase_Operation.h index 910bd6eae..dbf2b3406 100644 --- a/src/ModuleBase/ModuleBase_Operation.h +++ b/src/ModuleBase/ModuleBase_Operation.h @@ -202,7 +202,7 @@ signals: /// Returns pointer to the root document. boost::shared_ptr document() const; - /// + /// Activates widgets by preselection if it is accepted virtual void activateByPreselection(); /// Set value to the active widget diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 47471dab3..da84fe6ca 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -152,6 +152,7 @@ void ModuleBase_WidgetShapeSelector::onSelectionChanged() return; setObject(aObject); + emit focusOutWidget(this); } } @@ -170,7 +171,6 @@ void ModuleBase_WidgetShapeSelector::setObject(ObjectPtr theObj) updateSelectionName(); activateSelection(false); emit valuesChanged(); - emit focusOutWidget(this); } //******************************************************************** diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp index e8f081e4d..2ce61d8ef 100644 --- a/src/PartSet/PartSet_OperationSketchBase.cpp +++ b/src/PartSet/PartSet_OperationSketchBase.cpp @@ -6,6 +6,10 @@ #include #include +#include +#include +#include + #include #include #include @@ -104,3 +108,28 @@ void PartSet_OperationSketchBase::restartOperation(const std::string& theType, O } emit restartRequired(theType, theFeature); } + + + +void PartSet_OperationSketchBase::activateByPreselection() +{ + if (!myPropertyPanel) + return; + ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget(); + if ((myPreSelection.size() > 0) && aActiveWgt) { + const ModuleBase_ViewerPrs& aPrs = myPreSelection.front(); + ModuleBase_WidgetValueFeature aValue; + aValue.setObject(aPrs.object()); + if (aActiveWgt->setValue(&aValue)) { + myPreSelection.remove(aPrs); + if(isValid()) { + //myActiveWidget = NULL; + commit(); + } else { + myPropertyPanel->activateNextWidget(); + //emit activateNextWidget(myActiveWidget); + } + } + // If preselection is enough to make a valid feature - apply it immediately + } +} diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h index 356765cc4..25f714830 100644 --- a/src/PartSet/PartSet_OperationSketchBase.h +++ b/src/PartSet/PartSet_OperationSketchBase.h @@ -149,6 +149,9 @@ signals: /// \param theFlushMessage the flag whether the create message should be flushed /// \returns the created feature virtual FeaturePtr createFeature(const bool theFlushMessage = true); + + /// Activates widgets by preselection if it is accepted + virtual void activateByPreselection(); }; #endif -- 2.39.2