Medical Imaging Interaction Toolkit  2018.4.99-6a3ea89d
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 STEPPER_H_HEADER_INCLUDED_C1E77191
14 #define STEPPER_H_HEADER_INCLUDED_C1E77191
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 
55  virtual void SetPos(unsigned int pos)
56  {
57  // copied from itkMacro.h, itkSetClampMacro(...)
58  unsigned int newPos;
59  if (m_Steps != 0)
60  {
61  newPos = (pos > m_Steps - 1 ? m_Steps - 1 : pos);
62  }
63  else
64  {
65  newPos = 0;
66  }
67 
68  if (this->m_Pos != newPos)
69  {
70  this->m_Pos = newPos;
71  this->Modified();
72  }
73  }
74 
75  itkGetConstMacro(Steps, unsigned int);
76  itkSetMacro(Steps, unsigned int);
77 
78  itkGetConstMacro(AutoRepeat, bool);
79  itkSetMacro(AutoRepeat, bool);
80  itkBooleanMacro(AutoRepeat);
81 
83  itkSetMacro(PingPong, bool);
84  itkGetConstMacro(PingPong, bool);
85  itkBooleanMacro(PingPong);
86 
89  itkSetMacro(InverseDirection, bool);
90  itkGetConstMacro(InverseDirection, bool);
91  itkBooleanMacro(InverseDirection);
92 
93  void SetRange(ScalarType min, ScalarType max);
94  void InvalidateRange();
95  ScalarType GetRangeMin() const;
96  ScalarType GetRangeMax() const;
97  bool HasValidRange() const;
98  void RemoveRange();
99  bool HasRange() const;
100 
101  void SetUnitName(const char *unitName);
102  const char *GetUnitName() const;
103  void RemoveUnitName();
104  bool HasUnitName() const;
105 
106  virtual void Next();
107 
108  virtual void Previous();
109 
110  virtual void MoveSlice(int sliceDelta);
111 
112  virtual void First();
113 
114  virtual void Last();
115 
116  protected:
117  Stepper();
118  ~Stepper() override;
119 
120  void Increase();
121 
122  void Decrease();
123 
124  unsigned int m_Pos;
125 
126  unsigned int m_Steps;
127 
129 
132 
137 
138  std::string m_UnitName;
140  };
141 
142 } // namespace mitk
143 
144 #endif /* STEPPER_H_HEADER_INCLUDED_C1E77191 */
#define MITKCORE_EXPORT
std::string m_UnitName
Definition: mitkStepper.h:138
ScalarType m_RangeMax
Definition: mitkStepper.h:134
double ScalarType
DataCollection - Class to facilitate loading/accessing structured data.
ScalarType m_RangeMin
Definition: mitkStepper.h:133
bool m_HasUnitName
Definition: mitkStepper.h:139
unsigned int m_Pos
Definition: mitkStepper.h:124
bool m_InverseDirection
Definition: mitkStepper.h:131
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:49
unsigned int m_Steps
Definition: mitkStepper.h:126
virtual void SetPos(unsigned int pos)
Definition: mitkStepper.h:55
static T max(T x, T y)
Definition: svm.cpp:56
static T min(T x, T y)
Definition: svm.cpp:53
Helper class to step through a list.
Definition: mitkStepper.h:47