]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
To introduce segmentation functionality
authorapo <apo@opencascade.com>
Mon, 12 Sep 2005 04:28:14 +0000 (04:28 +0000)
committerapo <apo@opencascade.com>
Mon, 12 Sep 2005 04:28:14 +0000 (04:28 +0000)
17 files changed:
src/SVTK/Makefile.in
src/SVTK/SALOME_Actor.cxx
src/SVTK/SALOME_Actor.h
src/SVTK/SVTK.cxx [new file with mode: 0644]
src/SVTK/SVTK_Actor.cxx
src/SVTK/SVTK_GenericRenderWindowInteractor.cxx [new file with mode: 0644]
src/SVTK/SVTK_GenericRenderWindowInteractor.h [new file with mode: 0644]
src/SVTK/SVTK_InteractorStyle.cxx
src/SVTK/SVTK_InteractorStyle.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
src/SVTK/SVTK_ViewWindow.cxx
src/SVTK/SVTK_ViewWindow.h

index d81a1e22aa4d6d1403d54be59a534022f764ce27..9e81cb01d0032e5e14f83de7e2aeb3789d6e3e5e 100755 (executable)
@@ -25,6 +25,7 @@ EXPORT_HEADERS= SVTK.h \
                SVTK_Renderer.h \
                SVTK_InteractorStyle.h \
                SVTK_RenderWindowInteractor.h \
+               SVTK_GenericRenderWindowInteractor.h \
                SVTK_Selector.h \
                SVTK_Selection.h \
                SVTK_SelectionEvent.h \
@@ -47,25 +48,29 @@ LIB_SRC=    SVTK_Prs.cxx \
                SVTK_ViewWindow.cxx \
                SVTK_InteractorStyle.cxx \
                SVTK_RenderWindowInteractor.cxx \
+               SVTK_GenericRenderWindowInteractor.cxx \
                SVTK_SpaceMouse.cxx \
                SVTK_Selector.cxx
 
-LIB_MOC =      SVTK_RenderWindowInteractor.h \
-               SVTK_InteractorStyle.h \
-               SVTK_View.h \
+LIB_MOC =      SVTK_GenericRenderWindowInteractor.h \
+               SVTK_RenderWindowInteractor.h \
+               SVTK_ViewModelBase.h \
+               SVTK_ViewManager.h \
                SVTK_ViewWindow.h \
                SVTK_ViewModel.h \
-               SVTK_ViewManager.h \
-               SVTK_ViewModelBase.h
+               SVTK_View.h
 
 LIB_CLIENT_IDL = SALOMEDS.idl \
+                SALOMEDS_Attributes.idl \
                 SALOME_Exception.idl \
                 SALOME_ModuleCatalog.idl \
                 SALOME_GenericObj.idl
 
+BIN = SVTK
+
 CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(BOOST_CPPFLAGS) -I$(KERNEL_ROOT_DIR)/include/salome
 
 LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) -L$(KERNEL_ROOT_DIR)/lib/salome
-LIBS+= -lsuit -lCAM -lSalomeObject -lSalomePrs -lVTKViewer -lOpUtil
+LIBS+= -lsuit -lCAM -lSalomeObject -lSalomePrs -lVTKViewer -lOpUtil -lToolsGUI -lSalomeDS
 
 @CONCLUDE@
index c8ae5aba6ac9ab222275951135222534ce1f838c..2e0257d44c0aa2adea37cc7475b9c8646b605305 100644 (file)
@@ -208,6 +208,16 @@ SALOME_Actor
   theRenderer->RemoveActor( myOutlineActor );
 }
 
+void
+SALOME_Actor
+::AddToInteractor(vtkRenderWindowInteractor* theInteractor)
+{}
+
+void
+SALOME_Actor
+::RemoveFromInteractor(vtkRenderWindowInteractor* theInteractor)
+{}
+
 
 //----------------------------------------------------------------------------
 void
index 06896be1bf583740985e64cfa1917e310a9a3759..ed7d6d1d28e592d59dd3864336430109457c4fd6 100644 (file)
@@ -52,6 +52,8 @@ class vtkPolyDataMapper;
 class vtkOutlineSource;
 class vtkRenderer;
 class vtkInteractorStyle;
+class vtkRenderWindowInteractor;
+
 class VTKViewer_Transform;
 class VTKViewer_GeometryFilter;
 class VTKViewer_TransformFilter;
@@ -320,6 +322,7 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
   void
   SetVisibility( int );
 
+  //----------------------------------------------------------------------------
   virtual
   void
   AddToRender( vtkRenderer* ); 
@@ -328,7 +331,15 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
   void
   RemoveFromRender( vtkRenderer* );
 
