Add export format options: CSV, JSON, PPM
[gencolormap.git] / colormapwidgets.hpp
index c2b67ac..84e0cf4 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2015, 2016 Computer Graphics Group, University of Siegen
+ * Copyright (C) 2015, 2016, 2017, 2018, 2019
+ * Computer Graphics Group, University of Siegen
  * Written by Martin Lambers <martin.lambers@uni-siegen.de>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -70,12 +71,14 @@ public:
     /* Reset all values to their method-specific defaults */
     virtual void reset() = 0;
 
-    /* Get the color map corresponding to the current values as a vector of colors */
-    virtual QVector<QColor> colorMap() const = 0;
+    /* Get the color map corresponding to the current values as a vector of colors.
+     * Also return the number of clipped colors unless 'clipped' is NULL. */
+    virtual QVector<unsigned char> colorMap(int* clipped = NULL) const = 0;
 
-    /* Get a color map as an image of the specified size. If width or height is zero,
-     * then it will be set to the number of colors in the color map. */
-    QImage colorMapImage(int width, int height);
+    /* Transform a color map to an image of the specified size. If width or
+     * height is zero, then it will be set to the number of colors in the
+     * color map. */
+    static QImage colorMapImage(const QVector<unsigned char>& colormap, int width, int height);
 
     /* Get a rich text string containing the relevant literature reference for this method */
     virtual QString reference() const = 0;
@@ -103,7 +106,7 @@ public:
     ~ColorMapBrewerSequentialWidget();
 
     void reset() override;
-    QVector<QColor> colorMap() const override;
+    QVector<unsigned char> colorMap(int* clipped = NULL) const override;
     QString reference() const override;
     void parameters(int& n, float& hue,
             float& contrast, float& saturation, float& brightness, float& warmth) const;
@@ -129,7 +132,7 @@ public:
     ~ColorMapBrewerDivergingWidget();
 
     void reset() override;
-    QVector<QColor> colorMap() const override;
+    QVector<unsigned char> colorMap(int* clipped = NULL) const override;
     QString reference() const override;
     void parameters(int& n, float& hue, float& divergence,
             float& contrast, float& saturation, float& brightness, float& warmth) const;
@@ -154,41 +157,106 @@ public:
     ~ColorMapBrewerQualitativeWidget();
 
     void reset() override;
-    QVector<QColor> colorMap() const override;
+    QVector<unsigned char> colorMap(int* clipped = NULL) const override;
     QString reference() const override;
     void parameters(int& n, float& hue, float& divergence,
             float& contrast, float& saturation, float& brightness) const;
 };
 
-class ColorMapIsoluminantSequentialWidget : public ColorMapWidget
+class ColorMapPLSequentialLightnessWidget : public ColorMapWidget
 {
 Q_OBJECT
 private:
     bool _update_lock;
     QSpinBox* _n_spinbox;
-    ColorMapCombinedSliderSpinBox* _luminance_changer;
     ColorMapCombinedSliderSpinBox* _saturation_changer;
     ColorMapCombinedSliderSpinBox* _hue_changer;
 private slots:
     void update();
 
 public:
-    ColorMapIsoluminantSequentialWidget();
-    ~ColorMapIsoluminantSequentialWidget();
+    ColorMapPLSequentialLightnessWidget();
+    ~ColorMapPLSequentialLightnessWidget();
 
     void reset() override;
-    QVector<QColor> colorMap() const override;
+    QVector<unsigned char> colorMap(int* clipped = NULL) const override;
     QString reference() const override;
-    void parameters(int& n, float& luminance, float& saturation, float& hue) const;
+    void parameters(int& n, float& saturation, float& hue) const;
 };
 
