NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
niftkSingleViewerWidgetTest.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef niftkSingleViewerWidgetTest_h
16 #define niftkSingleViewerWidgetTest_h
17 
18 #include <QObject>
19 
21 
23 
24 #include <vector>
25 
26 namespace mitk
27 {
28 class DataNode;
29 }
30 
31 class QmitkRenderWindow;
32 
33 
34 namespace niftk
35 {
36 class SingleViewerWidget;
37 class SingleViewerWidgetTestClassPrivate;
38 
39 
40 class SingleViewerWidgetTestClass: public QObject
41 {
42  Q_OBJECT
43 
44 public:
45 
47 
51 
53  explicit SingleViewerWidgetTestClass();
54 
57 
59  std::string GetFileName() const;
60 
62  void SetFileName(const std::string& fileName);
63 
66  bool GetInteractiveMode() const;
67 
70  void SetInteractiveMode(bool interactiveMode);
71 
75  static mitk::Point3D GetWorldOrigin(const mitk::BaseGeometry* geometry);
76 
78  static mitk::Vector3D GetWorldUpDirections(const mitk::BaseGeometry* geometry);
79 
81  static std::vector<int> GetWorldAxes(const mitk::Geometry3D* geometry);
82 
86  static mitk::Point3D GetWorldBottomLeftBackCorner(const mitk::BaseGeometry* geometry);
87 
91  static QPoint GetPointAtCursorPosition(QmitkRenderWindow *renderWindow, const mitk::Vector2D& cursorPosition);
92 
96  static mitk::Vector2D GetDisplayPositionAtPoint(QmitkRenderWindow *renderWindow, const QPoint& point);
97 
98  mitk::Point3D GetWorldPositionAtDisplayPosition(int orientation, const mitk::Vector2D& displayPosition);
99 
100  mitk::Vector2D GetDisplayPositionAtWorldPosition(int orientation, const mitk::Point3D& worldPosition);
101 
103  mitk::Vector2D GetCentrePosition(int windowIndex);
104 
106  std::vector<mitk::Vector2D> GetCentrePositions();
107 
109  double GetVoxelCentreCoordinate(int axis, double coordinate);
110 
112  mitk::Point3D GetVoxelCentrePosition(const mitk::Point3D& position);
113 
117  bool Equals(const mitk::Point3D& selectedPosition1, const mitk::Point3D& selectedPosition2, double tolerance = -1.0);
118 
120  static bool Equals(const mitk::Vector2D& cursorPosition1, const mitk::Vector2D& cursorPosition2, double tolerance = 0.01);
121 
124  bool Equals(const std::vector<mitk::Vector2D>& cursorPositions1, const std::vector<mitk::Vector2D>& cursorPositions2, double tolerance = 0.01);
125 
127  mitk::Point3D GetRandomWorldPosition() const;
128 
131  static mitk::Vector2D GetRandomDisplayPosition();
132 
134  static std::vector<mitk::Vector2D> GetRandomDisplayPositions(std::size_t size = std::size_t(3));
135 
137  static double GetRandomScaleFactor();
138 
140  static std::vector<double> GetRandomScaleFactors(std::size_t size = std::size_t(3));
141 
143  void SetRandomPositions();
144 
145 private slots:
146 
148  void initTestCase();
149 
151  void cleanupTestCase();
152 
154  void init();
155 
157  void cleanup();
158 
160  void testViewer();
161 
163  void testSetSelectedSlice2();
164 
166  void testGetTimeGeometry();
167 
169  void testSetTimeGeometry();
170 
172  void testGetOrientation();
173 
175  void testGetSelectedPosition();
176 
178  void testSetSelectedPosition();
179 
181  void testGetSelectedSlice();
182 
184  void testSetSelectedSlice();
185 
187  void testGetCursorPosition();
188 
190  void testSetCursorPosition();
191 
193  void testGetCursorPositions();
194 
196  void testSetCursorPositions();
197 
199  void testGetWindowLayout();
200 
202  void testGetSelectedRenderWindow();
203 
205  void testSetSelectedRenderWindow();
206 
208  void testSetWindowLayout();
209 
211  void testRememberPositionsPerWindowLayout();
212 
214  void testSelectPositionByInteraction();
215 
217  void testChangeSliceByMouseInteraction();
218 
220  void testChangeSliceByKeyInteraction();
221 
223  void testSelectRenderWindowByInteraction();
224 
226  void testSelectSliceThroughSliceNavigationController();
227 
229  void testSelectPositionThroughSliceNavigationController();
230 
232  void testCursorPositionBinding();
233 
235  void testScaleFactorBinding();
236 
238  void testCursorPositionAndScaleFactorBinding();
239 
240 private:
241 
242  void DropNodes(QmitkRenderWindow* renderWindow, const std::vector<mitk::DataNode*>& nodes);
243 
244  static void MouseWheel(QWidget* window, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
245  QPoint point, int delta, Qt::Orientation orientation = Qt::Vertical);
246 
247  QScopedPointer<SingleViewerWidgetTestClassPrivate> d_ptr;
248 
249  Q_DECLARE_PRIVATE(SingleViewerWidgetTestClass)
250  Q_DISABLE_COPY(SingleViewerWidgetTestClass)
251 };
252 
253 }
254 
255 int niftkSingleViewerWidgetTest(int argc, char* argv[]);
256 
257 #endif
SingleViewerWidgetTestClass()
Constructs a niftkSingleViewerWidgetTestClass object.
Definition: niftkSingleViewerWidgetTest.cxx:114
double GetVoxelCentreCoordinate(int axis, double coordinate)
Gets one coordinate of the centre of the voxel that contains the given coordinate along the axis...
Definition: niftkSingleViewerWidgetTest.cxx:412
static mitk::Vector3D GetWorldUpDirections(const mitk::BaseGeometry *geometry)
Calculates the up direction of the world axes from a 3D geometry.
Definition: niftkSingleViewerWidgetTest.cxx:216
static std::vector< int > GetWorldAxes(const mitk::Geometry3D *geometry)
Calculates the world axes from a 3D geometry.
static mitk::Vector2D GetDisplayPositionAtPoint(QmitkRenderWindow *renderWindow, const QPoint &point)
Converts a point on the screen to a cursor position in a render window. The cursor position is a rela...
Definition: niftkSingleViewerWidgetTest.cxx:308
Test class to ensure the atomic transition from one object state to another.
Definition: niftkAtomicStateTransitionTester.h:59
Definition: niftkSingleViewerWidgetTest.h:46
Orientation
Definition: itkMIDASHelper.h:35
SingleViewerWidgetState ViewerState
Definition: niftkSingleViewerWidgetTest.h:49
Definition: ReceptorMemberCommandTest.cxx:25
std::string GetFileName() const
Gets the name of the image file to load into the viewer.
Definition: niftkSingleViewerWidgetTest.cxx:151
void SetFileName(const std::string &fileName)
Sets the name of the image file to load into the viewer.
Definition: niftkSingleViewerWidgetTest.cxx:159
Definition: niftkSingleViewerWidgetState.h:41
mitk::Vector2D GetCentrePosition(int windowIndex)
Gets the position of the centre of the displayed region, relative to the render window.
Definition: niftkSingleViewerWidgetTest.cxx:319
static double GetRandomScaleFactor()
Gives a random scale factor (mm/px) within the range (0.0, 2.0).
Definition: niftkSingleViewerWidgetTest.cxx:513
mitk::Vector2D GetDisplayPositionAtWorldPosition(int orientation, const mitk::Point3D &worldPosition)
Definition: niftkSingleViewerWidgetTest.cxx:390
SingleViewerWidgetTestClass Self
Definition: niftkSingleViewerWidgetTest.h:50
static mitk::Point3D GetWorldBottomLeftBackCorner(const mitk::BaseGeometry *geometry)
Calculates the world origin from a 3D geometry. The world origin is the centre of the bottom-left-bac...
Definition: niftkSingleViewerWidgetTest.cxx:240
mitk::Point3D GetWorldPositionAtDisplayPosition(int orientation, const mitk::Vector2D &displayPosition)
Definition: niftkSingleViewerWidgetTest.cxx:368
Definition: niftkSingleViewerWidgetTest.h:46
static std::vector< mitk::Vector2D > GetRandomDisplayPositions(std::vcl_size_t size=std::vcl_size_t(3))
Gives a vector of random diplay positions, normalised with the render window size.
Definition: niftkSingleViewerWidgetTest.cxx:501
mitk::Point3D GetRandomWorldPosition() const
Gives a random position from the image volume, in mm coordinates.
Definition: niftkSingleViewerWidgetTest.cxx:477
WorldAxes
Definition: niftkSingleViewerWidgetTest.h:46
static mitk::Vector2D GetRandomDisplayPosition()
Gives a random position in the render window, normalised with the render window size. The measurement is unit (i.e. px/px).
Definition: niftkSingleViewerWidgetTest.cxx:491
bool Equals(const mitk::Point3D &selectedPosition1, const mitk::Point3D &selectedPosition2, double tolerance=-1.0)
Determines if two world positions are equal with the certain tolerance. By default, or if negative value is specified, the tolerance is half voxel for each coordinate. Converting the positions to voxel space should result equal coordinates.
Definition: niftkSingleViewerWidgetTest.cxx:436
void SetInteractiveMode(bool interactiveMode)
Sets the interactive mode. In interactive mode the windows are not closed when the test is finished...
Definition: niftkSingleViewerWidgetTest.cxx:175
bool GetInteractiveMode() const
Gets the interactive mode. In interactive mode the windows are not closed when the test is finished...
Definition: niftkSingleViewerWidgetTest.cxx:167
static QPoint GetPointAtCursorPosition(QmitkRenderWindow *renderWindow, const mitk::Vector2D &cursorPosition)
Converts a cursor position in a render window to a point on the screen. The cursor position is a rela...
Definition: niftkSingleViewerWidgetTest.cxx:298
mitk::Point3D GetVoxelCentrePosition(const mitk::Point3D &position)
Gets the position of the centre of the voxel that contains the given position.
Definition: niftkSingleViewerWidgetTest.cxx:421
std::vector< mitk::Vector2D > GetCentrePositions()
Gets the position of the centre of the displayed regions, relative to their render windows...
Definition: niftkSingleViewerWidgetTest.cxx:342
GLsizeiptr size
Definition: glew.h:1665
static mitk::Point3D GetWorldOrigin(const mitk::BaseGeometry *geometry)
Calculates the world origin from a 3D geometry. The world origin is the centre of the bottom-left-bac...
Definition: niftkSingleViewerWidgetTest.cxx:183
Definition: niftkSingleViewerWidgetTest.h:46
Definition: niftkSingleViewerWidgetTest.h:40
static std::vector< double > GetRandomScaleFactors(std::vcl_size_t size=std::vcl_size_t(3))
Gives a vector of random scale factors (mm/px) within the range (0.0, 2.0).
Definition: niftkSingleViewerWidgetTest.cxx:520
AtomicStateTransitionTester< const SingleViewerWidget *, SingleViewerWidgetState > ViewerStateTester
Definition: niftkSingleViewerWidgetTest.h:48
void SetRandomPositions()
Sets random selected position, cursor positions and scale factors for the viewer. ...
Definition: niftkSingleViewerWidgetTest.cxx:532
int niftkSingleViewerWidgetTest(int argc, char *argv[])
Definition: niftkSingleViewerWidgetTest.cxx:3948
Definition: niftkExceptionObject.h:21
GLsizei const GLcharARB ** string
Definition: glew.h:5194
virtual ~SingleViewerWidgetTestClass()
Destructs the niftkSingleViewerWidgetTestClass object.
Definition: niftkSingleViewerWidgetTest.cxx:145