Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkStepper.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 mitkStepper_h
14 #define mitkStepper_h
15 
16 #include <mitkNumericTypes.h>
17 #include <MitkCoreExports.h>
18 #include <mitkCommon.h>
19 
20 #include <itkObject.h>
21 #include <itkObjectFactory.h>
22 
23 #include <string>
24 
25 namespace mitk
26 {
47  class MITKCORE_EXPORT Stepper : public itk::Object
48  {
49  public:
51  itkFactorylessNewMacro(Self);
52  itkCloneMacro(Self);
53  itkGetConstMacro(Pos, unsigned int);
54 
58  virtual void SetPos(unsigned int pos)
59  {
60  unsigned int newPos;
61  if (m_Steps != 0)
62  {
63  newPos = (pos > m_Steps - 1 ? m_Steps - 1 : pos);
64  }
65  else
66  {
67  newPos = 0;
68  }
69 
70  if (this->m_Pos != newPos)
71  {
72  this->m_Pos = newPos;
73  this->Modified();
74  }
75  }
76 
77  itkGetConstMacro(Steps, unsigned int);
78  itkSetMacro(Steps, unsigned int);
79 
80  itkGetConstMacro(AutoRepeat, bool);
81  itkSetMacro(AutoRepeat, bool);
82  itkBooleanMacro(AutoRepeat);
83 
85  itkSetMacro(PingPong, bool);
86  itkGetConstMacro(PingPong, bool);
87  itkBooleanMacro(PingPong);
88 
91  itkSetMacro(InverseDirection, bool);
92  itkGetConstMacro(InverseDirection, bool);
93  itkBooleanMacro(InverseDirection);
94 
99  void SetRange(ScalarType min, ScalarType max);
100 
103 
106 
109 
111  bool HasValidRange() const;
112 
114  void RemoveRange();
115 
117  bool HasRange() const;
118 
122  void SetUnitName(const char *unitName);
123 
125  const char *GetUnitName() const;
126 
129 
131  bool HasUnitName() const;
132 
137  virtual void Next();
138 
143  virtual void Previous();
144 
151  virtual void MoveSlice(int sliceDelta);
152 
154  virtual void First();
155 
157  virtual void Last();
158 
159  protected:
161  ~Stepper() override;
162 
164  void Increase();
165 
167  void Decrease();
168 
169  unsigned int m_Pos;
170 
171  unsigned int m_Steps;
172 
174 
177 
182 
183  std::string m_UnitName;
185  };
186 
187 } // namespace mitk
188 
189 #endif
#define MITKCORE_EXPORT
Helper class to step through a list.
Definition: mitkStepper.h:48
bool HasValidRange() const
Check whether the range has been set and is currently valid.
virtual void SetPos(unsigned int pos)
Set the current position, clamped to [0, GetSteps()-1].
Definition: mitkStepper.h:58
virtual void MoveSlice(int sliceDelta)
Move the position by a given delta (positive or negative).
void SetUnitName(const char *unitName)
Set the unit name string (e.g. "mm") for the stepping range.
mitkClassMacroItkParent(Stepper, itk::Object)
void Increase()
Increment position by one, respecting AutoRepeat and PingPong.
virtual void Previous()
Go to the previous position in the list.
bool m_HasUnitName
Definition: mitkStepper.h:184
ScalarType GetRangeMin() const
Get the minimum value of the range.
virtual void First()
Go to the first position (index 0).
ScalarType m_RangeMin
Definition: mitkStepper.h:178
std::string m_UnitName
Definition: mitkStepper.h:183
void InvalidateRange()
Mark the current range as invalid while keeping the range itself.
bool HasRange() const
Check whether a range has been set (may or may not be valid).
const char * GetUnitName() const
Get the unit name string.
void RemoveUnitName()
Remove the unit name.
void Decrease()
Decrement position by one, respecting AutoRepeat and PingPong.
virtual void Last()
Go to the last position (index GetSteps() - 1).
void SetRange(ScalarType min, ScalarType max)
Set the scalar range (min/max) corresponding to the step positions.
~Stepper() override
ScalarType GetRangeMax() const
Get the maximum value of the range.
unsigned int m_Pos
Definition: mitkStepper.h:169
void RemoveRange()
Remove the range entirely.
unsigned int m_Steps
Definition: mitkStepper.h:171
bool m_InverseDirection
Definition: mitkStepper.h:176
virtual void Next()
Advance to the next position in the list.
ScalarType m_RangeMax
Definition: mitkStepper.h:179
bool HasUnitName() const
Check whether a unit name has been set.
Convenience header that includes all MITK numeric types.
Find image slices visible on a given plane.
double ScalarType
Scalar type used throughout MITK for geometric computations.