From 1bfaeaddf0987c19e4bae89e74fb9e9ef9222fb2 Mon Sep 17 00:00:00 2001 From: apo Date: Wed, 21 Sep 2005 11:48:21 +0000 Subject: [PATCH] To improve Initialize functionality in order to provide explicit way of SVTK initialization --- src/VVTK/VVTK_Renderer.cxx | 22 ++++----- src/VVTK/VVTK_Renderer.h | 1 - src/VVTK/VVTK_View.cxx | 26 +++++----- src/VVTK/VVTK_View.h | 8 ++-- src/VVTK/VVTK_ViewWindow.cxx | 92 +++++++++++++++++++++++++++++------- src/VVTK/VVTK_ViewWindow.h | 6 +++ 6 files changed, 111 insertions(+), 44 deletions(-) diff --git a/src/VVTK/VVTK_Renderer.cxx b/src/VVTK/VVTK_Renderer.cxx index 0c8fec25..9b1eb747 100644 --- a/src/VVTK/VVTK_Renderer.cxx +++ b/src/VVTK/VVTK_Renderer.cxx @@ -136,17 +136,17 @@ VVTK_Renderer2 ::SetRenderer1(VVTK_Renderer1* theRenderer) { myRenderer1 = theRenderer; - myImplicitFunctionWidget1 = myRenderer1->GetImplicitFunctionWidget(); - myImplicitFunctionWidget1->AddObserver(vtkCommand::EndInteractionEvent, - myEventCallbackCommand.GetPointer(), - myPriority); - myImplicitFunctionWidget1->AddObserver(vtkCommand::EnableEvent, - myEventCallbackCommand.GetPointer(), - myPriority); - myImplicitFunctionWidget1->AddObserver(vtkCommand::DisableEvent, - myEventCallbackCommand.GetPointer(), - myPriority); - myImplicitFunction = myImplicitFunctionWidget1->ImplicitFunction(); + VISU_ImplicitFunctionWidget* aWidget = myRenderer1->GetImplicitFunctionWidget(); + aWidget->AddObserver(vtkCommand::EndInteractionEvent, + myEventCallbackCommand.GetPointer(), + myPriority); + aWidget->AddObserver(vtkCommand::EnableEvent, + myEventCallbackCommand.GetPointer(), + myPriority); + aWidget->AddObserver(vtkCommand::DisableEvent, + myEventCallbackCommand.GetPointer(), + myPriority); + myImplicitFunction = aWidget->ImplicitFunction(); } void diff --git a/src/VVTK/VVTK_Renderer.h b/src/VVTK/VVTK_Renderer.h index b7c194a5..797a9ee5 100644 --- a/src/VVTK/VVTK_Renderer.h +++ b/src/VVTK/VVTK_Renderer.h @@ -101,7 +101,6 @@ class VVTK_EXPORT VVTK_Renderer2 : public SVTK_Renderer // Priority at which events are processed float myPriority; - vtkSmartPointer myImplicitFunctionWidget1; vtkSmartPointer myImplicitFunction; VVTK_Renderer1* myRenderer1; }; diff --git a/src/VVTK/VVTK_View.cxx b/src/VVTK/VVTK_View.cxx index d1428bb3..d126b21e 100644 --- a/src/VVTK/VVTK_View.cxx +++ b/src/VVTK/VVTK_View.cxx @@ -89,9 +89,9 @@ VVTK_MainWindowBase void VVTK_MainWindowBase -::Initialize(SVTK_Renderer *theRenderer) +::Initialize(SVTK_RenderWindowInteractor* theInteractor) { - SVTK_MainWindow::Initialize(theRenderer); + SVTK_MainWindow::Initialize(theInteractor); PushInteractorStyle(myInteractorStyle.GetPointer()); } @@ -150,12 +150,12 @@ VVTK_MainWindow1 void VVTK_MainWindow1 -::Initialize() +::Initialize(SVTK_RenderWindowInteractor* theInteractor, + VVTK_Renderer1* theRenderer) { - myRenderer = VVTK_Renderer1::New(); - VVTK_MainWindowBase::Initialize(myRenderer); - mySegmentationCursorDlg->SetWidget( myRenderer->GetImplicitFunctionWidget() ); - myRenderer->Delete(); + myRenderer = theRenderer; + VVTK_MainWindowBase::Initialize(theInteractor); + mySegmentationCursorDlg->SetWidget( theRenderer->GetImplicitFunctionWidget() ); } VVTK_MainWindow1 @@ -177,7 +177,7 @@ VVTK_MainWindow1 ::sizeHint() const { QWidget* aParent = parentWidget(); - static float aCoeff = 2.0/3.0; + static float aCoeff = 1.0/2.0; int aWidth = int(aCoeff*aParent->width()); int aHeight = int(aCoeff*aParent->height()); @@ -215,11 +215,11 @@ VVTK_MainWindow2 void VVTK_MainWindow2 -::Initialize() +::Initialize(SVTK_RenderWindowInteractor* theInteractor, + VVTK_Renderer2* theRenderer) { - myRenderer = VVTK_Renderer2::New(); - VVTK_MainWindowBase::Initialize(myRenderer); - myRenderer->Delete(); + myRenderer = theRenderer; + VVTK_MainWindowBase::Initialize(theInteractor); myRenderer->SetRenderer1(myMainWindow->GetRenderer1()); } @@ -234,7 +234,7 @@ VVTK_MainWindow2 ::sizeHint() const { QWidget* aParent = parentWidget(); - static float aCoeff = 1.0/3.0; + static float aCoeff = 1.0/2.0; int aWidth = int(aCoeff*aParent->width()); int aHeight = int(aCoeff*aParent->height()); diff --git a/src/VVTK/VVTK_View.h b/src/VVTK/VVTK_View.h index 9cc036b5..8802bebd 100644 --- a/src/VVTK/VVTK_View.h +++ b/src/VVTK/VVTK_View.h @@ -25,7 +25,7 @@ public: SUIT_ResourceMgr* theResourceMgr); virtual void - Initialize(SVTK_Renderer *theRenderer); + Initialize(SVTK_RenderWindowInteractor* theInteractor); virtual ~VVTK_MainWindowBase(); @@ -51,7 +51,8 @@ public: SUIT_ResourceMgr* theResourceMgr); virtual void - Initialize(); + Initialize(SVTK_RenderWindowInteractor* theInteractor, + VVTK_Renderer1* theRenderer); virtual ~VVTK_MainWindow1(); @@ -87,7 +88,8 @@ public: virtual void - Initialize(); + Initialize(SVTK_RenderWindowInteractor* theInteractor, + VVTK_Renderer2* theRenderer); virtual ~VVTK_MainWindow2(); diff --git a/src/VVTK/VVTK_ViewWindow.cxx b/src/VVTK/VVTK_ViewWindow.cxx index 5d1801e4..5a662979 100755 --- a/src/VVTK/VVTK_ViewWindow.cxx +++ b/src/VVTK/VVTK_ViewWindow.cxx @@ -34,6 +34,11 @@ #include "SUIT_Session.h" +#include "VVTK_Renderer.h" +#include "SVTK_InteractorStyle.h" +#include "SVTK_RenderWindowInteractor.h" +#include "SVTK_GenericRenderWindowInteractor.h" + #include #include @@ -60,22 +65,68 @@ VVTK_ViewWindow QSplitter* aSplitter = new QSplitter(Qt::Vertical,aWidget); aSplitter->setChildrenCollapsible(true); - myMainWindow1 = new VVTK_MainWindow1(aSplitter, - "VVTK_MainWindow", - aResourceMgr); - myMainWindow = myMainWindow1; - myMainWindow->Initialize(); + SVTK_Selector* aSelector = SVTK_Selector::New(); + { + myMainWindow1 = new VVTK_MainWindow1(aSplitter, + "VVTK_MainWindow", + aResourceMgr); + + SVTK_RenderWindowInteractor* anIteractor = + new SVTK_RenderWindowInteractor(myMainWindow1,"SVTK_RenderWindowInteractor1"); + + VVTK_Renderer1* aRenderer = VVTK_Renderer1::New(); + + SVTK_GenericRenderWindowInteractor* aDevice = + SVTK_GenericRenderWindowInteractor::New(); + aDevice->SetRenderWidget(anIteractor); + aDevice->SetSelector(aSelector); + + anIteractor->Initialize(aDevice,aRenderer,aSelector); + + SVTK_InteractorStyle* aStyle = SVTK_InteractorStyle::New(); + anIteractor->PushInteractorStyle(aStyle); + aStyle->Delete(); + + aDevice->Delete(); + aRenderer->Delete(); + + myMainWindow1->Initialize(anIteractor,aRenderer); + + myView1 = new SVTK_View(myMainWindow1); + } + { + myMainWindow2 = new VVTK_MainWindow2(aSplitter, + "VVTK_SegmantationWindow", + aResourceMgr, + myMainWindow1); + SVTK_RenderWindowInteractor* anIteractor = + new SVTK_RenderWindowInteractor(myMainWindow2,"SVTK_RenderWindowInteractor1"); + + VVTK_Renderer2* aRenderer = VVTK_Renderer2::New(); + + SVTK_GenericRenderWindowInteractor* aDevice = + SVTK_GenericRenderWindowInteractor::New(); + aDevice->SetRenderWidget(anIteractor); + aDevice->SetSelector(aSelector); - myView = new SVTK_View(myMainWindow); - SVTK_ViewWindow::Initialize(myView,theModel); + anIteractor->Initialize(aDevice,aRenderer,aSelector); - myMainWindow2 = new VVTK_MainWindow2(aSplitter, - "VVTK_SegmantationWindow", - aResourceMgr, - myMainWindow1); - myMainWindow2->Initialize(); + SVTK_InteractorStyle* aStyle = SVTK_InteractorStyle::New(); + anIteractor->PushInteractorStyle(aStyle); + aStyle->Delete(); - myView2 = new SVTK_View(myMainWindow2); + aDevice->Delete(); + aRenderer->Delete(); + + myMainWindow2->Initialize(anIteractor,aRenderer); + + myView2 = new SVTK_View(myMainWindow2); + } + aSelector->Delete(); + + SVTK_ViewWindow::Initialize(myView1,theModel); + myMainWindow = myMainWindow1; + myView = myView1; } } @@ -91,7 +142,7 @@ VVTK_ViewWindow ::AddActor(VTKViewer_Actor* theActor, bool theIsUpdate) { - SVTK_ViewWindow::AddActor(theActor,theIsUpdate); + myMainWindow1->AddActor(theActor,theIsUpdate); if(VISU_Actor* anAct = dynamic_cast(theActor)) if(VISU::TActorFactory* aFactory = anAct->GetFactory()) if(VISU_Actor* anActor = aFactory->CloneActor(anAct)) @@ -104,7 +155,7 @@ VVTK_ViewWindow ::RemoveActor(VTKViewer_Actor* theActor, bool theIsUpdate) { - SVTK_ViewWindow::RemoveActor(theActor,theIsUpdate); + myMainWindow1->RemoveActor(theActor,theIsUpdate); myMainWindow2->RemoveActor(theActor,theIsUpdate); } @@ -113,10 +164,19 @@ void VVTK_ViewWindow ::Repaint(bool theUpdateTrihedron) { - myMainWindow->Repaint(theUpdateTrihedron); + myMainWindow1->Repaint(theUpdateTrihedron); myMainWindow2->Repaint(theUpdateTrihedron); } +//---------------------------------------------------------------- +void +VVTK_ViewWindow +::onSelectionChanged() +{ + myView1->onSelectionChanged(); + myView2->onSelectionChanged(); +} + //---------------------------------------------------------------------------- void VVTK_ViewWindow diff --git a/src/VVTK/VVTK_ViewWindow.h b/src/VVTK/VVTK_ViewWindow.h index b60b095d..90134e22 100755 --- a/src/VVTK/VVTK_ViewWindow.h +++ b/src/VVTK/VVTK_ViewWindow.h @@ -41,6 +41,10 @@ public: Repaint(bool theUpdateTrihedron = true); public slots: + virtual + void + onSelectionChanged(); + virtual void onResetView(); @@ -51,6 +55,8 @@ public slots: protected: VVTK_MainWindow1* myMainWindow1; + SVTK_View* myView1; + VVTK_MainWindow2* myMainWindow2; SVTK_View* myView2; }; -- 2.39.2