restrict SA graph options, show dBm instead dB
This commit is contained in:
parent
b2ed124240
commit
0c782fc009
@ -57,6 +57,8 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window)
|
||||
normalize.points = 0;
|
||||
normalize.dialog.reset();
|
||||
|
||||
traceModel.setSource(TraceModel::DataSource::SA);
|
||||
|
||||
// Create default traces
|
||||
auto tPort1 = new Trace("Port1", Qt::yellow);
|
||||
tPort1->fromLivedata(Trace::LivedataType::Overwrite, Trace::LiveParameter::Port1);
|
||||
|
@ -9,6 +9,7 @@ TraceModel::TraceModel(QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
traces.clear();
|
||||
source = DataSource::Unknown;
|
||||
}
|
||||
|
||||
TraceModel::~TraceModel()
|
||||
@ -208,6 +209,7 @@ void TraceModel::clearLiveData()
|
||||
|
||||
void TraceModel::addVNAData(const Protocol::Datapoint &d, TraceMath::DataType datatype)
|
||||
{
|
||||
source = DataSource::VNA;
|
||||
for(auto t : traces) {
|
||||
if (t->isLive() && !t->isPaused()) {
|
||||
Trace::Data td;
|
||||
@ -238,6 +240,7 @@ void TraceModel::addVNAData(const Protocol::Datapoint &d, TraceMath::DataType da
|
||||
|
||||
void TraceModel::addSAData(const Protocol::SpectrumAnalyzerResult& d, const Protocol::SpectrumAnalyzerSettings& settings)
|
||||
{
|
||||
source = DataSource::SA;
|
||||
for(auto t : traces) {
|
||||
if (t->isLive() && !t->isPaused()) {
|
||||
Trace::Data td;
|
||||
@ -254,6 +257,16 @@ void TraceModel::addSAData(const Protocol::SpectrumAnalyzerResult& d, const Prot
|
||||
}
|
||||
}
|
||||
|
||||
TraceModel::DataSource TraceModel::getSource() const
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
void TraceModel::setSource(const DataSource &value)
|
||||
{
|
||||
source = value;
|
||||
}
|
||||
|
||||
MarkerModel *TraceModel::getMarkerModel() const
|
||||
{
|
||||
return markerModel;
|
||||
|
@ -25,6 +25,12 @@ public:
|
||||
ColIndexLast,
|
||||
};
|
||||
|
||||
enum class DataSource {
|
||||
VNA,
|
||||
SA,
|
||||
Unknown,
|
||||
};
|
||||
|
||||
void addTrace(Trace *t);
|
||||
void removeTrace(unsigned int index);
|
||||
Trace *trace(unsigned int index);
|
||||
@ -46,6 +52,9 @@ public:
|
||||
MarkerModel *getMarkerModel() const;
|
||||
void setMarkerModel(MarkerModel *value);
|
||||
|
||||
DataSource getSource() const;
|
||||
void setSource(const DataSource &value);
|
||||
|
||||
signals:
|
||||
void SpanChanged(double fmin, double fmax);
|
||||
void traceAdded(Trace *t);
|
||||
@ -59,6 +68,7 @@ public slots:
|
||||
void addSAData(const Protocol::SpectrumAnalyzerResult& d, const Protocol::SpectrumAnalyzerSettings& settings);
|
||||
|
||||
private:
|
||||
DataSource source;
|
||||
std::vector<Trace*> traces;
|
||||
MarkerModel *markerModel;
|
||||
};
|
||||
|
@ -466,6 +466,11 @@ void TracePlot::markerRemoved(Marker *m)
|
||||
triggerReplot();
|
||||
}
|
||||
|
||||
TraceModel &TracePlot::getModel() const
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
void TracePlot::updateGraphColors()
|
||||
{
|
||||
replot();
|
||||
|
@ -29,6 +29,8 @@ public:
|
||||
|
||||
static std::set<TracePlot *> getPlots();
|
||||
|
||||
TraceModel &getModel() const;
|
||||
|
||||
public slots:
|
||||
void updateGraphColors();
|
||||
|
||||
|
@ -342,7 +342,7 @@ void TraceXYPlot::draw(QPainter &p)
|
||||
{
|
||||
auto pref = Preferences::getInstance();
|
||||
|
||||
constexpr int yAxisSpace = 50;
|
||||
constexpr int yAxisSpace = 55;
|
||||
constexpr int yAxisDisabledSpace = 10;
|
||||
constexpr int xAxisSpace = 30;
|
||||
auto w = p.window();
|
||||
@ -1227,6 +1227,8 @@ QString TraceXYPlot::mouseText(QPoint pos)
|
||||
|
||||
QString TraceXYPlot::AxisUnit(TraceXYPlot::YAxisType type)
|
||||
{
|
||||
auto source = model.getSource();
|
||||
if(source == TraceModel::DataSource::VNA) {
|
||||
switch(type) {
|
||||
case TraceXYPlot::YAxisType::Magnitude: return "dB";
|
||||
case TraceXYPlot::YAxisType::Phase: return "°";
|
||||
@ -1239,6 +1241,13 @@ QString TraceXYPlot::AxisUnit(TraceXYPlot::YAxisType type)
|
||||
case TraceXYPlot::YAxisType::GroupDelay: return "s";
|
||||
default: return "";
|
||||
}
|
||||
} else if(source == TraceModel::DataSource::SA) {
|
||||
switch(type) {
|
||||
case TraceXYPlot::YAxisType::Magnitude: return "dBm";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
QString TraceXYPlot::AxisUnit(TraceXYPlot::XAxisType type)
|
||||
|
@ -78,9 +78,9 @@ private:
|
||||
static QString AxisTypeToName(YAxisType type);
|
||||
static QString AxisTypeToName(XAxisType type);
|
||||
static QString AxisModeToName(XAxisMode mode);
|
||||
XAxisType XAxisTypeFromName(QString name);
|
||||
YAxisType YAxisTypeFromName(QString name);
|
||||
XAxisMode AxisModeFromName(QString name);
|
||||
static XAxisType XAxisTypeFromName(QString name);
|
||||
static YAxisType YAxisTypeFromName(QString name);
|
||||
static XAxisMode AxisModeFromName(QString name);
|
||||
void enableTraceAxis(Trace *t, int axis, bool enabled);
|
||||
bool domainMatch(Trace *t);
|
||||
bool supported(Trace *t) override;
|
||||
@ -94,7 +94,7 @@ private:
|
||||
void traceDropped(Trace *t, QPoint position) override;
|
||||
QString mouseText(QPoint pos) override;
|
||||
|
||||
static QString AxisUnit(YAxisType type);
|
||||
QString AxisUnit(YAxisType type);
|
||||
static QString AxisUnit(XAxisType type);
|
||||
|
||||
std::set<Trace*> tracesAxis[2];
|
||||
|
@ -6,6 +6,13 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
static void enableComboBoxItem(QComboBox *cb, int itemNum, bool enable) {
|
||||
auto *model = qobject_cast<QStandardItemModel *>(cb->model());
|
||||
auto item = model->item(itemNum);
|
||||
item->setFlags(enable ? item->flags() | Qt::ItemIsEnabled
|
||||
: item->flags() & ~Qt::ItemIsEnabled);
|
||||
}
|
||||
|
||||
XYplotAxisDialog::XYplotAxisDialog(TraceXYPlot *plot) :
|
||||
QDialog(nullptr),
|
||||
ui(new Ui::XYplotAxisDialog),
|
||||
@ -26,8 +33,17 @@ XYplotAxisDialog::XYplotAxisDialog(TraceXYPlot *plot) :
|
||||
ui->XType->addItem(TraceXYPlot::AxisTypeToName((TraceXYPlot::XAxisType) i));
|
||||
}
|
||||
|
||||
if(plot->getModel().getSource() == TraceModel::DataSource::SA) {
|
||||
for(int i=0;i<ui->XType->count();i++) {
|
||||
auto xtype = TraceXYPlot::XAxisTypeFromName(ui->XType->itemText(i));
|
||||
if(!isSupported(xtype)) {
|
||||
enableComboBoxItem(ui->XType, i, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Setup GUI connections
|
||||
connect(ui->Y1type, qOverload<int>(&QComboBox::currentIndexChanged), [this](int index) {
|
||||
connect(ui->Y1type, qOverload<int>(&QComboBox::currentIndexChanged), [=](int index) {
|
||||
//ui->Y1log->setEnabled(index != 0);
|
||||
ui->Y1linear->setEnabled(index != 0);
|
||||
ui->Y1auto->setEnabled(index != 0);
|
||||
@ -36,7 +52,7 @@ XYplotAxisDialog::XYplotAxisDialog(TraceXYPlot *plot) :
|
||||
ui->Y1max->setEnabled(index != 0 && !autoRange);
|
||||
ui->Y1divs->setEnabled(index != 0 && !autoRange);
|
||||
auto type = (TraceXYPlot::YAxisType) index;
|
||||
QString unit = TraceXYPlot::AxisUnit(type);
|
||||
QString unit = plot->AxisUnit(type);
|
||||
ui->Y1min->setUnit(unit);
|
||||
ui->Y1max->setUnit(unit);
|
||||
ui->Y1divs->setUnit(unit);
|
||||
@ -47,7 +63,7 @@ XYplotAxisDialog::XYplotAxisDialog(TraceXYPlot *plot) :
|
||||
ui->Y1divs->setEnabled(!checked);
|
||||
});
|
||||
|
||||
connect(ui->Y2type, qOverload<int>(&QComboBox::currentIndexChanged), [this](int index) {
|
||||
connect(ui->Y2type, qOverload<int>(&QComboBox::currentIndexChanged), [=](int index) {
|
||||
//ui->Y2log->setEnabled(index != 0);
|
||||
ui->Y2linear->setEnabled(index != 0);
|
||||
ui->Y2auto->setEnabled(index != 0);
|
||||
@ -56,7 +72,7 @@ XYplotAxisDialog::XYplotAxisDialog(TraceXYPlot *plot) :
|
||||
ui->Y2max->setEnabled(index != 0 && !autoRange);
|
||||
ui->Y2divs->setEnabled(index != 0 && !autoRange);
|
||||
auto type = (TraceXYPlot::YAxisType) index;
|
||||
QString unit = TraceXYPlot::AxisUnit(type);
|
||||
QString unit = plot->AxisUnit(type);
|
||||
ui->Y2min->setUnit(unit);
|
||||
ui->Y2max->setUnit(unit);
|
||||
ui->Y2divs->setUnit(unit);
|
||||
@ -148,13 +164,6 @@ void XYplotAxisDialog::on_buttonBox_accepted()
|
||||
plot->setXAxis((TraceXYPlot::XAxisType) ui->XType->currentIndex(), mode, ui->Xlog->isChecked(), ui->Xmin->value(), ui->Xmax->value(), ui->Xdivs->value());
|
||||
}
|
||||
|
||||
static void enableComboBoxItem(QComboBox *cb, int itemNum, bool enable) {
|
||||
auto *model = qobject_cast<QStandardItemModel *>(cb->model());
|
||||
auto item = model->item(itemNum);
|
||||
item->setFlags(enable ? item->flags() | Qt::ItemIsEnabled
|
||||
: item->flags() & ~Qt::ItemIsEnabled);
|
||||
}
|
||||
|
||||
void XYplotAxisDialog::XAxisTypeChanged(int XAxisIndex)
|
||||
{
|
||||
auto type = (TraceXYPlot::XAxisType) XAxisIndex;
|
||||
@ -199,6 +208,8 @@ void XYplotAxisDialog::XAxisTypeChanged(int XAxisIndex)
|
||||
std::set<TraceXYPlot::YAxisType> XYplotAxisDialog::supportedYAxis(TraceXYPlot::XAxisType type)
|
||||
{
|
||||
set<TraceXYPlot::YAxisType> ret = {TraceXYPlot::YAxisType::Disabled};
|
||||
auto source = plot->getModel().getSource();
|
||||
if(source == TraceModel::DataSource::VNA) {
|
||||
switch(type) {
|
||||
case TraceXYPlot::XAxisType::Frequency:
|
||||
case TraceXYPlot::XAxisType::Power:
|
||||
@ -225,5 +236,30 @@ std::set<TraceXYPlot::YAxisType> XYplotAxisDialog::supportedYAxis(TraceXYPlot::X
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if(source == TraceModel::DataSource::SA) {
|
||||
switch(type) {
|
||||
case TraceXYPlot::XAxisType::Frequency:
|
||||
ret.insert(TraceXYPlot::YAxisType::Magnitude);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool XYplotAxisDialog::isSupported(TraceXYPlot::XAxisType type)
|
||||
{
|
||||
auto source = plot->getModel().getSource();
|
||||
if(source == TraceModel::DataSource::VNA) {
|
||||
// all X axis types are supported
|
||||
return true;
|
||||
} else if(source == TraceModel::DataSource::SA) {
|
||||
if (type == TraceXYPlot::XAxisType::Frequency) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ private slots:
|
||||
|
||||
private:
|
||||
std::set<TraceXYPlot::YAxisType> supportedYAxis(TraceXYPlot::XAxisType type);
|
||||
bool isSupported(TraceXYPlot::XAxisType type);
|
||||
Ui::XYplotAxisDialog *ui;
|
||||
TraceXYPlot *plot;
|
||||
};
|
||||
|
@ -64,6 +64,8 @@ VNA::VNA(AppWindow *window)
|
||||
calEdited = false;
|
||||
settings.sweepType = SweepType::Frequency;
|
||||
|
||||
traceModel.setSource(TraceModel::DataSource::VNA);
|
||||
|
||||
// Create default traces
|
||||
auto tS11 = new Trace("S11", Qt::yellow);
|
||||
tS11->fromLivedata(Trace::LivedataType::Overwrite, Trace::LiveParameter::S11);
|
||||
|
Loading…
Reference in New Issue
Block a user