29 const std::vector<std::pair<QString, Qt::GlobalColor>> color_queue = {
30 {
"Black", Qt::GlobalColor::black}, {
"Blue", Qt::GlobalColor::blue},
31 {
"Red", Qt::GlobalColor::darkRed}, {
"Cyan", Qt::GlobalColor::darkCyan},
32 {
"Gray", Qt::GlobalColor::darkGray}, {
"Magenta", Qt::GlobalColor::darkMagenta}};
35 const QMap<QString, QCPScatterStyle::ScatterShape> scatter_map = {
36 {
"None", QCPScatterStyle::ScatterShape::ssNone},
37 {
"Disc", QCPScatterStyle::ScatterShape::ssDisc},
38 {
"Circle", QCPScatterStyle::ScatterShape::ssCircle},
39 {
"Cross", QCPScatterStyle::ScatterShape::ssCross},
40 {
"Diamond", QCPScatterStyle::ScatterShape::ssDiamond},
41 {
"Star", QCPScatterStyle::ScatterShape::ssStar}};
44 const QMap<QString, QCPGraph::LineStyle> line_map = {
45 {
"None", QCPGraph::LineStyle::lsNone},
46 {
"Line", QCPGraph::LineStyle::lsLine},
47 {
"StepLeft", QCPGraph::LineStyle::lsStepLeft},
48 {
"StepRight", QCPGraph::LineStyle::lsStepRight},
49 {
"StepCenter", QCPGraph::LineStyle::lsStepCenter},
50 {
"Impulse", QCPGraph::LineStyle::lsImpulse}};
52 struct ColorNameComparator {
53 ColorNameComparator(QString value_to_comp)
54 : m_value_to_comp(std::move(value_to_comp))
57 bool operator()(
const std::pair<QString, Qt::GlobalColor>& value)
const
59 return value.first == m_value_to_comp;
62 const QString m_value_to_comp;
68 for (
const auto& color : color_queue)
69 result << color.first;
70 result.
setValue(color_queue.front().first);
77 for (
const auto& scatter : scatter_map.keys())
79 result.
setValue(scatter_map.keys().first());
86 for (
const auto& line : line_map.keys())
88 result.
setValue(line_map.keys().first());
94 QModelIndex getIndexFromPath(
const SessionModel* model,
const QString& path)
99 QStringList parts = path.split(
"/");
101 for (
int i = 0; i < parts.length(); i++) {
131 auto item_index = getIndexFromPath(hosting_model, path);
132 ASSERT(item_index.isValid());
149 std::find_if(color_queue.begin(), color_queue.end(), ColorNameComparator(color_name));
150 ASSERT(iter != color_queue.end());
151 return QColor(iter->second);
162 return color_queue.front().first;
165 std::find_if(color_queue.begin(), color_queue.end(), ColorNameComparator(current_color));
166 if (iter == color_queue.end() || *iter == color_queue.back())
167 return color_queue.front().first;
168 return (++iter)->first;
173 auto color_combo = defaultColorCombo();
174 color_combo.setValue(color_name);
181 bool contains = scatter_map.contains(scatter_name);
183 return QCPScatterStyle::ScatterShape(scatter_map.value(scatter_name));
189 bool contains = line_map.contains(line_name);
191 return QCPGraph::LineStyle(line_map.value(line_name));
196 auto scatter_combo = defaultScatterCombo();
197 scatter_combo.setValue(scatter_name);
203 auto line_combo = defaultLineCombo();
204 line_combo.setValue(line_name);
Defines class ComboProperty.
Defines class DataProperties and its descendants.
Defines class InstrumentItem and all its children.
Defines class Helpers functions.
Defines class SessionModel.
Custom property to define list of string values with multiple selections. Intended for QVariant.
void setValue(const QString &name)
Holds data required for 1D DataItem representation.
void setColorProperty(const QString &color_name)
Returns set up color ComboProperty.
static constexpr auto P_COLOR
static const QString & nextColorName(Data1DProperties *properties)
Returns the name of the color, which follows the color of passes property container....
QColor color()
Creates and returns a color object from color name.
QCPScatterStyle::ScatterShape scatter()
Returns a QCP scatter object from its name.
void setLineProperty(const QString &line_name)
Set up line for qcustomplot.
static constexpr auto P_SCATTER
QString colorName() const
Returns the name of the color.
static constexpr auto P_LINE
QCPGraph::LineStyle line()
Returns a QCP line object from its name.
void setScatterProperty(const QString &scatter_name)
Set up scatter for qcustomplot.
Abstract base class for IntensityDataItem and SpecularDataItem. Owns one simulated data set of type D...
Implements a link to DataItem. If path name of a DataItem changes, the link becomes invalid....
void setDataItem(DataItem *item)
DataProperties(const QString &model_type)
static constexpr auto P_DATALINK
Base class for a GUI data item.
QString itemName() const
Get item name, return display name if no name is set.
SessionItem * addProperty(const QString &name, const QVariant &variant)
Add new property item and register new tag. name is the tag name and the display name....
int numberOfChildren() const
Returns total number of children.
QVariant getItemValue(const QString &tag) const
Directly access value of item under given tag.
void setItemValue(const QString &tag, const QVariant &variant) const
Directly set value of item under given tag.
SessionModel * model() const
Returns model of this item.
T * item(const QString &tag) const
SessionItem * childAt(int row) const
Returns the child at the given row.
QModelIndex index() const
Returns model index of this item.
Base class for a GUI data collection. A collection is e.g. all real data (RealDataModel)....
SessionItem * itemForIndex(const QModelIndex &index) const
SessionItem * rootItem() const
QString getPathFromIndex(const QModelIndex &index)