X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_Operation.cpp;h=b3bf0b07572308f26b62a2fc2c177a4ae2eb24dc;hb=28c90c232ffe159b88edd156286a398bfa3bb73b;hp=9f99fad519725bd389e2899e5df8288cefae98b1;hpb=979ad873ba8ebe5ec3c8e6eae08f359b94768766;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index 9f99fad51..b3bf0b075 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -28,6 +29,9 @@ #include +#include +#include + #ifdef _DEBUG #include #endif @@ -217,7 +221,13 @@ bool ModuleBase_Operation::commit() disconnect(myPropertyPanel, 0, this, 0); stopOperation(); - ModelAPI_Session::get()->finishOperation(); + // check whether there are modifications performed during the current operation + // in the model + // in case if there are no modifications, do not increase the undo/redo stack + if (ModelAPI_Session::get()->isModified()) + ModelAPI_Session::get()->finishOperation(); + else + ModelAPI_Session::get()->abortOperation(); emit stopped(); @@ -244,10 +254,11 @@ bool ModuleBase_Operation::activateByPreselection() if (aWidgets.empty()) return false; - ModuleBase_ModelWidget* aWgt; + ModuleBase_ModelWidget* aWgt, *aFilledWgt = 0; ModuleBase_ViewerPrs aPrs; QList::const_iterator aWIt; QList::const_iterator aPIt; + bool isSet = false; for (aWIt = aWidgets.constBegin(), aPIt = myPreSelection.constBegin(); (aWIt != aWidgets.constEnd()) && (aPIt != myPreSelection.constEnd()); ++aWIt, ++aPIt) { @@ -255,14 +266,29 @@ bool ModuleBase_Operation::activateByPreselection() aPrs = (*aPIt); ModuleBase_WidgetValueFeature aValue; aValue.setObject(aPrs.object()); - if (!aWgt->setValue(&aValue)) + // Check if the selection has a selected point + // for today it is impossible to do because + // the selected point demands convertation to Sketch plane 2d + if (!aWgt->setValue(&aValue)) { + isSet = false; break; + } else { + isSet = true; + aFilledWgt = aWgt; + } } - if (canBeCommitted()) { + if (isSet && canBeCommitted()) { // if all widgets are filled with selection commit(); return true; } + else { + //activate next widget + if (aFilledWgt) { + myPropertyPanel->activateNextWidget(aFilledWgt); + return true; + } + } //ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget(); //if ((myPreSelection.size() > 0) && aActiveWgt) { @@ -278,9 +304,27 @@ bool ModuleBase_Operation::activateByPreselection() return false; } -void ModuleBase_Operation::initSelection(ModuleBase_ISelection* theSelection) +void ModuleBase_Operation::initSelection(ModuleBase_ISelection* theSelection, + ModuleBase_IViewer* /*theViewer*/) { - myPreSelection = theSelection->getSelected(); + myPreSelection.clear(); + + // Check that the selected result are not results of operation feature + QList aSelected = theSelection->getSelected(); + FeaturePtr aFeature = feature(); + if (aFeature) { + std::list aResults = aFeature->results(); + QList aResList; + std::list::const_iterator aIt; + for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) + aResList.append(*aIt); + + foreach (ModuleBase_ViewerPrs aPrs, aSelected) { + if ((!aResList.contains(aPrs.object())) && (aPrs.object() != aFeature)) + myPreSelection.append(aPrs); + } + } else + myPreSelection = aSelected; } void ModuleBase_Operation::onWidgetActivated(ModuleBase_ModelWidget* theWidget)