From 711ef4841e2c869a28a7bb376e87d6f21b84c00b Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 24 Jun 2015 12:03:52 +0300 Subject: [PATCH] Issue #675 Modification of data structure outside of the transaction when constraint between segmnet and construction element 1 problem: operation has the previous list of preselected objects, it should be cleared after activateByPreselection is done. 2 problem: second parallel constraint operation has not empty first value. the reason is that the selection is cleared only in Viewer, but not in the OB. --- src/ModuleBase/ModuleBase_Operation.cpp | 76 +++++++++++-------------- src/PartSet/PartSet_Module.cpp | 7 ++- 2 files changed, 37 insertions(+), 46 deletions(-) diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index 3f9e149ed..7484ff28d 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -268,54 +268,44 @@ void ModuleBase_Operation::commitOperation() void ModuleBase_Operation::activateByPreselection() { - if (!myPropertyPanel || myPreSelection.empty()) { - myPropertyPanel->activateNextWidget(NULL); - return; - } - const QList& aWidgets = myPropertyPanel->modelWidgets(); - if (aWidgets.empty()) { - myPropertyPanel->activateNextWidget(NULL); - return; - } - - ModuleBase_ModelWidget* aWgt, *aFilledWgt = 0; - QList::const_iterator aWIt; - bool isSet = false; - // 1. apply the selection to controls - for (aWIt = aWidgets.constBegin(); aWIt != aWidgets.constEnd(); ++aWIt) { - aWgt = (*aWIt); - if (!aWgt->canSetValue()) - continue; - - if (!aWgt->setSelection(myPreSelection)) { - isSet = false; - break; - } else { - isSet = true; - aFilledWgt = aWgt; + ModuleBase_ModelWidget* aFilledWgt = 0; + + if (myPropertyPanel && !myPreSelection.empty()) { + const QList& aWidgets = myPropertyPanel->modelWidgets(); + if (!aWidgets.empty()) { + ModuleBase_ModelWidget* aWgt = 0; + QList::const_iterator aWIt; + bool isSet = false; + // 1. apply the selection to controls + for (aWIt = aWidgets.constBegin(); aWIt != aWidgets.constEnd(); ++aWIt) { + aWgt = (*aWIt); + if (!aWgt->canSetValue()) + continue; + + if (!aWgt->setSelection(myPreSelection)) { + isSet = false; + break; + } else { + isSet = true; + aFilledWgt = aWgt; + } + } + // in order to redisplay object in the viewer, the update/redisplay signals should be flushed + // it is better to perform it not in setSelection of each widget, but do it here, + // after the preselection is processed + ModuleBase_ModelWidget::updateObject(myFeature); + + // 3. a signal should be emitted before the next widget activation + // because, the activation of the next widget will give a focus to the widget. As a result + // the value of the widget is initialized. And commit may happens until the value is entered. + if (aFilledWgt) + emit activatedByPreselection(); } } - // in order to redisplay object in the viewer, the update/redisplay signals should be flushed - // it is better to perform it not in setSelection of each widget, but do it here, - // after the preselection is processed - ModuleBase_ModelWidget::updateObject(myFeature); - - // 2. ignore not obligatory widgets - /*for (; aWIt != aWidgets.constEnd(); ++aWIt) { - aWgt = (*aWIt); - if (aWgt && aWgt->isObligatory()) - continue; - aFilledWgt = aWgt; - }*/ - - // 3. a signal should be emitted before the next widget activation - // because, the activation of the next widget will give a focus to the widget. As a result - // the value of the widget is initialized. And commit may happens until the value is entered. - if (aFilledWgt) - emit activatedByPreselection(); // 4. activate the next obligatory widget myPropertyPanel->activateNextWidget(aFilledWgt); + clearPreselection(); } void ModuleBase_Operation::setParentFeature(CompositeFeaturePtr theParent) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 483e34ade..6bbc85002 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include #include @@ -228,9 +229,9 @@ void PartSet_Module::onOperationCommitted(ModuleBase_Operation* theOperation) // the selection is cleared after commit the create operation // in order to do not use the same selected objects in the restarted operation // for common behaviour, the selection is cleared even if the operation is not restarted - Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); - if (!aContext.IsNull()) - aContext->ClearSelected(); + XGUI_ModuleConnector* aConnector = dynamic_cast(workshop()); + XGUI_Workshop* aWorkshop = aConnector->workshop(); + aWorkshop->selector()->clearSelection(); /// Restart sketcher operations automatically FeaturePtr aFeature = theOperation->feature(); -- 2.39.2