NorMIT-nav  22.09
An IGT application
cxSharedContextCreatedCallback.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
13 
14 #include <vtkOpenGLRenderWindow.h>
15 
16 #include "vtkRenderWindow.h"
17 #include "cxLogger.h"
18 #include "cxSharedOpenGLContext.h"
19 #include "cxRenderWindowFactory.h"
20 
21 namespace cx
22 {
23 
25 {
26  return new SharedContextCreatedCallback();
27 }
28 
30  mRenderWindowFactory(NULL)
31 {
32 }
33 
35 {
36  mRenderWindowFactory = factory;
37 }
38 
39 void SharedContextCreatedCallback::Execute(vtkObject *renderWindow, unsigned long eventId, void *cbo)
40 {
41  if(!mRenderWindowFactory)
42  {
43  CX_LOG_ERROR() << "SharedContextCreatedCallback::Execute: RenderWindowFactoryPtr missing";
44  return;
45  }
46 
47  if(eventId == vtkCommand::CXSharedContextCreatedEvent)
48  {
49  vtkOpenGLRenderWindowPtr opengl_renderwindow = vtkOpenGLRenderWindow::SafeDownCast(renderWindow);
50 
51  if(SharedOpenGLContext::isValid(opengl_renderwindow))
52  {
53  mRenderWindowFactory->setSharedRenderWindow(opengl_renderwindow);
54  }
55  else
56  {
57  CX_LOG_WARNING() << "VTK render window is not an opengl renderwindow. This means we don't have an OpenGL shared context";
58  }
59  }
60 }
61 
62 }//cx
cxSharedOpenGLContext.h
cxLogger.h
cx::RenderWindowFactory
Use to create all vtkRenderWindows, and store a single shared render window.
Definition: cxRenderWindowFactory.h:38
cx::SharedContextCreatedCallback::Execute
virtual void Execute(vtkObject *view, unsigned long eventId, void *cbo)
Definition: cxSharedContextCreatedCallback.cpp:39
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
vtkOpenGLRenderWindowPtr
vtkSmartPointer< class vtkOpenGLRenderWindow > vtkOpenGLRenderWindowPtr
Definition: vtkForwardDeclarations.h:101
cx::SharedContextCreatedCallback
Definition: cxSharedContextCreatedCallback.h:26
cxSharedContextCreatedCallback.h
cxRenderWindowFactory.h
CX_LOG_ERROR
#define CX_LOG_ERROR
Definition: cxLogger.h:99
cx::SharedOpenGLContext::isValid
static bool isValid(vtkOpenGLRenderWindowPtr opengl_renderwindow, bool print=false)
Definition: cxSharedOpenGLContext.cpp:39
cx::SharedContextCreatedCallback::New
static SharedContextCreatedCallback * New()
Definition: cxSharedContextCreatedCallback.cpp:24
CX_LOG_WARNING
#define CX_LOG_WARNING
Definition: cxLogger.h:98
cx::SharedContextCreatedCallback::setRenderWindowFactory
void setRenderWindowFactory(RenderWindowFactory *factory)
Definition: cxSharedContextCreatedCallback.cpp:34
cx::SharedContextCreatedCallback::SharedContextCreatedCallback
SharedContextCreatedCallback()
Definition: cxSharedContextCreatedCallback.cpp:29