Medical Imaging Interaction Toolkit  2016.11.0
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,
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 #ifndef STEPPER_H_HEADER_INCLUDED_C1E77191
18 #define STEPPER_H_HEADER_INCLUDED_C1E77191
19 
20 #include "mitkNumericTypes.h"
21 #include <MitkCoreExports.h>
22 #include <mitkCommon.h>
23 
24 #include <itkObject.h>
25 #include <itkObjectFactory.h>
26 
27 #include <string>
28 
29 namespace mitk
30 {
51  class MITKCORE_EXPORT Stepper : public itk::Object
52  {
53  public:
55  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
56 
57  itkGetConstMacro(Pos, unsigned int);
58 
59  virtual void SetPos(unsigned int pos)
60  {
61  // copied from itkMacro.h, itkSetClampMacro(...)
62  unsigned int newPos;
63  if (m_Steps != 0)
64  {
65  newPos = (pos > m_Steps - 1 ? m_Steps - 1 : pos);
66  }
67  else
68  {
69  newPos = 0;
70  }
71 
72  if (this->m_Pos != newPos)
73  {
74  this->m_Pos = newPos;
75  this->Modified();
76  }
77  }
78 
79  itkGetConstMacro(Steps, unsigned int);
80  itkSetMacro(Steps, unsigned int);
81 
82  itkGetConstMacro(AutoRepeat, bool);
83  itkSetMacro(AutoRepeat, bool);
84  itkBooleanMacro(AutoRepeat);
85 
87  itkSetMacro(PingPong, bool);
88  itkGetConstMacro(PingPong, bool);
89  itkBooleanMacro(PingPong);
90 
93  itkSetMacro(InverseDirection, bool);
94  itkGetConstMacro(InverseDirection, bool);
95  itkBooleanMacro(InverseDirection);
96 
97  void SetRange(ScalarType min, ScalarType max);
98  void InvalidateRange();
99  ScalarType GetRangeMin() const;
100  ScalarType GetRangeMax() const;
101  bool HasValidRange() const;
102  void RemoveRange();
103  bool HasRange() const;
104 
105  void SetUnitName(const char *unitName);
106  const char *GetUnitName() const;
107  void RemoveUnitName();
108  bool HasUnitName() const;
109 
110  virtual void Next();
111 
112  virtual void Previous();
113 
114  virtual void First();
115 
116  virtual void Last();
117 
118  protected:
119  Stepper();
120  virtual ~Stepper();
121 
122  void Increase();
123 
124  void Decrease();
125 
126  unsigned int m_Pos;
127 
128  unsigned int m_Steps;
129 
131 
134 
139 
140  std::string m_UnitName;
142  };
143 
144 } // namespace mitk
145 
146 #endif /* STEPPER_H_HEADER_INCLUDED_C1E77191 */
#define MITKCORE_EXPORT
std::string m_UnitName
Definition: mitkStepper.h:140
ScalarType m_RangeMax
Definition: mitkStepper.h:136
double ScalarType
DataCollection - Class to facilitate loading/accessing structured data.
ScalarType m_RangeMin
Definition: mitkStepper.h:135
bool m_HasUnitName
Definition: mitkStepper.h:141
unsigned int m_Pos
Definition: mitkStepper.h:126
bool m_InverseDirection
Definition: mitkStepper.h:133
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:53
unsigned int m_Steps
Definition: mitkStepper.h:128
static T max(T x, T y)
Definition: svm.cpp:70
static T min(T x, T y)
Definition: svm.cpp:67
Helper class to step through a list.
Definition: mitkStepper.h:51