Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkColorSequenceCycleH.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 #include <mitkColorConversions.h>
18 
19 namespace mitk
20 {
22  {
23  color_h = -60.0; // after the first increase this will yield red
24  color_s = 1.0; // full saturation
25  color_v = 1.0; // full value
26  color_cycle = 0;
27  }
28 
30  {
31  // nothing to do
32  }
33 
35  {
36  color_h += 60.0;
37  if (color_h < 0.0)
38  color_h = 0.0;
39 
40  if (color_h >= 360.0)
41  {
42  if (color_cycle == 0)
43  {
44  color_h = 30.0;
45  color_s = 1.0;
46  color_v = 1.0;
47  color_cycle = 1;
48  }
49  else if (color_cycle == 1)
50  {
51  color_h = 0.0;
52  color_s = 0.5;
53  color_v = 1.0;
54  color_cycle = 2;
55  }
56  else if (color_cycle == 2)
57  {
58  color_h = 30.0;
59  color_s = 0.5;
60  color_v = 1.0;
61  color_cycle = 3;
62  }
63  else if (color_cycle == 3)
64  {
65  color_h = 0.0;
66  color_s = 1.0;
67  color_v = 0.5;
68  color_cycle = 4;
69  }
70  else if (color_cycle == 4)
71  {
72  color_h = 30.0;
73  color_s = 1.0;
74  color_v = 0.5;
75  color_cycle = 5;
76  }
77  else if (color_cycle == 5)
78  {
79  color_h = 0.0;
80  color_s = 1.0;
81  color_v = 1.0;
82  color_cycle = 0;
83  }
84  }
85 
86  // convert to rgb
87  float r, g, b;
89 
90  Color returnColor;
91  returnColor.Set(r, g, b);
92 
93  return returnColor;
94  }
95 
97  {
98  color_h = -60.0; // after the first increase this will yield red
99  color_s = 1.0; // full saturation
100  color_v = 1.0; // full value
101  color_cycle = 0;
102  }
103 
104  void ColorSequenceCycleH::ChangeHueValueByCycleSteps(int steps) { color_h += (float)(steps * 60.0); }
106  void ColorSequenceCycleH::SetColorCycle(unsigned short cycle)
107  {
108  if (cycle > 5)
109  cycle = 5;
110  color_cycle = cycle;
111  color_h = 360.0;
112  this->GetNextColor();
113  }
114 
115 } // mitk
virtual void GoToBegin() override
Rewind to first color.
DataCollection - Class to facilitate loading/accessing structured data.
virtual Color GetNextColor() override
Return another color.
virtual void SetColorCycle(unsigned short cycle)
Set the color cycle. The color cycle has to be an integer value between 0 and 5 (see class descriptio...
virtual void ChangeHueValueByAbsoluteNumber(float number)
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
virtual void ChangeHueValueByCycleSteps(int steps)
Increase the used Hue value. This can be done by steps ( = steps * 60 increase of Hue ) or absolute (...
void Hsv2Rgb(float h, float s, float v, float &r, float &g, float &b)
convert a HSV color to RGB color, H from 0 to 360, all other parameters 0 to 1