Skip to content

Commit

Permalink
Osc: add controls in the cursors panel for locking/unlocking cursors …
Browse files Browse the repository at this point in the history
…and track mode

Signed-off-by: Daniel Guramulta <[email protected]>
  • Loading branch information
DanielGuramulta authored and adisuciu committed Jul 9, 2018
1 parent f575c53 commit a31997c
Show file tree
Hide file tree
Showing 3 changed files with 340 additions and 135 deletions.
40 changes: 39 additions & 1 deletion src/oscilloscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)),
Expand All @@ -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);
Expand All @@ -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()){
Expand Down Expand Up @@ -1853,6 +1888,7 @@ void Oscilloscope::toggle_blockchain_flow(bool en)

void Oscilloscope::runStopToggled(bool checked)
{

QPushButton *btn = static_cast<QPushButton *>(QObject::sender());
setDynamicProperty(btn, "running", checked);

Expand Down Expand Up @@ -3683,6 +3719,8 @@ void Oscilloscope::singleCaptureDone()
}

periodicFlowRestart();
plot.repositionCursors();

if(autosetRequested)
{
bool found = autosetFindFrequency();
Expand Down
4 changes: 4 additions & 0 deletions src/oscilloscope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -308,6 +309,9 @@ namespace adiscope {
QList<bool> high_gain_modes;
std::vector<double> channel_offset;

bool hCursorsEnabled;
bool vCursorsEnabled;

std::vector<bool> chnAcCoupled;
bool triggerAcCoupled;
std::vector<gr::basic_block_sptr> filterBlocks;
Expand Down
Loading

0 comments on commit a31997c

Please sign in to comment.