]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To improve Initialize functionality in order to
authorapo <apo@opencascade.com>
Wed, 21 Sep 2005 11:48:21 +0000 (11:48 +0000)
committerapo <apo@opencascade.com>
Wed, 21 Sep 2005 11:48:21 +0000 (11:48 +0000)
provide explicit way of SVTK initialization

src/VVTK/VVTK_Renderer.cxx
src/VVTK/VVTK_Renderer.h
src/VVTK/VVTK_View.cxx
src/VVTK/VVTK_View.h
src/VVTK/VVTK_ViewWindow.cxx
src/VVTK/VVTK_ViewWindow.h

index 0c8fec25477d354d7272abbb2dacb81e9eafb84d..9b1eb747865feed2f5e2c00994cab422e244072f 100644 (file)
@@ -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 
index b7c194a5cdcb389ad7eb2519e7364bff0fecda5d..797a9ee5e563599d51c824ad223a18709df28d76 100644 (file)
@@ -101,7 +101,6 @@ class VVTK_EXPORT VVTK_Renderer2 : public SVTK_Renderer
   // Priority at which events are processed
   float myPriority;
 
-  vtkSmartPointer<VISU_ImplicitFunctionWidget> myImplicitFunctionWidget1;
   vtkSmartPointer<vtkImplicitFunction> myImplicitFunction;
   VVTK_Renderer1* myRenderer1;
 };
index d1428bb3385d6b07a9f0fdb85caaa94fde2cbe63..d126b21e316d08fff001e48c9dc592b2a4bbf2cd 100644 (file)
@@ -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());
 
index 9cc036b5b2cae141024e69443ab01d5432434197..8802bebdb4552233ab7fc07cfcd4cdc87b7437e1 100644 (file)
@@ -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();
index 5d1801e41d7151ea1a936da2e21aaddc9f63d1e2..5a6629794b1e709a3bb64064e4216d31aee157cb 100755 (executable)
 
 #include "SUIT_Session.h"
 
+#include "VVTK_Renderer.h"
+#include "SVTK_InteractorStyle.h"
+#include "SVTK_RenderWindowInteractor.h"
+#include "SVTK_GenericRenderWindowInteractor.h"
+
 #include <qsplitter.h>
 #include <qlayout.h>
 
@@ -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<VISU_Actor*>(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
index b60b095d1f754b40adc92e1f0c2bb2c1e8d9cfcb..90134e222fcb7fb6aef98a5a09691e5d50fe2406 100755 (executable)
@@ -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;
 };