From f4434ad22645c6f697a397e320f7f5693ef4f85d Mon Sep 17 00:00:00 2001 From: "adam@algroup.co.uk" Date: Tue, 21 Jul 2009 16:10:58 +0000 Subject: [PATCH] make grid function linux friendly --- linux/gui.c | 1 + linux/proxgui.h | 1 + linux/proxguiqt.cpp | 26 ++++++++++++++++++++++++-- winsrc/command.cpp | 6 ++---- winsrc/gui.cpp | 6 ------ winsrc/prox.h | 2 +- 6 files changed, 29 insertions(+), 13 deletions(-) diff --git a/linux/gui.c b/linux/gui.c index e8751a62..d31c5287 100644 --- a/linux/gui.c +++ b/linux/gui.c @@ -9,6 +9,7 @@ int GraphBuffer[MAX_GRAPH_TRACE_LEN]; int GraphTraceLen; double CursorScaleFactor; +int PlotGridX, PlotGridY; int CommandFinished; int offline; diff --git a/linux/proxgui.h b/linux/proxgui.h index 786d9361..6989f541 100644 --- a/linux/proxgui.h +++ b/linux/proxgui.h @@ -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; diff --git a/linux/proxguiqt.cpp b/linux/proxguiqt.cpp index f024529a..af32809d 100644 --- a/linux/proxguiqt.cpp +++ b/linux/proxguiqt.cpp @@ -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; diff --git a/winsrc/command.cpp b/winsrc/command.cpp index bc9fb9dc..b830922b 100644 --- a/winsrc/command.cpp +++ b/winsrc/command.cpp @@ -2590,9 +2590,7 @@ static void CmdPlot(char *str) static void CmdGrid(char *str) { - int x = 0, y = 0; - sscanf(str, "%i %i", &x, &y); - SetGraphGrid(x, y); + sscanf(str, "%i %i", &PlotGridX, &PlotGridY); RepaintGraphWindow(); } @@ -2734,7 +2732,7 @@ static struct { {"flexdemod", CmdFlexdemod, 1, "Demodulate samples for FlexPass"}, {"fpgaoff", CmdFPGAOff, 0, "Set FPGA off"}, {"fskdemod", CmdFSKdemod, 1, "Demodulate graph window as a HID FSK"}, - {"grid", CmdGrid, 1, "grid x y, overlay grid on graph window, use zero value to turn off either"}, + {"grid", CmdGrid, 1, " -- overlay grid on graph window, use zero value to turn off either"}, {"hexsamples", CmdHexsamples, 0, " -- Dump big buffer as hex bytes"}, {"hi14alist", CmdHi14alist, 0, "List ISO 14443a history"}, {"hi14areader", CmdHi14areader, 0, "Act like an ISO14443 Type A reader"}, diff --git a/winsrc/gui.cpp b/winsrc/gui.cpp index bcc0cbb6..161f99d6 100644 --- a/winsrc/gui.cpp +++ b/winsrc/gui.cpp @@ -67,12 +67,6 @@ void ExecCmd(char *cmd) int CommandFinished; int offset = 64; -void SetGraphGrid(int x, int y) -{ - PlotGridX = x; - PlotGridY = y; -} - static void ResizeCommandWindow(void) { int w, h; diff --git a/winsrc/prox.h b/winsrc/prox.h index 53449a13..aeb6dfea 100644 --- a/winsrc/prox.h +++ b/winsrc/prox.h @@ -13,12 +13,12 @@ void ShowGui(); void HideGraphWindow(void); void ShowGraphWindow(void); void RepaintGraphWindow(void); -void SetGraphGrid(int x, int y); void PrintToScrollback(char *fmt, ...); #define MAX_GRAPH_TRACE_LEN (1024*128) extern int GraphBuffer[MAX_GRAPH_TRACE_LEN]; extern int GraphTraceLen; extern double CursorScaleFactor; +extern int PlotGridX, PlotGridY; extern int CommandFinished; extern int offline; -- 2.39.5