Improve old calibration import + graph pan/zoom settings
This commit is contained in:
parent
c343cdf69f
commit
2dd4edfae6
@ -1358,8 +1358,37 @@ void Calibration::fromJSON(nlohmann::json j)
|
||||
// unknown measurement name
|
||||
throw runtime_error("Measurement name unknown: "+std::string(j_m["name"]));
|
||||
}
|
||||
// no standard selection in this format, just use the first suitable one
|
||||
m->setFirstSupportedStandard();
|
||||
// attempt to select the correct standard
|
||||
bool p1male = j.value("port1StandardMale", true);
|
||||
bool p2male = j.value("port2StandardMale", true);
|
||||
bool throughZeroLength = j.value("throughZeroLength", true);
|
||||
|
||||
auto onePort = dynamic_cast<CalibrationMeasurement::OnePort*>(m);
|
||||
if(onePort) {
|
||||
bool male = onePort->getPort() == 1 ? p1male : p2male;
|
||||
QString name = male ? "Default male standard" : "Default female standard";
|
||||
for(auto s : m->supportedStandards()) {
|
||||
if(s->getName() == name) {
|
||||
m->setStandard(s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
auto through = dynamic_cast<CalibrationMeasurement::Through*>(m);
|
||||
if(through) {
|
||||
if(throughZeroLength) {
|
||||
// needs to create a zero length through standard in the calkit in addition to the already existing through standard
|
||||
auto zerolength = new CalStandard::Through();
|
||||
zerolength->setName("Zero length");
|
||||
kit.addStandard(zerolength);
|
||||
// use this standard
|
||||
m->setStandard(zerolength);
|
||||
}
|
||||
}
|
||||
if(!m->getStandard()) {
|
||||
// failed to find specific standard, use the first available
|
||||
m->setFirstSupportedStandard();
|
||||
}
|
||||
// extract points
|
||||
if(!j_m.contains("points")) {
|
||||
throw runtime_error("Measurement "+name.toStdString()+" does not contain any points");
|
||||
|
@ -354,6 +354,11 @@ std::vector<CalStandard::Virtual *> Calkit::getStandards() const
|
||||
return standards;
|
||||
}
|
||||
|
||||
void Calkit::addStandard(CalStandard::Virtual *s)
|
||||
{
|
||||
standards.push_back(s);
|
||||
}
|
||||
|
||||
nlohmann::json Calkit::toJSON()
|
||||
{
|
||||
json j = Savable::createJSON(descr);
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
void edit(std::function<void(void)> updateCal = nullptr);
|
||||
|
||||
std::vector<CalStandard::Virtual *> getStandards() const;
|
||||
void addStandard(CalStandard::Virtual* s);
|
||||
|
||||
virtual nlohmann::json toJSON() override;
|
||||
virtual void fromJSON(nlohmann::json j) override;
|
||||
|
@ -326,9 +326,10 @@ void TracePlot::finishContextMenu()
|
||||
|
||||
void TracePlot::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
auto &pref = Preferences::getInstance();
|
||||
if(event->buttons() == Qt::LeftButton) {
|
||||
selectedMarker = markerAtPosition(event->pos(), true);
|
||||
if(!selectedMarker && positionWithinGraphArea(event->pos())) {
|
||||
if(!selectedMarker && pref.Graphs.enablePanAndZoom && positionWithinGraphArea(event->pos())) {
|
||||
// no marker at the position, enter trace moving mode
|
||||
movingGraph = true;
|
||||
lastMousePoint = event->pos();
|
||||
@ -337,7 +338,7 @@ void TracePlot::mousePressEvent(QMouseEvent *event)
|
||||
} else {
|
||||
selectedMarker = nullptr;
|
||||
}
|
||||
if(event->button() == Qt::MiddleButton) {
|
||||
if(pref.Graphs.enablePanAndZoom && event->button() == Qt::MiddleButton) {
|
||||
bool horizontally = !(QApplication::keyboardModifiers() & Qt::ShiftModifier);
|
||||
bool vertically = !(QApplication::keyboardModifiers() & Qt::ControlModifier);
|
||||
setAuto(horizontally, vertically);
|
||||
@ -392,10 +393,10 @@ void TracePlot::leaveEvent(QEvent *event)
|
||||
void TracePlot::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
auto &pref = Preferences::getInstance();
|
||||
if(positionWithinGraphArea(event->pos())) {
|
||||
if(pref.Graphs.enablePanAndZoom && positionWithinGraphArea(event->pos())) {
|
||||
bool horizontally = !(QApplication::keyboardModifiers() & Qt::ShiftModifier);
|
||||
bool vertically = !(QApplication::keyboardModifiers() & Qt::ControlModifier);
|
||||
double factor = pow((1.0-pref.Graphs.zoomFactor), (double) event->angleDelta().y() / 120.0);
|
||||
double factor = pow(pref.Graphs.zoomFactor, (double) event->angleDelta().y() / 120.0);
|
||||
zoom(event->pos(), factor, horizontally, vertically);
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +115,9 @@ PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) :
|
||||
connect(ui->AcquisitionADCpresc, qOverload<int>(&QSpinBox::valueChanged), updateIF2);
|
||||
connect(ui->AcquisitionADCphaseInc, qOverload<int>(&QSpinBox::valueChanged), updateIF2);
|
||||
|
||||
// Graph page
|
||||
ui->GraphsZoomFactor->setPrecision(3);
|
||||
|
||||
// General page
|
||||
if(p->TCPoverride) {
|
||||
ui->SCPIServerPort->setEnabled(false);
|
||||
@ -305,6 +308,8 @@ void PreferencesDialog::setInitialGUIState()
|
||||
ui->GraphsFontSizeCursorOverlay->setValue(p->Graphs.fontSizeCursorOverlay);
|
||||
ui->GraphsFontSizeMarkerData->setValue(p->Graphs.fontSizeMarkerData);
|
||||
ui->GraphsFontSizeTraceNames->setValue(p->Graphs.fontSizeTraceNames);
|
||||
ui->GraphsEnablePanZoom->setChecked(p->Graphs.enablePanAndZoom);
|
||||
ui->GraphsZoomFactor->setValue(p->Graphs.zoomFactor);
|
||||
|
||||
ui->MarkerShowMarkerData->setChecked(p->Marker.defaultBehavior.showDataOnGraphs);
|
||||
ui->MarkerShowAllMarkerData->setChecked(p->Marker.defaultBehavior.showAllData);
|
||||
@ -376,6 +381,8 @@ void PreferencesDialog::updateFromGUI()
|
||||
p->Graphs.fontSizeCursorOverlay = ui->GraphsFontSizeCursorOverlay->value();
|
||||
p->Graphs.fontSizeMarkerData = ui->GraphsFontSizeMarkerData->value();
|
||||
p->Graphs.fontSizeTraceNames = ui->GraphsFontSizeTraceNames->value();
|
||||
p->Graphs.enablePanAndZoom = ui->GraphsEnablePanZoom->isChecked();
|
||||
p->Graphs.zoomFactor = ui->GraphsZoomFactor->value();
|
||||
|
||||
p->Marker.defaultBehavior.showDataOnGraphs = ui->MarkerShowMarkerData->isChecked();
|
||||
p->Marker.defaultBehavior.showAllData = ui->MarkerShowAllMarkerData->isChecked();
|
||||
|
@ -129,6 +129,7 @@ public:
|
||||
int fontSizeTraceNames;
|
||||
int fontSizeCursorOverlay;
|
||||
|
||||
bool enablePanAndZoom;
|
||||
double zoomFactor;
|
||||
} Graphs;
|
||||
struct {
|
||||
@ -213,7 +214,8 @@ private:
|
||||
{&Graphs.fontSizeCursorOverlay, "Graphs.fontSizeCursorOverlay", 12},
|
||||
{&Graphs.fontSizeMarkerData, "Graphs.fontSizeMarkerData", 12},
|
||||
{&Graphs.fontSizeTraceNames, "Graphs.fontSizeTraceNames", 12},
|
||||
{&Graphs.zoomFactor, "Graphs.zoomFactor", 0.2},
|
||||
{&Graphs.enablePanAndZoom, "Graphs.enablePanAndZoom", true},
|
||||
{&Graphs.zoomFactor, "Graphs.zoomFactor", 0.9},
|
||||
{&Marker.defaultBehavior.showDataOnGraphs, "Marker.defaultBehavior.ShowDataOnGraphs", true},
|
||||
{&Marker.defaultBehavior.showAllData, "Marker.defaultBehavior.ShowAllData", false},
|
||||
{&Marker.interpolatePoints, "Marker.interpolatePoints", false},
|
||||
|
@ -83,8 +83,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>687</width>
|
||||
<height>884</height>
|
||||
<width>684</width>
|
||||
<height>854</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_12">
|
||||
@ -103,7 +103,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="Startup">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
@ -1117,6 +1117,39 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_18">
|
||||
<property name="title">
|
||||
<string>Pan and Zoom</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_13">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_46">
|
||||
<property name="text">
|
||||
<string>Enable:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="GraphsEnablePanZoom">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_47">
|
||||
<property name="text">
|
||||
<string>Zoom factor:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="SIUnitEdit" name="GraphsZoomFactor"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_12">
|
||||
<property name="title">
|
||||
|
Loading…
Reference in New Issue
Block a user