diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp b/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp index b6eb437..76d8400 100644 --- a/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp @@ -1316,7 +1316,7 @@ void Calibration::fromJSON(nlohmann::json j) } break; case 2: { - // TODO load associated calkit + // associated calkit should already be loaded if(j.contains("measurements")) { // grab measurements for(auto j_m : j["measurements"]) { diff --git a/Software/PC_Application/LibreVNA-GUI/Device/device.cpp b/Software/PC_Application/LibreVNA-GUI/Device/device.cpp index 57e01dd..1f9e288 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/device.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/device.cpp @@ -25,6 +25,7 @@ USBInBuffer::USBInBuffer(libusb_device_handle *handle, unsigned char endpoint, i inCallback(false) { buffer = new unsigned char[buffer_size]; + memset(buffer, 0, buffer_size); transfer = libusb_alloc_transfer(0); libusb_fill_bulk_transfer(transfer, handle, endpoint, buffer, buffer_size, CallbackTrampoline, this, 0); libusb_submit_transfer(transfer); @@ -229,9 +230,6 @@ Device::Device(QString serial) connect(this, &Device::receivedAnswer, this, &Device::transmissionFinished, Qt::QueuedConnection); transmissionTimer.setSingleShot(true); transmissionActive = false; - // got a new connection, request info - SendCommandWithoutPayload(Protocol::PacketType::RequestDeviceInfo); - SendCommandWithoutPayload(Protocol::PacketType::RequestDeviceStatus); } Device::~Device() diff --git a/Software/PC_Application/LibreVNA-GUI/Device/virtualdevice.cpp b/Software/PC_Application/LibreVNA-GUI/Device/virtualdevice.cpp index 2046f63..5f57fb5 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/virtualdevice.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/virtualdevice.cpp @@ -178,6 +178,14 @@ void VirtualDevice::RegisterTypes() qRegisterMetaType("SAMeasurement"); } +void VirtualDevice::initialize() +{ + for(auto dev : devices) { + dev->SendCommandWithoutPayload(Protocol::PacketType::RequestDeviceInfo); + dev->SendCommandWithoutPayload(Protocol::PacketType::RequestDeviceStatus); + } +} + bool VirtualDevice::isCompoundDevice() const { return cdev != nullptr; diff --git a/Software/PC_Application/LibreVNA-GUI/Device/virtualdevice.h b/Software/PC_Application/LibreVNA-GUI/Device/virtualdevice.h index b25bb0a..236711f 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/virtualdevice.h +++ b/Software/PC_Application/LibreVNA-GUI/Device/virtualdevice.h @@ -61,6 +61,8 @@ public: static void RegisterTypes(); + void initialize(); // call this after creating the virtual device and all connections to signals have been made + bool isCompoundDevice() const; Device *getDevice(); CompoundDevice *getCompoundDevice(); diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp index 8e2b26e..ed69e6f 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp @@ -339,12 +339,13 @@ void TracePlot::finishContextMenu() void TracePlot::mousePressEvent(QMouseEvent *event) { auto &pref = Preferences::getInstance(); + auto position = event->pos() - QPoint(marginLeft, marginTop); if(event->buttons() == Qt::LeftButton) { - selectedMarker = markerAtPosition(event->pos(), true); - if(!selectedMarker && pref.Graphs.enablePanAndZoom && positionWithinGraphArea(event->pos())) { + selectedMarker = markerAtPosition(position, true); + if(!selectedMarker && pref.Graphs.enablePanAndZoom && positionWithinGraphArea(position)) { // no marker at the position, enter trace moving mode movingGraph = true; - lastMousePoint = event->pos(); + lastMousePoint = position; cursorLabel->hide(); } } else { @@ -374,8 +375,8 @@ void TracePlot::mouseMoveEvent(QMouseEvent *event) selectedMarker->setPosition(nearestTracePoint(trace, clickPoint)); cursorLabel->hide(); } else if(movingGraph) { - move(event->pos() - lastMousePoint); - lastMousePoint = event->pos(); + move(clickPoint - lastMousePoint); + lastMousePoint = clickPoint; } else { auto text = mouseText(clickPoint); if(!text.isEmpty()) { diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/tracepolar.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/tracepolar.cpp index 05a49b7..d5c7487 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/tracepolar.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/tracepolar.cpp @@ -118,7 +118,12 @@ void TracePolar::setAuto(bool horizontally, bool vertically) bool TracePolar::positionWithinGraphArea(const QPoint &p) { // TODO - return true; + auto coord = pixelToData(p); + if(abs(coord) <= edgeReflection) { + return true; + } else { + return false; + } } QPoint TracePolar::dataToPixel(std::complex d) diff --git a/Software/PC_Application/LibreVNA-GUI/appwindow.cpp b/Software/PC_Application/LibreVNA-GUI/appwindow.cpp index d8683a5..9170e88 100644 --- a/Software/PC_Application/LibreVNA-GUI/appwindow.cpp +++ b/Software/PC_Application/LibreVNA-GUI/appwindow.cpp @@ -345,8 +345,6 @@ bool AppWindow::ConnectToDevice(QString serial) } ui->actionPreset->setEnabled(true); - UpdateAcquisitionFrequencies(); - for(auto d : deviceActionGroup->actions()) { if(d->text() == vdevice->serial()) { d->blockSignals(true); @@ -359,6 +357,9 @@ bool AppWindow::ConnectToDevice(QString serial) connect(vdevice, &VirtualDevice::InfoUpdated, m, &Mode::deviceInfoUpdated); } + vdevice->initialize(); + + UpdateAcquisitionFrequencies(); if (modeHandler->getActiveMode()) { modeHandler->getActiveMode()->initializeDevice(); } @@ -1276,18 +1277,11 @@ void AppWindow::UpdateStatusBar(DeviceStatusBar status) case DeviceStatusBar::Connected: lConnectionStatus.setText("Connected to " + vdevice->serial()); qInfo() << "Connected to" << vdevice->serial(); -// lDeviceInfo.setText(vdevice->getLastDeviceInfoString()); break; case DeviceStatusBar::Disconnected: lConnectionStatus.setText("No device connected"); lDeviceInfo.setText("No device information available yet"); break; - case DeviceStatusBar::Updated: -// lDeviceInfo.setText(vdevice->getLastDeviceInfoString()); -// lADCOverload.setVisible(vdevice->StatusV1().ADC_overload); -// lUnlevel.setVisible(vdevice->StatusV1().unlevel); -// lUnlock.setVisible(!vdevice->StatusV1().LO1_locked || !vdevice->StatusV1().source_locked); - break; default: // invalid status break; diff --git a/Software/PC_Application/LibreVNA-GUI/appwindow.h b/Software/PC_Application/LibreVNA-GUI/appwindow.h index f3d03ed..65ac1dc 100644 --- a/Software/PC_Application/LibreVNA-GUI/appwindow.h +++ b/Software/PC_Application/LibreVNA-GUI/appwindow.h @@ -79,7 +79,6 @@ private: enum class DeviceStatusBar { Connected, - Updated, Disconnected, };