1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSet_LockApplyMgr.cpp
4 // Created: 25 Jun 2015
5 // Author: Natalia Ermolaeva
7 #include "PartSet_LockApplyMgr.h"
8 #include "PartSet_Module.h"
10 #include <ModuleBase_IWorkshop.h>
11 #include <ModuleBase_IViewer.h>
13 #include <XGUI_Workshop.h>
14 #include <XGUI_ViewerProxy.h>
15 #include <XGUI_ModuleConnector.h>
16 #include <XGUI_OperationMgr.h>
18 PartSet_LockApplyMgr::PartSet_LockApplyMgr(QObject* theParent,
19 ModuleBase_IWorkshop* theWorkshop)
20 : QObject(theParent), myWorkshop(theWorkshop)
24 void PartSet_LockApplyMgr::activate()
26 XGUI_ViewerProxy* aViewer = dynamic_cast<XGUI_ViewerProxy*>(myWorkshop->viewer());
27 connect(aViewer, SIGNAL(enterViewPort()), this, SLOT(onLockValidating()));
28 connect(aViewer, SIGNAL(leaveViewPort()), this, SLOT(onUnlockValidating()));
30 PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
31 if (aModule->isMouseOverWindow())
35 void PartSet_LockApplyMgr::deactivate()
37 XGUI_ViewerProxy* aViewer = dynamic_cast<XGUI_ViewerProxy*>(myWorkshop->viewer());
38 disconnect(aViewer, SIGNAL(enterViewPort()), this, SLOT(onLockValidating()));
39 disconnect(aViewer, SIGNAL(leaveViewPort()), this, SLOT(onUnlockValidating()));
44 void PartSet_LockApplyMgr::valuesChanged()
46 operationMgr()->setLockValidating(false);
49 void PartSet_LockApplyMgr::onLockValidating()
51 XGUI_OperationMgr* anOperationMgr = operationMgr();
53 anOperationMgr->setLockValidating(true);
54 // the Ok button should be disabled in the property panel by moving the mouse point in the viewer
55 // this leads that the user does not try to click Ok and it avoids an incorrect situation that the
56 // line is moved to the cursor to the Ok button
57 //anOperationMgr->setApplyEnabled(false);
60 void PartSet_LockApplyMgr::onUnlockValidating()
62 XGUI_OperationMgr* anOperationMgr = operationMgr();
64 // it is important to restore the validity state in the property panel after leaving the
65 // view port. Unlock the validating.
66 if (anOperationMgr->isValidationLocked()) {
67 anOperationMgr->setLockValidating(false);
68 //anOperationMgr->onValidateOperation();
72 XGUI_OperationMgr* PartSet_LockApplyMgr::operationMgr() const
74 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
75 XGUI_Workshop* aWorkshop = aConnector->workshop();
77 return aWorkshop->operationMgr();