15 #include <vtkRenderWindow.h>
16 #include <vtkOpenGLRenderWindow.h>
17 #include "QVTKWidget.h"
23 bool RenderWindowFactory::mInstanceExisting =
false;
29 CX_LOG_ERROR() <<
"There can only be one instance of RenderWindowFactory <--------";
31 mInstanceExisting =
true;
35 this->preventSharedContextRenderWindowFromBeingShownOnScreen(renderWindow);
36 renderWindow->Render();
39 void RenderWindowFactory::preventSharedContextRenderWindowFromBeingShownOnScreen(
vtkRenderWindowPtr renderWindow)
41 mQvtkWidgetForHidingSharedContextRenderWindow =
new QVTKWidget();
42 mQvtkWidgetForHidingSharedContextRenderWindow->SetRenderWindow(renderWindow);
49 return mRenderWindows[uid];
58 return (mRenderWindows.count(uid) > 0);
63 if(!mSharedRenderWindow)
65 CX_LOG_WARNING() <<
"RenderWindowFactory::getSharedRenderWindow(): No shared opengl renderwindow available.";
67 return mSharedRenderWindow;
72 if(mSharedRenderWindow == sharedRenderWindow)
76 mSharedRenderWindow = sharedRenderWindow;
79 if(opengl_renderwindow)
85 CX_LOG_WARNING() <<
"RenderWindowFactory::setSharedRenderWindow(): got no opengl render window.";
91 return mSharedOpenGLContext;
94 vtkRenderWindowPtr RenderWindowFactory::createRenderWindow(QString uid,
bool offScreenRendering)
97 renderWindow->SetOffScreenRendering(offScreenRendering);
99 mSharedContextCreatedCallback = SharedContextCreatedCallbackPtr::New();
100 mSharedContextCreatedCallback->setRenderWindowFactory(
this);
103 if(!opengl_renderwindow)
105 CX_LOG_ERROR() <<
"The created renderwindow is not an opengl renderwindow.";
107 opengl_renderwindow->AddObserver(vtkCommand::CXSharedContextCreatedEvent, mSharedContextCreatedCallback);
109 mRenderWindows[uid] = renderWindow;