diff options
author | Samuel Fadel <samuelfadel@gmail.com> | 2016-01-19 02:30:50 +0100 |
---|---|---|
committer | Samuel Fadel <samuelfadel@gmail.com> | 2016-01-19 02:30:50 +0100 |
commit | a319a857a633ab2fbcdbae5204eb5cfcdcc1b413 (patch) | |
tree | 94c3408db5539cd24b03b28e68f316ac6e145951 /main.h | |
parent | e5eaf5236d6e0348b344e0c96c2612b603ff6a3a (diff) |
Updated options & hacks to change color scales.
Diffstat (limited to 'main.h')
-rw-r--r-- | main.h | 149 |
1 files changed, 136 insertions, 13 deletions
@@ -4,11 +4,18 @@ #include <QObject> #include <armadillo> -#include "interactionhandler.h" +#include "colorscale.h" +#include "continuouscolorscale.h" + +#include "barchart.h" +#include "colormap.h" +#include "scatterplot.h" +#include "voronoisplat.h" class Main : public QObject { Q_OBJECT + Q_ENUMS(ColorScaleType) public: static Main *instance() { // FIXME: Possibly dangerous @@ -47,18 +54,110 @@ public: setCPSavePath(path.toStdString()); } - void setInteractionHandler(InteractionHandler *interactionHandler) { - m_interactionHandler = interactionHandler; + arma::mat X() const { return m_dataset.cols(0, m_dataset.n_cols - 2); } + arma::vec labels() const { return m_dataset.col(m_dataset.n_cols - 1); } + + enum ColorScaleType { + ColorScaleCategorical, + ColorScaleContinuous, + ColorScaleDivergent, + ColorScaleRainbow + }; + + ColorScale *COLOR_SCALE_CATEGORICAL; + ColorScale *COLOR_SCALE_CONTINUOUS; + ColorScale *COLOR_SCALE_DIVERGENT; + ColorScale *COLOR_SCALE_RAINBOW; + + Q_INVOKABLE void setCPPlotColorScale(ColorScaleType colorScaleType) { + switch (colorScaleType) { + case ColorScaleCategorical: + cpPlot->setColorScale(*COLOR_SCALE_CATEGORICAL); + break; + case ColorScaleContinuous: + cpPlot->setColorScale(*COLOR_SCALE_CONTINUOUS); + break; + case ColorScaleDivergent: + cpPlot->setColorScale(*COLOR_SCALE_DIVERGENT); + break; + case ColorScaleRainbow: + cpPlot->setColorScale(*COLOR_SCALE_RAINBOW); + break; + } } - Q_INVOKABLE void setTechnique(int technique) { - if (m_interactionHandler) { - m_interactionHandler->setTechnique((InteractionHandler::Technique) technique); + Q_INVOKABLE void setRPPlotColorScale(ColorScaleType colorScaleType) { + switch (colorScaleType) { + case ColorScaleCategorical: + rpPlot->setColorScale(*COLOR_SCALE_CATEGORICAL); + break; + case ColorScaleContinuous: + rpPlot->setColorScale(*COLOR_SCALE_CONTINUOUS); + break; + case ColorScaleDivergent: + rpPlot->setColorScale(*COLOR_SCALE_DIVERGENT); + break; + case ColorScaleRainbow: + rpPlot->setColorScale(*COLOR_SCALE_RAINBOW); + break; } } - arma::mat X() const { return m_dataset.cols(0, m_dataset.n_cols - 2); } - arma::vec labels() const { return m_dataset.col(m_dataset.n_cols - 1); } + Q_INVOKABLE void setColormapColorScale(ColorScaleType colorScaleType) { + switch (colorScaleType) { + case ColorScaleCategorical: + colormap->setColorScale(*COLOR_SCALE_CATEGORICAL); + break; + case ColorScaleContinuous: + colormap->setColorScale(*COLOR_SCALE_CONTINUOUS); + break; + case ColorScaleDivergent: + colormap->setColorScale(*COLOR_SCALE_DIVERGENT); + break; + case ColorScaleRainbow: + colormap->setColorScale(*COLOR_SCALE_RAINBOW); + break; + } + } + + Q_INVOKABLE void setBarChartColorScale(ColorScaleType colorScaleType) { + switch (colorScaleType) { + case ColorScaleCategorical: + barChart->setColorScale(*COLOR_SCALE_CATEGORICAL); + break; + case ColorScaleContinuous: + barChart->setColorScale(*COLOR_SCALE_CONTINUOUS); + break; + case ColorScaleDivergent: + barChart->setColorScale(*COLOR_SCALE_DIVERGENT); + break; + case ColorScaleRainbow: + barChart->setColorScale(*COLOR_SCALE_RAINBOW); + break; + } + } + + Q_INVOKABLE void setSplatColorScale(ColorScaleType colorScaleType) { + switch (colorScaleType) { + case ColorScaleCategorical: + splat->setColorScale(*COLOR_SCALE_CATEGORICAL); + break; + case ColorScaleContinuous: + splat->setColorScale(*COLOR_SCALE_CONTINUOUS); + break; + case ColorScaleDivergent: + splat->setColorScale(*COLOR_SCALE_DIVERGENT); + break; + case ColorScaleRainbow: + splat->setColorScale(*COLOR_SCALE_RAINBOW); + break; + } + } + + BarChart *barChart; + Colormap *colormap; + Scatterplot *cpPlot, *rpPlot; + VoronoiSplat *splat; public slots: void setCPIndices(const arma::uvec &indices) { m_cpIndices = indices; } @@ -74,15 +173,39 @@ public slots: private: Main(QObject *parent = 0) : QObject(parent) - , m_interactionHandler(0) - {} - ~Main() {} - Q_DISABLE_COPY(Main) + , barChart(0) + , cpPlot(0) + , rpPlot(0) + , splat(0) + { + COLOR_SCALE_CATEGORICAL = new ColorScale{ + QColor("#1f77b4"), + QColor("#ff7f0e"), + QColor("#2ca02c"), + QColor("#d62728"), + QColor("#9467bd"), + QColor("#8c564b"), + QColor("#e377c2"), + QColor("#17becf"), + QColor("#7f7f7f"), + }; + COLOR_SCALE_CONTINUOUS = + new ColorScale{ContinuousColorScale::builtin(ContinuousColorScale::HEATED_OBJECTS)}; + COLOR_SCALE_DIVERGENT = + new ColorScale{ContinuousColorScale::builtin(ContinuousColorScale::RED_GRAY_BLUE)}; + COLOR_SCALE_RAINBOW = + new ColorScale{ContinuousColorScale::builtin(ContinuousColorScale::RAINBOW)}; + } + ~Main() { + delete COLOR_SCALE_CATEGORICAL; + delete COLOR_SCALE_CONTINUOUS; + delete COLOR_SCALE_DIVERGENT; + delete COLOR_SCALE_RAINBOW; + } arma::mat m_dataset, m_cp; arma::uvec m_cpIndices; std::string m_indicesSavePath, m_cpSavePath; - InteractionHandler *m_interactionHandler; }; #endif // MAIN_H |