ddt  1.0.0
ddtColourmapWidget.hpp
Go to the documentation of this file.
1 
19 #ifndef DDT_DATAVISUALISATION_DDTWIDGETS_COLOURMAPWIDGET_HPP
20 #define DDT_DATAVISUALISATION_DDTWIDGETS_COLOURMAPWIDGET_HPP
21 
22 #include <QtUiPlugin/QDesignerExportWidget>
23 
24 #include "ddt/imageHandling.hpp"
26 
31 class QDESIGNER_WIDGET_EXPORT DdtColourmapWidget : public DdtWidget {
32  Q_OBJECT
33 
34  public:
39  explicit DdtColourmapWidget(QWidget* parent = nullptr);
40 
45 
46  void mousePressEvent(QMouseEvent* event) final;
47  void mouseMoveEvent(QMouseEvent* event) final;
48  void mouseReleaseEvent(QMouseEvent* event) final;
49 
50  signals:
55  ddt::colorMap_t colourmap_inverted,
56  ddt::colorMapARGB_t colourmap_argb,
57  ddt::colorMapARGB_t colourmap_argb_inverted);
58 
64 
65  private:
66  QLabel* colourbar_label;
67  QLabel* colourscale_label;
68  QVector<QRgb> orig_colourmap;
69  QVector<QRgb> current_colourmap;
70  int colourbar_clicked_pos_x;
71  const int MAX_COLOR_MAP_ENTRIES = 256;
72  const int MAX_COLOR_MAP_VALUE = 255;
73  const int PIXMAP_HEIGHT = 20;
74  int amount;
75  std::atomic<bool> inverted;
76 
77  void CreateWidget();
78 
82  void ConvertCurrentMap(ddt::colorMap_t& colourmap,
83  ddt::colorMap_t& colourmap_inverted,
84  ddt::colorMapARGB_t& colourmap_argb,
85  ddt::colorMapARGB_t& colourmap_argb_inverted);
86 
90  void ConvertAndEmit();
91 
95  void ShiftColourmap();
96 
100  void RotateColourmap();
101 
105  void ScaleColourmap();
106 
110  void UpdateColourmap(QVector<QRgb> colourmap);
111 
115  void ResetColourmap();
116 
117  int GetPosX(const QPoint pos) const;
118 
119  void UpdateColourscale(double min_value, double max_value,
120  int scaling_function);
121  void DrawScale(double min_value, double max_value, QPainter& painter,
122  int scaling_function);
123  void DrawScaleLog(double min_value, double max_value, QPainter& painter);
124  int CalculateTickPositionLinear(double tick, double min_value, double width,
125  double maxsize);
126  int CalculateTickPositionSqrt(double tick, double min_value, double width,
127  double maxsize);
128 
129  void enterEvent(QEvent* const event) override;
130  void leaveEvent(QEvent* const event) override;
131 
132  protected slots:
137  void SetCurrentColourmap(QVector<QRgb> colourmap);
138 
146  void UpdateColourbarAxis(double min_value, double max_value,
147  int scaling_function);
148 
152  void Reset();
153 
158  void InvertColourmap(const bool invert);
159 };
160 
161 #endif // DDT_DATAVISUALISATION_DDTWIDGETS_COLOURMAPWIDGET_HPP
162 
Definition: ddtColourmapWidget.hpp:31
void ChangeContrast(ddt::colorMap_t colourmap, ddt::colorMap_t colourmap_inverted, ddt::colorMapARGB_t colourmap_argb, ddt::colorMapARGB_t colourmap_argb_inverted)
virtual ~DdtColourmapWidget()
The DdtWidget class Use as wrapper class for new widgets.
Definition: ddtWidget.hpp:28
DDT Widgets. Base class for the DDT widgets. Base class for the DDT widgets.
Image Handling class, offers access to image handling functions. This file is part of the DDT Image H...
std::array< std::array< float, COLOR_MAP_ENTRY_SIZE >, MAX_COLOR_MAP_ENTRIES > colorMap_t
Definition: imageColor.hpp:57
constexpr size_t MAX_COLOR_MAP_ENTRIES
Definition: imageColor.hpp:47
std::array< unsigned int, MAX_COLOR_MAP_ENTRIES > colorMapARGB_t
Definition: imageColor.hpp:67
constexpr size_t MAX_COLOR_MAP_VALUE
Definition: imageColor.hpp:48