Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkRenderingTestHelper.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef mitkRenderingTestHelper_h
18 #define mitkRenderingTestHelper_h
19 
20 #include <mitkDataStorage.h>
21 #include <mitkRenderWindow.h>
22 #include <vtkSmartPointer.h>
23 
25 #include <mitkIOUtil.h>
26 
27 class vtkRenderWindow;
28 class vtkRenderer;
29 
30 namespace mitk
31 {
33  {
34  public:
43  int width,
44  int height,
45  int argc,
46  char *argv[],
48 
52  int width,
53  int height,
55 
58 
61  vtkRenderer *GetVtkRenderer();
62 
65  vtkRenderWindow *GetVtkRenderWindow();
66 
70  void SaveAsPNG(std::string fileName);
71 
78  void SetAutomaticallyCloseRenderWindow(bool automaticallyCloseRenderWindow);
79 
85  void SetImageProperty(const char *propertyKey, mitk::BaseProperty *property);
86 
89  void SetViewDirection(mitk::SliceNavigationController::ViewDirection viewDirection);
90 
93  void ReorientSlices(mitk::Point3D origin, mitk::Vector3D rotation);
94 
97  void Render();
98 
102 
107  void SetMapperID(mitk::BaseRenderer::StandardMapperSlot id);
108 
113  void AddNodeToStorage(mitk::DataNode::Pointer node);
114 
119  void SetMapperIDToRender3D();
120 
124  void SetMapperIDToRender2D();
125 
130  void SaveReferenceScreenShot(std::string fileName);
131 
149  bool CompareRenderWindowAgainstReference(int argc, char *argv[], double threshold = 10.0);
150 
152  bool IsAdvancedOpenGL();
153 
161  {
162  private:
166  std::vector<char *> argv;
167  std::vector<std::vector<char>> argvec;
168 
169  public:
170  ArgcHelperClass(const std::vector<std::string> &argstrings)
171  : argv(argstrings.size() + 1), argvec(argstrings.size() + 1)
172  {
173  std::vector<std::string> cmdArgs;
174  cmdArgs.push_back(mitk::IOUtil::GetProgramPath());
175  cmdArgs.insert(cmdArgs.end(), argstrings.begin(), argstrings.end());
176  for (std::size_t i = 0; i < cmdArgs.size(); ++i)
177  {
178  argvec[i].assign(cmdArgs[i].begin(), cmdArgs[i].end());
179  argvec[i].push_back('\0');
180  argv[i] = &argvec[i][0];
181  }
182  }
183  char **GetArgv() { return &argv[0]; }
184  int GetArgc() { return argv.size(); }
185  };
186 
187  protected:
194  void Initialize(
195  int width,
196  int height,
198 
203  void PrintGLInfo();
204 
208  void AddToStorage(const std::string &filename);
209 
216  void SetInputFileNames(int argc, char *argv[]);
217 
218  mitk::RenderWindow::Pointer m_RenderWindow; //<< Contains the mitkRenderWindow into which the test renders the data
219  mitk::DataStorage::Pointer m_DataStorage; //<< Contains the mitkDataStorage which contains the data to be rendered
220  bool
221  m_AutomaticallyCloseRenderWindow; //<< Flag indicating whether the renderwindow should automatically close (true,
222  // default) or stay open (false). Usefull for debugging.
223  };
224 } // namespace mitk
225 #endif
mitk::DataStorage::Pointer m_DataStorage
DataCollection - Class to facilitate loading/accessing structured data.
static mitk::DataStorage::Pointer GetDataStorage()
static Matrix3D rotation
ArgcHelperClass(const std::vector< std::string > &argstrings)
Abstract base class for properties.
static const std::string filename
mitk::RenderWindow::Pointer m_RenderWindow
static std::string GetProgramPath()
Definition: mitkIOUtil.cpp:350
void SetInputFileNames(std::string input_directory)
The ArgcHelperClass class is a convinience class to convert a vector of strings to the standard c++ a...
#define MITKTESTINGHELPER_EXPORT
ViewDirection
Possible view directions, Original will uses the PlaneGeometry instances in a SlicedGeometry3D provid...