LibreVNA/Software/PC_Application/Traces/tracexyplot.h

73 lines
2.2 KiB
C
Raw Normal View History

2020-10-28 05:07:14 +08:00
#ifndef TRACEXYPLOT_H
#define TRACEXYPLOT_H
#include "traceplot.h"
2022-03-16 21:45:59 +08:00
#include "traceaxis.h"
2021-10-21 19:00:34 +08:00
#include <set>
2020-10-28 05:07:14 +08:00
class TraceXYPlot : public TracePlot
{
2020-10-28 05:07:14 +08:00
friend class XYplotAxisDialog;
Q_OBJECT
public:
2020-10-28 05:07:14 +08:00
TraceXYPlot(TraceModel &model, QWidget *parent = nullptr);
2020-11-02 05:56:31 +08:00
enum class XAxisMode {
UseSpan,
FitTraces,
Manual,
Last,
2020-11-02 05:56:31 +08:00
};
2022-03-16 21:45:59 +08:00
void setYAxis(int axis, YAxis::Type type, bool log, bool autorange, double min, double max, double div);
void setXAxis(XAxis::Type type, XAxisMode mode, bool log, double min, double max, double div);
void enableTrace(Trace *t, bool enabled) override;
void updateSpan(double min, double max) override;
void replot() override;
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;
2022-03-16 21:45:59 +08:00
bool isTDRtype(YAxis::Type type);
2020-10-28 05:07:14 +08:00
2020-11-02 05:56:31 +08:00
public slots:
void axisSetupDialog();
protected:
virtual bool configureForTrace(Trace *t) override;
2020-10-28 05:07:14 +08:00
virtual void updateContextMenu() override;
virtual bool dropSupported(Trace *t) override;
virtual void draw(QPainter &p) override;
private slots:
void updateAxisTicks();
private:
static constexpr int AxisLabelSize = 10;
static QString AxisModeToName(XAxisMode mode);
static XAxisMode AxisModeFromName(QString name);
void enableTraceAxis(Trace *t, int axis, bool enabled);
2021-12-11 06:36:28 +08:00
bool domainMatch(Trace *t);
bool supported(Trace *t) override;
2022-03-16 21:45:59 +08:00
bool supported(Trace *t, YAxis::Type type);
QPointF traceToCoordinate(Trace *t, unsigned int sample, YAxis &yaxis);
2020-11-23 04:25:41 +08:00
QPoint plotValueToPixel(QPointF plotValue, int Yaxis);
QPointF pixelToPlotValue(QPoint pixel, int YAxis);
QPoint markerToPixel(Marker *m) override;
2021-05-15 02:34:23 +08:00
double nearestTracePoint(Trace *t, QPoint pixel, double *distance = nullptr) override;
2022-03-16 21:45:59 +08:00
virtual bool markerVisible(double x) override;
void traceDropped(Trace *t, QPoint position) override;
QString mouseText(QPoint pos) override;
std::set<Trace*> tracesAxis[2];
2022-03-16 22:02:15 +08:00
YAxis yAxis[2];
XAxis xAxis;
2022-03-16 21:45:59 +08:00
XAxisMode xAxisMode;
int plotAreaLeft, plotAreaWidth, plotAreaBottom, plotAreaTop;
};
2020-10-28 05:07:14 +08:00
#endif // TRACEXYPLOT_H