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)
: Mode(window, name, "SA"),
central(new TileWidget(traceModel, window)),
central(new QScrollArea),
tiles(new TileWidget(traceModel, window)),
firstPointTime(0)
{
central->setWidget(tiles);
central->setWidgetResizable(true);
changingSettings = false;
averages = 1;
singleSweep = false;
@ -385,7 +388,7 @@ nlohmann::json SpectrumAnalyzer::toJSON()
j["sweep"] = sweep;
j["traces"] = traceModel.toJSON();
j["tiles"] = central->toJSON();
j["tiles"] = tiles->toJSON();
j["markers"] = markerModel->toJSON();
return j;
}
@ -399,7 +402,7 @@ void SpectrumAnalyzer::fromJSON(nlohmann::json j)
traceModel.fromJSON(j["traces"]);
}
if(j.contains("tiles")) {
central->fromJSON(j["tiles"]);
tiles->fromJSON(j["tiles"]);
}
if(j.contains("markers")) {
markerModel->fromJSON(j["markers"]);
@ -1059,7 +1062,7 @@ void SpectrumAnalyzer::SetupSCPI()
return average.getLevel() == averages ? "TRUE" : "FALSE";
}));
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 {
if (params.size() != 1) {
@ -1257,13 +1260,13 @@ void SpectrumAnalyzer::StoreSweepSettings()
void SpectrumAnalyzer::createDefaultTracesAndGraphs(int ports)
{
central->clear();
tiles->clear();
auto traceXY = new TraceXYPlot(traceModel);
traceXY->setYAxis(0, YAxis::Type::Magnitude, false, false, -120,0,10);
traceXY->setYAxis(1, YAxis::Type::Disabled, false, true, 0,0,1);
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};

View File

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

View File

@ -52,13 +52,17 @@
#include <QErrorMessage>
#include <QDebug>
#include <QStyle>
#include <QScrollArea>
VNA::VNA(AppWindow *window, QString name)
: Mode(window, name, "VNA"),
deembedding(traceModel),
deembedding_active(false),
central(new TileWidget(traceModel))
central(new QScrollArea),
tiles(new TileWidget(traceModel))
{
central->setWidget(tiles);
central->setWidgetResizable(true);
averages = 1;
singleSweep = false;
calMeasuring = false;
@ -734,7 +738,7 @@ nlohmann::json VNA::toJSON()
j["sweep"] = sweep;
j["traces"] = traceModel.toJSON();
j["tiles"] = central->toJSON();
j["tiles"] = tiles->toJSON();
j["markers"] = markerModel->toJSON();
j["de-embedding"] = deembedding.toJSON();
j["de-embedding_enabled"] = deembedding_active;
@ -750,7 +754,7 @@ void VNA::fromJSON(nlohmann::json j)
traceModel.fromJSON(j["traces"]);
}
if(j.contains("tiles")) {
central->fromJSON(j["tiles"]);
tiles->fromJSON(j["tiles"]);
}
if(j.contains("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);
}));
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 {
bool single;
@ -1531,8 +1535,8 @@ void VNA::createDefaultTracesAndGraphs(int ports)
}
}
// Add created graphs to tiles
central->clear();
TileWidget *tile = central;
tiles->clear();
TileWidget *tile = tiles;
for(int i=0;i<ports;i++) {
TileWidget *row;
if(i != ports - 1) {
@ -1557,7 +1561,7 @@ void VNA::createDefaultTracesAndGraphs(int ports)
}
if(ports >= 3) {
// 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++) {
TileWidget *rowTile;
if(i < ports - 1) {

View File

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

View File

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