1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "XGUI_OperationMgr.h"
22 #include "XGUI_ModuleConnector.h"
23 #include "XGUI_Workshop.h"
24 #include "XGUI_ErrorMgr.h"
25 #include "XGUI_Tools.h"
26 #include "XGUI_ObjectsBrowser.h"
27 #include "XGUI_ContextMenuMgr.h"
29 #include <ModuleBase_IPropertyPanel.h>
30 #include <ModuleBase_ModelWidget.h>
31 #include "ModuleBase_Operation.h"
32 #include "ModuleBase_IWorkshop.h"
33 #include "ModuleBase_IModule.h"
34 #include <ModuleBase_IViewer.h>
35 #include "ModuleBase_OperationDescription.h"
36 #include "ModuleBase_OperationFeature.h"
37 #include "ModuleBase_Tools.h"
39 #include "ModelAPI_CompositeFeature.h"
40 #include "ModelAPI_Session.h"
42 #include <XGUI_PropertyPanel.h>
43 #include <QToolButton>
46 #include <QMessageBox>
47 #include <QApplication>
50 //#define DEBUG_CURRENT_FEATURE
52 /// Processes "Delete" key event of application. This key is used by several application actions.
53 /// There is a logical order of the actions processing. So the key can not be set for actions
54 /// as a shortcut. The class listens the key event and call operation manager processor.
55 class XGUI_ShortCutListener : public QObject
59 /// \param theParent the parent to be deleted when the parent is deleted
60 /// \param theOperationMgr the class to perform deletion
61 XGUI_ShortCutListener(QObject* theParent, XGUI_OperationMgr* theOperationMgr)
62 : QObject(theParent), myOperationMgr(theOperationMgr)
64 qApp->installEventFilter(this);
66 ~XGUI_ShortCutListener() {}
68 /// Switch on short cut listener
69 void setActive(const bool theIsActive) { myIsActive = theIsActive; }
71 /// Redefinition of virtual function to process Delete key release
72 virtual bool eventFilter(QObject *theObject, QEvent *theEvent)
74 bool isAccepted = false;
75 if (myIsActive && theEvent->type() == QEvent::KeyRelease) {
76 QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*>(theEvent);
78 switch (aKeyEvent->key()) {
80 isAccepted = myOperationMgr->onProcessDelete(theObject);
83 isAccepted = myOperationMgr->onKeyReleased(theObject, aKeyEvent);
89 isAccepted = QObject::eventFilter(theObject, theEvent);
94 XGUI_OperationMgr* myOperationMgr; /// processor for key event
95 bool myIsActive; /// boolean state whether the event filter perform own signal processing
98 XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent,
99 ModuleBase_IWorkshop* theWorkshop)
100 : QObject(theParent), myWorkshop(theWorkshop)
102 /// we need to install filter to the application in order to react to 'Delete' key button
103 /// this key can not be a short cut for a corresponded action because we need to set
104 /// the actions priority
105 myShortCutListener = new XGUI_ShortCutListener(theParent, this);
108 XGUI_OperationMgr::~XGUI_OperationMgr()
112 void XGUI_OperationMgr::activate()
114 myShortCutListener->setActive(true);
117 void XGUI_OperationMgr::deactivate()
119 myShortCutListener->setActive(false);
122 ModuleBase_Operation* XGUI_OperationMgr::currentOperation() const
124 return myOperations.count() > 0 ? myOperations.last() : 0;
127 bool XGUI_OperationMgr::isCurrentOperation(ModuleBase_Operation* theOperation)
131 return currentOperation() == theOperation;
134 bool XGUI_OperationMgr::hasOperation() const
136 return !myOperations.isEmpty() && (myOperations.last() != NULL);
139 bool XGUI_OperationMgr::hasOperation(const QString& theId) const
141 foreach(ModuleBase_Operation* aOp, myOperations) {
142 if (aOp->id() == theId)
148 ModuleBase_Operation* XGUI_OperationMgr::findOperation(const QString& theId) const
150 QList<ModuleBase_Operation*>::const_iterator anIt = myOperations.end();
151 while (anIt != myOperations.begin()) {
153 ModuleBase_Operation* anOperation = *anIt;
154 if (anOperation->id() == theId)
161 int XGUI_OperationMgr::operationsCount() const
163 return myOperations.count();
166 QStringList XGUI_OperationMgr::operationList() const
169 foreach(ModuleBase_Operation* eachOperation, myOperations) {
170 ModuleBase_OperationFeature* aFOperation =
171 dynamic_cast<ModuleBase_OperationFeature*>(eachOperation);
173 FeaturePtr aFeature = aFOperation->feature();
175 result << QString::fromStdString(aFeature->getKind());
182 ModuleBase_Operation* XGUI_OperationMgr::previousOperation(ModuleBase_Operation* theOperation) const
184 int idx = myOperations.lastIndexOf(theOperation);
185 if(idx == -1 || idx == 0) {
188 return myOperations.at(idx - 1);
191 bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation)
194 currentOperation()->postpone();
195 myOperations.append(theOperation);
197 connect(theOperation, SIGNAL(beforeStarted()), SLOT(onBeforeOperationStarted()));
198 connect(theOperation, SIGNAL(beforeAborted()), SLOT(onBeforeOperationAborted()));
199 connect(theOperation, SIGNAL(beforeCommitted()), SLOT(onBeforeOperationCommitted()));
201 connect(theOperation, SIGNAL(started()), SLOT(onOperationStarted()));
202 connect(theOperation, SIGNAL(aborted()), SLOT(onOperationAborted()));
203 connect(theOperation, SIGNAL(committed()), SLOT(onOperationCommitted()));
205 connect(theOperation, SIGNAL(stopped()), SLOT(onOperationStopped()));
206 connect(theOperation, SIGNAL(resumed()), SLOT(onOperationResumed()));
208 bool isStarted = theOperation->start();
210 onValidateOperation();
214 void XGUI_OperationMgr::onAbortAllOperations()
216 abortAllOperations();
219 bool XGUI_OperationMgr::abortAllOperations(const XGUI_MessageKind& theMessageKind)
225 if (operationsCount() == 1) {
226 ModuleBase_Operation* aCurrentOperation = currentOperation();
227 if (canStopOperation(aCurrentOperation, theMessageKind)) {
228 abortOperation(aCurrentOperation);
234 if (theMessageKind == XGUI_AbortOperationMessage) {
235 aResult = QMessageBox::question(qApp->activeWindow(),
236 tr("Abort operation"),
237 tr("All active operations will be aborted."),
238 QMessageBox::Ok | QMessageBox::Cancel,
239 QMessageBox::Cancel) == QMessageBox::Ok;
241 else if (theMessageKind == XGUI_InformationMessage) {
242 QString aMessage = tr("Please validate all your active operations before saving.");
243 QMessageBox::question(qApp->activeWindow(),
244 tr("Validate operation"),
248 aResult = false; // do not perform abort
250 while(aResult && hasOperation()) {
251 abortOperation(currentOperation());
257 bool XGUI_OperationMgr::commitAllOperations()
259 bool isCompositeCommitted = false, anOperationProcessed = false;
260 while (hasOperation()) {
261 ModuleBase_Operation* anOperation = currentOperation();
262 if (XGUI_Tools::workshop(myWorkshop)->errorMgr()->isApplyEnabled()) {
263 anOperationProcessed = commitOperation();
265 abortOperation(anOperation);
266 anOperationProcessed = true;
268 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
271 FeaturePtr aFeature = aFOperation->feature();
272 CompositeFeaturePtr aComposite =
273 std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
274 isCompositeCommitted = aComposite.get();
275 if (isCompositeCommitted)
278 // not processed[committed] operation might be used in composite feature,
279 // so the while will be stopped by the previous check.
280 // this code is not necessary, but logically should be done when the processing will not
281 // be done for not composite feature by some reasons
282 if (!anOperationProcessed)
288 void XGUI_OperationMgr::onValidateOperation()
292 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
293 (currentOperation());
294 if(aFOperation && aFOperation->feature().get())
295 XGUI_Tools::workshop(myWorkshop)->errorMgr()->updateActions(aFOperation->feature());
298 void XGUI_OperationMgr::updateApplyOfOperations(ModuleBase_Operation* theOperation)
300 XGUI_ErrorMgr* anErrorMgr = XGUI_Tools::workshop(myWorkshop)->errorMgr();
302 ModuleBase_OperationFeature* aFOperation =
303 dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
305 anErrorMgr->updateAcceptAllAction(aFOperation->feature());
308 foreach(ModuleBase_Operation* anOperation, myOperations) {
310 updateApplyOfOperations(anOperation);
313 // Apply button of the current operation should also be updated
314 onValidateOperation();
317 bool XGUI_OperationMgr::canStopOperation(ModuleBase_Operation* theOperation,
318 const XGUI_OperationMgr::XGUI_MessageKind& theMessageKind)
320 //in case of nested (sketch) operation no confirmation needed
321 if (isGrantedOperation(theOperation->id()))
323 if (theOperation && theOperation->isModified()) {
324 if (theMessageKind == XGUI_AbortOperationMessage) {
325 QString aMessage = tr("%1 operation will be aborted.").arg(theOperation->id());
326 int anAnswer = QMessageBox::question(qApp->activeWindow(),
327 tr("Abort operation"),
329 QMessageBox::Ok | QMessageBox::Cancel,
330 QMessageBox::Cancel);
331 return anAnswer == QMessageBox::Ok;
333 else if (theMessageKind == XGUI_InformationMessage) {
334 QString aMessage = tr("Please validate your %1 before saving.").arg(theOperation->id());
335 QMessageBox::question(qApp->activeWindow(),
336 tr("Validate operation"),
346 void XGUI_OperationMgr::resumeOperation(ModuleBase_Operation* theOperation)
348 theOperation->resume();
351 bool XGUI_OperationMgr::isGrantedOperation(const QString& theId)
353 bool isGranted = false;
355 QListIterator<ModuleBase_Operation*> anIt(myOperations);
357 ModuleBase_Operation* aPreviousOperation = 0;
358 while (anIt.hasPrevious() && !isGranted) {
359 ModuleBase_Operation* anOp = anIt.previous();
361 isGranted = anOp->isGranted(theId);
366 void XGUI_OperationMgr::setCurrentFeature(const FeaturePtr& theFeature)
368 SessionPtr aMgr = ModelAPI_Session::get();
369 DocumentPtr aDoc = aMgr->activeDocument();
370 bool aIsOp = aMgr->isOperation();
372 aMgr->startOperation(QString("Set current feature: %1")
373 .arg(theFeature->getKind().c_str()).toStdString());
374 aDoc->setCurrentFeature(theFeature, false);
375 #ifdef DEBUG_CURRENT_FEATURE
376 qDebug(QString(" document->setCurrentFeature(false) = %1 SET").arg(
377 ModuleBase_Tools::objectName(
378 ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str());
382 aMgr->finishOperation();
385 bool XGUI_OperationMgr::canStartOperation(const QString& theId, bool& isCommitted)
387 bool aCanStart = true;
389 ModuleBase_Operation* aCurrentOp = currentOperation();
391 bool aGranted = aCurrentOp->isGranted(theId);
392 // the started operation is granted for the current one,
393 // e.g. current - Sketch, started - Line
398 if (!isGrantedOperation(theId)) {
399 // the operation is not granted in the current list of operations
400 // e.g. Edit Parameter when Sketch, Line in Sketch is active.
401 aCanStart = abortAllOperations();
403 else if (canStopOperation(aCurrentOp)) {
404 // the started operation is granted in the parrent operation,
405 // e.g. current - Line in Sketch, started Circle
406 stopOperation(aCurrentOp, isCommitted);
415 void XGUI_OperationMgr::stopOperation(ModuleBase_Operation* theOperation, bool& isCommitted)
417 if (XGUI_Tools::workshop(myWorkshop)->errorMgr()->isApplyEnabled() && theOperation->isModified())
418 isCommitted = theOperation->commit();
421 abortOperation(theOperation);
425 void XGUI_OperationMgr::abortOperation(ModuleBase_Operation* theOperation)
427 ModuleBase_Operation* aCurrentOperation = currentOperation();
428 if (theOperation == aCurrentOperation)
429 theOperation->abort();
431 // it is possible to trigger upper operation(e.g. sketch, current is sketch line)
432 // all operation from the current to triggered should also be aborted
433 // operations over the parameter one are not aborted(e.g. extrusion cut, sketch abort)
434 while(hasOperation()) {
435 ModuleBase_Operation* aCurrentOperation = currentOperation();
436 aCurrentOperation->abort();
437 if(theOperation == aCurrentOperation)
443 bool XGUI_OperationMgr::commitOperation()
445 bool isCommitted = false;
446 ModuleBase_Operation* anOperation = currentOperation();
447 if (anOperation && myWorkshop->module()->canCommitOperation())
448 isCommitted = anOperation->commit();
452 void XGUI_OperationMgr::onAbortOperation()
454 ModuleBase_Operation* aCurrentOperation = currentOperation();
455 if (aCurrentOperation && canStopOperation(aCurrentOperation)) {
456 abortOperation(aCurrentOperation);
460 void XGUI_OperationMgr::onBeforeOperationStarted()
462 ModuleBase_Operation* aCurrentOperation = dynamic_cast<ModuleBase_Operation*>(sender());
463 if (!aCurrentOperation)
466 /// Set current feature and remeber old current feature
467 ModuleBase_OperationFeature* aFOperation =
468 dynamic_cast<ModuleBase_OperationFeature*>(aCurrentOperation);
470 SessionPtr aMgr = ModelAPI_Session::get();
471 DocumentPtr aDoc = aMgr->activeDocument();
472 // the parameter of current feature should be false, we should use all feature, not only
473 // visible in order to correctly save the previous feature of the nested operation, where the
474 // features can be not visible in the tree. The problem case is Edit sketch entitity(line)
475 // in the Sketch, created in ExtrusionCut operation. The entity disappears by commit.
476 // When sketch entity operation started, the sketch should be cashed here as the current.
477 // Otherwise(the flag is true), the ExtrusionCut is cashed, when commit happens, the sketch
478 // is disabled, sketch entity is disabled as extrusion cut is created earliest then sketch.
479 // As a result the sketch disappears from the viewer.
480 // However after commit it is displayed back.
481 aFOperation->setPreviousCurrentFeature(aDoc->currentFeature(false));
483 #ifdef DEBUG_CURRENT_FEATURE
484 FeaturePtr aFeature = aFOperation->feature();
485 QString aKind = aFeature ? aFeature->getKind().c_str() : "";
487 qDebug(QString("onBeforeOperationStarted() isEditOperation = %1, feature = %2")
488 .arg(aFOperation->isEditOperation())
489 .arg(ModuleBase_Tools::objectName(aFeature)).toStdString().c_str());
490 qDebug(QString(" document->currentFeature(false) = %1 : DO: setPreviousCurrentFeature").arg(
491 ModuleBase_Tools::objectName(aDoc->currentFeature(false))).toStdString().c_str());
494 if (aFOperation->isEditOperation()) {// it should be performed by the feature edit only
495 // in create operation, the current feature is changed by addFeature()
496 aDoc->setCurrentFeature(aFOperation->feature(), false);
497 #ifdef DEBUG_CURRENT_FEATURE
498 qDebug(QString(" document->setCurrentFeature(false) = %1").arg(
499 ModuleBase_Tools::objectName(aDoc->currentFeature(false))).toStdString().c_str());
501 // this is the only place where flushes must be called after setCurrentFeature for the
502 // current moment: after this the opertion is not finished, so, the ObjectBrowser
503 // state may be corrupted (issue #1457)
504 static Events_Loop* aLoop = Events_Loop::loop();
505 static Events_ID aCreateEvent = aLoop->eventByName(EVENT_OBJECT_CREATED);
506 aLoop->flush(aCreateEvent);
507 static Events_ID aDeleteEvent = aLoop->eventByName(EVENT_OBJECT_DELETED);
508 aLoop->flush(aDeleteEvent);
513 void XGUI_OperationMgr::onOperationStarted()
515 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
516 updateApplyOfOperations(aSenderOperation);
517 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
518 aWorkshop->operationStarted(aSenderOperation);
521 void XGUI_OperationMgr::onBeforeOperationAborted()
523 onBeforeOperationCommitted();
526 void XGUI_OperationMgr::onOperationAborted()
528 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
529 emit operationAborted(aSenderOperation);
532 void XGUI_OperationMgr::onBeforeOperationCommitted()
534 ModuleBase_Operation* aCurrentOperation = dynamic_cast<ModuleBase_Operation*>(sender());
535 if (!aCurrentOperation)
538 /// Restore the previous current feature
539 ModuleBase_OperationFeature* aFOperation =
540 dynamic_cast<ModuleBase_OperationFeature*>(aCurrentOperation);
542 #ifdef DEBUG_CURRENT_FEATURE
543 QString aKind = aFOperation->feature()->getKind().c_str();
544 qDebug(QString("onBeforeOperationCommitted() isEditOperation = %1, feature = %2")
545 .arg(aFOperation->isEditOperation())
546 .arg(ModuleBase_Tools::objectName(aFOperation->feature())).toStdString().c_str());
547 qDebug(QString(" document->currentFeature(false) = %1").arg(
548 ModuleBase_Tools::objectName(
549 ModelAPI_Session::get()->activeDocument()->currentFeature(false)))
550 .toStdString().c_str());
553 if (aFOperation->isEditOperation()) {
554 /// Restore the previous current feature
555 setCurrentFeature(aFOperation->previousCurrentFeature());
557 else { // create operation
558 // the Top created feature should stays the current. In nested operations,
559 // like Line in the Sketch or
560 // Sketch in ExtrusionCut, a previous feature should be restored on commit.
561 // It is performed here
562 // in order to perform it in the current transaction without opening a new one.
563 if (myOperations.front() != aFOperation)
564 setCurrentFeature(aFOperation->previousCurrentFeature());
566 ModuleBase_IModule* aModule = myWorkshop->module();
568 aModule->beforeOperationStopped(aFOperation);
572 void XGUI_OperationMgr::onOperationCommitted()
574 // apply state for all features from the stack of operations should be updated
575 updateApplyOfOperations();
577 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
578 emit operationCommitted(aSenderOperation);
581 void XGUI_OperationMgr::onOperationResumed()
583 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
584 emit operationResumed(aSenderOperation);
587 void XGUI_OperationMgr::onOperationStopped()
589 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
590 ModuleBase_Operation* aCurrentOperation = currentOperation();
591 if (!aSenderOperation || !aCurrentOperation || aSenderOperation != aCurrentOperation)
594 myOperations.removeAll(aCurrentOperation);
595 aCurrentOperation->deleteLater();
597 emit operationStopped(aCurrentOperation);
599 // get last operation which can be resumed
600 ModuleBase_Operation* aResultOp = 0;
601 QListIterator<ModuleBase_Operation*> anIt(myOperations);
603 while (anIt.hasPrevious()) {
604 ModuleBase_Operation* anOp = anIt.previous();
611 bool isModified = aCurrentOperation->isModified();
612 aResultOp->setIsModified(aResultOp->isModified() || isModified);
613 resumeOperation(aResultOp);
614 onValidateOperation();
618 bool XGUI_OperationMgr::onKeyReleased(QObject *theObject, QKeyEvent* theEvent)
620 // Let the manager decide what to do with the given key combination.
621 ModuleBase_Operation* anOperation = currentOperation();
622 bool isAccepted = false;
623 switch (theEvent->key()) {
624 case Qt::Key_Escape: {
625 ModuleBase_Operation* aOperation = currentOperation();
633 case Qt::Key_Backtab:
635 ModuleBase_Operation* aOperation = currentOperation();
637 ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
639 QWidget* aFocusedWidget = qApp->focusWidget();
640 bool isPPChildObject = aFocusedWidget && isChildObject(aFocusedWidget, aPanel);
641 if (!isPPChildObject) {
642 // check for case when the operation is started but property panel is not filled
643 XGUI_PropertyPanel* aPP = dynamic_cast<XGUI_PropertyPanel*>(aPanel);
644 aPP->setFocusNextPrevChild(theEvent->key() == Qt::Key_Tab);
652 case Qt::Key_Enter: {
653 isAccepted = onProcessEnter(theObject);
658 bool noModifiers = (theEvent->modifiers() == Qt::NoModifier);
660 ModuleBase_IViewer* aViewer = myWorkshop->viewer();
661 Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
662 if (!aContext.IsNull()) {
663 Handle(V3d_View) aView = aViewer->activeView();
664 if ((theEvent->key() == Qt::Key_N))
665 aContext->HilightNextDetected(aView);
666 else if ((theEvent->key() == Qt::Key_P))
667 aContext->HilightPreviousDetected(aView);
678 // anOperation->keyReleased(theEvent->key());
683 bool XGUI_OperationMgr::onProcessEnter(QObject* theObject)
685 bool isAccepted = false;
686 ModuleBase_Operation* aOperation = currentOperation();
687 // to avoid enter processing when operation has not been started yet
690 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
691 // the next code is obsolete as we want to process Enter in property panel always
692 // only property panel enter is processed in order to do not process enter in application dialogs
693 //bool isPPChild = isChildObject(theObject, aPanel);
695 // return isAccepted;
697 ModuleBase_ModelWidget* anActiveWgt = aPanel->activeWidget();
698 bool isAborted = false;
700 QWidget* aFocusWidget = aPanel->focusWidget();
701 QToolButton* aCancelBtn =
702 dynamic_cast<XGUI_PropertyPanel*>(aPanel)->findButton(PROP_PANEL_CANCEL);
703 if (aFocusWidget && aCancelBtn && aFocusWidget == aCancelBtn) {
704 abortOperation(aOperation);
710 isAccepted = anActiveWgt && anActiveWgt->processEnter();
713 myWorkshop->module()->processEnter(anActiveWgt ? anActiveWgt->attributeID() : "");
715 /// functionality is similar to Apply click
716 ModuleBase_OperationFeature* aFOperation =
717 dynamic_cast<ModuleBase_OperationFeature*>(currentOperation());
719 myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty()) {
720 // key released is emitted to apply the current value to the model
721 // if it was modified in PP
722 emit keyEnterReleased();
734 bool editorControl(QObject* theObject)
736 QLineEdit* aLineEdit = dynamic_cast<QLineEdit*>(theObject);
740 bool XGUI_OperationMgr::onProcessDelete(QObject* theObject)
742 bool isAccepted = false;
743 ModuleBase_Operation* aOperation = currentOperation();
744 ModuleBase_ModelWidget* anActiveWgt = 0;
745 // firstly the widget should process Delete action
746 ModuleBase_IPropertyPanel* aPanel;
747 bool isPPChildObject = false;
749 aPanel = aOperation->propertyPanel();
751 isPPChildObject = isChildObject(theObject, aPanel);
752 // process delete in active widget only if delete sender is child of property panel
753 // it is necessary for the case when OB is shown, user perform selection and click Delete
754 if (isPPChildObject) {
755 anActiveWgt = aPanel->activeWidget();
757 isAccepted = anActiveWgt->processDelete();
763 // after widget, object browser and viewer should process delete
764 /// other widgets such as line edit controls should not lead to
765 /// processing delete by workshop
766 XGUI_ObjectsBrowser* aBrowser = XGUI_Tools::workshop(myWorkshop)->objectBrowser();
767 QWidget* aViewPort = myWorkshop->viewer()->activeViewPort();
768 bool isToDeleteObject = false;
769 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
770 XGUI_ContextMenuMgr* aContextMenuMgr = aWorkshop->contextMenuMgr();
771 if (theObject == aBrowser->treeView()) {
772 aContextMenuMgr->updateObjectBrowserMenu();
773 isToDeleteObject = aContextMenuMgr->action("DELETE_CMD")->isEnabled();
775 else if (isChildObject(theObject, aViewPort)) {
776 aContextMenuMgr->updateViewerMenu();
777 isToDeleteObject = aContextMenuMgr->action("DELETE_CMD")->isEnabled();
779 else if (isPPChildObject) {
780 // property panel child object is processed to process delete performed on Apply button of PP
781 isToDeleteObject = true;
783 else if (editorControl(theObject)) {
784 isToDeleteObject = false; /// Line Edit of Rename operation in ObjectBrowser
788 if (isToDeleteObject) {
789 aWorkshop->deleteObjects();
797 bool XGUI_OperationMgr::isChildObject(const QObject* theObject, const QObject* theParent)
799 bool isPPChild = false;
800 if (theParent && theObject) {
801 QObject* aParent = (QObject*)theObject;
803 isPPChild = aParent == theParent;
806 aParent = aParent->parent();