diff --git a/Software/PC_Application/Calibration/calibration.cpp b/Software/PC_Application/Calibration/calibration.cpp index bf0710e..1737f9d 100644 --- a/Software/PC_Application/Calibration/calibration.cpp +++ b/Software/PC_Application/Calibration/calibration.cpp @@ -790,7 +790,7 @@ bool Calibration::openFromFile(QString filename) qDebug() << "Associated calibration kit expected in" << calkit_file; try { kit = Calkit::fromFile(calkit_file); - } catch (runtime_error e) { + } catch (runtime_error &e) { InformationBox::ShowError("Missing calibration kit", "The calibration kit file associated with the selected calibration could not be parsed. The calibration might not be accurate. (" + QString(e.what()) + ")"); qWarning() << "Parsing of calibration kit failed while opening calibration file: " << e.what(); } @@ -809,7 +809,7 @@ bool Calibration::openFromFile(QString filename) nlohmann::json j; file >> j; fromJSON(j); - } catch(exception e) { + } catch(exception &e) { // json parsing failed, probably using a legacy file format try { file.clear(); @@ -818,7 +818,7 @@ bool Calibration::openFromFile(QString filename) InformationBox::ShowMessage("Loading calibration file", "The file \"" + filename + "\" is stored in a deprecated" " calibration format. Future versions of this application might not support" " it anymore. Please save the calibration to update to the new format"); - } catch(exception e) { + } catch(exception &e) { InformationBox::ShowError("File parsing error", e.what()); qWarning() << "Calibration file parsing failed: " << e.what(); return false; diff --git a/Software/PC_Application/Calibration/calkit.h b/Software/PC_Application/Calibration/calkit.h index 3c4e8ac..bd094f6 100644 --- a/Software/PC_Application/Calibration/calkit.h +++ b/Software/PC_Application/Calibration/calkit.h @@ -13,6 +13,7 @@ class Calkit friend class CalkitDialog; public: Calkit(); + Calkit(const Calkit&) = default; Calkit& operator=(const Calkit& other) { this->manufacturer = other.manufacturer; diff --git a/Software/PC_Application/Calibration/calkitdialog.cpp b/Software/PC_Application/Calibration/calkitdialog.cpp index 7f8cca4..a684619 100644 --- a/Software/PC_Application/Calibration/calkitdialog.cpp +++ b/Software/PC_Application/Calibration/calkitdialog.cpp @@ -195,7 +195,7 @@ CalkitDialog::CalkitDialog(Calkit &c, QWidget *parent) : if(filename.length() > 0) { try { ownKit = Calkit::fromFile(filename); - } catch (runtime_error e) { + } catch (runtime_error &e) { InformationBox::ShowError("Error", "The calibration kit file could not be parsed (" + QString(e.what()) + ")"); qWarning() << "Parsing of calibration kit failed while opening calibration file: " << e.what(); } diff --git a/Software/PC_Application/CustomWidgets/jsonpickerdialog.cpp b/Software/PC_Application/CustomWidgets/jsonpickerdialog.cpp index a1fe5ff..82fe8ff 100644 --- a/Software/PC_Application/CustomWidgets/jsonpickerdialog.cpp +++ b/Software/PC_Application/CustomWidgets/jsonpickerdialog.cpp @@ -113,12 +113,11 @@ QVariant JSONModel::data(const QModelIndex &index, int role) const case 0: return info.name; case 1: - if(item->is_object() || item->is_array()) { - return QVariant(); - } else { + if(!item->is_object() && !item->is_array()) { return info.data; } } + return QVariant(); case Qt::CheckStateRole: { if(index.column() == 0) { return info.enabled ? Qt::Checked : Qt::Unchecked; diff --git a/Software/PC_Application/SpectrumAnalyzer/tracewidgetsa.cpp b/Software/PC_Application/SpectrumAnalyzer/tracewidgetsa.cpp index 08cc863..ada3123 100644 --- a/Software/PC_Application/SpectrumAnalyzer/tracewidgetsa.cpp +++ b/Software/PC_Application/SpectrumAnalyzer/tracewidgetsa.cpp @@ -44,7 +44,7 @@ void TraceWidgetSA::importDialog() if(AppWindow::showGUI()) { i->show(); } - } catch(const std::exception e) { + } catch(const std::exception &e) { InformationBox::ShowError("Failed to import file", QString("Attempt to import file ended with error: \"") + e.what()+"\""); } } diff --git a/Software/PC_Application/Tools/impedancematchdialog.cpp b/Software/PC_Application/Tools/impedancematchdialog.cpp index 79814c8..2618804 100644 --- a/Software/PC_Application/Tools/impedancematchdialog.cpp +++ b/Software/PC_Application/Tools/impedancematchdialog.cpp @@ -267,7 +267,7 @@ void ImpedanceMatchDialog::calculateMatch() ui->Image->setPixmap(QPixmap(":/icons/pCsC_small.png")); } } - } catch (exception e){ + } catch (exception &e){ // something went wrong, probably caused by (intermediate) invalid input, such as f=0Hz ui->lValue->setValue(nan("")); ui->cValue->setValue(nan("")); diff --git a/Software/PC_Application/Traces/traceaxis.cpp b/Software/PC_Application/Traces/traceaxis.cpp index bc6c9a8..e7be30b 100644 --- a/Software/PC_Application/Traces/traceaxis.cpp +++ b/Software/PC_Application/Traces/traceaxis.cpp @@ -81,6 +81,11 @@ static void createLogarithmicTicks(vector& ticks, double start, double s } while(div <= stop); } +YAxis::YAxis() +{ + type = Type::Magnitude; +} + double YAxis::sampleToCoordinate(Trace::Data data, Trace *t, unsigned int sample) { switch(type) { @@ -246,7 +251,7 @@ QString YAxis::Unit(Type type, TraceModel::DataSource source) case Type::Reactance: return "Ω"; case Type::Capacitance: return "F"; case Type::Inductance: return "H"; - case Type::Last: return ""; + default: return ""; } } else if(source == TraceModel::DataSource::SA) { switch(type) { @@ -280,7 +285,7 @@ QString YAxis::Prefixes(Type type, TraceModel::DataSource source) case Type::Reactance: return "m kM"; case Type::Capacitance: return "pnum "; case Type::Inductance: return "pnum "; - case Type::Last: return " "; + default: return " "; } } else if(source == TraceModel::DataSource::SA) { switch(type) { @@ -358,8 +363,14 @@ bool Axis::getLog() const return log; } +XAxis::XAxis() +{ + type = Type::Frequency; +} + double XAxis::sampleToCoordinate(Trace::Data data, Trace *t, unsigned int sample) { + Q_UNUSED(sample) switch(type) { case Type::Distance: if(!t) { @@ -430,6 +441,16 @@ XAxis::Type XAxis::getType() const return type; } +Axis::Axis() +{ + log = false; + autorange = true; + rangeMin = -1.0; + rangeMax = 1.0; + rangeDiv = 1.0; + ticks.clear(); +} + double Axis::transform(double value, double to_low, double to_high) { return Util::Scale(value, rangeMin, rangeMax, to_low, to_high, log); diff --git a/Software/PC_Application/Traces/traceaxis.h b/Software/PC_Application/Traces/traceaxis.h index cc9ed8f..960bd9c 100644 --- a/Software/PC_Application/Traces/traceaxis.h +++ b/Software/PC_Application/Traces/traceaxis.h @@ -8,6 +8,7 @@ class Axis { public: + Axis(); virtual double sampleToCoordinate(Trace::Data data, Trace *t = nullptr, unsigned int sample = 0) = 0; double transform(double value, double to_low, double to_high); double inverseTransform(double value, double to_low, double to_high); @@ -55,6 +56,7 @@ public: Impedance, Last, }; + YAxis(); double sampleToCoordinate(Trace::Data data, Trace *t = nullptr, unsigned int sample = 0) override; void set(Type type, bool log, bool autorange, double min, double max, double div); static QString TypeToName(Type type); @@ -80,6 +82,7 @@ public: Power, Last, }; + XAxis(); double sampleToCoordinate(Trace::Data data, Trace *t = nullptr, unsigned int sample = 0) override; void set(Type type, bool log, bool autorange, double min, double max, double div); static QString TypeToName(Type type); diff --git a/Software/PC_Application/Traces/tracesmithchart.cpp b/Software/PC_Application/Traces/tracesmithchart.cpp index 516aaa3..408cf7d 100644 --- a/Software/PC_Application/Traces/tracesmithchart.cpp +++ b/Software/PC_Application/Traces/tracesmithchart.cpp @@ -20,6 +20,7 @@ TraceSmithChart::TraceSmithChart(TraceModel &model, QWidget *parent) : TracePlot(model, parent) { limitToSpan = true; + limitToEdge = true; edgeReflection = 1.0; initializeTraceInfo(); } diff --git a/Software/PC_Application/Traces/tracewaterfall.cpp b/Software/PC_Application/Traces/tracewaterfall.cpp index 101055b..a6dc656 100644 --- a/Software/PC_Application/Traces/tracewaterfall.cpp +++ b/Software/PC_Application/Traces/tracewaterfall.cpp @@ -21,6 +21,11 @@ TraceWaterfall::TraceWaterfall(TraceModel &model, QWidget *parent) keepDataBeyondPlotSize(false), maxDataSweeps(500) { + plotAreaTop = 0; + plotAreaLeft = 0; + plotAreaWidth = 0; + plotAreaBottom = 0; + xAxis.set(XAxis::Type::Frequency, false, true, 0, 6000000000, 500000000); yAxis.set(YAxis::Type::Magnitude, false, true, -1, 1, 1); initializeTraceInfo(); @@ -478,7 +483,7 @@ double TraceWaterfall::nearestTracePoint(Trace *t, QPoint pixel, double *distanc QString TraceWaterfall::mouseText(QPoint pos) { QString ret; - if(QRect(plotAreaLeft, 0, plotAreaWidth + 1, plotAreaBottom).contains(pos)) { + if(QRect(plotAreaLeft, plotAreaTop, plotAreaWidth + 1, plotAreaBottom).contains(pos)) { double x = xAxis.inverseTransform(pos.x(), plotAreaLeft, plotAreaLeft + plotAreaWidth); int significantDigits = floor(log10(abs(xAxis.getRangeMax()))) - floor(log10((abs(xAxis.getRangeMax() - xAxis.getRangeMin())) / 1000.0)) + 1; ret += Unit::ToString(x, xAxis.Unit(), "fpnum kMG", significantDigits) + "\n"; diff --git a/Software/PC_Application/VNA/vna.cpp b/Software/PC_Application/VNA/vna.cpp index ee14a92..85bef89 100644 --- a/Software/PC_Application/VNA/vna.cpp +++ b/Software/PC_Application/VNA/vna.cpp @@ -757,7 +757,7 @@ void VNA::fromJSON(nlohmann::json j) EnableDeembedding(false); } - // sweep configuration has to go last sog graphs can catch events from changed sweep + // sweep configuration has to go last so graphs can catch events from changed sweep if(j.contains("sweep")) { auto sweep = j["sweep"]; // restore sweep settings, keep current value as default in case of missing entry @@ -882,7 +882,7 @@ void VNA::SettingsChanged(bool resetTraces, std::function maxPoints) { points = maxPoints; } else if (points < 2) { @@ -1176,7 +1176,7 @@ void VNA::ApplyCalibration(Calibration::Type type) } else { DisableCalibration(true); } - } catch (runtime_error e) { + } catch (runtime_error &e) { InformationBox::ShowError("Calibration failure", e.what()); DisableCalibration(true); } @@ -1196,8 +1196,7 @@ void VNA::ApplyCalibration(Calibration::Type type) void VNA::StartCalibrationMeasurements(std::set m) { - auto device = window->getDevice(); - if(!device) { + if(!window->getDevice()) { return; } // Stop sweep diff --git a/Software/PC_Application/VNA/vna.h b/Software/PC_Application/VNA/vna.h index 47db758..9371b45 100644 --- a/Software/PC_Application/VNA/vna.h +++ b/Software/PC_Application/VNA/vna.h @@ -42,6 +42,12 @@ public: class Settings { public: + Settings() + : sweepType(SweepType::Frequency) + , Freq({.start=1000000, .stop=6000000000, .excitation_power=-10, .logSweep=false}) + , Power({.start=-40, .stop=-10, .frequency=1000000000}) + , npoints(501), bandwidth(1000), excitingPort1(true), excitingPort2(true) + , segments(1), activeSegment(0){} SweepType sweepType; struct { double start;