X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=src%2FcreawxVTKRenderWindowInteractor.mm;h=33f4e84002409d8f58ae5eb0f438765da9699652;hb=refs%2Fheads%2Fvtk9itk5wx3-macos;hp=6bc66c2f2df9f15d6c850d60dd77f9d99c83e92a;hpb=0ec2144d3569d045ee5dfe886e3db723f400225a;p=crea.git diff --git a/src/creawxVTKRenderWindowInteractor.mm b/src/creawxVTKRenderWindowInteractor.mm index 6bc66c2..51fd743 100644 --- a/src/creawxVTKRenderWindowInteractor.mm +++ b/src/creawxVTKRenderWindowInteractor.mm @@ -44,7 +44,6 @@ =========================================================================*/ - #include #include "creawxVTKRenderWindowInteractor.h" @@ -54,6 +53,7 @@ # include "vtkVersion.h" #endif + #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0) # include "vtkCommand.h" #else @@ -81,6 +81,11 @@ #endif +#ifdef VTK_USE_TDX +#import "vtkTDxMacDevice.h" +#endif + + //======================================================================= // LG : NAMESPACE IS NECESSARY TO AVOID CONFLICTING SYMBOLS IN DYN LIBS namespace crea @@ -102,12 +107,16 @@ wxWindow* wxGetTopLevelParent(wxWindow *win) // To access objc calls on cocoa #ifdef __WXCOCOA__ -#ifdef VTK_USE_COCOA -// This trick is no longer need in VTK CVS, should get rid of that: + #define id Id -#else -#error Build mismatch you need both wxWidgets and VTK to be configure against Cocoa to work -#endif //VTK_USE_COCOA + +// #ifdef VTK_USE_COCOA +// // This trick is no longer need in VTK CVS, should get rid of that: +// #define id Id +// #else +// #error Build mismatch you need both wxWidgets and VTK to be configure against Cocoa to work +// #endif //VTK_USE_COCOA + #endif //__WXCOCOA__ #if wxMAJOR_VERSION <= 2 @@ -261,6 +270,9 @@ wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() , RenderWhenDisabled(1) , UseCaptureMouse(0) { + //EED 2025-01-20 Create sync mechanism windows + firstTimeOnPaint=false; + #ifdef VTK_DEBUG_LEAKS vtkDebugLeaks::ConstructClass("wxVTKRenderWindowInteractor"); #endif @@ -270,6 +282,11 @@ 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, @@ -296,6 +313,8 @@ wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor(wxWindow *parent, , RenderWhenDisabled(1) , UseCaptureMouse(0) { + //EED 2025-01-20 Create sync mechanism windows + firstTimeOnPaint=false; #ifdef VTK_DEBUG_LEAKS vtkDebugLeaks::ConstructClass("wxVTKRenderWindowInteractor"); #endif @@ -310,7 +329,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() { @@ -319,13 +344,19 @@ wxVTKRenderWindowInteractor::~wxVTKRenderWindowInteractor() #if defined(__WXGTK__) && defined(USE_WXGLCANVAS) delete this->context; #endif + +#ifdef VTK_USE_TDX + this->Device->Delete(); +#endif } + //--------------------------------------------------------------------------- wxVTKRenderWindowInteractor * wxVTKRenderWindowInteractor::New() { // we don't make use of the objectfactory, because we're not registered return new wxVTKRenderWindowInteractor; } + //--------------------------------------------------------------------------- void wxVTKRenderWindowInteractor::Initialize() { @@ -333,13 +364,11 @@ void wxVTKRenderWindowInteractor::Initialize() // enable everything and start rendering Enable(); //RenderWindow->Start(); - // set the size in the render window interactor Size[0] = size[0]; Size[1] = size[1]; - // this is initialized - Initialized = 1; + Initialized = 1; } //--------------------------------------------------------------------------- void wxVTKRenderWindowInteractor::Enable() @@ -353,11 +382,30 @@ 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 @@ -369,8 +417,17 @@ void wxVTKRenderWindowInteractor::Disable() { // if already disabled then done 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(); @@ -396,9 +453,9 @@ void wxVTKRenderWindowInteractor::UpdateSize(int x, int y) // and our RenderWindow's size #ifdef __WXCOCOA__ - #ifdef VTK_USE_COCOA - #else - #endif //VTK_USE_COCOA +// #ifdef VTK_USE_COCOA +// #else +// #endif //VTK_USE_COCOA #else RenderWindow->SetSize(x, y); #endif //__WXCOCOA__ @@ -414,19 +471,21 @@ int wxVTKRenderWindowInteractor::CreateTimer(int WXUNUSED(timertype)) { // it's a one shot timer if (!timer.Start(10, TRUE)) + { return 0; - + } return 1; - } + #if VTK_MAJOR_VERSION > 5 || (VTK_MAJOR_VERSION == 5 && VTK_MINOR_VERSION >= 2) //------------------------------------------------------------------ int wxVTKRenderWindowInteractor::InternalCreateTimer(int timerId, int timerType, unsigned long duration) { if (!timer.Start(duration, timerType == OneShotTimer)) + { return 0; - + } return ID_wxVTKRenderWindowInteractor_TIMER; } //------------------------------------------------------------------ @@ -436,12 +495,14 @@ int wxVTKRenderWindowInteractor::InternalDestroyTimer(int platformTimerId) return 1; } #endif + //--------------------------------------------------------------------------- int wxVTKRenderWindowInteractor::DestroyTimer() { // do nothing return 1; } + //--------------------------------------------------------------------------- void wxVTKRenderWindowInteractor::OnTimer(wxTimerEvent& WXUNUSED(event)) { @@ -511,6 +572,9 @@ long wxVTKRenderWindowInteractor::GetHandleHack() //--------------------------------------------------------------------------- void wxVTKRenderWindowInteractor::OnPaint(wxPaintEvent& WXUNUSED(event)) { + //EED 2025-01-20 Create sync mechanism windows + firstTimeOnPaint=true; + //must always be here //EED2021-08-26 #ifdef __WXCOCOA__ @@ -576,30 +640,31 @@ void wxVTKRenderWindowInteractor::OnPaint(wxPaintEvent& WXUNUSED(event)) #endif #endif } + //--------------------------------------------------------------------------- void wxVTKRenderWindowInteractor::OnEraseBackground(wxEraseEvent &event) { //turn off background erase to reduce flickering on MSW event.Skip(false); } + //--------------------------------------------------------------------------- void wxVTKRenderWindowInteractor::OnSize(wxSizeEvent& WXUNUSED(event)) { int w, h; GetClientSize(&w, &h); UpdateSize(w, h); - if (!Enabled) - { - return; - } - + { + return; + } #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0) InvokeEvent(vtkCommand::ConfigureEvent, NULL); #endif //this will check for Handle //Render(); } + //--------------------------------------------------------------------------- void wxVTKRenderWindowInteractor::OnMotion(wxMouseEvent &event) { @@ -661,7 +726,7 @@ void wxVTKRenderWindowInteractor::OnLeave(wxMouseEvent &event) //--------------------------------------------------------------------------- void wxVTKRenderWindowInteractor::OnKeyDown(wxKeyEvent &event) { - if (!Enabled) + if (!Enabled) { return; } @@ -691,7 +756,7 @@ void wxVTKRenderWindowInteractor::OnKeyDown(wxKeyEvent &event) //--------------------------------------------------------------------------- void wxVTKRenderWindowInteractor::OnKeyUp(wxKeyEvent &event) { - if (!Enabled) + if (!Enabled) { return; } @@ -722,7 +787,7 @@ void wxVTKRenderWindowInteractor::OnKeyUp(wxKeyEvent &event) //--------------------------------------------------------------------------- void wxVTKRenderWindowInteractor::OnChar(wxKeyEvent &event) { - if (!Enabled) + if (!Enabled) { return; } @@ -889,7 +954,7 @@ void wxVTKRenderWindowInteractor::OnMouseWheel(wxMouseEvent& event) InvokeEvent(vtkCommand::MouseWheelBackwardEvent, NULL); } #endif - + } //--------------------------------------------------------------------------- @@ -912,48 +977,53 @@ void wxVTKRenderWindowInteractor::OnMouseCaptureLost(wxMouseCaptureLostEvent& ev //--------------------------------------------------------------------------- void wxVTKRenderWindowInteractor::Render() { + //EED 2025-01-20 Create sync mechanism windows + if (firstTimeOnPaint==true) + { + #if wxCHECK_VERSION(2, 8, 0) - int renderAllowed = !IsFrozen(); + int renderAllowed = !IsFrozen(); #else - int renderAllowed = 1; + int renderAllowed = 1; #endif - if (renderAllowed && !RenderWhenDisabled) - { - //the user doesn't want us to render when the toplevel frame - //is disabled - first find the top level parent - wxWindow *topParent = wxGetTopLevelParent(this); - if (topParent) - { - //if it exists, check whether it's enabled - //if it's not enabeld, renderAllowed will be false - renderAllowed = topParent->IsEnabled(); - } - } - - if (renderAllowed) - { + if (renderAllowed && !RenderWhenDisabled) + { + //the user doesn't want us to render when the toplevel frame + //is disabled - first find the top level parent + wxWindow *topParent = wxGetTopLevelParent(this); + if (topParent) + { + //if it exists, check whether it's enabled + //if it's not enabeld, renderAllowed will be false + renderAllowed = topParent->IsEnabled(); + } + } // if renderAllowed && !RenderWhenDisabled + + if (renderAllowed) + { #if defined(__WXGTK__) && defined(USE_WXGLCANVAS) - wxGLCanvas::SetCurrent(*(this->context)); + wxGLCanvas::SetCurrent(*(this->context)); #endif - if(Handle && (Handle == GetHandleHack()) ) - { - RenderWindow->Render(); - } + if(Handle && (Handle == GetHandleHack()) ) + { + RenderWindow->Render(); + } #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2) - else if(GetHandleHack()) - { - //this means the user has reparented us; let's adapt to the - //new situation by doing the WindowRemap dance - //store the new situation - Handle = GetHandleHack(); - RenderWindow->SetNextWindowId(reinterpret_cast(Handle)); - RenderWindow->WindowRemap(); - RenderWindow->Render(); - } + else if(GetHandleHack()) + { + //this means the user has reparented us; let's adapt to the + //new situation by doing the WindowRemap dance + //store the new situation + Handle = GetHandleHack(); + RenderWindow->SetNextWindowId(reinterpret_cast(Handle)); + RenderWindow->WindowRemap(); + RenderWindow->Render(); + } #endif - - } + } // if renderAllowed + } // if firstTimeOnPaint } + //--------------------------------------------------------------------------- void wxVTKRenderWindowInteractor::SetRenderWhenDisabled(int newValue) { @@ -1001,7 +1071,7 @@ void wxVTKRenderWindowInteractor::PrintSelf(ostream& os, vtkIndent indent) } -// LG : EO namespace bbwxvtk +// LG : EO namespace //=======================================================================