#include <ModuleBase_ModelWidget.h>
#include <XGUI_ModuleConnector.h>
#include <XGUI_PropertyPanel.h>
+#include <XGUI_ViewerProxy.h>
#include <AppElements_MainWindow.h>
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();
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();
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)
{
connectToPropertyPanel(false);
myIsPropertyPanelValueChanged = false;
+ myIsMouseOverWindow = false;
myIsMouseOverViewProcessed = true;
}
// 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<XGUI_ModuleConnector*>(anIWorkshop);
XGUI_Workshop* aWorkshop = aConnector->workshop();
AppElements_MainWindow* aMainWindow = aWorkshop->mainWindow();
- aCanDisplay = aMainWindow->isMouseOverWindow();
- }
+ //aCanDisplay = aMainWindow->isMouseOverWindow();
+ }*/
return aCanDisplay;
}
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*);
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;
#include <AppElements_ViewWindow.h>
#include <AppElements_Viewer.h>
+#include <QEvent>
+
XGUI_ViewerProxy::XGUI_ViewerProxy(XGUI_Workshop* theParent)
: ModuleBase_IViewer(theParent),
myWorkshop(theParent)
connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
SIGNAL(contextMenuRequested(QContextMenuEvent*)));
-
} else {
AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
}
}
+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)
{
void XGUI_ViewerProxy::onViewCreated(AppElements_ViewWindow* theWnd)
{
+ theWnd->viewPort()->installEventFilter(this);
+
emit viewCreated(theWnd);
}
} else {
return true;
}
-}
\ No newline at end of file
+}