VTK
vtkQtChartColors.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkQtChartColors.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16  Copyright 2008 Sandia Corporation.
17  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18  the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
20 
23 
24 #ifndef _vtkQtChartColors_h
25 #define _vtkQtChartColors_h
26 
27 #include "vtkQtChartExport.h"
28 #include <QColor> // Needed for return type.
29 
30 class vtkQtChartColorsInternal;
31 
32 
36 class VTKQTCHART_EXPORT vtkQtChartColors
37 {
38 public:
40  {
41  Spectrum = 0,
42  Warm,
43  Cool,
47  Custom
48  };
49 
50 public:
54  vtkQtChartColors(ColorScheme scheme=Spectrum);
55 
59  vtkQtChartColors(const vtkQtChartColors &other);
61 
67  vtkQtChartColors &operator=(const vtkQtChartColors &other);
68 
73  ColorScheme getColorScheme() const {return this->Scheme;}
74 
82  void setColorScheme(ColorScheme scheme);
83 
88  int getNumberOfColors() const;
89 
94  QColor getColor(int index) const;
95 
103  void setColor(int index, const QColor &color);
104 
106  void clearColors();
107 
111  void addColor(const QColor &color);
112 
117  void insertColor(int index, const QColor &color);
118 
122  void removeColor(int index);
123 
124 public:
140  static QColor lighter(const QColor &color, float factor=0.7);
141 
153  static QColor interpolateHsv(const QColor &color1, const QColor &color2,
154  float fraction);
155 
164  static QColor interpolateRgb(const QColor &color1, const QColor &color2,
165  float fraction);
166 
167 private:
176  static float getDistance(float x1, float y1, float z1, float x2, float y2,
177  float z2);
178 
189  static float getComponent(float x1, float x2, float f, float s);
190 
191 private:
192  vtkQtChartColorsInternal *Internal;
193  ColorScheme Scheme;
194 };
195 
196 #endif