DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Loading...
Searching...
No Matches
GraphUtil.h
Go to the documentation of this file.
1// This file is part of DynExp.
2
8#pragma once
9
10#include "stdafx.h"
11#include "../MetaInstruments/DataStreamInstrument.h"
12#include "../MetaInstruments/Spectrometer.h"
13
14namespace DynExpModule::Graph
15{
17 {
21 using QPointFValueType = decltype(std::declval<QPointF>().x());
22
27 QString GetMultiplierLabel() const;
28
32 void Reset();
33
41 void GenerateSampleTimingInfo(std::vector<DynExpInstr::DataStreamBase::BasicSampleListType>& BasicSamplesSeries);
42
51 bool ProcessSamples(QList<QPointF> RawSamples, QList<QPointF>& Samples, const size_t SeriesIndex);
52
62 QList<QPointF>& Samples, const size_t SeriesIndex);
63
73 QList<QPointF>& Samples, const size_t SeriesIndex);
74
78 void AdjustAxesLimits();
79
86 void ReprocessSamples(const QList<QPointF>& Samples, const size_t SeriesIndex);
87
94 void CheckSampleHovered(const QPointFValueType X, const QPointFValueType Y, const size_t SeriesIndex);
95
99 void ResetHoveredSample();
100
105
110
114 bool XIsLogarithmic = false;
115
119 bool YIsLogarithmic = false;
120
124 QString XLabel;
125
129 QString YLabel;
130
134 unsigned int Multiplier = 0;
135
141
145 QPointF MinValues;
146
150 QPointF MaxValues;
151
156
161
166
171
176
180 size_t HoveredSeries = 0;
181
185 QPointFValueType HoveredDistance = std::numeric_limits<QPointFValueType>::max();
186
187 private:
188 double inline ApplyXLog(double Value) const { return XIsLogarithmic ? (Value > .0 ? std::log10(Value) : .0) : Value; }
189 double inline ApplyYLog(double Value) const { return YIsLogarithmic ? std::log10(Value) : Value; }
190 };
191}
std::vector< BasicSample > BasicSampleListType
Type of a list containing data stream samples of type BasicSample.
Type describing a spectrum as acquired by the Spectrometer instrument.
UnitType
Units which can be used with DynExp instruments.
Definition Units.h:28
@ Arbitrary
Arbitrary units (a.u.)
@ Index
Sample index.
Accumulates include statements to provide a precompiled header.
QPointF LastMinValues
Lower axes limits of x and y axes from previous graph update.
Definition GraphUtil.h:155
size_t MaxSampleCountPerSeries
Indicates the number of samples contained in the longest data series to plot. A value of 0 indicates ...
Definition GraphUtil.h:140
decltype(std::declval< QPointF >().x()) QPointFValueType
Data type of sample values for plotting.
Definition GraphUtil.h:21
DynExp::Units::UnitType XUnit
Joint unit of the plot's x axis.
Definition GraphUtil.h:104
QPointF CursorPosition
Relative position of the mouse cursor inside the coordinate system (between 0. and 1....
Definition GraphUtil.h:165
void AdjustAxesLimits()
Adjusts MinValues and MaxValues to best display all data series.
QPointF HoveredPoint
Hovered point belonging to any series in normalized coordinate system coordinates (between 0....
Definition GraphUtil.h:170
size_t HoveredSeries
Index of the data series the hovered point belongs to.
Definition GraphUtil.h:180
void CheckSampleHovered(const QPointFValueType X, const QPointFValueType Y, const size_t SeriesIndex)
Checks whether the given sample is close to the mouse cursor (hovered).
bool ProcessSpectrum(DynExpInstr::SpectrometerData::SpectrumType Spectrum, QList< QPointF > &Samples, const size_t SeriesIndex)
Converts Spectrum to displayable format and stores its minimal and maximal values in this DynExpLineG...
QPointF MinValues
Current lower axes limits of x and y axes.
Definition GraphUtil.h:145
void ReprocessSamples(const QList< QPointF > &Samples, const size_t SeriesIndex)
If data plotting is not enabled (running), the available and already plotted samples have to be repro...
QString YLabel
If empty, the y label is constructed from YUnit. Otherwise, YLabel is used.
Definition GraphUtil.h:129
double ApplyXLog(double Value) const
Definition GraphUtil.h:188
QPointF LastMaxValues
Upper axes limits of x and y axes from previous graph update.
Definition GraphUtil.h:160
QString GetMultiplierLabel() const
Returns the multiplier prefix associated with Multiplier.
Definition GraphUtil.cpp:7
QPointFValueType HoveredDistance
Distance between the mouse cursor and the hovered point.
Definition GraphUtil.h:185
bool XIsLogarithmic
Determines whether x axis is logarithmic.
Definition GraphUtil.h:114
void ResetHoveredSample()
Removes the stored hovered sample.
void Reset()
Resets the instance to generate information from new sample series.
Definition GraphUtil.cpp:20
unsigned int Multiplier
Best order of magnitude to scale the plot's joint time axis with.
Definition GraphUtil.h:134
bool ProcessBasicSamples(DynExpInstr::DataStreamBase::BasicSampleListType BasicSamples, QList< QPointF > &Samples, const size_t SeriesIndex)
Converts BasicSamples to displayable format and stores their minimal and maximal values in this DynEx...
void GenerateSampleTimingInfo(std::vector< DynExpInstr::DataStreamBase::BasicSampleListType > &BasicSamplesSeries)
Extracts sample timing information for x axis scaling from BasicSamples and stores the results in thi...
Definition GraphUtil.cpp:38
double ApplyYLog(double Value) const
Definition GraphUtil.h:189
QPointF HoveredSample
Hovered sample belonging to any series in the graphs's real coordinate system.
Definition GraphUtil.h:175
bool YIsLogarithmic
Determines whether y axis is logarithmic.
Definition GraphUtil.h:119
DynExp::Units::UnitType YUnit
Joint unit of the plot's y axis.
Definition GraphUtil.h:109
bool ProcessSamples(QList< QPointF > RawSamples, QList< QPointF > &Samples, const size_t SeriesIndex)
Converts RawSamples to displayable format and stores their minimal and maximal values in this DynExpL...
Definition GraphUtil.cpp:90
QString XLabel
If empty, the x label is constructed from XUnit. Otherwise, XLabel is used.
Definition GraphUtil.h:124
QPointF MaxValues
Current upper axes limits of x and y axes.
Definition GraphUtil.h:150