]> Creatis software - crea.git/blobdiff - src/creawxVTKRenderWindowInteractor.mm
3388 TDx
[crea.git] / src / creawxVTKRenderWindowInteractor.mm
index 3047c9397e9c54ec980e4edfa0b30ad39ef665b9..578c3a36ac4a925008d8b224af635a1928211fed 100644 (file)
 
 =========================================================================*/
 
-//#import <Cocoa/Cocoa.h>
+
 
 #include <assert.h>
 
 #include "creawxVTKRenderWindowInteractor.h"
 
-#include <wx/display.h>
-
-
 //This is needed for vtk 3.1 :
 #ifndef VTK_MAJOR_VERSION
 #  include "vtkVersion.h"
@@ -66,7 +63,8 @@
 
 // AKT: wxOSX 2.9.x defines __WXOSX_COCOA__ rather than __WXCOCOA__
 #ifdef __WXOSX_COCOA__
-#define __WXCOCOA__
+   #import <Cocoa/Cocoa.h>
+   #define __WXCOCOA__
 #endif
 
 #if defined(__WXMAC__) && wxCHECK_VERSION(2,9,0)
 #endif
 
 
+#ifdef VTK_USE_TDX
+// #import "vtkTDxMacDevice.h"
+#import "/Users/davila/Creatis/C11/tpli/include/vtk-8.2/vtkTDxMacDevice.h"
+#endif
+
+
 //=======================================================================
 // LG : NAMESPACE IS NECESSARY TO AVOID CONFLICTING SYMBOLS IN DYN LIBS
 namespace crea
@@ -105,7 +109,6 @@ wxWindow* wxGetTopLevelParent(wxWindow *win)
 // To access objc calls on cocoa
 #ifdef __WXCOCOA__
 #ifdef VTK_USE_COCOA
-#import <Cocoa/Cocoa.h>
 // This trick is no longer need in VTK CVS, should get rid of that:
 #define id Id
 #else
@@ -114,7 +117,6 @@ wxWindow* wxGetTopLevelParent(wxWindow *win)
 #endif //__WXCOCOA__
 
 #if wxMAJOR_VERSION <= 2
-
        #ifdef __WXGTK__
         #include <gdk/gdkx.h> // GDK_WINDOW_XWINDOW is found here in wxWidgets 2.8.0
         #include "gdk/gdkprivate.h"
@@ -274,6 +276,12 @@ wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor()
   this->RenderWindow = NULL;
   this->SetRenderWindow(vtkRenderWindow::New());
   this->RenderWindow->Delete();
+    
+#ifdef VTK_USE_TDX
+    this->Device=vtkTDxMacDevice::New();
+#endif
+
+    
 }
 //---------------------------------------------------------------------------
 wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor(wxWindow *parent,
@@ -314,6 +322,13 @@ wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor(wxWindow *parent,
   // so we update the size information of the interactor/renderwindow here
   this->UpdateSize(size.x, size.y);
 #endif
+    
+
+#ifdef VTK_USE_TDX
+    this->Device=vtkTDxMacDevice::New();
+#endif
+
+    
 }
 //---------------------------------------------------------------------------
 wxVTKRenderWindowInteractor::~wxVTKRenderWindowInteractor()
@@ -323,6 +338,11 @@ wxVTKRenderWindowInteractor::~wxVTKRenderWindowInteractor()
 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
   delete this->context;
 #endif
+    
+#ifdef VTK_USE_TDX
+  this->Device->Delete();
+#endif
+
 }
 //---------------------------------------------------------------------------
 wxVTKRenderWindowInteractor * wxVTKRenderWindowInteractor::New()
@@ -357,11 +377,34 @@ void wxVTKRenderWindowInteractor::Enable()
 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
   wxGLCanvas::SetCurrent(*this->context);
 #endif
+
+//EED 2010-10-14
+#ifdef VTK_USE_TDX
+  if(this->UseTDx)
+  {
+    this->Device->SetInteractor(this);
+    this->Device->Initialize();
+  }
+#endif
+
+    
+    
   Modified();
 }
 //---------------------------------------------------------------------------
 bool wxVTKRenderWindowInteractor::Enable(bool enable)
 {
+    
+#ifdef VTK_USE_TDX
+  if(this->UseTDx)
+  {
+    this->Device->SetInteractor(this);
+    this->Device->Initialize();
+  }
+#endif
+
+    
+    
 #if defined(__WXGTK__) && defined(USE_WXGLCANVAS)
   return wxGLCanvas::Enable(enable);
 #else
@@ -375,6 +418,14 @@ void wxVTKRenderWindowInteractor::Disable()
   if (!Enabled)
     return;
 
+#ifdef VTK_USE_TDX
+  if(this->Device->GetInitialized())
+  {
+    this->Device->Close();
+  }
+#endif
+    
+    
   // that's it (we can't remove the event handler like it should be...)
   Enabled = 0;
   Modified();
@@ -515,9 +566,12 @@ long wxVTKRenderWindowInteractor::GetHandleHack()
 //---------------------------------------------------------------------------
 void wxVTKRenderWindowInteractor::OnPaint(wxPaintEvent& WXUNUSED(event))
 {
-
   //must always be here
-//EED2021-08-26  wxPaintDC pDC(this);
+//EED2021-08-26  
+#ifdef __WXCOCOA__
+#else
+       wxPaintDC pDC(this);
+#endif
 
   //do it here rather than in the cstor: this is safer.
   if(!Handle)
@@ -526,9 +580,6 @@ void wxVTKRenderWindowInteractor::OnPaint(wxPaintEvent& WXUNUSED(event))
        
 #ifdef __WXCOCOA__
        vtkCocoaRenderWindow    *rwin           = vtkCocoaRenderWindow::SafeDownCast(RenderWindow);
-//2021-08-30
-//      rwin->SetWantsBestResolution(true);
-      
     NSView                                     *nvsview        = (NSView* )Handle;
        NSWindow                                *nswindow       = nvsview.window;
     rwin->SetRootWindow( nswindow );
@@ -555,8 +606,7 @@ void wxVTKRenderWindowInteractor::OnPaint(wxPaintEvent& WXUNUSED(event))
     #endif
   }
   // get vtk to render to the wxWindows
-
-Render();
+  Render();
 #ifdef __WXMAC__
   // This solves a problem with repainting after a window resize
   // See also: http://sourceforge.net/mailarchive/forum.php?thread_id=31690967&forum_id=41789
@@ -570,7 +620,6 @@ Render();
     }
   #endif
 #else
-    
   vtkCarbonRenderWindow* rwin = vtkCarbonRenderWindow::SafeDownCast(RenderWindow);
   if( rwin )
   {
@@ -582,7 +631,6 @@ Render();
 #endif
 #endif
 }
-
 //---------------------------------------------------------------------------
 void wxVTKRenderWindowInteractor::OnEraseBackground(wxEraseEvent &event)
 {
@@ -606,9 +654,7 @@ void wxVTKRenderWindowInteractor::OnSize(wxSizeEvent& WXUNUSED(event))
 #endif
   //this will check for Handle
   //Render();
-
 }
-
 //---------------------------------------------------------------------------
 void wxVTKRenderWindowInteractor::OnMotion(wxMouseEvent &event)
 {
@@ -617,7 +663,6 @@ void wxVTKRenderWindowInteractor::OnMotion(wxMouseEvent &event)
     return;
     }
 #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0)
-
   SetEventInformationFlipY(event.GetX(), event.GetY(), 
     event.ControlDown(), event.ShiftDown(), '\0', 0, NULL);