File: colorscale.h

package info (click to toggle)
aoflagger 3.4.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,960 kB
  • sloc: cpp: 83,076; python: 10,187; sh: 260; makefile: 178
file content (74 lines) | stat: -rw-r--r-- 2,111 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef PLOT_COLORSCALE_H
#define PLOT_COLORSCALE_H

#include <string>
#include <map>

#include "verticalplotscale.h"

#include <gtkmm/drawingarea.h>

class ColorScale {
 public:
  ColorScale();
  void Clear() { _colorValues.clear(); }
  void SetPlotDimensions(double plotWidth, double plotHeight, double topMargin,
                         bool textOnLeft) {
    _plotWidth = plotWidth;
    _plotHeight = plotHeight;
    _topMargin = topMargin;
    _width = 0.0;
    _textOnLeft = textOnLeft;
  }
  double GetWidth(const Cairo::RefPtr<Cairo::Context>& cairo) {
    if (_width == 0.0) initWidth(cairo);
    return _width;
  }
  void Draw(const Cairo::RefPtr<Cairo::Context>& cairo);
  void SetAxisType(AxisType axisType) {
    _verticalPlotScale.SetAxisType(axisType);
  }
  void SetTickRange(double min, double max) {
    _verticalPlotScale.SetTickRange(min, max);
  }
  void SetLogarithmic(bool logarithmic) {
    _verticalPlotScale.SetLogarithmic(logarithmic);
  }
  void InitializeTicks() { _verticalPlotScale.InitializeTicks(); }
  void SetColorValue(double value, double red, double green, double blue) {
    ColorValue cValue;
    cValue.red = red;
    cValue.green = green;
    cValue.blue = blue;
    _colorValues.insert(std::pair<double, ColorValue>(value, cValue));
  }
  void SetDescriptionFontSize(double fontSize) {
    _verticalPlotScale.SetDescriptionFontSize(fontSize);
  }
  void SetTickValuesFontSize(double fontSize) {
    _verticalPlotScale.SetTickValuesFontSize(fontSize);
  }
  void SetDrawWithDescription(bool drawWithDescription) {
    _verticalPlotScale.SetDrawWithDescription(drawWithDescription);
  }
  void SetUnitsCaption(const std::string& caption) {
    _verticalPlotScale.SetUnitsCaption(caption);
  }

 private:
  static const double BAR_WIDTH;

  struct ColorValue {
    double red, green, blue;
  };

  void initWidth(const Cairo::RefPtr<Cairo::Context>& cairo);

  double _plotWidth, _plotHeight, _topMargin;
  double _scaleWidth, _width, _textHeight;
  bool _textOnLeft;
  class VerticalPlotScale _verticalPlotScale;
  std::map<double, ColorValue> _colorValues;
};

#endif