mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-22 06:13:51 -07:00
Merge pull request #2359 from jlitewski/marker_v2
Graph Markers, Version 2
This commit is contained in:
commit
591795a8fc
11 changed files with 196 additions and 114 deletions
|
@ -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...
|
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]
|
## [unreleased][unreleased]
|
||||||
|
- Updated Graph Markers implementation to include temporary markers and marker labels (@HACKhalo2)
|
||||||
- Updated to SWIG 4.2.1 (@iceman1001)
|
- Updated to SWIG 4.2.1 (@iceman1001)
|
||||||
- Removed `data bin2hex` - replaced by `data num` (@iceman1001)
|
- Removed `data bin2hex` - replaced by `data num` (@iceman1001)
|
||||||
- Removed `data hex2bin` - replaced by `data num` (@iceman1001)
|
- Removed `data hex2bin` - replaced by `data num` (@iceman1001)
|
||||||
|
|
|
@ -478,8 +478,8 @@ int ASKDemod_ext(int clk, int invert, int maxErr, size_t maxlen, bool amplify, b
|
||||||
|
|
||||||
if (st) {
|
if (st) {
|
||||||
*stCheck = st;
|
*stCheck = st;
|
||||||
g_MarkerCPos = ststart;
|
g_MarkerC.pos = ststart;
|
||||||
g_MarkerDPos = stend;
|
g_MarkerD.pos = stend;
|
||||||
if (verbose)
|
if (verbose)
|
||||||
PrintAndLogEx(DEBUG, "Found Sequence Terminator - First one is shown by orange / blue graph markers");
|
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);
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
bool keep = arg_get_lit(ctx, 1);
|
bool keep = arg_get_lit(ctx, 1);
|
||||||
g_MarkerAPos = arg_get_u32_def(ctx, 2, (keep ? g_MarkerAPos : 0));
|
g_MarkerA.pos = arg_get_u32_def(ctx, 2, (keep ? g_MarkerA.pos : 0));
|
||||||
g_MarkerBPos = arg_get_u32_def(ctx, 3, (keep ? g_MarkerBPos : 0));
|
g_MarkerB.pos = arg_get_u32_def(ctx, 3, (keep ? g_MarkerB.pos : 0));
|
||||||
g_MarkerCPos = arg_get_u32_def(ctx, 4, (keep ? g_MarkerCPos : 0));
|
g_MarkerC.pos = arg_get_u32_def(ctx, 4, (keep ? g_MarkerC.pos : 0));
|
||||||
g_MarkerDPos = arg_get_u32_def(ctx, 5, (keep ? g_MarkerDPos : 0));
|
g_MarkerD.pos = arg_get_u32_def(ctx, 5, (keep ? g_MarkerD.pos : 0));
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
PrintAndLogEx(INFO, "Setting markers " _BRIGHT_YELLOW_("A") "=%u, "_BRIGHT_MAGENTA_("B") "=%u, "_RED_("C") "=%u, "_BLUE_("D") "=%u",
|
PrintAndLogEx(INFO, "Setting markers " _BRIGHT_YELLOW_("A") "=%u, "_BRIGHT_MAGENTA_("B") "=%u, "_RED_("C") "=%u, "_BLUE_("D") "=%u",
|
||||||
g_MarkerAPos,
|
g_MarkerA.pos,
|
||||||
g_MarkerBPos,
|
g_MarkerB.pos,
|
||||||
g_MarkerCPos,
|
g_MarkerC.pos,
|
||||||
g_MarkerDPos
|
g_MarkerD.pos
|
||||||
);
|
);
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
|
|
@ -1085,8 +1085,8 @@ static int CmdTune(const char *Cmd) {
|
||||||
, LF_DIV2FREQ(LF_DIVISOR_134)
|
, LF_DIV2FREQ(LF_DIVISOR_134)
|
||||||
);
|
);
|
||||||
g_GraphTraceLen = 256;
|
g_GraphTraceLen = 256;
|
||||||
g_MarkerCPos = LF_DIVISOR_125;
|
g_MarkerC.pos = LF_DIVISOR_125;
|
||||||
g_MarkerDPos = LF_DIVISOR_134;
|
g_MarkerD.pos = LF_DIVISOR_134;
|
||||||
ShowGraphWindow();
|
ShowGraphWindow();
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "cmdlfti.h"
|
#include "cmdlfti.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h> // strncpy
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include "cmdparser.h" // command_t
|
#include "cmdparser.h" // command_t
|
||||||
#include "commonutil.h"
|
#include "commonutil.h"
|
||||||
|
@ -168,8 +169,8 @@ int demodTI(bool verbose) {
|
||||||
|
|
||||||
// place a marker in the buffer to visually aid location
|
// place a marker in the buffer to visually aid location
|
||||||
// of the start of sync
|
// of the start of sync
|
||||||
g_GraphBuffer[maxPos] = 800;
|
g_MarkerC.pos = maxPos;
|
||||||
g_GraphBuffer[maxPos + 1] = -800;
|
strcpy(g_MarkerC.label, "Sync Start");
|
||||||
|
|
||||||
// advance pointer to start of actual data stream (after 16 pre and 8 start bits)
|
// advance pointer to start of actual data stream (after 16 pre and 8 start bits)
|
||||||
maxPos += 17 * lowLen;
|
maxPos += 17 * lowLen;
|
||||||
|
@ -177,8 +178,8 @@ int demodTI(bool verbose) {
|
||||||
|
|
||||||
// place a marker in the buffer to visually aid location
|
// place a marker in the buffer to visually aid location
|
||||||
// of the end of sync
|
// of the end of sync
|
||||||
g_GraphBuffer[maxPos] = 800;
|
g_MarkerD.pos = maxPos;
|
||||||
g_GraphBuffer[maxPos + 1] = -800;
|
strcpy(g_MarkerD.label, "Sync End");
|
||||||
|
|
||||||
PrintAndLogEx(DEBUG, "actual data bits start at sample %d", maxPos);
|
PrintAndLogEx(DEBUG, "actual data bits start at sample %d", maxPos);
|
||||||
PrintAndLogEx(DEBUG, "length %d/%d", highLen, lowLen);
|
PrintAndLogEx(DEBUG, "length %d/%d", highLen, lowLen);
|
||||||
|
@ -214,8 +215,7 @@ int demodTI(bool verbose) {
|
||||||
shift3 >>= 1;
|
shift3 >>= 1;
|
||||||
|
|
||||||
// place a marker in the buffer between bits to visually aid location
|
// place a marker in the buffer between bits to visually aid location
|
||||||
g_GraphBuffer[maxPos] = 800;
|
add_temporary_marker(maxPos, "");
|
||||||
g_GraphBuffer[maxPos + 1] = -800;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
|
|
|
@ -81,6 +81,12 @@ size_t ClearGraph(bool redraw) {
|
||||||
g_DemodBufferLen = 0;
|
g_DemodBufferLen = 0;
|
||||||
g_useOverlays = false;
|
g_useOverlays = false;
|
||||||
|
|
||||||
|
remove_temporary_markers();
|
||||||
|
g_MarkerA.pos = 0;
|
||||||
|
g_MarkerB.pos = 0;
|
||||||
|
g_MarkerC.pos = 0;
|
||||||
|
g_MarkerD.pos = 0;
|
||||||
|
|
||||||
if (redraw) {
|
if (redraw) {
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
}
|
}
|
||||||
|
@ -123,6 +129,7 @@ void setGraphBuffer(const uint8_t *src, size_t size) {
|
||||||
g_OperationBuffer[i] = src[i] - 128;
|
g_OperationBuffer[i] = src[i] - 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remove_temporary_markers();
|
||||||
g_GraphTraceLen = size;
|
g_GraphTraceLen = size;
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
#include "ui.h" // for prints
|
#include "ui.h" // for prints
|
||||||
|
|
||||||
static ProxGuiQT *gui = NULL;
|
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;
|
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) {
|
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);
|
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*)calloc(1, 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*)calloc(1, strlen(label) + 1);
|
||||||
|
strcpy(markerLabel, label);
|
||||||
|
|
||||||
|
if(strlen(markerLabel) > 30) {
|
||||||
|
PrintAndLogEx(WARNING, "Label for temporary marker too long! Trunicating...");
|
||||||
|
markerLabel[30] = '\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) {
|
extern "C" void ExitGraphics(void) {
|
||||||
if (!gui)
|
if (!gui)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -27,6 +27,11 @@ extern "C" {
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t pos;
|
||||||
|
char label[30];
|
||||||
|
} marker_t;
|
||||||
|
|
||||||
void ShowGraphWindow(void);
|
void ShowGraphWindow(void);
|
||||||
void HideGraphWindow(void);
|
void HideGraphWindow(void);
|
||||||
void RepaintGraphWindow(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 InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd, bool stayInCommandLoop);
|
||||||
void ExitGraphics(void);
|
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 double g_CursorScaleFactor;
|
||||||
extern char g_CursorScaleFactorUnit[11];
|
extern char g_CursorScaleFactorUnit[11];
|
||||||
extern double g_PlotGridX, g_PlotGridY, g_DefaultGridX, g_DefaultGridY, g_GridOffset;
|
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 uint32_t g_GraphStart, g_GraphStart_old, g_GraphStop;
|
||||||
extern int CommandFinished;
|
extern int CommandFinished;
|
||||||
extern int offline;
|
extern int offline;
|
||||||
|
|
|
@ -773,9 +773,9 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) {
|
||||||
|
|
||||||
if (g_CursorScaleFactor != 1) {
|
if (g_CursorScaleFactor != 1) {
|
||||||
if (g_CursorScaleFactorUnit[0] == '\x00') {
|
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 {
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -783,13 +783,12 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) {
|
||||||
char graphText[] = "@%u..%u dt=%i %s zoom=%2.3f";
|
char graphText[] = "@%u..%u dt=%i %s zoom=%2.3f";
|
||||||
length = ((sizeof(graphText))+(sizeof(uint32_t)*3)+sizeof(scalestr)+sizeof(float_t));
|
length = ((sizeof(graphText))+(sizeof(uint32_t)*3)+sizeof(scalestr)+sizeof(float_t));
|
||||||
|
|
||||||
annotation = (char*)malloc(length);
|
annotation = (char*)calloc(1, length);
|
||||||
memset(annotation, 0x00, length);
|
|
||||||
|
|
||||||
snprintf(annotation, length, graphText,
|
snprintf(annotation, length, graphText,
|
||||||
g_GraphStart,
|
g_GraphStart,
|
||||||
g_GraphStop,
|
g_GraphStop,
|
||||||
g_MarkerBPos - g_MarkerAPos,
|
g_MarkerB.pos - g_MarkerA.pos,
|
||||||
scalestr,
|
scalestr,
|
||||||
g_GraphPixelsPerPoint
|
g_GraphPixelsPerPoint
|
||||||
);
|
);
|
||||||
|
@ -799,12 +798,13 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) {
|
||||||
|
|
||||||
//Print Grid Information if the grid is enabled
|
//Print Grid Information if the grid is enabled
|
||||||
if(g_PlotGridX > 0) {
|
if(g_PlotGridX > 0) {
|
||||||
|
free(annotation);
|
||||||
|
|
||||||
const char *gridLocked = (g_GridLocked ? "Locked" : "Unlocked");
|
const char *gridLocked = (g_GridLocked ? "Locked" : "Unlocked");
|
||||||
char gridText[] = "GridX=%lf GridY=%lf (%s) GridXoffset=%lf";
|
char gridText[] = "GridX=%lf GridY=%lf (%s) GridXoffset=%lf";
|
||||||
length = (sizeof(gridText) + (sizeof(double)*3) + sizeof(gridLocked));
|
length = (sizeof(gridText) + (sizeof(double)*3) + sizeof(gridLocked));
|
||||||
|
|
||||||
annotation = (char*)malloc(length);
|
annotation = (char*)calloc(1, length);
|
||||||
memset(annotation, 0x00, length);
|
|
||||||
|
|
||||||
snprintf(annotation, length, gridText,
|
snprintf(annotation, length, gridText,
|
||||||
g_DefaultGridX,
|
g_DefaultGridX,
|
||||||
|
@ -822,17 +822,16 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) {
|
||||||
uint32_t pos = 0, loc = 375;
|
uint32_t pos = 0, loc = 375;
|
||||||
painter->setPen(WHITE);
|
painter->setPen(WHITE);
|
||||||
|
|
||||||
if(g_MarkerAPos > 0) {
|
if(g_MarkerA.pos > 0) {
|
||||||
|
free(annotation);
|
||||||
|
|
||||||
length = (sizeof(markerText) + (sizeof(uint32_t)*3) + sizeof(" ") + 1);
|
length = (sizeof(markerText) + (sizeof(uint32_t)*3) + sizeof(" ") + 1);
|
||||||
pos = g_MarkerAPos;
|
pos = g_MarkerA.pos;
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
size_t value;
|
size_t value;
|
||||||
|
|
||||||
annotation = (char*)malloc(length);
|
annotation = (char*)calloc(1, length);
|
||||||
char *textA = (char*)malloc(length);
|
char *textA = (char*)calloc(1, length);
|
||||||
|
|
||||||
memset(annotation, 0x00, length);
|
|
||||||
memset(textA, 0x00, length);
|
|
||||||
|
|
||||||
strcat(textA, markerText);
|
strcat(textA, markerText);
|
||||||
strcat(textA, " (%s%u)");
|
strcat(textA, " (%s%u)");
|
||||||
|
@ -853,14 +852,17 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) {
|
||||||
);
|
);
|
||||||
|
|
||||||
painter->drawText(loc, annotationRect.bottom() - 48, annotation);
|
painter->drawText(loc, annotationRect.bottom() - 48, annotation);
|
||||||
|
|
||||||
|
free(textA);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(g_MarkerBPos > 0) {
|
if(g_MarkerB.pos > 0) {
|
||||||
length = ((sizeof(markerText))+(sizeof(uint32_t)*2)+1);
|
free(annotation);
|
||||||
pos = g_MarkerBPos;
|
|
||||||
|
|
||||||
annotation = (char*)malloc(length);
|
length = ((sizeof(markerText))+(sizeof(uint32_t)*2)+1);
|
||||||
memset(annotation, 0x00, length);
|
pos = g_MarkerB.pos;
|
||||||
|
|
||||||
|
annotation = (char*)calloc(1, length);
|
||||||
|
|
||||||
snprintf(annotation, length, markerText,
|
snprintf(annotation, length, markerText,
|
||||||
"B",
|
"B",
|
||||||
|
@ -871,12 +873,13 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) {
|
||||||
painter->drawText(loc, annotationRect.bottom() - 36, annotation);
|
painter->drawText(loc, annotationRect.bottom() - 36, annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(g_MarkerCPos > 0) {
|
if(g_MarkerC.pos > 0) {
|
||||||
length = ((sizeof(markerText))+(sizeof(uint32_t)*2)+1);
|
free(annotation);
|
||||||
pos = g_MarkerCPos;
|
|
||||||
|
|
||||||
annotation = (char*)malloc(length);
|
length = ((sizeof(markerText))+(sizeof(uint32_t)*2)+1);
|
||||||
memset(annotation, 0x00, length);
|
pos = g_MarkerC.pos;
|
||||||
|
|
||||||
|
annotation = (char*)calloc(1, length);
|
||||||
|
|
||||||
snprintf(annotation, length, markerText,
|
snprintf(annotation, length, markerText,
|
||||||
"C",
|
"C",
|
||||||
|
@ -887,12 +890,13 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) {
|
||||||
painter->drawText(loc, annotationRect.bottom() - 24, annotation);
|
painter->drawText(loc, annotationRect.bottom() - 24, annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(g_MarkerDPos > 0) {
|
if(g_MarkerD.pos > 0) {
|
||||||
length = ((sizeof(markerText))+(sizeof(uint32_t)*2)+1);
|
free(annotation);
|
||||||
pos = g_MarkerDPos;
|
|
||||||
|
|
||||||
annotation = (char*)malloc(length);
|
length = ((sizeof(markerText))+(sizeof(uint32_t)*2)+1);
|
||||||
memset(annotation, 0x00, length);
|
pos = g_MarkerD.pos;
|
||||||
|
|
||||||
|
annotation = (char*)calloc(1, length);
|
||||||
|
|
||||||
snprintf(annotation, length, markerText,
|
snprintf(annotation, length, markerText,
|
||||||
"D",
|
"D",
|
||||||
|
@ -903,6 +907,7 @@ void Plot::drawAnnotations(QRect annotationRect, QPainter *painter) {
|
||||||
painter->drawText(loc, annotationRect.bottom() - 12, annotation);
|
painter->drawText(loc, annotationRect.bottom() - 12, annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plot::plotGridLines(QPainter *painter, QRect r) {
|
void Plot::plotGridLines(QPainter *painter, QRect r) {
|
||||||
|
@ -1040,10 +1045,16 @@ void Plot::paintEvent(QPaintEvent *event) {
|
||||||
// End graph drawing
|
// End graph drawing
|
||||||
|
|
||||||
//Draw the markers
|
//Draw the markers
|
||||||
draw_marker(g_MarkerAPos, plotRect, YELLOW, &painter);
|
if(g_TempMarkerSize > 0) {
|
||||||
draw_marker(g_MarkerBPos, plotRect, PINK, &painter);
|
for(int i = 0; i < g_TempMarkerSize; i++) {
|
||||||
draw_marker(g_MarkerCPos, plotRect, ORANGE, &painter);
|
draw_marker(g_TempMarkers[i], plotRect, GRAY100, &painter);
|
||||||
draw_marker(g_MarkerDPos, plotRect, LIGHTBLUE, &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
|
//Draw annotations
|
||||||
drawAnnotations(infoRect, &painter);
|
drawAnnotations(infoRect, &painter);
|
||||||
|
@ -1059,16 +1070,21 @@ void Plot::paintEvent(QPaintEvent *event) {
|
||||||
g_GraphStart_old = g_GraphStart;
|
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 the marker is outside the buffer length, reset
|
||||||
if(marker > g_GraphTraceLen) {
|
if(marker.pos > g_GraphTraceLen) {
|
||||||
marker = 0;
|
marker.pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Make sure the marker is inside the current plot view to render
|
//Make sure the marker is inside the current plot view to render
|
||||||
if(marker > g_GraphStart && xCoordOf(marker, plotRect) < plotRect.right()) {
|
if(marker.pos > g_GraphStart && xCoordOf(marker.pos, plotRect) < plotRect.right()) {
|
||||||
painter->setPen(color);
|
painter->drawLine(xCoordOf(marker.pos, plotRect), plotRect.top(), xCoordOf(marker.pos, plotRect), plotRect.bottom());
|
||||||
painter->drawLine(xCoordOf(marker, plotRect), plotRect.top(), xCoordOf(marker, plotRect), plotRect.bottom());
|
|
||||||
|
if(strlen(marker.label) > 0) {
|
||||||
|
painter->drawText(xCoordOf(marker.pos, plotRect) + 1, plotRect.top() + 12, marker.label);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1084,8 +1100,10 @@ Plot::Plot(QWidget *parent) : QWidget(parent), g_GraphPixelsPerPoint(1) {
|
||||||
setPalette(palette);
|
setPalette(palette);
|
||||||
setAutoFillBackground(true);
|
setAutoFillBackground(true);
|
||||||
|
|
||||||
g_MarkerAPos = 0;
|
g_MarkerA.pos = 0;
|
||||||
g_MarkerBPos = 0;
|
g_MarkerB.pos = 0;
|
||||||
|
g_MarkerC.pos = 0;
|
||||||
|
g_MarkerD.pos = 0;
|
||||||
g_GraphStart = 0;
|
g_GraphStart = 0;
|
||||||
g_GraphStop = 0;
|
g_GraphStop = 0;
|
||||||
|
|
||||||
|
@ -1176,23 +1194,23 @@ void Plot::Move(int offset) {
|
||||||
|
|
||||||
void Plot::Trim(void) {
|
void Plot::Trim(void) {
|
||||||
uint32_t lref, rref;
|
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;
|
lref = g_GraphStart;
|
||||||
rref = g_GraphStop;
|
rref = g_GraphStop;
|
||||||
if (g_MarkerAPos >= lref) {
|
if (g_MarkerA.pos >= lref) {
|
||||||
g_MarkerAPos -= lref;
|
g_MarkerA.pos -= lref;
|
||||||
} else {
|
} else {
|
||||||
g_MarkerAPos = 0;
|
g_MarkerA.pos = 0;
|
||||||
}
|
}
|
||||||
if (g_MarkerBPos >= lref) {
|
if (g_MarkerB.pos >= lref) {
|
||||||
g_MarkerBPos -= lref;
|
g_MarkerB.pos -= lref;
|
||||||
} else {
|
} else {
|
||||||
g_MarkerBPos = 0;
|
g_MarkerB.pos = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
lref = g_MarkerAPos < g_MarkerBPos ? g_MarkerAPos : g_MarkerBPos;
|
lref = g_MarkerA.pos < g_MarkerB.pos ? g_MarkerA.pos : g_MarkerB.pos;
|
||||||
rref = g_MarkerAPos < g_MarkerBPos ? g_MarkerBPos : g_MarkerAPos;
|
rref = g_MarkerA.pos < g_MarkerB.pos ? g_MarkerB.pos : g_MarkerA.pos;
|
||||||
|
|
||||||
// g_GraphPixelsPerPoint must remain a power of ZOOM_STEP
|
// g_GraphPixelsPerPoint must remain a power of ZOOM_STEP
|
||||||
double GPPPtarget = g_GraphPixelsPerPoint * (g_GraphStop - g_GraphStart) / (rref - lref);
|
double GPPPtarget = g_GraphPixelsPerPoint * (g_GraphStop - g_GraphStart) / (rref - lref);
|
||||||
|
@ -1202,8 +1220,8 @@ void Plot::Trim(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
g_GraphPixelsPerPoint /= ZOOM_STEP;
|
g_GraphPixelsPerPoint /= ZOOM_STEP;
|
||||||
g_MarkerAPos -= lref;
|
g_MarkerA.pos -= lref;
|
||||||
g_MarkerBPos -= lref;
|
g_MarkerB.pos -= lref;
|
||||||
}
|
}
|
||||||
g_DemodStartIdx -= lref;
|
g_DemodStartIdx -= lref;
|
||||||
|
|
||||||
|
@ -1255,9 +1273,9 @@ void Plot::mouseMoveEvent(QMouseEvent *event) {
|
||||||
x += g_GraphStart;
|
x += g_GraphStart;
|
||||||
|
|
||||||
if ((event->buttons() & Qt::LeftButton)) {
|
if ((event->buttons() & Qt::LeftButton)) {
|
||||||
g_MarkerAPos = x;
|
g_MarkerA.pos = x;
|
||||||
} else if (event->buttons() & Qt::RightButton) {
|
} else if (event->buttons() & Qt::RightButton) {
|
||||||
g_MarkerBPos = x;
|
g_MarkerB.pos = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->update();
|
this->update();
|
||||||
|
@ -1284,15 +1302,15 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||||
case Qt::Key_Down:
|
case Qt::Key_Down:
|
||||||
if (event->modifiers() & Qt::ShiftModifier) {
|
if (event->modifiers() & Qt::ShiftModifier) {
|
||||||
if (event->modifiers() & Qt::ControlModifier) {
|
if (event->modifiers() & Qt::ControlModifier) {
|
||||||
Zoom(ZOOM_STEP, g_MarkerBPos);
|
Zoom(ZOOM_STEP, g_MarkerB.pos);
|
||||||
} else {
|
} else {
|
||||||
Zoom(ZOOM_STEP * 2, g_MarkerBPos);
|
Zoom(ZOOM_STEP * 2, g_MarkerB.pos);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (event->modifiers() & Qt::ControlModifier) {
|
if (event->modifiers() & Qt::ControlModifier) {
|
||||||
Zoom(ZOOM_STEP, g_MarkerAPos);
|
Zoom(ZOOM_STEP, g_MarkerA.pos);
|
||||||
} else {
|
} else {
|
||||||
Zoom(ZOOM_STEP * 2, g_MarkerAPos);
|
Zoom(ZOOM_STEP * 2, g_MarkerA.pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1300,15 +1318,15 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||||
case Qt::Key_Up:
|
case Qt::Key_Up:
|
||||||
if (event->modifiers() & Qt::ShiftModifier) {
|
if (event->modifiers() & Qt::ShiftModifier) {
|
||||||
if (event->modifiers() & Qt::ControlModifier) {
|
if (event->modifiers() & Qt::ControlModifier) {
|
||||||
Zoom(1.0 / ZOOM_STEP, g_MarkerBPos);
|
Zoom(1.0 / ZOOM_STEP, g_MarkerB.pos);
|
||||||
} else {
|
} else {
|
||||||
Zoom(1.0 / (ZOOM_STEP * 2), g_MarkerBPos);
|
Zoom(1.0 / (ZOOM_STEP * 2), g_MarkerB.pos);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (event->modifiers() & Qt::ControlModifier) {
|
if (event->modifiers() & Qt::ControlModifier) {
|
||||||
Zoom(1.0 / ZOOM_STEP, g_MarkerAPos);
|
Zoom(1.0 / ZOOM_STEP, g_MarkerA.pos);
|
||||||
} else {
|
} else {
|
||||||
Zoom(1.0 / (ZOOM_STEP * 2), g_MarkerAPos);
|
Zoom(1.0 / (ZOOM_STEP * 2), g_MarkerA.pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1426,9 +1444,9 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||||
|
|
||||||
case Qt::Key_Equal:
|
case Qt::Key_Equal:
|
||||||
if(event->modifiers() & Qt::ControlModifier) {
|
if(event->modifiers() & Qt::ControlModifier) {
|
||||||
g_OperationBuffer[g_MarkerAPos] += 5;
|
g_OperationBuffer[g_MarkerA.pos] += 5;
|
||||||
} else {
|
} else {
|
||||||
g_OperationBuffer[g_MarkerAPos] += 1;
|
g_OperationBuffer[g_MarkerA.pos] += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
|
@ -1436,9 +1454,9 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||||
|
|
||||||
case Qt::Key_Minus:
|
case Qt::Key_Minus:
|
||||||
if(event->modifiers() & Qt::ControlModifier) {
|
if(event->modifiers() & Qt::ControlModifier) {
|
||||||
g_OperationBuffer[g_MarkerAPos] -= 5;
|
g_OperationBuffer[g_MarkerA.pos] -= 5;
|
||||||
} else {
|
} else {
|
||||||
g_OperationBuffer[g_MarkerAPos] -= 1;
|
g_OperationBuffer[g_MarkerA.pos] -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
|
@ -1446,9 +1464,9 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||||
|
|
||||||
case Qt::Key_Plus:
|
case Qt::Key_Plus:
|
||||||
if(event->modifiers() & Qt::ControlModifier) {
|
if(event->modifiers() & Qt::ControlModifier) {
|
||||||
g_GraphBuffer[g_MarkerAPos] += 5;
|
g_GraphBuffer[g_MarkerA.pos] += 5;
|
||||||
} else {
|
} else {
|
||||||
g_GraphBuffer[g_MarkerAPos] += 1;
|
g_GraphBuffer[g_MarkerA.pos] += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
|
@ -1456,9 +1474,9 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||||
|
|
||||||
case Qt::Key_Underscore:
|
case Qt::Key_Underscore:
|
||||||
if(event->modifiers() & Qt::ControlModifier) {
|
if(event->modifiers() & Qt::ControlModifier) {
|
||||||
g_GraphBuffer[g_MarkerAPos] -= 5;
|
g_GraphBuffer[g_MarkerA.pos] -= 5;
|
||||||
} else {
|
} else {
|
||||||
g_GraphBuffer[g_MarkerAPos] -= 1;
|
g_GraphBuffer[g_MarkerA.pos] -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
|
@ -1466,23 +1484,23 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||||
|
|
||||||
case Qt::Key_BracketLeft: {
|
case Qt::Key_BracketLeft: {
|
||||||
if(event->modifiers() & Qt::ControlModifier) {
|
if(event->modifiers() & Qt::ControlModifier) {
|
||||||
g_MarkerAPos -= 5;
|
g_MarkerA.pos -= 5;
|
||||||
} else {
|
} 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;
|
uint32_t halfway = PageWidth / 2;
|
||||||
|
|
||||||
if((g_MarkerAPos - halfway) > g_GraphTraceLen) {
|
if((g_MarkerA.pos - halfway) > g_GraphTraceLen) {
|
||||||
g_GraphStart = 0;
|
g_GraphStart = 0;
|
||||||
} else {
|
} else {
|
||||||
g_GraphStart = g_MarkerAPos - halfway;
|
g_GraphStart = g_MarkerA.pos - halfway;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(g_MarkerAPos < g_GraphStart) {
|
if(g_MarkerA.pos < g_GraphStart) {
|
||||||
g_MarkerAPos = g_GraphStart;
|
g_MarkerA.pos = g_GraphStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
|
@ -1491,23 +1509,23 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||||
|
|
||||||
case Qt::Key_BracketRight: {
|
case Qt::Key_BracketRight: {
|
||||||
if(event->modifiers() & Qt::ControlModifier) {
|
if(event->modifiers() & Qt::ControlModifier) {
|
||||||
g_MarkerAPos += 5;
|
g_MarkerA.pos += 5;
|
||||||
} else {
|
} 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;
|
uint32_t halfway = PageWidth / 2;
|
||||||
|
|
||||||
if((g_MarkerAPos + halfway) >= g_GraphTraceLen) {
|
if((g_MarkerA.pos + halfway) >= g_GraphTraceLen) {
|
||||||
g_GraphStart = g_GraphTraceLen - halfway;
|
g_GraphStart = g_GraphTraceLen - halfway;
|
||||||
} else {
|
} else {
|
||||||
g_GraphStart = g_MarkerAPos - halfway;
|
g_GraphStart = g_MarkerA.pos - halfway;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(g_MarkerAPos >= g_GraphTraceLen) {
|
if(g_MarkerA.pos >= g_GraphTraceLen) {
|
||||||
g_MarkerAPos = g_GraphTraceLen;
|
g_MarkerA.pos = g_GraphTraceLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
|
@ -1516,13 +1534,13 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||||
|
|
||||||
case Qt::Key_BraceLeft:
|
case Qt::Key_BraceLeft:
|
||||||
if(event->modifiers() & Qt::ControlModifier) {
|
if(event->modifiers() & Qt::ControlModifier) {
|
||||||
g_MarkerBPos -= 5;
|
g_MarkerB.pos -= 5;
|
||||||
} else {
|
} else {
|
||||||
g_MarkerBPos -= 1;
|
g_MarkerB.pos -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(g_MarkerBPos < g_GraphStart) {
|
if(g_MarkerB.pos < g_GraphStart) {
|
||||||
g_MarkerBPos = g_GraphStart;
|
g_MarkerB.pos = g_GraphStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
|
@ -1530,13 +1548,13 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||||
|
|
||||||
case Qt::Key_BraceRight:
|
case Qt::Key_BraceRight:
|
||||||
if(event->modifiers() & Qt::ControlModifier) {
|
if(event->modifiers() & Qt::ControlModifier) {
|
||||||
g_MarkerBPos += 5;
|
g_MarkerB.pos += 5;
|
||||||
} else {
|
} else {
|
||||||
g_MarkerBPos += 1;
|
g_MarkerB.pos += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(g_MarkerBPos >= g_GraphTraceLen) {
|
if(g_MarkerB.pos >= g_GraphTraceLen) {
|
||||||
g_MarkerBPos = g_GraphTraceLen;
|
g_MarkerB.pos = g_GraphTraceLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
|
#include "proxgui.h"
|
||||||
#include "ui/ui_overlays.h"
|
#include "ui/ui_overlays.h"
|
||||||
#include "ui/ui_image.h"
|
#include "ui/ui_image.h"
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ class Plot: public QWidget {
|
||||||
void plotGridLines(QPainter *painter, QRect r);
|
void plotGridLines(QPainter *painter, QRect r);
|
||||||
void plotOperations(int *buffer, size_t len, QPainter *painter, QRect rect);
|
void plotOperations(int *buffer, size_t len, QPainter *painter, QRect rect);
|
||||||
void drawAnnotations(QRect annotationRect, QPainter *painter);
|
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 xCoordOf(int i, QRect r);
|
||||||
int yCoordOf(int v, QRect r, int maxVal);
|
int yCoordOf(int v, QRect r, int maxVal);
|
||||||
int valueOf_yCoord(int y, QRect r, int maxVal);
|
int valueOf_yCoord(int y, QRect r, int maxVal);
|
||||||
|
|
|
@ -51,7 +51,6 @@ double g_CursorScaleFactor = 1;
|
||||||
char g_CursorScaleFactorUnit[11] = {0};
|
char g_CursorScaleFactorUnit[11] = {0};
|
||||||
double g_PlotGridX = 0, g_PlotGridY = 0;
|
double g_PlotGridX = 0, g_PlotGridY = 0;
|
||||||
double g_DefaultGridX = 64, g_DefaultGridY = 64;
|
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_GraphStart = 0; // Starting point/offset for the left side of the graph
|
||||||
uint32_t g_GraphStop = 0;
|
uint32_t g_GraphStop = 0;
|
||||||
uint32_t g_GraphStart_old = 0;
|
uint32_t g_GraphStart_old = 0;
|
||||||
|
|
|
@ -66,6 +66,7 @@ typedef struct {
|
||||||
} session_arg_t;
|
} session_arg_t;
|
||||||
|
|
||||||
extern session_arg_t g_session;
|
extern session_arg_t g_session;
|
||||||
|
|
||||||
#ifndef M_PI
|
#ifndef M_PI
|
||||||
#define M_PI 3.14159265358979323846264338327
|
#define M_PI 3.14159265358979323846264338327
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue