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,15 +647,18 @@ void Plot::closeEvent(QCloseEvent *event) {
|
|||
g_useOverlays = false;
|
||||
}
|
||||
|
||||
void Plot::Zoom(double factor, int refX) {
|
||||
void Plot::Zoom(double factor, uint32_t refX) {
|
||||
if (factor >= 1) { // Zoom in
|
||||
if (GraphPixelsPerPoint <= 25 * factor) {
|
||||
GraphPixelsPerPoint *= factor;
|
||||
if (refX > GraphStart) {
|
||||
GraphStart += (refX - GraphStart) - ((refX - GraphStart) / factor);
|
||||
}
|
||||
}
|
||||
} else { // Zoom out
|
||||
if (GraphPixelsPerPoint >= 0.01 / factor) {
|
||||
GraphPixelsPerPoint *= factor;
|
||||
if (refX > GraphStart) {
|
||||
if (GraphStart >= ((refX - GraphStart) / factor) - (refX - GraphStart)) {
|
||||
GraphStart -= ((refX - GraphStart) / factor) - (refX - GraphStart);
|
||||
} else {
|
||||
|
@ -663,6 +666,7 @@ void Plot::Zoom(double factor, int refX) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Plot::Move(int offset) {
|
||||
|
@ -722,9 +726,9 @@ void Plot::wheelEvent(QWheelEvent *event) {
|
|||
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
|
||||
#if QT_VERSION >= 0x050d00
|
||||
int x = event->position().x();
|
||||
uint32_t x = event->position().x();
|
||||
#else
|
||||
int x = event->x();
|
||||
uint32_t x = event->x();
|
||||
#endif
|
||||
x -= WIDTH_AXES;
|
||||
x = (int)(x / GraphPixelsPerPoint);
|
||||
|
@ -765,6 +769,7 @@ void Plot::mouseMoveEvent(QMouseEvent *event) {
|
|||
|
||||
void Plot::keyPressEvent(QKeyEvent *event) {
|
||||
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 (PlotGridX)
|
||||
|
@ -781,18 +786,34 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
|||
switch (event->key()) {
|
||||
case Qt::Key_Down:
|
||||
if (event->modifiers() & Qt::ShiftModifier) {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
Zoom(zoom_offset, CursorBPos);
|
||||
} else {
|
||||
Zoom(2, CursorBPos);
|
||||
}
|
||||
} else {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
Zoom(zoom_offset, CursorAPos);
|
||||
} else {
|
||||
Zoom(2, CursorAPos);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::Key_Up:
|
||||
if (event->modifiers() & Qt::ShiftModifier) {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
Zoom(1.0/zoom_offset, CursorBPos);
|
||||
} else {
|
||||
Zoom(0.5, CursorBPos);
|
||||
}
|
||||
} else {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
Zoom(1.0/zoom_offset, CursorAPos);
|
||||
} else {
|
||||
Zoom(0.5, CursorAPos);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::Key_Right:
|
||||
|
|
|
@ -51,7 +51,7 @@ class Plot: public QWidget {
|
|||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void Zoom(double factor, int refX);
|
||||
void Zoom(double factor, uint32_t refX);
|
||||
void Move(int offset);
|
||||
void Trim(void);
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue