2020-10-28 05:07:14 +08:00
|
|
|
#ifndef TRACEXYPLOT_H
|
|
|
|
#define TRACEXYPLOT_H
|
2020-08-31 04:03:41 +08:00
|
|
|
|
|
|
|
#include "traceplot.h"
|
|
|
|
#include <set>
|
2020-10-20 01:39:16 +08:00
|
|
|
|
2020-10-28 05:07:14 +08:00
|
|
|
class TraceXYPlot : public TracePlot
|
2020-08-31 04:03:41 +08:00
|
|
|
{
|
2020-10-28 05:07:14 +08:00
|
|
|
friend class XYplotAxisDialog;
|
2020-08-31 04:03:41 +08:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2020-10-28 05:07:14 +08:00
|
|
|
TraceXYPlot(TraceModel &model, QWidget *parent = nullptr);
|
2020-08-31 04:03:41 +08:00
|
|
|
|
|
|
|
enum class YAxisType {
|
|
|
|
Disabled = 0,
|
2020-10-28 05:07:14 +08:00
|
|
|
// S parameter options
|
2020-08-31 04:03:41 +08:00
|
|
|
Magnitude = 1,
|
|
|
|
Phase = 2,
|
|
|
|
VSWR = 3,
|
2020-10-28 05:07:14 +08:00
|
|
|
// TDR options
|
2020-12-06 22:37:16 +08:00
|
|
|
ImpulseReal = 4,
|
|
|
|
ImpulseMag = 5,
|
|
|
|
Step = 6,
|
|
|
|
Impedance = 7,
|
2020-08-31 04:03:41 +08:00
|
|
|
Last,
|
|
|
|
};
|
2020-10-28 05:07:14 +08:00
|
|
|
static const std::set<YAxisType> YAxisTypes;
|
|
|
|
enum class XAxisType {
|
|
|
|
Frequency,
|
|
|
|
Time,
|
|
|
|
Distance,
|
2020-12-18 03:37:30 +08:00
|
|
|
Last,
|
2020-10-28 05:07:14 +08:00
|
|
|
};
|
2020-11-02 05:56:31 +08:00
|
|
|
enum class XAxisMode {
|
|
|
|
UseSpan,
|
|
|
|
FitTraces,
|
|
|
|
Manual,
|
2020-12-18 03:37:30 +08:00
|
|
|
Last,
|
2020-11-02 05:56:31 +08:00
|
|
|
};
|
2020-08-31 04:03:41 +08:00
|
|
|
|
|
|
|
void setYAxis(int axis, YAxisType type, bool log, bool autorange, double min, double max, double div);
|
2020-11-02 05:56:31 +08:00
|
|
|
void setXAxis(XAxisType type, XAxisMode mode, double min, double max, double div);
|
2020-08-31 04:03:41 +08:00
|
|
|
void enableTrace(Trace *t, bool enabled) override;
|
2020-11-22 07:41:42 +08:00
|
|
|
void updateSpan(double min, double max) override;
|
2020-11-22 21:38:52 +08:00
|
|
|
void replot() override;
|
2020-08-31 04:03:41 +08:00
|
|
|
|
2020-12-05 06:49:52 +08:00
|
|
|
virtual Type getType() override { return Type::XYPlot;};
|
|
|
|
virtual nlohmann::json toJSON() override;
|
|
|
|
virtual void fromJSON(nlohmann::json j) override;
|
|
|
|
|
2020-10-28 05:07:14 +08:00
|
|
|
bool isTDRtype(YAxisType type);
|
|
|
|
|
2020-11-02 05:56:31 +08:00
|
|
|
public slots:
|
|
|
|
void axisSetupDialog();
|
|
|
|
|
2020-08-31 04:03:41 +08:00
|
|
|
protected:
|
2020-10-28 05:07:14 +08:00
|
|
|
virtual void updateContextMenu() override;
|
2021-02-22 20:39:47 +08:00
|
|
|
virtual bool dropSupported(Trace *t) override;
|
2020-11-22 07:41:42 +08:00
|
|
|
virtual void draw(QPainter &p) override;
|
2020-08-31 04:03:41 +08:00
|
|
|
|
|
|
|
private slots:
|
2020-11-22 07:41:42 +08:00
|
|
|
void updateAxisTicks();
|
2020-08-31 04:03:41 +08:00
|
|
|
private:
|
2020-11-22 07:41:42 +08:00
|
|
|
static constexpr int AxisLabelSize = 10;
|
2020-08-31 04:03:41 +08:00
|
|
|
QString AxisTypeToName(YAxisType type);
|
2020-12-18 03:37:30 +08:00
|
|
|
QString AxisTypeToName(XAxisType type);
|
|
|
|
QString AxisModeToName(XAxisMode mode);
|
|
|
|
XAxisType XAxisTypeFromName(QString name);
|
|
|
|
YAxisType YAxisTypeFromName(QString name);
|
|
|
|
XAxisMode AxisModeFromName(QString name);
|
2020-08-31 04:03:41 +08:00
|
|
|
void enableTraceAxis(Trace *t, int axis, bool enabled);
|
2021-02-22 20:39:47 +08:00
|
|
|
bool supported(Trace *t) override;
|
2020-08-31 04:03:41 +08:00
|
|
|
bool supported(Trace *t, YAxisType type);
|
2020-11-29 05:34:40 +08:00
|
|
|
void removeUnsupportedTraces();
|
2020-11-27 00:45:55 +08:00
|
|
|
QPointF traceToCoordinate(Trace *t, unsigned int sample, YAxisType type);
|
2020-11-23 04:25:41 +08:00
|
|
|
QPoint plotValueToPixel(QPointF plotValue, int Yaxis);
|
2020-11-25 18:55:53 +08:00
|
|
|
QPointF pixelToPlotValue(QPoint pixel, int YAxis);
|
2020-11-23 04:25:41 +08:00
|
|
|
QPoint markerToPixel(TraceMarker *m) override;
|
|
|
|
double nearestTracePoint(Trace *t, QPoint pixel) override;
|
2020-11-22 21:38:52 +08:00
|
|
|
void traceDropped(Trace *t, QPoint position) override;
|
2020-11-25 18:55:53 +08:00
|
|
|
QString mouseText(QPoint pos) override;
|
|
|
|
|
|
|
|
static QString AxisUnit(YAxisType type);
|
|
|
|
static QString AxisUnit(XAxisType type);
|
2020-08-31 04:03:41 +08:00
|
|
|
|
|
|
|
std::set<Trace*> tracesAxis[2];
|
|
|
|
|
2020-11-02 05:56:31 +08:00
|
|
|
class YAxis {
|
2020-08-31 04:03:41 +08:00
|
|
|
public:
|
2020-11-02 05:56:31 +08:00
|
|
|
YAxisType type;
|
|
|
|
bool log; // not used yet
|
2020-08-31 04:03:41 +08:00
|
|
|
bool autorange;
|
|
|
|
double rangeMin;
|
|
|
|
double rangeMax;
|
|
|
|
double rangeDiv;
|
2020-11-22 07:41:42 +08:00
|
|
|
std::vector<double> ticks;
|
2020-08-31 04:03:41 +08:00
|
|
|
};
|
2020-11-02 05:56:31 +08:00
|
|
|
class XAxis {
|
|
|
|
public:
|
|
|
|
XAxisType type;
|
|
|
|
XAxisMode mode;
|
|
|
|
bool log; // not used yet
|
|
|
|
double rangeMin;
|
|
|
|
double rangeMax;
|
|
|
|
double rangeDiv;
|
2020-11-22 07:41:42 +08:00
|
|
|
std::vector<double> ticks;
|
2020-11-02 05:56:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
YAxis YAxis[2];
|
|
|
|
XAxis XAxis;
|
2020-08-31 04:03:41 +08:00
|
|
|
|
2020-11-22 21:38:52 +08:00
|
|
|
int plotAreaLeft, plotAreaWidth, plotAreaBottom;
|
2020-08-31 04:03:41 +08:00
|
|
|
};
|
|
|
|
|
2020-10-28 05:07:14 +08:00
|
|
|
#endif // TRACEXYPLOT_H
|