]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To improve a way to apply picking and outside cursor settings
authorapo <apo@opencascade.com>
Thu, 6 Oct 2005 05:00:11 +0000 (05:00 +0000)
committerapo <apo@opencascade.com>
Thu, 6 Oct 2005 05:00:11 +0000 (05:00 +0000)
src/VVTK/VVTK_MainWindow.cxx
src/VVTK/VVTK_MainWindow.h
src/VVTK/VVTK_Renderer.cxx
src/VVTK/VVTK_Renderer.h
src/VVTK/VVTK_SegmentationCursorDlg.cxx
src/VVTK/VVTK_SegmentationCursorDlg.h
src/VVTK/VVTK_ViewWindow.cxx

index 01219d9397accefbf53ad0197bdd06416190a1bc..dba80f7947f65d1cdca4405e07b3e2d5f45c1866 100644 (file)
@@ -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<VISU_GaussPtsAct1*>(theActor))
-    mySegmentationCursorDlg->AddActor( anActor1 );
-
-  if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor))
-    myPickingDlg->AddActor( anActor );
-
-  SVTK_MainWindow::AddActor( theActor, theIsUpdate );
-}
-
-//----------------------------------------------------------------------------
-void
-VVTK_MainWindow1
-::RemoveActor(VTKViewer_Actor* theActor, 
-             bool theIsUpdate)
-{
-  if(VISU_GaussPtsAct1* anActor1 = dynamic_cast<VISU_GaussPtsAct1*>(theActor))
-    mySegmentationCursorDlg->RemoveActor( anActor1 );
-
-  if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(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<VISU_GaussPtsAct*>(theActor))
-    myPickingDlg->AddActor( anActor );
-
-  SVTK_MainWindow::AddActor( theActor, theIsUpdate );
-}
-
-//----------------------------------------------------------------------------
-void
-VVTK_MainWindow2
-::RemoveActor(VTKViewer_Actor* theActor, 
-             bool theIsUpdate)
-{
-  if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor))
-    myPickingDlg->RemoveActor( anActor );
-
-  SVTK_MainWindow::RemoveActor( theActor, theIsUpdate );
-}
-
 //----------------------------------------------------------------------------
 QSize
 VVTK_MainWindow2
index f697a677292ae401e747c4e6248e1ae4db3ba33a..bee6727a71397eda3edfe49a7589d1a945dfd220 100644 (file)
@@ -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;
 };
 
 
index 0cad2ffc37bb4199b926d03f4b233aab19d6f4fe..d57532e17d84c1603e0c056563e53c055b5f174d 100644 (file)
@@ -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() - "<<this);
 
@@ -160,6 +161,37 @@ VVTK_Renderer
   if(MYDEBUG) INFOS("~VVTK_Renderer() - "<<this);
 }
 
+//----------------------------------------------------------------------------
+void
+VVTK_Renderer
+::AddActor(VTKViewer_Actor* theActor)
+{
+  if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor)){
+    anActor->SetPickingSettings(myPickingSettings);
+    Superclass::AddActor(anActor);
+  }
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_Renderer
+::RemoveActor(VTKViewer_Actor* theActor)
+{
+  using namespace VISU;  
+  if(VISU_GaussPtsAct1* anActor = dynamic_cast<VISU_GaussPtsAct1*>(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() - "<<this);
 
@@ -194,7 +227,8 @@ VVTK_Renderer1
 {
   if(VISU_GaussPtsAct1* anActor = dynamic_cast<VISU_GaussPtsAct1*>(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<VISU_GaussPtsAct1*>(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<VISU_GaussPtsAct2*>(theActor)){
     anActor->SetImplicitFunctionWidget(NULL);
-    SVTK_Renderer::RemoveActor(theActor);
+    Superclass::RemoveActor(theActor);
   }
 }
index 28eff415f9c6978c0c4a1a5ac2b59bf4fc19e667..85ac72b983ad00ab3f6b6d4543c5e6699726560b 100644 (file)
@@ -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<VISU_FPSActor> 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<VISU_ImplicitFunctionWidget> myImplicitFunctionWidget;
+  VISU_OutsideCursorSettings* myOutsideCursorSettings;
   vtkSmartPointer<VISU_FPSActor> 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;
 };
 
 
index dd7fe982c64500cab60d0d4fae4e0507d202f902..64cf9945155c4ea86e0027af68f1c321f46302c0 100644 (file)
@@ -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 )
 {
index 910b40aca4176873dd0c51ddf5e2e3f139ab9d78..270ef2fc59ddf968b39204554ea92ddfba81df24 100644 (file)
@@ -52,6 +52,8 @@ public:
 
   void             UpdateOutsideCursor();
 
+  VISU_OutsideCursorSettings* GetOutsideCursorSettings();
+
 protected:
   void             ApplySegmentationCursor();
   void             ApplyOutsideCursor();
index 5ba89216737b82dc8901c714739f494399f4e323..06f7305dd52f120b1c215a94b52eba2fbba282fe 100755 (executable)
@@ -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);