]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
To use native vtkRenderWindow
authorapo <apo@opencascade.com>
Fri, 9 Sep 2005 05:42:47 +0000 (05:42 +0000)
committerapo <apo@opencascade.com>
Fri, 9 Sep 2005 05:42:47 +0000 (05:42 +0000)
src/SVTK/Makefile.in
src/SVTK/SVTK_InteractorStyle.cxx
src/SVTK/SVTK_RenderWindow.cxx [deleted file]
src/SVTK/SVTK_RenderWindow.h [deleted file]
src/SVTK/SVTK_RenderWindowInteractor.cxx
src/SVTK/SVTK_RenderWindowInteractor.h
src/SVTK/SVTK_View.cxx
src/SVTK/SVTK_View.h
src/SVTK/SVTK_ViewWindow.cxx

index 1bfc3eefe2214be1c655fc05c0f6e890ba375f13..d81a1e22aa4d6d1403d54be59a534022f764ce27 100755 (executable)
@@ -23,7 +23,6 @@ EXPORT_HEADERS= SVTK.h \
                SVTK_ViewModel.h \
                SVTK_ViewWindow.h \
                SVTK_Renderer.h \
-               SVTK_RenderWindow.h \
                SVTK_InteractorStyle.h \
                SVTK_RenderWindowInteractor.h \
                SVTK_Selector.h \
@@ -46,7 +45,6 @@ LIB_SRC=      SVTK_Prs.cxx \
                SVTK_ViewModel.cxx \
                SVTK_Renderer.cxx \
                SVTK_ViewWindow.cxx \
-               SVTK_RenderWindow.cxx\
                SVTK_InteractorStyle.cxx \
                SVTK_RenderWindowInteractor.cxx \
                SVTK_SpaceMouse.cxx \
index ce5a1a8405525daf43d4d7c984b3f7d7218f1b32..4fe4eb51e9622cc78f44421d5bf9982695c12de0 100644 (file)
@@ -1407,5 +1407,3 @@ SVTK_InteractorStyle
   }
   vtkInteractorStyle::ProcessEvents( object, event, clientData, callData );
 }
-
-#include "SVTK_RenderWindow.h"
diff --git a/src/SVTK/SVTK_RenderWindow.cxx b/src/SVTK/SVTK_RenderWindow.cxx
deleted file mode 100644 (file)
index 435265e..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-//  SALOME VTKViewer : build VTK viewer into Salome desktop
-//
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   :
-//  Author :
-//  Module :
-//  $Header$
-
-#include "SVTK_RenderWindow.h"
-
-#include "SVTK_Renderer.h"
-#include "SVTK_Selector.h"
-
-#include <vtkObjectFactory.h>
-
-//----------------------------------------------------------------------------
-vtkStandardNewMacro(SVTK_RenderWindow);
-
-
-//----------------------------------------------------------------------------
-SVTK_RenderWindow
-::SVTK_RenderWindow():
-  myRenderWidget(NULL)
-{
-}
-
-SVTK_RenderWindow
-::~SVTK_RenderWindow() 
-{}
-
-
-//----------------------------------------------------------------------------
-SVTK_Renderer* 
-SVTK_RenderWindow
-::GetRenderer()
-{
-  return myRenderer.GetPointer();
-}
-
-void
-SVTK_RenderWindow
-::SetRenderer(SVTK_Renderer* theRenderer)
-{
-  this->RemoveRenderer(GetRenderer());
-  myRenderer = theRenderer;
-  this->AddRenderer(GetRenderer());
-}
-
-
-//----------------------------------------------------------------------------
-SVTK_Selector* 
-SVTK_RenderWindow
-::GetSelector()
-{
-  return mySelector.GetPointer();
-}
-
-void
-SVTK_RenderWindow
-::SetSelector(SVTK_Selector* theSelector)
-{
-  mySelector = theSelector;
-}
-
-
-//----------------------------------------------------------------------------
-SVTK_RenderWindow::TRenderWidget* 
-SVTK_RenderWindow
-::GetRenderWidget()
-{
-  return myRenderWidget;
-}
-
-void
-SVTK_RenderWindow
-::GetRenderWidget(TRenderWidget* theWidget)
-{
-  myRenderWidget = theWidget;
-}
diff --git a/src/SVTK/SVTK_RenderWindow.h b/src/SVTK/SVTK_RenderWindow.h
deleted file mode 100644 (file)
index 2b990ea..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-//  SALOME VTKViewer : build VTK viewer into Salome desktop
-//
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : VTKViewer_RenderWindow.h
-//  Author : Nicolas REJNERI
-//  Module : SALOME
-//  $Header$
-
-#ifndef SVTK_RenderWindow_h
-#define SVTK_RenderWindow_h
-
-#include "SVTK.h"
-
-#include <vtkSmartPointer.h>
-
-#ifndef VTK_IMPLEMENT_MESA_CXX
-#include <vtkXOpenGLRenderWindow.h>
-#define SVTK_RENDER_WINDOW_SUPERCLASS vtkXOpenGLRenderWindow
-#else
-#include <vtkXMesaRenderWindow.h>
-#define SVTK_RENDER_WINDOW_SUPERCLASS vtkXMesaRenderWindow
-#endif
-
-class QWidget;
-class SVTK_Renderer;
-class SVTK_Selector;
-
-class SVTK_EXPORT SVTK_RenderWindow: public SVTK_RENDER_WINDOW_SUPERCLASS
-{
- public:
-  vtkTypeMacro(SVTK_RenderWindow,SVTK_RENDER_WINDOW_SUPERCLASS);
-  static SVTK_RenderWindow* New();
-
-  SVTK_RenderWindow();
-  virtual ~SVTK_RenderWindow();
-
-  SVTK_Renderer* GetRenderer();
-  void SetRenderer(SVTK_Renderer* theRenderer);
-
-  SVTK_Selector* GetSelector();
-  void SetSelector(SVTK_Selector* theSelector);
-
-  typedef QWidget TRenderWidget;
-  TRenderWidget* GetRenderWidget();
-  void GetRenderWidget(TRenderWidget* theWidget);
-
- protected:
-  vtkSmartPointer<SVTK_Selector> mySelector;
-  vtkSmartPointer<SVTK_Renderer> myRenderer;
-  TRenderWidget* myRenderWidget;
-};
-
-
-#endif
index fc97faef0431c376fe75440cc95c3926ec211fce..1c6df4d46bc6ba658cbfd6975966b6d77c343114 100644 (file)
 #include "SVTK_RenderWindowInteractor.h"
 
 #include "SVTK_InteractorStyle.h"
