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 email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
20 #include "XGUI_OperationMgr.h"
21 #include "XGUI_ModuleConnector.h"
22 #include "XGUI_Workshop.h"
23 #include "XGUI_ErrorMgr.h"
24 #include "XGUI_Tools.h"
25 #include "XGUI_ObjectsBrowser.h"
26 #include "XGUI_ContextMenuMgr.h"
28 #include <ModuleBase_IPropertyPanel.h>
29 #include <ModuleBase_ModelWidget.h>
30 #include "ModuleBase_Operation.h"
31 #include "ModuleBase_IWorkshop.h"
32 #include "ModuleBase_IModule.h"
33 #include <ModuleBase_IViewer.h>
34 #include "ModuleBase_OperationDescription.h"
35 #include "ModuleBase_OperationFeature.h"
36 #include "ModuleBase_Tools.h"
38 #include "ModelAPI_CompositeFeature.h"
39 #include "ModelAPI_Session.h"
41 #include <XGUI_PropertyPanel.h>
42 #include <QToolButton>
45 #include <QMessageBox>
46 #include <QApplication>
49 //#define DEBUG_CURRENT_FEATURE
51 /// Processes "Delete" key event of application. This key is used by several application actions.
52 /// There is a logical order of the actions processing. So the key can not be set for actions
53 /// as a shortcut. The class listens the key event and call operation manager processor.
54 class XGUI_ShortCutListener : public QObject
58 /// \param theParent the parent to be deleted when the parent is deleted
59 /// \param theOperationMgr the class to perform deletion
60 XGUI_ShortCutListener(QObject* theParent, XGUI_OperationMgr* theOperationMgr)
61 : QObject(theParent), myOperationMgr(theOperationMgr)
63 qApp->installEventFilter(this);
65 ~XGUI_ShortCutListener() {}
67 /// Switch on short cut listener
68 void setActive(const bool theIsActive) { myIsActive = theIsActive; }
70 /// Redefinition of virtual function to process Delete key release
71 virtual bool eventFilter(QObject *theObject, QEvent *theEvent)
73 bool isAccepted = false;
74 if (myIsActive && theEvent->type() == QEvent::KeyRelease) {
75 QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*>(theEvent);
77 switch (aKeyEvent->key()) {
79 isAccepted = myOperationMgr->onProcessDelete(theObject);
82 isAccepted = myOperationMgr->onKeyReleased(theObject, aKeyEvent);
88 isAccepted = QObject::eventFilter(theObject, theEvent);
93 XGUI_OperationMgr* myOperationMgr; /// processor for key event
94 bool myIsActive; /// boolean state whether the event filter perform own signal processing
97 XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent,
98 ModuleBase_IWorkshop* theWorkshop)
99 : QObject(theParent), myWorkshop(theWorkshop)
101 /// we need to install filter to the application in order to react to 'Delete' key button
102 /// this key can not be a short cut for a corresponded action because we need to set
103 /// the actions priority
104 myShortCutListener = new XGUI_ShortCutListener(theParent, this);
107 XGUI_OperationMgr::~XGUI_OperationMgr()
111 void XGUI_OperationMgr::activate()
113 myShortCutListener->setActive(true);
116 void XGUI_OperationMgr::deactivate()
118 myShortCutListener->setActive(false);
121 ModuleBase_Operation* XGUI_OperationMgr::currentOperation() const
123 return myOperations.count() > 0 ? myOperations.last() : 0;
126 bool XGUI_OperationMgr::isCurrentOperation(ModuleBase_Operation* theOperation)
130 return currentOperation() == theOperation;
133 bool XGUI_OperationMgr::hasOperation() const
135 return !myOperations.isEmpty() && (myOperations.last() != NULL);
138 bool XGUI_OperationMgr::hasOperation(const QString& theId) const
140 foreach(ModuleBase_Operation* aOp, myOperations) {
141 if (aOp->id() == theId)
147 ModuleBase_Operation* XGUI_OperationMgr::findOperation(const QString& theId) const
149 QList<ModuleBase_Operation*>::const_iterator anIt = myOperations.end();
150 while (anIt != myOperations.begin()) {
152 ModuleBase_Operation* anOperation = *anIt;
153 if (anOperation->id() == theId)
160 int XGUI_OperationMgr::operationsCount() const
162 return myOperations.count();
165 QStringList XGUI_OperationMgr::operationList() const
168 foreach(ModuleBase_Operation* eachOperation, myOperations) {
169 ModuleBase_OperationFeature* aFOperation =
170 dynamic_cast<ModuleBase_OperationFeature*>(eachOperation);
172 FeaturePtr aFeature = aFOperation->feature();
174 result << QString::fromStdString(aFeature->getKind());
181 ModuleBase_Operation* XGUI_OperationMgr::previousOperation(ModuleBase_Operation* theOperation) const
183 int idx = myOperations.lastIndexOf(theOperation);
184 if(idx == -1 || idx == 0) {
187 return myOperations.at(idx - 1);
190 bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation)
193 currentOperation()->postpone();
194 myOperations.append(theOperation);
196 connect(theOperation, SIGNAL(beforeStarted()), SLOT(onBeforeOperationStarted()));
197 connect(theOperation, SIGNAL(beforeAborted()), SLOT(onBeforeOperationAborted()));
198 connect(theOperation, SIGNAL(beforeCommitted()), SLOT(onBeforeOperationCommitted()));
200 connect(theOperation, SIGNAL(started()), SLOT(onOperationStarted()));
201 connect(theOperation, SIGNAL(aborted()), SLOT(onOperationAborted()));
202 connect(theOperation, SIGNAL(committed()), SLOT(onOperationCommitted()));
204 connect(theOperation, SIGNAL(stopped()), SLOT(onOperationStopped()));
205 connect(theOperation, SIGNAL(resumed()), SLOT(onOperationResumed()));
207 bool isStarted = theOperation->start();
209 onValidateOperation();
213 bool XGUI_OperationMgr::abortAllOperations()
219 if (operationsCount() == 1) {
220 ModuleBase_Operation* aCurrentOperation = currentOperation();
221 if (canStopOperation(aCurrentOperation)) {
222 abortOperation(aCurrentOperation);
228 aResult = QMessageBox::question(qApp->activeWindow(),
229 tr("Abort operation"),
230 tr("All active operations will be aborted."),
231 QMessageBox::Ok | QMessageBox::Cancel,
232 QMessageBox::Cancel) == QMessageBox::Ok;
233 while(aResult && hasOperation()) {
234 abortOperation(currentOperation());
240 bool XGUI_OperationMgr::commitAllOperations()
242 bool isCompositeCommitted = false, anOperationProcessed = false;
243 while (hasOperation()) {
244 ModuleBase_Operation* anOperation = currentOperation();
245 if (XGUI_Tools::workshop(myWorkshop)->errorMgr()->isApplyEnabled()) {
246 anOperationProcessed = onCommitOperation();
248 abortOperation(anOperation);
249 anOperationProcessed = true;
251 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
254 FeaturePtr aFeature = aFOperation->feature();
255 CompositeFeaturePtr aComposite =
256 std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
257 isCompositeCommitted = aComposite.get();
258 if (isCompositeCommitted)
261 // not processed[committed] operation might be used in composite feature,
262 // so the while will be stopped by the previous check.
263 // this code is not necessary, but logically should be done when the processing will not
264 // be done for not composite feature by some reasons
265 if (!anOperationProcessed)
271 void XGUI_OperationMgr::onValidateOperation()
275 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
276 (currentOperation());
277 if(aFOperation && aFOperation->feature().get())
278 XGUI_Tools::workshop(myWorkshop)->errorMgr()->updateActions(aFOperation->feature());
281 void XGUI_OperationMgr::updateApplyOfOperations(ModuleBase_Operation* theOperation)
283 XGUI_ErrorMgr* anErrorMgr = XGUI_Tools::workshop(myWorkshop)->errorMgr();
285 ModuleBase_OperationFeature* aFOperation =
286 dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
288 anErrorMgr->updateAcceptAllAction(aFOperation->feature());
291 foreach(ModuleBase_Operation* anOperation, myOperations) {
293 updateApplyOfOperations(anOperation);
296 // Apply button of the current operation should also be updated
297 onValidateOperation();
300 bool XGUI_OperationMgr::canStopOperation(ModuleBase_Operation* theOperation)
302 //in case of nested (sketch) operation no confirmation needed
303 if (isGrantedOperation(theOperation->id()))
305 if (theOperation && theOperation->isModified()) {
306 QString aMessage = tr("%1 operation will be aborted.").arg(theOperation->id());
307 int anAnswer = QMessageBox::question(qApp->activeWindow(),
308 tr("Abort operation"),
310 QMessageBox::Ok | QMessageBox::Cancel,
311 QMessageBox::Cancel);
312 return anAnswer == QMessageBox::Ok;
317 bool XGUI_OperationMgr::commitOperation()
319 //if (hasOperation() && currentOperation()->isValid()) {
320 // onCommitOperation();
324 return onCommitOperation();
327 void XGUI_OperationMgr::resumeOperation(ModuleBase_Operation* theOperation)
329 theOperation->resume();
332 bool XGUI_OperationMgr::isGrantedOperation(const QString& theId)
334 bool isGranted = false;
336 QListIterator<ModuleBase_Operation*> anIt(myOperations);
338 ModuleBase_Operation* aPreviousOperation = 0;
339 while (anIt.hasPrevious() && !isGranted) {
340 ModuleBase_Operation* anOp = anIt.previous();
342 isGranted = anOp->isGranted(theId);
347 void XGUI_OperationMgr::setCurrentFeature(const FeaturePtr& theFeature)
349 SessionPtr aMgr = ModelAPI_Session::get();
350 DocumentPtr aDoc = aMgr->activeDocument();
351 bool aIsOp = aMgr->isOperation();
353 aMgr->startOperation(QString("Set current feature: %1")
354 .arg(theFeature->getKind().c_str()).toStdString());
355 aDoc->setCurrentFeature(theFeature, false);
356 #ifdef DEBUG_CURRENT_FEATURE
357 qDebug(QString(" document->setCurrentFeature(false) = %1 SET").arg(
358 ModuleBase_Tools::objectName(
359 ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str());
363 aMgr->finishOperation();
366 bool XGUI_OperationMgr::canStartOperation(const QString& theId, bool& isCommitted)
368 bool aCanStart = true;
370 ModuleBase_Operation* aCurrentOp = currentOperation();
372 bool aGranted = aCurrentOp->isGranted(theId);
373 // the started operation is granted for the current one,
374 // e.g. current - Sketch, started - Line
379 if (!isGrantedOperation(theId)) {
380 // the operation is not granted in the current list of operations
381 // e.g. Edit Parameter when Sketch, Line in Sketch is active.
382 aCanStart = abortAllOperations();
384 else if (canStopOperation(aCurrentOp)) {
385 // the started operation is granted in the parrent operation,
386 // e.g. current - Line in Sketch, started Circle
387 stopOperation(aCurrentOp, isCommitted);
396 void XGUI_OperationMgr::stopOperation(ModuleBase_Operation* theOperation, bool& isCommitted)
398 if (XGUI_Tools::workshop(myWorkshop)->errorMgr()->isApplyEnabled() && theOperation->isModified())
399 isCommitted = theOperation->commit();
402 abortOperation(theOperation);
406 void XGUI_OperationMgr::abortOperation(ModuleBase_Operation* theOperation)
408 ModuleBase_Operation* aCurrentOperation = currentOperation();
409 if (theOperation == aCurrentOperation)
410 theOperation->abort();
412 // it is possible to trigger upper operation(e.g. sketch, current is sketch line)
413 // all operation from the current to triggered should also be aborted
414 // operations over the parameter one are not aborted(e.g. extrusion cut, sketch abort)
415 while(hasOperation()) {
416 ModuleBase_Operation* aCurrentOperation = currentOperation();
417 aCurrentOperation->abort();
418 if(theOperation == aCurrentOperation)
424 bool XGUI_OperationMgr::onCommitOperation()
426 bool isCommitted = false;
427 ModuleBase_Operation* anOperation = currentOperation();
428 if (anOperation && myWorkshop->module()->canCommitOperation())
429 isCommitted = anOperation->commit();
433 void XGUI_OperationMgr::onAbortOperation()
435 ModuleBase_Operation* aCurrentOperation = currentOperation();
436 if (aCurrentOperation && canStopOperation(aCurrentOperation)) {
437 abortOperation(aCurrentOperation);
441 void XGUI_OperationMgr::onBeforeOperationStarted()
443 ModuleBase_Operation* aCurrentOperation = dynamic_cast<ModuleBase_Operation*>(sender());
444 if (!aCurrentOperation)
447 /// Set current feature and remeber old current feature
448 ModuleBase_OperationFeature* aFOperation =
449 dynamic_cast<ModuleBase_OperationFeature*>(aCurrentOperation);
451 SessionPtr aMgr = ModelAPI_Session::get();
452 DocumentPtr aDoc = aMgr->activeDocument();
453 // the parameter of current feature should be false, we should use all feature, not only
454 // visible in order to correctly save the previous feature of the nested operation, where the
455 // features can be not visible in the tree. The problem case is Edit sketch entitity(line)
456 // in the Sketch, created in ExtrusionCut operation. The entity disappears by commit.
457 // When sketch entity operation started, the sketch should be cashed here as the current.
458 // Otherwise(the flag is true), the ExtrusionCut is cashed, when commit happens, the sketch
459 // is disabled, sketch entity is disabled as extrusion cut is created earliest then sketch.
460 // As a result the sketch disappears from the viewer.
461 // However after commit it is displayed back.
462 aFOperation->setPreviousCurrentFeature(aDoc->currentFeature(false));
464 #ifdef DEBUG_CURRENT_FEATURE
465 FeaturePtr aFeature = aFOperation->feature();
466 QString aKind = aFeature ? aFeature->getKind().c_str() : "";
468 qDebug(QString("onBeforeOperationStarted() isEditOperation = %1, feature = %2")
469 .arg(aFOperation->isEditOperation())
470 .arg(ModuleBase_Tools::objectName(aFeature)).toStdString().c_str());
471 qDebug(QString(" document->currentFeature(false) = %1 : DO: setPreviousCurrentFeature").arg(
472 ModuleBase_Tools::objectName(aDoc->currentFeature(false))).toStdString().c_str());
475 if (aFOperation->isEditOperation()) {// it should be performed by the feature edit only
476 // in create operation, the current feature is changed by addFeature()
477 aDoc->setCurrentFeature(aFOperation->feature(), false);
478 #ifdef DEBUG_CURRENT_FEATURE
479 qDebug(QString(" document->setCurrentFeature(false) = %1").arg(
480 ModuleBase_Tools::objectName(aDoc->currentFeature(false))).toStdString().c_str());
482 // this is the only place where flushes must be called after setCurrentFeature for the
483 // current moment: after this the opertion is not finished, so, the ObjectBrowser
484 // state may be corrupted (issue #1457)
485 static Events_Loop* aLoop = Events_Loop::loop();
486 static Events_ID aCreateEvent = aLoop->eventByName(EVENT_OBJECT_CREATED);
487 aLoop->flush(aCreateEvent);
488 static Events_ID aDeleteEvent = aLoop->eventByName(EVENT_OBJECT_DELETED);
489 aLoop->flush(aDeleteEvent);
494 void XGUI_OperationMgr::onOperationStarted()
496 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
497 updateApplyOfOperations(aSenderOperation);
498 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
499 aWorkshop->operationStarted(aSenderOperation);
502 void XGUI_OperationMgr::onBeforeOperationAborted()
504 onBeforeOperationCommitted();
507 void XGUI_OperationMgr::onOperationAborted()
509 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
510 emit operationAborted(aSenderOperation);
513 void XGUI_OperationMgr::onBeforeOperationCommitted()
515 ModuleBase_Operation* aCurrentOperation = dynamic_cast<ModuleBase_Operation*>(sender());
516 if (!aCurrentOperation)
519 /// Restore the previous current feature
520 ModuleBase_OperationFeature* aFOperation =
521 dynamic_cast<ModuleBase_OperationFeature*>(aCurrentOperation);
523 #ifdef DEBUG_CURRENT_FEATURE
524 QString aKind = aFOperation->feature()->getKind().c_str();
525 qDebug(QString("onBeforeOperationCommitted() isEditOperation = %1, feature = %2")
526 .arg(aFOperation->isEditOperation())
527 .arg(ModuleBase_Tools::objectName(aFOperation->feature())).toStdString().c_str());
528 qDebug(QString(" document->currentFeature(false) = %1").arg(
529 ModuleBase_Tools::objectName(
530 ModelAPI_Session::get()->activeDocument()->currentFeature(false)))
531 .toStdString().c_str());
534 if (aFOperation->isEditOperation()) {
535 /// Restore the previous current feature
536 setCurrentFeature(aFOperation->previousCurrentFeature());
538 else { // create operation
539 // the Top created feature should stays the current. In nested operations,
540 // like Line in the Sketch or
541 // Sketch in ExtrusionCut, a previous feature should be restored on commit.
542 // It is performed here
543 // in order to perform it in the current transaction without opening a new one.
544 if (myOperations.front() != aFOperation)
545 setCurrentFeature(aFOperation->previousCurrentFeature());
547 ModuleBase_IModule* aModule = myWorkshop->module();
549 aModule->beforeOperationStopped(aFOperation);
553 void XGUI_OperationMgr::onOperationCommitted()
555 // apply state for all features from the stack of operations should be updated
556 updateApplyOfOperations();
558 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
559 emit operationCommitted(aSenderOperation);
562 void XGUI_OperationMgr::onOperationResumed()
564 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
565 emit operationResumed(aSenderOperation);
568 void XGUI_OperationMgr::onOperationStopped()
570 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
571 ModuleBase_Operation* aCurrentOperation = currentOperation();
572 if (!aSenderOperation || !aCurrentOperation || aSenderOperation != aCurrentOperation)
575 myOperations.removeAll(aCurrentOperation);
576 aCurrentOperation->deleteLater();
578 emit operationStopped(aCurrentOperation);
580 // get last operation which can be resumed
581 ModuleBase_Operation* aResultOp = 0;
582 QListIterator<ModuleBase_Operation*> anIt(myOperations);
584 while (anIt.hasPrevious()) {
585 ModuleBase_Operation* anOp = anIt.previous();
592 bool isModified = aCurrentOperation->isModified();
593 aResultOp->setIsModified(aResultOp->isModified() || isModified);
594 resumeOperation(aResultOp);
595 onValidateOperation();
599 bool XGUI_OperationMgr::onKeyReleased(QObject *theObject, QKeyEvent* theEvent)
601 // Let the manager decide what to do with the given key combination.
602 ModuleBase_Operation* anOperation = currentOperation();
603 bool isAccepted = false;
604 switch (theEvent->key()) {
605 case Qt::Key_Escape: {
606 ModuleBase_Operation* aOperation = currentOperation();
614 case Qt::Key_Backtab:
616 ModuleBase_Operation* aOperation = currentOperation();
618 ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
620 QWidget* aFocusedWidget = qApp->focusWidget();
621 bool isPPChildObject = aFocusedWidget && isChildObject(aFocusedWidget, aPanel);
622 if (!isPPChildObject) {
623 // check for case when the operation is started but property panel is not filled
624 XGUI_PropertyPanel* aPP = dynamic_cast<XGUI_PropertyPanel*>(aPanel);
625 aPP->setFocusNextPrevChild(theEvent->key() == Qt::Key_Tab);
633 case Qt::Key_Enter: {
634 isAccepted = onProcessEnter(theObject);
639 bool noModifiers = (theEvent->modifiers() == Qt::NoModifier);
641 ModuleBase_IViewer* aViewer = myWorkshop->viewer();
642 Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
643 if (!aContext.IsNull()) {
644 Handle(V3d_View) aView = aViewer->activeView();
645 if ((theEvent->key() == Qt::Key_N))
646 aContext->HilightNextDetected(aView);
647 else if ((theEvent->key() == Qt::Key_P))
648 aContext->HilightPreviousDetected(aView);
659 // anOperation->keyReleased(theEvent->key());
664 bool XGUI_OperationMgr::onProcessEnter(QObject* theObject)
666 bool isAccepted = false;
667 ModuleBase_Operation* aOperation = currentOperation();
668 // to avoid enter processing when operation has not been started yet
671 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
672 // the next code is obsolete as we want to process Enter in property panel always
673 // only property panel enter is processed in order to do not process enter in application dialogs
674 //bool isPPChild = isChildObject(theObject, aPanel);
676 // return isAccepted;
678 ModuleBase_ModelWidget* anActiveWgt = aPanel->activeWidget();
679 bool isAborted = false;
681 QWidget* aFocusWidget = aPanel->focusWidget();
682 QToolButton* aCancelBtn =
683 dynamic_cast<XGUI_PropertyPanel*>(aPanel)->findButton(PROP_PANEL_CANCEL);
684 if (aFocusWidget && aCancelBtn && aFocusWidget == aCancelBtn) {
685 abortOperation(aOperation);
691 isAccepted = anActiveWgt && anActiveWgt->processEnter();
694 myWorkshop->module()->processEnter(anActiveWgt ? anActiveWgt->attributeID() : "");
696 /// functionality is similar to Apply click
697 ModuleBase_OperationFeature* aFOperation =
698 dynamic_cast<ModuleBase_OperationFeature*>(currentOperation());
700 myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty()) {
701 // key released is emitted to apply the current value to the model
702 // if it was modified in PP
703 emit keyEnterReleased();
715 bool editorControl(QObject* theObject)
717 QLineEdit* aLineEdit = dynamic_cast<QLineEdit*>(theObject);
721 bool XGUI_OperationMgr::onProcessDelete(QObject* theObject)
723 bool isAccepted = false;
724 ModuleBase_Operation* aOperation = currentOperation();
725 ModuleBase_ModelWidget* anActiveWgt = 0;
726 // firstly the widget should process Delete action
727 ModuleBase_IPropertyPanel* aPanel;
728 bool isPPChildObject = false;
730 aPanel = aOperation->propertyPanel();
732 isPPChildObject = isChildObject(theObject, aPanel);
733 // process delete in active widget only if delete sender is child of property panel
734 // it is necessary for the case when OB is shown, user perform selection and click Delete
735 if (isPPChildObject) {
736 anActiveWgt = aPanel->activeWidget();
738 isAccepted = anActiveWgt->processDelete();
744 // after widget, object browser and viewer should process delete
745 /// other widgets such as line edit controls should not lead to
746 /// processing delete by workshop
747 XGUI_ObjectsBrowser* aBrowser = XGUI_Tools::workshop(myWorkshop)->objectBrowser();
748 QWidget* aViewPort = myWorkshop->viewer()->activeViewPort();
749 bool isToDeleteObject = false;
750 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
751 XGUI_ContextMenuMgr* aContextMenuMgr = aWorkshop->contextMenuMgr();
752 if (theObject == aBrowser->treeView()) {
753 aContextMenuMgr->updateObjectBrowserMenu();
754 isToDeleteObject = aContextMenuMgr->action("DELETE_CMD")->isEnabled();
756 else if (isChildObject(theObject, aViewPort)) {
757 aContextMenuMgr->updateViewerMenu();
758 isToDeleteObject = aContextMenuMgr->action("DELETE_CMD")->isEnabled();
760 else if (isPPChildObject) {
761 // property panel child object is processed to process delete performed on Apply button of PP
762 isToDeleteObject = true;
764 else if (editorControl(theObject)) {
765 isToDeleteObject = false; /// Line Edit of Rename operation in ObjectBrowser
769 if (isToDeleteObject) {
770 aWorkshop->deleteObjects();
778 bool XGUI_OperationMgr::isChildObject(const QObject* theObject, const QObject* theParent)
780 bool isPPChild = false;
781 if (theParent && theObject) {
782 QObject* aParent = (QObject*)theObject;
784 isPPChild = aParent == theParent;
787 aParent = aParent->parent();