Add export format options: CSV, JSON, PPM
[gencolormap.git] / colormapwidgets.hpp
index b2516d6..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,12 +157,168 @@ 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 ColorMapPLSequentialLightnessWidget : public ColorMapWidget
+{
+Q_OBJECT
+private:
+    bool _update_lock;
+    QSpinBox* _n_spinbox;
+    ColorMapCombinedSliderSpinBox* _saturation_changer;
+    ColorMapCombinedSliderSpinBox* _hue_changer;
+private slots:
+    void update();
+
+public:
+    ColorMapPLSequentialLightnessWidget();
+    ~ColorMapPLSequentialLightnessWidget();
+
+    void reset() override;
+    QVector<unsigned char> colorMap(int* clipped = NULL) const override;
+    QString reference() const override;
+    void parameters(int& n, float& saturation, float& hue) const;
+};
+
+class ColorMapPLSequentialSaturationWidget : public ColorMapWidget
+{
+Q_OBJECT
+private:
+    bool _update_lock;
+    QSpinBox* _n_spinbox;
+    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;
+private slots:
+    void update();
+
+public:
+    ColorMapPLDivergingLightnessWidget();
+    ~ColorMapPLDivergingLightnessWidget();
+
+    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 ColorMapPLDivergingSaturationWidget : public ColorMapWidget
+{
+Q_OBJECT
+private:
+    bool _update_lock;
+    QSpinBox* _n_spinbox;
+    ColorMapCombinedSliderSpinBox* _lightness_changer;
+    ColorMapCombinedSliderSpinBox* _saturation_changer;
+    ColorMapCombinedSliderSpinBox* _hue_changer;
+    ColorMapCombinedSliderSpinBox* _divergence_changer;
+private slots:
+    void update();
+
+public:
+    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<unsigned char> colorMap(int* clipped = NULL) const override;
+    QString reference() const override;
+    void parameters(int& n, float& hue, float& divergence, float& lightness, float& saturation) const;
+};
+
 class ColorMapCubeHelixWidget : public ColorMapWidget
 {
 Q_OBJECT
@@ -178,13 +337,13 @@ 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;
 };
 
-class ColorMapMorelandDivergingWidget : public ColorMapWidget
+class ColorMapMorelandWidget : public ColorMapWidget
 {
 Q_OBJECT
 private:
@@ -198,18 +357,18 @@ private slots:
     void update();
 
 public:
-    ColorMapMorelandDivergingWidget();
-    ~ColorMapMorelandDivergingWidget();
+    ColorMapMorelandWidget();
+    ~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,
             unsigned char& r1, unsigned char& g1, unsigned char& b1) const;
 };
 
-class ColorMapMcNamesSequentialWidget : public ColorMapWidget
+class ColorMapMcNamesWidget : public ColorMapWidget
 {
 Q_OBJECT
 private:
@@ -220,11 +379,11 @@ private slots:
     void update();
 
 public:
-    ColorMapMcNamesSequentialWidget();
-    ~ColorMapMcNamesSequentialWidget();
+    ColorMapMcNamesWidget();
+    ~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;
 };