diff --git a/gui/include/Visualization/SqpColorScale.h b/gui/include/Visualization/SqpColorScale.h new file mode 100644 index 0000000..0a436ce --- /dev/null +++ b/gui/include/Visualization/SqpColorScale.h @@ -0,0 +1,24 @@ +#ifndef SCIQLOP_SQPCOLORSCALE_H +#define SCIQLOP_SQPCOLORSCALE_H + +#include + +/** + * @brief The SqpColorScale struct represents the color scale for some graphs (such as + * spectrograms). + * + * Its implementation is based on the QCustomPlot color scale (@sa QCPColorScale) to which are added + * other useful properties for viewing in SciQlop + */ +struct SqpColorScale { + explicit SqpColorScale(QCustomPlot &plot); + + /// QCustomPlot object representing the color scale. + /// @remarks The SqpColorScale instance has not the property on this pointer. The pointer must + /// remain valid throughout the existence of the SqpColorScale instance + QCPColorScale *m_Scale{nullptr}; + bool m_AutomaticThreshold{false}; + QCPColorGradient::GradientPreset m_GradientPreset{QCPColorGradient::gpJet}; +}; + +#endif // SCIQLOP_SQPCOLORSCALE_H diff --git a/gui/meson.build b/gui/meson.build index 4106eb8..82ce47c 100644 --- a/gui/meson.build +++ b/gui/meson.build @@ -80,7 +80,8 @@ gui_sources = [ 'src/Visualization/PlottablesRenderingUtils.cpp', 'src/Visualization/MacScrollBarStyle.cpp', 'src/Visualization/VisualizationCursorItem.cpp', - 'src/Visualization/ColorScaleWidget.cpp' + 'src/Visualization/ColorScaleWidget.cpp', + 'src/Visualization/SqpColorScale.cpp' ] gui_inc = include_directories(['include']) diff --git a/gui/src/Visualization/SqpColorScale.cpp b/gui/src/Visualization/SqpColorScale.cpp new file mode 100644 index 0000000..ae84524 --- /dev/null +++ b/gui/src/Visualization/SqpColorScale.cpp @@ -0,0 +1,17 @@ +#include "Visualization/SqpColorScale.h" + +namespace { + +const auto DEFAULT_GRADIENT_PRESET = QCPColorGradient::gpJet; +const auto DEFAULT_RANGE = QCPRange{1.0e3, 1.7e7}; + +} // namespace + +SqpColorScale::SqpColorScale(QCustomPlot &plot) + : m_Scale{new QCPColorScale{&plot}}, + m_AutomaticThreshold{false}, + m_GradientPreset{DEFAULT_GRADIENT_PRESET} +{ + m_Scale->setGradient(m_GradientPreset); + m_Scale->setDataRange(DEFAULT_RANGE); +}