X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_Operation.cpp;h=bfe58446d370168a50092075ea228460c6ca7c25;hb=8b3ac2b938bd55064a6f260ca7ec9c9a84cd977e;hp=516430bd04270fdf20b6874a86eb30022d7cb6b5;hpb=38afbd899a8645c83e17f2c24a17a2b7414911b4;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index 516430bd0..bfe58446d 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -66,32 +66,14 @@ bool ModuleBase_Operation::isValid() const { if (!myFeature) return true; // rename operation + if (myFeature->isAction()) + return true; //Get validators for the Id SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); return aFactory->validate(myFeature); } -bool ModuleBase_Operation::isNestedOperationsEnabled() const -{ - return true; -} - -//void ModuleBase_Operation::storeCustomValue() -//{ -// if (!myFeature) { -//#ifdef _DEBUG -// qDebug() << "ModuleBase_Operation::storeCustom: " << -// "trying to store value without opening a transaction."; -//#endif -// return; -// } -// -// ModuleBase_ModelWidget* aCustom = dynamic_cast(sender()); -// if (aCustom) -// aCustom->storeValue(); -//} - bool ModuleBase_Operation::canBeCommitted() const { @@ -110,7 +92,7 @@ void ModuleBase_Operation::flushCreated() FeaturePtr ModuleBase_Operation::createFeature(const bool theFlushMessage) { - if (myParentFeature) { + if (myParentFeature.get()) { myFeature = myParentFeature->addFeature(getDescription()->operationId().toStdString()); } else { std::shared_ptr aDoc = document(); @@ -164,26 +146,26 @@ std::shared_ptr ModuleBase_Operation::document() const void ModuleBase_Operation::start() { - ModelAPI_Session::get()->startOperation(); + QString anId = getDescription()->operationId(); + ModelAPI_Session::get()->startOperation(anId.toStdString()); if (!myIsEditing) createFeature(); startOperation(); emit started(); + } void ModuleBase_Operation::postpone() { - if (myPropertyPanel) - disconnect(myPropertyPanel, 0, this, 0); + postponeOperation(); emit postponed(); } void ModuleBase_Operation::resume() { - // connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), - // this, SLOT(onWidgetActivated(ModuleBase_ModelWidget*))); + resumeOperation(); emit resumed(); } @@ -191,8 +173,6 @@ void ModuleBase_Operation::abort() { abortOperation(); emit aborted(); - if (myPropertyPanel) - disconnect(myPropertyPanel, 0, this, 0); stopOperation(); @@ -203,9 +183,6 @@ void ModuleBase_Operation::abort() bool ModuleBase_Operation::commit() { if (canBeCommitted()) { - if (myPropertyPanel) - disconnect(myPropertyPanel, 0, this, 0); - commitOperation(); // check whether there are modifications performed during the current operation // in the model @@ -232,16 +209,16 @@ void ModuleBase_Operation::setRunning(bool theState) } } -bool ModuleBase_Operation::activateByPreselection() +void ModuleBase_Operation::activateByPreselection() { if (!myPropertyPanel || myPreSelection.empty()) { myPropertyPanel->activateNextWidget(NULL); - return false; + return; } const QList& aWidgets = myPropertyPanel->modelWidgets(); if (aWidgets.empty()) { myPropertyPanel->activateNextWidget(NULL); - return false; + return; } ModuleBase_ModelWidget* aWgt, *aFilledWgt = 0; @@ -266,14 +243,20 @@ bool ModuleBase_Operation::activateByPreselection() } } - if (aFilledWgt) { - myPropertyPanel->activateNextWidget(aFilledWgt); + myPropertyPanel->activateNextWidget(aFilledWgt); + if (aFilledWgt) emit activatedByPreselection(); - return true; - } - else - myPropertyPanel->activateNextWidget(NULL); - return false; + +} + +void ModuleBase_Operation::setParentFeature(CompositeFeaturePtr theParent) +{ + myParentFeature = theParent; +} + +CompositeFeaturePtr ModuleBase_Operation::parentFeature() const +{ + return myParentFeature; } void ModuleBase_Operation::initSelection(ModuleBase_ISelection* theSelection, @@ -355,11 +338,14 @@ void ModuleBase_Operation::setPropertyPanel(ModuleBase_IPropertyPanel* theProp) { myPropertyPanel = theProp; myPropertyPanel->setEditingMode(isEditOperation()); - //connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), this, - // SLOT(onWidgetActivated(ModuleBase_ModelWidget*))); + + // Do not activate widgets by default if the current operation is editing operation + // Because we don't know which widget is going to be edited. + if (!isEditOperation()) + activateByPreselection(); } bool ModuleBase_Operation::isGranted(QString theId) const { return myNestedFeatures.contains(theId); -} \ No newline at end of file +}