]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
make grid function linux friendly
authoradam@algroup.co.uk <adam@algroup.co.uk@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Tue, 21 Jul 2009 16:10:58 +0000 (16:10 +0000)
committeradam@algroup.co.uk <adam@algroup.co.uk@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Tue, 21 Jul 2009 16:10:58 +0000 (16:10 +0000)
linux/gui.c
linux/proxgui.h
linux/proxguiqt.cpp
winsrc/command.cpp
winsrc/gui.cpp
winsrc/prox.h

index e8751a6287977dd784e5e47ed545520836aa055f..d31c5287702de3bbd035a7b92c793f4ede57199f 100644 (file)
@@ -9,6 +9,7 @@
 int GraphBuffer[MAX_GRAPH_TRACE_LEN];
 int GraphTraceLen;
 double CursorScaleFactor;
+int PlotGridX, PlotGridY;
 int CommandFinished;
 int offline;
 
index 786d93615de5c31cef5dfde171354d93f513f012..6989f541807d9299c5873ba540f4d755847f356a 100644 (file)
@@ -13,6 +13,7 @@ void ExitGraphics(void);
 extern int GraphBuffer[MAX_GRAPH_TRACE_LEN];
 extern int GraphTraceLen;
 extern double CursorScaleFactor;
+extern int PlotGridX, PlotGridY;
 extern int CommandFinished;
 extern int offline;
 
index f024529a7d7eebbbbe8ca95d56b98822873179b7..af32809dda9ed9d9d6121d800f12fcbfa732a792 100644 (file)
@@ -86,7 +86,7 @@ ProxGuiQT::~ProxGuiQT(void)
 void ProxWidget::paintEvent(QPaintEvent *event)
 {
        QPainter painter(this);
-       QPainterPath penPath, whitePath, greyPath, cursorAPath, cursorBPath;
+       QPainterPath penPath, whitePath, greyPath, lightgreyPath, cursorAPath, cursorBPath;
        QRect r;
        QBrush brush(QColor(100, 255, 100));
        QPen pen(QColor(100, 255, 100));
@@ -115,6 +115,29 @@ void ProxWidget::paintEvent(QPaintEvent *event)
        greyPath.lineTo(r.right(), zeroHeight);
        painter.setPen(QColor(100, 100, 100));
        painter.drawPath(greyPath);
+
+        // plot X and Y grid lines
+        int i;
+        if ((PlotGridX > 0) && ((PlotGridX * GraphPixelsPerPoint) > 1)) {
+               for(i = GraphStart; 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);
+                       lightgreyPath.moveTo(r.left()+i,r.top());
+                       lightgreyPath.lineTo(r.left()+i,r.bottom());
+                       painter.drawPath(lightgreyPath);
+                } 
+        } 
+        if ((PlotGridY > 0) && ((PlotGridY * GraphPixelsPerPoint) > 1)){
+               for(i = 0; i < ((r.top() + r.bottom())>>1); i += (int)(PlotGridY * GraphPixelsPerPoint)) {
+                               lightgreyPath.moveTo(r.left(),zeroHeight + i);
+                       lightgreyPath.lineTo(r.right(),zeroHeight + i);
+                       painter.drawPath(lightgreyPath);
+                       lightgreyPath.moveTo(r.left(),zeroHeight - i);
+                       lightgreyPath.lineTo(r.right(),zeroHeight - i);
+                       painter.drawPath(lightgreyPath);
+                       }
+               }
        
        int startMax =
                (GraphTraceLen - (int)((r.right() - r.left() - 40) / GraphPixelsPerPoint));
@@ -127,7 +150,6 @@ void ProxWidget::paintEvent(QPaintEvent *event)
 
        int absYMax = 1;
 
-       int i;
        for(i = GraphStart; ; i++) {
                if(i >= GraphTraceLen) {
                        break;
index bc9fb9dca222df981d30648b218adb52e0f9c6ff..b830922bed9111d3587a8a1008870ba94df347c8 100644 (file)
@@ -2590,9 +2590,7 @@ static void CmdPlot(char *str)
 \r
 static void CmdGrid(char *str)\r
 {\r
-       int x = 0, y = 0;\r
-  sscanf(str, "%i %i", &x, &y);\r
-       SetGraphGrid(x, y);\r
+       sscanf(str, "%i %i", &PlotGridX, &PlotGridY);\r
        RepaintGraphWindow();\r
 }\r
 \r
@@ -2734,7 +2732,7 @@ static struct {
        {"flexdemod",                   CmdFlexdemod,                           1, "Demodulate samples for FlexPass"},\r
        {"fpgaoff",                             CmdFPGAOff,                                     0, "Set FPGA off"},\r
        {"fskdemod",                    CmdFSKdemod,                            1, "Demodulate graph window as a HID FSK"},\r
-       {"grid",                                        CmdGrid,                                                1, "grid x y, overlay grid on graph window, use zero value to turn off either"},\r
+       {"grid",                                        CmdGrid,                                                1, "<x> <y> -- overlay grid on graph window, use zero value to turn off either"},\r
        {"hexsamples",          CmdHexsamples,                  0, "<blocks> -- Dump big buffer as hex bytes"},\r
        {"hi14alist",                   CmdHi14alist,                           0, "List ISO 14443a history"},\r
        {"hi14areader",         CmdHi14areader,                 0, "Act like an ISO14443 Type A reader"},\r
index bcc0cbb65958cbda97c9c392e765d92a34adc18c..161f99d621a8dca3e8248b4ecf624f564f779736 100644 (file)
@@ -67,12 +67,6 @@ void ExecCmd(char *cmd)
 int CommandFinished;\r
 int offset = 64;\r
 \r
-void SetGraphGrid(int x, int y)\r
-{\r
-       PlotGridX = x;\r
-       PlotGridY = y;\r
-}\r
-\r
 static void ResizeCommandWindow(void)\r
 {\r
        int w, h;\r
index 53449a1376d3f9fe813262a932e63e192ae0fd83..aeb6dfea3ec5699090d5866a2956608f0d24027a 100644 (file)
@@ -13,12 +13,12 @@ void ShowGui();
 void HideGraphWindow(void);\r
 void ShowGraphWindow(void);\r
 void RepaintGraphWindow(void);\r
-void SetGraphGrid(int x, int y);\r
 void PrintToScrollback(char *fmt, ...);\r
 #define MAX_GRAPH_TRACE_LEN (1024*128)\r
 extern int GraphBuffer[MAX_GRAPH_TRACE_LEN];\r
 extern int GraphTraceLen;\r
 extern double CursorScaleFactor;\r
+extern int PlotGridX, PlotGridY;\r
 extern int CommandFinished;\r
 extern int offline;\r
 \r
Impressum, Datenschutz