fw4spl
OffScreenInteractorManager.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "fwRenderVTK/OffScreenInteractorManager.hpp"
8 
9 #include <fwRenderVTK/registry/macros.hpp>
10 
11 #include <vtkObjectFactory.h>
12 #include <vtkRenderer.h>
13 #include <vtkRenderWindow.h>
14 #include <vtkRenderWindowInteractor.h>
15 
16 //-----------------------------------------------------------------------------
17 
18 namespace fwRenderVTK
19 {
20 
21 //-----------------------------------------------------------------------------
22 
34 class vtkOffscreenRenderWindowInteractor : public vtkRenderWindowInteractor
35 {
36 public:
38  vtkTypeMacro(vtkOffscreenRenderWindowInteractor, vtkRenderWindowInteractor)
39 
40 protected:
42  {
43  }
45  {
46  }
47 
48 private:
50  void operator=(const vtkOffscreenRenderWindowInteractor&); // Not implemented.
51 };
52 
53 vtkStandardNewMacro(vtkOffscreenRenderWindowInteractor);
54 
55 //-----------------------------------------------------------------------------
56 
57 OffScreenInteractorManager::OffScreenInteractorManager()
58 {
59 }
60 
61 //-----------------------------------------------------------------------------
62 
63 OffScreenInteractorManager::~OffScreenInteractorManager()
64 {
65 }
66 
67 //-----------------------------------------------------------------------------
68 
69 void OffScreenInteractorManager::installInteractor( ::fwGui::container::fwContainer::sptr )
70 {
71  SLM_FATAL("This interactor doesn't need a container, use installInteractor(width, height).");
72 }
73 
74 //-----------------------------------------------------------------------------
75 
76 void OffScreenInteractorManager::installInteractor(unsigned int width, unsigned int height)
77 {
78  m_renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
79  m_renderWindow->SetOffScreenRendering( 1 );
80  m_renderWindow->SetSize(static_cast<int>(width), static_cast<int>(height));
81 
82  m_interactor = vtkSmartPointer<vtkOffscreenRenderWindowInteractor>::New();
83  m_interactor->SetRenderWindow(m_renderWindow);
84 }
85 
86 //-----------------------------------------------------------------------------
87 
89 {
90  m_renderWindow = nullptr;
91  m_interactor = nullptr;
92 }
93 
94 //-----------------------------------------------------------------------------
95 
96 ::vtkRenderWindowInteractor* OffScreenInteractorManager::getInteractor()
97 {
98  return m_interactor;
99 }
100 
101 //-----------------------------------------------------------------------------
102 
103 } // namespace fwRenderVTK
virtual FWRENDERVTK_API void installInteractor(::fwGui::container::fwContainer::sptr _parent) override
Do NOT use, this interactor doens&#39;t need container. You must use installInteractor(width, height) instead.
virtual FWRENDERVTK_API::vtkRenderWindowInteractor * getInteractor() override
Return a pointer on interactor.
#define SLM_FATAL(message)
Definition: spyLog.hpp:283
The namespace fwRenderVTK contains classes for rendering with VTK.
virtual FWRENDERVTK_API void uninstallInteractor() override
Deletes interactor and manage correctly the window (removing layout).
Defines a class to redefine a vtkRenderWindowInteractor that can be used in a off screen window...