From 900849174970e4156b24aa630b48e6e2ff8b88f6 Mon Sep 17 00:00:00 2001 From: apo Date: Tue, 23 Aug 2005 09:06:35 +0000 Subject: [PATCH] Minor changes --- src/SVTK/SVTK_RenderWindow.cxx | 23 +++++++++- src/SVTK/SVTK_RenderWindow.h | 7 ++- src/SVTK/SVTK_RenderWindowInteractor.cxx | 15 ++++--- src/SVTK/SVTK_RenderWindowInteractor.h | 6 +-- src/SVTK/SVTK_View.cxx | 56 +++--------------------- src/SVTK/SVTK_View.h | 30 +++++-------- src/SVTK/SVTK_ViewWindow.cxx | 4 +- src/SVTK/SVTK_ViewWindow.h | 7 +-- 8 files changed, 63 insertions(+), 85 deletions(-) diff --git a/src/SVTK/SVTK_RenderWindow.cxx b/src/SVTK/SVTK_RenderWindow.cxx index 470893fdf..3cbce7af9 100644 --- a/src/SVTK/SVTK_RenderWindow.cxx +++ b/src/SVTK/SVTK_RenderWindow.cxx @@ -270,6 +270,7 @@ SVTK_RenderWindow int(aBackgroundColor[2]*255)); } + //---------------------------------------------------------------------------- void SVTK_RenderWindow @@ -278,7 +279,6 @@ SVTK_RenderWindow myRenderer->GetScale( theScale ); } -//---------------------------------------------------------------------------- void SVTK_RenderWindow ::SetScale( double theScale[3] ) @@ -287,6 +287,27 @@ SVTK_RenderWindow Repaint(); } + +//---------------------------------------------------------------------------- +void +SVTK_RenderWindow +::AddActor(VTKViewer_Actor* theActor, bool theIsUpdate) +{ + myRenderer->AddActor(theActor); + if(theIsUpdate) + Repaint(); +} + +//---------------------------------------------------------------------------- +void +SVTK_RenderWindow +::RemoveActor(VTKViewer_Actor* theActor, bool theIsUpdate) +{ + myRenderer->RemoveActor(theActor); + if(theIsUpdate) + Repaint(); +} + //---------------------------------------------------------------------------- bool SVTK_RenderWindow diff --git a/src/SVTK/SVTK_RenderWindow.h b/src/SVTK/SVTK_RenderWindow.h index 9419100b9..020f2fceb 100644 --- a/src/SVTK/SVTK_RenderWindow.h +++ b/src/SVTK/SVTK_RenderWindow.h @@ -38,6 +38,8 @@ class VTKViewer_Trihedron; class VTKViewer_Transform; +class VTKViewer_Actor; + class SVTK_CubeAxesActor2D; class SVTK_Renderer; @@ -48,7 +50,7 @@ class vtkRenderWindow; class SVTK_EXPORT SVTK_RenderWindow : public QMainWindow { - Q_OBJECT + Q_OBJECT; public: SVTK_RenderWindow( QWidget*, const char* ); @@ -79,6 +81,9 @@ class SVTK_EXPORT SVTK_RenderWindow : public QMainWindow void SetScale( double theScale[3] ); void GetScale( double theScale[3] ); + void AddActor(VTKViewer_Actor* theActor, bool theIsUpdate = false); + void RemoveActor(VTKViewer_Actor* theActor, bool theIsUpdate = false); + public slots: virtual void activateZoom(); virtual void activateWindowFit(); diff --git a/src/SVTK/SVTK_RenderWindowInteractor.cxx b/src/SVTK/SVTK_RenderWindowInteractor.cxx index 30df08353..af266f130 100644 --- a/src/SVTK/SVTK_RenderWindowInteractor.cxx +++ b/src/SVTK/SVTK_RenderWindowInteractor.cxx @@ -126,10 +126,10 @@ QtRenderWindowInteractor //---------------------------------------------------------------------------- SVTK_RenderWindowInteractor ::SVTK_RenderWindowInteractor( QWidget* parent, const char* name ) : - SVTK_RenderWindow( parent, name ) + SVTK_RenderWindow( parent, name ), + myInteractor(QtRenderWindowInteractor::New()) { - myInteractor = QtRenderWindowInteractor::New(); - + myInteractor->Delete(); myInteractor->SetRenderWindow( getRenderWindow() ); myDisplayMode = 0; } @@ -144,12 +144,17 @@ SVTK_RenderWindowInteractor SVTK_SpaceMouse* sm = SVTK_SpaceMouse::getInstance(); if ( sm->isSpaceMouseOn() ) sm->close( x11Display() ); - - myInteractor->Delete(); } //---------------------------------------------------------------------------- +vtkRenderWindowInteractor* +SVTK_RenderWindowInteractor +::getDevice() +{ + return myInteractor.GetPointer(); +} + void SVTK_RenderWindowInteractor ::Initialize() diff --git a/src/SVTK/SVTK_RenderWindowInteractor.h b/src/SVTK/SVTK_RenderWindowInteractor.h index c3d6e7241..ecfc972fe 100644 --- a/src/SVTK/SVTK_RenderWindowInteractor.h +++ b/src/SVTK/SVTK_RenderWindowInteractor.h @@ -35,7 +35,7 @@ #include "SALOME_InteractiveObject.hxx" -// VTK Includes +#include #include class QTimer; @@ -88,7 +88,7 @@ class SVTK_EXPORT SVTK_RenderWindowInteractor: public SVTK_RenderWindow SVTK_RenderWindowInteractor( QWidget*, const char* ); ~SVTK_RenderWindowInteractor(); - vtkRenderWindowInteractor* getInteractor() { return myInteractor; } + vtkRenderWindowInteractor* getDevice(); // Description: // Initializes the event handlers without an XtAppContext. This is @@ -107,7 +107,7 @@ class SVTK_EXPORT SVTK_RenderWindowInteractor: public SVTK_RenderWindow vtkRenderer* GetRenderer(); protected: - vtkGenericRenderWindowInteractor* myInteractor; + vtkSmartPointer myInteractor; virtual void paintEvent( QPaintEvent* ); virtual void resizeEvent( QResizeEvent* ); diff --git a/src/SVTK/SVTK_View.cxx b/src/SVTK/SVTK_View.cxx index fd2751d47..f886bbf92 100644 --- a/src/SVTK/SVTK_View.cxx +++ b/src/SVTK/SVTK_View.cxx @@ -56,8 +56,7 @@ SVTK_View //---------------------------------------------------------------------------- SVTK_View ::~SVTK_View() -{ -} +{} //---------------------------------------------------------------------------- SVTK_Selector* @@ -140,7 +139,8 @@ SVTK_View } //---------------------------------------------------------------- -struct THighlightAction{ +struct THighlightAction +{ bool myIsHighlight; Selection_Mode myMode; THighlightAction( bool theIsHighlight, Selection_Mode theMode = ActorSelection ) @@ -196,8 +196,6 @@ void SVTK_View ::unHighlightAll() { - //cout << "SVTK_View::unHighlightAll" << endl; - using namespace VTK; ForEach( getRenderer()->GetActors(), THighlightAction( false ) ); @@ -220,48 +218,6 @@ SVTK_View update(); } -//---------------------------------------------------------------------------- -void -SVTK_View -::InsertActor( VTKViewer_Actor* theActor, bool theMoveInternalActors ) -{ - theActor->AddToRender( getRenderer() ); - - //theActor->SetTransform(myTransform); - //if(theMoveInternalActors) - // myRWInteractor->MoveInternalActors(); -} - -//---------------------------------------------------------------------------- -void -SVTK_View -::AddActor( VTKViewer_Actor* theActor, bool theUpdate ) -{ - InsertActor(theActor); - if(theUpdate) - Repaint(); -} - -//---------------------------------------------------------------------------- -void -SVTK_View -::RemoveActor( VTKViewer_Actor* theActor, bool theUpdate ) -{ - theActor->RemoveFromRender( getRenderer() ); - - if(theUpdate) - Repaint(); -} - -//---------------------------------------------------------------------------- -void -SVTK_View -::MoveActor( VTKViewer_Actor* theActor) -{ - RemoveActor(theActor); - InsertActor(theActor,true); -} - //---------------------------------------------------------------------------- void SVTK_View @@ -312,7 +268,7 @@ void SVTK_View ::initInteractorStyle( SVTK_InteractorStyle* interactorStyle ) { - getInteractor()->SetInteractorStyle( interactorStyle ); + getDevice()->SetInteractorStyle( interactorStyle ); interactorStyle->FindPokedRenderer( 0, 0 ); interactorStyle->SetSelector( GetSelector() ); @@ -324,7 +280,7 @@ void SVTK_View ::pushInteractorStyle( SVTK_InteractorStyle* interactorStyle ) { - myInteractorStyles.push( interactorStyle ); + myInteractorStyles.push( PInteractorStyle(interactorStyle) ); initInteractorStyle( interactorStyle ); } @@ -345,5 +301,5 @@ SVTK_InteractorStyle* SVTK_View ::getInteractorStyle() { - return myInteractorStyles.empty() ? 0 : myInteractorStyles.top(); + return myInteractorStyles.empty() ? 0 : myInteractorStyles.top().GetPointer(); } diff --git a/src/SVTK/SVTK_View.h b/src/SVTK/SVTK_View.h index 56c2f6ba3..76079a6a9 100644 --- a/src/SVTK/SVTK_View.h +++ b/src/SVTK/SVTK_View.h @@ -39,14 +39,6 @@ public: void pushInteractorStyle( SVTK_InteractorStyle* ); void popInteractorStyle(); - // Main process VTK event method - static - void - ProcessEvents(vtkObject* theObject, - unsigned long theEvent, - void* theClientData, - void* theCallData); - Selection_Mode SelectionMode() const; void SetSelectionMode( Selection_Mode ); @@ -69,10 +61,6 @@ public: void DisplayAll(); void EraseAll(); - //apply existing transformation on adding SALOME_Actor - void AddActor( VTKViewer_Actor*, bool update = false ); - void RemoveActor(VTKViewer_Actor*, bool update = false); - void AdjustTrihedrons( const bool forced ); void SetSelectionProp(const double& theRed = 1, @@ -96,13 +84,15 @@ public slots: virtual void activatePanning(); virtual void activateGlobalPanning(); -protected: - void InitialSetup(); - void InsertActor( VTKViewer_Actor* theActor, - bool theMoveInternalActors = false ); - void MoveActor( VTKViewer_Actor* theActor ); +protected: + // Main process VTK event method + static + void + ProcessEvents(vtkObject* theObject, + unsigned long theEvent, + void* theClientData, + void* theCallData); -private: SVTK_Viewer* myModel; // Used to process VTK events @@ -113,9 +103,9 @@ private: vtkSmartPointer mySelector; void initInteractorStyle( SVTK_InteractorStyle* ); - std::stack myInteractorStyles; - double myCurScale; + typedef vtkSmartPointer PInteractorStyle; + std::stack myInteractorStyles; }; #ifdef WIN32 diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 2854b4cec..a42b6b7b9 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -120,14 +120,14 @@ SVTK_ViewWindow return myView; } -SVTK_View* +SVTK_RenderWindow* SVTK_ViewWindow ::getRenderWindow() { return myView; } -SVTK_View* +SVTK_RenderWindowInteractor* SVTK_ViewWindow ::getRWInteractor() { diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index ff747772d..94ef06637 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -24,7 +24,8 @@ class SVTK_Selector; class SVTK_InteractorStyle; class SVTK_CubeAxesActor2D; -class vtkRenderer; +class SVTK_RenderWindow; +class SVTK_RenderWindowInteractor; class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow { @@ -41,8 +42,8 @@ public: SVTK_Selector* GetSelector(); SVTK_View* getView(); - SVTK_View* getRenderWindow(); - SVTK_View* getRWInteractor(); + SVTK_RenderWindow* getRenderWindow(); + SVTK_RenderWindowInteractor* getRWInteractor(); SVTK_InteractorStyle* getInteractorStyle(); -- 2.39.2