Medical Imaging Interaction Toolkit  2018.4.99-389bf124
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 (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 #include <mitkColorConversions.h>
14 
15 namespace mitk
16 {
18  {
19  color_h = -60.0; // after the first increase this will yield red
20  color_s = 1.0; // full saturation
21  color_v = 1.0; // full value
22  color_cycle = 0;
23  }
24 
26  {
27  // nothing to do
28  }
29 
31  {
32  color_h += 60.0;
33  if (color_h < 0.0)
34  color_h = 0.0;
35 
36  if (color_h >= 360.0)
37  {
38  if (color_cycle == 0)
39  {
40  color_h = 30.0;
41  color_s = 1.0;
42  color_v = 1.0;
43  color_cycle = 1;
44  }
45  else if (color_cycle == 1)
46  {
47  color_h = 0.0;
48  color_s = 0.5;
49  color_v = 1.0;
50  color_cycle = 2;
51  }
52  else if (color_cycle == 2)
53  {
54  color_h = 30.0;
55  color_s = 0.5;
56  color_v = 1.0;
57  color_cycle = 3;
58  }
59  else if (color_cycle == 3)
60  {
61  color_h = 0.0;
62  color_s = 1.0;
63  color_v = 0.5;
64  color_cycle = 4;
65  }
66  else if (color_cycle == 4)
67  {
68  color_h = 30.0;
69  color_s = 1.0;
70  color_v = 0.5;
71  color_cycle = 5;
72  }
73  else if (color_cycle == 5)
74  {
75  color_h = 0.0;
76  color_s = 1.0;
77  color_v = 1.0;
78  color_cycle = 0;
79  }
80  }
81 
82  // convert to rgb
83  float r, g, b;
85 
86  Color returnColor;
87  returnColor.Set(r, g, b);
88 
89  return returnColor;
90  }
91 
93  {
94  color_h = -60.0; // after the first increase this will yield red
95  color_s = 1.0; // full saturation
96  color_v = 1.0; // full value
97  color_cycle = 0;
98  }
99 
100  void ColorSequenceCycleH::ChangeHueValueByCycleSteps(int steps) { color_h += (float)(steps * 60.0); }
102  void ColorSequenceCycleH::SetColorCycle(unsigned short cycle)
103  {
104  if (cycle > 5)
105  cycle = 5;
106  color_cycle = cycle;
107  color_h = 360.0;
108  this->GetNextColor();
109  }
110 
111 } // mitk
void GoToBegin() override
Rewind to first color.
DataCollection - Class to facilitate loading/accessing structured data.
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