-#include "VTKViewer_Algorithm.h"
+#include "SVTK_Renderer.h"
 #include "SVTK_Functor.h"
 #include "SALOME_Actor.h"
+
 #include "SVTK_SpaceMouse.h" 
 #include "SVTK_Event.h" 
 
+#include "VTKViewer_Algorithm.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -416,7 +419,8 @@ SVTK_RenderWindowInteractor
 ::SVTK_RenderWindowInteractor(QWidget* theParent, 
                               const char* theName):
   QVTK_RenderWindowInteractor(theParent,theName),
-  myEventCallbackCommand(vtkCallbackCommand::New())
+  myEventCallbackCommand(vtkCallbackCommand::New()),
+  myRenderWindow(vtkRenderWindow::New())
 {
   myEventCallbackCommand->Delete();
 
@@ -425,55 +429,47 @@ SVTK_RenderWindowInteractor
 
   myEventCallbackCommand->SetCallback(SVTK_RenderWindowInteractor::ProcessEvents);
 
+  myRenderWindow->Delete();
+  GetDevice()->SetRenderWindow(getRenderWindow()); 
+
   SetSelector(SVTK_Selector::New());
-  GetSelector()->Delete();
+  mySelector->Delete();
 }
 
 SVTK_RenderWindowInteractor
 ::~SVTK_RenderWindowInteractor() 
 {}
 
-
-//----------------------------------------------------------------------------
-SVTK_Selector* 
+vtkRenderWindow* 
 SVTK_RenderWindowInteractor
