From: vsv Date: Wed, 30 Apr 2014 12:38:56 +0000 (+0400) Subject: Connect from SALOME to Sketcher (ref #31) X-Git-Tag: V_0.2~98 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c0a2da355dd7bbd190e6cb7c7852f34727a72624;p=modules%2Fshaper.git Connect from SALOME to Sketcher (ref #31) --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 5826a3493..13f3c8635 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -11,10 +11,10 @@ #include #include #include -#include #include #include #include +#include #include #include @@ -52,16 +52,15 @@ PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop) connect(anOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted())); connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), this, SLOT(onOperationStopped(ModuleBase_Operation*))); - if (!myWorkshop->isSalomeMode()) { - 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*))); - connect(aViewer, SIGNAL(keyRelease(XGUI_ViewWindow*, QKeyEvent*)), - this, SLOT(onKeyRelease(XGUI_ViewWindow*, QKeyEvent*))); - } + + connect(myWorkshop->selector(), SIGNAL(selectionChanged()), + this, SLOT(onSelectionChanged())); + connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)), + this, SLOT(onMouseReleased(QMouseEvent*))); + connect(myWorkshop->viewer(), SIGNAL(mouseMove(QMouseEvent*)), + this, SLOT(onMouseMoved(QMouseEvent*))); + connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)), + this, SLOT(onKeyRelease(QKeyEvent*))); } PartSet_Module::~PartSet_Module() @@ -177,7 +176,7 @@ void PartSet_Module::onSelectionChanged() } } -void PartSet_Module::onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent) +void PartSet_Module::onMouseReleased(QMouseEvent* theEvent) { QPoint aPoint = theEvent->pos(); ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); @@ -185,39 +184,30 @@ void PartSet_Module::onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* th 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 aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d); - aPreviewOp->mouseReleased(aPnt); - } + Handle(V3d_View) aView3d = myWorkshop->viewer()->activeView(); + if ( !aView3d.IsNull() ) { + gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d); + aPreviewOp->mouseReleased(aPnt); } } } } -void PartSet_Module::onMouseMoved(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent) +void PartSet_Module::onMouseMoved(QMouseEvent* theEvent) { QPoint aPoint = theEvent->pos(); ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); if (aPreviewOp) { - XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); - if (aViewer) { - XGUI_ViewWindow* aWindow = aViewer->activeViewWindow(); - if (aWindow) { - Handle(V3d_View) aView3d = aWindow->viewPort()->getView(); - if ( !aView3d.IsNull() ) { - gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d); - aPreviewOp->mouseMoved(aPnt); - } - } + Handle(V3d_View) aView3d = myWorkshop->viewer()->activeView(); + if ( !aView3d.IsNull() ) { + gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d); + aPreviewOp->mouseMoved(aPnt); } } } -void PartSet_Module::onKeyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent) +void PartSet_Module::onKeyRelease(QKeyEvent* theEvent) { ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); @@ -228,10 +218,7 @@ void PartSet_Module::onKeyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEven void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ) { - XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); - if (aViewer) { - aViewer->setViewProjection(theX, theY, theZ); - } + myWorkshop->viewer()->setViewProjection(theX, theY, theZ); ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); if (anOperation) { diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 7e8190eb1..a67b8d038 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -13,7 +13,6 @@ #include -class XGUI_ViewWindow; class QMouseEvent; class QKeyEvent; class PartSet_Listener; @@ -53,19 +52,16 @@ public slots: 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); + void onMouseReleased(QMouseEvent* theEvent); /// SLOT, that is called by the selection in the viewer is changed. /// 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); + void onMouseMoved(QMouseEvent* theEvent); /// SLOT, that is called by the key in the viewer is clicked. - /// \param theWindow the window where the signal appears /// \param theEvent the mouse event - void onKeyRelease(XGUI_ViewWindow*, QKeyEvent*); + void onKeyRelease(QKeyEvent*); /// SLOT, to apply to the current viewer the operation /// \param theX the X projection value diff --git a/src/XGUI/XGUI_Viewer.cpp b/src/XGUI/XGUI_Viewer.cpp index 20436bfbd..7e53ec0e7 100644 --- a/src/XGUI/XGUI_Viewer.cpp +++ b/src/XGUI/XGUI_Viewer.cpp @@ -247,17 +247,6 @@ 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 466951c7a..9222827f3 100644 --- a/src/XGUI/XGUI_Viewer.h +++ b/src/XGUI/XGUI_Viewer.h @@ -121,12 +121,6 @@ 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; diff --git a/src/XGUI/XGUI_ViewerProxy.cpp b/src/XGUI/XGUI_ViewerProxy.cpp index ff95ecff6..b39b1ce97 100644 --- a/src/XGUI/XGUI_ViewerProxy.cpp +++ b/src/XGUI/XGUI_ViewerProxy.cpp @@ -41,6 +41,17 @@ Handle(V3d_View) XGUI_ViewerProxy::activeView() const } } +void XGUI_ViewerProxy::setViewProjection(double theX, double theY, double theZ) +{ + Handle(V3d_View) aView3d = activeView(); + if ( !aView3d.IsNull() ) { + aView3d->SetProj(theX, theY, theZ); + aView3d->FitAll( 0.01, true, true ); + aView3d->SetZSize(0.); + } +} + + void XGUI_ViewerProxy::connectToViewer() { if (myWorkshop->isSalomeMode()) { @@ -57,18 +68,23 @@ void XGUI_ViewerProxy::connectToViewer() connect(aViewer, SIGNAL(activated()), this, SIGNAL(activated())); - connect(aViewer, SIGNAL(mousePress(QMouseEvent* theEvent)), - this, SIGNAL(mousePress(QMouseEvent* theEvent))); - connect(aViewer, SIGNAL(mouseRelease(QMouseEvent* theEvent)), - this, SIGNAL(mouseRelease(QMouseEvent* theEvent))); - connect(aViewer, SIGNAL(mouseDoubleClick(QMouseEvent* theEvent)), - this, SIGNAL(mouseDoubleClick(QMouseEvent* theEvent))); - connect(aViewer, SIGNAL(mouseMove(QMouseEvent* theEvent)), - this, SIGNAL(mouseMove(QMouseEvent* theEvent))); - connect(aViewer, SIGNAL(keyPress(QKeyEvent* theEvent)), - this, SIGNAL(keyPress(QKeyEvent* theEvent))); - connect(aViewer, SIGNAL(keyRelease(QKeyEvent* theEvent)), - this, SIGNAL(keyRelease(QKeyEvent* theEvent))); + connect(aViewer, SIGNAL(mousePress(QMouseEvent*)), + this, SIGNAL(mousePress(QMouseEvent*))); + + connect(aViewer, SIGNAL(mouseRelease(QMouseEvent*)), + this, SIGNAL(mouseRelease(QMouseEvent*))); + + connect(aViewer, SIGNAL(mouseDoubleClick(QMouseEvent*)), + this, SIGNAL(mouseDoubleClick(QMouseEvent*))); + + connect(aViewer, SIGNAL(mouseMove(QMouseEvent*)), + this, SIGNAL(mouseMove(QMouseEvent*))); + + connect(aViewer, SIGNAL(keyPress(QKeyEvent*)), + this, SIGNAL(keyPress(QKeyEvent*))); + + connect(aViewer, SIGNAL(keyRelease(QKeyEvent*)), + this, SIGNAL(keyRelease(QKeyEvent*))); } else { XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); diff --git a/src/XGUI/XGUI_ViewerProxy.h b/src/XGUI/XGUI_ViewerProxy.h index 7d26c4924..17d0bb8c4 100644 --- a/src/XGUI/XGUI_ViewerProxy.h +++ b/src/XGUI/XGUI_ViewerProxy.h @@ -13,7 +13,7 @@ class XGUI_ViewWindow; * It is reccomennded to use this class in operation for accessing to viewer * functionality instead of direct access to a viewer */ -class XGUI_ViewerProxy: public XGUI_SalomeViewer +class XGUI_EXPORT XGUI_ViewerProxy: public XGUI_SalomeViewer { Q_OBJECT public: @@ -28,6 +28,13 @@ public: //! Returns Vsd_View object from currently active view window virtual Handle(V3d_View) activeView() const; + //! 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); + + /// Connects to a viewer according to current environment void connectToViewer(); private slots: