mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
FIX: 'data plot window' - keypress G in an empty plot crashed the client. Missing parenthis.
This commit is contained in:
parent
802994d30a
commit
5de4d9d3a6
1 changed files with 66 additions and 52 deletions
|
@ -241,7 +241,7 @@ int Plot::xCoordOf(int i, QRect r ) {
|
|||
|
||||
int Plot::yCoordOf(int v, QRect r, int maxVal) {
|
||||
int z = (r.bottom() - r.top())/2;
|
||||
return -(z * v) / maxVal + z;
|
||||
return -(z * v) / (maxVal + z);
|
||||
}
|
||||
|
||||
int Plot::valueOf_yCoord(int y, QRect r, int maxVal) {
|
||||
|
@ -419,8 +419,10 @@ void Plot::PlotGraph(int *buffer, int len, QRect plotRect, QRect annotationRect,
|
|||
}
|
||||
|
||||
void Plot::plotGridLines(QPainter* painter, QRect r) {
|
||||
|
||||
// set GridOffset
|
||||
if (PlotGridX <= 0) return;
|
||||
|
||||
int offset = GridOffset;
|
||||
if (GridLocked && PlotGridX) {
|
||||
offset = GridOffset + PlotGridX - (GraphStart % PlotGridX);
|
||||
|
@ -433,15 +435,19 @@ void Plot::plotGridLines(QPainter* painter,QRect r) {
|
|||
int i;
|
||||
int grid_delta_x = (int) (PlotGridX * GraphPixelsPerPoint);
|
||||
int grid_delta_y = PlotGridY;
|
||||
|
||||
if ((PlotGridX > 0) && ((PlotGridX * GraphPixelsPerPoint) > 1)) {
|
||||
for (i = (offset * GraphPixelsPerPoint); i < r.right(); i += grid_delta_x) {
|
||||
painter->drawLine(r.left()+i, r.top(), r.left()+i, r.bottom());
|
||||
}
|
||||
}
|
||||
|
||||
if (PlotGridY > 0) {
|
||||
for (i = 0; yCoordOf(i, r, g_absVMax) > r.top(); i += grid_delta_y) {
|
||||
// line above mid
|
||||
painter->drawLine( r.left(), yCoordOf(i, r, g_absVMax), r.right(), yCoordOf(i, r, g_absVMax) );
|
||||
painter->drawLine( r.left(), yCoordOf(i*-1,r,g_absVMax), r.right(), yCoordOf(i*-1,r,g_absVMax) );
|
||||
// line below mid
|
||||
painter->drawLine( r.left(), yCoordOf(-i, r, g_absVMax), r.right(), yCoordOf(-i, r, g_absVMax) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -583,11 +589,12 @@ void Plot::keyPressEvent(QKeyEvent *event)
|
|||
offset = PageWidth - (PageWidth % PlotGridX);
|
||||
else
|
||||
offset = PageWidth;
|
||||
} else
|
||||
} else {
|
||||
if (event->modifiers() & Qt::ControlModifier)
|
||||
offset = 1;
|
||||
else
|
||||
offset = (int)(20 / GraphPixelsPerPoint);
|
||||
}
|
||||
|
||||
switch(event->key()) {
|
||||
case Qt::Key_Down:
|
||||
|
@ -623,30 +630,37 @@ void Plot::keyPressEvent(QKeyEvent *event)
|
|||
PlotGridX = 0;
|
||||
PlotGridY = 0;
|
||||
} else {
|
||||
if ( PlotGridXdefault < 0 )
|
||||
PlotGridXdefault = 64;
|
||||
if ( PlotGridYdefault < 0 )
|
||||
PlotGridYdefault = 0;
|
||||
|
||||
PlotGridX = PlotGridXdefault;
|
||||
PlotGridY = PlotGridYdefault;
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::Key_H:
|
||||
puts("Plot Window Keystrokes:\n");
|
||||
puts(" Key Action\n");
|
||||
puts(" DOWN Zoom in");
|
||||
puts(" G Toggle grid display");
|
||||
puts(" H Show help");
|
||||
puts(" L Toggle lock grid relative to samples");
|
||||
puts(" LEFT Move left");
|
||||
puts(" <CTL>LEFT Move left 1 sample");
|
||||
puts(" <SHIFT>LEFT Page left");
|
||||
puts(" LEFT-MOUSE-CLICK Set yellow cursor");
|
||||
puts(" Q Hide window");
|
||||
puts(" RIGHT Move right");
|
||||
puts(" <CTL>RIGHT Move right 1 sample");
|
||||
puts(" <SHIFT>RIGHT Page right");
|
||||
puts(" RIGHT-MOUSE-CLICK Set purple cursor");
|
||||
puts(" UP Zoom out");
|
||||
puts("");
|
||||
puts("Use client window 'data help' for more plot commands\n");
|
||||
|
||||
puts("\n-----------------------------------------------------------------------");
|
||||
puts("PLOT window keystrokes");
|
||||
puts("\tKey Action");
|
||||
puts("-----------------------------------------------------------------------");
|
||||
puts("\tUP Zoom out");
|
||||
puts("\tDOWN Zoom in");
|
||||
puts("\tG Toggle grid display");
|
||||
puts("\tH Show help");
|
||||
puts("\tL Toggle lock grid relative to samples");
|
||||
puts("\tQ Hide window");
|
||||
puts("\tLEFT Move left");
|
||||
puts("\t<CTLR> LEFT Move left 1 sample");
|
||||
puts("\t<SHIFT> LEFT Page left");
|
||||
puts("\tLEFT MOUSE CLICK Set yellow cursor");
|
||||
puts("\tRIGHT Move right");
|
||||
puts("\t<CTLR> RIGHT Move right 1 sample");
|
||||
puts("\t<SHIFT> RIGHT Page right");
|
||||
puts("\tRIGHT MOUSE CLICK Set purple cursor");
|
||||
puts("-----------------------------------------------------------------------");
|
||||
break;
|
||||
|
||||
case Qt::Key_L:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue