#include <ModelAPI_Document.h>
#include <ModelAPI_Events.h>
#include <ModelAPI_Result.h>
+#include <ModelAPI_Object.h>
#include <ModelAPI_Validator.h>
+#include <ModelAPI_Session.h>
#include <GeomAPI_Pnt2d.h>
#include <Events_Loop.h>
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
+
#ifdef _DEBUG
#include <QDebug>
#endif
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();
if (aWidgets.empty())
return false;
- ModuleBase_ModelWidget* aWgt;
+ ModuleBase_ModelWidget* aWgt, *aFilledWgt = 0;
ModuleBase_ViewerPrs aPrs;
QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
QList<ModuleBase_ViewerPrs>::const_iterator aPIt;
+ bool isSet = false;
for (aWIt = aWidgets.constBegin(), aPIt = myPreSelection.constBegin();
(aWIt != aWidgets.constEnd()) && (aPIt != myPreSelection.constEnd());
++aWIt, ++aPIt) {
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) {
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<ModuleBase_ViewerPrs> aSelected = theSelection->getSelected();
+ FeaturePtr aFeature = feature();
+ if (aFeature) {
+ std::list<ResultPtr> aResults = aFeature->results();
+ QList<ObjectPtr> aResList;
+ std::list<ResultPtr>::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)