-class ColorMapIsoluminantDivergingWidget : public ColorMapWidget
+class ColorMapPLSequentialSaturationWidget : public ColorMapWidget
 {
 Q_OBJECT
 private:
     bool _update_lock;
     QSpinBox* _n_spinbox;
-    ColorMapCombinedSliderSpinBox* _luminance_changer;
+    ColorMapCombinedSliderSpinBox* _lightness_changer;
+    ColorMapCombinedSliderSpinBox* _saturation_changer;
+    ColorMapCombinedSliderSpinBox* _hue_changer;
+private slots:
+    void update();
+
+public:
+    ColorMapPLSequentialSaturationWidget();
+    ~ColorMapPLSequentialSaturationWidget();
+
+    void reset() override;
+    QVector<unsigned char> colorMap(int* clipped = NULL) const override;
+    QString reference() const override;
+    void parameters(int& n, float& lightness, float& saturation, float& hue) const;
+};
+
+class ColorMapPLSequentialRainbowWidget : public ColorMapWidget
+{
+Q_OBJECT
+private:
+    bool _update_lock;
+    QSpinBox* _n_spinbox;
+    ColorMapCombinedSliderSpinBox* _hue_changer;
+    ColorMapCombinedSliderSpinBox* _rotations_changer;
+    ColorMapCombinedSliderSpinBox* _saturation_changer;
+private slots:
+    void update();
+
+public:
+    ColorMapPLSequentialRainbowWidget();
+    ~ColorMapPLSequentialRainbowWidget();
+
+    void reset() override;
+    QVector<unsigned char> colorMap(int* clipped = NULL) const override;
+    QString reference() const override;
+    void parameters(int& n, float& hue, float& rotations, float& saturation) const;
+};
+
+class ColorMapPLSequentialBlackBodyWidget : public ColorMapWidget
+{
+Q_OBJECT
+private:
+    bool _update_lock;
+    QSpinBox* _n_spinbox;
+    ColorMapCombinedSliderSpinBox* _temperature_changer;
+    ColorMapCombinedSliderSpinBox* _range_changer;
+    ColorMapCombinedSliderSpinBox* _saturation_changer;
+private slots:
+    void update();
+
+public:
+    ColorMapPLSequentialBlackBodyWidget();
+    ~ColorMapPLSequentialBlackBodyWidget();
+
+    void reset() override;
+    QVector<unsigned char> colorMap(int* clipped = NULL) const override;
+    QString reference() const override;
+    void parameters(int& n, float& temperature, float& range, float& saturation) const;
+};
+
+class ColorMapPLDivergingLightnessWidget : public ColorMapWidget
+{
+Q_OBJECT
+private:
+    bool _update_lock;
+    QSpinBox* _n_spinbox;
+    ColorMapCombinedSliderSpinBox* _lightness_changer;
     ColorMapCombinedSliderSpinBox* _saturation_changer;
     ColorMapCombinedSliderSpinBox* _hue_changer;
     ColorMapCombinedSliderSpinBox* _divergence_changer;
@@ -196,22 +264,22 @@ private slots:
     void update();
 
 public:
-    ColorMapIsoluminantDivergingWidget();
-    ~ColorMapIsoluminantDivergingWidget();
+    ColorMapPLDivergingLightnessWidget();
+    ~ColorMapPLDivergingLightnessWidget();
 
     void reset() override;
-    QVector<QColor> colorMap() const override;
+    QVector<unsigned char> colorMap(int* clipped = NULL) const override;
     QString reference() const override;
-    void parameters(int& n, float& luminance, float& saturation, float& hue, float& divergence) const;
+    void parameters(int& n, float& lightness, float& saturation, float& hue, float& divergence) const;
 };
 
-class ColorMapIsoluminantQualitativeWidget : public ColorMapWidget
+class ColorMapPLDivergingSaturationWidget : public ColorMapWidget
 {
 Q_OBJECT
 private:
     bool _update_lock;
     QSpinBox* _n_spinbox;
-    ColorMapCombinedSliderSpinBox* _luminance_changer;
+    ColorMapCombinedSliderSpinBox* _lightness_changer;
     ColorMapCombinedSliderSpinBox* _saturation_changer;
     ColorMapCombinedSliderSpinBox* _hue_changer;
     ColorMapCombinedSliderSpinBox* _divergence_changer;
@@ -219,13 +287,36 @@ private slots:
     void update();
 
 public:
-    ColorMapIsoluminantQualitativeWidget();
-    ~ColorMapIsoluminantQualitativeWidget();
+    ColorMapPLDivergingSaturationWidget();
+    ~ColorMapPLDivergingSaturationWidget();
+
+    void reset() override;
+    QVector<unsigned char> colorMap(int* clipped = NULL) const override;
+    QString reference() const override;
+    void parameters(int& n, float& lightness, float& saturation, float& hue, float& divergence) const;
+};
+
+class ColorMapPLQualitativeHueWidget : public ColorMapWidget
+{
+Q_OBJECT
+private:
+    bool _update_lock;
+    QSpinBox* _n_spinbox;
+    ColorMapCombinedSliderSpinBox* _hue_changer;
+    ColorMapCombinedSliderSpinBox* _divergence_changer;
+    ColorMapCombinedSliderSpinBox* _lightness_changer;
+    ColorMapCombinedSliderSpinBox* _saturation_changer;
+private slots:
+    void update();
+
+public:
+    ColorMapPLQualitativeHueWidget();
+    ~ColorMapPLQualitativeHueWidget();
 
     void reset() override;
-    QVector<QColor> colorMap() const override;
+    QVector<unsigned char> colorMap(int* clipped = NULL) const override;
     QString reference() const override;
-    void parameters(int& n, float& luminance, float& saturation, float& hue, float& divergence) const;
+    void parameters(int& n, float& hue, float& divergence, float& lightness, float& saturation) const;
 };
 
 class ColorMapCubeHelixWidget : public ColorMapWidget
@@ -246,7 +337,7 @@ public:
     ~ColorMapCubeHelixWidget();
 
     void reset() override;
-    QVector<QColor> colorMap() const override;
+    QVector<unsigned char> colorMap(int* clipped = NULL) const override;
     QString reference() const override;
     void parameters(int& n, float& hue, float& rotations,
             float& saturation, float& gamma) const;
@@ -270,7 +361,7 @@ public:
     ~ColorMapMorelandWidget();
 
     void reset() override;
-    QVector<QColor> colorMap() const override;
+    QVector<unsigned char> colorMap(int* clipped = NULL) const override;
     QString reference() const override;
     void parameters(int& n,
             unsigned char& r0, unsigned char& g0, unsigned char& b0,
@@ -292,7 +383,7 @@ public:
     ~ColorMapMcNamesWidget();
 
     void reset() override;
-    QVector<QColor> colorMap() const override;
+    QVector<unsigned char> colorMap(int* clipped = NULL) const override;
     QString reference() const override;
     void parameters(int& n, float& p) const;
 };