From bb1c662af057c12cfdf3642af81bae26e657758a Mon Sep 17 00:00:00 2001 From: Jacob Litewski Date: Thu, 18 Apr 2024 23:08:33 -0400 Subject: [PATCH] Graph Markers, Version 2 --- CHANGELOG.md | 1 + client/src/cmddata.c | 20 ++--- client/src/cmdhw.c | 4 +- client/src/cmdlfti.c | 12 +-- client/src/graph.c | 7 ++ client/src/proxgui.cpp | 44 ++++++++++ client/src/proxgui.h | 13 ++- client/src/proxguiqt.cpp | 176 ++++++++++++++++++++++----------------- client/src/proxguiqt.h | 3 +- client/src/ui.c | 1 - client/src/ui.h | 1 + 11 files changed, 186 insertions(+), 96 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b0aeb8c5..dc3e0861a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] +- Updated Graph Markers implementation to include temporary markers and marker labels (@HACKhalo2) - Updated to SWIG 4.2.1 (@iceman1001) - Removed `data bin2hex` - replaced by `data num` (@iceman1001) - Removed `data hex2bin` - replaced by `data num` (@iceman1001) diff --git a/client/src/cmddata.c b/client/src/cmddata.c index 97a0b7577..eba8b32be 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -478,8 +478,8 @@ int ASKDemod_ext(int clk, int invert, int maxErr, size_t maxlen, bool amplify, b if (st) { *stCheck = st; - g_MarkerCPos = ststart; - g_MarkerDPos = stend; + g_MarkerC.pos = ststart; + g_MarkerD.pos = stend; if (verbose) PrintAndLogEx(DEBUG, "Found Sequence Terminator - First one is shown by orange / blue graph markers"); } @@ -1738,16 +1738,16 @@ static int CmdSetGraphMarkers(const char *Cmd) { }; CLIExecWithReturn(ctx, Cmd, argtable, true); bool keep = arg_get_lit(ctx, 1); - g_MarkerAPos = arg_get_u32_def(ctx, 2, (keep ? g_MarkerAPos : 0)); - g_MarkerBPos = arg_get_u32_def(ctx, 3, (keep ? g_MarkerBPos : 0)); - g_MarkerCPos = arg_get_u32_def(ctx, 4, (keep ? g_MarkerCPos : 0)); - g_MarkerDPos = arg_get_u32_def(ctx, 5, (keep ? g_MarkerDPos : 0)); + g_MarkerA.pos = arg_get_u32_def(ctx, 2, (keep ? g_MarkerA.pos : 0)); + g_MarkerB.pos = arg_get_u32_def(ctx, 3, (keep ? g_MarkerB.pos : 0)); + g_MarkerC.pos = arg_get_u32_def(ctx, 4, (keep ? g_MarkerC.pos : 0)); + g_MarkerD.pos = arg_get_u32_def(ctx, 5, (keep ? g_MarkerD.pos : 0)); CLIParserFree(ctx); PrintAndLogEx(INFO, "Setting markers " _BRIGHT_YELLOW_("A") "=%u, "_BRIGHT_MAGENTA_("B") "=%u, "_RED_("C") "=%u, "_BLUE_("D") "=%u", - g_MarkerAPos, - g_MarkerBPos, - g_MarkerCPos, - g_MarkerDPos + g_MarkerA.pos, + g_MarkerB.pos, + g_MarkerC.pos, + g_MarkerD.pos ); RepaintGraphWindow(); return PM3_SUCCESS; diff --git a/client/src/cmdhw.c b/client/src/cmdhw.c index ed1f8d18e..7f6ba4b97 100644 --- a/client/src/cmdhw.c +++ b/client/src/cmdhw.c @@ -1085,8 +1085,8 @@ static int CmdTune(const char *Cmd) { , LF_DIV2FREQ(LF_DIVISOR_134) ); g_GraphTraceLen = 256; - g_MarkerCPos = LF_DIVISOR_125; - g_MarkerDPos = LF_DIVISOR_134; + g_MarkerC.pos = LF_DIVISOR_125; + g_MarkerD.pos = LF_DIVISOR_134; ShowGraphWindow(); RepaintGraphWindow(); } else { diff --git a/client/src/cmdlfti.c b/client/src/cmdlfti.c index beb0d4ae4..f4d6d79ee 100644 --- a/client/src/cmdlfti.c +++ b/client/src/cmdlfti.c @@ -19,6 +19,7 @@ #include "cmdlfti.h" #include #include +#include // strncpy #include #include "cmdparser.h" // command_t #include "commonutil.h" @@ -168,8 +169,8 @@ int demodTI(bool verbose) { // place a marker in the buffer to visually aid location // of the start of sync - g_GraphBuffer[maxPos] = 800; - g_GraphBuffer[maxPos + 1] = -800; + g_MarkerC.pos = maxPos; + strcpy(g_MarkerC.label, "Sync Start"); // advance pointer to start of actual data stream (after 16 pre and 8 start bits) maxPos += 17 * lowLen; @@ -177,8 +178,8 @@ int demodTI(bool verbose) { // place a marker in the buffer to visually aid location // of the end of sync - g_GraphBuffer[maxPos] = 800; - g_GraphBuffer[maxPos + 1] = -800; + g_MarkerD.pos = maxPos; + strcpy(g_MarkerD.label, "Sync End"); PrintAndLogEx(DEBUG, "actual data bits start at sample %d", maxPos); PrintAndLogEx(DEBUG, "length %d/%d", highLen, lowLen); @@ -214,8 +215,7 @@ int demodTI(bool verbose) { shift3 >>= 1; // place a marker in the buffer between bits to visually aid location - g_GraphBuffer[maxPos] = 800; - g_GraphBuffer[maxPos + 1] = -800; + add_temporary_marker(maxPos, ""); } RepaintGraphWindow(); diff --git a/client/src/graph.c b/client/src/graph.c index 352bbbb5f..22541aa82 100644 --- a/client/src/graph.c +++ b/client/src/graph.c @@ -81,6 +81,12 @@ size_t ClearGraph(bool redraw) { g_DemodBufferLen = 0; g_useOverlays = false; + remove_temporary_markers(); + g_MarkerA.pos = 0; + g_MarkerB.pos = 0; + g_MarkerC.pos = 0; + g_MarkerD.pos = 0; + if (redraw) { RepaintGraphWindow(); } @@ -123,6 +129,7 @@ void setGraphBuffer(const uint8_t *src, size_t size) { g_OperationBuffer[i] = src[i] - 128; } + remove_temporary_markers(); g_GraphTraceLen = size; RepaintGraphWindow(); } diff --git a/client/src/proxgui.cpp b/client/src/proxgui.cpp index 9d95a372d..f4849a6a1 100644 --- a/client/src/proxgui.cpp +++ b/client/src/proxgui.cpp @@ -24,6 +24,9 @@ #include "ui.h" // for prints static ProxGuiQT *gui = NULL; +marker_t g_MarkerA, g_MarkerB, g_MarkerC, g_MarkerD; +marker_t *g_TempMarkers; +uint8_t g_TempMarkerSize = 0; static WorkerThread *main_loop_thread = NULL; WorkerThread::WorkerThread(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) : script_cmds_file(script_cmds_file), script_cmd(script_cmd), stayInCommandLoop(stayInCommandLoop) { @@ -134,6 +137,47 @@ extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file, char gui = new ProxGuiQT(argc, argv, main_loop_thread); } +void add_temporary_marker(uint32_t position, const char *label) { + if(g_TempMarkerSize == 0) { //Initialize the marker array + g_TempMarkers = (marker_t*)malloc(sizeof(marker_t)); + } else { //add more space to the marker array using realloc() + marker_t *temp = (marker_t*)realloc(g_TempMarkers, ((g_TempMarkerSize + 1) * sizeof(marker_t))); + + if(temp == NULL) { //Unable to reallocate memory for a new marker + PrintAndLogEx(FAILED, "Unable to allocate memory for a new temporary marker!"); + free(temp); + return; + } else { + //Set g_TempMarkers to the new pointer + g_TempMarkers = temp; + } + } + + g_TempMarkers[g_TempMarkerSize].pos = position; + + char *markerLabel = (char*)malloc(strlen(label)); + strcpy(markerLabel, label); + + if(strlen(markerLabel) > 29) { + PrintAndLogEx(WARNING, "Label for temporary marker too long! Trunicating..."); + markerLabel[29] = '\0'; + } + + strncpy(g_TempMarkers[g_TempMarkerSize].label, markerLabel, 30); + g_TempMarkerSize++; + + memset(markerLabel, 0x00, strlen(label)); + free(markerLabel); +} + +void remove_temporary_markers(void) { + if(g_TempMarkerSize == 0) return; + + memset(g_TempMarkers, 0x00, (g_TempMarkerSize * sizeof(marker_t))); + free(g_TempMarkers); + g_TempMarkerSize = 0; +} + extern "C" void ExitGraphics(void) { if (!gui) return; diff --git a/client/src/proxgui.h b/client/src/proxgui.h index 623cf11af..4190eea4e 100644 --- a/client/src/proxgui.h +++ b/client/src/proxgui.h @@ -27,6 +27,11 @@ extern "C" { #include #include +typedef struct { + uint32_t pos; + char label[30]; +} marker_t; + void ShowGraphWindow(void); void HideGraphWindow(void); void RepaintGraphWindow(void); @@ -41,10 +46,16 @@ void MainGraphics(void); void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd, bool stayInCommandLoop); void ExitGraphics(void); +//Temporary Marker Functions +extern void add_temporary_marker(uint32_t position, const char *label); +extern void remove_temporary_markers(void); + extern double g_CursorScaleFactor; extern char g_CursorScaleFactorUnit[11]; extern double g_PlotGridX, g_PlotGridY, g_DefaultGridX, g_DefaultGridY, g_GridOffset; -extern uint32_t g_MarkerAPos, g_MarkerBPos, g_MarkerCPos, g_MarkerDPos; +extern marker_t g_MarkerA, g_MarkerB, g_MarkerC, g_MarkerD; +extern marker_t *g_TempMarkers; +extern uint8_t g_TempMarkerSize; extern uint32_t g_GraphStart, g_GraphStart_old, g_GraphStop; extern int CommandFinished; extern int offline; diff --git a/client/src/proxguiqt.cpp b/client/src/proxguiqt.cpp index e9e7fa097..21ea0dfa6 100644 --- a/client/src/proxguiqt.cpp +++ b/client/src/proxguiqt.cpp @@ -773,9 +773,9 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) { if (g_CursorScaleFactor != 1) { if (g_CursorScaleFactorUnit[0] == '\x00') { - snprintf(scalestr, sizeof(scalestr), "[%2.2f] ", ((int32_t)(g_MarkerBPos - g_MarkerAPos)) / g_CursorScaleFactor); + snprintf(scalestr, sizeof(scalestr), "[%2.2f] ", ((int32_t)(g_MarkerB.pos - g_MarkerA.pos)) / g_CursorScaleFactor); } else { - snprintf(scalestr, sizeof(scalestr), "[%2.2f %s] ", ((int32_t)(g_MarkerBPos - g_MarkerAPos)) / g_CursorScaleFactor, g_CursorScaleFactorUnit); + snprintf(scalestr, sizeof(scalestr), "[%2.2f %s] ", ((int32_t)(g_MarkerB.pos - g_MarkerA.pos)) / g_CursorScaleFactor, g_CursorScaleFactorUnit); } } @@ -789,7 +789,7 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) { snprintf(annotation, length, graphText, g_GraphStart, g_GraphStop, - g_MarkerBPos - g_MarkerAPos, + g_MarkerB.pos - g_MarkerA.pos, scalestr, g_GraphPixelsPerPoint ); @@ -799,6 +799,8 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) { //Print Grid Information if the grid is enabled if(g_PlotGridX > 0) { + free(annotation); + const char *gridLocked = (g_GridLocked ? "Locked" : "Unlocked"); char gridText[] = "GridX=%lf GridY=%lf (%s) GridXoffset=%lf"; length = (sizeof(gridText) + (sizeof(double)*3) + sizeof(gridLocked)); @@ -822,9 +824,11 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) { uint32_t pos = 0, loc = 375; painter->setPen(WHITE); - if(g_MarkerAPos > 0) { + if(g_MarkerA.pos > 0) { + free(annotation); + length = (sizeof(markerText) + (sizeof(uint32_t)*3) + sizeof(" ") + 1); - pos = g_MarkerAPos; + pos = g_MarkerA.pos; bool flag = false; size_t value; @@ -853,11 +857,15 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) { ); painter->drawText(loc, annotationRect.bottom() - 48, annotation); + + free(textA); } - if(g_MarkerBPos > 0) { + if(g_MarkerB.pos > 0) { + free(annotation); + length = ((sizeof(markerText))+(sizeof(uint32_t)*2)+1); - pos = g_MarkerBPos; + pos = g_MarkerB.pos; annotation = (char*)malloc(length); memset(annotation, 0x00, length); @@ -871,9 +879,11 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) { painter->drawText(loc, annotationRect.bottom() - 36, annotation); } - if(g_MarkerCPos > 0) { + if(g_MarkerC.pos > 0) { + free(annotation); + length = ((sizeof(markerText))+(sizeof(uint32_t)*2)+1); - pos = g_MarkerCPos; + pos = g_MarkerC.pos; annotation = (char*)malloc(length); memset(annotation, 0x00, length); @@ -887,9 +897,11 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) { painter->drawText(loc, annotationRect.bottom() - 24, annotation); } - if(g_MarkerDPos > 0) { + if(g_MarkerD.pos > 0) { + free(annotation); + length = ((sizeof(markerText))+(sizeof(uint32_t)*2)+1); - pos = g_MarkerDPos; + pos = g_MarkerD.pos; annotation = (char*)malloc(length); memset(annotation, 0x00, length); @@ -902,7 +914,8 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) { painter->drawText(loc, annotationRect.bottom() - 12, annotation); } - + + free(annotation); } void Plot::plotGridLines(QPainter *painter, QRect r) { @@ -1040,10 +1053,16 @@ void Plot::paintEvent(QPaintEvent *event) { // End graph drawing //Draw the markers - draw_marker(g_MarkerAPos, plotRect, YELLOW, &painter); - draw_marker(g_MarkerBPos, plotRect, PINK, &painter); - draw_marker(g_MarkerCPos, plotRect, ORANGE, &painter); - draw_marker(g_MarkerDPos, plotRect, LIGHTBLUE, &painter); + if(g_TempMarkerSize > 0) { + for(int i = 0; i < g_TempMarkerSize; i++) { + draw_marker(g_TempMarkers[i], plotRect, GRAY100, &painter); + } + } + + draw_marker(g_MarkerA, plotRect, YELLOW, &painter); + draw_marker(g_MarkerB, plotRect, PINK, &painter); + draw_marker(g_MarkerC, plotRect, ORANGE, &painter); + draw_marker(g_MarkerD, plotRect, LIGHTBLUE, &painter); //Draw annotations drawAnnotations(infoRect, &painter); @@ -1059,16 +1078,21 @@ void Plot::paintEvent(QPaintEvent *event) { g_GraphStart_old = g_GraphStart; } -void Plot::draw_marker(uint32_t marker, QRect plotRect, QColor color, QPainter *painter) { +void Plot::draw_marker(marker_t marker, QRect plotRect, QColor color, QPainter *painter) { + painter->setPen(color); + //If the marker is outside the buffer length, reset - if(marker > g_GraphTraceLen) { - marker = 0; + if(marker.pos > g_GraphTraceLen) { + marker.pos = 0; } //Make sure the marker is inside the current plot view to render - if(marker > g_GraphStart && xCoordOf(marker, plotRect) < plotRect.right()) { - painter->setPen(color); - painter->drawLine(xCoordOf(marker, plotRect), plotRect.top(), xCoordOf(marker, plotRect), plotRect.bottom()); + if(marker.pos > g_GraphStart && xCoordOf(marker.pos, plotRect) < plotRect.right()) { + painter->drawLine(xCoordOf(marker.pos, plotRect), plotRect.top(), xCoordOf(marker.pos, plotRect), plotRect.bottom()); + + if(strlen(marker.label) > 0) { + painter->drawText(xCoordOf(marker.pos, plotRect) + 1, plotRect.top() + 12, marker.label); + } } } @@ -1084,8 +1108,10 @@ Plot::Plot(QWidget *parent) : QWidget(parent), g_GraphPixelsPerPoint(1) { setPalette(palette); setAutoFillBackground(true); - g_MarkerAPos = 0; - g_MarkerBPos = 0; + g_MarkerA.pos = 0; + g_MarkerB.pos = 0; + g_MarkerC.pos = 0; + g_MarkerD.pos = 0; g_GraphStart = 0; g_GraphStop = 0; @@ -1176,23 +1202,23 @@ void Plot::Move(int offset) { void Plot::Trim(void) { uint32_t lref, rref; - if ((g_MarkerAPos == 0) || (g_MarkerBPos == 0)) { // if we don't have both cursors set + if ((g_MarkerA.pos == 0) || (g_MarkerB.pos == 0)) { // if we don't have both cursors set lref = g_GraphStart; rref = g_GraphStop; - if (g_MarkerAPos >= lref) { - g_MarkerAPos -= lref; + if (g_MarkerA.pos >= lref) { + g_MarkerA.pos -= lref; } else { - g_MarkerAPos = 0; + g_MarkerA.pos = 0; } - if (g_MarkerBPos >= lref) { - g_MarkerBPos -= lref; + if (g_MarkerB.pos >= lref) { + g_MarkerB.pos -= lref; } else { - g_MarkerBPos = 0; + g_MarkerB.pos = 0; } } else { - lref = g_MarkerAPos < g_MarkerBPos ? g_MarkerAPos : g_MarkerBPos; - rref = g_MarkerAPos < g_MarkerBPos ? g_MarkerBPos : g_MarkerAPos; + lref = g_MarkerA.pos < g_MarkerB.pos ? g_MarkerA.pos : g_MarkerB.pos; + rref = g_MarkerA.pos < g_MarkerB.pos ? g_MarkerB.pos : g_MarkerA.pos; // g_GraphPixelsPerPoint must remain a power of ZOOM_STEP double GPPPtarget = g_GraphPixelsPerPoint * (g_GraphStop - g_GraphStart) / (rref - lref); @@ -1202,8 +1228,8 @@ void Plot::Trim(void) { } g_GraphPixelsPerPoint /= ZOOM_STEP; - g_MarkerAPos -= lref; - g_MarkerBPos -= lref; + g_MarkerA.pos -= lref; + g_MarkerB.pos -= lref; } g_DemodStartIdx -= lref; @@ -1255,9 +1281,9 @@ void Plot::mouseMoveEvent(QMouseEvent *event) { x += g_GraphStart; if ((event->buttons() & Qt::LeftButton)) { - g_MarkerAPos = x; + g_MarkerA.pos = x; } else if (event->buttons() & Qt::RightButton) { - g_MarkerBPos = x; + g_MarkerB.pos = x; } this->update(); @@ -1284,15 +1310,15 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_Down: if (event->modifiers() & Qt::ShiftModifier) { if (event->modifiers() & Qt::ControlModifier) { - Zoom(ZOOM_STEP, g_MarkerBPos); + Zoom(ZOOM_STEP, g_MarkerB.pos); } else { - Zoom(ZOOM_STEP * 2, g_MarkerBPos); + Zoom(ZOOM_STEP * 2, g_MarkerB.pos); } } else { if (event->modifiers() & Qt::ControlModifier) { - Zoom(ZOOM_STEP, g_MarkerAPos); + Zoom(ZOOM_STEP, g_MarkerA.pos); } else { - Zoom(ZOOM_STEP * 2, g_MarkerAPos); + Zoom(ZOOM_STEP * 2, g_MarkerA.pos); } } break; @@ -1300,15 +1326,15 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_Up: if (event->modifiers() & Qt::ShiftModifier) { if (event->modifiers() & Qt::ControlModifier) { - Zoom(1.0 / ZOOM_STEP, g_MarkerBPos); + Zoom(1.0 / ZOOM_STEP, g_MarkerB.pos); } else { - Zoom(1.0 / (ZOOM_STEP * 2), g_MarkerBPos); + Zoom(1.0 / (ZOOM_STEP * 2), g_MarkerB.pos); } } else { if (event->modifiers() & Qt::ControlModifier) { - Zoom(1.0 / ZOOM_STEP, g_MarkerAPos); + Zoom(1.0 / ZOOM_STEP, g_MarkerA.pos); } else { - Zoom(1.0 / (ZOOM_STEP * 2), g_MarkerAPos); + Zoom(1.0 / (ZOOM_STEP * 2), g_MarkerA.pos); } } break; @@ -1426,9 +1452,9 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_Equal: if(event->modifiers() & Qt::ControlModifier) { - g_OperationBuffer[g_MarkerAPos] += 5; + g_OperationBuffer[g_MarkerA.pos] += 5; } else { - g_OperationBuffer[g_MarkerAPos] += 1; + g_OperationBuffer[g_MarkerA.pos] += 1; } RepaintGraphWindow(); @@ -1436,9 +1462,9 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_Minus: if(event->modifiers() & Qt::ControlModifier) { - g_OperationBuffer[g_MarkerAPos] -= 5; + g_OperationBuffer[g_MarkerA.pos] -= 5; } else { - g_OperationBuffer[g_MarkerAPos] -= 1; + g_OperationBuffer[g_MarkerA.pos] -= 1; } RepaintGraphWindow(); @@ -1446,9 +1472,9 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_Plus: if(event->modifiers() & Qt::ControlModifier) { - g_GraphBuffer[g_MarkerAPos] += 5; + g_GraphBuffer[g_MarkerA.pos] += 5; } else { - g_GraphBuffer[g_MarkerAPos] += 1; + g_GraphBuffer[g_MarkerA.pos] += 1; } RepaintGraphWindow(); @@ -1456,9 +1482,9 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_Underscore: if(event->modifiers() & Qt::ControlModifier) { - g_GraphBuffer[g_MarkerAPos] -= 5; + g_GraphBuffer[g_MarkerA.pos] -= 5; } else { - g_GraphBuffer[g_MarkerAPos] -= 1; + g_GraphBuffer[g_MarkerA.pos] -= 1; } RepaintGraphWindow(); @@ -1466,23 +1492,23 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_BracketLeft: { if(event->modifiers() & Qt::ControlModifier) { - g_MarkerAPos -= 5; + g_MarkerA.pos -= 5; } else { - g_MarkerAPos -= 1; + g_MarkerA.pos -= 1; } - if((g_MarkerAPos >= g_GraphStop) || (g_MarkerAPos <= g_GraphStart)) { + if((g_MarkerA.pos >= g_GraphStop) || (g_MarkerA.pos <= g_GraphStart)) { uint32_t halfway = PageWidth / 2; - if((g_MarkerAPos - halfway) > g_GraphTraceLen) { + if((g_MarkerA.pos - halfway) > g_GraphTraceLen) { g_GraphStart = 0; } else { - g_GraphStart = g_MarkerAPos - halfway; + g_GraphStart = g_MarkerA.pos - halfway; } } - if(g_MarkerAPos < g_GraphStart) { - g_MarkerAPos = g_GraphStart; + if(g_MarkerA.pos < g_GraphStart) { + g_MarkerA.pos = g_GraphStart; } RepaintGraphWindow(); @@ -1491,23 +1517,23 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_BracketRight: { if(event->modifiers() & Qt::ControlModifier) { - g_MarkerAPos += 5; + g_MarkerA.pos += 5; } else { - g_MarkerAPos += 1; + g_MarkerA.pos += 1; } - if((g_MarkerAPos >= g_GraphStop) || (g_MarkerAPos <= g_GraphStart)) { + if((g_MarkerA.pos >= g_GraphStop) || (g_MarkerA.pos <= g_GraphStart)) { uint32_t halfway = PageWidth / 2; - if((g_MarkerAPos + halfway) >= g_GraphTraceLen) { + if((g_MarkerA.pos + halfway) >= g_GraphTraceLen) { g_GraphStart = g_GraphTraceLen - halfway; } else { - g_GraphStart = g_MarkerAPos - halfway; + g_GraphStart = g_MarkerA.pos - halfway; } } - if(g_MarkerAPos >= g_GraphTraceLen) { - g_MarkerAPos = g_GraphTraceLen; + if(g_MarkerA.pos >= g_GraphTraceLen) { + g_MarkerA.pos = g_GraphTraceLen; } RepaintGraphWindow(); @@ -1516,13 +1542,13 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_BraceLeft: if(event->modifiers() & Qt::ControlModifier) { - g_MarkerBPos -= 5; + g_MarkerB.pos -= 5; } else { - g_MarkerBPos -= 1; + g_MarkerB.pos -= 1; } - if(g_MarkerBPos < g_GraphStart) { - g_MarkerBPos = g_GraphStart; + if(g_MarkerB.pos < g_GraphStart) { + g_MarkerB.pos = g_GraphStart; } RepaintGraphWindow(); @@ -1530,13 +1556,13 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_BraceRight: if(event->modifiers() & Qt::ControlModifier) { - g_MarkerBPos += 5; + g_MarkerB.pos += 5; } else { - g_MarkerBPos += 1; + g_MarkerB.pos += 1; } - if(g_MarkerBPos >= g_GraphTraceLen) { - g_MarkerBPos = g_GraphTraceLen; + if(g_MarkerB.pos >= g_GraphTraceLen) { + g_MarkerB.pos = g_GraphTraceLen; } RepaintGraphWindow(); diff --git a/client/src/proxguiqt.h b/client/src/proxguiqt.h index bda75c3d4..2f4879495 100644 --- a/client/src/proxguiqt.h +++ b/client/src/proxguiqt.h @@ -29,6 +29,7 @@ #include #include +#include "proxgui.h" #include "ui/ui_overlays.h" #include "ui/ui_image.h" @@ -48,7 +49,7 @@ class Plot: public QWidget { void plotGridLines(QPainter *painter, QRect r); void plotOperations(int *buffer, size_t len, QPainter *painter, QRect rect); void drawAnnotations(QRect annotationRect, QPainter *painter); - void draw_marker(uint32_t cursor, QRect plotRect, QColor color, QPainter *painter); + void draw_marker(marker_t marker, QRect plotRect, QColor color, QPainter *painter); int xCoordOf(int i, QRect r); int yCoordOf(int v, QRect r, int maxVal); int valueOf_yCoord(int y, QRect r, int maxVal); diff --git a/client/src/ui.c b/client/src/ui.c index 3e693d710..bfe705d80 100644 --- a/client/src/ui.c +++ b/client/src/ui.c @@ -51,7 +51,6 @@ double g_CursorScaleFactor = 1; char g_CursorScaleFactorUnit[11] = {0}; double g_PlotGridX = 0, g_PlotGridY = 0; double g_DefaultGridX = 64, g_DefaultGridY = 64; -uint32_t g_MarkerAPos = 0, g_MarkerBPos = 0, g_MarkerCPos = 0, g_MarkerDPos = 0; uint32_t g_GraphStart = 0; // Starting point/offset for the left side of the graph uint32_t g_GraphStop = 0; uint32_t g_GraphStart_old = 0; diff --git a/client/src/ui.h b/client/src/ui.h index 0c0588307..033f8b9a3 100644 --- a/client/src/ui.h +++ b/client/src/ui.h @@ -66,6 +66,7 @@ typedef struct { } session_arg_t; extern session_arg_t g_session; + #ifndef M_PI #define M_PI 3.14159265358979323846264338327 #endif