diff --git a/client/src/cmddata.c b/client/src/cmddata.c index bc12443d3..97a0b7577 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_CursorCPos = ststart; - g_CursorDPos = stend; + g_MarkerCPos = ststart; + g_MarkerDPos = stend; if (verbose) PrintAndLogEx(DEBUG, "Found Sequence Terminator - First one is shown by orange / blue graph markers"); } @@ -1682,13 +1682,13 @@ void setClockGrid(uint32_t clk, int offset) { g_GridLocked = false; g_GridOffset = 0; g_PlotGridX = 0; - g_PlotGridXdefault = 0; + g_DefaultGridX = 0; RepaintGraphWindow(); } else { g_GridLocked = true; g_GridOffset = offset; g_PlotGridX = clk; - g_PlotGridXdefault = clk; + g_DefaultGridX = clk; RepaintGraphWindow(); } } @@ -1713,8 +1713,8 @@ int CmdGrid(const char *Cmd) { CLIParserFree(ctx); PrintAndLogEx(DEBUG, "Setting X %.0f Y %.0f", g_PlotGridX, g_PlotGridY); - g_PlotGridXdefault = g_PlotGridX; - g_PlotGridYdefault = g_PlotGridY; + g_DefaultGridX = g_PlotGridX; + g_DefaultGridY = g_PlotGridY; RepaintGraphWindow(); return PM3_SUCCESS; } @@ -1722,21 +1722,33 @@ int CmdGrid(const char *Cmd) { static int CmdSetGraphMarkers(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "data setgraphmarkers", - "Set blue and orange marker in graph window", - "data setgraphmarkers --> turn off\n" - "data setgraphmarkers -a 64 -b 50" + "Set the locations of the markers in the graph window", + "data setgraphmarkers --> reset the markers\n" + "data setgraphmarkers -a 64 --> set A, reset the rest\n" + "data setgraphmarkers -d --keep --> set D, keep the rest" ); void *argtable[] = { arg_param_begin, - arg_u64_0("a", NULL, "", "orange marker"), - arg_u64_0("b", NULL, "", "blue marker"), + arg_lit0(NULL, "keep", "keep the current values of the markers"), + arg_u64_0("a", NULL, "", "yellow marker"), + arg_u64_0("b", NULL, "", "pink marker"), + arg_u64_0("c", NULL, "", "orange marker"), + arg_u64_0("d", NULL, "", "blue marker"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, true); - g_CursorCPos = arg_get_u32_def(ctx, 1, 0); - g_CursorDPos = arg_get_u32_def(ctx, 2, 0); + 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)); CLIParserFree(ctx); - PrintAndLogEx(INFO, "Setting orange %u blue %u", g_CursorCPos, g_CursorDPos); + 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 + ); RepaintGraphWindow(); return PM3_SUCCESS; } @@ -3727,7 +3739,7 @@ static command_t CommandTable[] = { {"mtrim", CmdMtrim, AlwaysAvailable, "Trim out samples from the specified start to the specified stop"}, {"norm", CmdNorm, AlwaysAvailable, "Normalize max/min to +/-128"}, {"rtrim", CmdRtrim, AlwaysAvailable, "Trim samples from right of trace"}, - {"setgraphmarkers", CmdSetGraphMarkers, AlwaysAvailable, "Set blue and orange marker in graph window"}, + {"setgraphmarkers", CmdSetGraphMarkers, AlwaysAvailable, "Set the markers in the graph window"}, {"shiftgraphzero", CmdGraphShiftZero, AlwaysAvailable, "Shift 0 for Graphed wave + or - shift value"}, {"timescale", CmdTimeScale, AlwaysAvailable, "Set cursor display timescale"}, {"undecimate", CmdUndecimate, AlwaysAvailable, "Un-decimate samples"}, diff --git a/client/src/cmdhw.c b/client/src/cmdhw.c index ea57a7728..ed1f8d18e 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_CursorCPos = LF_DIVISOR_125; - g_CursorDPos = LF_DIVISOR_134; + g_MarkerCPos = LF_DIVISOR_125; + g_MarkerDPos = LF_DIVISOR_134; ShowGraphWindow(); RepaintGraphWindow(); } else { diff --git a/client/src/proxgui.h b/client/src/proxgui.h index 99c69af94..623cf11af 100644 --- a/client/src/proxgui.h +++ b/client/src/proxgui.h @@ -43,8 +43,9 @@ void ExitGraphics(void); extern double g_CursorScaleFactor; extern char g_CursorScaleFactorUnit[11]; -extern double g_PlotGridX, g_PlotGridY, g_PlotGridXdefault, g_PlotGridYdefault, g_GridOffset; -extern uint32_t g_CursorCPos, g_CursorDPos, g_GraphStart, g_GraphStart_old, g_GraphStop; +extern double g_PlotGridX, g_PlotGridY, g_DefaultGridX, g_DefaultGridY, g_GridOffset; +extern uint32_t g_MarkerAPos, g_MarkerBPos, g_MarkerCPos, g_MarkerDPos; +extern uint32_t g_GraphStart, g_GraphStart_old, g_GraphStop; extern int CommandFinished; extern int offline; extern bool g_GridLocked; diff --git a/client/src/proxguiqt.cpp b/client/src/proxguiqt.cpp index 514b2920c..e9e7fa097 100644 --- a/client/src/proxguiqt.cpp +++ b/client/src/proxguiqt.cpp @@ -676,7 +676,6 @@ void Plot::PlotDemod(uint8_t *buffer, size_t len, QRect plotRect, QRect annotati clk = grid_delta_x; } - // Graph annotations painter->drawPath(penPath); } @@ -774,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)(CursorBPos - CursorAPos)) / g_CursorScaleFactor); + snprintf(scalestr, sizeof(scalestr), "[%2.2f] ", ((int32_t)(g_MarkerBPos - g_MarkerAPos)) / g_CursorScaleFactor); } else { - snprintf(scalestr, sizeof(scalestr), "[%2.2f %s] ", ((int32_t)(CursorBPos - CursorAPos)) / g_CursorScaleFactor, g_CursorScaleFactorUnit); + snprintf(scalestr, sizeof(scalestr), "[%2.2f %s] ", ((int32_t)(g_MarkerBPos - g_MarkerAPos)) / g_CursorScaleFactor, g_CursorScaleFactorUnit); } } @@ -790,7 +789,7 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) { snprintf(annotation, length, graphText, g_GraphStart, g_GraphStop, - CursorBPos - CursorAPos, + g_MarkerBPos - g_MarkerAPos, scalestr, g_GraphPixelsPerPoint ); @@ -808,8 +807,8 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) { memset(annotation, 0x00, length); snprintf(annotation, length, gridText, - g_PlotGridXdefault, - g_PlotGridYdefault, + g_DefaultGridX, + g_DefaultGridY, gridLocked, g_GridOffset ); @@ -818,14 +817,14 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) { painter->drawText(800, annotationRect.bottom() - 62, annotation); } - //Print the Cursor Information - char cursorText[] = "Cursor%s={Pos=%u Val=%d}"; + //Print the Marker Information + char markerText[] = "Marker%s={Pos=%u Val=%d}"; uint32_t pos = 0, loc = 375; painter->setPen(WHITE); - if(CursorAPos > 0) { - length = (sizeof(cursorText) + (sizeof(uint32_t)*3) + sizeof(" ") + 1); - pos = CursorAPos; + if(g_MarkerAPos > 0) { + length = (sizeof(markerText) + (sizeof(uint32_t)*3) + sizeof(" ") + 1); + pos = g_MarkerAPos; bool flag = false; size_t value; @@ -835,7 +834,7 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) { memset(annotation, 0x00, length); memset(textA, 0x00, length); - strcat(textA, cursorText); + strcat(textA, markerText); strcat(textA, " (%s%u)"); if(g_GraphBuffer[pos] <= g_OperationBuffer[pos]) { @@ -856,14 +855,14 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) { painter->drawText(loc, annotationRect.bottom() - 48, annotation); } - if(CursorBPos > 0) { - length = ((sizeof(cursorText))+(sizeof(uint32_t)*2)+1); - pos = CursorBPos; + if(g_MarkerBPos > 0) { + length = ((sizeof(markerText))+(sizeof(uint32_t)*2)+1); + pos = g_MarkerBPos; annotation = (char*)malloc(length); memset(annotation, 0x00, length); - snprintf(annotation, length, cursorText, + snprintf(annotation, length, markerText, "B", pos, g_GraphBuffer[pos] @@ -872,14 +871,14 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) { painter->drawText(loc, annotationRect.bottom() - 36, annotation); } - if(g_CursorCPos > 0) { - length = ((sizeof(cursorText))+(sizeof(uint32_t)*2)+1); - pos = g_CursorCPos; + if(g_MarkerCPos > 0) { + length = ((sizeof(markerText))+(sizeof(uint32_t)*2)+1); + pos = g_MarkerCPos; annotation = (char*)malloc(length); memset(annotation, 0x00, length); - snprintf(annotation, length, cursorText, + snprintf(annotation, length, markerText, "C", pos, g_GraphBuffer[pos] @@ -888,14 +887,14 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) { painter->drawText(loc, annotationRect.bottom() - 24, annotation); } - if(g_CursorDPos > 0) { - length = ((sizeof(cursorText))+(sizeof(uint32_t)*2)+1); - pos = g_CursorDPos; + if(g_MarkerDPos > 0) { + length = ((sizeof(markerText))+(sizeof(uint32_t)*2)+1); + pos = g_MarkerDPos; annotation = (char*)malloc(length); memset(annotation, 0x00, length); - snprintf(annotation, length, cursorText, + snprintf(annotation, length, markerText, "D", pos, g_GraphBuffer[pos] @@ -1003,18 +1002,6 @@ void Plot::paintEvent(QPaintEvent *event) { painter.setFont(QFont("Courier New", 10)); - if (CursorAPos > g_GraphTraceLen) - CursorAPos = 0; - - if (CursorBPos > g_GraphTraceLen) - CursorBPos = 0; - - if (g_CursorCPos > g_GraphTraceLen) - g_CursorCPos = 0; - - if (g_CursorDPos > g_GraphTraceLen) - g_CursorDPos = 0; - QRect plotRect(WIDTH_AXES, 0, width() - WIDTH_AXES, height() - HEIGHT_INFO); QRect infoRect(0, height() - HEIGHT_INFO, width(), HEIGHT_INFO); PageWidth = plotRect.width() / g_GraphPixelsPerPoint; @@ -1052,26 +1039,11 @@ void Plot::paintEvent(QPaintEvent *event) { } // End graph drawing - //Draw the cursors - if (CursorAPos > g_GraphStart && xCoordOf(CursorAPos, plotRect) < plotRect.right()) { - painter.setPen(YELLOW); - painter.drawLine(xCoordOf(CursorAPos, plotRect), plotRect.top(), xCoordOf(CursorAPos, plotRect), plotRect.bottom()); - } - - if (CursorBPos > g_GraphStart && xCoordOf(CursorBPos, plotRect) < plotRect.right()) { - painter.setPen(PINK); - painter.drawLine(xCoordOf(CursorBPos, plotRect), plotRect.top(), xCoordOf(CursorBPos, plotRect), plotRect.bottom()); - } - - if (g_CursorCPos > g_GraphStart && xCoordOf(g_CursorCPos, plotRect) < plotRect.right()) { - painter.setPen(ORANGE); - painter.drawLine(xCoordOf(g_CursorCPos, plotRect), plotRect.top(), xCoordOf(g_CursorCPos, plotRect), plotRect.bottom()); - } - - if (g_CursorDPos > g_GraphStart && xCoordOf(g_CursorDPos, plotRect) < plotRect.right()) { - painter.setPen(LIGHTBLUE); - painter.drawLine(xCoordOf(g_CursorDPos, plotRect), plotRect.top(), xCoordOf(g_CursorDPos, plotRect), plotRect.bottom()); - } + //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); //Draw annotations drawAnnotations(infoRect, &painter); @@ -1087,6 +1059,19 @@ void Plot::paintEvent(QPaintEvent *event) { g_GraphStart_old = g_GraphStart; } +void Plot::draw_marker(uint32_t marker, QRect plotRect, QColor color, QPainter *painter) { + //If the marker is outside the buffer length, reset + if(marker > g_GraphTraceLen) { + marker = 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()); + } +} + Plot::Plot(QWidget *parent) : QWidget(parent), g_GraphPixelsPerPoint(1) { //Need to set this, otherwise we don't receive keypress events setFocusPolicy(Qt::StrongFocus); @@ -1099,8 +1084,8 @@ Plot::Plot(QWidget *parent) : QWidget(parent), g_GraphPixelsPerPoint(1) { setPalette(palette); setAutoFillBackground(true); - CursorAPos = 0; - CursorBPos = 0; + g_MarkerAPos = 0; + g_MarkerBPos = 0; g_GraphStart = 0; g_GraphStop = 0; @@ -1191,23 +1176,23 @@ void Plot::Move(int offset) { void Plot::Trim(void) { uint32_t lref, rref; - if ((CursorAPos == 0) || (CursorBPos == 0)) { // if we don't have both cursors set + if ((g_MarkerAPos == 0) || (g_MarkerBPos == 0)) { // if we don't have both cursors set lref = g_GraphStart; rref = g_GraphStop; - if (CursorAPos >= lref) { - CursorAPos -= lref; + if (g_MarkerAPos >= lref) { + g_MarkerAPos -= lref; } else { - CursorAPos = 0; + g_MarkerAPos = 0; } - if (CursorBPos >= lref) { - CursorBPos -= lref; + if (g_MarkerBPos >= lref) { + g_MarkerBPos -= lref; } else { - CursorBPos = 0; + g_MarkerBPos = 0; } } else { - lref = CursorAPos < CursorBPos ? CursorAPos : CursorBPos; - rref = CursorAPos < CursorBPos ? CursorBPos : CursorAPos; + lref = g_MarkerAPos < g_MarkerBPos ? g_MarkerAPos : g_MarkerBPos; + rref = g_MarkerAPos < g_MarkerBPos ? g_MarkerBPos : g_MarkerAPos; // g_GraphPixelsPerPoint must remain a power of ZOOM_STEP double GPPPtarget = g_GraphPixelsPerPoint * (g_GraphStop - g_GraphStart) / (rref - lref); @@ -1217,8 +1202,8 @@ void Plot::Trim(void) { } g_GraphPixelsPerPoint /= ZOOM_STEP; - CursorAPos -= lref; - CursorBPos -= lref; + g_MarkerAPos -= lref; + g_MarkerBPos -= lref; } g_DemodStartIdx -= lref; @@ -1270,9 +1255,9 @@ void Plot::mouseMoveEvent(QMouseEvent *event) { x += g_GraphStart; if ((event->buttons() & Qt::LeftButton)) { - CursorAPos = x; + g_MarkerAPos = x; } else if (event->buttons() & Qt::RightButton) { - CursorBPos = x; + g_MarkerBPos = x; } this->update(); @@ -1299,15 +1284,15 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_Down: if (event->modifiers() & Qt::ShiftModifier) { if (event->modifiers() & Qt::ControlModifier) { - Zoom(ZOOM_STEP, CursorBPos); + Zoom(ZOOM_STEP, g_MarkerBPos); } else { - Zoom(ZOOM_STEP * 2, CursorBPos); + Zoom(ZOOM_STEP * 2, g_MarkerBPos); } } else { if (event->modifiers() & Qt::ControlModifier) { - Zoom(ZOOM_STEP, CursorAPos); + Zoom(ZOOM_STEP, g_MarkerAPos); } else { - Zoom(ZOOM_STEP * 2, CursorAPos); + Zoom(ZOOM_STEP * 2, g_MarkerAPos); } } break; @@ -1315,15 +1300,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, CursorBPos); + Zoom(1.0 / ZOOM_STEP, g_MarkerBPos); } else { - Zoom(1.0 / (ZOOM_STEP * 2), CursorBPos); + Zoom(1.0 / (ZOOM_STEP * 2), g_MarkerBPos); } } else { if (event->modifiers() & Qt::ControlModifier) { - Zoom(1.0 / ZOOM_STEP, CursorAPos); + Zoom(1.0 / ZOOM_STEP, g_MarkerAPos); } else { - Zoom(1.0 / (ZOOM_STEP * 2), CursorAPos); + Zoom(1.0 / (ZOOM_STEP * 2), g_MarkerAPos); } } break; @@ -1349,16 +1334,16 @@ void Plot::keyPressEvent(QKeyEvent *event) { g_PlotGridX = 0; g_PlotGridY = 0; } else { - if (g_PlotGridXdefault < 0) { - g_PlotGridXdefault = 64; + if (g_DefaultGridX < 0) { + g_DefaultGridX = 64; } - if (g_PlotGridYdefault < 0) { - g_PlotGridYdefault = 0; + if (g_DefaultGridY < 0) { + g_DefaultGridY = 0; } - g_PlotGridX = g_PlotGridXdefault; - g_PlotGridY = g_PlotGridYdefault; + g_PlotGridX = g_DefaultGridX; + g_PlotGridY = g_DefaultGridY; } break; @@ -1375,22 +1360,24 @@ void Plot::keyPressEvent(QKeyEvent *event) { PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("PgUp") "/" _RED_("PgDown"), "Move left/right by 1 window"); PrintAndLogEx(NORMAL, "\n" _GREEN_("Zoom:")); PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("Shift") " + " _YELLOW_("Mouse wheel"), "Zoom in/out around mouse cursor"); - PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("Down") "/" _RED_("Up"), "Zoom in/out around yellow cursor"); + PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("Down") "/" _RED_("Up"), "Zoom in/out around yellow marker"); PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, " + " _RED_("Ctrl"), "... with smaller increment"); - PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, " + " _RED_("Shift"), "... around purple cursor"); + PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, " + " _RED_("Shift"), "... around pink marker"); PrintAndLogEx(NORMAL, "\n" _GREEN_("Trim:")); - PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _RED_("t"), "Trim data on window or on cursors if defined"); + PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _RED_("t"), "Trim data on window or on markers (if defined)"); PrintAndLogEx(NORMAL, "\n" _GREEN_("Grid and demod:")); PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _RED_("g"), "Toggle grid and demodulation plot display"); PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _RED_("l"), "Toggle lock grid relative to samples"); PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("< ") "/" _RED_(" >"), "Move demodulation left/right relative to samples"); PrintAndLogEx(NORMAL, "\n" _GREEN_("Misc:")); - PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _YELLOW_("Left mouse click"), "Set yellow cursor"); - PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _YELLOW_("Right mouse click"), "Set purple cursor"); - PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("[ ") "/" _RED_(" ]"), "Move yellow cursor left/right by 1 sample"); - PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("{ ") "/" _RED_(" }"), "Move purple cursor left/right by 1 sample"); + PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _YELLOW_("Left mouse click"), "Set yellow marker"); + PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _YELLOW_("Right mouse click"), "Set pink marker"); + PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("[ ") "/" _RED_(" ]"), "Move yellow marker left/right by 1 sample"); + PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("{ ") "/" _RED_(" }"), "Move pink marker left/right by 1 sample"); PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, " + " _RED_("Ctrl"), "... by 5 samples"); - PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 +9, _RED_("= ") "/" _RED_(" -"), "Add/Subtract to the plot point over the yellow cursor by 1"); + PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 +9, _RED_("= ") "/" _RED_(" -"), "Add/Subtract to the plot point (Operation Buffer) over the yellow marker by 1"); + PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, " + " _RED_("Ctrl"), "... by 5"); + PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 +9, _RED_("+ ") "/" _RED_(" _"), "Add/Subtract to the plot point (Graph Buffer) over the yellow marker by 1"); PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, " + " _RED_("Ctrl"), "... by 5"); PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _RED_("h"), "Show this help"); PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _RED_("q"), "Close plot window"); @@ -1439,9 +1426,9 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_Equal: if(event->modifiers() & Qt::ControlModifier) { - g_OperationBuffer[CursorAPos] += 5; + g_OperationBuffer[g_MarkerAPos] += 5; } else { - g_OperationBuffer[CursorAPos] += 1; + g_OperationBuffer[g_MarkerAPos] += 1; } RepaintGraphWindow(); @@ -1449,9 +1436,9 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_Minus: if(event->modifiers() & Qt::ControlModifier) { - g_OperationBuffer[CursorAPos] -= 5; + g_OperationBuffer[g_MarkerAPos] -= 5; } else { - g_OperationBuffer[CursorAPos] -= 1; + g_OperationBuffer[g_MarkerAPos] -= 1; } RepaintGraphWindow(); @@ -1459,9 +1446,9 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_Plus: if(event->modifiers() & Qt::ControlModifier) { - g_GraphBuffer[CursorAPos] += 5; + g_GraphBuffer[g_MarkerAPos] += 5; } else { - g_GraphBuffer[CursorAPos] += 1; + g_GraphBuffer[g_MarkerAPos] += 1; } RepaintGraphWindow(); @@ -1469,9 +1456,9 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_Underscore: if(event->modifiers() & Qt::ControlModifier) { - g_GraphBuffer[CursorAPos] -= 5; + g_GraphBuffer[g_MarkerAPos] -= 5; } else { - g_GraphBuffer[CursorAPos] -= 1; + g_GraphBuffer[g_MarkerAPos] -= 1; } RepaintGraphWindow(); @@ -1479,23 +1466,23 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_BracketLeft: { if(event->modifiers() & Qt::ControlModifier) { - CursorAPos -= 5; + g_MarkerAPos -= 5; } else { - CursorAPos -= 1; + g_MarkerAPos -= 1; } - if((CursorAPos >= g_GraphStop) || (CursorAPos <= g_GraphStart)) { + if((g_MarkerAPos >= g_GraphStop) || (g_MarkerAPos <= g_GraphStart)) { uint32_t halfway = PageWidth / 2; - if((CursorAPos - halfway) > g_GraphTraceLen) { + if((g_MarkerAPos - halfway) > g_GraphTraceLen) { g_GraphStart = 0; } else { - g_GraphStart = CursorAPos - halfway; + g_GraphStart = g_MarkerAPos - halfway; } } - if(CursorAPos < g_GraphStart) { - CursorAPos = g_GraphStart; + if(g_MarkerAPos < g_GraphStart) { + g_MarkerAPos = g_GraphStart; } RepaintGraphWindow(); @@ -1504,23 +1491,23 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_BracketRight: { if(event->modifiers() & Qt::ControlModifier) { - CursorAPos += 5; + g_MarkerAPos += 5; } else { - CursorAPos += 1; + g_MarkerAPos += 1; } - if((CursorAPos >= g_GraphStop) || (CursorAPos <= g_GraphStart)) { + if((g_MarkerAPos >= g_GraphStop) || (g_MarkerAPos <= g_GraphStart)) { uint32_t halfway = PageWidth / 2; - if((CursorAPos + halfway) >= g_GraphTraceLen) { + if((g_MarkerAPos + halfway) >= g_GraphTraceLen) { g_GraphStart = g_GraphTraceLen - halfway; } else { - g_GraphStart = CursorAPos - halfway; + g_GraphStart = g_MarkerAPos - halfway; } } - if(CursorAPos >= g_GraphTraceLen) { - CursorAPos = g_GraphTraceLen; + if(g_MarkerAPos >= g_GraphTraceLen) { + g_MarkerAPos = g_GraphTraceLen; } RepaintGraphWindow(); @@ -1529,13 +1516,13 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_BraceLeft: if(event->modifiers() & Qt::ControlModifier) { - CursorBPos -= 5; + g_MarkerBPos -= 5; } else { - CursorBPos -= 1; + g_MarkerBPos -= 1; } - if(CursorBPos < g_GraphStart) { - CursorBPos = g_GraphStart; + if(g_MarkerBPos < g_GraphStart) { + g_MarkerBPos = g_GraphStart; } RepaintGraphWindow(); @@ -1543,13 +1530,13 @@ void Plot::keyPressEvent(QKeyEvent *event) { case Qt::Key_BraceRight: if(event->modifiers() & Qt::ControlModifier) { - CursorBPos += 5; + g_MarkerBPos += 5; } else { - CursorBPos += 1; + g_MarkerBPos += 1; } - if(CursorBPos >= g_GraphTraceLen) { - CursorBPos = g_GraphTraceLen; + if(g_MarkerBPos >= g_GraphTraceLen) { + g_MarkerBPos = g_GraphTraceLen; } RepaintGraphWindow(); diff --git a/client/src/proxguiqt.h b/client/src/proxguiqt.h index e19a43944..bda75c3d4 100644 --- a/client/src/proxguiqt.h +++ b/client/src/proxguiqt.h @@ -43,13 +43,12 @@ class Plot: public QWidget { private: QWidget *master; double g_GraphPixelsPerPoint; // How many visual pixels are between each sample point (x axis) - uint32_t CursorAPos; - uint32_t CursorBPos; void PlotGraph(int *buffer, size_t len, QRect plotRect, QRect annotationRect, QPainter *painter, int graphNum); void PlotDemod(uint8_t *buffer, size_t len, QRect plotRect, QRect annotationRect, QPainter *painter, int graphNum, uint32_t plotOffset); 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); 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 f2dcb46d9..3e693d710 100644 --- a/client/src/ui.c +++ b/client/src/ui.c @@ -49,9 +49,11 @@ session_arg_t g_session; double g_CursorScaleFactor = 1; char g_CursorScaleFactorUnit[11] = {0}; -double g_PlotGridX = 0, g_PlotGridY = 0, g_PlotGridXdefault = 64, g_PlotGridYdefault = 64; -uint32_t g_CursorCPos = 0, g_CursorDPos = 0, g_GraphStop = 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; double g_GraphPixelsPerPoint = 1.f; // How many visual pixels are between each sample point (x axis) static bool flushAfterWrite = false;