LibreVNA/Software/PC_Application/LibreVNA-GUI/Traces/tracemodel.h

86 lines
2.2 KiB
C
Raw Normal View History

2022-10-30 03:19:30 +08:00
#ifndef TRACEMODEL_H
2022-10-01 23:10:44 +08:00
#define TRACEMODEL_H
#include "Device/device.h"
#include "savable.h"
#include "trace.h"
#include <QAbstractTableModel>
#include <vector>
class MarkerModel;
class TraceModel : public QAbstractTableModel, public Savable
{
Q_OBJECT
public:
TraceModel(QObject *parent = 0);
~TraceModel();
enum {
ColIndexVisible = 0,
ColIndexPlayPause = 1,
ColIndexDeembedding = 2,
ColIndexMath = 3,
ColIndexName = 4,
2022-10-01 23:10:44 +08:00
ColIndexLast,
};
enum class DataSource {
VNA,
SA,
Unknown,
};
void addTrace(Trace *t);
void removeTrace(unsigned int index);
void removeTrace(Trace *t);
Trace *trace(unsigned int index);
int findIndex(Trace *t);
void toggleVisibility(unsigned int index);
void togglePause(unsigned int index);
void toggleMath(unsigned int index);
void toggleDeembedding(unsigned int index);
2022-10-01 23:10:44 +08:00
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
std::vector<Trace*> getTraces() const;
std::vector<Trace*> getLiveTraces() const;
2022-10-01 23:10:44 +08:00
bool PortExcitationRequired(int port);
virtual nlohmann::json toJSON() override;
virtual void fromJSON(nlohmann::json j) override;
MarkerModel *getMarkerModel() const;
void setMarkerModel(MarkerModel *value);
DataSource getSource() const;
void setSource(const DataSource &value);
2022-10-30 03:19:30 +08:00
double getSweepPosition() const;
2022-10-01 23:10:44 +08:00
signals:
void SpanChanged(double fmin, double fmax);
void traceAdded(Trace *t);
void traceRemoved(Trace *t);
void requiredExcitation();
void traceNameChanged(Trace *t);
public slots:
void clearLiveData();
void addVNAData(const VirtualDevice::VNAMeasurement& d, TraceMath::DataType datatype, bool deembedded);
2022-10-01 23:10:44 +08:00
void addSAData(const VirtualDevice::SAMeasurement &d, const VirtualDevice::SASettings &settings);
private:
DataSource source;
2022-10-30 03:19:30 +08:00
double lastSweepPosition;
QDateTime lastReceivedData;
2022-10-01 23:10:44 +08:00
std::vector<Trace*> traces;
MarkerModel *markerModel;
};
#endif // TRACEMODEL_H