-  
+  virtual
+  void
+  AddToInteractor(vtkRenderWindowInteractor* theInteractor);
+
+  virtual
+  void
+  RemoveFromInteractor(vtkRenderWindowInteractor* theInteractor);
+
+  //----------------------------------------------------------------------------
   virtual
   bool
   PreHighlight(        SVTK_Selector*, 
diff --git a/src/SVTK/SVTK.cxx b/src/SVTK/SVTK.cxx
new file mode 100644 (file)
index 0000000..df2b3e9
--- /dev/null
@@ -0,0 +1,33 @@
+//  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$
+
+int
+main(int argc, char** argv)
+{
+  return 0;
+}
index 1ec5fa4b11d9e97e2e9819df5e0e293e35a61985..16faf1791459d9e6dd68af2bd6063196ee965af2 100644 (file)
@@ -31,7 +31,7 @@
 #include <vtkPolyData.h>
 #include <vtkShrinkFilter.h>
 
-//#include "utilities.h"
+#include "utilities.h"
 
 using namespace std;
 
@@ -59,6 +59,8 @@ vtkStandardNewMacro(SVTK_Actor);
 
 SVTK_Actor::SVTK_Actor()
 {
+  if(MYDEBUG) INFOS("SVTK_Actor - "<<this);
+
   myRenderer = NULL;
   myIsInfinite = true;
 
@@ -111,7 +113,7 @@ void SVTK_Actor::UnShrink()
 //----------------------------------------------------------------------------
 SVTK_Actor::~SVTK_Actor()
 {
-  //if(MYDEBUG) INFOS("VTKViewer_Actor::~VTKViewer_Actor()");
+  if(MYDEBUG) INFOS("~SVTK_Actor()");
 
   myMapper->RemoveAllInputs();
   myMapper->Delete();
diff --git a/src/SVTK/SVTK_GenericRenderWindowInteractor.cxx b/src/SVTK/SVTK_GenericRenderWindowInteractor.cxx
new file mode 100644 (file)
index 0000000..0114c0c
--- /dev/null
@@ -0,0 +1,150 @@
+//  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 : SALOME
+//  $Header$
+
+#include "SVTK_GenericRenderWindowInteractor.h"
+#include "SVTK_Selector.h"
+
+#include "utilities.h"
+
+#include <vtkObjectFactory.h>
+#include <vtkCommand.h>
+
+#include <qtimer.h>
+
+using namespace std;
+
+#ifdef _DEBUG_
+static int MYDEBUG = 1;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(QVTK_GenericRenderWindowInteractor);
+
+QVTK_GenericRenderWindowInteractor
+::QVTK_GenericRenderWindowInteractor()
+{
+  if(MYDEBUG) INFOS("QVTK_GenericRenderWindowInteractor() - "<<this);
+  myTimer = new QTimer( ) ;
+  connect(myTimer, SIGNAL(timeout()), this, SLOT(OnTimeOut())) ;
+}
+
+QVTK_GenericRenderWindowInteractor
+::~QVTK_GenericRenderWindowInteractor()
+{
+  if(MYDEBUG) INFOS("~QVTK_GenericRenderWindowInteractor() - "<<this);
+  delete myTimer;
+}
+
+
+//----------------------------------------------------------------------------
+void
+QVTK_GenericRenderWindowInteractor
+::OnTimeOut() 
+{
+  if( GetEnabled() ) {
+    this->InvokeEvent(vtkCommand::TimerEvent,NULL);
+  }
+}
+
+int
+QVTK_GenericRenderWindowInteractor
+::CreateTimer(int vtkNotUsed(timertype)) 
+{
+  //
+  // Start a one-shot timer for <DELAY> ms. 
+  //
+  static int DELAY = 1;
+  myTimer->start(DELAY,TRUE);
+  return 1;
+}
+
+int
+QVTK_GenericRenderWindowInteractor
+::DestroyTimer(void) 
+{
+  //
+  // :TRICKY: Tue May  2 00:17:32 2000 Pagey
+  //
+  // QTimer will automatically expire after 10ms. So 
+  // we do not need to do anything here. In fact, we 
+  // should not even Stop() the QTimer here because doing 
+  // this will skip some of the processing that the TimerFunc()
+  // does and will result in undesirable effects. For 
+  // example, this will result in vtkLODActor to leave
+  // the models in low-res mode after the mouse stops
+  // moving. 
+  //
+  return 1;
+}
+
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(SVTK_GenericRenderWindowInteractor);
+
+SVTK_GenericRenderWindowInteractor
+::SVTK_GenericRenderWindowInteractor():
+  myRenderWidget(NULL)
+{
+  if(MYDEBUG) INFOS("SVTK_GenericRenderWindowInteractor() - "<<this);
+}
+
+SVTK_GenericRenderWindowInteractor
+::~SVTK_GenericRenderWindowInteractor()
+{
+  if(MYDEBUG) INFOS("~SVTK_GenericRenderWindowInteractor() - "<<this);
+}
+
+SVTK_Selector*
+SVTK_GenericRenderWindowInteractor
+::GetSelector()
+{
+  return mySelector.GetPointer();
+}
+
+void
+SVTK_GenericRenderWindowInteractor
+::SetSelector(SVTK_Selector* theSelector)
+{
+  mySelector = theSelector;
+}
+
+QWidget*
+SVTK_GenericRenderWindowInteractor
+::GetRenderWidget()
+{
+  return myRenderWidget;
+}
+
+void
+SVTK_GenericRenderWindowInteractor
+::SetRenderWidget(QWidget* theRenderWidget)
+{
+  myRenderWidget = theRenderWidget;
+}
diff --git a/src/SVTK/SVTK_GenericRenderWindowInteractor.h b/src/SVTK/SVTK_GenericRenderWindowInteractor.h
new file mode 100644 (file)
index 0000000..9cb1066
--- /dev/null
@@ -0,0 +1,108 @@
+//  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 : SALOME
+//  $Header$
+
+#ifndef SVTK_GenericRenderWindowInteractor_h
+#define SVTK_GenericRenderWindowInteractor_h
+
+#include "SVTK.h"
+
+#include <qobject.h>
+#include <vtkGenericRenderWindowInteractor.h>
+#include <vtkSmartPointer.h>
+
+class QTimer;
+class QWidget;
+
+class SVTK_Selector;
+class SVTK_Renderer;
+
+// ------------------------------------------------------------
+// :TRICKY: Fri Apr 21 22:19:27 2000 Pagey
+// The Signal/Slot mechanism used by Qt requires that QObject 
+// appear as the first class when using multiple inheritance. 
+// Hence the order of the two classes QObject and vtkRenderWindowInteractor
+// matters here. Be careful not to change it by accident. 
+// ------------------------------------------------------------
+class SVTK_EXPORT QVTK_GenericRenderWindowInteractor: 
+ public QObject,
+ public vtkGenericRenderWindowInteractor
+{
+  Q_OBJECT;
+
+ public:
+  static QVTK_GenericRenderWindowInteractor* New();
+  vtkTypeMacro(QVTK_GenericRenderWindowInteractor,vtkGenericRenderWindowInteractor);
+
+  virtual
+  int
+  CreateTimer( int ) ; 
+
+  virtual
+  int
+  DestroyTimer() ; 
+
+ protected slots:
+  void
+  OnTimeOut();
+
+ protected:
+  QVTK_GenericRenderWindowInteractor();
+  ~QVTK_GenericRenderWindowInteractor();
+
+  QTimer* myTimer ;
+};
+
+
+// ------------------------------------------------------------
+class SVTK_EXPORT SVTK_GenericRenderWindowInteractor: public QVTK_GenericRenderWindowInteractor
+{
+ public:
+  static SVTK_GenericRenderWindowInteractor* New();
+  vtkTypeMacro(SVTK_GenericRenderWindowInteractor,QVTK_GenericRenderWindowInteractor);
+
+  SVTK_Selector* 
+  GetSelector();
+
+  void
+  SetSelector(SVTK_Selector* theSelector);
+
+  QWidget*
+  GetRenderWidget();
+
+  void
+  SetRenderWidget(QWidget* theRenderWidget);
+
+ protected:
+  SVTK_GenericRenderWindowInteractor();
+  ~SVTK_GenericRenderWindowInteractor();
+
+  vtkSmartPointer<SVTK_Selector> mySelector;
+  QWidget* myRenderWidget;
+};
+
+#endif
index 4fe4eb51e9622cc78f44421d5bf9982695c12de0..c9b2a9a7ed057952df8ac5f0337504df3c65f9f9 100644 (file)
@@ -21,8 +21,8 @@
 //
 //
 //
-//  File   : SVTK_InteractorStyle.cxx
-//  Author : Christophe ATTANASIO
+//  File   : 
+//  Author : 
 //  Module : SALOME
 //  $Header$
 
@@ -31,6 +31,7 @@
 
 #include "VTKViewer_Utilities.h"
 #include "VTKViewer_RectPicker.h"
+#include "SVTK_GenericRenderWindowInteractor.h"
 
 #include "SVTK_Selection.h"
 #include "SVTK_Event.h" 
 using namespace std;
 
 #ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
 #else
 static int MYDEBUG = 0;
 #endif
 
 namespace
 {
-  bool CheckDimensionId(Selection_Mode theMode, SALOME_Actor *theActor, vtkIdType theObjId){
-    switch(theMode){
-    case CellSelection:
-      return true;
-    case EdgeSelection:
-      return ( theActor->GetObjDimension( theObjId ) == 1 );
-    case FaceSelection:
-      return ( theActor->GetObjDimension( theObjId ) == 2 );
-    case VolumeSelection:
-      return ( theActor->GetObjDimension( theObjId ) == 3 );
-    };
-    return false;
+  inline 
+  void
+  GetEventPosition(vtkRenderWindowInteractor* theInteractor,
+                  int& theX, 
+                  int& theY)
+  {
+    theInteractor->GetEventPosition(theX,theY);
+    theY = theInteractor->GetSize()[1] - theY - 1;
   }
 }  
   
@@ -103,6 +100,8 @@ vtkStandardNewMacro(SVTK_InteractorStyle);
 SVTK_InteractorStyle
 ::SVTK_InteractorStyle() 
 {
+  if(MYDEBUG) INFOS("SVTK_InteractorStyle() - "<<this);
+
   this->MotionFactor = 10.0;
   this->State = VTK_INTERACTOR_STYLE_CAMERA_NONE;
   this->RadianToDegree = 180.0 / vtkMath::Pi();
@@ -131,15 +130,22 @@ SVTK_InteractorStyle
 SVTK_InteractorStyle
 ::~SVTK_InteractorStyle() 
 {
-  if(MYDEBUG) INFOS("SVTK_InteractorStyle::~SVTK_InteractorStyle()");
+  if(MYDEBUG) INFOS("~SVTK_InteractorStyle() - "<<this);
 }
 
 //----------------------------------------------------------------------------
+QWidget*
+SVTK_InteractorStyle
+::GetRenderWidget()
+{
+  return myInteractor->GetRenderWidget();
+}
+
 SVTK_Selector*
 SVTK_InteractorStyle
 ::GetSelector() 
 {
-  return mySelector.GetPointer();
+  return myInteractor->GetSelector();
 }
 
 //----------------------------------------------------------------------------
@@ -157,12 +163,11 @@ SVTK_InteractorStyle
 {
   SVTK_SelectionEvent aSelectionEvent;
 
-  int x, y, w, h;
-  Interactor->GetEventPosition( x, y );
-  Interactor->GetSize( w, h );
+  int x, y;
+  GetEventPosition( this->Interactor, x, y );
 
   aSelectionEvent.myX = x;
-  aSelectionEvent.myY = h - y - 1;
+  aSelectionEvent.myY = y;
   aSelectionEvent.myIsCtrl = Interactor->GetControlKey();
   aSelectionEvent.myIsShift = Interactor->GetShiftKey();
   aSelectionEvent.mySelectionMode = GetSelector()->SelectionMode();
@@ -170,22 +175,6 @@ SVTK_InteractorStyle
   return aSelectionEvent;
 }
 
-//----------------------------------------------------------------------------
-void
-SVTK_InteractorStyle
-::SetSelector( SVTK_Selector* theSelector ) 
-{ 
-  mySelector = theSelector; 
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_InteractorStyle
-::SetRenderWidget(QWidget* theWidget)
-{
-  myRenderWidget = theWidget;
-}
-
 //----------------------------------------------------------------------------
 void
 SVTK_InteractorStyle
@@ -287,7 +276,7 @@ SVTK_InteractorStyle
 ::OnMouseMove() 
 {
   int x, y;
-  this->Interactor->GetEventPosition( x, y );
+  GetEventPosition( this->Interactor, x, y );
   this->OnMouseMove( this->Interactor->GetControlKey(),
                     this->Interactor->GetShiftKey(),
                     x, y );
@@ -300,7 +289,7 @@ SVTK_InteractorStyle
 ::OnLeftButtonDown()
 {
   int x, y;
-  this->Interactor->GetEventPosition( x, y );
+  GetEventPosition( this->Interactor, x, y );
   this->OnLeftButtonDown( this->Interactor->GetControlKey(),
                          this->Interactor->GetShiftKey(),
                          x, y );
@@ -313,7 +302,7 @@ SVTK_InteractorStyle
 ::OnLeftButtonUp()
 {
   int x, y;
-  this->Interactor->GetEventPosition( x, y );
+  GetEventPosition( this->Interactor, x, y );
   this->OnLeftButtonUp( this->Interactor->GetControlKey(),
                        this->Interactor->GetShiftKey(),
                        x, y );
@@ -326,7 +315,7 @@ SVTK_InteractorStyle
 ::OnMiddleButtonDown() 
 {
   int x, y;
-  this->Interactor->GetEventPosition( x, y );
+  GetEventPosition( this->Interactor, x, y );
   this->OnMiddleButtonDown( this->Interactor->GetControlKey(),
                            this->Interactor->GetShiftKey(),
                            x, y );
@@ -339,7 +328,7 @@ SVTK_InteractorStyle
 ::OnMiddleButtonUp()
 {
   int x, y;
-  this->Interactor->GetEventPosition( x, y );
+  GetEventPosition( this->Interactor, x, y );
   this->OnMiddleButtonUp( this->Interactor->GetControlKey(),
                          this->Interactor->GetShiftKey(),
                          x, y );
@@ -352,7 +341,7 @@ SVTK_InteractorStyle
 ::OnRightButtonDown() 
 {
   int x, y;
-  this->Interactor->GetEventPosition( x, y );
+  GetEventPosition( this->Interactor, x, y );
   this->OnRightButtonDown( this->Interactor->GetControlKey(),
                           this->Interactor->GetShiftKey(),
                           x, y );
@@ -364,7 +353,7 @@ SVTK_InteractorStyle
 ::OnRightButtonUp()
 {
   int x, y;
-  this->Interactor->GetEventPosition( x, y );
+  GetEventPosition( this->Interactor, x, y );
   this->OnRightButtonUp( this->Interactor->GetControlKey(),
                         this->Interactor->GetShiftKey(),
                         x, y );
@@ -622,35 +611,17 @@ void
 SVTK_InteractorStyle
 ::loadCursors()
 {
-  myDefCursor       = QCursor(ArrowCursor);
-  myHandCursor      = QCursor(PointingHandCursor);
-  myPanCursor       = QCursor(SizeAllCursor);
+  myDefCursor       = QCursor(Qt::ArrowCursor);
+  myHandCursor      = QCursor(Qt::PointingHandCursor);
+  myPanCursor       = QCursor(Qt::SizeAllCursor);
   myZoomCursor      = QCursor(QPixmap(imageZoomCursor));
   myRotateCursor    = QCursor(QPixmap(imageRotateCursor));
   mySpinCursor      = QCursor(QPixmap(imageRotateCursor)); // temporarly !!!!!!
-  myGlobalPanCursor = QCursor(CrossCursor);
+  myGlobalPanCursor = QCursor(Qt::CrossCursor);
   myCursorState     = false;
 }
 
 
-//----------------------------------------------------------------------------
-// event filter - controls mouse and keyboard events during viewer operations
-bool
-SVTK_InteractorStyle
-::eventFilter(QObject* object, QEvent* event)
-{
-  if (!myRenderWidget) return false;
-  if ( (event->type() == QEvent::MouseButtonPress || 
-       event->type() == QEvent::KeyPress) && 
-       object != myRenderWidget)
-  {
-    qApp->removeEventFilter(this);
-    startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
-  }
-  return QObject::eventFilter(object, event);
-}
-
-
 //----------------------------------------------------------------------------
 // starts Zoom operation (e.g. through menu command)
 void
@@ -664,7 +635,6 @@ SVTK_InteractorStyle
   }
   setCursor(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
   ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ZOOM;
-  qApp->installEventFilter(this);
 }
 
 
@@ -681,7 +651,6 @@ SVTK_InteractorStyle
   }
   setCursor(VTK_INTERACTOR_STYLE_CAMERA_PAN);
   ForcedState = VTK_INTERACTOR_STYLE_CAMERA_PAN;
-  qApp->installEventFilter(this);
 }
 
 //----------------------------------------------------------------------------
@@ -697,7 +666,6 @@ SVTK_InteractorStyle
   }
   setCursor(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);
   ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ROTATE;
-  qApp->installEventFilter(this);
 }
 
 
@@ -714,7 +682,6 @@ SVTK_InteractorStyle
   }
   setCursor(VTK_INTERACTOR_STYLE_CAMERA_SPIN);
   ForcedState = VTK_INTERACTOR_STYLE_CAMERA_SPIN;
-  qApp->installEventFilter(this);
 }
 
 
@@ -732,7 +699,6 @@ SVTK_InteractorStyle
   }
   setCursor(VTK_INTERACTOR_STYLE_CAMERA_FIT);
   ForcedState = VTK_INTERACTOR_STYLE_CAMERA_FIT;
-  qApp->installEventFilter(this);
 }
 
 
@@ -751,14 +717,11 @@ SVTK_InteractorStyle
   ForcedState = VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN;
 
   // store current zoom scale
-  vtkCamera *cam = GetCurrentRenderer()->GetActiveCamera();
-  myScale = cam->GetParallelScale();
+  myScale = GetCurrentRenderer()->GetActiveCamera()->GetParallelScale();
 
   GetCurrentRenderer()->ResetCamera();
 
   this->Render();
-  
-  qApp->installEventFilter(this);
 }
 
 
@@ -836,37 +799,37 @@ void
 SVTK_InteractorStyle
 ::setCursor(const int operation)
 {
-  if (!myRenderWidget) return;
+  if (!GetRenderWidget()) return;
   switch (operation)
   {
     case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
-      myRenderWidget->setCursor(myZoomCursor); 
+      GetRenderWidget()->setCursor(myZoomCursor); 
       myCursorState = true;
       break;
     case VTK_INTERACTOR_STYLE_CAMERA_PAN:
-      myRenderWidget->setCursor(myPanCursor); 
+      GetRenderWidget()->setCursor(myPanCursor); 
       myCursorState = true;
       break;
     case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
-      myRenderWidget->setCursor(myRotateCursor); 
+      GetRenderWidget()->setCursor(myRotateCursor); 
       myCursorState = true;
       break;
     case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
-      myRenderWidget->setCursor(mySpinCursor); 
+      GetRenderWidget()->setCursor(mySpinCursor); 
       myCursorState = true;
       break;
     case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
-      myRenderWidget->setCursor(myGlobalPanCursor); 
+      GetRenderWidget()->setCursor(myGlobalPanCursor); 
       myCursorState = true;
       break;
     case VTK_INTERACTOR_STYLE_CAMERA_FIT:
     case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
-      myRenderWidget->setCursor(myHandCursor); 
+      GetRenderWidget()->setCursor(myHandCursor); 
       myCursorState = true;
       break;
     case VTK_INTERACTOR_STYLE_CAMERA_NONE:
     default:
-      myRenderWidget->setCursor(myDefCursor); 
+      GetRenderWidget()->setCursor(myDefCursor); 
       myCursorState = false;
       break;
   }
@@ -879,14 +842,14 @@ void
 SVTK_InteractorStyle
 ::onStartOperation()
 {
-  if (!myRenderWidget) return;
+  if (!GetRenderWidget()) return;
   // VSV: LOD actor activisation
   //  this->Interactor->GetRenderWindow()->SetDesiredUpdateRate(this->Interactor->GetDesiredUpdateRate());
   switch (State) {
     case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
     case VTK_INTERACTOR_STYLE_CAMERA_FIT:
     {
-      QPainter p(myRenderWidget);
+      QPainter p(GetRenderWidget());
       p.setPen(Qt::lightGray);
       p.setRasterOp(Qt::XorROP);
       p.drawRect(QRect(myPoint, myOtherPoint));
@@ -908,7 +871,7 @@ void
 SVTK_InteractorStyle
 ::onFinishOperation() 
 {
-  if (!myRenderWidget
+  if (!GetRenderWidget()
     return;
 
   // VSV: LOD actor activisation
@@ -920,7 +883,7 @@ SVTK_InteractorStyle
     case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
     case VTK_INTERACTOR_STYLE_CAMERA_FIT:
     {
-      QPainter p(myRenderWidget);
+      QPainter p(GetRenderWidget());
       p.setPen(Qt::lightGray);
       p.setRasterOp(Qt::XorROP);
       QRect rect(myPoint, myOtherPoint);
@@ -1032,7 +995,7 @@ void
 SVTK_InteractorStyle
 ::onOperation(QPoint mousePos) 
 {
-  if (!myRenderWidget
+  if (!GetRenderWidget()
     return;
 
   switch (State) {
@@ -1071,7 +1034,7 @@ SVTK_InteractorStyle
     }
   case VTK_INTERACTOR_STYLE_CAMERA_FIT:
     {
-      QPainter p(myRenderWidget);
+      QPainter p(GetRenderWidget());
       p.setPen(Qt::lightGray);
       p.setRasterOp(Qt::XorROP);
       p.drawRect(QRect(myPoint, myOtherPoint));
@@ -1203,40 +1166,42 @@ SVTK_InteractorStyle
 //----------------------------------------------------------------------------
 void
 SVTK_InteractorStyle
-::SetInteractor( vtkRenderWindowInteractor* interactor )
+::SetInteractor( vtkRenderWindowInteractor* theInteractor )
 {
   // register EventCallbackCommand as observer of standard events (keypress, mousemove, etc)
-  vtkInteractorStyle::SetInteractor( interactor );
+  vtkInteractorStyle::SetInteractor( theInteractor );
  
-  if ( interactor ) { 
+  myInteractor = dynamic_cast<SVTK_GenericRenderWindowInteractor*>(theInteractor);
+
+  if ( myInteractor.GetPointer() ) { 
     // register EventCallbackCommand as observer of custorm event (3d space mouse event)
-    interactor->AddObserver( SVTK::SpaceMouseMoveEvent, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::SpaceMouseButtonEvent, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::PanLeftEvent, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::PanRightEvent, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::PanUpEvent, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::PanDownEvent, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::ZoomInEvent, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::ZoomOutEvent, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::RotateLeftEvent, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::RotateRightEvent, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::RotateUpEvent, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::RotateDownEvent, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::PlusSpeedIncrementEvent, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::MinusSpeedIncrementEvent, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::SetSpeedIncrementEvent, EventCallbackCommand, Priority );
-
-    interactor->AddObserver( SVTK::SetSpaceMouseF1Event, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::SetSpaceMouseF2Event, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::SetSpaceMouseF3Event, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::SetSpaceMouseF4Event, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::SetSpaceMouseF5Event, EventCallbackCommand, Priority );
-
-    interactor->AddObserver( SVTK::StartZoom, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::StartPan, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::StartRotate, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::StartGlobalPan, EventCallbackCommand, Priority );
-    interactor->AddObserver( SVTK::StartFitArea, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::SpaceMouseMoveEvent, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::SpaceMouseButtonEvent, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::PanLeftEvent, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::PanRightEvent, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::PanUpEvent, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::PanDownEvent, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::ZoomInEvent, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::ZoomOutEvent, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::RotateLeftEvent, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::RotateRightEvent, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::RotateUpEvent, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::RotateDownEvent, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::PlusSpeedIncrementEvent, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::MinusSpeedIncrementEvent, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::SetSpeedIncrementEvent, EventCallbackCommand, Priority );
+
+    theInteractor->AddObserver( SVTK::SetSpaceMouseF1Event, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::SetSpaceMouseF2Event, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::SetSpaceMouseF3Event, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::SetSpaceMouseF4Event, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::SetSpaceMouseF5Event, EventCallbackCommand, Priority );
+
+    theInteractor->AddObserver( SVTK::StartZoom, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::StartPan, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::StartRotate, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::StartGlobalPan, EventCallbackCommand, Priority );
+    theInteractor->AddObserver( SVTK::StartFitArea, EventCallbackCommand, Priority );
   }
 }
 
@@ -1268,7 +1233,7 @@ SVTK_InteractorStyle
   
   // general things, do SetCurrentRenderer() within FindPokedRenderer() 
   int x, y;
-  Interactor->GetEventPosition( x, y ); // current mouse position (from last mouse move event or any other event)
+  GetEventPosition( this->Interactor, x, y ); // current mouse position (from last mouse move event or any other event)
   FindPokedRenderer( x, y ); // calls SetCurrentRenderer
   
   IncrementalZoom( (int)data[2] );        // 1. push toward / pull backward = zoom out / zoom in
index 26a54d47cefc002c1c81377cb38c363b160de034..a1e5158f971ed731de5b8de5fcd353d3cc8a5902 100644 (file)
 
 #include "SVTK.h"
 
+#include "SVTK_SelectionEvent.h"
+
 #include <vtkInteractorStyle.h>
 #include <vtkSmartPointer.h>
 
-class vtkCell;
-class vtkRenderWindowInteractor;
-
-#include <qobject.h>
 #include <qcursor.h>
 #include <qevent.h>
 
 #include <map>
 
-#include "SVTK_SelectionEvent.h"
-
+class vtkCell;
 class vtkPicker;
 class VTKViewer_RectPicker;
 
-class SALOME_Actor;
-class SVTK_Viewer;
 class SVTK_Selector;
-class SVTK_ViewWindow;
+class SVTK_GenericRenderWindowInteractor;
 
 #define VTK_INTERACTOR_STYLE_CAMERA_NONE    0
 #define VTK_INTERACTOR_STYLE_CAMERA_ROTATE  1
@@ -62,12 +57,8 @@ class SVTK_ViewWindow;
 #define VTK_INTERACTOR_STYLE_CAMERA_SELECT     6
 #define VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN 7
 
-class SVTK_EXPORT SVTK_InteractorStyle : 
-  public QObject,
-  public vtkInteractorStyle
+class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle
 {
-  Q_OBJECT;
-
  public:
   // Description:
   // This class must be supplied with a vtkRenderWindowInteractor wrapper or
@@ -76,11 +67,6 @@ class SVTK_EXPORT SVTK_InteractorStyle :
   static SVTK_InteractorStyle *New();
   vtkTypeMacro(SVTK_InteractorStyle, vtkInteractorStyle);
 
-  void SetSelector( SVTK_Selector* theSelector );
-  SVTK_Selector* GetSelector();
-
-  void SetRenderWidget(QWidget* theRenderWidget);
-
   virtual int GetState();
 
   SVTK_SelectionEvent GetSelectionEvent();
@@ -103,20 +89,15 @@ class SVTK_EXPORT SVTK_InteractorStyle :
   virtual void OnRightButtonDown();
   virtual void OnRightButtonUp();
 
-  void
-  IncrementalPan( const int incrX, const int incrY );
-
-  void
-  IncrementalZoom( const int incr );
-
-  void
-  IncrementalRotate( const int incrX, const int incrY );
-
  protected:
   SVTK_InteractorStyle();
   ~SVTK_InteractorStyle();
-  SVTK_InteractorStyle(const SVTK_InteractorStyle&) {};
-  void operator=(const SVTK_InteractorStyle&) {};
+
+  QWidget*
+  GetRenderWidget();
+
+  SVTK_Selector* 
+  GetSelector();
 
   // Generic event bindings must be overridden in subclasses
   virtual void OnMouseMove  (int ctrl, int shift, int x, int y);
@@ -135,6 +116,15 @@ class SVTK_EXPORT SVTK_InteractorStyle :
   void Place(const int theX, const int theY);
   void TranslateView(int toX, int toY, int fromX, int fromY);
 
+  void
+  IncrementalPan( const int incrX, const int incrY );
+
+  void
+  IncrementalZoom( const int incr );
+
+  void
+  IncrementalRotate( const int incrX, const int incrY );
+
   // custom event handling function (to handle 3d space mouse events)
   static void ProcessEvents( vtkObject* object, unsigned long event,
                             void* clientData, void* callData );
@@ -144,7 +134,6 @@ class SVTK_EXPORT SVTK_InteractorStyle :
   double myScale;
 
  public:
-  bool eventFilter(QObject* object, QEvent* event);
   void startZoom();
   void startPan();
   void startGlobalPan();
@@ -192,6 +181,7 @@ class SVTK_EXPORT SVTK_InteractorStyle :
   
   QWidget*                  myRenderWidget;
   vtkSmartPointer<SVTK_Selector> mySelector;
+  vtkSmartPointer<SVTK_GenericRenderWindowInteractor> myInteractor;
 
   vtkSmartPointer<vtkPicker> myPicker;
   vtkSmartPointer<VTKViewer_RectPicker> myRectPicker;
index 1c6df4d46bc6ba658cbfd6975966b6d77c343114..709505d89d3e9e41c6931782e32c97c9e01fe1e9 100644 (file)
@@ -27,6 +27,7 @@
 //  $Header$
 
 #include "SVTK_RenderWindowInteractor.h"
+#include "SVTK_GenericRenderWindowInteractor.h"
 
 #include "SVTK_InteractorStyle.h"
 #include "SVTK_Renderer.h"
 using namespace std;
 
 #ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
 #else
 static int MYDEBUG = 0;
 #endif
 
 //#define GENERATE_SUIT_EVENTS
 
-//----------------------------------------------------------------------------
-vtkStandardNewMacro(QtRenderWindowInteractor);
-
-QtRenderWindowInteractor
-::QtRenderWindowInteractor()
-{
-  myTimer = new QTimer( ) ;
-  connect(myTimer, SIGNAL(timeout()), this, SLOT(OnTimeOut())) ;
-}
-
-QtRenderWindowInteractor
-::~QtRenderWindowInteractor()
-{
-  delete myTimer;
-}
-
-
-//----------------------------------------------------------------------------
-void
-QtRenderWindowInteractor
-::OnTimeOut() 
-{
-  if( GetEnabled() ) {
-    this->InvokeEvent(vtkCommand::TimerEvent,NULL);
-  }
-}
-
-int
-QtRenderWindowInteractor
-::CreateTimer(int vtkNotUsed(timertype)) 
-{
-  //
-  // Start a one-shot timer for 10ms. 
-  //
-  myTimer->start(1,TRUE);
-  return 1;
-}
-
-int
-QtRenderWindowInteractor
-::DestroyTimer(void) 
-{
-  //
-  // :TRICKY: Tue May  2 00:17:32 2000 Pagey
-  //
-  // QTimer will automatically expire after 10ms. So 
-  // we do not need to do anything here. In fact, we 
-  // should not even Stop() the QTimer here because doing 
-  // this will skip some of the processing that the TimerFunc()
-  // does and will result in undesirable effects. For 
-  // example, this will result in vtkLODActor to leave
-  // the models in low-res mode after the mouse stops
-  // moving. 
-  //
-  return 1;
-}
-
 
 //----------------------------------------------------------------------------
 QVTK_RenderWindowInteractor
 ::QVTK_RenderWindowInteractor(QWidget* theParent, 
                              const char* theName):
-  QWidget(theParent,theName),
-  myInteractor(QtRenderWindowInteractor::New())
+  QWidget(theParent,theName)
 {
-  myInteractor->Delete();
-
+  if(MYDEBUG) INFOS("QVTK_RenderWindowInteractor() - "<<this);
   setMouseTracking(true);
 }
 
@@ -144,17 +86,26 @@ QVTK_RenderWindowInteractor
 QVTK_RenderWindowInteractor
 ::~QVTK_RenderWindowInteractor() 
 {
+  if(MYDEBUG) INFOS("~QVTK_RenderWindowInteractor() - "<<this);
+
   if(SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance())
     if(aSpaceMouse->isSpaceMouseOn())
       aSpaceMouse->close(x11Display());
 }
 
 //----------------------------------------------------------------------------
-vtkRenderWindowInteractor* 
+vtkGenericRenderWindowInteractor* 
 QVTK_RenderWindowInteractor
 ::GetDevice()
 {
-  return myInteractor.GetPointer();
+  return myDevice.GetPointer();
+}
+
+void 
+QVTK_RenderWindowInteractor
+::SetDevice(vtkGenericRenderWindowInteractor* theDevice)
+{
+  myDevice = theDevice;
 }
 
 //----------------------------------------------------------------------------
@@ -162,7 +113,7 @@ void
 QVTK_RenderWindowInteractor
 ::SetRenderWindow(vtkRenderWindow *theRenderWindow)
 {
-  myInteractor->SetRenderWindow(theRenderWindow);
+  GetDevice()->SetRenderWindow(theRenderWindow);
   theRenderWindow->DoubleBufferOn();
 }
 
@@ -170,7 +121,7 @@ vtkRenderWindow*
 QVTK_RenderWindowInteractor
 ::GetRenderWindow()
 {
-  return myInteractor->GetRenderWindow();
+  return GetDevice()->GetRenderWindow();
 }
 
 //----------------------------------------------------------------------------
@@ -178,7 +129,7 @@ void
 QVTK_RenderWindowInteractor
 ::InvokeEvent(unsigned long theEvent, void* theCallData)
 {
-  myInteractor->InvokeEvent(theEvent,theCallData);
+  GetDevice()->InvokeEvent(theEvent,theCallData);
 }
 
 //----------------------------------------------------------------------------
@@ -195,13 +146,13 @@ void
 QVTK_RenderWindowInteractor
 ::polish()
 {
-  // Final initialization just before the widget is displayed.
-  myInteractor->SetSize(width(),height());
+  // Final initialization just before the widget is displayed
+  GetDevice()->SetSize(width(),height());
 #ifndef WNT
   GetRenderWindow()->SetDisplayId((void*)x11Display());
 #endif
   GetRenderWindow()->SetWindowId((void*)winId());
-  myInteractor->Enable();
+  GetDevice()->Enable();
 }
 
 //----------------------------------------------------------------------------
@@ -209,7 +160,7 @@ void
 QVTK_RenderWindowInteractor
 ::resize(int w, int h) 
 {
-  myInteractor->UpdateSize(w,h);
+  GetDevice()->UpdateSize(w,h);
 }
 
 //----------------------------------------------------------------------------
@@ -217,12 +168,12 @@ void
 QVTK_RenderWindowInteractor
 ::paintEvent( QPaintEvent* theEvent ) 
 {
-  if(myInteractor->GetEnabled()){
-    if(!myInteractor->GetInitialized()){
-      myInteractor->Initialize();
-      myInteractor->ConfigureEvent();
+  if(GetDevice()->GetEnabled()){
+    if(!GetDevice()->GetInitialized()){
+      GetDevice()->Initialize();
+      GetDevice()->ConfigureEvent();
     }
-    myInteractor->Render();
+    GetDevice()->Render();
   }
 }
 
@@ -236,9 +187,9 @@ QVTK_RenderWindowInteractor
   int aWidth = aSize[0];
   int aHeight = aSize[1];
 
-  myInteractor->UpdateSize(width(),height());
+  GetDevice()->UpdateSize(width(),height());
 
-  if(aWidth && aHeight){
+  if(isVisible() && aWidth && aHeight){
     if( aWidth != width() || aHeight != height() ) {
       vtkRendererCollection * aRenderers = GetRenderWindow()->GetRenderers();
       aRenderers->InitTraversal();
@@ -271,10 +222,11 @@ void
 QVTK_RenderWindowInteractor
 ::mouseMoveEvent( QMouseEvent* event ) 
 {
-  myInteractor->SetEventInformation( event->x(), event->y(),
-                                    ( event->state() & ControlButton ),
-                                    ( event->state() & ShiftButton ) );
-  myInteractor->MouseMoveEvent();
+  GetDevice()->SetEventInformationFlipY(event->x(), 
+                                       event->y(),
+                                       event->state() & ControlButton,
+                                       event->state() & ShiftButton);
+  GetDevice()->MouseMoveEvent();
 }
 
 
@@ -283,15 +235,16 @@ void
 QVTK_RenderWindowInteractor
 ::mousePressEvent( QMouseEvent* event ) 
 {
-  myInteractor->SetEventInformation( event->x(), event->y(),
-                                    ( event->state() & ControlButton ),
-                                    ( event->state() & ShiftButton ) );
+  GetDevice()->SetEventInformationFlipY(event->x(), 
+                                       event->y(),
+                                       event->state() & ControlButton,
+                                       event->state() & ShiftButton);
   if( event->button() & LeftButton )
-    myInteractor->LeftButtonPressEvent();
+    GetDevice()->LeftButtonPressEvent();
   else if( event->button() & MidButton )
-    myInteractor->MiddleButtonPressEvent();
+    GetDevice()->MiddleButtonPressEvent();
   else if( event->button() & RightButton )
-    myInteractor->RightButtonPressEvent();
+    GetDevice()->RightButtonPressEvent();
 }
 
 
@@ -300,16 +253,17 @@ void
 QVTK_RenderWindowInteractor
 ::mouseReleaseEvent( QMouseEvent *event )
 {
-  myInteractor->SetEventInformation( event->x(), event->y(),
-                                    ( event->state() & ControlButton ),
-                                    ( event->state() & ShiftButton ) );
+  GetDevice()->SetEventInformationFlipY(event->x(), 
+                                       event->y(),
+                                       event->state() & ControlButton,
+                                       event->state() & ShiftButton);
 
   if( event->button() & LeftButton )
-    myInteractor->LeftButtonReleaseEvent();
+    GetDevice()->LeftButtonReleaseEvent();
   else if( event->button() & MidButton )
-    myInteractor->MiddleButtonReleaseEvent();
+    GetDevice()->MiddleButtonReleaseEvent();
   else if( event->button() & RightButton )
-    myInteractor->RightButtonReleaseEvent();
+    GetDevice()->RightButtonReleaseEvent();
 }
 
 
@@ -332,10 +286,11 @@ void
 QVTK_RenderWindowInteractor
 ::keyPressEvent( QKeyEvent* event ) 
 {
-  myInteractor->SetKeyEventInformation( ( event->state() & ControlButton ),
-                                       ( event->state() & ShiftButton ),
-                                       event->key() );
-  myInteractor->KeyPressEvent();
+  GetDevice()->SetKeyEventInformation(event->state() & ControlButton,
+                                     event->state() & ShiftButton,
+                                     event->key());
+  GetDevice()->KeyPressEvent();
+  GetDevice()->CharEvent();
 }
 
 //----------------------------------------------------------------------------
@@ -343,10 +298,10 @@ void
 QVTK_RenderWindowInteractor
 ::keyReleaseEvent( QKeyEvent * event ) 
 {
-  myInteractor->SetKeyEventInformation( ( event->state() & ControlButton ),
-                                       ( event->state() & ShiftButton ),
-                                       event->key() );
-  myInteractor->KeyReleaseEvent();
+  GetDevice()->SetKeyEventInformation(event->state() & ControlButton,
+                                     event->state() & ShiftButton,
+                                     event->key());
+  GetDevice()->KeyReleaseEvent();
 }
 
 
@@ -366,7 +321,7 @@ QVTK_RenderWindowInteractor
     }
   }
 
-  myInteractor->EnterEvent();
+  GetDevice()->EnterEvent();
 }
 
 //----------------------------------------------------------------------------
@@ -382,7 +337,7 @@ QVTK_RenderWindowInteractor
       aSpaceMouse->setWindow(x11Display(),0);
   }
 
-  myInteractor->LeaveEvent();
+  GetDevice()->LeaveEvent();
 }
 
 
@@ -398,10 +353,10 @@ QVTK_RenderWindowInteractor
       int type = aSpaceMouse->translateEvent( x11Display(), xEvent, &anEvent, 1.0, 1.0 );
       switch( type ){
       case SVTK_SpaceMouse::SpaceMouseMove : 
-       myInteractor->InvokeEvent(SVTK::SpaceMouseMoveEvent, anEvent.data );
+       GetDevice()->InvokeEvent(SVTK::SpaceMouseMoveEvent, anEvent.data );
        break;
       case SVTK_SpaceMouse::SpaceButtonPress :
-       myInteractor->InvokeEvent( SVTK::SpaceMouseButtonEvent, &anEvent.button );
+       GetDevice()->InvokeEvent( SVTK::SpaceMouseButtonEvent, &anEvent.button );
        break;
       case SVTK_SpaceMouse::SpaceButtonRelease :
        break;
@@ -422,6 +377,8 @@ SVTK_RenderWindowInteractor
   myEventCallbackCommand(vtkCallbackCommand::New()),
   myRenderWindow(vtkRenderWindow::New())
 {
+  if(MYDEBUG) INFOS("SVTK_RenderWindowInteractor() - "<<this);
+
   myEventCallbackCommand->Delete();
 
   myEventCallbackCommand->SetClientData(this); 
@@ -429,16 +386,26 @@ SVTK_RenderWindowInteractor
 
   myEventCallbackCommand->SetCallback(SVTK_RenderWindowInteractor::ProcessEvents);
 
-  myRenderWindow->Delete();
-  GetDevice()->SetRenderWindow(getRenderWindow()); 
+  SVTK_GenericRenderWindowInteractor* aDevice = SVTK_GenericRenderWindowInteractor::New();
+  SetDevice(aDevice);
+  aDevice->Delete();
+
+  aDevice->SetRenderWidget(this);
 
   SetSelector(SVTK_Selector::New());
   mySelector->Delete();
+
+  aDevice->SetSelector(GetSelector());
+
+  GetDevice()->SetRenderWindow(getRenderWindow()); 
+  myRenderWindow->Delete();
 }
 
 SVTK_RenderWindowInteractor
 ::~SVTK_RenderWindowInteractor() 
-{}
+{
+  if(MYDEBUG) INFOS("~SVTK_RenderWindowInteractor() - "<<this);
+}
 
 vtkRenderWindow* 
 SVTK_RenderWindowInteractor
@@ -460,35 +427,43 @@ vtkRenderer*
 SVTK_RenderWindowInteractor
 ::getRenderer()
 {
-  return GetRenderer();
+  return GetRenderer()->GetDevice();
 }
 
 void
 SVTK_RenderWindowInteractor
 ::SetRenderer(SVTK_Renderer* theRenderer)
 {
-  myRenderWindow->RemoveRenderer(GetRenderer());
+  if(theRenderer == myRenderer.GetPointer())
+    return;
+
+  if(GetRenderer()){
+    myRenderWindow->RemoveRenderer(getRenderer());
+    theRenderer->SetInteractor(NULL);
+  }
+
   myRenderer = theRenderer;
-  myRenderWindow->AddRenderer(GetRenderer());
+
+  if(GetRenderer()){
+    myRenderWindow->AddRenderer(getRenderer());
+    theRenderer->SetInteractor(GetDevice());
+  }
 }
 
 
 //----------------------------------------------------------------------------
 void
 SVTK_RenderWindowInteractor
-::InitInteractorStyle(SVTK_InteractorStyle* theStyle)
+::InitInteractorStyle(vtkInteractorStyle* theStyle)
 {
   GetDevice()->SetInteractorStyle(theStyle); 
-
-  theStyle->SetSelector(GetSelector());
-  theStyle->SetRenderWidget(this);
 }
 
 
 //----------------------------------------------------------------------------
 void
 SVTK_RenderWindowInteractor
-::PushInteractorStyle(SVTK_InteractorStyle* theStyle)
+::PushInteractorStyle(vtkInteractorStyle* theStyle)
 {
   myInteractorStyles.push(PInteractorStyle(theStyle));
   InitInteractorStyle(theStyle);
@@ -509,7 +484,7 @@ SVTK_RenderWindowInteractor
 
 
 //----------------------------------------------------------------------------
-SVTK_InteractorStyle* 
+vtkInteractorStyle* 
 SVTK_RenderWindowInteractor
 ::GetInteractorStyle()
 {
index 6ac251674aa4cce8a93b9039a671b3f61ebdc370..146be1081fe1b7a7ca151ac6140470f561d175f6 100644 (file)
@@ -21,8 +21,8 @@
 //
 //
 //
-//  File   : SVTK_RenderWindowInteractor.h
-//  Author : Nicolas REJNERI
+//  File   : 
+//  Author : 
 //  Module : SALOME
 //  $Header$
 
 #include "SVTK.h"
 #include "SVTK_Selection.h"
 
-#include "SALOME_InteractiveObject.hxx"
-
-#include <vtkSmartPointer.h>
-#include <vtkGenericRenderWindowInteractor.h>
-
-#include <qvaluestack.h>
 #include <qwidget.h>
+#include <qvaluestack.h>
 
-class QTimer;
+#include <vtkSmartPointer.h>
 
-class vtkCallbackCommand;
-class vtkActorCollection;
 class vtkGenericRenderWindowInteractor;
+class vtkInteractorStyle;
+class vtkCallbackCommand;
+class vtkRenderWindow;
+class vtkRenderer;
+class vtkObject;
 
-class SALOME_Actor;
 class SVTK_Selector;
 class SVTK_Renderer;
-class SVTK_InteractorStyle;
-
-// ------------------------------------------------------------
-// :TRICKY: Fri Apr 21 22:19:27 2000 Pagey
-// The Signal/Slot mechanism used by Qt requires that QObject 
-// appear as the first class when using multiple inheritance. 
-// Hence the order of the two classes QObject and vtkRenderWindowInteractor
-// matters here. Be careful not to change it by accident. 
-// ------------------------------------------------------------
-class SVTK_EXPORT QtRenderWindowInteractor: 
- public QObject,
- public vtkGenericRenderWindowInteractor
-{
-  Q_OBJECT;
-
- public:
-  static QtRenderWindowInteractor* New();
-  vtkTypeMacro(QtRenderWindowInteractor,vtkGenericRenderWindowInteractor);
-
-  virtual
-  int
-  CreateTimer( int ) ; 
-
-  virtual
-  int
-  DestroyTimer() ; 
-
- protected slots:
-  virtual
-  void
-  OnTimeOut();
-
- protected:
-  QtRenderWindowInteractor();
-  ~QtRenderWindowInteractor();
-
-  QTimer* myTimer ;
-};
-
 
 // ------------------------------------------------------------
 class SVTK_EXPORT QVTK_RenderWindowInteractor: public QWidget
@@ -100,9 +58,12 @@ class SVTK_EXPORT QVTK_RenderWindowInteractor: public QWidget
 
   ~QVTK_RenderWindowInteractor();
 
-  vtkRenderWindowInteractor* 
+  vtkGenericRenderWindowInteractor* 
   GetDevice();
 
+  void
+  SetDevice(vtkGenericRenderWindowInteractor* theDevice);
+
   void
   SetRenderWindow(vtkRenderWindow *theRenderWindow);
 
@@ -138,7 +99,7 @@ class SVTK_EXPORT QVTK_RenderWindowInteractor: public QWidget
 
   virtual bool x11Event( XEvent *e );
 
-  vtkSmartPointer<vtkGenericRenderWindowInteractor> myInteractor;
+  vtkSmartPointer<vtkGenericRenderWindowInteractor> myDevice;
 };
 
 
@@ -167,11 +128,11 @@ class SVTK_EXPORT SVTK_RenderWindowInteractor: public QVTK_RenderWindowInteracto
   getRenderer();
 
   //----------------------------------------------------------------------------
-  SVTK_InteractorStyle* 
+  vtkInteractorStyle* 
   GetInteractorStyle();
 
   void
-  PushInteractorStyle(SVTK_InteractorStyle* theStyle);
+  PushInteractorStyle(vtkInteractorStyle* theStyle);
 
   void
   PopInteractorStyle();
@@ -219,7 +180,7 @@ class SVTK_EXPORT SVTK_RenderWindowInteractor: public QVTK_RenderWindowInteracto
   virtual void contextMenuEvent( QContextMenuEvent * e );
 
   void
-  InitInteractorStyle(SVTK_InteractorStyle* theStyle);
+  InitInteractorStyle(vtkInteractorStyle* theStyle);
 
   // Main process VTK event method
   static
@@ -240,7 +201,7 @@ class SVTK_EXPORT SVTK_RenderWindowInteractor: public QVTK_RenderWindowInteracto
   vtkSmartPointer<SVTK_Renderer> myRenderer;
   vtkSmartPointer<vtkRenderWindow> myRenderWindow;
 
-  typedef vtkSmartPointer<SVTK_InteractorStyle> PInteractorStyle;
+  typedef vtkSmartPointer<vtkInteractorStyle> PInteractorStyle;
   QValueStack<PInteractorStyle> myInteractorStyles;
 };
 
index d04ad8936c66ed47fde3ac7f7c9336a4a7301537..bf499d37543d69b910a9c4b7c9239e8b7ca053b3 100644 (file)
 #include "SVTK_Trihedron.h"
 #include "SVTK_CubeAxesActor2D.h"
 
-#include "VTKViewer_Actor.h"
 #include "SALOME_Actor.h"
-
+#include "VTKViewer_Actor.h"
 #include "VTKViewer_Transform.h"
 #include "VTKViewer_Utilities.h"
 
-#include "SUIT_Session.h"
-#include "SUIT_ResourceMgr.h"
-
 #include <vtkCamera.h>
+#include <vtkRenderer.h>
 #include <vtkTextProperty.h>
 #include <vtkObjectFactory.h>
 #include <vtkCallbackCommand.h>
 
+#include "utilities.h"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 1;
+#else
+static int MYDEBUG = 0;
+#endif
+
 
 //----------------------------------------------------------------------------
 vtkStandardNewMacro(SVTK_Renderer);
@@ -52,6 +57,8 @@ vtkStandardNewMacro(SVTK_Renderer);
 //----------------------------------------------------------------------------
 SVTK_Renderer
 ::SVTK_Renderer():
+  myDevice(vtkRenderer::New()),
+  myInteractor(NULL),
   myTransform(VTKViewer_Transform::New()),
   myCubeAxes(SVTK_CubeAxesActor2D::New()),
   myTrihedron(SVTK_Trihedron::New()),
@@ -59,62 +66,60 @@ SVTK_Renderer
   myPriority(0.0),
   myEventCallbackCommand(vtkCallbackCommand::New())
 {
+  if(MYDEBUG) INFOS("SVTK_Renderer() - "<<this);
+
   myTransform->Delete();
   myTrihedron->Delete();
   myCubeAxes->Delete();
   myEventCallbackCommand->Delete();
 
-  myTrihedron->AddToRender(this);
-  this->AddProp(GetCubeAxes());
+  myTrihedron->AddToRender(GetDevice());
+  GetDevice()->AddProp(GetCubeAxes());
 
-  vtkTextProperty* aTextProp = vtkTextProperty::New();
-  aTextProp->SetColor(1, 1, 1);
-  aTextProp->ShadowOn();
-  
-  float aBndBox[6];
-  aBndBox[0] = aBndBox[2] = aBndBox[4] = 0;
-  aBndBox[1] = aBndBox[3] = aBndBox[5] = myTrihedron->GetSize();
-  myCubeAxes->SetBounds(aBndBox);
-  myCubeAxes->SetCamera(this->GetActiveCamera());
+  myBndBox[0] = myBndBox[2] = myBndBox[4] = 0;
+  myBndBox[1] = myBndBox[3] = myBndBox[5] = myTrihedron->GetSize();
+
+  myCubeAxes->SetBounds(myBndBox);
+  myCubeAxes->SetCamera(GetDevice()->GetActiveCamera());
 
   myCubeAxes->SetLabelFormat("%6.4g");
   myCubeAxes->SetFlyModeToOuterEdges(); // ENK remarks: it must bee
   myCubeAxes->SetFontFactor(0.8);
-  myCubeAxes->SetAxisTitleTextProperty(aTextProp);
-  myCubeAxes->SetAxisLabelTextProperty(aTextProp);
   myCubeAxes->SetCornerOffset(0);
   myCubeAxes->SetScaling(0);
   myCubeAxes->SetNumberOfLabels(5);
   myCubeAxes->VisibilityOff();
   myCubeAxes->SetTransform(GetTransform());
-  aTextProp->Delete();
 
-  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
-  QColor aColor = aResMgr->colorValue("VTKViewer","background",QColor());
-  this->SetBackground(aColor.red()/255.0,
-                     aColor.green()/255.0,
-                     aColor.blue()/255.0);
+  vtkTextProperty* aTextProp = vtkTextProperty::New();
+  aTextProp->SetColor(1, 1, 1);
+  aTextProp->ShadowOn();
+  myCubeAxes->SetAxisTitleTextProperty(aTextProp);
+  myCubeAxes->SetAxisLabelTextProperty(aTextProp);
+  aTextProp->Delete();
 
-  this->GetActiveCamera()->ParallelProjectionOn();
-  this->LightFollowCameraOn();
-  this->TwoSidedLightingOn();
+  GetDevice()->GetActiveCamera()->ParallelProjectionOn();
+  GetDevice()->LightFollowCameraOn();
+  GetDevice()->TwoSidedLightingOn();
 
   myEventCallbackCommand->SetClientData(this);
   myEventCallbackCommand->SetCallback(SVTK_Renderer::ProcessEvents);
-  this->AddObserver(vtkCommand::ConfigureEvent,
-                   myEventCallbackCommand.GetPointer(), 
-                   myPriority);
-  this->AddObserver(vtkCommand::ResetCameraEvent,
-                   myEventCallbackCommand.GetPointer(), 
-                   myPriority);
-  this->AddObserver(vtkCommand::ResetCameraClippingRangeEvent,
-                   myEventCallbackCommand.GetPointer(), 
-                   myPriority);
+  GetDevice()->AddObserver(vtkCommand::ConfigureEvent,
+                          myEventCallbackCommand.GetPointer(), 
+                          myPriority);
+  GetDevice()->AddObserver(vtkCommand::ResetCameraEvent,
+                          myEventCallbackCommand.GetPointer(), 
+                          myPriority);
+  GetDevice()->AddObserver(vtkCommand::ResetCameraClippingRangeEvent,
+                          myEventCallbackCommand.GetPointer(), 
+                          myPriority);
 }
 
 SVTK_Renderer
 ::~SVTK_Renderer()
-{}
+{
+  if(MYDEBUG) INFOS("~SVTK_Renderer() - "<<this);
+}
 
 
 void 
@@ -128,60 +133,75 @@ SVTK_Renderer
 
   switch(theEvent){
   case vtkCommand::ConfigureEvent:
-    self->onResetView();
+    self->OnResetView();
     break;
   case vtkCommand::ResetCameraEvent:
-    self->onFitAll();
+    self->OnFitAll();
     break;
   case vtkCommand::ResetCameraClippingRangeEvent:
-    self->onResetClippingRange();
+    self->OnResetClippingRange();
     break;
   }
 }
+
 //----------------------------------------------------------------------------
-SVTK_CubeAxesActor2D
+vtkRenderer
 SVTK_Renderer
-::GetCubeAxes()
+::GetDevice()
 {
-  return myCubeAxes.GetPointer();
+  return myDevice.GetPointer();
 }
 
-bool
+void 
 SVTK_Renderer
-::isCubeAxesDisplayed()
+::SetInteractor(vtkRenderWindowInteractor* theInteractor)
 {
-  return myCubeAxes->GetVisibility() == 1;
+  myInteractor = theInteractor;
 }
 
-VTKViewer_Trihedron* 
+//----------------------------------------------------------------------------
+void
 SVTK_Renderer
-::GetTrihedron()
+::AddActor(VTKViewer_Actor* theActor)
 {
-  return myTrihedron.GetPointer();
+  if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(theActor))
+    anActor->AddToInteractor(myInteractor);
+  theActor->SetTransform(GetTransform());
+  theActor->AddToRender(GetDevice());
+  AdjustActors();
 }
 
-bool
+void
 SVTK_Renderer
-::isTrihedronDisplayed()
+::RemoveActor(VTKViewer_Actor* theActor)
 {
-  return myTrihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
+  if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(theActor))
+    anActor->RemoveFromInteractor(myInteractor);
+  theActor->SetTransform(NULL);
+  theActor->RemoveFromRender(GetDevice());
+  AdjustActors();
 }
 
-int
+VTKViewer_Transform* 
 SVTK_Renderer
-::GetTrihedronSize() const
+::GetTransform()
 {
-  return myTrihedronSize;
+  return myTransform.GetPointer();
 }
 
 void
 SVTK_Renderer
-::SetTrihedronSize(int theSize)
+::GetScale( double theScale[3] ) 
 {
-  if(myTrihedronSize != theSize){
-    myTrihedronSize = theSize;
-    AdjustTrihedrons(true);
-  }
+  myTransform->GetMatrixScale( theScale );
+}
+
+void
+SVTK_Renderer
+::SetScale( double theScale[3] ) 
+{
+  myTransform->SetMatrixScale( theScale[0], theScale[1], theScale[2] );
+  AdjustActors();
 }
 
 
@@ -201,51 +221,39 @@ CheckBndBox(const float theBounds[6])
   return false;
 }
 
-void
+bool
 SVTK_Renderer
-::AdjustTrihedrons(const bool theIsForced)
+::OnAdjustActors()
 {
-  bool aTDisplayed = isTrihedronDisplayed();
-  bool aCDisplayed = isCubeAxesDisplayed();
-
-  if(!aCDisplayed && !aTDisplayed && !theIsForced)
-    return;
-
-  float aBndBox[ 6 ];
-  myCubeAxes->GetBounds(aBndBox);
+  bool aTDisplayed = IsTrihedronDisplayed();
+  bool aCDisplayed = IsCubeAxesDisplayed();
 
   float aNewBndBox[6];
   aNewBndBox[ 0 ] = aNewBndBox[ 2 ] = aNewBndBox[ 4 ] = VTK_LARGE_FLOAT;
   aNewBndBox[ 1 ] = aNewBndBox[ 3 ] = aNewBndBox[ 5 ] = -VTK_LARGE_FLOAT;
 
-  int aVisibleNum = myTrihedron->GetVisibleActorCount(this);
+  int aVisibleNum = myTrihedron->GetVisibleActorCount(GetDevice());
   if(aVisibleNum){
-    // if the new trihedron size have sufficient difference, then apply the value
-    double aNewSize = 100;
-    double anOldSize = myTrihedron->GetSize();
-
     if(aTDisplayed)
       myTrihedron->VisibilityOff();
 
     if(aCDisplayed) 
       myCubeAxes->VisibilityOff();
 
-    static SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
-    float aSizeInPercents = aResMgr->doubleValue("VTKViewer","trihedron_size", 105);
-
-    ComputeTrihedronSize(this,aNewSize,anOldSize,aSizeInPercents);
-
-    myTrihedron->SetSize(aNewSize);
+    // if the new trihedron size have sufficient difference, then apply the value
+    double aSize = myTrihedron->GetSize();
+    ComputeTrihedronSize(GetDevice(),aSize,aSize,myTrihedronSize);
+    myTrihedron->SetSize(aSize);
 
     // iterate through displayed objects and set size if necessary
-    vtkActorCollection* anActors = this->GetActors();
+    vtkActorCollection* anActors = GetDevice()->GetActors();
     anActors->InitTraversal();
-    while(vtkActor* anActor = anActors->GetNextActor()){
-      if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast( anActor )){
-       if(aSActor->IsResizable())
-         aSActor->SetSize(0.5 * aNewSize);
-        if(aSActor->GetVisibility() && !aSActor->IsInfinitive()){
-         float *aBounds = aSActor->GetBounds();
+    while(vtkActor* anAct = anActors->GetNextActor()){
+      if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(anAct)){
+       if(anActor->IsResizable())
+         anActor->SetSize(0.5*aSize);
+        if(anActor->GetVisibility() && !anActor->IsInfinitive()){
+         float *aBounds = anActor->GetBounds();
           if(CheckBndBox(aBounds))
            for(int i = 0; i < 5; i = i + 2){
              if(aBounds[i] < aNewBndBox[i]) 
@@ -269,107 +277,124 @@ SVTK_Renderer
     aNewBndBox[1] = aNewBndBox[3] = aNewBndBox[5] = aSize;
   }
   
-  if(CheckBndBox(aNewBndBox))
-    myCubeAxes->SetBounds(aNewBndBox);
+  if(CheckBndBox(aNewBndBox)){
+    for(int i = 0; i < 6; i++)
+      myBndBox[i] = aNewBndBox[i];
+    myCubeAxes->SetBounds(myBndBox);
+    return true;
+  }
 
-  ::ResetCameraClippingRange(this);
+  return false;
 }
 
-
-//----------------------------------------------------------------------------
-void 
+void
 SVTK_Renderer
-::onViewTrihedron()
+::AdjustActors()
 {
-  if(isTrihedronDisplayed())
-    myTrihedron->VisibilityOff();
-  else
-    myTrihedron->VisibilityOn();
+  if(OnAdjustActors())
+    ::ResetCameraClippingRange(GetDevice());
 }
 
 void
 SVTK_Renderer
-::onViewCubeAxes()
+::SetTrihedronSize(int theSize)
 {
-  if(isCubeAxesDisplayed())
-    myCubeAxes->VisibilityOff();
-  else
-    myCubeAxes->VisibilityOn();
+  if(myTrihedronSize != theSize){
+    myTrihedronSize = theSize;
+    AdjustActors();
+  }
+}
+
+int
+SVTK_Renderer
+::GetTrihedronSize() const
+{
+  return myTrihedronSize;
 }
 
 
 //----------------------------------------------------------------------------
-void
+VTKViewer_Trihedron* 
 SVTK_Renderer
-::onAdjustTrihedron()
-{   
-  AdjustTrihedrons(false);
+::GetTrihedron()
+{
+  return myTrihedron.GetPointer();
 }
 
-void
+bool
 SVTK_Renderer
-::onAdjustCubeAxes()
-{   
-  AdjustTrihedrons(false);
+::IsTrihedronDisplayed()
+{
+  return myTrihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
 }
 
-
-//----------------------------------------------------------------------------
-VTKViewer_Transform* 
+void 
 SVTK_Renderer
-::GetTransform()
+::OnViewTrihedron()
 {
-  return myTransform.GetPointer();
+  if(IsTrihedronDisplayed())
+    myTrihedron->VisibilityOff();
+  else
+    myTrihedron->VisibilityOn();
 }
 
 void
 SVTK_Renderer
-::GetScale( double theScale[3] ) 
-{
-  myTransform->GetMatrixScale( theScale );
+::OnAdjustTrihedron()
+{   
+  AdjustActors();
 }
 
-void
+
+//----------------------------------------------------------------------------
+SVTK_CubeAxesActor2D* 
 SVTK_Renderer
-::SetScale( double theScale[3] ) 
+::GetCubeAxes()
 {
-  myTransform->SetMatrixScale( theScale[0], theScale[1], theScale[2] );
+  return myCubeAxes.GetPointer();
 }
 
+bool
+SVTK_Renderer
+::IsCubeAxesDisplayed()
+{
+  return myCubeAxes->GetVisibility() == 1;
+}
 
-//----------------------------------------------------------------------------
 void
 SVTK_Renderer
-::AddActor(VTKViewer_Actor* theActor)
+::OnViewCubeAxes()
 {
-  theActor->SetTransform(GetTransform());
-  theActor->AddToRender(this);
+  if(IsCubeAxesDisplayed())
+    myCubeAxes->VisibilityOff();
+  else
+    myCubeAxes->VisibilityOn();
 }
 
 void
 SVTK_Renderer
-::RemoveActor(VTKViewer_Actor* theActor)
-{
-  theActor->RemoveFromRender(this);
+::OnAdjustCubeAxes()
+{   
+  AdjustActors();
 }
 
 
 //----------------------------------------------------------------------------
 void
 SVTK_Renderer
-::onResetView()
+::OnResetView()
 {
-  int aTrihedronIsVisible = isTrihedronDisplayed();
-  int aCubeAxesIsVisible = isCubeAxesDisplayed();
+  int aTrihedronIsVisible = IsTrihedronDisplayed();
+  int aCubeAxesIsVisible = IsCubeAxesDisplayed();
 
   myTrihedron->SetVisibility( VTKViewer_Trihedron::eOnlyLineOn );
   myCubeAxes->SetVisibility(0);
 
-  ::ResetCamera(this,true);  
-  vtkCamera* aCamera = this->GetActiveCamera();
+  ::ResetCamera(GetDevice(),true);  
+  vtkCamera* aCamera = GetDevice()->GetActiveCamera();
   aCamera->SetPosition(1,-1,1);
   aCamera->SetViewUp(0,0,1);
-  ::ResetCamera(this,true);  
+  ::ResetCamera(GetDevice(),true);  
 
   if(aTrihedronIsVisible) 
     myTrihedron->VisibilityOn();
@@ -389,27 +414,27 @@ SVTK_Renderer
 //----------------------------------------------------------------------------
 void
 SVTK_Renderer
-::onFitAll()
+::OnFitAll()
 {
   int aTrihedronWasVisible = false;
   int aCubeAxesWasVisible = false;
 
-  aTrihedronWasVisible = isTrihedronDisplayed();
+  aTrihedronWasVisible = IsTrihedronDisplayed();
   if(aTrihedronWasVisible)
     myTrihedron->VisibilityOff();
 
-  aCubeAxesWasVisible = isCubeAxesDisplayed();
+  aCubeAxesWasVisible = IsCubeAxesDisplayed();
   if(aCubeAxesWasVisible)
     myCubeAxes->VisibilityOff();
 
-  if(myTrihedron->GetVisibleActorCount(this)){
+  if(myTrihedron->GetVisibleActorCount(GetDevice())){
     myTrihedron->VisibilityOff();
     myCubeAxes->VisibilityOff();
-    ::ResetCamera(this);
+    ::ResetCamera(GetDevice());
   }else{
     myTrihedron->SetVisibility(VTKViewer_Trihedron::eOnlyLineOn);
     myCubeAxes->SetVisibility(2);
-    ::ResetCamera(this,true);
+    ::ResetCamera(GetDevice(),true);
   }
 
   if(aTrihedronWasVisible)
@@ -422,88 +447,88 @@ SVTK_Renderer
   else
     myCubeAxes->VisibilityOff();
 
-  ::ResetCameraClippingRange(this);
+  ::ResetCameraClippingRange(GetDevice());
 }
 
 
 //----------------------------------------------------------------------------
 void
 SVTK_Renderer
-::onResetClippingRange()
+::OnResetClippingRange()
 {
   return;
-  ::ResetCameraClippingRange(this);
+  ::ResetCameraClippingRange(GetDevice());
 }
 
 
 //----------------------------------------------------------------------------
 void
 SVTK_Renderer
-::onFrontView()
+::OnFrontView()
 {
-  vtkCamera* aCamera = this->GetActiveCamera();
+  vtkCamera* aCamera = GetDevice()->GetActiveCamera();
   aCamera->SetPosition(1,0,0);
   aCamera->SetViewUp(0,0,1);
   aCamera->SetFocalPoint(0,0,0);
-  this->onFitAll();
+  this->OnFitAll();
 }
 
 //----------------------------------------------------------------------------
 void
 SVTK_Renderer
-::onBackView()
+::OnBackView()
 {
-  vtkCamera* aCamera = this->GetActiveCamera();
+  vtkCamera* aCamera = GetDevice()->GetActiveCamera();
   aCamera->SetPosition(-1,0,0);
   aCamera->SetViewUp(0,0,1);
   aCamera->SetFocalPoint(0,0,0);
-  this->onFitAll();
+  this->OnFitAll();
 }
 
 //----------------------------------------------------------------------------
 void
 SVTK_Renderer
-::onTopView()
+::OnTopView()
 {
-  vtkCamera* aCamera = this->GetActiveCamera();
+  vtkCamera* aCamera = GetDevice()->GetActiveCamera();
   aCamera->SetPosition(0,0,1);
   aCamera->SetViewUp(0,1,0);
   aCamera->SetFocalPoint(0,0,0);
-  this->onFitAll();
+  this->OnFitAll();
 }
 
 //----------------------------------------------------------------------------
 void
 SVTK_Renderer
-::onBottomView()
+::OnBottomView()
 {
-  vtkCamera* aCamera = this->GetActiveCamera();
+  vtkCamera* aCamera = GetDevice()->GetActiveCamera();
   aCamera->SetPosition(0,0,-1);
   aCamera->SetViewUp(0,1,0);
   aCamera->SetFocalPoint(0,0,0);
-  this->onFitAll();
+  this->OnFitAll();
 }
 
 //----------------------------------------------------------------------------
 void
 SVTK_Renderer
-::onLeftView()
+::OnLeftView()
 {
-  vtkCamera* aCamera = this->GetActiveCamera(); 
+  vtkCamera* aCamera = GetDevice()->GetActiveCamera(); 
   aCamera->SetPosition(0,-1,0);
   aCamera->SetViewUp(0,0,1);
   aCamera->SetFocalPoint(0,0,0);
-  this->onFitAll();
+  this->OnFitAll();
 }
 
 //----------------------------------------------------------------------------
 void
 SVTK_Renderer
-::onRightView()
+::OnRightView()
 {
-  vtkCamera* aCamera = this->GetActiveCamera();
+  vtkCamera* aCamera = GetDevice()->GetActiveCamera();
   aCamera->SetPosition(0,1,0);
   aCamera->SetViewUp(0,0,1);
   aCamera->SetFocalPoint(0,0,0);
-  this->onFitAll();
+  this->OnFitAll();
 }
index feb48827f5528339a89994f572651c8a61beb659..18186da7c1499bfb3a7f0b6224f16b2ee699f873 100644 (file)
@@ -21,8 +21,8 @@
 //
 //
 //
-//  File   : VTKViewer_RenderWindow.h
-//  Author : Nicolas REJNERI
+//  File   : 
+//  Author : 
 //  Module : SALOME
 //  $Header$
 
 
 #include "SVTK.h"
 
+#include <vtkObject.h>
 #include <vtkSmartPointer.h>
 
-#ifndef VTK_IMPLEMENT_MESA_CXX
-#include <vtkOpenGLRenderer.h>
-#define SVTK_RENDERER_SUPERCLASS vtkOpenGLRenderer
-#else
-#include <vtkMesaRenderer.h>
-#define SVTK_RENDERER_SUPERCLASS vtkMesaRenderer
-#endif
-
+class vtkRenderer;
 class vtkCallbackCommand;
+class vtkRenderWindowInteractor;
 
 class VTKViewer_Trihedron;
 class VTKViewer_Transform;
 class SVTK_CubeAxesActor2D;
 class VTKViewer_Actor;
 
-class SVTK_EXPORT SVTK_Renderer : public SVTK_RENDERER_SUPERCLASS
+class SVTK_EXPORT SVTK_Renderer : public vtkObject
 {
+ public:
+  vtkTypeMacro(SVTK_Renderer,vtkObject);
+  static SVTK_Renderer* New();
+
+  //----------------------------------------------------------------------------
+  vtkRenderer* 
+  GetDevice();
+
+  virtual
+  void 
+  SetInteractor(vtkRenderWindowInteractor* theInteractor);
+
+  //----------------------------------------------------------------------------
+  virtual
+  void 
+  AddActor(VTKViewer_Actor* theActor);
+
+  virtual
+  void 
+  RemoveActor(VTKViewer_Actor* theActor);
+
+  VTKViewer_Transform* 
+  GetTransform();
+
+  virtual
+  void
+  SetScale( double theScale[3] );
+
+  void
+  GetScale( double theScale[3] );
+
+  //----------------------------------------------------------------------------
+  void
+  AdjustActors();
+
+  void
+  SetTrihedronSize(int theSize);
+  int  
+  GetTrihedronSize() const;
+
+  //----------------------------------------------------------------------------
+  VTKViewer_Trihedron* 
+  GetTrihedron();
+
+  bool 
+  IsTrihedronDisplayed();
+
+  void 
+  OnViewTrihedron(); 
+
+  void 
+  OnAdjustTrihedron();
+
+  //----------------------------------------------------------------------------
+  SVTK_CubeAxesActor2D* 
+  GetCubeAxes();
+
+  bool 
+  IsCubeAxesDisplayed();
+
+  void 
+  OnViewCubeAxes();
+
+  void 
+  OnAdjustCubeAxes();
+
+  //----------------------------------------------------------------------------
+  void OnFitAll();
+  void OnResetView();     
+  void OnResetClippingRange();
+
+  void OnFrontView(); 
+  void OnBackView(); 
+  void OnTopView();
+  void OnBottomView();
+  void OnRightView(); 
+  void OnLeftView();     
+
  protected:
   SVTK_Renderer();
   ~SVTK_Renderer();
 
-  vtkSmartPointer<VTKViewer_Transform> myTransform;
-  vtkSmartPointer<SVTK_CubeAxesActor2D> myCubeAxes;
-  vtkSmartPointer<VTKViewer_Trihedron> myTrihedron;  
-  int myTrihedronSize;
+  virtual
+  bool
+  OnAdjustActors();
 
   // Priority at which events are processed
   float myPriority;
@@ -72,43 +145,14 @@ class SVTK_EXPORT SVTK_Renderer : public SVTK_RENDERER_SUPERCLASS
                             void* clientdata, 
                             void* calldata);
   
- public:
-  vtkTypeMacro(SVTK_Renderer,SVTK_RENDERER_SUPERCLASS);
-  static SVTK_Renderer* New();
-
-  VTKViewer_Trihedron* GetTrihedron();
-  SVTK_CubeAxesActor2D* GetCubeAxes();
-
-  bool isTrihedronDisplayed();
-  bool isCubeAxesDisplayed();
+  vtkSmartPointer<vtkRenderer> myDevice;
+  vtkRenderWindowInteractor* myInteractor;
 
-  int  GetTrihedronSize() const;
-  void SetTrihedronSize(int theSize);
-  void AdjustTrihedrons(bool theIsForced);
-
-  void onViewTrihedron(); 
-  void onViewCubeAxes();
-
-  void onAdjustTrihedron();
-  void onAdjustCubeAxes();
-
-  VTKViewer_Transform* GetTransform();
-  void SetScale( double theScale[3] );
-  void GetScale( double theScale[3] );
-
-  void AddActor(VTKViewer_Actor* theActor);
-  void RemoveActor(VTKViewer_Actor* theActor);
-
-  void onFitAll();
-  void onResetView();     
-  void onResetClippingRange();
-
-  void onFrontView(); 
-  void onBackView(); 
-  void onTopView();
-  void onBottomView();
-  void onRightView(); 
-  void onLeftView();     
+  vtkSmartPointer<VTKViewer_Transform> myTransform;
+  vtkSmartPointer<SVTK_CubeAxesActor2D> myCubeAxes;
+  vtkSmartPointer<VTKViewer_Trihedron> myTrihedron;  
+  int myTrihedronSize;
+  float myBndBox[6];
 };
 
 #endif
index 1cf6e52b8b8b9280736f5a9545669f427e176ee2..bc2dc2c752cea0ec674b78b714b22c7462b7dc1f 100644 (file)
@@ -1,8 +1,37 @@
+//  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 : SALOME
+//  $Header$
+
 #include "SALOME_Actor.h"
 
 #include <qapplication.h>
 #include <qpushbutton.h>
 
+#include <vtkGenericRenderWindowInteractor.h>
 #include <vtkCallbackCommand.h>
 #include <vtkTextProperty.h>
 #include <vtkActorCollection.h>
 #include "VTKViewer_Algorithm.h"
 #include "SVTK_Functor.h"
 
+#include "utilities.h"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 1;
+#else
+static int MYDEBUG = 0;
+#endif
+
 
 //----------------------------------------------------------------------------
 SVTK_MainWindow
@@ -46,6 +83,8 @@ SVTK_MainWindow
                  SUIT_ResourceMgr* theResourceMgr) :
   QMainWindow(theParent,theName,0)
 {
+  if(MYDEBUG) INFOS("SVTK_MainWindow() - "<<this);
+
   myToolBar = new QToolBar(this);
   myToolBar->setCloseMode(QDockWindow::Undocked);
   myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
@@ -56,24 +95,33 @@ SVTK_MainWindow
 
 void
 SVTK_MainWindow
-::Initialize()
+::Initialize(SVTK_Renderer *theRenderer)
 {
   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();
+
+  GetInteractor()->SetRenderer(theRenderer);
+}
+
+void
+SVTK_MainWindow
+::Initialize()
+{
+  SVTK_Renderer* aRenderer = SVTK_Renderer::New();
+  Initialize(aRenderer);
+  aRenderer->Delete();
 }
 
 
 //----------------------------------------------------------------------------
 SVTK_MainWindow
 ::~SVTK_MainWindow()
-{}
+{
+  if(MYDEBUG) INFOS("~SVTK_MainWindow() - "<<this);
+}
 
 
 //----------------------------------------------------------------------------
@@ -126,7 +174,7 @@ SVTK_MainWindow
 ::Repaint(bool theUpdateTrihedron)
 {
   if(theUpdateTrihedron) 
-    GetRenderer()->onAdjustTrihedron();
+    GetRenderer()->OnAdjustTrihedron();
 
   GetInteractor()->update();
 }
@@ -140,7 +188,7 @@ SVTK_MainWindow
 }
 
 //----------------------------------------------------------------------------
-SVTK_InteractorStyle*
+vtkInteractorStyle*
 SVTK_MainWindow
 ::GetInteractorStyle()
 {
@@ -149,7 +197,7 @@ SVTK_MainWindow
 
 void
 SVTK_MainWindow
-::PushInteractorStyle(SVTK_InteractorStyle* theStyle)
+::PushInteractorStyle(vtkInteractorStyle* theStyle)
 {
   GetInteractor()->PushInteractorStyle(theStyle);
 }
@@ -218,7 +266,7 @@ void
 SVTK_MainWindow
 ::SetBackgroundColor(const QColor& theColor)
 {
-  GetRenderer()->SetBackground(theColor.red()/255.0, 
+  getRenderer()->SetBackground(theColor.red()/255.0, 
                               theColor.green()/255.0,
                               theColor.blue()/255.0);
 }
@@ -228,7 +276,7 @@ SVTK_MainWindow
 ::BackgroundColor()
 {
   float aBackgroundColor[3];
-  GetRenderer()->GetBackground(aBackgroundColor);
+  getRenderer()->GetBackground(aBackgroundColor);
   return QColor(int(aBackgroundColor[0]*255), 
                int(aBackgroundColor[1]*255), 
                int(aBackgroundColor[2]*255));
@@ -298,9 +346,9 @@ SVTK_MainWindow
  */
 void
 SVTK_MainWindow
-::AdjustTrihedrons(const bool theIsForced)
+::AdjustActors()
 {
-  GetRenderer()->AdjustTrihedrons(theIsForced);
+  GetRenderer()->AdjustActors();
   Repaint();
 }
 
@@ -309,7 +357,7 @@ bool
 SVTK_MainWindow
 ::IsTrihedronDisplayed()
 {
-  return GetRenderer()->isTrihedronDisplayed();
+  return GetRenderer()->IsTrihedronDisplayed();
 }
 
 //----------------------------------------------------------------------------
@@ -317,7 +365,7 @@ bool
 SVTK_MainWindow
 ::IsCubeAxesDisplayed()
 {
-  return GetRenderer()->isCubeAxesDisplayed();
+  return GetRenderer()->IsCubeAxesDisplayed();
 }
 
 //----------------------------------------------------------------------------
@@ -554,7 +602,7 @@ void
 SVTK_MainWindow
 ::onFrontView()
 {
-  GetRenderer()->onFrontView();
+  GetRenderer()->OnFrontView();
 }
 
 //----------------------------------------------------------------------------
@@ -562,7 +610,7 @@ void
 SVTK_MainWindow
 ::onBackView()
 {
-  GetRenderer()->onBackView();
+  GetRenderer()->OnBackView();
 }
 
 //----------------------------------------------------------------------------
@@ -570,7 +618,7 @@ void
 SVTK_MainWindow
 ::onTopView()
 {
-  GetRenderer()->onTopView();
+  GetRenderer()->OnTopView();
 }
 
 //----------------------------------------------------------------------------
@@ -578,7 +626,7 @@ void
 SVTK_MainWindow
 ::onBottomView()
 {
-  GetRenderer()->onBottomView();
+  GetRenderer()->OnBottomView();
 }
 
 //----------------------------------------------------------------------------
@@ -586,7 +634,7 @@ void
 SVTK_MainWindow
 ::onLeftView()
 {
-  GetRenderer()->onLeftView();
+  GetRenderer()->OnLeftView();
 }
 
 //----------------------------------------------------------------------------
@@ -594,7 +642,7 @@ void
 SVTK_MainWindow
 ::onRightView()
 {
-  GetRenderer()->onRightView();
+  GetRenderer()->OnRightView();
 }
 
 //----------------------------------------------------------------------------
@@ -602,7 +650,7 @@ void
 SVTK_MainWindow
 ::onResetView()
 {
-  GetRenderer()->onResetView();
+  GetRenderer()->OnResetView();
   Repaint();
 }
 
@@ -611,7 +659,7 @@ void
 SVTK_MainWindow
 ::onFitAll()
 {
-  GetRenderer()->onFitAll();
+  GetRenderer()->OnFitAll();
   Repaint();
 }
 
@@ -620,7 +668,7 @@ void
 SVTK_MainWindow
 ::onViewTrihedron()
 {
-  GetRenderer()->onViewTrihedron();
+  GetRenderer()->OnViewTrihedron();
   Repaint();
 }
 
@@ -629,7 +677,7 @@ void
 SVTK_MainWindow
 ::onViewCubeAxes()
 {
-  GetRenderer()->onViewCubeAxes();
+  GetRenderer()->OnViewCubeAxes();
   Repaint();
 }
 
@@ -638,7 +686,7 @@ void
 SVTK_MainWindow
 ::onAdjustTrihedron()
 {   
-  GetRenderer()->onAdjustTrihedron();
+  GetRenderer()->OnAdjustTrihedron();
 }
 
 //----------------------------------------------------------------------------
@@ -646,7 +694,7 @@ void
 SVTK_MainWindow
 ::onAdjustCubeAxes()
 {   
-  GetRenderer()->onAdjustCubeAxes();
+  GetRenderer()->OnAdjustCubeAxes();
 }
 
 //----------------------------------------------------------------------------
@@ -671,6 +719,8 @@ SVTK_SignalHandler
   QObject(theMainWindow),
   myMainWindow(theMainWindow)
 {
+  if(MYDEBUG) INFOS("SVTK_SignalHandler() - "<<this);
+
   SVTK_RenderWindowInteractor* anInteractor = theMainWindow->GetInteractor();
 
   connect(anInteractor,SIGNAL(KeyPressed(QKeyEvent*)),
@@ -693,7 +743,9 @@ SVTK_SignalHandler
 
 SVTK_SignalHandler
 ::~SVTK_SignalHandler()
-{}
+{
+  if(MYDEBUG) INFOS("~SVTK_SignalHandler() - "<<this);
+}
 
 SVTK_MainWindow*
 SVTK_SignalHandler
@@ -730,7 +782,7 @@ vtkRenderer*
 SVTK_SignalHandler
 ::getRenderer()
 {
-  return myMainWindow->GetRenderer();
+  return myMainWindow->getRenderer();
 }
 
 //----------------------------------------------------------------
@@ -757,7 +809,7 @@ void
 SVTK_SignalHandler
 ::onSelectionChanged()
 {
-  vtkActorCollection* anActors = myMainWindow->GetRenderer()->GetActors();
+  vtkActorCollection* anActors = myMainWindow->getRenderer()->GetActors();
 
   using namespace VTK;
   ForEach<SALOME_Actor>(anActors,
@@ -780,12 +832,16 @@ SVTK_SignalHandler
 SVTK_View
 ::SVTK_View(SVTK_MainWindow* theMainWindow) :
   SVTK_SignalHandler(theMainWindow)
-{}
+{
+  if(MYDEBUG) INFOS("SVTK_View() - "<<this);
+}
 
 //----------------------------------------------------------------------------
 SVTK_View
 ::~SVTK_View()
-{}
+{
+  if(MYDEBUG) INFOS("~SVTK_View() - "<<this);
+}
 
 //----------------------------------------------------------------
 void 
@@ -793,7 +849,7 @@ SVTK_View
 ::unHighlightAll() 
 {
   using namespace VTK;
-  ForEach<SALOME_Actor>(GetRenderer()->GetActors(),
+  ForEach<SALOME_Actor>(getRenderer()->GetActors(),
                        THighlightAction( false ));
 
   Repaint();
@@ -808,7 +864,7 @@ SVTK_View
 {
   using namespace VTK;
   SVTK_Selector* aSelector = myMainWindow->GetSelector();
-  ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+  ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
                          TIsSameIObject<SALOME_Actor>( theIO ),
                          THighlightAction( theIsHighlight, aSelector->SelectionMode() ));
   
@@ -823,7 +879,7 @@ SVTK_View
                   const double& theBlue, 
                   const int& theWidth) 
 {
-  vtkActorCollection* anActors = GetRenderer()->GetActors();
+  vtkActorCollection* anActors = getRenderer()->GetActors();
   anActors->InitTraversal();
   while( vtkActor* anActor = anActors->GetNextActor() )
   {
@@ -847,7 +903,7 @@ SVTK_View
 ::SetSelectionTolerance(const double& theTolNodes, 
                        const double& theTolItems)
 {
-  vtkActorCollection* anActors = GetRenderer()->GetActors();
+  vtkActorCollection* anActors = getRenderer()->GetActors();
   anActors->InitTraversal();
   while( vtkActor* anActor = anActors->GetNextActor() )
   {
@@ -867,7 +923,7 @@ SVTK_View
 {
   using namespace VTK;
   SALOME_Actor* anActor = 
-    Find<SALOME_Actor>(GetRenderer()->GetActors(),
+    Find<SALOME_Actor>(getRenderer()->GetActors(),
                       TIsSameIObject<SALOME_Actor>(theIObject));
   return anActor != NULL;
 }
@@ -879,7 +935,7 @@ SVTK_View
 {
   using namespace VTK;
   SALOME_Actor* anActor = 
-    Find<SALOME_Actor>(GetRenderer()->GetActors(),
+    Find<SALOME_Actor>(getRenderer()->GetActors(),
                       TIsSameIObject<SALOME_Actor>(theIObject));
   return anActor != NULL && anActor->GetVisibility();
 }
@@ -891,7 +947,7 @@ SVTK_View
         const QString& theName)
 {
   using namespace VTK;
-  ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+  ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
                          TIsSameIObject<SALOME_Actor>(theIObject),
                          TSetFunction<SALOME_Actor,const char*,QString>
                          (&SALOME_Actor::setName,theName.latin1()));
@@ -922,7 +978,7 @@ SVTK_View
                 int theMode)
 {
   using namespace VTK;
-  ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+  ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
                          TIsSameIObject<SALOME_Actor>(theIObject),
                          TSetFunction<SALOME_Actor,int>
                          (&SALOME_Actor::setDisplayMode,theMode));
@@ -933,14 +989,14 @@ void
 SVTK_View
 ::ChangeRepresentationToWireframe()
 {
-  ChangeRepresentationToWireframe(GetRenderer()->GetActors());
+  ChangeRepresentationToWireframe(getRenderer()->GetActors());
 }
 
 void
 SVTK_View
 ::ChangeRepresentationToSurface()
 {
-  ChangeRepresentationToSurface(GetRenderer()->GetActors());
+  ChangeRepresentationToSurface(getRenderer()->GetActors());
 }
 
 
@@ -988,7 +1044,7 @@ SVTK_View
 ::EraseAll()
 {   
   using namespace VTK;
-  ForEach<SALOME_Actor>(GetRenderer()->GetActors(),
+  ForEach<SALOME_Actor>(getRenderer()->GetActors(),
                        TErase());
   Repaint();
 }
@@ -998,7 +1054,7 @@ SVTK_View
 ::DisplayAll()
 { 
   using namespace VTK;
-  ForEach<SALOME_Actor>(GetRenderer()->GetActors(),
+  ForEach<SALOME_Actor>(getRenderer()->GetActors(),
                        TSetVisibility<SALOME_Actor>(true));
   Repaint();
 }
@@ -1022,7 +1078,7 @@ SVTK_View
        bool theIsUpdate)
 {
   using namespace VTK;
-  ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+  ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
                          TIsSameIObject<SALOME_Actor>(theIObject),
                          TErase());
   if(theIsUpdate)
@@ -1049,7 +1105,7 @@ SVTK_View
          bool theIsUpdate)
 {
   using namespace VTK;
-  ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+  ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
                          TIsSameIObject<SALOME_Actor>(theIObject),
                          TSetVisibility<SALOME_Actor>(true));
 
@@ -1060,10 +1116,14 @@ SVTK_View
 //----------------------------------------------------------------------------
 struct TRemoveAction
 {
-  vtkRenderer* myRen;
-  TRemoveAction(vtkRenderer* theRen): myRen(theRen){}
-  void operator()(SALOME_Actor* theActor){
-    myRen->RemoveActor(theActor);
+  SVTK_Renderer* myRenderer;
+  TRemoveAction(SVTK_Renderer* theRenderer): 
+    myRenderer(theRenderer)
+  {}
+  void
+  operator()(SALOME_Actor* theActor)
+  {
+    myRenderer->RemoveActor(theActor);
   }
 };
 
@@ -1073,7 +1133,7 @@ SVTK_View
         bool theIsUpdate)
 {
   using namespace VTK;
-  ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+  ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
                          TIsSameIObject<SALOME_Actor>(theIObject),
                          TRemoveAction(GetRenderer()));
   if(theIsUpdate)
@@ -1085,7 +1145,7 @@ SVTK_View
 ::Remove(SALOME_Actor* theActor, 
         bool theIsUpdate)
 {
-  GetRenderer()->RemoveProp(theActor);
+  GetRenderer()->RemoveActor(theActor);
   if(theIsUpdate)
     Repaint();
 }
@@ -1094,7 +1154,7 @@ void
 SVTK_View
 ::RemoveAll(bool theIsUpdate)
 {
-  vtkRenderer* aRenderer = GetRenderer();
+  vtkRenderer* aRenderer = getRenderer();
   if(vtkActorCollection* anActors = aRenderer->GetActors()){
     anActors->InitTraversal();
     while(vtkActor *anAct = anActors->GetNextActor()){
@@ -1116,7 +1176,7 @@ SVTK_View
 {
   using namespace VTK;
   SALOME_Actor* anActor = 
-    Find<SALOME_Actor>(GetRenderer()->GetActors(),
+    Find<SALOME_Actor>(getRenderer()->GetActors(),
                       TIsSameIObject<SALOME_Actor>(theIObject));
   if(anActor)
     return 1.0 - anActor->GetOpacity();
@@ -1131,7 +1191,7 @@ SVTK_View
 {
   float anOpacity = 1.0 - theTrans;
   using namespace VTK;
-  ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+  ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
                          TIsSameIObject<SALOME_Actor>(theIObject),
                          TSetFunction<SALOME_Actor,float>
                          (&SALOME_Actor::SetOpacity,anOpacity));
@@ -1146,7 +1206,7 @@ SVTK_View
   float aColor[3] = {theColor.red()/255., theColor.green()/255., theColor.blue()/255.};
 
   using namespace VTK;
-  ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+  ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
                          TIsSameIObject<SALOME_Actor>(theIObject),
                          TSetFunction<SALOME_Actor,const float*>
                          (&SALOME_Actor::SetColor,aColor));
@@ -1159,7 +1219,7 @@ SVTK_View
 {
   using namespace VTK;
   SALOME_Actor* anActor = 
-    Find<SALOME_Actor>(GetRenderer()->GetActors(),
+    Find<SALOME_Actor>(getRenderer()->GetActors(),
                       TIsSameIObject<SALOME_Actor>(theIObject));
   if(anActor){
     float r,g,b;
index 1514b8d38b909e99c3b2bee97740c3004fdde960..e992830179b44e74c54f8c283cebd8e0ab261e64 100644 (file)
@@ -17,6 +17,7 @@ class QtxAction;
 
 class vtkRenderer;
 class vtkRenderWindow;
+class vtkInteractorStyle;
 class vtkRenderWindowInteractor;
 
 class vtkObject;
@@ -36,7 +37,6 @@ class VTKViewer_Actor;
 class SVTK_Renderer;
 
 class SVTK_RenderWindow;
-class SVTK_InteractorStyle;
 class SVTK_RenderWindowInteractor;
 
 class SALOME_Actor;
@@ -51,6 +51,10 @@ public:
                  const char* theName,
                  SUIT_ResourceMgr* theResourceMgr);
 
+  virtual
+  void
+  Initialize(SVTK_Renderer *theRenderer);
+
   virtual
   void
   Initialize();
@@ -81,11 +85,11 @@ public:
   InvokeEvent(unsigned long theEvent, void* theCallData);
 
   //----------------------------------------------------------------------------
-  SVTK_InteractorStyle* 
+  vtkInteractorStyle* 
   GetInteractorStyle();
 
   void
-  PushInteractorStyle(SVTK_InteractorStyle* theStyle);
+  PushInteractorStyle(vtkInteractorStyle* theStyle);
 
   void
   PopInteractorStyle();
@@ -128,6 +132,7 @@ public:
   void 
   AddActor(VTKViewer_Actor* theActor, 
           bool theIsUpdate = false);
+
   void 
   RemoveActor(VTKViewer_Actor* theActor, 
              bool theIsUpdate = false);
@@ -139,7 +144,7 @@ public:
   SetTrihedronSize(const int theSize);
 
   void 
-  AdjustTrihedrons(const bool theIsForced);
+  AdjustActors();
 
   bool
   IsTrihedronDisplayed();
index 96da68fea8386d5d5849bec2528c0d95d5b8c9ae..6e97aef2050ff3a9cf03659910a3da85095bd254 100755 (executable)
@@ -41,7 +41,9 @@
 //----------------------------------------------------------------------------
 SVTK_ViewWindow
 ::SVTK_ViewWindow(SUIT_Desktop* theDesktop):
-  SUIT_ViewWindow(theDesktop)
+  SUIT_ViewWindow(theDesktop),
+  myMainWindow(NULL),
+  myView(NULL)
 {}
 
 void
@@ -359,7 +361,7 @@ void
 SVTK_ViewWindow
 ::AdjustTrihedrons(const bool theIsForcedUpdate)
 {
-  myMainWindow->AdjustTrihedrons( theIsForcedUpdate );
+  myMainWindow->AdjustActors();
 }
 
 //----------------------------------------------------------------------------
index b5efe0519c60a14347f16fd6e787e5b34f6072bb..02a563f9fc07d0e623acb51aeb64f2cd706ce3c6 100755 (executable)
@@ -96,18 +96,37 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow
   void Repaint() { Repaint(true); }
 
   //apply existing transformation on adding SALOME_Actor
-  void SetScale( double theScale[3] );
-  void GetScale( double theScale[3] );
-  void AddActor( VTKViewer_Actor*, bool update = false );
-  void RemoveActor(VTKViewer_Actor*, bool update = false);
+  virtual
+  void 
+  SetScale( double theScale[3] );
+
+  virtual
+  void
+  GetScale( double theScale[3] );
+
+  virtual
+  void
+  AddActor(VTKViewer_Actor* theActor,
+          bool theIsUpdate = false);
+
+  virtual
+  void
+  RemoveActor(VTKViewer_Actor* theActor,
+             bool theIsUpdate = false);
 
   void AdjustTrihedrons( const bool forced );
 
-  VTKViewer_Trihedron*  GetTrihedron();
-  SVTK_CubeAxesActor2D* GetCubeAxes();
+  VTKViewer_Trihedron*  
+  GetTrihedron();
+
+  SVTK_CubeAxesActor2D* 
+  GetCubeAxes();
 
-  int  GetTrihedronSize() const;
-  void SetTrihedronSize( const int );
+  int  
+  GetTrihedronSize() const;
+
+  void 
+  SetTrihedronSize( const int );
 
   void SetSelectionProp(const double& theRed = 1, 
                        const double& theGreen = 1,
@@ -129,8 +148,14 @@ public slots:
   void onBottomView();
   void onRightView(); 
   void onLeftView();     
-  void onResetView();     
-  void onFitAll();
+
+  virtual
+  void
+  onResetView();     
+
+  virtual
+  void 
+  onFitAll();
 
   void onViewTrihedron(); 
   void onViewCubeAxes();