Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkMultiStepper.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 "mitkMultiStepper.h"
18 #include "mitkStepper.h"
19 
21 {
22 }
23 
25 {
26 }
27 void mitk::MultiStepper::AddStepper(Stepper::Pointer stepper, unsigned int repeat)
28 {
29  m_SubSteppers.insert(stepper);
30  m_ScaleFactors.insert(std::make_pair(stepper, repeat));
31  UpdateStepCount();
32 }
33 void mitk::MultiStepper::RemoveStepper(Stepper::Pointer stepper, unsigned int /* repeat */)
34 {
35  m_SubSteppers.erase(stepper);
36  m_ScaleFactors.erase(stepper);
37  UpdateStepCount();
38 }
39 /*void mitk::MultiStepper::Next() {
40  for (StepperSet::iterator it = m_SubSteppers.begin(); it != m_SubSteppers.end() ; it++ ) {
41  (*it)->Next();
42  }
43 }
44 void mitk::MultiStepper::Previous() {
45  for (StepperSet::iterator it = m_SubSteppers.begin(); it != m_SubSteppers.end() ; it++ ) {
46  (*it)->Previous();
47  }
48 }
49 void mitk::MultiStepper::First() {
50  for (StepperSet::iterator it = m_SubSteppers.begin(); it != m_SubSteppers.end() ; it++ ) {
51  (*it)->First();
52  }
53 }
54 void mitk::MultiStepper::Last() {
55  for (StepperSet::iterator it = m_SubSteppers.begin(); it != m_SubSteppers.end() ; it++ ) {
56  (*it)->Last();
57  }
58 }*/
59 
60 void mitk::MultiStepper::SetPos(unsigned int pos)
61 {
62  Stepper::SetPos(pos);
63  for (auto it = m_SubSteppers.begin(); it != m_SubSteppers.end(); it++)
64  {
65  unsigned int count = (*it)->GetSteps() * m_ScaleFactors[(*it)];
66  if ((this->GetSteps() != 0) && ((*it)->GetSteps() != 0))
67  {
68  (*it)->SetPos((pos * count / this->GetSteps()) % (*it)->GetSteps());
69  }
70  }
71 };
72 
73 void mitk::MultiStepper::SetSteps(unsigned int /*steps*/)
74 {
75  assert(false);
76 };
77 
79 {
80  m_Steps = 0;
81  m_LargestRangeStepper = nullptr;
82  for (auto it = m_SubSteppers.begin(); it != m_SubSteppers.end(); it++)
83  {
84  unsigned int count = (*it)->GetSteps() * m_ScaleFactors[(*it)];
85  if (count > m_Steps)
86  {
87  m_Steps = count;
88  m_LargestRangeStepper = *it;
89  }
90  }
91 }
void AddStepper(Stepper::Pointer stepper, unsigned int repeat=1)
void RemoveStepper(Stepper::Pointer stepper, unsigned int repeat=1)
virtual void SetPos(unsigned int pos)
Definition: mitkStepper.h:59
void SetSteps(const unsigned int steps) override
void SetPos(unsigned int pos) override