Skip to content

Commit 873d5f9

Browse files
committed
fix: maintain cross cursor throughout data cursor mode
1 parent 47cc04f commit 873d5f9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

octproz_project/octproz/src/plotwindow1d.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ void PlotWindow1D::setSettings(QVariantMap settings) {
127127
this->panel->spinBoxLine->setValue(this->line);
128128

129129
this->dataCursorEnabled = settings.value(PLOT1D_DATA_CURSOR, false).toBool();
130+
this->plotArea->setDataCursorMode(this->dataCursorEnabled);
130131
if (this->dataCursorEnabled) {
131132
this->plotArea->setCursor(Qt::CrossCursor);
132133
} else {
@@ -492,6 +493,7 @@ void PlotWindow1D::enableBitshift(bool enable) {
492493

493494
void PlotWindow1D::toggleDualCoordinates(bool enabled) {
494495
this->dataCursorEnabled = enabled;
496+
this->plotArea->setDataCursorMode(enabled);
495497
if (enabled){
496498
this->plotArea->setCursor(Qt::CrossCursor);
497499
} else {
@@ -669,7 +671,8 @@ void StatsLabel::enterEvent(QEvent *event) {
669671
// ---------------------- PlotArea1D Implementation ----------------------
670672
PlotArea1D::PlotArea1D(QWidget *parent) : QCustomPlot(parent),
671673
draggingLegend(false),
672-
showInfoInLegend(false)
674+
showInfoInLegend(false),
675+
dataCursorEnabled(false)
673676
{
674677
this->rawLineName = tr("Raw Line");
675678
this->processedLineName = tr("A-scan");
@@ -953,6 +956,8 @@ void PlotArea1D::mouseMoveEvent(QMouseEvent* event) {
953956
// Cursor handling
954957
if (this->legend->selectTest(event->pos(), false) > 0) {
955958
this->setCursor(Qt::OpenHandCursor);
959+
} else if (this->dataCursorEnabled) {
960+
this->setCursor(Qt::CrossCursor);
956961
} else {
957962
this->unsetCursor();
958963
}
@@ -968,6 +973,8 @@ void PlotArea1D::mouseReleaseEvent(QMouseEvent *event) {
968973
// Restore cursor
969974
if (this->legend->selectTest(event->pos(), false) > 0) {
970975
this->setCursor(Qt::OpenHandCursor);
976+
} else if (this->dataCursorEnabled) {
977+
this->setCursor(Qt::CrossCursor);
971978
} else {
972979
this->unsetCursor();
973980
}

octproz_project/octproz/src/plotwindow1d.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ class PlotArea1D : public QCustomPlot
216216
void updateInfoInRawLegend(int lineNr, int bufferNr);
217217
void updateInfoInProcessedLegend(int lineNr, int bufferNr);
218218

219+
void setDataCursorMode(bool enabled) {this->dataCursorEnabled = enabled; }
220+
219221

220222
protected:
221223
void mousePressEvent(QMouseEvent *event) override;
@@ -234,6 +236,7 @@ class PlotArea1D : public QCustomPlot
234236
QPointF dragLegendOrigin;
235237

236238
bool showInfoInLegend;
239+
bool dataCursorEnabled;
237240

238241
public slots:
239242
void zoomSelectedAxisWithMouseWheel();

0 commit comments

Comments
 (0)