add scroll bars to graph area

This commit is contained in:
Jan Käberich 2022-12-12 22:59:10 +01:00
parent e6678435bd
commit fb347c37ac
5 changed files with 28 additions and 16 deletions

View File

@ -46,9 +46,12 @@
SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window, QString name) SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window, QString name)
: Mode(window, name, "SA"), : Mode(window, name, "SA"),
central(new TileWidget(traceModel, window)), central(new QScrollArea),
tiles(new TileWidget(traceModel, window)),
firstPointTime(0) firstPointTime(0)
{ {
central->setWidget(tiles);
central->setWidgetResizable(true);
changingSettings = false; changingSettings = false;
averages = 1; averages = 1;
singleSweep = false; singleSweep = false;
@ -385,7 +388,7 @@ nlohmann::json SpectrumAnalyzer::toJSON()
j["sweep"] = sweep; j["sweep"] = sweep;
j["traces"] = traceModel.toJSON(); j["traces"] = traceModel.toJSON();
j["tiles"] = central->toJSON(); j["tiles"] = tiles->toJSON();
j["markers"] = markerModel->toJSON(); j["markers"] = markerModel->toJSON();
return j; return j;
} }
@ -399,7 +402,7 @@ void SpectrumAnalyzer::fromJSON(nlohmann::json j)
traceModel.fromJSON(j["traces"]); traceModel.fromJSON(j["traces"]);
} }
if(j.contains("tiles")) { if(j.contains("tiles")) {
central->fromJSON(j["tiles"]); tiles->fromJSON(j["tiles"]);
} }
if(j.contains("markers")) { if(j.contains("markers")) {
markerModel->fromJSON(j["markers"]); markerModel->fromJSON(j["markers"]);
@ -1059,7 +1062,7 @@ void SpectrumAnalyzer::SetupSCPI()
return average.getLevel() == averages ? "TRUE" : "FALSE"; return average.getLevel() == averages ? "TRUE" : "FALSE";
})); }));
scpi_acq->add(new SCPICommand("LIMit", nullptr, [=](QStringList) -> QString { scpi_acq->add(new SCPICommand("LIMit", nullptr, [=](QStringList) -> QString {
return central->allLimitsPassing() ? "PASS" : "FAIL"; return tiles->allLimitsPassing() ? "PASS" : "FAIL";
})); }));
scpi_acq->add(new SCPICommand("SIGid", [=](QStringList params) -> QString { scpi_acq->add(new SCPICommand("SIGid", [=](QStringList params) -> QString {
if (params.size() != 1) { if (params.size() != 1) {
@ -1257,13 +1260,13 @@ void SpectrumAnalyzer::StoreSweepSettings()
void SpectrumAnalyzer::createDefaultTracesAndGraphs(int ports) void SpectrumAnalyzer::createDefaultTracesAndGraphs(int ports)
{ {
central->clear(); tiles->clear();
auto traceXY = new TraceXYPlot(traceModel); auto traceXY = new TraceXYPlot(traceModel);
traceXY->setYAxis(0, YAxis::Type::Magnitude, false, false, -120,0,10); traceXY->setYAxis(0, YAxis::Type::Magnitude, false, false, -120,0,10);
traceXY->setYAxis(1, YAxis::Type::Disabled, false, true, 0,0,1); traceXY->setYAxis(1, YAxis::Type::Disabled, false, true, 0,0,1);
traceXY->updateSpan(settings.freqStart, settings.freqStop); traceXY->updateSpan(settings.freqStart, settings.freqStop);
central->setPlot(traceXY); tiles->setPlot(traceXY);
QColor defaultColors[] = {Qt::yellow, Qt::blue, Qt::red, Qt::green, Qt::gray, Qt::cyan, Qt::magenta, Qt::white}; QColor defaultColors[] = {Qt::yellow, Qt::blue, Qt::red, Qt::green, Qt::gray, Qt::cyan, Qt::magenta, Qt::white};

View File

@ -12,6 +12,7 @@
#include <QWidget> #include <QWidget>
#include <QComboBox> #include <QComboBox>
#include <QCheckBox> #include <QCheckBox>
#include <QScrollArea>
class SpectrumAnalyzer : public Mode class SpectrumAnalyzer : public Mode
{ {
@ -99,7 +100,8 @@ private:
MarkerModel *markerModel; MarkerModel *markerModel;
Averaging average; Averaging average;
TileWidget *central; QScrollArea *central;
TileWidget *tiles;
QCheckBox *cbSignalID; QCheckBox *cbSignalID;
QComboBox *cbWindowType, *cbDetector; QComboBox *cbWindowType, *cbDetector;
QComboBox *cbTrackGenPort; QComboBox *cbTrackGenPort;

View File

@ -52,13 +52,17 @@
#include <QErrorMessage> #include <QErrorMessage>
#include <QDebug> #include <QDebug>
#include <QStyle> #include <QStyle>
#include <QScrollArea>
VNA::VNA(AppWindow *window, QString name) VNA::VNA(AppWindow *window, QString name)
: Mode(window, name, "VNA"), : Mode(window, name, "VNA"),
deembedding(traceModel), deembedding(traceModel),
deembedding_active(false), deembedding_active(false),
central(new TileWidget(traceModel)) central(new QScrollArea),
tiles(new TileWidget(traceModel))
{ {
central->setWidget(tiles);
central->setWidgetResizable(true);
averages = 1; averages = 1;
singleSweep = false; singleSweep = false;
calMeasuring = false; calMeasuring = false;
@ -734,7 +738,7 @@ nlohmann::json VNA::toJSON()
j["sweep"] = sweep; j["sweep"] = sweep;
j["traces"] = traceModel.toJSON(); j["traces"] = traceModel.toJSON();
j["tiles"] = central->toJSON(); j["tiles"] = tiles->toJSON();
j["markers"] = markerModel->toJSON(); j["markers"] = markerModel->toJSON();
j["de-embedding"] = deembedding.toJSON(); j["de-embedding"] = deembedding.toJSON();
j["de-embedding_enabled"] = deembedding_active; j["de-embedding_enabled"] = deembedding_active;
@ -750,7 +754,7 @@ void VNA::fromJSON(nlohmann::json j)
traceModel.fromJSON(j["traces"]); traceModel.fromJSON(j["traces"]);
} }
if(j.contains("tiles")) { if(j.contains("tiles")) {
central->fromJSON(j["tiles"]); tiles->fromJSON(j["tiles"]);
} }
if(j.contains("markers")) { if(j.contains("markers")) {
markerModel->fromJSON(j["markers"]); markerModel->fromJSON(j["markers"]);
@ -1359,7 +1363,7 @@ void VNA::SetupSCPI()
return average.getLevel() == averages ? SCPI::getResultName(SCPI::Result::True) : SCPI::getResultName(SCPI::Result::False); return average.getLevel() == averages ? SCPI::getResultName(SCPI::Result::True) : SCPI::getResultName(SCPI::Result::False);
})); }));
scpi_acq->add(new SCPICommand("LIMit", nullptr, [=](QStringList) -> QString { scpi_acq->add(new SCPICommand("LIMit", nullptr, [=](QStringList) -> QString {
return central->allLimitsPassing() ? "PASS" : "FAIL"; return tiles->allLimitsPassing() ? "PASS" : "FAIL";
})); }));
scpi_acq->add(new SCPICommand("SINGLE", [=](QStringList params) -> QString { scpi_acq->add(new SCPICommand("SINGLE", [=](QStringList params) -> QString {
bool single; bool single;
@ -1531,8 +1535,8 @@ void VNA::createDefaultTracesAndGraphs(int ports)
} }
} }
// Add created graphs to tiles // Add created graphs to tiles
central->clear(); tiles->clear();
TileWidget *tile = central; TileWidget *tile = tiles;
for(int i=0;i<ports;i++) { for(int i=0;i<ports;i++) {
TileWidget *row; TileWidget *row;
if(i != ports - 1) { if(i != ports - 1) {
@ -1557,7 +1561,7 @@ void VNA::createDefaultTracesAndGraphs(int ports)
} }
if(ports >= 3) { if(ports >= 3) {
// default split at the middle does not result in all plots being the same size, adjust // default split at the middle does not result in all plots being the same size, adjust
tile = central; tile = tiles;
for(int i=0;i<ports;i++) { for(int i=0;i<ports;i++) {
TileWidget *rowTile; TileWidget *rowTile;
if(i < ports - 1) { if(i < ports - 1) {

View File

@ -12,6 +12,7 @@
#include <QObject> #include <QObject>
#include <QWidget> #include <QWidget>
#include <QScrollArea>
#include <functional> #include <functional>
class VNA : public Mode class VNA : public Mode
@ -168,7 +169,8 @@ private:
QLabel *lAverages; QLabel *lAverages;
QLabel *calLabel; QLabel *calLabel;
TileWidget *central; TileWidget *tiles;
QScrollArea *central;
signals: signals:
void deviceInitialized(); void deviceInitialized();

View File

@ -1,4 +1,4 @@
#include "appwindow.h" #include "appwindow.h"
#include "unit.h" #include "unit.h"
#include "CustomWidgets/toggleswitch.h" #include "CustomWidgets/toggleswitch.h"
@ -58,6 +58,7 @@
#include <iomanip> #include <iomanip>
#include <QDateTime> #include <QDateTime>
#include <QCommandLineParser> #include <QCommandLineParser>
#include <QScrollArea>
using namespace std; using namespace std;