-::GetSelector() 
-{ 
-  return mySelector.GetPointer(); 
+::getRenderWindow()
+{
+  return myRenderWindow.GetPointer();
 }
 
 
-void
+//----------------------------------------------------------------------------
+SVTK_Renderer* 
 SVTK_RenderWindowInteractor
-::SetSelector(SVTK_Selector* theSelector)
-{ 
-  if(mySelector.GetPointer())
-    mySelector->RemoveObserver(myEventCallbackCommand.GetPointer());
-
-  mySelector = theSelector; 
-
-  if(mySelector.GetPointer())
-    mySelector->AddObserver(vtkCommand::EndPickEvent, 
-                           myEventCallbackCommand.GetPointer(), 
-                           myPriority);
+::GetRenderer()
+{
+  return myRenderer.GetPointer();
 }
 
-
-//----------------------------------------------------------------------------
-void 
+vtkRenderer* 
 SVTK_RenderWindowInteractor
-::ProcessEvents(vtkObject* vtkNotUsed(theObject), 
-               unsigned long theEvent,
-               void* theClientData, 
-               void* vtkNotUsed(theCallData))
+::getRenderer()
 {
-  SVTK_RenderWindowInteractor* self = reinterpret_cast<SVTK_RenderWindowInteractor*>(theClientData);
+  return GetRenderer();
+}
 
-  switch(theEvent){
-  case vtkCommand::EndPickEvent:
-    self->onEmitSelectionChanged();
-    break;
-  }
+void
+SVTK_RenderWindowInteractor
+::SetRenderer(SVTK_Renderer* theRenderer)
+{
+  myRenderWindow->RemoveRenderer(GetRenderer());
+  myRenderer = theRenderer;
+  myRenderWindow->AddRenderer(GetRenderer());
 }
 
 
@@ -521,6 +517,49 @@ SVTK_RenderWindowInteractor
 }
 
 
+//----------------------------------------------------------------------------
+SVTK_Selector* 
+SVTK_RenderWindowInteractor
+::GetSelector() 
+{ 
+  return mySelector.GetPointer(); 
+}
+
+
+void
+SVTK_RenderWindowInteractor
+::SetSelector(SVTK_Selector* theSelector)
+{ 
+  if(mySelector.GetPointer())
+    mySelector->RemoveObserver(myEventCallbackCommand.GetPointer());
+
+  mySelector = theSelector; 
+
+  if(mySelector.GetPointer())
+    mySelector->AddObserver(vtkCommand::EndPickEvent, 
+                           myEventCallbackCommand.GetPointer(), 
+                           myPriority);
+}
+
+
+//----------------------------------------------------------------------------
+void 
+SVTK_RenderWindowInteractor
+::ProcessEvents(vtkObject* vtkNotUsed(theObject), 
+               unsigned long theEvent,
+               void* theClientData, 
+               void* vtkNotUsed(theCallData))
+{
+  SVTK_RenderWindowInteractor* self = reinterpret_cast<SVTK_RenderWindowInteractor*>(theClientData);
+
+  switch(theEvent){
+  case vtkCommand::EndPickEvent:
+    self->onEmitSelectionChanged();
+    break;
+  }
+}
+
+
 //----------------------------------------------------------------
 void
 SVTK_RenderWindowInteractor
index 0e544b93e3c2151dcb4c91477a3fe42f0c8cc6f0..6ac251674aa4cce8a93b9039a671b3f61ebdc370 100644 (file)
@@ -48,6 +48,7 @@ class vtkGenericRenderWindowInteractor;
 
 class SALOME_Actor;
 class SVTK_Selector;
+class SVTK_Renderer;
 class SVTK_InteractorStyle;
 
 // ------------------------------------------------------------
@@ -152,15 +153,41 @@ class SVTK_EXPORT SVTK_RenderWindowInteractor: public QVTK_RenderWindowInteracto
 
   ~SVTK_RenderWindowInteractor();
 
-  SVTK_Selector* GetSelector();
-  void SetSelector(SVTK_Selector* theSelector);
+  vtkRenderWindow*
+  getRenderWindow();
+
+  //----------------------------------------------------------------------------
+  void
+  SetRenderer(SVTK_Renderer *theRenderer);
+
+  SVTK_Renderer* 
+  GetRenderer();
 
-  SVTK_InteractorStyle* GetInteractorStyle();
-  void PushInteractorStyle(SVTK_InteractorStyle* theStyle);
-  void PopInteractorStyle();
+  vtkRenderer* 
+  getRenderer();
 
-  Selection_Mode SelectionMode() const;
-  void SetSelectionMode(Selection_Mode theMode);
+  //----------------------------------------------------------------------------
+  SVTK_InteractorStyle* 
+  GetInteractorStyle();
+
+  void
+  PushInteractorStyle(SVTK_InteractorStyle* theStyle);
+
+  void
+  PopInteractorStyle();
+
+  //----------------------------------------------------------------------------
+  SVTK_Selector* 
+  GetSelector();
+
+  void
+  SetSelector(SVTK_Selector* theSelector);
+
+  Selection_Mode 
+  SelectionMode() const;
+
+  void 
+  SetSelectionMode(Selection_Mode theMode);
 
  public:
   void
@@ -210,8 +237,12 @@ class SVTK_EXPORT SVTK_RenderWindowInteractor: public QVTK_RenderWindowInteracto
 
   vtkSmartPointer<SVTK_Selector> mySelector;
 
+  vtkSmartPointer<SVTK_Renderer> myRenderer;
+  vtkSmartPointer<vtkRenderWindow> myRenderWindow;
+
   typedef vtkSmartPointer<SVTK_InteractorStyle> PInteractorStyle;
   QValueStack<PInteractorStyle> myInteractorStyles;
 };
 
