diff --git a/src/oscilloscope.cpp b/src/oscilloscope.cpp index 8b6c53b1cc..9a62068316 100644 --- a/src/oscilloscope.cpp +++ b/src/oscilloscope.cpp @@ -111,7 +111,9 @@ Oscilloscope::Oscilloscope(struct iio_context *ctx, Filter *filt, d_displayOneBuffer(true), nb_ref_channels(0), lastFunctionValid(false), - import_error("") + import_error(""), + hCursorsEnabled(true), + vCursorsEnabled(true) { ui->setupUi(this); int triggers_panel = ui->stackedWidget->insertWidget(-1, &trigger_settings); @@ -1127,7 +1129,15 @@ void Oscilloscope::cursor_panel_init() { cr_ui = new Ui::CursorsSettings; cr_ui->setupUi(ui->cursorsSettings); + setDynamicProperty(cr_ui->btnLockHorizontal, "use_icon", true); + setDynamicProperty(cr_ui->btnLockVertical, "use_icon", true); //cr_ui->posSelect->setStyleSheet("background-color:red;"); + + connect(cr_ui->btnLockHorizontal, &QPushButton::toggled, + &plot, &CapturePlot::setHorizCursorsLocked); + connect(cr_ui->btnLockVertical, &QPushButton::toggled, + &plot, &CapturePlot::setVertCursorsLocked); + cursorsPositionButton = new CustomPlotPositionButton(cr_ui->posSelect); connect(cr_ui->hCursorsEnable, SIGNAL(toggled(bool)), @@ -1141,6 +1151,8 @@ void Oscilloscope::cursor_panel_init() connect(cr_ui->vCursorsEnable, SIGNAL(toggled(bool)), cursor_readouts_ui->VoltageCursors, SLOT(setVisible(bool))); + connect(cr_ui->btnNormalTrack, &QPushButton::toggled, + this, &Oscilloscope::toggleCursorsMode); cr_ui->horizontalSlider->setMaximum(100); cr_ui->horizontalSlider->setMinimum(0); @@ -1157,6 +1169,29 @@ void Oscilloscope::cursor_panel_init() }); } +void Oscilloscope::toggleCursorsMode(bool toggled) +{ + cr_ui->hCursorsEnable->setEnabled(toggled); + cr_ui->vCursorsEnable->setEnabled(toggled); + + if (toggled) { + plot.setVertCursorsEnabled(hCursorsEnabled); + plot.setHorizCursorsEnabled(vCursorsEnabled); + cursor_readouts_ui->TimeCursors->setVisible(vCursorsEnabled); + cursor_readouts_ui->VoltageCursors->setVisible(hCursorsEnabled); + } else { + hCursorsEnabled = cr_ui->hCursorsEnable->isChecked(); + vCursorsEnabled = cr_ui->vCursorsEnable->isChecked(); + plot.setVertCursorsEnabled(true); + plot.setHorizCursorsEnabled(true); + cursor_readouts_ui->TimeCursors->setVisible(true); + cursor_readouts_ui->VoltageCursors->setVisible(true); + } + + cr_ui->btnLockVertical->setEnabled(toggled); + plot.trackModeEnabled(toggled); +} + void Oscilloscope::pause(bool paused) { if (ui->pushButtonRunStop->isChecked()){ @@ -1853,6 +1888,7 @@ void Oscilloscope::toggle_blockchain_flow(bool en) void Oscilloscope::runStopToggled(bool checked) { + QPushButton *btn = static_cast(QObject::sender()); setDynamicProperty(btn, "running", checked); @@ -3683,6 +3719,8 @@ void Oscilloscope::singleCaptureDone() } periodicFlowRestart(); + plot.repositionCursors(); + if(autosetRequested) { bool found = autosetFindFrequency(); diff --git a/src/oscilloscope.hpp b/src/oscilloscope.hpp index 3ebe15c3b8..704be40e5c 100644 --- a/src/oscilloscope.hpp +++ b/src/oscilloscope.hpp @@ -209,6 +209,7 @@ namespace adiscope { void resetStreamingFlag(bool); void onFilledScreen(bool, unsigned int); + void toggleCursorsMode(bool toggled); public Q_SLOTS: void requestAutoset(); void enableLabels(bool); @@ -308,6 +309,9 @@ namespace adiscope { QList high_gain_modes; std::vector channel_offset; + bool hCursorsEnabled; + bool vCursorsEnabled; + std::vector chnAcCoupled; bool triggerAcCoupled; std::vector filterBlocks; diff --git a/ui/cursors_settings.ui b/ui/cursors_settings.ui index 993179df10..c40b9e92aa 100644 --- a/ui/cursors_settings.ui +++ b/ui/cursors_settings.ui @@ -6,8 +6,8 @@ 0 0 - 361 - 508 + 278 + 537 @@ -86,56 +86,142 @@ - + + + 0 + QLayout::SetDefaultConstraint - - 0 - - - - - - 0 - 1 - + + + + Qt::Vertical - + + QSizePolicy::Fixed + + - 16777215 - 1 + 10 + 25 - - border: 1px solid rgba(255, 255, 255, 70); - - - Qt::Horizontal - - + - - - - - 0 - 0 - - - - QLabel { - font-size: 12px; - color: rgba(255, 255, 255, 70); - } - - - HORIZONTAL - - + + + + 0 + + + + + true + + + + 0 + 0 + + + + + 238 + 30 + + + + QPushButton { +min-height: 30px; +max-height: 30px; +min-width: 238px; +max-width: 238px; +background-color: black; +border-radius: 4px; +} + +QPushButton:disabled { +background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.501, y2:0, stop:0 #727273, stop:1 #141416); +} + +QWidget#handle { +min-height: 30px; +max-height: 30px; +min-width: 119px; +max-width: 119px; +background-color: #4a64ff; +border-radius: 2px; +} + +QWidget#handle:disabled { +background-color: #aaaaaa; +} + +QLabel { +margin-top: 6px; +background-color: transparent; +line-height: 19px; +} + +QLabel#on { +margin-top: 0px; +min-height:30px; +max-height:30px; +min-width:119px; +max-width:119px; +qproperty-alignment: AlignCenter AlignCenter; +margin-left: 0px; +color: white; +} + +QLabel#on:disabled { +color: rgba(255,255,255,102); +} + +QLabel#off { +margin-top: 0px; +min-height:30px; +max-height:30px; +min-width:119px; +max-width:119px; +margin-left: 119px; +color: white; +qproperty-alignment: AlignCenter AlignCenter; +} + +QLabel#off:disabled { +color: rgba(255,255,255,51); +} + + + + + + + true + + + true + + + false + + + Normal + + + Track + + + 0 + + + + - - + + Qt::Vertical @@ -144,14 +230,62 @@ - 0 + 20 15 - - + + + + 10 + + + + + + 0 + 0 + + + + QLabel { + font-size: 12px; + color: rgba(255, 255, 255, 70); + } + + + HORIZONTAL + + + + + + + + 0 + 1 + + + + + 16777215 + 1 + + + + border: 1px solid rgba(255, 255, 255, 70); + + + Qt::Horizontal + + + + + + + Qt::Vertical @@ -161,7 +295,7 @@ 0 - 25 + 15 @@ -169,32 +303,52 @@ - - - 15 + + + 6 - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - true - - - true - - + + + + 0 + + + + + true + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QPushButton[use_icon=true] + + + + + + true + + + + @@ -203,28 +357,6 @@ 0 - - - - - 0 - 1 - - - - - 16777215 - 1 - - - - border: 1px solid rgba(255, 255, 255, 70); - - - Qt::Horizontal - - - @@ -276,38 +408,77 @@ - - - - - - 6 - - - 15 - - - - - true + + + + + 0 + 1 + + + + + 16777215 + 1 + - - true + + border: 1px solid rgba(255, 255, 255, 70); - - - - Qt::Horizontal - - - 40 - 20 - - - + + + + + + + + 10 + + + + + 0 + + + + + true + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QPushButton[use_icon=true] + + + + + + true + + + + @@ -535,19 +706,6 @@ QSlider::sub-page:horizontal { - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -572,6 +730,11 @@ QSlider::sub-page:horizontal { + + adiscope::SmallOnOffSwitch + QPushButton +
smallOnOffSwitch.hpp
+
adiscope::CustomSwitch QPushButton