Medical Imaging Interaction Toolkit  2021.02.99-e55a5d2f
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkRenderingTestHelper_h
14 #define mitkRenderingTestHelper_h
15 
16 #include <mitkDataStorage.h>
17 #include <mitkRenderWindow.h>
18 #include <vtkSmartPointer.h>
19 
21 #include <mitkIOUtil.h>
22 
23 class vtkRenderWindow;
24 class vtkRenderer;
25 
26 namespace mitk
27 {
29  {
30  public:
41  int width,
42  int height,
43  int argc,
44  char *argv[],
45  AntiAliasing antiAliasing = AntiAliasing::None);
46 
50  int width,
51  int height,
52  AntiAliasing antiAliasing = AntiAliasing::None);
53 
56 
59  vtkRenderer *GetVtkRenderer();
60 
63  vtkRenderWindow *GetVtkRenderWindow();
64 
68  void SaveAsPNG(std::string fileName);
69 
76  void SetAutomaticallyCloseRenderWindow(bool automaticallyCloseRenderWindow);
77 
84  void SetImageProperty(const char *propertyKey, mitk::BaseProperty *property);
85 
88  void SetViewDirection(mitk::SliceNavigationController::ViewDirection viewDirection);
89 
92  void ReorientSlices(mitk::Point3D origin, mitk::Vector3D rotation);
93 
96  void Render();
97 
100  mitk::DataStorage::Pointer GetDataStorage();
101 
106  void SetMapperID(mitk::BaseRenderer::StandardMapperSlot id);
107 
112  void AddNodeToStorage(mitk::DataNode::Pointer node);
113 
118  void SetMapperIDToRender3D();
119 
123  void SetMapperIDToRender2D();
124 
129  void SaveReferenceScreenShot(std::string fileName);
130 
148  bool CompareRenderWindowAgainstReference(int argc, char *argv[], double threshold = 10.0);
149 
157  {
158  private:
162  std::vector<char *> argv;
163  std::vector<std::vector<char>> argvec;
164 
165  public:
166  ArgcHelperClass(const std::vector<std::string> &argstrings)
167  : argv(argstrings.size() + 1), argvec(argstrings.size() + 1)
168  {
169  std::vector<std::string> cmdArgs;
170  cmdArgs.push_back(mitk::IOUtil::GetProgramPath());
171  cmdArgs.insert(cmdArgs.end(), argstrings.begin(), argstrings.end());
172  for (std::size_t i = 0; i < cmdArgs.size(); ++i)
173  {
174  argvec[i].assign(cmdArgs[i].begin(), cmdArgs[i].end());
175  argvec[i].push_back('\0');
176  argv[i] = &argvec[i][0];
177  }
178  }
179  char **GetArgv() { return &argv[0]; }
180  int GetArgc() { return argv.size(); }
181  };
182 
183  protected:
190  void Initialize(
191  int width,
192  int height,
193  AntiAliasing antiAliasing = AntiAliasing::None);
194 
198  void AddToStorage(const std::string &filename);
199 
206  void SetInputFileNames(int argc, char *argv[]);
207 
208  mitk::RenderWindow::Pointer m_RenderWindow; //<< Contains the mitkRenderWindow into which the test renders the data
209  mitk::DataStorage::Pointer m_DataStorage; //<< Contains the mitkDataStorage which contains the data to be rendered
210  bool
211  m_AutomaticallyCloseRenderWindow; //<< Flag indicating whether the renderwindow should automatically close (true,
212  // default) or stay open (false). Usefull for debugging.
213  };
214 } // namespace mitk
215 #endif
mitk::DataStorage::Pointer m_DataStorage
DataCollection - Class to facilitate loading/accessing structured data.
ArgcHelperClass(const std::vector< std::string > &argstrings)
Abstract base class for properties.
ViewDirection
Possible view directions, Original will uses the PlaneGeometry instances in a SlicedGeometry3D provid...
mitk::RenderWindow::Pointer m_RenderWindow
The ArgcHelperClass class is a convinience class to convert a vector of strings to the standard c++ a...
static std::string GetProgramPath()
#define MITKTESTINGHELPER_EXPORT