]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - client/proxguiqt.cpp
Oops. Fix grid lock when zoomed in or out.
[proxmark3-svn] / client / proxguiqt.cpp
index f687bdf4a8b641793b6ef2ac99791edcdc287694..4e57fecc7ff8754cb46f30f84d64b2decc6daee3 100644 (file)
@@ -1,4 +1,6 @@
 //-----------------------------------------------------------------------------
+// Copyright (C) 2009 Michael Gernoth <michael at gernoth.net>
+//
 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
 // at your option, any later version. See the LICENSE.txt file for the text of
 // the license.
 #include "proxguiqt.h"
 #include "proxgui.h"
 
+int GridOffset= 0;
+bool GridLocked= 0;
+int startMax;
+
 void ProxGuiQT::ShowGraphWindow(void)
 {
        emit ShowGraphWindowSignal();
@@ -128,7 +134,7 @@ void ProxWidget::paintEvent(QPaintEvent *event)
         // plot X and Y grid lines
         int i;
         if ((PlotGridX > 0) && ((PlotGridX * GraphPixelsPerPoint) > 1)) {
-               for(i = 40; i < r.right(); i += (int)(PlotGridX * GraphPixelsPerPoint)) {
+               for(i = 40 + (GridOffset * GraphPixelsPerPoint); i < r.right(); i += (int)(PlotGridX * GraphPixelsPerPoint)) {
                        //SelectObject(hdc, GreyPenLite);
                        //MoveToEx(hdc, r.left + i, r.top, NULL);
                        //LineTo(hdc, r.left + i, r.bottom);
@@ -148,8 +154,7 @@ void ProxWidget::paintEvent(QPaintEvent *event)
                        }
                }
        
-       int startMax =
-               (GraphTraceLen - (int)((r.right() - r.left() - 40) / GraphPixelsPerPoint));
+       startMax = (GraphTraceLen - (int)((r.right() - r.left() - 40) / GraphPixelsPerPoint));
        if(startMax < 0) {
                startMax = 0;
        }
@@ -261,7 +266,7 @@ void ProxWidget::paintEvent(QPaintEvent *event)
        painter.setPen(QColor(255, 0, 255));
        painter.drawPath(cursorBPath);
 
-       char str[100];
+       char str[200];
        sprintf(str, "@%d   max=%d min=%d mean=%d n=%d/%d    dt=%d [%.3f] zoom=%.3f CursorA=%d [%d] CursorB=%d [%d]",
                        GraphStart, yMax, yMin, yMean, n, GraphTraceLen,
                        CursorBPos - CursorAPos, (CursorBPos - CursorAPos)/CursorScaleFactor,GraphPixelsPerPoint,CursorAPos,GraphBuffer[CursorAPos],CursorBPos,GraphBuffer[CursorBPos]);
@@ -321,18 +326,65 @@ void ProxWidget::keyPressEvent(QKeyEvent *event)
 
                case Qt::Key_Right:
                        if(GraphPixelsPerPoint < 20) {
+                               if (GridLocked && GraphStart < startMax)
+                                       GridOffset -= (int)(20 / GraphPixelsPerPoint);
                                GraphStart += (int)(20 / GraphPixelsPerPoint);
                        } else {
+                               if (GridLocked && GraphStart < startMax)
+                                       GridOffset--;
                                GraphStart++;
                        }
+                       if(GridOffset < 0)
+                               GridOffset += PlotGridX;
+                       if (PlotGridX)
+                               GridOffset %= PlotGridX;
                        break;
 
                case Qt::Key_Left:
                        if(GraphPixelsPerPoint < 20) {
+                               if (GridLocked && GraphStart > 0)
+                                       GridOffset += (int)(20 / GraphPixelsPerPoint);
                                GraphStart -= (int)(20 / GraphPixelsPerPoint);
                        } else {
+                               if (GridLocked && GraphStart > 0)
+                                       GridOffset++;
                                GraphStart--;
                        }
+                       if (PlotGridX)
+                               GridOffset %= PlotGridX;
+                       break;
+
+               case Qt::Key_G:
+                       if(PlotGridX || PlotGridY) {
+                               PlotGridX= 0;
+                               PlotGridY= 0;
+                       } else {
+                               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(" LEFT          Move left");
+                       puts(" L             Toggle lock grid relative to samples");
+                       puts(" Q             Hide window");
+                       puts(" RIGHT         Move right");
+                       puts(" UP            Zoom out");
+                       puts("");
+                       puts("Use client window 'data help' for more plot commands\n");
+                       break;
+
+               case Qt::Key_L:
+                       GridLocked= !GridLocked;
+                       break;
+
+               case Qt::Key_Q:
+                       this->hide();
                        break;
 
                default:
Impressum, Datenschutz