From a319a857a633ab2fbcdbae5204eb5cfcdcc1b413 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Tue, 19 Jan 2016 02:30:50 +0100 Subject: Updated options & hacks to change color scales. --- main.h | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 136 insertions(+), 13 deletions(-) (limited to 'main.h') diff --git a/main.h b/main.h index 86024b9..69c58f0 100644 --- a/main.h +++ b/main.h @@ -4,11 +4,18 @@ #include #include -#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 -- cgit v1.2.3