From d2807fce5b2f43da4489f72b339f3d2b8007ef73 Mon Sep 17 00:00:00 2001 From: mzn Date: Fri, 10 Feb 2006 13:22:34 +0000 Subject: [PATCH] Fix for remark on PAL10982 ( "Relative size" check-button behavior: trihedron is not depended on this preference ). --- src/LightApp/LightApp_Application.cxx | 6 ++++-- src/SVTK/SVTK_MainWindow.cxx | 4 ++-- src/SVTK/SVTK_MainWindow.h | 2 +- src/SVTK/SVTK_Renderer.cxx | 23 ++++++++++++++++++----- src/SVTK/SVTK_Renderer.h | 9 +++++++-- src/SVTK/SVTK_ViewModel.cxx | 13 ++++++++++--- src/SVTK/SVTK_ViewModel.h | 6 +++++- src/SVTK/SVTK_ViewWindow.cxx | 4 ++-- src/SVTK/SVTK_ViewWindow.h | 2 +- 9 files changed, 50 insertions(+), 19 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index ca93892ff..0ebc91d89 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1108,7 +1108,8 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType if( vm ) { vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) ); - vm->setTrihedronSize( resMgr->integerValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ) ); + vm->setTrihedronSize( resMgr->integerValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ), + resMgr->booleanValue( "VTKViewer", "relative_size", vm->trihedronRelative() ) ); new LightApp_VTKSelector( vm, mySelMgr ); } } @@ -1641,6 +1642,7 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString if ( sec == QString( "VTKViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )) ) { int sz = resMgr->integerValue( "VTKViewer", "trihedron_size", -1 ); + bool isRelative = resMgr->booleanValue( "VTKViewer", "relative_size", true ); QPtrList lst; viewManagers( SVTK_Viewer::Type(), lst ); for ( QPtrListIterator it( lst ); it.current() && sz >= 0; ++it ) @@ -1652,7 +1654,7 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString SVTK_Viewer* vtkVM = dynamic_cast( vm ); if( vtkVM ) { - vtkVM->setTrihedronSize( sz ); + vtkVM->setTrihedronSize( sz, isRelative ); vtkVM->Repaint(); } } diff --git a/src/SVTK/SVTK_MainWindow.cxx b/src/SVTK/SVTK_MainWindow.cxx index ad01609bc..145aa9aa5 100644 --- a/src/SVTK/SVTK_MainWindow.cxx +++ b/src/SVTK/SVTK_MainWindow.cxx @@ -265,9 +265,9 @@ SVTK_MainWindow //---------------------------------------------------------------------------- void SVTK_MainWindow -::SetTrihedronSize( const int theSize ) +::SetTrihedronSize( const int theSize, const bool theRelative ) { - GetRenderer()->SetTrihedronSize(theSize); + GetRenderer()->SetTrihedronSize(theSize, theRelative); Repaint(); } diff --git a/src/SVTK/SVTK_MainWindow.h b/src/SVTK/SVTK_MainWindow.h index 758093797..45f525f28 100644 --- a/src/SVTK/SVTK_MainWindow.h +++ b/src/SVTK/SVTK_MainWindow.h @@ -150,7 +150,7 @@ public: //! Redirect the request to #SVTK_Renderer::SetTrihedronSize void - SetTrihedronSize(const int theSize); + SetTrihedronSize(const int theSize, const bool theRelative = true); //! Redirect the request to #SVTK_Renderer::AdjustActors void diff --git a/src/SVTK/SVTK_Renderer.cxx b/src/SVTK/SVTK_Renderer.cxx index cad43a139..8302903a3 100644 --- a/src/SVTK/SVTK_Renderer.cxx +++ b/src/SVTK/SVTK_Renderer.cxx @@ -74,7 +74,8 @@ SVTK_Renderer myTransform(VTKViewer_Transform::New()), myCubeAxes(SVTK_CubeAxesActor2D::New()), myTrihedron(SVTK_Trihedron::New()), - myTrihedronSize(105) + myTrihedronSize(105), + myIsTrihedronRelative(true) { myDevice->Delete(); myTransform->Delete(); @@ -363,8 +364,13 @@ SVTK_Renderer // if the new trihedron size have sufficient difference, then apply the value double aSize = myTrihedron->GetSize(); - ComputeTrihedronSize(GetDevice(),aSize,aSize,myTrihedronSize); - myTrihedron->SetSize(aSize); + if ( IsTrihedronRelative() ) + { + ComputeTrihedronSize(GetDevice(),aSize,aSize,myTrihedronSize); + myTrihedron->SetSize(aSize); + } + else + myTrihedron->SetSize( myTrihedronSize ); // iterate through displayed objects and set size if necessary vtkActorCollection* anActors = GetDevice()->GetActors(); @@ -418,10 +424,11 @@ SVTK_Renderer void SVTK_Renderer -::SetTrihedronSize(int theSize) +::SetTrihedronSize(int theSize, const bool theRelative) { - if(myTrihedronSize != theSize){ + if(myTrihedronSize != theSize || myIsTrihedronRelative != theRelative){ myTrihedronSize = theSize; + myIsTrihedronRelative = theRelative; AdjustActors(); } } @@ -433,6 +440,12 @@ SVTK_Renderer return myTrihedronSize; } +bool +SVTK_Renderer +::IsTrihedronRelative() const +{ + return myIsTrihedronRelative; +} //---------------------------------------------------------------------------- VTKViewer_Trihedron* diff --git a/src/SVTK/SVTK_Renderer.h b/src/SVTK/SVTK_Renderer.h index 5f486543c..5532ea852 100644 --- a/src/SVTK/SVTK_Renderer.h +++ b/src/SVTK/SVTK_Renderer.h @@ -127,12 +127,16 @@ class SVTK_EXPORT SVTK_Renderer : public vtkObject //! Set size of the trihedron in percents from bounding box of the scene void - SetTrihedronSize(int theSize); + SetTrihedronSize(int theSize, const bool theRelative = true); //! Get size of the trihedron in percents from bounding box of the scene int GetTrihedronSize() const; + //! Shows if the size of the trihedron is relative + bool + IsTrihedronRelative() const; + //---------------------------------------------------------------------------- //! Get trihedron control VTKViewer_Trihedron* @@ -238,7 +242,8 @@ class SVTK_EXPORT SVTK_Renderer : public vtkObject //---------------------------------------------------------------------------- vtkSmartPointer myCubeAxes; vtkSmartPointer myTrihedron; - int myTrihedronSize; + int myTrihedronSize; + bool myIsTrihedronRelative; float myBndBox[6]; }; diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index 08c2169d5..df8ae1474 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -63,6 +63,7 @@ SVTK_Viewer::SVTK_Viewer() { myTrihedronSize = 105; + myTrihedronRelative = true; } //========================================================== @@ -105,7 +106,7 @@ createView( SUIT_Desktop* theDesktop ) aViewWindow->Initialize(this); aViewWindow->setBackgroundColor( backgroundColor() ); - aViewWindow->SetTrihedronSize( trihedronSize() ); + aViewWindow->SetTrihedronSize( trihedronSize(), trihedronRelative() ); return aViewWindow; } @@ -115,9 +116,15 @@ int SVTK_Viewer::trihedronSize() const return myTrihedronSize; } -void SVTK_Viewer::setTrihedronSize( const int sz ) +bool SVTK_Viewer::trihedronRelative() const +{ + return myTrihedronRelative; +} + +void SVTK_Viewer::setTrihedronSize( const int sz, const bool relative ) { myTrihedronSize = sz; + myTrihedronRelative = relative; SUIT_ViewManager* vm = getViewManager(); if ( !vm ) @@ -131,7 +138,7 @@ void SVTK_Viewer::setTrihedronSize( const int sz ) continue; SVTK_ViewWindow* vw = (SVTK_ViewWindow*)win; - vw->SetTrihedronSize( sz ); + vw->SetTrihedronSize( sz, relative ); } } diff --git a/src/SVTK/SVTK_ViewModel.h b/src/SVTK/SVTK_ViewModel.h index 5875d465e..21ca80007 100644 --- a/src/SVTK/SVTK_ViewModel.h +++ b/src/SVTK/SVTK_ViewModel.h @@ -65,8 +65,11 @@ public: //! Get size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize) int trihedronSize() const; + //! Shows if the size of trihedron relative (see #SVTK_Renderer::SetTrihedronSize) + bool trihedronRelative() const; + //! Set size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize) - void setTrihedronSize( const int ); + void setTrihedronSize( const int, const bool = true ); public: void enableSelection(bool isEnabled); @@ -115,6 +118,7 @@ protected slots: private: QColor myBgColor; int myTrihedronSize; + bool myTrihedronRelative; bool mySelectionEnabled; bool myMultiSelectionEnabled; }; diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index b95a23d20..2e536541b 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -432,9 +432,9 @@ SVTK_ViewWindow void SVTK_ViewWindow -::SetTrihedronSize(const int theSize) +::SetTrihedronSize(const int theSize, const bool theRelative) { - myMainWindow->SetTrihedronSize(theSize); + myMainWindow->SetTrihedronSize(theSize, theRelative); } /*! If parameter theIsForcedUpdate is true, recalculate parameters for diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index 1fc559c78..1eb88a773 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -219,7 +219,7 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow //! Redirect the request to #SVTK_Renderer::SetTrihedronSize virtual void - SetTrihedronSize( const int ); + SetTrihedronSize( const int, const bool = true ); //! Redirect the request to #SVTK_Renderer::SetSelectionProp virtual -- 2.39.2