X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_Operation.cpp;h=8b19dcd8270b9c0a57a0f5f1826ba605c911b774;hb=561ec84c4405975d78d8cd7d50c5bfa6dba8d738;hp=4d54780f9941acda1717d3030d28b48f4efad6b7;hpb=03936c76cd52c555961e4636e640c12fe2d47f2f;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index 4d54780f9..8b19dcd82 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -50,6 +50,16 @@ ModuleBase_Operation::~ModuleBase_Operation() delete myDescription; } +const QStringList& ModuleBase_Operation::grantedOperationIds() const +{ + return myGrantedIds; +} + +void ModuleBase_Operation::setGrantedOperationIds(const QStringList& theList) +{ + myGrantedIds = theList; +} + QString ModuleBase_Operation::id() const { return getDescription()->operationId(); @@ -65,39 +75,16 @@ bool ModuleBase_Operation::canBeCommitted() const return isValid(); } - -void ModuleBase_Operation::start() +bool ModuleBase_Operation::start() { myIsModified = false; - /* - QString anId = getDescription()->operationId(); - if (myIsEditing) { - anId = anId.append(EditSuffix()); - } - ModelAPI_Session::get()->startOperation(anId.toStdString()); - - if (!myIsEditing) { - FeaturePtr aFeature = createFeature(); - // if the feature is not created, there is no sense to start the operation - if (aFeature.get() == NULL) { - // it is necessary to abor the operation in the session and emit the aborted signal - // in order to update commands status in the workshop, to be exact the feature action - // to be unchecked - abort(); - return; - } - } - /// Set current feature and remeber old current feature - if (myIsEditing) { - SessionPtr aMgr = ModelAPI_Session::get(); - DocumentPtr aDoc = aMgr->activeDocument(); - myCurrentFeature = aDoc->currentFeature(true); - aDoc->setCurrentFeature(feature(), false); - } + + ModelAPI_Session::get()->startOperation(id().toStdString()); startOperation(); emit started(); -*/ + + return true; } void ModuleBase_Operation::postpone() @@ -114,75 +101,29 @@ void ModuleBase_Operation::resume() void ModuleBase_Operation::abort() { -/* // the viewer update should be blocked in order to avoid the features blinking before they are // hidden - std::shared_ptr aMsg = std::shared_ptr( - new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED))); - Events_Loop::loop()->send(aMsg); - - // the widgets of property panel should not process any events come from data mode - // after abort clicked. Some signal such as redisplay/create influence on content - // of the object browser and viewer context. Therefore it influence to the current - // selection and if the active widget listens it, the attribute value is errnoneous - // changed. - if (myPropertyPanel) - myPropertyPanel->cleanContent(); - - SessionPtr aMgr = ModelAPI_Session::get(); - if (myIsEditing) { - DocumentPtr aDoc = aMgr->activeDocument(); - bool aIsOp = aMgr->isOperation(); - if (!aIsOp) - aMgr->startOperation(); - aDoc->setCurrentFeature(myCurrentFeature, true); - if (!aIsOp) - aMgr->finishOperation(); - myCurrentFeature = FeaturePtr(); - } - abortOperation(); + //std::shared_ptr aMsg = std::shared_ptr( + // new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED))); + //Events_Loop::loop()->send(aMsg); - stopOperation(); - // is is necessary to deactivate current widgets before the model operation is aborted - // because abort removes the feature and activated filters should not check it - propertyPanel()->cleanContent(); + ModelAPI_Session::get()->abortOperation(); - aMgr->abortOperation(); emit stopped(); // the viewer update should be unblocked in order to avoid the features blinking before they are // hidden - aMsg = std::shared_ptr( - new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED))); - - Events_Loop::loop()->send(aMsg); + //aMsg = std::shared_ptr( + // new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED))); + //Events_Loop::loop()->send(aMsg); emit aborted(); -*/ } bool ModuleBase_Operation::commit() { -/* if (canBeCommitted()) { - // the widgets of property panel should not process any events come from data mode - // after commit clicked. Some signal such as redisplay/create influence on content - // of the object browser and viewer context. Therefore it influence to the current - // selection and if the active widget listens it, the attribute value is errnoneous - // changed. - if (myPropertyPanel) - myPropertyPanel->cleanContent(); - + if (canBeCommitted()) { SessionPtr aMgr = ModelAPI_Session::get(); - /// Set current feature and remeber old current feature - if (myIsEditing) { - DocumentPtr aDoc = aMgr->activeDocument(); - bool aIsOp = aMgr->isOperation(); - if (!aIsOp) - aMgr->startOperation(); - aDoc->setCurrentFeature(myCurrentFeature, true); - if (!aIsOp) - aMgr->finishOperation(); - myCurrentFeature = FeaturePtr(); - } + commitOperation(); aMgr->finishOperation(); @@ -193,7 +134,6 @@ bool ModuleBase_Operation::commit() afterCommitOperation(); return true; } -*/ return false; } @@ -209,5 +149,5 @@ void ModuleBase_Operation::setPropertyPanel(ModuleBase_IPropertyPanel* theProp) bool ModuleBase_Operation::isGranted(QString theId) const { - return false; + return myGrantedIds.contains(theId); }