From 9a82598002bc3e609ec33dc294b00b3ff7fe3be9 Mon Sep 17 00:00:00 2001 From: vsr Date: Sun, 9 Oct 2011 17:20:19 +0000 Subject: [PATCH] 0021319: EDF 1616 ALL: synchronization of 3D viewers Additional modification for SetScale() function --- src/OCCViewer/OCCViewer_AxialScaleDlg.cxx | 4 ++-- src/OCCViewer/OCCViewer_ViewPort3d.cxx | 23 ++++++++++++++++++ src/OCCViewer/OCCViewer_ViewPort3d.h | 29 +++++++++++++---------- src/OCCViewer/OCCViewer_ViewWindow.h | 2 ++ 4 files changed, 43 insertions(+), 15 deletions(-) diff --git a/src/OCCViewer/OCCViewer_AxialScaleDlg.cxx b/src/OCCViewer/OCCViewer_AxialScaleDlg.cxx index cbe928988..fcb674f40 100644 --- a/src/OCCViewer/OCCViewer_AxialScaleDlg.cxx +++ b/src/OCCViewer/OCCViewer_AxialScaleDlg.cxx @@ -141,7 +141,7 @@ void OCCViewer_AxialScaleDlg::Update() { // Get values from the OCC view double aScaleFactor[3]; - myView->getViewPort()->getView()->AxialScale( aScaleFactor[0], aScaleFactor[1], aScaleFactor[2] ); + myView->getViewPort()->getAxialScale( aScaleFactor[0], aScaleFactor[1], aScaleFactor[2] ); m_sbXcoeff->setValue( aScaleFactor[0] ); m_sbYcoeff->setValue( aScaleFactor[1] ); m_sbZcoeff->setValue( aScaleFactor[2] ); @@ -162,7 +162,7 @@ void OCCViewer_AxialScaleDlg::accept() bool OCCViewer_AxialScaleDlg::apply() { double aScaleFactor[3] = { m_sbXcoeff->value(), m_sbYcoeff->value(), m_sbZcoeff->value() }; - myView->getViewPort()->getView()->SetAxialScale( aScaleFactor[0], aScaleFactor[1], aScaleFactor[2] ); + myView->getViewPort()->setAxialScale( aScaleFactor[0], aScaleFactor[1], aScaleFactor[2] ); return true; } diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index 88fd810a6..ebaeedcae 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -258,6 +258,17 @@ void OCCViewer_ViewPort3d::setZSize( double zsize ) myPerspView->SetZSize( zsize );*/ } +/*! + Get axial scale to the view +*/ +void OCCViewer_ViewPort3d::getAxialScale( double& xScale, double& yScale, double& zScale ) +{ + xScale = yScale = zScale = 1.; + + if ( !activeView().IsNull() ) + activeView()->AxialScale( xScale, yScale, zScale ); +} + /*! Returns the background color [ virtual public ] */ @@ -572,6 +583,18 @@ void OCCViewer_ViewPort3d::rotateXY( double degrees ) emit vpTransformed( this ); } +/*! + Set axial scale to the view +*/ +void OCCViewer_ViewPort3d::setAxialScale( double xScale, double yScale, double zScale ) +{ + if ( activeView().IsNull() ) + return; + + activeView()->SetAxialScale( xScale, yScale, zScale ); + emit vpTransformed( this ); +} + /*! Passed the handle of native window of the component to CASCADE view. [ private ] */ diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.h b/src/OCCViewer/OCCViewer_ViewPort3d.h index 92261f9b6..57ee49508 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.h +++ b/src/OCCViewer/OCCViewer_ViewPort3d.h @@ -48,11 +48,11 @@ public: virtual ~OCCViewer_ViewPort3d(); public: - Handle(V3d_View) getView() const; - Handle(V3d_View) setView( const Handle(V3d_View)& ); - Handle(V3d_Viewer) getViewer() const; + Handle(V3d_View) getView() const; + Handle(V3d_View) setView( const Handle(V3d_View)& ); + Handle(V3d_Viewer) getViewer() const; - void setAnimationMode(bool theDegenerated); + void setAnimationMode(bool theDegenerated); virtual void setBackgroundColor( const QColor& color); virtual QColor backgroundColor() const; @@ -63,12 +63,14 @@ public: virtual void updateStaticTriedronVisibility(); // void setActive( V3d_TypeOfView ); - virtual bool syncronize( const OCCViewer_ViewPort3d* ); + virtual bool syncronize( const OCCViewer_ViewPort3d* ); - double getZSize() const; - void setZSize( double ); + double getZSize() const; + void setZSize( double ); - virtual void onUpdate(); + void getAxialScale( double&, double&, double& ); + + virtual void onUpdate(); // TRANSFORMATIONS virtual void reset(); @@ -79,6 +81,7 @@ public: virtual void zoom( int, int, int, int ); virtual void fitAll( bool keepScale = false, bool withZ = true, bool upd = true ); virtual void rotateXY( double ); + virtual void setAxialScale( double, double, double ); virtual void startRotation( int, int, int, const gp_Pnt& ); virtual void rotate( int, int, int, const gp_Pnt& ); @@ -100,11 +103,11 @@ protected: virtual void attachWindow( const Handle(V3d_View)&, const Handle(Aspect_Window)& ); private: - Handle(V3d_View) activeView() const; - Handle(V3d_View) inactiveView() const; - bool mapView( const Handle(V3d_View)& ); - bool setWindow( const Handle(V3d_View)& ); - bool mapped( const Handle(V3d_View)& ) const; + Handle(V3d_View) activeView() const; + Handle(V3d_View) inactiveView() const; + bool mapView( const Handle(V3d_View)& ); + bool setWindow( const Handle(V3d_View)& ); + bool mapped( const Handle(V3d_View)& ) const; private: Handle(V3d_View) myOrthoView; diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index 9717f60ec..bb91bc1e1 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -313,6 +313,8 @@ protected: private slots: void onSynchronizeView(bool); void updateSyncViews(); + +private: static void synchronizeView( OCCViewer_ViewWindow*, int ); private: -- 2.39.2