+
 #endif
index 1e2ddf70700615ce5949eadd9580339c7ba05163..1cf6e52b8b8b9280736f5a9545669f427e176ee2 100644 (file)
@@ -28,7 +28,6 @@
 #include "SVTK_Event.h"
 #include "SVTK_Renderer.h"
 #include "SVTK_ViewModel.h"
-#include "SVTK_RenderWindow.h"
 #include "SVTK_InteractorStyle.h"
 #include "SVTK_RenderWindowInteractor.h"
 
@@ -55,6 +54,22 @@ SVTK_MainWindow
   createToolBar();
 }
 
+void
+SVTK_MainWindow
+::Initialize()
+{
+  SetInteractor(new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor"));
+
+  SVTK_Renderer* aRenderer = SVTK_Renderer::New();
+  GetInteractor()->SetRenderer(aRenderer);
+  aRenderer->Delete();
+
+  SVTK_InteractorStyle* aStyle = SVTK_InteractorStyle::New();
+  GetInteractor()->PushInteractorStyle(aStyle);
+  aStyle->Delete();
+}
+
+
 //----------------------------------------------------------------------------
 SVTK_MainWindow
 ::~SVTK_MainWindow()
@@ -90,6 +105,13 @@ SVTK_MainWindow
   return GetInteractor()->GetDevice();
 }
 
+vtkRenderWindow*
+SVTK_MainWindow
+::getRenderWindow()
+{
+  return GetInteractor()->getRenderWindow();
+}
+
 //----------------------------------------------------------------------------
 void
 SVTK_MainWindow
@@ -114,7 +136,7 @@ void
 SVTK_MainWindow
 ::InvokeEvent(unsigned long theEvent, void* theCallData)
 {
-  myInteractor->InvokeEvent(theEvent,theCallData);
+  GetInteractor()->InvokeEvent(theEvent,theCallData);
 }
 
 //----------------------------------------------------------------------------
@@ -122,21 +144,21 @@ SVTK_InteractorStyle*
 SVTK_MainWindow
 ::GetInteractorStyle()
 {
-  return myInteractor->GetInteractorStyle();
+  return GetInteractor()->GetInteractorStyle();
 }
 
 void
 SVTK_MainWindow
 ::PushInteractorStyle(SVTK_InteractorStyle* theStyle)
 {
-  myInteractor->PushInteractorStyle(theStyle);
+  GetInteractor()->PushInteractorStyle(theStyle);
 }
 
 void
 SVTK_MainWindow
 ::PopInteractorStyle()
 {
-  myInteractor->PopInteractorStyle();
+  GetInteractor()->PopInteractorStyle();
 }
 
 //----------------------------------------------------------------------------
@@ -144,14 +166,14 @@ SVTK_Selector*
 SVTK_MainWindow
 ::GetSelector()
 {
-  return myInteractor->GetSelector();
+  return GetInteractor()->GetSelector();
 }
 
 void
 SVTK_MainWindow
 ::SetSelector(SVTK_Selector* theSelector)
 {
-  myInteractor->SetSelector(theSelector);
+  GetInteractor()->SetSelector(theSelector);
 }
 
 Selection_Mode
@@ -172,39 +194,23 @@ SVTK_MainWindow
 //----------------------------------------------------------------------------
 void
 SVTK_MainWindow
-::SetRenderWindow(SVTK_RenderWindow *theRenderWindow)
-{
-  myRenderWindow = theRenderWindow;
-}
-
-SVTK_RenderWindow*
-SVTK_MainWindow
-::GetRenderWindow()
+::SetRenderer(SVTK_Renderer* theRenderer)
 {
-  return myRenderWindow.GetPointer();
+  GetInteractor()->SetRenderer(theRenderer);
 }
 
