Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkScaleLogarithmicTransformView.cpp
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 
18 #include "mitkImageAccessByItk.h"
19 #include <QValidator>
20 #include <itkScaleLogarithmicTransform.h>
21 
24 {
25 }
26 
28 {
29 }
30 
32 {
34 }
35 
37 {
38  if (m_FixedImage.IsNotNull())
39  {
40  AccessByItk(m_FixedImage, GetTransform2);
41  return m_TransformObject;
42  }
43  return nullptr;
44 }
45 
46 template <class TPixelType, unsigned int VImageDimension>
47 itk::Object::Pointer QmitkScaleLogarithmicTransformView::GetTransform2(
48  itk::Image<TPixelType, VImageDimension> * /*itkImage1*/)
49 {
50  typedef typename itk::Image<TPixelType, VImageDimension> FixedImageType;
51  typedef typename itk::Image<TPixelType, VImageDimension> MovingImageType;
54  transformPointer->SetIdentity();
55  m_TransformObject = transformPointer.GetPointer();
56  return transformPointer.GetPointer();
57 }
58 
60 {
61  itk::Array<double> transformValues;
62  transformValues.SetSize(4);
63  transformValues.fill(0);
64  transformValues[0] = m_Controls.m_UseOptimizerScalesScaleLogarithmic->isChecked();
65  transformValues[1] = m_Controls.m_ScalesScaleLogarithmicTransformScaleX->text().toDouble();
66  transformValues[2] = m_Controls.m_ScalesScaleLogarithmicTransformScaleY->text().toDouble();
67  transformValues[3] = m_Controls.m_ScalesScaleLogarithmicTransformScaleZ->text().toDouble();
68  return transformValues;
69 }
70 
71 void QmitkScaleLogarithmicTransformView::SetTransformParameters(itk::Array<double> transformValues)
72 {
73  m_Controls.m_UseOptimizerScalesScaleLogarithmic->setChecked(transformValues[0]);
74  m_Controls.m_ScalesScaleLogarithmicTransformScaleX->setText(QString::number(transformValues[1]));
75  m_Controls.m_ScalesScaleLogarithmicTransformScaleY->setText(QString::number(transformValues[2]));
76  m_Controls.m_ScalesScaleLogarithmicTransformScaleZ->setText(QString::number(transformValues[3]));
77 }
78 
80 {
81  return "ScaleLogarithmic";
82 }
83 
85 {
86  m_Controls.setupUi(parent);
87  QValidator *validatorLineEditInputFloat = new QDoubleValidator(0, 20000000, 8, this);
88  m_Controls.m_ScalesScaleLogarithmicTransformScaleX->setValidator(validatorLineEditInputFloat);
89  m_Controls.m_ScalesScaleLogarithmicTransformScaleY->setValidator(validatorLineEditInputFloat);
90  m_Controls.m_ScalesScaleLogarithmicTransformScaleZ->setValidator(validatorLineEditInputFloat);
91 }
92 
94 {
95  itk::Array<double> scales;
96  scales.SetSize(3);
97  scales.Fill(1.0);
98  if (m_Controls.m_UseOptimizerScalesScaleLogarithmic->isChecked())
99  {
100  scales[0] = m_Controls.m_ScalesScaleLogarithmicTransformScaleX->text().toDouble();
101  scales[1] = m_Controls.m_ScalesScaleLogarithmicTransformScaleY->text().toDouble();
102  scales[2] = m_Controls.m_ScalesScaleLogarithmicTransformScaleZ->text().toDouble();
103  }
104  return scales;
105 }
106 
107 vtkTransform *QmitkScaleLogarithmicTransformView::Transform(vtkMatrix4x4 *vtkmatrix,
108  vtkTransform *vtktransform,
109  itk::Array<double> transformParams)
110 {
111  if (m_MovingImage.IsNotNull())
112  {
113  for (unsigned int i = 0; i < transformParams.size(); i++)
114  {
115  vtkmatrix->SetElement(i, i, transformParams[i]);
116  }
117  vtktransform->SetMatrix(vtkmatrix);
118  }
119  return vtktransform;
120 }
121 
123 {
124  if (m_FixedImage.IsNotNull())
125  {
126  if (m_FixedImage->GetDimension() == 2)
127  {
128  m_Controls.m_ScalesScaleLogarithmicTransformScaleZ->hide();
129  m_Controls.textLabel3_5_3->hide();
130  return 2;
131  }
132  else
133  {
134  m_Controls.m_ScalesScaleLogarithmicTransformScaleZ->show();
135  m_Controls.textLabel3_5_3->show();
136  return 3;
137  }
138  }
139  else
140  return 0;
141 }
itk::SmartPointer< Self > Pointer
QmitkScaleLogarithmicTransformView(QWidget *parent=nullptr, Qt::WindowFlags f=nullptr)
Ui::QmitkScaleLogarithmicTransformControls m_Controls
virtual void SetTransformParameters(itk::Array< double > transformValues) override
virtual mitk::TransformParameters::TransformType GetTransformType() override
virtual void SetupUI(QWidget *parent) override
virtual itk::Object::Pointer GetTransform() override
virtual itk::Array< double > GetScales() override
TransformType
Unique integer value for every transform.
#define AccessByItk(mitkImage, itkImageTypeFunction)
Access a MITK image by an ITK image.
virtual vtkTransform * Transform(vtkMatrix4x4 *vtkmatrix, vtkTransform *vtktransform, itk::Array< double > transformParams) override
virtual itk::Array< double > GetTransformParameters() override
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.