From cb1cfc2d4b48a0d1ce37362c90f520fe0ead6ddd Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 24 Apr 2014 18:37:12 +0400 Subject: [PATCH] refs #30 - Sketch base GUI: create, draw lines Set plane for sketch and erase the sketch preview. Set view projection. --- src/PartSet/PartSet_Module.cpp | 13 ++++++++++++- src/PartSet/PartSet_Module.h | 5 +++++ src/PartSet/PartSet_OperationSketch.cpp | 3 ++- src/PartSet/PartSet_OperationSketchBase.h | 3 +++ src/XGUI/XGUI_Viewer.cpp | 11 +++++++++++ src/XGUI/XGUI_Viewer.h | 6 ++++++ 6 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index f1787442a..71d0987a4 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -98,8 +98,11 @@ void PartSet_Module::onOperationStarted() ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); - if (aPreviewOp) + if (aPreviewOp) { visualizePreview(true); + connect(aPreviewOp, SIGNAL(viewerProjectionChange(double, double, double)), + this, SLOT(onViewerProjectionChange(double, double, double))); + } } void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation) @@ -126,6 +129,14 @@ void PartSet_Module::onViewSelectionChanged() } } +void PartSet_Module::onViewerProjectionChange(double theX, double theY, double theZ) +{ + XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); + if (aViewer) { + aViewer->setViewProjection(theX, theY, theZ); + } +} + void PartSet_Module::visualizePreview(bool isDisplay) { ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index fcf98a0c3..c7d8e8d3b 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -34,6 +34,11 @@ public slots: /// 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 onViewSelectionChanged(); + /// 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); private: /// Displays or erase the current operation preview, if it has it. diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index 1f1f1e91c..8ce3b7958 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -63,7 +63,8 @@ void PartSet_OperationSketch::setSelectedShapes(const NCollection_Listreal(SKETCH_ATTR_PLANE_C)->setValue(aC); aData->real(SKETCH_ATTR_PLANE_D)->setValue(aD); - //emit viewPlaneChanged(); + boost::shared_ptr aDir = aPlane->direction(); + emit viewerProjectionChange(aDir->x(), aDir->y(), aDir->z()); commit(); } diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h index 72a635bb1..7ca7fd2d3 100644 --- a/src/PartSet/PartSet_OperationSketchBase.h +++ b/src/PartSet/PartSet_OperationSketchBase.h @@ -39,6 +39,9 @@ public: /// Gives the current selected objects to be processed by the operation /// \param a list of interactive selected objects virtual void setSelectedShapes(const NCollection_List& theList) = 0; + +signals: + void viewerProjectionChange(double theX, double theY, double theZ); }; #endif diff --git a/src/XGUI/XGUI_Viewer.cpp b/src/XGUI/XGUI_Viewer.cpp index a09722bcd..dd50e3e11 100644 --- a/src/XGUI/XGUI_Viewer.cpp +++ b/src/XGUI/XGUI_Viewer.cpp @@ -283,6 +283,17 @@ void XGUI_Viewer::getHotButton(XGUI::InteractionStyle theInteractionStyle, theButton = myButtonMap[theInteractionStyle][theOper]; } +void XGUI_Viewer::setViewProjection(double theX, double theY, double theZ) +{ + XGUI_ViewWindow* aWindow = dynamic_cast(myActiveView->widget()); + if (aWindow) { + Handle(V3d_View) aView3d = aWindow->viewPort()->getView(); + if ( !aView3d.IsNull() ) + aView3d->SetProj(theX, theY, theZ); + aWindow->viewPort()->fitAll(); + } +} + /*! Changes visibility of trihedron to opposite */ diff --git a/src/XGUI/XGUI_Viewer.h b/src/XGUI/XGUI_Viewer.h index c7a2492f1..27df6840d 100644 --- a/src/XGUI/XGUI_Viewer.h +++ b/src/XGUI/XGUI_Viewer.h @@ -119,6 +119,12 @@ public: static void getHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper, Qt::KeyboardModifiers& theState, Qt::MouseButtons& theButton); + //! Sets the view projection + /// \param theX the X projection value + /// \param theY the Y projection value + /// \param theZ the Z projection value + void setViewProjection(double theX, double theY, double theZ); + typedef QMap StatesMap; typedef QMap ButtonsMap; -- 2.39.2