From 140c2aaa27106b8d4e2e6e3bb135f0069d36ff04 Mon Sep 17 00:00:00 2001 From: enk Date: Thu, 19 May 2005 12:27:47 +0000 Subject: [PATCH] added some culculation for Trihedron and CubeAxes from InteractorStyleSALOME. --- src/VTKViewer/VTKViewer_ViewFrame.cxx | 51 ++++++++++++++++++++++----- src/VTKViewer/VTKViewer_ViewFrame.h | 6 ++++ 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/VTKViewer/VTKViewer_ViewFrame.cxx b/src/VTKViewer/VTKViewer_ViewFrame.cxx index e15e8a590..2bac8e16a 100644 --- a/src/VTKViewer/VTKViewer_ViewFrame.cxx +++ b/src/VTKViewer/VTKViewer_ViewFrame.cxx @@ -128,8 +128,6 @@ void VTKViewer_ViewFrame::InitialSetup() { m_RWInteractor->Initialize(); m_RWInteractor->setViewFrame(this); - RWS->setTriedron(m_Triedron); - RWS->setCubeAxes(m_CubeAxes); RWS->setViewFrame(this); //SRN: additional initialization, to init CurrentRenderer of vtkInteractorStyle @@ -152,6 +150,7 @@ void VTKViewer_ViewFrame::InitialSetup() { m_CubeAxes->SetAxisLabelTextProperty(tprop); m_CubeAxes->SetCornerOffset(0.0); m_CubeAxes->SetScaling(0); + m_CubeAxes->SetNumberOfLabels(10); tprop->Delete(); setCentralWidget( m_RW ); @@ -238,7 +237,7 @@ double VTKViewer_ViewFrame::GetTrihedronSize() const void VTKViewer_ViewFrame::AdjustTrihedrons( const bool forcedUpdate ) { - if ( !isTrihedronDisplayed() && !forcedUpdate ) + if ( !isCubeAxesDisplayed() && !isTrihedronDisplayed() && !forcedUpdate ) return; float bnd[ 6 ]; @@ -308,11 +307,21 @@ void VTKViewer_ViewFrame::AdjustTrihedrons( const bool forcedUpdate ) ::ResetCameraClippingRange(m_Renderer); } +void VTKViewer_ViewFrame::AdjustAxes( const bool forcedUpdate ) +{ + AdjustTrihedrons(forcedUpdate); +} + void VTKViewer_ViewFrame::onAdjustTrihedron() { AdjustTrihedrons( false ); } +void VTKViewer_ViewFrame::onAdjustAxes() +{ + AdjustAxes( false ); +} + /*! Display/hide Trihedron */ @@ -399,7 +408,33 @@ void VTKViewer_ViewFrame::onViewFront(){ Fits all objects in the active view */ void VTKViewer_ViewFrame::onViewFitAll(){ - m_RWInteractor->GetInteractorStyleSALOME()->ViewFitAll(); + + int aTriedronWasVisible = false; + int aCubeAxesWasVisible = false; + if(m_Triedron){ + aTriedronWasVisible = m_Triedron->GetVisibility() == VTKViewer_Trihedron::eOn; + if(aTriedronWasVisible) m_Triedron->VisibilityOff(); + } + if(m_CubeAxes){ + aCubeAxesWasVisible = m_CubeAxes->GetVisibility(); + if(aCubeAxesWasVisible) m_CubeAxes->VisibilityOff(); + } + + if(m_Triedron->GetVisibleActorCount(m_Renderer)){ + m_Triedron->VisibilityOff(); + m_CubeAxes->VisibilityOff(); + ::ResetCamera(m_Renderer); + }else{ + m_Triedron->SetVisibility(VTKViewer_Trihedron::eOnlyLineOn); + m_CubeAxes->SetVisibility(2); + ::ResetCamera(m_Renderer,true); + } + if(aTriedronWasVisible) m_Triedron->VisibilityOn(); + else m_Triedron->VisibilityOff(); + if(aCubeAxesWasVisible) m_CubeAxes->VisibilityOn(); + else m_CubeAxes->VisibilityOff(); + ::ResetCameraClippingRange(m_Renderer); + Repaint(); } @@ -689,9 +724,9 @@ void VTKViewer_ViewFrame::EraseAll() } -void VTKViewer_ViewFrame::Repaint(bool theUpdateTrihedron) +void VTKViewer_ViewFrame::Repaint(bool theUpdateAxes) { - if (theUpdateTrihedron) onAdjustTrihedron(); + if (theUpdateAxes) onAdjustAxes(); m_RW->update(); } @@ -900,8 +935,8 @@ void VTKViewer_ViewFrame::redisplayAll( QAD_Study* theQADStudy, const bool theTo if ( aComponent->_is_nil() ) return; - bool isTrhDisplayed = isTrihedronDisplayed(); - bool isCubeDisplayed = isCubeAxesDisplayed(); +// bool isTrhDisplayed = isTrihedronDisplayed(); +// bool isCubeDisplayed = isCubeAxesDisplayed(); m_RWInteractor->RemoveAll( false ); //m_RWInteractor->EraseAll(); diff --git a/src/VTKViewer/VTKViewer_ViewFrame.h b/src/VTKViewer/VTKViewer_ViewFrame.h index ca3817774..6efcf6a5b 100644 --- a/src/VTKViewer/VTKViewer_ViewFrame.h +++ b/src/VTKViewer/VTKViewer_ViewFrame.h @@ -109,9 +109,14 @@ public: void RemoveActor(SALOME_Actor*, bool update = false); void AdjustTrihedrons( const bool forced ); + void AdjustAxes( const bool forced ); + bool ComputeTrihedronSize( double& theNewSize, double& theOldSize ); double GetTrihedronSize() const; + + VTKViewer_Trihedron* GetTrihedron() {return this->m_Triedron;}; + SALOME_CubeAxesActor2D* GetCubeAxes() {return this->m_CubeAxes;}; public slots: void onViewPan(); @@ -129,6 +134,7 @@ public slots: void onViewTop(); void onViewTrihedron(); void onAdjustTrihedron(); + void onAdjustAxes(); void onPanLeft(); void onPanRight(); -- 2.39.2