From: nds Date: Fri, 13 Feb 2015 10:49:30 +0000 (+0300) Subject: Issue #394 Undo-ing a Sketch element X-Git-Tag: V_1.1.0~194 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1cbebb6f3e523ba66c3a2af447b33f8f210343ec;p=modules%2Fshaper.git Issue #394 Undo-ing a Sketch element Enter/Leave events using to process the state in the sketch manager. --- diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 2bbd22d09..fcc4576d4 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -110,7 +111,8 @@ void fillFeature2Attribute(const QList& theList, PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule) : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false), - myIsPropertyPanelValueChanged(false), myIsMouseOverViewProcessed(true) + myIsPropertyPanelValueChanged(false), myIsMouseOverWindow(false), + myIsMouseOverViewProcessed(true) { ModuleBase_IWorkshop* anIWorkshop = myModule->workshop(); ModuleBase_IViewer* aViewer = anIWorkshop->viewer(); @@ -140,19 +142,25 @@ PartSet_SketcherMgr::~PartSet_SketcherMgr() myPlaneFilter.Nullify(); } -void PartSet_SketcherMgr::onMouseMoveOverWindow(bool theOverWindow) +void PartSet_SketcherMgr::onEnterViewPort() { - if (!isNestedCreateOperation() || theOverWindow) + if (!isNestedCreateOperation()) return; // 1. if the mouse over window, update the next flag. Do not perform update visibility of // created feature because it should be done in onMouseMove(). Some widgets watch // the mouse move and use the cursor position to update own values. If the presentaion is // redisplayed before this update, the feature presentation jumps from reset value to current. - if (theOverWindow) { - myIsPropertyPanelValueChanged = false; + myIsMouseOverWindow = true; + myIsPropertyPanelValueChanged = false; +} + +void PartSet_SketcherMgr::onLeaveViewPort() +{ + if (!isNestedCreateOperation()) return; - } + myIsMouseOverViewProcessed = false; + myIsMouseOverWindow = false; // 2. if the mouse IS NOT over window, reset the active widget value and hide the presentation ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); @@ -456,8 +464,9 @@ void PartSet_SketcherMgr::onApplicationStarted() this, SLOT(onBeforeWidgetActivated(ModuleBase_ModelWidget*))); } - AppElements_MainWindow* aMainWindow = aWorkshop->mainWindow(); - connect(aMainWindow, SIGNAL(mouseMoveOverWindow(bool)), this, SLOT(onMouseMoveOverWindow(bool))); + XGUI_ViewerProxy* aViewerProxy = aWorkshop->viewer(); + connect(aViewerProxy, SIGNAL(enterViewPort()), this, SLOT(onEnterViewPort())); + connect(aViewerProxy, SIGNAL(leaveViewPort()), this, SLOT(onLeaveViewPort())); } void PartSet_SketcherMgr::onBeforeWidgetActivated(ModuleBase_ModelWidget* theWidget) @@ -644,6 +653,7 @@ void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* ) { connectToPropertyPanel(false); myIsPropertyPanelValueChanged = false; + myIsMouseOverWindow = false; myIsMouseOverViewProcessed = true; } @@ -665,15 +675,15 @@ bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const // during a nested create operation, the feature is redisplayed only if the mouse over view // of there was a value modified in the property panel after the mouse left the view - aCanDisplay = myIsPropertyPanelValueChanged; - if (!aCanDisplay) { + aCanDisplay = myIsPropertyPanelValueChanged || myIsMouseOverWindow; + /*if (!aCanDisplay) { ModuleBase_IWorkshop* anIWorkshop = myModule->workshop(); XGUI_ModuleConnector* aConnector = dynamic_cast(anIWorkshop); XGUI_Workshop* aWorkshop = aConnector->workshop(); AppElements_MainWindow* aMainWindow = aWorkshop->mainWindow(); - aCanDisplay = aMainWindow->isMouseOverWindow(); - } + //aCanDisplay = aMainWindow->isMouseOverWindow(); + }*/ return aCanDisplay; } diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index 59ed0f8fb..c9b16a0a9 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -130,9 +130,13 @@ public slots: private slots: - /// Process the signal about mouse moving into or out of the window - /// \param heOverWindow true, if the moving happens to window - void onMouseMoveOverWindow(bool theOverWindow); + /// Process the enter mouse to the view port. If the current operation is a create of + /// a nested sketch feature, it updates internal flags to display the feature on mouse move + void onEnterViewPort(); + /// Process the leave mouse of the view port. If the current operation is a create of + /// a nested sketch feature, it hides the feature in the viewer + void onLeaveViewPort(); + void onValuesChangedInPropertyPanel(); void onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*); void onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*); @@ -220,6 +224,7 @@ private: bool myIsDragging; bool myDragDone; bool myIsPropertyPanelValueChanged; /// the state that value in the property panel is changed + bool myIsMouseOverWindow; /// the state that the mouse over the view bool myIsMouseOverViewProcessed; /// the state whether the over view state is processed by mouseMove method Point myCurrentPoint; Point myClickedPoint; diff --git a/src/XGUI/XGUI_ViewerProxy.cpp b/src/XGUI/XGUI_ViewerProxy.cpp index ec7049618..3352c318f 100644 --- a/src/XGUI/XGUI_ViewerProxy.cpp +++ b/src/XGUI/XGUI_ViewerProxy.cpp @@ -10,6 +10,8 @@ #include #include +#include + XGUI_ViewerProxy::XGUI_ViewerProxy(XGUI_Workshop* theParent) : ModuleBase_IViewer(theParent), myWorkshop(theParent) @@ -105,7 +107,6 @@ void XGUI_ViewerProxy::connectToViewer() connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged())); connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this, SIGNAL(contextMenuRequested(QContextMenuEvent*))); - } else { AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); @@ -147,6 +148,21 @@ void XGUI_ViewerProxy::connectToViewer() } } +bool XGUI_ViewerProxy::eventFilter(QObject *theObject, QEvent *theEvent) +{ + AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); + bool isViewPort = theObject == aViewer->activeViewWindow()->viewPort(); + if (isViewPort) + { + if (theEvent->type() == QEvent::Enter) { + emit enterViewPort(); + } + else if (theEvent->type() == QEvent::Leave) { + emit leaveViewPort(); + } + } + return ModuleBase_IViewer::eventFilter(theObject, theEvent); +} void XGUI_ViewerProxy::onTryCloseView(AppElements_ViewWindow* theWnd) { @@ -160,6 +176,8 @@ void XGUI_ViewerProxy::onDeleteView(AppElements_ViewWindow* theWnd) void XGUI_ViewerProxy::onViewCreated(AppElements_ViewWindow* theWnd) { + theWnd->viewPort()->installEventFilter(this); + emit viewCreated(theWnd); } @@ -273,4 +291,4 @@ bool XGUI_ViewerProxy::canDragByMouse() const } else { return true; } -} \ No newline at end of file +} diff --git a/src/XGUI/XGUI_ViewerProxy.h b/src/XGUI/XGUI_ViewerProxy.h index acd152d23..2bc5497a4 100644 --- a/src/XGUI/XGUI_ViewerProxy.h +++ b/src/XGUI/XGUI_ViewerProxy.h @@ -73,6 +73,19 @@ Q_OBJECT /// by mouse drugging. If this is impossible thet it has to return False. virtual bool canDragByMouse() const; +signals: + /// Emits by mouse entering the view port + void enterViewPort(); + + /// Emits by mouse leaving of the view port + void leaveViewPort(); + +protected: + /// processes the application signals to catch the mouse leaving state of the main window + /// \param theObject + /// \param theEvent + bool eventFilter(QObject *theObject, QEvent *theEvent); + private slots: void onTryCloseView(AppElements_ViewWindow*); void onDeleteView(AppElements_ViewWindow*);