15 #ifndef niftkSingleViewerWidgetState_h
16 #define niftkSingleViewerWidgetState_h
22 #include <mitkGlobalInteraction.h>
28 static bool EqualsWithTolerance1(
const mitk::Point3D& worldPosition1,
const mitk::Point3D& worldPosition2,
double tolerance = 0.001)
30 return std::abs(worldPosition1[0] - worldPosition2[0]) < tolerance
31 && std::abs(worldPosition1[1] - worldPosition2[1]) < tolerance
32 && std::abs(worldPosition1[2] - worldPosition2[2]) < tolerance;
35 static bool EqualsWithTolerance(
const mitk::Vector2D& cursorPosition1,
const mitk::Vector2D& cursorPosition2,
double tolerance = 0.01)
37 return std::abs(cursorPosition1[0] - cursorPosition2[0]) < tolerance
38 && std::abs(cursorPosition1[1] - cursorPosition2[1]) < tolerance;
50 itkGetConstMacro(TimeGeometry, const
mitk::TimeGeometry*);
53 itkSetObjectMacro(TimeGeometry,
mitk::TimeGeometry);
59 itkSetMacro(Orientation, WindowOrientation);
65 itkSetMacro(WindowLayout, WindowLayout);
68 itkGetConstMacro(SelectedRenderWindow, QmitkRenderWindow*);
71 itkSetObjectMacro(SelectedRenderWindow, QmitkRenderWindow);
74 itkGetConstMacro(TimeStep,
unsigned);
77 itkSetMacro(TimeStep,
unsigned);
80 itkGetConstMacro(SelectedPosition,
mitk::Point3D);
83 itkSetMacro(SelectedPosition,
mitk::Point3D);
86 itkGetConstMacro(CursorPositions,
std::vector<
mitk::Vector2D>);
91 this->m_CursorPositions = cursorPositions;
95 itkGetConstMacro(ScaleFactors, std::vector<double>);
100 m_ScaleFactors = scaleFactors;
104 itkGetConstMacro(CursorPositionBinding,
bool);
107 itkSetMacro(CursorPositionBinding,
bool);
110 itkGetConstMacro(ScaleFactorBinding,
bool);
113 itkSetMacro(ScaleFactorBinding,
bool);
117 bool EqualsWithTolerance(
const std::vector<mitk::Vector2D>& cursorPositions1,
const std::vector<mitk::Vector2D>& cursorPositions2,
double tolerance = 0.001)
const
119 std::vector<QmitkRenderWindow*> renderWindows = m_Viewer->
GetRenderWindows();
120 for (
int i = 0; i < 3; ++i)
132 bool EqualsWithTolerance(
const std::vector<double>& scaleFactors1,
const std::vector<double>& scaleFactors2,
double tolerance = 0.001)
const
134 std::vector<QmitkRenderWindow*> renderWindows = m_Viewer->
GetRenderWindows();
135 for (
int i = 0; i < 3; ++i)
148 this->GetTimeGeometry() == otherState.GetTimeGeometry()
162 return !(*
this == otherState);
165 void PrintDifference(SingleViewerWidgetState::Pointer otherState, std::ostream & os = std::cout, itk::Indent indent = 0)
const
167 if (this->GetTimeGeometry() != otherState->GetTimeGeometry())
169 os << indent <<
"Time geometry: " << this->GetTimeGeometry() <<
" ; " << otherState->GetTimeGeometry() << std::endl;
173 os << indent <<
"Orientation: " << this->
GetOrientation() <<
" ; " << otherState->GetOrientation() << std::endl;
177 os << indent <<
"Window layout: " << this->
GetWindowLayout() <<
" ; " << otherState->GetWindowLayout() << std::endl;
181 os << indent <<
"Selected render window: " << this->
GetSelectedRenderWindow() <<
" ; " << otherState->GetOrientation() << std::endl;
183 if (this->
GetTimeStep() != otherState->GetTimeStep())
185 os << indent <<
"Time step: " << this->
GetTimeStep() <<
" ; " << otherState->GetTimeStep() << std::endl;
189 os << indent <<
"Selected position: " << this->
GetSelectedPosition() <<
", " << otherState->GetSelectedPosition() << std::endl;
193 std::vector<mitk::Vector2D> otherStateCursorPositions = otherState->GetCursorPositions();
194 os << indent <<
"Cursor positions:" << std::endl;
195 os << indent <<
" " << m_CursorPositions[0] <<
", " << otherStateCursorPositions[0] << std::endl;
196 os << indent <<
" " << m_CursorPositions[1] <<
", " << otherStateCursorPositions[1] << std::endl;
197 os << indent <<
" " << m_CursorPositions[2] <<
", " << otherStateCursorPositions[2] << std::endl;
201 std::vector<double> otherStateScaleFactors = otherState->GetScaleFactors();
202 os << indent <<
"Scale factors:" << std::endl;
203 os << indent <<
" " << m_ScaleFactors[0] <<
", " << otherStateScaleFactors[0] << std::endl;
204 os << indent <<
" " << m_ScaleFactors[1] <<
", " << otherStateScaleFactors[1] << std::endl;
205 os << indent <<
" " << m_ScaleFactors[2] <<
", " << otherStateScaleFactors[2] << std::endl;
209 os << indent <<
"Cursor position binding: " << this->
GetCursorPositionBinding() <<
" ; " << otherState->GetCursorPositionBinding() << std::endl;
213 os << indent <<
"Scale factor binding: " << this->
GetScaleFactorBinding() <<
" ; " << otherState->GetScaleFactorBinding() << std::endl;
222 if (!selectedRenderWindow)
224 MITK_INFO <<
"ERROR: Invalid state. The viewer is selected but there is no selected render window.";
225 MITK_INFO << Self::ConstPointer(
this);
226 QFAIL(
"Invalid state. The viewer is selected but there is no selected render window.");
232 if (qApp->focusWidget() && !selectedRenderWindow->hasFocus())
234 MITK_INFO <<
"ERROR: Invalid state. The viewer is selected but the selected render window has not got the Qt key focus.";
235 MITK_INFO << Self::ConstPointer(
this);
236 QFAIL(
"Invalid state. The viewer is selected but the selected render window has not got the Qt key focus.");
238 if (mitk::GlobalInteraction::GetInstance()->GetFocus() != selectedRenderWindow->GetRenderer())
240 MITK_INFO <<
"ERROR: Invalid state. The viewer is selected but the selected render window has not got the MITK interaction focus.";
241 MITK_INFO << Self::ConstPointer(
this);
242 QFAIL(
"Invalid state. The viewer is selected but the selected render window has not got the MITK interaction focus.");
248 if (!selectedRenderWindow)
250 MITK_INFO <<
"ERROR: Invalid state. The viewer is selected but there is no selected render window.";
251 MITK_INFO << Self::ConstPointer(
this);
252 QFAIL(
"Invalid state. The viewer is selected but there is no selected render window.");
258 || m_Viewer->hasFocus())
260 MITK_INFO <<
"ERROR: Invalid state. The viewer has the Qt focus, although it is not selected.";
261 MITK_INFO << Self::ConstPointer(
this);
262 QFAIL(
"Invalid state. The viewer has the Qt focus, although it is not selected.");
264 mitk::BaseRenderer* focusedRenderer = mitk::GlobalInteraction::GetInstance()->GetFocus();
268 || focusedRenderer == m_Viewer->
Get3DWindow()->GetRenderer())
270 MITK_INFO <<
"ERROR: Invalid state. The viewer has the MITK interaction focus, although it is not selected.";
271 MITK_INFO << Self::ConstPointer(
this);
272 QFAIL(
"Invalid state. The viewer has the MITK interaction focus, although it is not selected.");
292 mitk::SliceNavigationController* axialSnc = m_Viewer->
GetAxialWindow()->GetSliceNavigationController();
293 mitk::SliceNavigationController* sagittalSnc = m_Viewer->
GetSagittalWindow()->GetSliceNavigationController();
294 mitk::SliceNavigationController* coronalSnc = m_Viewer->
GetCoronalWindow()->GetSliceNavigationController();
296 QVERIFY(axialMaxSliceIndex == axialSnc->GetSlice()->GetSteps() - 1);
297 QVERIFY(sagittalMaxSliceIndex == sagittalSnc->GetSlice()->GetSteps() - 1);
298 QVERIFY(coronalMaxSliceIndex == coronalSnc->GetSlice()->GetSteps() - 1);
300 int axialSncPos = axialSnc->GetSlice()->GetPos();
301 int sagittalSncPos = sagittalSnc->GetSlice()->GetPos();
302 int coronalSncPos = coronalSnc->GetSlice()->GetPos();
304 int expectedAxialSliceIndex = m_UpDirections[2] > 0 ? axialSncPos : axialMaxSliceIndex - axialSncPos;
305 int expectedSagittalSliceIndex = m_UpDirections[0] > 0 ? sagittalSncPos : sagittalMaxSliceIndex - sagittalSncPos;
306 int expectedCoronalSliceIndex = m_UpDirections[1] > 0 ? coronalSncPos : coronalMaxSliceIndex - coronalSncPos;
308 if (axialSliceIndex != expectedAxialSliceIndex
309 || sagittalSliceIndex != expectedSagittalSliceIndex
310 || coronalSliceIndex != expectedCoronalSliceIndex)
330 , m_TimeGeometry(viewer->GetTimeGeometry())
349 , m_Viewer(otherState->m_Viewer)
350 , m_TimeGeometry(otherState->GetTimeGeometry())
360 , m_UpDirections(otherState->m_UpDirections)
370 virtual void PrintSelf(std::ostream & os, itk::Indent indent)
const override
373 os << indent <<
"orientation: " << m_Orientation << std::endl;
374 os << indent <<
"window layout: " << m_WindowLayout << std::endl;
375 if (m_SelectedRenderWindow)
377 os << indent <<
"selected render window: " << m_SelectedRenderWindow <<
", " << m_SelectedRenderWindow->GetRenderer()->GetName() << std::endl;
381 os << indent <<
"selected render window: none" << std::endl;
383 os << indent <<
"time step: " << m_TimeStep << std::endl;
384 os << indent <<
"selected position: " << m_SelectedPosition << std::endl;
385 os << indent <<
"cursor positions: " << m_CursorPositions[0] <<
", " << m_CursorPositions[1] <<
", " << m_CursorPositions[2] << std::endl;
386 os << indent <<
"scale factors: " << m_ScaleFactors[0] <<
", " << m_ScaleFactors[1] <<
", " << m_ScaleFactors[2] << std::endl;
387 os << indent <<
"cursor position binding: " << m_CursorPositionBinding << std::endl;
388 os << indent <<
"scale factor binding: " << m_ScaleFactorBinding << std::endl;
397 const mitk::TimeGeometry* m_TimeGeometry;
406 QmitkRenderWindow* m_SelectedRenderWindow;
412 mitk::Point3D m_SelectedPosition;
415 std::vector<mitk::Vector2D> m_CursorPositions;
418 std::vector<double> m_ScaleFactors;
421 bool m_CursorPositionBinding;
424 bool m_ScaleFactorBinding;
427 mitk::Vector3D m_UpDirections;
WindowOrientation
Describes the different types of orientation, axial, sagittal, coronal, that can be achieved in the D...
Definition: niftkDnDDisplayEnums.h:29
Definition: niftkDnDDisplayEnums.h:31
static bool EqualsWithTolerance(const mitk::Vector2D &cursorPosition1, const mitk::Vector2D &cursorPosition2, double tolerance=0.01)
Definition: niftkSingleViewerWidgetState.h:35
Orientation
Definition: itkMIDASHelper.h:35
Definition: niftkMeshSmoother.cxx:19
Definition: ReceptorMemberCommandTest.cxx:25
Definition: niftkITKAffineResampleImage.cxx:74
WindowLayout
Describes the different render window layouts. So one WindowLayout could have multiple windows of dif...
Definition: niftkDnDDisplayEnums.h:49
Definition: niftkDnDDisplayEnums.h:32
static bool EqualsWithTolerance1(const mitk::Point3D &worldPosition1, const mitk::Point3D &worldPosition2, double tolerance=0.001)
Definition: niftkSingleViewerWidgetState.h:28
Definition: niftkExceptionObject.h:21
Definition: niftkDnDDisplayEnums.h:33