]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
To customize vtkRenderWindow
authorapo <apo@opencascade.com>
Thu, 8 Sep 2005 07:32:59 +0000 (07:32 +0000)
committerapo <apo@opencascade.com>
Thu, 8 Sep 2005 07:32:59 +0000 (07:32 +0000)
src/SALOME_PY/SalomePy.cxx
src/SVTK/Makefile.in
src/SVTK/SVTK_InteractorStyle.cxx
src/SVTK/SVTK_RenderWindow.cxx
src/SVTK/SVTK_RenderWindow.h
src/SVTK/SVTK_RenderWindowInteractor.cxx
src/SVTK/SVTK_RenderWindowInteractor.h
src/SVTK/SVTK_Renderer.cxx
src/SVTK/SVTK_Renderer.h
src/SVTK/SVTK_View.cxx
src/SVTK/SVTK_View.h

index ea2fcc9767afeda6b92e41bb243799309e8e26bf..6fa4c45162bf6bdb535b8759829443a1ec08bd71 100755 (executable)
@@ -42,8 +42,6 @@
 
 #include "SVTK_ViewManager.h"
 #include "SVTK_ViewWindow.h"
-#include "SVTK_RenderWindow.h"
-#include "SVTK_RenderWindowInteractor.h"
 
 using namespace std;
 
index f56bd406bd5a61ac4ca892c779f03bb76ae60b48..1bfc3eefe2214be1c655fc05c0f6e890ba375f13 100755 (executable)
@@ -46,7 +46,7 @@ LIB_SRC=      SVTK_Prs.cxx \
                SVTK_ViewModel.cxx \
                SVTK_Renderer.cxx \
                SVTK_ViewWindow.cxx \
-               SVTK_RenderWindow.cxx \
+               SVTK_RenderWindow.cxx\
                SVTK_InteractorStyle.cxx \
                SVTK_RenderWindowInteractor.cxx \
                SVTK_SpaceMouse.cxx \
@@ -54,7 +54,6 @@ LIB_SRC=      SVTK_Prs.cxx \
 
 LIB_MOC =      SVTK_RenderWindowInteractor.h \
                SVTK_InteractorStyle.h \
-               SVTK_RenderWindow.h \
                SVTK_View.h \
                SVTK_ViewWindow.h \
                SVTK_ViewModel.h \
index 7f642941e9694c4d0701feaf582531896cc57397..8b4cd9a75a395340ed096df52769bd6ae74bcf08 100644 (file)
@@ -32,8 +32,6 @@
 #include "VTKViewer_Utilities.h"
 #include "VTKViewer_RectPicker.h"
 
-#include "SVTK_RenderWindow.h"
-#include "SVTK_ViewWindow.h"
 #include "SVTK_Selection.h"
 #include "SVTK_Event.h" 
 #include "SVTK_Selector.h"
@@ -59,6 +57,7 @@
 #include <vtkRendererCollection.h>
 
 #include <qapplication.h>
+#include <qpixmap.h>
 //VRV: porting on Qt 3.0.5
 #if QT_VERSION >= 0x030005
 #include <qpainter.h>
@@ -640,7 +639,9 @@ SVTK_InteractorStyle
 ::eventFilter(QObject* object, QEvent* event)
 {
   if (!myRenderWidget) return false;
-  if ( (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::KeyPress) && object != myRenderWidget)
+  if ( (event->type() == QEvent::MouseButtonPress || 
+       event->type() == QEvent::KeyPress) && 
+       object != myRenderWidget)
   {
     qApp->removeEventFilter(this);
     startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
@@ -1408,3 +1409,5 @@ SVTK_InteractorStyle
   }
   vtkInteractorStyle::ProcessEvents( object, event, clientData, callData );
 }
+
+#include "SVTK_RenderWindow.h"
index b90b3a30b2c32b31aa2a8dd68284b7ac28a62b1a..435265ea311a09c733eb088a99d4acd7c7117771 100644 (file)
@@ -1,57 +1,99 @@
-#include "SVTK_RenderWindow.h"
-#include "SVTK_Trihedron.h"
-#include "SVTK_CubeAxesActor2D.h"
-#include "SALOME_Actor.h"
+//  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 "VTKViewer_Transform.h"
-#include "VTKViewer_Utilities.h"
+#include "SVTK_RenderWindow.h"
 
 #include "SVTK_Renderer.h"
+#include "SVTK_Selector.h"
 
-#include "QtxAction.h"
+#include <vtkObjectFactory.h>
 
-#include "SUIT_Session.h"
-#include "SUIT_ToolButton.h"
-#include "SUIT_MessageBox.h"
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(SVTK_RenderWindow);
 
