From: nds Date: Tue, 29 Apr 2014 12:58:01 +0000 (+0400) Subject: refs #30 - Sketch base GUI: create, draw lines X-Git-Tag: V_0.2~104^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6957832ba852817fdac77616b248c3898cf13a7d;p=modules%2Fshaper.git refs #30 - Sketch base GUI: create, draw lines The code is corrected by the 3D Viewer modification, Call enable nested actions --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 5fb8796e0..54472ed0a 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -27,6 +28,7 @@ #include #include +#include #include #ifdef _DEBUG @@ -51,10 +53,12 @@ PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop) connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), this, SLOT(onOperationStopped(ModuleBase_Operation*))); if (!myWorkshop->isSalomeMode()) { - connect(myWorkshop->mainWindow()->viewer(), SIGNAL(mouseReleased(QPoint)), - this, SLOT(onMouseReleased(QPoint))); - connect(myWorkshop->mainWindow()->viewer(), SIGNAL(mouseMoved(QPoint)), - this, SLOT(onMouseMoved(QPoint))); + XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); + connect(aViewer, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); + connect(aViewer, SIGNAL(mouseRelease(XGUI_ViewWindow*, QMouseEvent*)), + this, SLOT(onMouseReleased(XGUI_ViewWindow*, QMouseEvent*))); + connect(aViewer, SIGNAL(mouseMove(XGUI_ViewWindow*, QMouseEvent*)), + this, SLOT(onMouseMoved(XGUI_ViewWindow*, QMouseEvent*))); } } @@ -135,8 +139,12 @@ void PartSet_Module::onOperationStarted() PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); if (aPreviewOp) { visualizePreview(true); - connect(aPreviewOp, SIGNAL(viewerProjectionChange(double, double, double)), - this, SLOT(onViewerProjectionChange(double, double, double))); + + PartSet_OperationSketch* aSketchOp = dynamic_cast(aPreviewOp); + if (aSketchOp) { + connect(aSketchOp, SIGNAL(planeSelected(double, double, double)), + this, SLOT(onPlaneSelected(double, double, double))); + } } } @@ -150,7 +158,7 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation) visualizePreview(false); } -void PartSet_Module::onMouseReleased(QPoint thePoint) +void PartSet_Module::onSelectionChanged() { ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); @@ -159,20 +167,34 @@ void PartSet_Module::onMouseReleased(QPoint thePoint) if (aSelector) { NCollection_List aList; aSelector->selectedShapes(aList); + aPreviewOp->setSelectedShapes(aList); + } + } +} + +void PartSet_Module::onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent) +{ + QPoint aPoint = theEvent->pos(); + ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); + PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); + if (aPreviewOp) { + XGUI_SelectionMgr* aSelector = myWorkshop->selector(); + if (aSelector) { XGUI_ViewWindow* aWindow = myWorkshop->mainWindow()->viewer()->activeViewWindow(); if (aWindow) { Handle(V3d_View) aView3d = aWindow->viewPort()->getView(); if ( !aView3d.IsNull() ) { - gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(thePoint, aView3d); - aPreviewOp->setSelectedShapes(aList, aPoint); + gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d); + aPreviewOp->mouseReleased(aPnt); } } } } } -void PartSet_Module::onMouseMoved(QPoint thePoint) +void PartSet_Module::onMouseMoved(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent) { + QPoint aPoint = theEvent->pos(); ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); if (aPreviewOp) { @@ -182,20 +204,21 @@ void PartSet_Module::onMouseMoved(QPoint thePoint) if (aWindow) { Handle(V3d_View) aView3d = aWindow->viewPort()->getView(); if ( !aView3d.IsNull() ) { - gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(thePoint, aView3d); - aPreviewOp->setMouseMovePoint(aPoint); + gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d); + aPreviewOp->mouseMoved(aPnt); } } } } } -void PartSet_Module::onViewerProjectionChange(double theX, double theY, double theZ) +void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ) { XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); if (aViewer) { aViewer->setViewProjection(theX, theY, theZ); } + myWorkshop->actionsMgr()->setNestedActionsEnabled(true); } void PartSet_Module::visualizePreview(bool isDisplay) diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index b71c7fb2e..ba120ea09 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -11,6 +11,8 @@ #include +class XGUI_ViewWindow; +class QMouseEvent; class PartSet_Listener; class PARTSET_EXPORT PartSet_Module: public QObject, public XGUI_Module @@ -40,19 +42,26 @@ public slots: /// SLOT, that is called after the operation is stopped. Disconnect the sketch feature /// from the viewer selection and show the sketch preview. void onOperationStopped(ModuleBase_Operation* theOperation); + /// SLOT, that is called by the selection in the viewer is changed. - /// The selection is sent to the current operation if it listen the selection. - void onMouseReleased(QPoint thePoint); + /// The selection is sent to the current operation if it listens selection. + void onSelectionChanged(); + /// SLOT, that is called by mouse click in the viewer. + /// The mouse released point is sent to the current operation to be processed. + /// \param theWindow the window where the signal appears + /// \param theEvent the mouse event + void onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent); /// SLOT, that is called by the selection in the viewer is changed. - /// The selection is sent to the current operation if it listen the selection. - /// \thePoint the mouse point - void onMouseMoved(QPoint thePoint); + /// The mouse moved point is sent to the current operation to be processed. + /// \param theWindow the window where the signal appears + /// \param theEvent the mouse event + void onMouseMoved(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent); /// SLOT, to apply to the current viewer the operation /// \param theX the X projection value /// \param theY the Y projection value /// \param theZ the Z projection value - void onViewerProjectionChange(double theX, double theY, double theZ); + void onPlaneSelected(double theX, double theY, double theZ); private: XGUI_Workshop* myWorkshop; diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index 48bd5f0e3..cc5fad46c 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -35,8 +35,7 @@ int PartSet_OperationSketch::getSelectionMode() const return TopAbs_FACE; } -void PartSet_OperationSketch::setSelectedShapes(const NCollection_List& theList, - const gp_Pnt& theSelectedPoint) +void PartSet_OperationSketch::setSelectedShapes(const NCollection_List& theList) { if (theList.IsEmpty()) return; @@ -76,7 +75,7 @@ void PartSet_OperationSketch::setSelectedShapes(const NCollection_ListsetValue(aC, anA, aB); boost::shared_ptr aDir = aPlane->direction(); - emit viewerProjectionChange(aDir->x(), aDir->y(), aDir->z()); + emit planeSelected(aDir->x(), aDir->y(), aDir->z()); //commit(); //SketchPlugin_Sketch::setActive(myFeature); diff --git a/src/PartSet/PartSet_OperationSketch.h b/src/PartSet/PartSet_OperationSketch.h index 021a8c8cd..5eb45b17e 100644 --- a/src/PartSet/PartSet_OperationSketch.h +++ b/src/PartSet/PartSet_OperationSketch.h @@ -32,8 +32,14 @@ public: /// Gives the current selected objects to be processed by the operation /// \param theList a list of interactive selected shapes /// \param theSelectedPoint a point clidked in the viewer - virtual void setSelectedShapes(const NCollection_List& theList, - const gp_Pnt& theSelectedPoint); + virtual void setSelectedShapes(const NCollection_List& theList); + +signals: + /// signal about the sketch plane is selected + /// \param theX the value in the X direction of the plane + /// \param theX the value in the Y direction value of the plane + /// \param theX the value in the Z direction of the plane + void planeSelected(double theX, double theY, double theZ); }; #endif diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h index 0e6c24263..bcc3f3aa1 100644 --- a/src/PartSet/PartSet_OperationSketchBase.h +++ b/src/PartSet/PartSet_OperationSketchBase.h @@ -41,15 +41,15 @@ public: /// Gives the current selected objects to be processed by the operation /// \param theList a list of interactive selected shapes - /// \param theSelectedPoint a 3D selected point - virtual void setSelectedShapes(const NCollection_List& theList, - const gp_Pnt& thePoint) = 0; - /// Gives the current mouse point in the viewer - /// \param thePoint a point clidked in the viewer - virtual void setMouseMovePoint(const gp_Pnt& thePoint) {}; - -signals: - void viewerProjectionChange(double theX, double theY, double theZ); + virtual void setSelectedShapes(const NCollection_List& theList) {}; + + /// Processes the mouse release in the point + /// \param thePoint a point clicked in the viewer + virtual void mouseReleased(const gp_Pnt& thePoint) {}; + + /// Processes the mouse move in the point + /// \param thePoint a 3D point clicked in the viewer + virtual void mouseMoved(const gp_Pnt& thePoint) {}; }; #endif diff --git a/src/PartSet/PartSet_OperationSketchLine.cpp b/src/PartSet/PartSet_OperationSketchLine.cpp index 57d5f7646..6da4b71f5 100644 --- a/src/PartSet/PartSet_OperationSketchLine.cpp +++ b/src/PartSet/PartSet_OperationSketchLine.cpp @@ -38,12 +38,8 @@ int PartSet_OperationSketchLine::getSelectionMode() const return 0;//TopAbs_FACE; } -void PartSet_OperationSketchLine::setSelectedShapes(const NCollection_List& theList, - const gp_Pnt& thePoint) +void PartSet_OperationSketchLine::mouseReleased(const gp_Pnt& thePoint) { - if (theList.IsEmpty()) - return; - switch (myPointSelectionMode) { case SM_FirstPoint: { @@ -65,7 +61,7 @@ void PartSet_OperationSketchLine::setSelectedShapes(const NCollection_List& theList, - const gp_Pnt& thePoint); + /// \param thePoint a point clicked in the viewer + virtual void mouseReleased(const gp_Pnt& thePoint); /// Gives the current mouse point in the viewer - /// \param thePoint a point clidked in the viewer - virtual void setMouseMovePoint(const gp_Pnt& thePoint); + /// \param thePoint a point clicked in the viewer + virtual void mouseMoved(const gp_Pnt& thePoint); protected: /// \brief Virtual method called when operation is started diff --git a/src/XGUI/XGUI_ActionsMgr.h b/src/XGUI/XGUI_ActionsMgr.h index d6c55d833..dd5ac36f7 100644 --- a/src/XGUI/XGUI_ActionsMgr.h +++ b/src/XGUI/XGUI_ActionsMgr.h @@ -5,6 +5,8 @@ #ifndef XGUI_ACTIONSMGR_H_ #define XGUI_ACTIONSMGR_H_ +#include "XGUI.h" + #include #include #include @@ -12,7 +14,7 @@ class XGUI_Command; class QAction; -class XGUI_ActionsMgr: public QObject +class XGUI_EXPORT XGUI_ActionsMgr: public QObject { Q_OBJECT diff --git a/src/XGUI/XGUI_Viewer.h b/src/XGUI/XGUI_Viewer.h index b422e4034..466951c7a 100644 --- a/src/XGUI/XGUI_Viewer.h +++ b/src/XGUI/XGUI_Viewer.h @@ -149,8 +149,6 @@ signals: void keyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent); void activated(XGUI_ViewWindow* theWindow); void selectionChanged(); - //void mouseReleased(QPoint thePoint); - //void mouseMoved(QPoint thePoint); public slots: void onWindowMinimized(QMdiSubWindow*); diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 3f857ff12..41ac3b144 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -59,6 +59,9 @@ public: //! ! Returns operation manager. XGUI_OperationMgr* operationMgr() const { return myOperationMgr; } + //! ! Returns an actions manager + XGUI_ActionsMgr* actionsMgr() const { return myActionsMgr; }; + //! Creates and adds a new workbench (menu group) with the given name and returns it XGUI_Workbench* addWorkbench(const QString& theName);