From f6983bbb20107bac8e14360131ae763990d382f7 Mon Sep 17 00:00:00 2001 From: asl Date: Wed, 2 Sep 2015 12:19:10 +0300 Subject: [PATCH] refs #821: correct orientation of the viewer after the plane selection --- src/ModuleBase/ModuleBase_IViewer.h | 4 +++- src/NewGeom/NewGeom_SalomeViewer.cpp | 3 ++- src/NewGeom/NewGeom_SalomeViewer.h | 4 +++- src/PartSet/PartSet_WidgetSketchLabel.cpp | 3 ++- src/XGUI/XGUI_ViewerProxy.cpp | 3 ++- src/XGUI/XGUI_ViewerProxy.h | 4 +++- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/ModuleBase/ModuleBase_IViewer.h b/src/ModuleBase/ModuleBase_IViewer.h index b4c37edd5..a82b5d24a 100644 --- a/src/ModuleBase/ModuleBase_IViewer.h +++ b/src/ModuleBase/ModuleBase_IViewer.h @@ -57,7 +57,9 @@ Q_OBJECT /// \param theX the X projection value /// \param theY the Y projection value /// \param theZ the Z projection value - virtual void setViewProjection(double theX, double theY, double theZ) = 0; + /// \param theTwist the twist angle in radians + virtual void setViewProjection( double theX, double theY, double theZ, + double theTwist ) = 0; /// Add selection filter to the viewer /// \param theFilter a selection filter diff --git a/src/NewGeom/NewGeom_SalomeViewer.cpp b/src/NewGeom/NewGeom_SalomeViewer.cpp index 3f5a801b5..a9d0c382d 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.cpp +++ b/src/NewGeom/NewGeom_SalomeViewer.cpp @@ -286,7 +286,7 @@ void NewGeom_SalomeViewer::fitAll() } //********************************************** -void NewGeom_SalomeViewer::setViewProjection(double theX, double theY, double theZ) +void NewGeom_SalomeViewer::setViewProjection(double theX, double theY, double theZ, double theTwist) { if (!mySelector) return; @@ -297,6 +297,7 @@ void NewGeom_SalomeViewer::setViewProjection(double theX, double theY, double th Handle(V3d_View) aView3d = aVFrame->getViewPort()->getView(); if (!aView3d.IsNull()) { aView3d->SetProj(theX, theY, theZ); + aView3d->SetTwist( theTwist ); aView3d->FitAll(0.01, true); aView3d->SetZSize(0.); } diff --git a/src/NewGeom/NewGeom_SalomeViewer.h b/src/NewGeom/NewGeom_SalomeViewer.h index 56ba4f824..0635c8989 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.h +++ b/src/NewGeom/NewGeom_SalomeViewer.h @@ -98,7 +98,9 @@ Q_OBJECT /// \param theX the X projection value /// \param theY the Y projection value /// \param theZ the Z projection value - virtual void setViewProjection(double theX, double theY, double theZ); + /// \param theTwist the twist angle in radians + virtual void setViewProjection( double theX, double theY, double theZ, + double theTwist ); /// Set selector /// \param theSel a selector instance diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index e7f7e0d1c..f3d4179c3 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -152,6 +152,7 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs std::shared_ptr aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape); std::shared_ptr aDir = aPlane->direction(); gp_XYZ aXYZ = aDir->impl().XYZ(); + double aTwist = 0.0; // orienting projection if(aBaseShape.get() != NULL) { @@ -168,7 +169,7 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs } } - myWorkshop->viewer()->setViewProjection(aXYZ.X(), aXYZ.Y(), aXYZ.Z()); + myWorkshop->viewer()->setViewProjection(aXYZ.X(), aXYZ.Y(), aXYZ.Z(), aTwist); } // 3. Clear text in the label myLabel->setText(""); diff --git a/src/XGUI/XGUI_ViewerProxy.cpp b/src/XGUI/XGUI_ViewerProxy.cpp index e19cb39b0..345efbe07 100644 --- a/src/XGUI/XGUI_ViewerProxy.cpp +++ b/src/XGUI/XGUI_ViewerProxy.cpp @@ -47,11 +47,12 @@ Handle(V3d_View) XGUI_ViewerProxy::activeView() const } } -void XGUI_ViewerProxy::setViewProjection(double theX, double theY, double theZ) +void XGUI_ViewerProxy::setViewProjection(double theX, double theY, double theZ, double theTwist) { Handle(V3d_View) aView3d = activeView(); if (!aView3d.IsNull()) { aView3d->SetProj(theX, theY, theZ); + aView3d->SetTwist( theTwist ); aView3d->FitAll(0.01, true); aView3d->SetZSize(0.); } diff --git a/src/XGUI/XGUI_ViewerProxy.h b/src/XGUI/XGUI_ViewerProxy.h index 5e8f75a63..64bc12fb8 100644 --- a/src/XGUI/XGUI_ViewerProxy.h +++ b/src/XGUI/XGUI_ViewerProxy.h @@ -48,7 +48,9 @@ Q_OBJECT /// \param theX the X projection value /// \param theY the Y projection value /// \param theZ the Z projection value - virtual void setViewProjection(double theX, double theY, double theZ); + /// \param theTwist the twist angle in radians + virtual void setViewProjection( double theX, double theY, double theZ, + double theTwist ); //! Sets the view fitted all virtual void fitAll(); -- 2.39.2