-#include "SUIT_Tools.h"
-#include "SUIT_ResourceMgr.h"
 
-#include <vtkRenderWindow.h>
+//----------------------------------------------------------------------------
+SVTK_RenderWindow
+::SVTK_RenderWindow():
+  myRenderWidget(NULL)
+{
+}
+
+SVTK_RenderWindow
+::~SVTK_RenderWindow() 
+{}
 
-#if QT_VERSION > 300
-#include <qcursor.h>
-#endif
 
 //----------------------------------------------------------------------------
+SVTK_Renderer* 
 SVTK_RenderWindow
-::SVTK_RenderWindow(QWidget* parent, const char* name) :
-  QMainWindow(parent, name, 
-             Qt::WStyle_NoBorder | 
-             Qt::WDestructiveClose | 
-             Qt::WResizeNoErase | 
-             Qt::WRepaintNoErase),
-    myRenderWindow(vtkRenderWindow::New())
+::GetRenderer()
 {
-  myRenderWindow->Delete();
+  return myRenderer.GetPointer();
+}
 
-#ifndef WNT
-  myRenderWindow->SetDisplayId((void*)x11Display());
-#endif
-  myRenderWindow->SetWindowId((void*)winId());
-  myRenderWindow->DoubleBufferOn();
-  setMouseTracking(true);
+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
-::~SVTK_RenderWindow() 
-{}
+::SetSelector(SVTK_Selector* theSelector)
+{
+  mySelector = theSelector;
+}
 
 
-vtkRenderWindow* 
+//----------------------------------------------------------------------------
+SVTK_RenderWindow::TRenderWidget* 
 SVTK_RenderWindow
