Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkStepper.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 
17 #include "mitkStepper.h"
18 
20  : m_Pos(0),
21  m_Steps(0),
22  m_AutoRepeat(false),
23  m_PingPong(false),
24  m_InverseDirection(false),
25  m_RangeMin(0.0),
26  m_RangeMax(-1.0),
27  m_RangeValid(false),
28  m_HasRange(false),
29  m_HasUnitName(false)
30 {
31 }
32 
34 {
35 }
36 
38 {
39  m_RangeMin = min;
40  m_RangeMax = max;
41  m_HasRange = true;
42  m_RangeValid = true;
43  this->Modified();
44 }
45 
47 {
48  m_HasRange = true;
49  m_RangeValid = false;
50  this->Modified();
51 }
52 
54 {
55  return m_RangeMin;
56 }
57 
59 {
60  return m_RangeMax;
61 }
62 
64 {
65  m_HasRange = false;
66  this->Modified();
67 }
68 
70 {
71  return (m_HasRange && m_RangeValid);
72 }
73 
75 {
76  return m_HasRange;
77 }
78 
79 void mitk::Stepper::SetUnitName(const char *unitName)
80 {
81  m_UnitName = std::string(unitName);
82  m_HasUnitName = true;
83  this->Modified();
84 }
85 
86 const char *mitk::Stepper::GetUnitName() const
87 {
88  return m_UnitName.c_str();
89 }
90 
92 {
93  m_HasUnitName = false;
94  this->Modified();
95 }
96 
98 {
99  return m_HasUnitName;
100 }
101 
103 {
104  if (this->GetPos() < this->GetSteps() - 1)
105  {
106  this->SetPos(this->GetPos() + 1);
107  }
108  else if (m_AutoRepeat)
109  {
110  if (!m_PingPong)
111  {
112  this->SetPos(0);
113  }
114  else
115  {
116  m_InverseDirection = true;
117  if (this->GetPos() > 0)
118  {
119  this->SetPos(this->GetPos() - 1);
120  }
121  }
122  }
123 }
124 
126 {
127  if (this->GetPos() > 0)
128  {
129  this->SetPos(this->GetPos() - 1);
130  }
131  else if (m_AutoRepeat)
132  {
133  if (!m_PingPong)
134  {
135  this->SetPos(this->GetSteps() - 1);
136  }
137  else
138  {
139  m_InverseDirection = false;
140  if (this->GetPos() < this->GetSteps() - 1)
141  {
142  this->SetPos(this->GetPos() + 1);
143  }
144  }
145  }
146 }
147 
149 {
150  if (!m_InverseDirection)
151  {
152  this->Increase();
153  }
154  else
155  {
156  this->Decrease();
157  }
158 }
159 
161 {
162  if (!m_InverseDirection)
163  {
164  this->Decrease();
165  }
166  else
167  {
168  this->Increase();
169  }
170 }
171 
173 {
174  this->SetPos(0);
175 }
176 
178 {
179  this->SetPos(this->GetSteps() - 1);
180 }
void InvalidateRange()
Definition: mitkStepper.cpp:46
double ScalarType
void RemoveRange()
Definition: mitkStepper.cpp:63
bool HasValidRange() const
Definition: mitkStepper.cpp:69
void RemoveUnitName()
Definition: mitkStepper.cpp:91
ScalarType GetRangeMax() const
Definition: mitkStepper.cpp:58
virtual void First()
void SetRange(ScalarType min, ScalarType max)
Definition: mitkStepper.cpp:37
bool HasUnitName() const
Definition: mitkStepper.cpp:97
virtual void Previous()
ScalarType GetRangeMin() const
Definition: mitkStepper.cpp:53
const char * GetUnitName() const
Definition: mitkStepper.cpp:86
static T max(T x, T y)
Definition: svm.cpp:70
void SetUnitName(const char *unitName)
Definition: mitkStepper.cpp:79
virtual void Last()
static T min(T x, T y)
Definition: svm.cpp:67
virtual void Next()
virtual ~Stepper()
Definition: mitkStepper.cpp:33
bool HasRange() const
Definition: mitkStepper.cpp:74