mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
zoom: add ctrl for small increments with key, to get same as with wheel
This commit is contained in:
parent
128fdd82e2
commit
1f2133fa17
2 changed files with 34 additions and 13 deletions
|
@ -647,19 +647,23 @@ void Plot::closeEvent(QCloseEvent *event) {
|
||||||
g_useOverlays = false;
|
g_useOverlays = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plot::Zoom(double factor, int refX) {
|
void Plot::Zoom(double factor, uint32_t refX) {
|
||||||
if (factor >= 1) { // Zoom in
|
if (factor >= 1) { // Zoom in
|
||||||
if (GraphPixelsPerPoint <= 25 * factor) {
|
if (GraphPixelsPerPoint <= 25 * factor) {
|
||||||
GraphPixelsPerPoint *= factor;
|
GraphPixelsPerPoint *= factor;
|
||||||
GraphStart += (refX - GraphStart) - ((refX - GraphStart) / factor);
|
if (refX > GraphStart) {
|
||||||
|
GraphStart += (refX - GraphStart) - ((refX - GraphStart) / factor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else { // Zoom out
|
} else { // Zoom out
|
||||||
if (GraphPixelsPerPoint >= 0.01 / factor) {
|
if (GraphPixelsPerPoint >= 0.01 / factor) {
|
||||||
GraphPixelsPerPoint *= factor;
|
GraphPixelsPerPoint *= factor;
|
||||||
if (GraphStart >= ((refX - GraphStart) / factor) - (refX - GraphStart)) {
|
if (refX > GraphStart) {
|
||||||
GraphStart -= ((refX - GraphStart) / factor) - (refX - GraphStart);
|
if (GraphStart >= ((refX - GraphStart) / factor) - (refX - GraphStart)) {
|
||||||
} else {
|
GraphStart -= ((refX - GraphStart) / factor) - (refX - GraphStart);
|
||||||
GraphStart = 0;
|
} else {
|
||||||
|
GraphStart = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -722,9 +726,9 @@ void Plot::wheelEvent(QWheelEvent *event) {
|
||||||
if (event->modifiers() & Qt::ShiftModifier) {
|
if (event->modifiers() & Qt::ShiftModifier) {
|
||||||
// event->position doesn't exist in QT5.12.8, both exist in 5.14.2 and event->x doesn't exist in 5.15.0
|
// event->position doesn't exist in QT5.12.8, both exist in 5.14.2 and event->x doesn't exist in 5.15.0
|
||||||
#if QT_VERSION >= 0x050d00
|
#if QT_VERSION >= 0x050d00
|
||||||
int x = event->position().x();
|
uint32_t x = event->position().x();
|
||||||
#else
|
#else
|
||||||
int x = event->x();
|
uint32_t x = event->x();
|
||||||
#endif
|
#endif
|
||||||
x -= WIDTH_AXES;
|
x -= WIDTH_AXES;
|
||||||
x = (int)(x / GraphPixelsPerPoint);
|
x = (int)(x / GraphPixelsPerPoint);
|
||||||
|
@ -765,6 +769,7 @@ void Plot::mouseMoveEvent(QMouseEvent *event) {
|
||||||
|
|
||||||
void Plot::keyPressEvent(QKeyEvent *event) {
|
void Plot::keyPressEvent(QKeyEvent *event) {
|
||||||
uint32_t offset; // Left/right movement offset (in sample size)
|
uint32_t offset; // Left/right movement offset (in sample size)
|
||||||
|
const double zoom_offset = 1.148698354997035; // 2**(1/5)
|
||||||
|
|
||||||
if (event->modifiers() & Qt::ShiftModifier) {
|
if (event->modifiers() & Qt::ShiftModifier) {
|
||||||
if (PlotGridX)
|
if (PlotGridX)
|
||||||
|
@ -781,17 +786,33 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||||
switch (event->key()) {
|
switch (event->key()) {
|
||||||
case Qt::Key_Down:
|
case Qt::Key_Down:
|
||||||
if (event->modifiers() & Qt::ShiftModifier) {
|
if (event->modifiers() & Qt::ShiftModifier) {
|
||||||
Zoom(2, CursorBPos);
|
if (event->modifiers() & Qt::ControlModifier) {
|
||||||
|
Zoom(zoom_offset, CursorBPos);
|
||||||
|
} else {
|
||||||
|
Zoom(2, CursorBPos);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Zoom(2, CursorAPos);
|
if (event->modifiers() & Qt::ControlModifier) {
|
||||||
|
Zoom(zoom_offset, CursorAPos);
|
||||||
|
} else {
|
||||||
|
Zoom(2, CursorAPos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Up:
|
case Qt::Key_Up:
|
||||||
if (event->modifiers() & Qt::ShiftModifier) {
|
if (event->modifiers() & Qt::ShiftModifier) {
|
||||||
Zoom(0.5, CursorBPos);
|
if (event->modifiers() & Qt::ControlModifier) {
|
||||||
|
Zoom(1.0/zoom_offset, CursorBPos);
|
||||||
|
} else {
|
||||||
|
Zoom(0.5, CursorBPos);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Zoom(0.5, CursorAPos);
|
if (event->modifiers() & Qt::ControlModifier) {
|
||||||
|
Zoom(1.0/zoom_offset, CursorAPos);
|
||||||
|
} else {
|
||||||
|
Zoom(0.5, CursorAPos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ class Plot: public QWidget {
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
void Zoom(double factor, int refX);
|
void Zoom(double factor, uint32_t refX);
|
||||||
void Move(int offset);
|
void Move(int offset);
|
||||||
void Trim(void);
|
void Trim(void);
|
||||||
void wheelEvent(QWheelEvent *event);
|
void wheelEvent(QWheelEvent *event);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue