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 bool XGUI_OperationMgr::abortAllOperations()
220 if (operationsCount() == 1) {
221 ModuleBase_Operation* aCurrentOperation = currentOperation();
222 if (canStopOperation(aCurrentOperation)) {
223 abortOperation(aCurrentOperation);
229 aResult = QMessageBox::question(qApp->activeWindow(),
230 tr("Abort operation"),
231 tr("All active operations will be aborted."),
232 QMessageBox::Ok | QMessageBox::Cancel,
233 QMessageBox::Cancel) == QMessageBox::Ok;
234 while(aResult && hasOperation()) {
235 abortOperation(currentOperation());
241 bool XGUI_OperationMgr::commitAllOperations()
243 bool isCompositeCommitted = false, anOperationProcessed = false;
244 while (hasOperation()) {
245 ModuleBase_Operation* anOperation = currentOperation();
246 if (XGUI_Tools::workshop(myWorkshop)->errorMgr()->isApplyEnabled()) {
247 anOperationProcessed = onCommitOperation();
249 abortOperation(anOperation);
250 anOperationProcessed = true;
252 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
255 FeaturePtr aFeature = aFOperation->feature();
256 CompositeFeaturePtr aComposite =
257 std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
258 isCompositeCommitted = aComposite.get();
259 if (isCompositeCommitted)
262 // not processed[committed] operation might be used in composite feature,
263 // so the while will be stopped by the previous check.
264 // this code is not necessary, but logically should be done when the processing will not
265 // be done for not composite feature by some reasons
266 if (!anOperationProcessed)
272 void XGUI_OperationMgr::onValidateOperation()
276 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
277 (currentOperation());
278 if(aFOperation && aFOperation->feature().get())
279 XGUI_Tools::workshop(myWorkshop)->errorMgr()->updateActions(aFOperation->feature());
282 void XGUI_OperationMgr::updateApplyOfOperations(ModuleBase_Operation* theOperation)
284 XGUI_ErrorMgr* anErrorMgr = XGUI_Tools::workshop(myWorkshop)->errorMgr();
286 ModuleBase_OperationFeature* aFOperation =
287 dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
289 anErrorMgr->updateAcceptAllAction(aFOperation->feature());
292 foreach(ModuleBase_Operation* anOperation, myOperations) {
294 updateApplyOfOperations(anOperation);
297 // Apply button of the current operation should also be updated
298 onValidateOperation();
301 bool XGUI_OperationMgr::canStopOperation(ModuleBase_Operation* theOperation)
303 //in case of nested (sketch) operation no confirmation needed
304 if (isGrantedOperation(theOperation->id()))
306 if (theOperation && theOperation->isModified()) {
307 QString aMessage = tr("%1 operation will be aborted.").arg(theOperation->id());
308 int anAnswer = QMessageBox::question(qApp->activeWindow(),
309 tr("Abort operation"),
311 QMessageBox::Ok | QMessageBox::Cancel,
312 QMessageBox::Cancel);
313 return anAnswer == QMessageBox::Ok;
318 bool XGUI_OperationMgr::commitOperation()
320 //if (hasOperation() && currentOperation()->isValid()) {
321 // onCommitOperation();
325 return onCommitOperation();
328 void XGUI_OperationMgr::resumeOperation(ModuleBase_Operation* theOperation)
330 theOperation->resume();
333 bool XGUI_OperationMgr::isGrantedOperation(const QString& theId)
335 bool isGranted = false;
337 QListIterator<ModuleBase_Operation*> anIt(myOperations);
339 ModuleBase_Operation* aPreviousOperation = 0;
340 while (anIt.hasPrevious() && !isGranted) {
341 ModuleBase_Operation* anOp = anIt.previous();
343 isGranted = anOp->isGranted(theId);
348 void XGUI_OperationMgr::setCurrentFeature(const FeaturePtr& theFeature)
350 SessionPtr aMgr = ModelAPI_Session::get();
351 DocumentPtr aDoc = aMgr->activeDocument();
352 bool aIsOp = aMgr->isOperation();
354 aMgr->startOperation(QString("Set current feature: %1")
355 .arg(theFeature->getKind().c_str()).toStdString());
356 aDoc->setCurrentFeature(theFeature, false);
357 #ifdef DEBUG_CURRENT_FEATURE
358 qDebug(QString(" document->setCurrentFeature(false) = %1 SET").arg(
359 ModuleBase_Tools::objectName(
360 ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str());
364 aMgr->finishOperation();
367 bool XGUI_OperationMgr::canStartOperation(const QString& theId, bool& isCommitted)
369 bool aCanStart = true;
371 ModuleBase_Operation* aCurrentOp = currentOperation();
373 bool aGranted = aCurrentOp->isGranted(theId);
374 // the started operation is granted for the current one,
375 // e.g. current - Sketch, started - Line
380 if (!isGrantedOperation(theId)) {
381 // the operation is not granted in the current list of operations
382 // e.g. Edit Parameter when Sketch, Line in Sketch is active.
383 aCanStart = abortAllOperations();
385 else if (canStopOperation(aCurrentOp)) {
386 // the started operation is granted in the parrent operation,
387 // e.g. current - Line in Sketch, started Circle
388 stopOperation(aCurrentOp, isCommitted);
397 void XGUI_OperationMgr::stopOperation(ModuleBase_Operation* theOperation, bool& isCommitted)
399 if (XGUI_Tools::workshop(myWorkshop)->errorMgr()->isApplyEnabled() && theOperation->isModified())
400 isCommitted = theOperation->commit();
403 abortOperation(theOperation);
407 void XGUI_OperationMgr::abortOperation(ModuleBase_Operation* theOperation)
409 ModuleBase_Operation* aCurrentOperation = currentOperation();
410 if (theOperation == aCurrentOperation)
411 theOperation->abort();
413 // it is possible to trigger upper operation(e.g. sketch, current is sketch line)
414 // all operation from the current to triggered should also be aborted
415 // operations over the parameter one are not aborted(e.g. extrusion cut, sketch abort)
416 while(hasOperation()) {
417 ModuleBase_Operation* aCurrentOperation = currentOperation();
418 aCurrentOperation->abort();
419 if(theOperation == aCurrentOperation)
425 bool XGUI_OperationMgr::onCommitOperation()
427 bool isCommitted = false;
428 ModuleBase_Operation* anOperation = currentOperation();
429 if (anOperation && myWorkshop->module()->canCommitOperation())
430 isCommitted = anOperation->commit();
434 void XGUI_OperationMgr::onAbortOperation()
436 ModuleBase_Operation* aCurrentOperation = currentOperation();
437 if (aCurrentOperation && canStopOperation(aCurrentOperation)) {
438 abortOperation(aCurrentOperation);
442 void XGUI_OperationMgr::onBeforeOperationStarted()
444 ModuleBase_Operation* aCurrentOperation = dynamic_cast<ModuleBase_Operation*>(sender());
445 if (!aCurrentOperation)
448 /// Set current feature and remeber old current feature
449 ModuleBase_OperationFeature* aFOperation =
450 dynamic_cast<ModuleBase_OperationFeature*>(aCurrentOperation);
452 SessionPtr aMgr = ModelAPI_Session::get();
453 DocumentPtr aDoc = aMgr->activeDocument();
454 // the parameter of current feature should be false, we should use all feature, not only
455 // visible in order to correctly save the previous feature of the nested operation, where the
456 // features can be not visible in the tree. The problem case is Edit sketch entitity(line)
457 // in the Sketch, created in ExtrusionCut operation. The entity disappears by commit.
458 // When sketch entity operation started, the sketch should be cashed here as the current.
459 // Otherwise(the flag is true), the ExtrusionCut is cashed, when commit happens, the sketch
460 // is disabled, sketch entity is disabled as extrusion cut is created earliest then sketch.
461 // As a result the sketch disappears from the viewer.
462 // However after commit it is displayed back.
463 aFOperation->setPreviousCurrentFeature(aDoc->currentFeature(false));
465 #ifdef DEBUG_CURRENT_FEATURE
466 FeaturePtr aFeature = aFOperation->feature();
467 QString aKind = aFeature ? aFeature->getKind().c_str() : "";
469 qDebug(QString("onBeforeOperationStarted() isEditOperation = %1, feature = %2")
470 .arg(aFOperation->isEditOperation())
471 .arg(ModuleBase_Tools::objectName(aFeature)).toStdString().c_str());
472 qDebug(QString(" document->currentFeature(false) = %1 : DO: setPreviousCurrentFeature").arg(
473 ModuleBase_Tools::objectName(aDoc->currentFeature(false))).toStdString().c_str());
476 if (aFOperation->isEditOperation()) {// it should be performed by the feature edit only
477 // in create operation, the current feature is changed by addFeature()
478 aDoc->setCurrentFeature(aFOperation->feature(), false);
479 #ifdef DEBUG_CURRENT_FEATURE
480 qDebug(QString(" document->setCurrentFeature(false) = %1").arg(
481 ModuleBase_Tools::objectName(aDoc->currentFeature(false))).toStdString().c_str());
483 // this is the only place where flushes must be called after setCurrentFeature for the
484 // current moment: after this the opertion is not finished, so, the ObjectBrowser
485 // state may be corrupted (issue #1457)
486 static Events_Loop* aLoop = Events_Loop::loop();
487 static Events_ID aCreateEvent = aLoop->eventByName(EVENT_OBJECT_CREATED);
488 aLoop->flush(aCreateEvent);
489 static Events_ID aDeleteEvent = aLoop->eventByName(EVENT_OBJECT_DELETED);
490 aLoop->flush(aDeleteEvent);
495 void XGUI_OperationMgr::onOperationStarted()
497 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
498 updateApplyOfOperations(aSenderOperation);
499 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
500 aWorkshop->operationStarted(aSenderOperation);
503 void XGUI_OperationMgr::onBeforeOperationAborted()
505 onBeforeOperationCommitted();
508 void XGUI_OperationMgr::onOperationAborted()
510 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
511 emit operationAborted(aSenderOperation);
514 void XGUI_OperationMgr::onBeforeOperationCommitted()
516 ModuleBase_Operation* aCurrentOperation = dynamic_cast<ModuleBase_Operation*>(sender());
517 if (!aCurrentOperation)
520 /// Restore the previous current feature
521 ModuleBase_OperationFeature* aFOperation =
522 dynamic_cast<ModuleBase_OperationFeature*>(aCurrentOperation);
524 #ifdef DEBUG_CURRENT_FEATURE
525 QString aKind = aFOperation->feature()->getKind().c_str();
526 qDebug(QString("onBeforeOperationCommitted() isEditOperation = %1, feature = %2")
527 .arg(aFOperation->isEditOperation())
528 .arg(ModuleBase_Tools::objectName(aFOperation->feature())).toStdString().c_str());
529 qDebug(QString(" document->currentFeature(false) = %1").arg(
530 ModuleBase_Tools::objectName(
531 ModelAPI_Session::get()->activeDocument()->currentFeature(false)))
532 .toStdString().c_str());
535 if (aFOperation->isEditOperation()) {
536 /// Restore the previous current feature
537 setCurrentFeature(aFOperation->previousCurrentFeature());
539 else { // create operation
540 // the Top created feature should stays the current. In nested operations,
541 // like Line in the Sketch or
542 // Sketch in ExtrusionCut, a previous feature should be restored on commit.
543 // It is performed here
544 // in order to perform it in the current transaction without opening a new one.
545 if (myOperations.front() != aFOperation)
546 setCurrentFeature(aFOperation->previousCurrentFeature());
548 ModuleBase_IModule* aModule = myWorkshop->module();
550 aModule->beforeOperationStopped(aFOperation);
554 void XGUI_OperationMgr::onOperationCommitted()
556 // apply state for all features from the stack of operations should be updated
557 updateApplyOfOperations();
559 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
560 emit operationCommitted(aSenderOperation);
563 void XGUI_OperationMgr::onOperationResumed()
565 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
566 emit operationResumed(aSenderOperation);
569 void XGUI_OperationMgr::onOperationStopped()
571 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
572 ModuleBase_Operation* aCurrentOperation = currentOperation();
573 if (!aSenderOperation || !aCurrentOperation || aSenderOperation != aCurrentOperation)
576 myOperations.removeAll(aCurrentOperation);
577 aCurrentOperation->deleteLater();
579 emit operationStopped(aCurrentOperation);
581 // get last operation which can be resumed
582 ModuleBase_Operation* aResultOp = 0;
583 QListIterator<ModuleBase_Operation*> anIt(myOperations);
585 while (anIt.hasPrevious()) {
586 ModuleBase_Operation* anOp = anIt.previous();
593 bool isModified = aCurrentOperation->isModified();
594 aResultOp->setIsModified(aResultOp->isModified() || isModified);
595 resumeOperation(aResultOp);
596 onValidateOperation();
600 bool XGUI_OperationMgr::onKeyReleased(QObject *theObject, QKeyEvent* theEvent)
602 // Let the manager decide what to do with the given key combination.
603 ModuleBase_Operation* anOperation = currentOperation();
604 bool isAccepted = false;
605 switch (theEvent->key()) {
606 case Qt::Key_Escape: {
607 ModuleBase_Operation* aOperation = currentOperation();
615 case Qt::Key_Backtab:
617 ModuleBase_Operation* aOperation = currentOperation();
619 ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
621 QWidget* aFocusedWidget = qApp->focusWidget();
622 bool isPPChildObject = aFocusedWidget && isChildObject(aFocusedWidget, aPanel);
623 if (!isPPChildObject) {
624 // check for case when the operation is started but property panel is not filled
625 XGUI_PropertyPanel* aPP = dynamic_cast<XGUI_PropertyPanel*>(aPanel);
626 aPP->setFocusNextPrevChild(theEvent->key() == Qt::Key_Tab);
634 case Qt::Key_Enter: {
635 isAccepted = onProcessEnter(theObject);
640 bool noModifiers = (theEvent->modifiers() == Qt::NoModifier);
642 ModuleBase_IViewer* aViewer = myWorkshop->viewer();
643 Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
644 if (!aContext.IsNull()) {
645 Handle(V3d_View) aView = aViewer->activeView();
646 if ((theEvent->key() == Qt::Key_N))
647 aContext->HilightNextDetected(aView);
648 else if ((theEvent->key() == Qt::Key_P))
649 aContext->HilightPreviousDetected(aView);
660 // anOperation->keyReleased(theEvent->key());
665 bool XGUI_OperationMgr::onProcessEnter(QObject* theObject)
667 bool isAccepted = false;
668 ModuleBase_Operation* aOperation = currentOperation();
669 // to avoid enter processing when operation has not been started yet
672 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
673 // the next code is obsolete as we want to process Enter in property panel always
674 // only property panel enter is processed in order to do not process enter in application dialogs
675 //bool isPPChild = isChildObject(theObject, aPanel);
677 // return isAccepted;
679 ModuleBase_ModelWidget* anActiveWgt = aPanel->activeWidget();
680 bool isAborted = false;
682 QWidget* aFocusWidget = aPanel->focusWidget();
683 QToolButton* aCancelBtn =
684 dynamic_cast<XGUI_PropertyPanel*>(aPanel)->findButton(PROP_PANEL_CANCEL);
685 if (aFocusWidget && aCancelBtn && aFocusWidget == aCancelBtn) {
686 abortOperation(aOperation);
692 isAccepted = anActiveWgt && anActiveWgt->processEnter();
695 myWorkshop->module()->processEnter(anActiveWgt ? anActiveWgt->attributeID() : "");
697 /// functionality is similar to Apply click
698 ModuleBase_OperationFeature* aFOperation =
699 dynamic_cast<ModuleBase_OperationFeature*>(currentOperation());
701 myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty()) {
702 // key released is emitted to apply the current value to the model
703 // if it was modified in PP
704 emit keyEnterReleased();
716 bool editorControl(QObject* theObject)
718 QLineEdit* aLineEdit = dynamic_cast<QLineEdit*>(theObject);
722 bool XGUI_OperationMgr::onProcessDelete(QObject* theObject)
724 bool isAccepted = false;
725 ModuleBase_Operation* aOperation = currentOperation();
726 ModuleBase_ModelWidget* anActiveWgt = 0;
727 // firstly the widget should process Delete action
728 ModuleBase_IPropertyPanel* aPanel;
729 bool isPPChildObject = false;
731 aPanel = aOperation->propertyPanel();
733 isPPChildObject = isChildObject(theObject, aPanel);
734 // process delete in active widget only if delete sender is child of property panel
735 // it is necessary for the case when OB is shown, user perform selection and click Delete
736 if (isPPChildObject) {
737 anActiveWgt = aPanel->activeWidget();
739 isAccepted = anActiveWgt->processDelete();
745 // after widget, object browser and viewer should process delete
746 /// other widgets such as line edit controls should not lead to
747 /// processing delete by workshop
748 XGUI_ObjectsBrowser* aBrowser = XGUI_Tools::workshop(myWorkshop)->objectBrowser();
749 QWidget* aViewPort = myWorkshop->viewer()->activeViewPort();
750 bool isToDeleteObject = false;
751 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
752 XGUI_ContextMenuMgr* aContextMenuMgr = aWorkshop->contextMenuMgr();
753 if (theObject == aBrowser->treeView()) {
754 aContextMenuMgr->updateObjectBrowserMenu();
755 isToDeleteObject = aContextMenuMgr->action("DELETE_CMD")->isEnabled();
757 else if (isChildObject(theObject, aViewPort)) {
758 aContextMenuMgr->updateViewerMenu();
759 isToDeleteObject = aContextMenuMgr->action("DELETE_CMD")->isEnabled();
761 else if (isPPChildObject) {
762 // property panel child object is processed to process delete performed on Apply button of PP
763 isToDeleteObject = true;
765 else if (editorControl(theObject)) {
766 isToDeleteObject = false; /// Line Edit of Rename operation in ObjectBrowser
770 if (isToDeleteObject) {
771 aWorkshop->deleteObjects();
779 bool XGUI_OperationMgr::isChildObject(const QObject* theObject, const QObject* theParent)
781 bool isPPChild = false;
782 if (theParent && theObject) {
783 QObject* aParent = (QObject*)theObject;
785 isPPChild = aParent == theParent;
788 aParent = aParent->parent();