Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
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:
39  int width,
40  int height,
41  int argc,
42  char *argv[],
43  AntiAliasing antiAliasing = AntiAliasing::None);
44 
48  int width,
49  int height,
50  AntiAliasing antiAliasing = AntiAliasing::None);
51 
54 
57  vtkRenderer *GetVtkRenderer();
58 
61  vtkRenderWindow *GetVtkRenderWindow();
62 
66  void SaveAsPNG(std::string fileName);
67 
74  void SetAutomaticallyCloseRenderWindow(bool automaticallyCloseRenderWindow);
75 
81  void SetImageProperty(const char *propertyKey, mitk::BaseProperty *property);
82 
85  void SetViewDirection(mitk::SliceNavigationController::ViewDirection viewDirection);
86 
89  void ReorientSlices(mitk::Point3D origin, mitk::Vector3D rotation);
90 
93  void Render();
94 
97  mitk::DataStorage::Pointer GetDataStorage();
98 
103  void SetMapperID(mitk::BaseRenderer::StandardMapperSlot id);
104 
109  void AddNodeToStorage(mitk::DataNode::Pointer node);
110 
115  void SetMapperIDToRender3D();
116 
120  void SetMapperIDToRender2D();
121 
126  void SaveReferenceScreenShot(std::string fileName);
127 
145  bool CompareRenderWindowAgainstReference(int argc, char *argv[], double threshold = 10.0);
146 
154  {
155  private:
159  std::vector<char *> argv;
160  std::vector<std::vector<char>> argvec;
161 
162  public:
163  ArgcHelperClass(const std::vector<std::string> &argstrings)
164  : argv(argstrings.size() + 1), argvec(argstrings.size() + 1)
165  {
166  std::vector<std::string> cmdArgs;
167  cmdArgs.push_back(mitk::IOUtil::GetProgramPath());
168  cmdArgs.insert(cmdArgs.end(), argstrings.begin(), argstrings.end());
169  for (std::size_t i = 0; i < cmdArgs.size(); ++i)
170  {
171  argvec[i].assign(cmdArgs[i].begin(), cmdArgs[i].end());
172  argvec[i].push_back('\0');
173  argv[i] = &argvec[i][0];
174  }
175  }
176  char **GetArgv() { return &argv[0]; }
177  int GetArgc() { return argv.size(); }
178  };
179 
180  protected:
187  void Initialize(
188  int width,
189  int height,
190  AntiAliasing antiAliasing = AntiAliasing::None);
191 
195  void AddToStorage(const std::string &filename);
196 
203  void SetInputFileNames(int argc, char *argv[]);
204 
205  mitk::RenderWindow::Pointer m_RenderWindow; //<< Contains the mitkRenderWindow into which the test renders the data
206  mitk::DataStorage::Pointer m_DataStorage; //<< Contains the mitkDataStorage which contains the data to be rendered
207  bool
208  m_AutomaticallyCloseRenderWindow; //<< Flag indicating whether the renderwindow should automatically close (true,
209  // default) or stay open (false). Usefull for debugging.
210  };
211 } // namespace mitk
212 #endif
mitk::DataStorage::Pointer m_DataStorage
DataCollection - Class to facilitate loading/accessing structured data.
static Matrix3D rotation
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
static std::string GetProgramPath()
Definition: mitkIOUtil.cpp:356
The ArgcHelperClass class is a convinience class to convert a vector of strings to the standard c++ a...
#define MITKTESTINGHELPER_EXPORT