From: apo Date: Thu, 6 Oct 2005 05:00:11 +0000 (+0000) Subject: To improve a way to apply picking and outside cursor settings X-Git-Tag: BR-D5-38-2003_D2005-12-10~49 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a909c855ea57d8f4b4c6e8da6b21d4caecfd2d43;p=modules%2Fvisu.git To improve a way to apply picking and outside cursor settings --- diff --git a/src/VVTK/VVTK_MainWindow.cxx b/src/VVTK/VVTK_MainWindow.cxx index 01219d93..dba80f79 100644 --- a/src/VVTK/VVTK_MainWindow.cxx +++ b/src/VVTK/VVTK_MainWindow.cxx @@ -69,13 +69,6 @@ VVTK_MainWindow ::~VVTK_MainWindow() {} -VVTK_InteractorStyle* -VVTK_MainWindow -::GetVInteractorStyle() -{ - return myInteractorStyle.GetPointer(); -} - //---------------------------------------------------------------------------- void @@ -120,7 +113,8 @@ VVTK_MainWindow1 SUIT_ResourceMgr* theResourceMgr): VVTK_MainWindow(theParent,theName,theResourceMgr), myStyleSwitchAction(NULL), - mySplitter(theParent) + mySplitter(theParent), + myPickingDlg(NULL) { myPtsToolBar = new QToolBar(this); myPtsToolBar->setCloseMode(QDockWindow::Undocked); @@ -160,6 +154,7 @@ VVTK_MainWindow1 myPickingDlg = new VVTK_PickingDlg( this, "PickingDlg" ); myPickingDlg->SetAction( anAction ); + myInteractorStyle->SetPickingSettings(myPickingDlg->GetPickingSettings()); aPixmap = theResourceMgr->loadPixmap("VISU",tr("ICON_VVTK_PLANE_SEGMENTATION_SWITCH")); anAction = new QtxAction(tr("MNU_VVTK_PLANE_SEGMENTATION_SWITCH"), @@ -186,7 +181,6 @@ VVTK_MainWindow1 myRenderer = theRenderer; VVTK_MainWindow::Initialize(theInteractor); mySegmentationCursorDlg->SetWidget( theRenderer->GetImplicitFunctionWidget() ); - GetVInteractorStyle()->SetPickingSettings( GetPickingSettings() ); } VVTK_MainWindow1 @@ -198,16 +192,15 @@ VVTK_MainWindow1 VVTK_MainWindow2* VVTK_MainWindow1 ::CreateMainWindow2(QWidget* theParent, - const char* theName, - SUIT_ResourceMgr* theResourceMgr) + const char* theName, + SUIT_ResourceMgr* theResourceMgr, + VISU_PickingSettings* thePickingSettings) { VVTK_MainWindow2* aMainWindow2 = new VVTK_MainWindow2(theParent, theName, theResourceMgr, - this, - myStyleSwitchAction, - myPickingDlg); - aMainWindow2->GetVInteractorStyle()->SetPickingSettings(GetPickingSettings()); + thePickingSettings, + myStyleSwitchAction); return aMainWindow2; } @@ -230,48 +223,18 @@ VVTK_MainWindow1 //---------------------------------------------------------------------------- -void -VVTK_MainWindow1 -::AddActor(VTKViewer_Actor* theActor, - bool theIsUpdate) -{ - if(VISU_GaussPtsAct1* anActor1 = dynamic_cast(theActor)) - mySegmentationCursorDlg->AddActor( anActor1 ); - - if(VISU_GaussPtsAct* anActor = dynamic_cast(theActor)) - myPickingDlg->AddActor( anActor ); - - SVTK_MainWindow::AddActor( theActor, theIsUpdate ); -} - -//---------------------------------------------------------------------------- -void -VVTK_MainWindow1 -::RemoveActor(VTKViewer_Actor* theActor, - bool theIsUpdate) -{ - if(VISU_GaussPtsAct1* anActor1 = dynamic_cast(theActor)) - mySegmentationCursorDlg->RemoveActor( anActor1 ); - - if(VISU_GaussPtsAct* anActor = dynamic_cast(theActor)) - myPickingDlg->RemoveActor( anActor ); - - SVTK_MainWindow::RemoveActor( theActor, theIsUpdate ); -} - -//---------------------------------------------------------------------------- -VVTK_Renderer1* +VISU_ImplicitFunctionWidget* VVTK_MainWindow1 -::GetRenderer1() +::GetImplicitFunctionWidget() { - return myRenderer; + return myRenderer->GetImplicitFunctionWidget(); } -VISU_ImplicitFunctionWidget* +VISU_OutsideCursorSettings* VVTK_MainWindow1 -::GetImplicitFunctionWidget() +::GetOutsideCursorSettings() { - return myRenderer->GetImplicitFunctionWidget(); + return mySegmentationCursorDlg->GetOutsideCursorSettings(); } VISU_PickingSettings* @@ -320,55 +283,19 @@ VVTK_MainWindow2 ::VVTK_MainWindow2(QWidget* theParent, const char* theName, SUIT_ResourceMgr* theResourceMgr, - VVTK_MainWindow1* theMainWindow, - QtxAction* theStyleSwitchAction, - VVTK_PickingDlg* thePickingDlg): - VVTK_MainWindow(theParent,theName,theResourceMgr), - myMainWindow(theMainWindow), - myPickingDlg(thePickingDlg) + VISU_PickingSettings* thePickingSettings, + QtxAction* theStyleSwitchAction): + VVTK_MainWindow(theParent,theName,theResourceMgr) { - connect(theStyleSwitchAction, SIGNAL(toggled(bool)), this, SLOT(OnInteractorStyleSwitch(bool))); -} + myInteractorStyle->SetPickingSettings(thePickingSettings); -void -VVTK_MainWindow2 -::Initialize(SVTK_RenderWindowInteractor* theInteractor, - VVTK_Renderer2* theRenderer) -{ - myRenderer = theRenderer; - VVTK_MainWindow::Initialize(theInteractor); - - myRenderer->SetRenderer1(myMainWindow->GetRenderer1()); + connect(theStyleSwitchAction, SIGNAL(toggled(bool)), this, SLOT(OnInteractorStyleSwitch(bool))); } VVTK_MainWindow2 ::~VVTK_MainWindow2() {} -//---------------------------------------------------------------------------- -void -VVTK_MainWindow2 -::AddActor(VTKViewer_Actor* theActor, - bool theIsUpdate) -{ - if(VISU_GaussPtsAct* anActor = dynamic_cast(theActor)) - myPickingDlg->AddActor( anActor ); - - SVTK_MainWindow::AddActor( theActor, theIsUpdate ); -} - -//---------------------------------------------------------------------------- -void -VVTK_MainWindow2 -::RemoveActor(VTKViewer_Actor* theActor, - bool theIsUpdate) -{ - if(VISU_GaussPtsAct* anActor = dynamic_cast(theActor)) - myPickingDlg->RemoveActor( anActor ); - - SVTK_MainWindow::RemoveActor( theActor, theIsUpdate ); -} - //---------------------------------------------------------------------------- QSize VVTK_MainWindow2 diff --git a/src/VVTK/VVTK_MainWindow.h b/src/VVTK/VVTK_MainWindow.h index f697a677..bee6727a 100644 --- a/src/VVTK/VVTK_MainWindow.h +++ b/src/VVTK/VVTK_MainWindow.h @@ -12,6 +12,7 @@ class QSplitter; class VISU_ImplicitFunctionWidget; class VVTK_SegmentationCursorDlg; +class VISU_OutsideCursorSettings; class VISU_PickingSettings; class VVTK_InteractorStyle; class VVTK_PickingDlg; @@ -35,9 +36,6 @@ public: virtual ~VVTK_MainWindow(); - VVTK_InteractorStyle* - GetVInteractorStyle(); - public slots: virtual void @@ -77,24 +75,15 @@ public: VVTK_MainWindow2* CreateMainWindow2(QWidget* theParent, const char* theName, - SUIT_ResourceMgr* theResourceMgr); - - virtual - void - AddActor(VTKViewer_Actor* theActor, - bool theIsUpdate = false); - - virtual - void - RemoveActor(VTKViewer_Actor* theActor, - bool theIsUpdate = false); - - VVTK_Renderer1* - GetRenderer1(); + SUIT_ResourceMgr* theResourceMgr, + VISU_PickingSettings* thePickingSettings); VISU_ImplicitFunctionWidget* GetImplicitFunctionWidget(); + VISU_OutsideCursorSettings* + GetOutsideCursorSettings(); + VISU_PickingSettings* GetPickingSettings(); @@ -117,8 +106,8 @@ public: QToolBar* myPtsToolBar; QSplitter* mySplitter; - VVTK_PickingDlg* myPickingDlg; VVTK_SegmentationCursorDlg* mySegmentationCursorDlg; + VVTK_PickingDlg* myPickingDlg; }; @@ -132,37 +121,15 @@ class VVTK_EXPORT VVTK_MainWindow2: public VVTK_MainWindow VVTK_MainWindow2(QWidget* theParent, const char* theName, SUIT_ResourceMgr* theResourceMgr, - VVTK_MainWindow1* theMainWindow, - QtxAction* theStyleSwitchAction, - VVTK_PickingDlg* thePickingDlg); + VISU_PickingSettings* thePickingSettings, + QtxAction* theStyleSwitchAction); public: - virtual - void - Initialize(SVTK_RenderWindowInteractor* theInteractor, - VVTK_Renderer2* theRenderer); - virtual ~VVTK_MainWindow2(); - virtual - void - AddActor(VTKViewer_Actor* theActor, - bool theIsUpdate = false); - - virtual - void - RemoveActor(VTKViewer_Actor* theActor, - bool theIsUpdate = false); - virtual QSize sizeHint() const; - - protected: - VVTK_MainWindow1* myMainWindow; - VVTK_Renderer2* myRenderer; - - VVTK_PickingDlg* myPickingDlg; }; diff --git a/src/VVTK/VVTK_Renderer.cxx b/src/VVTK/VVTK_Renderer.cxx index 0cad2ffc..d57532e1 100644 --- a/src/VVTK/VVTK_Renderer.cxx +++ b/src/VVTK/VVTK_Renderer.cxx @@ -132,7 +132,8 @@ vtkStandardNewMacro(VVTK_Renderer); //---------------------------------------------------------------------------- VVTK_Renderer ::VVTK_Renderer(): - myFPSActor(VISU_FPSActor::New()) + myFPSActor(VISU_FPSActor::New()), + myPickingSettings(NULL) { if(MYDEBUG) INFOS("VVTK_Renderer() - "<(theActor)){ + anActor->SetPickingSettings(myPickingSettings); + Superclass::AddActor(anActor); + } +} + +//---------------------------------------------------------------------------- +void +VVTK_Renderer +::RemoveActor(VTKViewer_Actor* theActor) +{ + using namespace VISU; + if(VISU_GaussPtsAct1* anActor = dynamic_cast(theActor)){ + anActor->SetPickingSettings(NULL); + Superclass::RemoveActor(theActor); + } +} + +//---------------------------------------------------------------------------- +void +VVTK_Renderer +::SetPickingSettings(VISU_PickingSettings* thePickingSettings) +{ + myPickingSettings = thePickingSettings; +} + //---------------------------------------------------------------------------- vtkStandardNewMacro(VVTK_Renderer1); @@ -167,7 +199,8 @@ vtkStandardNewMacro(VVTK_Renderer1); //---------------------------------------------------------------------------- VVTK_Renderer1 ::VVTK_Renderer1(): - myImplicitFunctionWidget(VISU_ImplicitFunctionWidget::New()) + myImplicitFunctionWidget(VISU_ImplicitFunctionWidget::New()), + myOutsideCursorSettings(NULL) { if(MYDEBUG) INFOS("VVTK_Renderer1() - "<(theActor)){ anActor->SetImplicitFunctionWidget(GetImplicitFunctionWidget()); - SVTK_Renderer::AddActor(anActor); + anActor->SetOutsideCursorSettings(myOutsideCursorSettings); + Superclass::AddActor(anActor); } } @@ -206,9 +240,11 @@ VVTK_Renderer1 using namespace VISU; if(VISU_GaussPtsAct1* anActor = dynamic_cast(theActor)){ anActor->SetImplicitFunctionWidget(NULL); - SVTK_Renderer::RemoveActor(theActor); + anActor->SetOutsideCursorSettings(NULL); + Superclass::RemoveActor(theActor); } } + //---------------------------------------------------------------------------- void VVTK_Renderer1 @@ -218,6 +254,14 @@ VVTK_Renderer1 myImplicitFunctionWidget->SetInteractor(theInteractor); } +//---------------------------------------------------------------------------- +void +VVTK_Renderer1 +::SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings) +{ + myOutsideCursorSettings = theOutsideCursorSettings; +} + //---------------------------------------------------------------------------- VISU_ImplicitFunctionWidget* VVTK_Renderer1 @@ -268,19 +312,18 @@ VVTK_Renderer2 //---------------------------------------------------------------------------- void VVTK_Renderer2 -::SetRenderer1(VVTK_Renderer1* theRenderer) +::SetImplicitFunctionWidget(VISU_ImplicitFunctionWidget* theWidget) { - myRenderer1 = theRenderer; - myWidget = myRenderer1->GetImplicitFunctionWidget(); - myWidget->AddObserver(vtkCommand::EndInteractionEvent, - myEventCallbackCommand.GetPointer(), - myPriority); - myWidget->AddObserver(vtkCommand::EnableEvent, - myEventCallbackCommand.GetPointer(), - myPriority); - myWidget->AddObserver(vtkCommand::DisableEvent, - myEventCallbackCommand.GetPointer(), - myPriority); + theWidget->AddObserver(vtkCommand::EndInteractionEvent, + myEventCallbackCommand.GetPointer(), + myPriority); + theWidget->AddObserver(vtkCommand::EnableEvent, + myEventCallbackCommand.GetPointer(), + myPriority); + theWidget->AddObserver(vtkCommand::DisableEvent, + myEventCallbackCommand.GetPointer(), + myPriority); + myWidget = theWidget; } void @@ -317,7 +360,7 @@ VVTK_Renderer2 if(VISU::TGaussPtsActorFactory* aFactory = anActor->GetGaussPtsFactory()){ if(VISU_GaussPtsAct2* anActor2 = aFactory->CloneActor(anActor)){ anActor2->SetImplicitFunctionWidget(myWidget); - SVTK_Renderer::AddActor(anActor2); + Superclass::AddActor(anActor2); } } } @@ -331,6 +374,6 @@ VVTK_Renderer2 using namespace VISU; if(VISU_GaussPtsAct2* anActor = dynamic_cast(theActor)){ anActor->SetImplicitFunctionWidget(NULL); - SVTK_Renderer::RemoveActor(theActor); + Superclass::RemoveActor(theActor); } } diff --git a/src/VVTK/VVTK_Renderer.h b/src/VVTK/VVTK_Renderer.h index 28eff415..85ac72b9 100644 --- a/src/VVTK/VVTK_Renderer.h +++ b/src/VVTK/VVTK_Renderer.h @@ -34,6 +34,8 @@ #include "SVTK_Renderer.h" class VISU_ImplicitFunctionWidget; +class VISU_OutsideCursorSettings; +class VISU_PickingSettings; class VISU_FPSActor; class vtkImplicitFunction; @@ -45,10 +47,22 @@ class VVTK_EXPORT VVTK_Renderer : public SVTK_Renderer vtkTypeMacro(VVTK_Renderer,SVTK_Renderer); static VVTK_Renderer* New(); + virtual + void + AddActor(VTKViewer_Actor* theActor); + + virtual + void + RemoveActor(VTKViewer_Actor* theActor); + + void + SetPickingSettings(VISU_PickingSettings* thePickingSettings); + protected: VVTK_Renderer(); ~VVTK_Renderer(); + VISU_PickingSettings* myPickingSettings; vtkSmartPointer myFPSActor; }; @@ -57,7 +71,7 @@ class VVTK_EXPORT VVTK_Renderer : public SVTK_Renderer class VVTK_EXPORT VVTK_Renderer1 : public VVTK_Renderer { public: - vtkTypeMacro(VVTK_Renderer1,SVTK_Renderer); + vtkTypeMacro(VVTK_Renderer1,VVTK_Renderer); static VVTK_Renderer1* New(); virtual @@ -72,6 +86,9 @@ class VVTK_EXPORT VVTK_Renderer1 : public VVTK_Renderer void SetInteractor(vtkRenderWindowInteractor* theInteractor); + void + SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings); + VISU_ImplicitFunctionWidget* GetImplicitFunctionWidget(); @@ -84,6 +101,7 @@ class VVTK_EXPORT VVTK_Renderer1 : public VVTK_Renderer OnAdjustActors(); vtkSmartPointer myImplicitFunctionWidget; + VISU_OutsideCursorSettings* myOutsideCursorSettings; vtkSmartPointer myTextActor; }; @@ -92,7 +110,7 @@ class VVTK_EXPORT VVTK_Renderer1 : public VVTK_Renderer class VVTK_EXPORT VVTK_Renderer2 : public VVTK_Renderer { public: - vtkTypeMacro(VVTK_Renderer2,SVTK_Renderer); + vtkTypeMacro(VVTK_Renderer2,VVTK_Renderer); static VVTK_Renderer2* New(); virtual @@ -104,7 +122,7 @@ class VVTK_EXPORT VVTK_Renderer2 : public VVTK_Renderer RemoveActor(VTKViewer_Actor* theActor); void - SetRenderer1(VVTK_Renderer1* theRenderer); + SetImplicitFunctionWidget(VISU_ImplicitFunctionWidget* theWidget); void OnEndInteractionEvent(); @@ -128,7 +146,6 @@ class VVTK_EXPORT VVTK_Renderer2 : public VVTK_Renderer float myPriority; VISU_ImplicitFunctionWidget* myWidget; - VVTK_Renderer1* myRenderer1; }; diff --git a/src/VVTK/VVTK_SegmentationCursorDlg.cxx b/src/VVTK/VVTK_SegmentationCursorDlg.cxx index dd7fe982..64cf9945 100644 --- a/src/VVTK/VVTK_SegmentationCursorDlg.cxx +++ b/src/VVTK/VVTK_SegmentationCursorDlg.cxx @@ -446,6 +446,11 @@ void VVTK_SegmentationCursorDlg::UpdateOutsideCursor() ApplyOutsideCursor(); } +VISU_OutsideCursorSettings* VVTK_SegmentationCursorDlg::GetOutsideCursorSettings() +{ + return myOutsideCursorSettings.GetPointer(); +} + vtkImageData* VVTK_SegmentationCursorDlg::MakeImageData( const QString& theMainTexture, const QString& theAlphaTexture ) { diff --git a/src/VVTK/VVTK_SegmentationCursorDlg.h b/src/VVTK/VVTK_SegmentationCursorDlg.h index 910b40ac..270ef2fc 100644 --- a/src/VVTK/VVTK_SegmentationCursorDlg.h +++ b/src/VVTK/VVTK_SegmentationCursorDlg.h @@ -52,6 +52,8 @@ public: void UpdateOutsideCursor(); + VISU_OutsideCursorSettings* GetOutsideCursorSettings(); + protected: void ApplySegmentationCursor(); void ApplyOutsideCursor(); diff --git a/src/VVTK/VVTK_ViewWindow.cxx b/src/VVTK/VVTK_ViewWindow.cxx index 5ba89216..06f7305d 100755 --- a/src/VVTK/VVTK_ViewWindow.cxx +++ b/src/VVTK/VVTK_ViewWindow.cxx @@ -65,17 +65,26 @@ VVTK_ViewWindow QSplitter* aSplitter = new QSplitter(Qt::Vertical,aWidget); aSplitter->setChildrenCollapsible(true); + VISU_ImplicitFunctionWidget* anImplicitFunctionWidget = NULL; + VISU_OutsideCursorSettings* anOutsideCursorSettings = NULL; + VISU_PickingSettings* aPickingSettings = NULL; SVTK_Selector* aSelector = SVTK_Selector::New(); { myMainWindow1 = new VVTK_MainWindow1(aSplitter, "VVTK_MainWindow", aResourceMgr); + anOutsideCursorSettings = myMainWindow1->GetOutsideCursorSettings(); + aPickingSettings = myMainWindow1->GetPickingSettings(); + SVTK_RenderWindowInteractor* anIteractor = new SVTK_RenderWindowInteractor(myMainWindow1,"SVTK_RenderWindowInteractor1"); VVTK_Renderer1* aRenderer = VVTK_Renderer1::New(); - + anImplicitFunctionWidget = aRenderer->GetImplicitFunctionWidget(); + aRenderer->SetOutsideCursorSettings(anOutsideCursorSettings); + aRenderer->SetPickingSettings(aPickingSettings); + SVTK_GenericRenderWindowInteractor* aDevice = SVTK_GenericRenderWindowInteractor::New(); aDevice->SetRenderWidget(anIteractor); @@ -98,11 +107,14 @@ VVTK_ViewWindow { myMainWindow2 = myMainWindow1->CreateMainWindow2(aSplitter, "VVTK_SegmantationWindow", - aResourceMgr); + aResourceMgr, + aPickingSettings); SVTK_RenderWindowInteractor* anIteractor = new SVTK_RenderWindowInteractor(myMainWindow2,"SVTK_RenderWindowInteractor1"); VVTK_Renderer2* aRenderer = VVTK_Renderer2::New(); + aRenderer->SetImplicitFunctionWidget(anImplicitFunctionWidget); + aRenderer->SetPickingSettings(aPickingSettings); SVTK_GenericRenderWindowInteractor* aDevice = SVTK_GenericRenderWindowInteractor::New(); @@ -118,7 +130,7 @@ VVTK_ViewWindow aDevice->Delete(); aRenderer->Delete(); - myMainWindow2->Initialize(anIteractor,aRenderer); + myMainWindow2->Initialize(anIteractor); myView2 = new SVTK_View(myMainWindow2); SVTK_ViewWindow::Initialize(myView2,theModel);