+ return ModelAPI_Session::get()->moduleDocument();
+}
+
+
+void ModuleBase_Operation::start()
+{
+ ModelAPI_Session::get()->startOperation();
+
+ startOperation();
+ emit started();
+}
+
+void ModuleBase_Operation::resume()
+{
+ if (myPropertyPanel)
+ connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)),
+ this, SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
+ emit resumed();
+}
+
+void ModuleBase_Operation::abort()
+{
+ abortOperation();
+ emit aborted();
+ if (myPropertyPanel)
+ disconnect(myPropertyPanel, 0, this, 0);
+
+ stopOperation();
+
+ ModelAPI_Session::get()->abortOperation();
+ emit stopped();
+}
+
+bool ModuleBase_Operation::commit()
+{
+ if (canBeCommitted()) {
+ commitOperation();
+ emit committed();
+
+ if (myPropertyPanel)
+ disconnect(myPropertyPanel, 0, this, 0);
+
+ stopOperation();
+ ModelAPI_Session::get()->finishOperation();
+
+ emit stopped();
+
+ afterCommitOperation();
+ return true;
+ }
+ return false;
+}
+
+void ModuleBase_Operation::setRunning(bool theState)
+{
+ if (!theState) {
+ abort();
+ }
+}
+
+bool ModuleBase_Operation::activateByPreselection()
+{
+ if (!myPropertyPanel)
+ return false;
+ if (myPreSelection.empty())
+ return false;
+ const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
+ if (aWidgets.empty())
+ return false;
+
+ ModuleBase_ModelWidget* aWgt;
+ 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) {
+ aWgt = (*aWIt);
+ aPrs = (*aPIt);
+ ModuleBase_WidgetValueFeature aValue;
+ aValue.setObject(aPrs.object());
+ // 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;
+ }
+ if (isSet && canBeCommitted()) {
+ // if all widgets are filled with selection
+ commit();
+ return true;
+ }
+
+ //ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
+ //if ((myPreSelection.size() > 0) && aActiveWgt) {
+ // const ModuleBase_ViewerPrs& aPrs = myPreSelection.first();
+ // ModuleBase_WidgetValueFeature aValue;
+ // aValue.setObject(aPrs.object());
+ // if (aActiveWgt->setValue(&aValue)) {
+ // myPreSelection.removeOne(aPrs);
+ // myPropertyPanel->activateNextWidget();
+ // }
+ // // If preselection is enough to make a valid feature - apply it immediately
+ //}