-vtkRenderWindow*
-SVTK_MainWindow
-::getRenderWindow()
-{
-  return myRenderWindow.GetPointer();
-}
-
-
-//----------------------------------------------------------------------------
 SVTK_Renderer* 
 SVTK_MainWindow
 ::GetRenderer()
 {
-  return GetRenderWindow()->GetRenderer();
+  return GetInteractor()->GetRenderer();
 }
 
 vtkRenderer* 
 SVTK_MainWindow
 ::getRenderer()
 {
-  return GetRenderWindow()->GetRenderer();
+  return GetInteractor()->getRenderer();
 }
 
 //----------------------------------------------------------------------------
@@ -654,7 +660,7 @@ QImage
 SVTK_MainWindow
 ::dumpView()
 {
-  QPixmap px = QPixmap::grabWindow( winId() );
+  QPixmap px = QPixmap::grabWindow( GetInteractor()->winId() );
   return px.convertToImage();
 }
 
@@ -665,19 +671,7 @@ SVTK_SignalHandler
   QObject(theMainWindow),
   myMainWindow(theMainWindow)
 {
-  SVTK_RenderWindow* aRenderWindow = SVTK_RenderWindow::New();
-  theMainWindow->SetRenderWindow(aRenderWindow);
-  aRenderWindow->Delete();
-
-  aRenderWindow->SetRenderer(SVTK_Renderer::New());
-
-  SVTK_RenderWindowInteractor* anInteractor = 
-    new SVTK_RenderWindowInteractor(theMainWindow,"SVTK_RenderWindowInteractor");
-  anInteractor->SetRenderWindow(aRenderWindow);
-
-  theMainWindow->SetInteractor(anInteractor);
-
-  anInteractor->PushInteractorStyle(SVTK_InteractorStyle::New());
+  SVTK_RenderWindowInteractor* anInteractor = theMainWindow->GetInteractor();
 
   connect(anInteractor,SIGNAL(KeyPressed(QKeyEvent*)),
          this,SIGNAL(KeyPressed(QKeyEvent*)) );
index c00d9716024ba387213587d000d451dd2451bf3c..1514b8d38b909e99c3b2bee97740c3004fdde960 100644 (file)
@@ -51,6 +51,10 @@ public:
                  const char* theName,
                  SUIT_ResourceMgr* theResourceMgr);
 
+  virtual
+  void
+  Initialize();
+
   virtual
   ~SVTK_MainWindow();
 
@@ -64,6 +68,9 @@ public:
   vtkRenderWindowInteractor*
   getInteractor();
 
+  vtkRenderWindow*
+  getRenderWindow();
+
   void
   Repaint();
 
@@ -98,15 +105,8 @@ public:
 
   //----------------------------------------------------------------------------
   void
-  SetRenderWindow(SVTK_RenderWindow *theRenderWindow);
+  SetRenderer(SVTK_Renderer* theRenderer);
 
-  SVTK_RenderWindow*
-  GetRenderWindow();
-
-  vtkRenderWindow*
-  getRenderWindow();
-
-  //----------------------------------------------------------------------------
   SVTK_Renderer* 
   GetRenderer();
 
@@ -203,7 +203,6 @@ public:
   QToolBar* myToolBar;
 
   SVTK_RenderWindowInteractor* myInteractor;
-  vtkSmartPointer<SVTK_RenderWindow> myRenderWindow;
 };
 
 
index 38ea4162c20dbbf9184d597fe7c6991014149de2..96da68fea8386d5d5849bec2528c0d95d5b8c9ae 100755 (executable)
@@ -44,13 +44,14 @@ SVTK_ViewWindow
   SUIT_ViewWindow(theDesktop)
 {}
 
-//----------------------------------------------------------------------------
 void
 SVTK_ViewWindow
 ::Initialize(SVTK_ViewModelBase* theModel)
 {
   if(SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr()){
     myMainWindow = new SVTK_MainWindow(this,"SVTK_MainWindow",aResourceMgr);
+    myMainWindow->Initialize();
+
     setCentralWidget(myMainWindow);
     
     myView = new SVTK_View(myMainWindow);
@@ -58,7 +59,6 @@ SVTK_ViewWindow
   }
 }
 
-
 void
 SVTK_ViewWindow
 ::Initialize(SVTK_View* theView,
@@ -82,14 +82,11 @@ SVTK_ViewWindow
          theModel,SLOT(onSelectionChanged()));
 }
 
-//----------------------------------------------------------------------------
 SVTK_ViewWindow
 ::~SVTK_ViewWindow()
 {}
 
 
-//----------------------------------------------------------------------------
-//----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
 SVTK_View* 
 SVTK_ViewWindow