From 758a502f274b7ecaa4d2c48ef46e2d4c863740b0 Mon Sep 17 00:00:00 2001 From: andresmmera Date: Wed, 18 Sep 2024 06:15:30 +0200 Subject: [PATCH] Lock feature A toogle button was added to lock the axes. Sometimes it's annoying to have the axes changing the settings constantly when managing traces --- qucs-s-spar-viewer/qucs-s-spar-viewer.cpp | 41 ++++++++++++++++++++++- qucs-s-spar-viewer/qucs-s-spar-viewer.h | 3 ++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/qucs-s-spar-viewer/qucs-s-spar-viewer.cpp b/qucs-s-spar-viewer/qucs-s-spar-viewer.cpp index d9b0d692..bc213fcd 100644 --- a/qucs-s-spar-viewer/qucs-s-spar-viewer.cpp +++ b/qucs-s-spar-viewer/qucs-s-spar-viewer.cpp @@ -230,7 +230,7 @@ Qucs_S_SPAR_Viewer::Qucs_S_SPAR_Viewer() QComboBox_y_axis_div = new QComboBox(); available_y_axis_div.clear(); available_y_axis_div << 50 << 25 << 20 << 10 << 5 << 2 << 1 << 0.5 << 0.2 << 0.1; - for (const double &value : available_y_axis_div) { + for (const double &value : qAsConst(available_y_axis_div)) { QComboBox_y_axis_div->addItem(QString::number(value)); } connect(QComboBox_y_axis_div, SIGNAL(currentIndexChanged(int)), SLOT(updatePlot())); @@ -266,6 +266,14 @@ Qucs_S_SPAR_Viewer::Qucs_S_SPAR_Viewer() QSpinBox_y2_axis_div->hide(); // QCombobox_y2_axis_units->hide(); + // Lock axis settings button + Lock_axis_settings_Button = new QPushButton("Lock Axes"); + Lock_axis_settings_Button->setCheckable(true); + connect(Lock_axis_settings_Button, SIGNAL(clicked(bool)), SLOT(lock_unlock_axis_settings())); + lock_axis = false; + + SettingsGrid->addWidget(Lock_axis_settings_Button, 0, 4); + QWidget * TracesGroup = new QWidget(); QVBoxLayout *Traces_VBox = new QVBoxLayout(TracesGroup); @@ -1322,9 +1330,11 @@ void Qucs_S_SPAR_Viewer::changeTraceWidth() void Qucs_S_SPAR_Viewer::updatePlot() { + if (lock_axis == false){ // Update axes update_X_axis(); update_Y_axis(); + } // Trim the traces according to the new settings updateTraces(); @@ -2170,3 +2180,32 @@ void Qucs_S_SPAR_Viewer::dropEvent(QDropEvent *event) addFiles(fileList); } } + + +void Qucs_S_SPAR_Viewer::lock_unlock_axis_settings() +{ + if (lock_axis == true){ + lock_axis = false; + Lock_axis_settings_Button->setText("Lock Axes"); + //Frozen axes inputs + QSpinBox_x_axis_min->setEnabled(true); + QSpinBox_x_axis_max->setEnabled(true); + QComboBox_x_axis_div->setEnabled(true); + QCombobox_x_axis_units->setEnabled(true); + QSpinBox_y_axis_min->setEnabled(true); + QSpinBox_y_axis_max->setEnabled(true); + QComboBox_y_axis_div->setEnabled(true); + } + else{ + lock_axis = true; + Lock_axis_settings_Button->setText("Unlock Axes"); + //Unfrozen axes inputs + QSpinBox_x_axis_min->setDisabled(true); + QSpinBox_x_axis_max->setDisabled(true); + QComboBox_x_axis_div->setDisabled(true); + QCombobox_x_axis_units->setDisabled(true); + QSpinBox_y_axis_min->setDisabled(true); + QSpinBox_y_axis_max->setDisabled(true); + QComboBox_y_axis_div->setDisabled(true); + } +} diff --git a/qucs-s-spar-viewer/qucs-s-spar-viewer.h b/qucs-s-spar-viewer/qucs-s-spar-viewer.h index fbd22e24..67867664 100644 --- a/qucs-s-spar-viewer/qucs-s-spar-viewer.h +++ b/qucs-s-spar-viewer/qucs-s-spar-viewer.h @@ -73,6 +73,7 @@ class Qucs_S_SPAR_Viewer : public QMainWindow void update_X_axis(); void update_Y_axis(); + void lock_unlock_axis_settings(); void addMarker(); void removeMarker(); @@ -120,6 +121,8 @@ class Qucs_S_SPAR_Viewer : public QMainWindow QList available_y_axis_div; QComboBox *QComboBox_y_axis_div; QDoubleSpinBox *QSpinBox_y2_axis_min, *QSpinBox_y2_axis_max, *QSpinBox_y2_axis_div; + QPushButton *Lock_axis_settings_Button; + bool lock_axis; // Trace management widgets QComboBox *QCombobox_datasets, *QCombobox_traces;