-::getRenderWindow()
-{ 
-  return myRenderWindow.GetPointer(); 
+::GetRenderWidget()
+{
+  return myRenderWidget;
+}
+
+void
+SVTK_RenderWindow
+::GetRenderWidget(TRenderWidget* theWidget)
+{
+  myRenderWidget = theWidget;
 }
index 712f1fb6d9f6d3d1bdad895b826011059ee36e3d..2b990ea5116365b480f55865e7a17890c3b300e3 100644 (file)
 #ifndef SVTK_RenderWindow_h
 #define SVTK_RenderWindow_h
 
-#include <vtkSmartPointer.h>
+#include "SVTK.h"
 
-#include <qmainwindow.h>
-#include <qimage.h>
+#include <vtkSmartPointer.h>
 
-#include "SVTK.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();
 
-class vtkRenderer;
-class vtkRenderWindow;
+  SVTK_RenderWindow();
+  virtual ~SVTK_RenderWindow();
 
-class SVTK_EXPORT SVTK_RenderWindow : public QMainWindow
-{
-  Q_OBJECT;
+  SVTK_Renderer* GetRenderer();
+  void SetRenderer(SVTK_Renderer* theRenderer);
 
- public:
-  SVTK_RenderWindow( QWidget*, const char* );
-  virtual ~SVTK_RenderWindow() ;
+  SVTK_Selector* GetSelector();
+  void SetSelector(SVTK_Selector* theSelector);
 
-  vtkRenderWindow* getRenderWindow();
+  typedef QWidget TRenderWidget;
+  TRenderWidget* GetRenderWidget();
+  void GetRenderWidget(TRenderWidget* theWidget);
 
  protected:
-  vtkSmartPointer<vtkRenderWindow> myRenderWindow;
+  vtkSmartPointer<SVTK_Selector> mySelector;
+  vtkSmartPointer<SVTK_Renderer> myRenderer;
+  TRenderWidget* myRenderWidget;
 };
 
+
 #endif
index 98ce10b3e908a7739f3cf77bd9e1aa70405416a1..05abcc19687733cd9c951c2942295ec44e751276 100644 (file)
@@ -232,24 +232,22 @@ QVTK_RenderWindowInteractor
   int aWidth = aSize[0];
   int aHeight = aSize[1];
 
-  //myInteractor->SetSize(width(),height());
   myInteractor->UpdateSize(width(),height());
-  myInteractor->ConfigureEvent();
-
-  if( aWidth != width() || aHeight != height() )
-  {
-    vtkRendererCollection * aRenderers = GetRenderWindow()->GetRenderers();
-    aRenderers->InitTraversal();
-    double aCoeff = 1.0;
-    if(vtkRenderer *aRenderer = aRenderers->GetNextItem())
-    {
-      vtkCamera *aCamera = aRenderer->GetActiveCamera();
-      double aScale = aCamera->GetParallelScale();
-      if((aWidth - width())*(aHeight - height()) > 0)
-        aCoeff = sqrt(double(aWidth)/double(width())*double(height())/double(aHeight));
-      else
-        aCoeff = double(aWidth)/double(width());
-      aCamera->SetParallelScale(aScale*aCoeff);
+
+  if(true || aWidth && aHeight){
+    if( aWidth != width() || aHeight != height() ) {
+      vtkRendererCollection * aRenderers = GetRenderWindow()->GetRenderers();
+      aRenderers->InitTraversal();
+      double aCoeff = 1.0;
+      if(vtkRenderer *aRenderer = aRenderers->GetNextItem()) {
+       vtkCamera *aCamera = aRenderer->GetActiveCamera();
+       double aScale = aCamera->GetParallelScale();
+       if((aWidth - width())*(aHeight - height()) > 0)
+         aCoeff = sqrt(double(aWidth)/double(width())*double(height())/double(aHeight));
+       else
+         aCoeff = double(aWidth)/double(width());
+       aCamera->SetParallelScale(aScale*aCoeff);
+      }
     }
   }
 
index cd5ddbfee27f044877f605c40f09373591c5c2f8..9d9df812bdcfdcc684266ccaa689a9a8bb6bcffb 100644 (file)
@@ -31,7 +31,6 @@
 
 #include "SVTK.h"
 #include "SVTK_Selection.h"
-#include "SVTK_RenderWindow.h"
 
 #include "SALOME_InteractiveObject.hxx"
 
@@ -39,6 +38,7 @@
 #include <vtkGenericRenderWindowInteractor.h>
 
 #include <qvaluestack.h>
+#include <qwidget.h>
 
 class QTimer;
 
index e342545c3917ab60562fd886bc1e1744f38f9e0b..ae067194fa7e01aa3b02fb8fd97f90bc9eb26ba6 100644 (file)
@@ -1,3 +1,31 @@
+//  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_Renderer.h"
 
 #include "SVTK_Trihedron.h"
index 25ad29939fb425b9f6d6ce6fda3308aaaef4b1d2..6f78b4383eadfd38fd6be988ef3733ecab12edd5 100644 (file)
 
 #ifndef VTK_IMPLEMENT_MESA_CXX
 #include <vtkOpenGLRenderer.h>
-#define RENDERER_SUPERCLASS vtkOpenGLRenderer
+#define SVTK_RENDERER_SUPERCLASS vtkOpenGLRenderer
 #else
 #include <vtkMesaRenderer.h>
-#define RENDERER_SUPERCLASS vtkMesaRenderer
+#define SVTK_RENDERER_SUPERCLASS vtkMesaRenderer
 #endif
 
 class vtkCallbackCommand;
@@ -48,7 +48,7 @@ class VTKViewer_Transform;
 class SVTK_CubeAxesActor2D;
 class VTKViewer_Actor;
 
-class SVTK_EXPORT SVTK_Renderer : public RENDERER_SUPERCLASS
+class SVTK_EXPORT SVTK_Renderer : public SVTK_RENDERER_SUPERCLASS
 {
  protected:
   SVTK_Renderer();
@@ -73,7 +73,7 @@ class SVTK_EXPORT SVTK_Renderer : public RENDERER_SUPERCLASS
                             void* calldata);
   
  public:
-  vtkTypeMacro(SVTK_Renderer,RENDERER_SUPERCLASS);
+  vtkTypeMacro(SVTK_Renderer,SVTK_RENDERER_SUPERCLASS);
   static SVTK_Renderer* New();
 
   VTKViewer_Trihedron* GetTrihedron();
index c3665f6f0fa024a690731f3cc68e241333f52f4f..6c162f8a0d085278348466d5a8cfdd0ee8d77c14 100644 (file)
@@ -28,6 +28,7 @@
 #include "SVTK_Event.h"
 #include "SVTK_Renderer.h"
 #include "SVTK_ViewModel.h"
+#include "SVTK_RenderWindow.h"
 #include "SVTK_InteractorStyle.h"
 #include "SVTK_RenderWindowInteractor.h"
 
@@ -537,7 +538,7 @@ SVTK_InteractorHolder
                        const char* theName,
                        SUIT_ResourceMgr* theResourceMgr) :
   SVTK_ActionHolder(theParent,theName,theResourceMgr),
-  myRenderWindow(vtkRenderWindow::New())
+  myRenderWindow(SVTK_RenderWindow::New())
 {
   myRenderWindow->Delete();
 
index 87525dab7b24f366629f8179881b8236695d867e..f5ef4d6c361fc2244d1675788534fcd5a5096cc3 100644 (file)
@@ -215,7 +215,7 @@ public:
 
  protected:  
   SVTK_RenderWindowInteractor* myInteractor;
-  vtkSmartPointer<vtkRenderWindow> myRenderWindow;
+  vtkSmartPointer<SVTK_RenderWindow> myRenderWindow;
 };