mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-20 12:07:05 +08: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 Plot::yCoordOf(int v, QRect r, int maxVal) {
|
||||||
int z = (r.bottom() - r.top())/2;
|
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) {
|
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) {
|
void Plot::plotGridLines(QPainter* painter, QRect r) {
|
||||||
|
|
||||||
// set GridOffset
|
// set GridOffset
|
||||||
if (PlotGridX <= 0) return;
|
if (PlotGridX <= 0) return;
|
||||||
|
|
||||||
int offset = GridOffset;
|
int offset = GridOffset;
|
||||||
if (GridLocked && PlotGridX) {
|
if (GridLocked && PlotGridX) {
|
||||||
offset = GridOffset + PlotGridX - (GraphStart % PlotGridX);
|
offset = GridOffset + PlotGridX - (GraphStart % PlotGridX);
|
||||||
|
@ -433,15 +435,19 @@ void Plot::plotGridLines(QPainter* painter,QRect r) {
|
||||||
int i;
|
int i;
|
||||||
int grid_delta_x = (int) (PlotGridX * GraphPixelsPerPoint);
|
int grid_delta_x = (int) (PlotGridX * GraphPixelsPerPoint);
|
||||||
int grid_delta_y = PlotGridY;
|
int grid_delta_y = PlotGridY;
|
||||||
|
|
||||||
if ((PlotGridX > 0) && ((PlotGridX * GraphPixelsPerPoint) > 1)) {
|
if ((PlotGridX > 0) && ((PlotGridX * GraphPixelsPerPoint) > 1)) {
|
||||||
for (i = (offset * GraphPixelsPerPoint); i < r.right(); i += grid_delta_x) {
|
for (i = (offset * GraphPixelsPerPoint); i < r.right(); i += grid_delta_x) {
|
||||||
painter->drawLine(r.left()+i, r.top(), r.left()+i, r.bottom());
|
painter->drawLine(r.left()+i, r.top(), r.left()+i, r.bottom());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PlotGridY > 0) {
|
if (PlotGridY > 0) {
|
||||||
for (i = 0; yCoordOf(i, r, g_absVMax) > r.top(); i += grid_delta_y) {
|
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, 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);
|
offset = PageWidth - (PageWidth % PlotGridX);
|
||||||
else
|
else
|
||||||
offset = PageWidth;
|
offset = PageWidth;
|
||||||
} else
|
} else {
|
||||||
if (event->modifiers() & Qt::ControlModifier)
|
if (event->modifiers() & Qt::ControlModifier)
|
||||||
offset = 1;
|
offset = 1;
|
||||||
else
|
else
|
||||||
offset = (int)(20 / GraphPixelsPerPoint);
|
offset = (int)(20 / GraphPixelsPerPoint);
|
||||||
|
}
|
||||||
|
|
||||||
switch(event->key()) {
|
switch(event->key()) {
|
||||||
case Qt::Key_Down:
|
case Qt::Key_Down:
|
||||||
|
@ -623,30 +630,37 @@ void Plot::keyPressEvent(QKeyEvent *event)
|
||||||
PlotGridX = 0;
|
PlotGridX = 0;
|
||||||
PlotGridY = 0;
|
PlotGridY = 0;
|
||||||
} else {
|
} else {
|
||||||
|
if ( PlotGridXdefault < 0 )
|
||||||
|
PlotGridXdefault = 64;
|
||||||
|
if ( PlotGridYdefault < 0 )
|
||||||
|
PlotGridYdefault = 0;
|
||||||
|
|
||||||
PlotGridX = PlotGridXdefault;
|
PlotGridX = PlotGridXdefault;
|
||||||
PlotGridY = PlotGridYdefault;
|
PlotGridY = PlotGridYdefault;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_H:
|
case Qt::Key_H:
|
||||||
puts("Plot Window Keystrokes:\n");
|
|
||||||
puts(" Key Action\n");
|
puts("\n-----------------------------------------------------------------------");
|
||||||
puts(" DOWN Zoom in");
|
puts("PLOT window keystrokes");
|
||||||
puts(" G Toggle grid display");
|
puts("\tKey Action");
|
||||||
puts(" H Show help");
|
puts("-----------------------------------------------------------------------");
|
||||||
puts(" L Toggle lock grid relative to samples");
|
puts("\tUP Zoom out");
|
||||||
puts(" LEFT Move left");
|
puts("\tDOWN Zoom in");
|
||||||
puts(" <CTL>LEFT Move left 1 sample");
|
puts("\tG Toggle grid display");
|
||||||
puts(" <SHIFT>LEFT Page left");
|
puts("\tH Show help");
|
||||||
puts(" LEFT-MOUSE-CLICK Set yellow cursor");
|
puts("\tL Toggle lock grid relative to samples");
|
||||||
puts(" Q Hide window");
|
puts("\tQ Hide window");
|
||||||
puts(" RIGHT Move right");
|
puts("\tLEFT Move left");
|
||||||
puts(" <CTL>RIGHT Move right 1 sample");
|
puts("\t<CTLR> LEFT Move left 1 sample");
|
||||||
puts(" <SHIFT>RIGHT Page right");
|
puts("\t<SHIFT> LEFT Page left");
|
||||||
puts(" RIGHT-MOUSE-CLICK Set purple cursor");
|
puts("\tLEFT MOUSE CLICK Set yellow cursor");
|
||||||
puts(" UP Zoom out");
|
puts("\tRIGHT Move right");
|
||||||
puts("");
|
puts("\t<CTLR> RIGHT Move right 1 sample");
|
||||||
puts("Use client window 'data help' for more plot commands\n");
|
puts("\t<SHIFT> RIGHT Page right");
|
||||||
|
puts("\tRIGHT MOUSE CLICK Set purple cursor");
|
||||||
|
puts("-----------------------------------------------------------------------");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_L:
|
case Qt::Key_L:
|
||||||
|
|
Loading…
Add table
Reference in a new issue