fixup QT GUI

This commit is contained in:
Michael Farrell 2017-07-08 22:53:28 +10:00
commit b4a56dd774
10 changed files with 106 additions and 84 deletions

View file

@ -25,6 +25,8 @@
#include "loclass/cipherutils.h" // for decimating samples in getsamples #include "loclass/cipherutils.h" // for decimating samples in getsamples
#include "cmdlfem4x.h"// for em410x demod #include "cmdlfem4x.h"// for em410x demod
uint8_t g_debugMode=0;
static int CmdHelp(pm3_connection* conn, const char *Cmd); static int CmdHelp(pm3_connection* conn, const char *Cmd);
//set the demod buffer with given array of binary (one bit per byte) //set the demod buffer with given array of binary (one bit per byte)

View file

@ -6,6 +6,7 @@
#include "usb_cmd.h" #include "usb_cmd.h"
#include "uart.h" #include "uart.h"
#include "util_posix.h"
#ifndef CMD_BUFFER_SIZE #ifndef CMD_BUFFER_SIZE
#define CMD_BUFFER_SIZE 50 #define CMD_BUFFER_SIZE 50

View file

@ -25,7 +25,14 @@ uint8_t fskClocks(pm3_connection* conn, uint8_t *fc1, uint8_t *fc2, uint8_t *rf1
//uint8_t fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, bool verbose); //uint8_t fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, bool verbose);
bool graphJustNoise(int *BitStream, int size); bool graphJustNoise(int *BitStream, int size);
void setGraphBuf(pm3_connection* conn, uint8_t *buff, size_t size); void setGraphBuf(pm3_connection* conn, uint8_t *buff, size_t size);
#ifdef __cplusplus
extern "C" {
#endif
void save_restoreGB(pm3_connection* conn, uint8_t saveOpt); void save_restoreGB(pm3_connection* conn, uint8_t saveOpt);
#ifdef __cplusplus
}
#endif
bool HasGraphData(); bool HasGraphData();
void DetectHighLowInGraph(pm3_connection* conn, int *high, int *low, bool addFuzz); void DetectHighLowInGraph(pm3_connection* conn, int *high, int *low, bool addFuzz);

View file

@ -21,8 +21,8 @@ extern "C" void ShowGraphWindow(pm3_connection* conn)
} }
} }
extern "C" void HideGraphWindow(pm3_connection* conn) {} extern "C" void HideGraphWindow() {}
extern "C" void RepaintGraphWindow(pm3_connection* conn) {} extern "C" void RepaintGraphWindow() {}
extern "C" void MainGraphics() {} extern "C" void MainGraphics(pm3_connection* conn) {}
extern "C" void InitGraphics(int argc, char **argv) {} extern "C" void InitGraphics(int argc, char **argv) {}
extern "C" void ExitGraphics(void) {} extern "C" void ExitGraphics(void) {}

View file

@ -16,11 +16,9 @@
static ProxGuiQT *gui = NULL; static ProxGuiQT *gui = NULL;
static WorkerThread *main_loop_thread = NULL; static WorkerThread *main_loop_thread = NULL;
WorkerThread::WorkerThread(char *script_cmds_file, bool usb_present,
serial_port* sp, bool flush_after_write)
: script_cmds_file(script_cmds_file), usb_present(usb_present),
sp(sp), flush_after_write(flush_after_write)
WorkerThread::WorkerThread(char *script_cmds_file, bool usb_present, serial_port* port, bool flush_after_write)
: script_cmds_file(script_cmds_file), usb_present(usb_present), port(port), flush_after_write(flush_after_write)
{ {
} }
@ -29,7 +27,7 @@ WorkerThread::~WorkerThread()
} }
void WorkerThread::run() { void WorkerThread::run() {
main_loop(script_cmds_file, usb_present, sp, flush_after_write); main_loop(script_cmds_file, usb_present, port, flush_after_write);
} }
extern "C" void ShowGraphWindow(void) extern "C" void ShowGraphWindow(void)
@ -56,16 +54,16 @@ extern "C" void RepaintGraphWindow(void)
gui->RepaintGraphWindow(); gui->RepaintGraphWindow();
} }
extern "C" void MainGraphics(void) extern "C" void MainGraphics(pm3_connection* conn)
{ {
if (!gui) if (!gui)
return; return;
main_loop_thread->start(); main_loop_thread->start();
gui->MainLoop(); gui->MainLoop(conn);
} }
extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file, bool usb_present, serial_port* sp, bool flush_after_write) extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file, bool usb_present, serial_port* port, bool flush_after_write)
{ {
#ifdef Q_WS_X11 #ifdef Q_WS_X11
bool useGUI = getenv("DISPLAY") != 0; bool useGUI = getenv("DISPLAY") != 0;
@ -76,7 +74,7 @@ extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file, bool
return; return;
gui = new ProxGuiQT(argc, argv); gui = new ProxGuiQT(argc, argv);
main_loop_thread = new WorkerThread(script_cmds_file, usb_present, sp, flush_after_write); main_loop_thread = new WorkerThread(script_cmds_file, usb_present, port, flush_after_write);
QObject::connect(main_loop_thread, SIGNAL(finished()), main_loop_thread, SLOT(deleteLater())); QObject::connect(main_loop_thread, SIGNAL(finished()), main_loop_thread, SLOT(deleteLater()));
QObject::connect(main_loop_thread, SIGNAL(finished()), gui, SLOT(_Exit())); QObject::connect(main_loop_thread, SIGNAL(finished()), gui, SLOT(_Exit()));
} }

View file

@ -17,10 +17,10 @@ extern "C" {
#include "uart.h" #include "uart.h"
#include "comms.h" #include "comms.h"
void ShowGraphWindow(pm3_connection* conn); void ShowGraphWindow(void);
void HideGraphWindow(pm3_connection* conn); void HideGraphWindow(void);
void RepaintGraphWindow(pm3_connection* conn); void RepaintGraphWindow(void);
void MainGraphics(void); void MainGraphics(pm3_connection* conn);
void InitGraphics(int argc, char **argv, char *script_cmds_file, bool usb_present, serial_port* port, bool flush_after_write); void InitGraphics(int argc, char **argv, char *script_cmds_file, bool usb_present, serial_port* port, bool flush_after_write);
void ExitGraphics(void); void ExitGraphics(void);

View file

@ -26,6 +26,8 @@
#include <string.h> #include <string.h>
#include "proxgui.h" #include "proxgui.h"
#include <QtGui> #include <QtGui>
#include "graph.h"
#include "ui.h"
//#include <ctime> //#include <ctime>
bool g_useOverlays = false; bool g_useOverlays = false;
@ -85,7 +87,7 @@ void ProxGuiQT::_Exit(void) {
delete this; delete this;
} }
void ProxGuiQT::MainLoop() void ProxGuiQT::MainLoop(pm3_connection *conn)
{ {
plotapp = new QApplication(argc, argv); plotapp = new QApplication(argc, argv);
@ -94,6 +96,7 @@ void ProxGuiQT::MainLoop()
connect(this, SIGNAL(HideGraphWindowSignal()), this, SLOT(_HideGraphWindow())); connect(this, SIGNAL(HideGraphWindowSignal()), this, SLOT(_HideGraphWindow()));
connect(this, SIGNAL(ExitSignal()), this, SLOT(_Exit())); connect(this, SIGNAL(ExitSignal()), this, SLOT(_Exit()));
this->conn = conn;
plotapp->exec(); plotapp->exec();
} }
@ -120,19 +123,19 @@ ProxGuiQT::~ProxGuiQT(void)
void ProxWidget::applyOperation() void ProxWidget::applyOperation()
{ {
//printf("ApplyOperation()"); //printf("ApplyOperation()");
save_restoreGB(GRAPH_SAVE); save_restoreGB(master->conn, GRAPH_SAVE);
memcpy(GraphBuffer, s_Buff, sizeof(int) * GraphTraceLen); memcpy(master->conn->GraphBuffer, master->conn->s_Buff, sizeof(int) * master->conn->GraphTraceLen);
RepaintGraphWindow(); RepaintGraphWindow();
} }
void ProxWidget::stickOperation() void ProxWidget::stickOperation()
{ {
save_restoreGB(GRAPH_RESTORE); save_restoreGB(master->conn, GRAPH_RESTORE);
//printf("stickOperation()"); //printf("stickOperation()");
} }
void ProxWidget::vchange_autocorr(int v) void ProxWidget::vchange_autocorr(int v)
{ {
int ans; int ans;
ans = AutoCorrelate(GraphBuffer, s_Buff, GraphTraceLen, v, true, false); ans = AutoCorrelate(master->conn->GraphBuffer, master->conn->s_Buff, master->conn->GraphTraceLen, v, true, false);
if (g_debugMode) printf("vchange_autocorr(w:%d): %d\n", v, ans); if (g_debugMode) printf("vchange_autocorr(w:%d): %d\n", v, ans);
g_useOverlays = true; g_useOverlays = true;
RepaintGraphWindow(); RepaintGraphWindow();
@ -141,7 +144,7 @@ void ProxWidget::vchange_askedge(int v)
{ {
int ans; int ans;
//extern int AskEdgeDetect(const int *in, int *out, int len, int threshold); //extern int AskEdgeDetect(const int *in, int *out, int len, int threshold);
ans = AskEdgeDetect(GraphBuffer, s_Buff, GraphTraceLen, v); ans = AskEdgeDetect(master->conn->GraphBuffer, master->conn->s_Buff, master->conn->GraphTraceLen, v);
if (g_debugMode) printf("vchange_askedge(w:%d)%d\n", v, ans); if (g_debugMode) printf("vchange_askedge(w:%d)%d\n", v, ans);
g_useOverlays = true; g_useOverlays = true;
RepaintGraphWindow(); RepaintGraphWindow();
@ -149,7 +152,7 @@ void ProxWidget::vchange_askedge(int v)
void ProxWidget::vchange_dthr_up(int v) void ProxWidget::vchange_dthr_up(int v)
{ {
int down = opsController->horizontalSlider_dirthr_down->value(); int down = opsController->horizontalSlider_dirthr_down->value();
directionalThreshold(GraphBuffer, s_Buff, GraphTraceLen, v, down); directionalThreshold(master->conn->GraphBuffer, master->conn->s_Buff, master->conn->GraphTraceLen, v, down);
//printf("vchange_dthr_up(%d)", v); //printf("vchange_dthr_up(%d)", v);
g_useOverlays = true; g_useOverlays = true;
RepaintGraphWindow(); RepaintGraphWindow();
@ -158,7 +161,7 @@ void ProxWidget::vchange_dthr_down(int v)
{ {
//printf("vchange_dthr_down(%d)", v); //printf("vchange_dthr_down(%d)", v);
int up = opsController->horizontalSlider_dirthr_up->value(); int up = opsController->horizontalSlider_dirthr_up->value();
directionalThreshold(GraphBuffer,s_Buff, GraphTraceLen, v, up); directionalThreshold(master->conn->GraphBuffer,master->conn->s_Buff, master->conn->GraphTraceLen, v, up);
g_useOverlays = true; g_useOverlays = true;
RepaintGraphWindow(); RepaintGraphWindow();
} }
@ -194,7 +197,7 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent)
// Set up the plot widget, which does the actual plotting // Set up the plot widget, which does the actual plotting
plot = new Plot(this); plot = new Plot(this, master);
/* /*
QSlider* slider = new QSlider(Qt::Horizontal); QSlider* slider = new QSlider(Qt::Horizontal);
slider->setFocusPolicy(Qt::StrongFocus); slider->setFocusPolicy(Qt::StrongFocus);
@ -306,20 +309,20 @@ void Plot::setMaxAndStart(int *buffer, int len, QRect plotRect)
void Plot::PlotDemod(uint8_t *buffer, size_t len, QRect plotRect, QRect annotationRect, QPainter *painter, int graphNum, int plotOffset) void Plot::PlotDemod(uint8_t *buffer, size_t len, QRect plotRect, QRect annotationRect, QPainter *painter, int graphNum, int plotOffset)
{ {
if (len == 0 || PlotGridX <= 0) return; if (len == 0 || master->conn->PlotGridX <= 0) return;
//clock_t begin = clock(); //clock_t begin = clock();
QPainterPath penPath; QPainterPath penPath;
int grid_delta_x = PlotGridX; int grid_delta_x = master->conn->PlotGridX;
int first_delta_x = grid_delta_x; //(plotOffset > 0) ? PlotGridX : (PlotGridX +); int first_delta_x = grid_delta_x; //(plotOffset > 0) ? master->conn->PlotGridX : (master->conn->PlotGridX +);
if (GraphStart > plotOffset) first_delta_x -= (GraphStart-plotOffset); if (GraphStart > plotOffset) first_delta_x -= (GraphStart-plotOffset);
int DemodStart = GraphStart; int DemodStart = GraphStart;
if (plotOffset > GraphStart) DemodStart = plotOffset; if (plotOffset > GraphStart) DemodStart = plotOffset;
int BitStart = 0; int BitStart = 0;
// round down // round down
if (DemodStart-plotOffset > 0) BitStart = (int)(((DemodStart-plotOffset)+(PlotGridX-1))/PlotGridX)-1; if (DemodStart-plotOffset > 0) BitStart = (int)(((DemodStart-plotOffset)+(master->conn->PlotGridX-1))/master->conn->PlotGridX)-1;
first_delta_x += BitStart * PlotGridX; first_delta_x += BitStart * master->conn->PlotGridX;
if (BitStart > (int)len) return; if (BitStart > (int)len) return;
int delta_x = 0; int delta_x = 0;
int v = 0; int v = 0;
@ -435,26 +438,26 @@ void Plot::PlotGraph(int *buffer, int len, QRect plotRect, QRect annotationRect,
void Plot::plotGridLines(QPainter* painter,QRect r) void Plot::plotGridLines(QPainter* painter,QRect r)
{ {
// set GridOffset // set master->conn->GridOffset
if (PlotGridX <= 0) return; if (master->conn->PlotGridX <= 0) return;
int offset = GridOffset; int offset = master->conn->GridOffset;
if (GridLocked && PlotGridX) { if (master->conn->GridLocked && master->conn->PlotGridX) {
offset = GridOffset + PlotGridX - (GraphStart % PlotGridX); offset = master->conn->GridOffset + master->conn->PlotGridX - (GraphStart % master->conn->PlotGridX);
} else if (!GridLocked && GraphStart > 0 && PlotGridX) { } else if (!master->conn->GridLocked && GraphStart > 0 && master->conn->PlotGridX) {
offset = PlotGridX-((GraphStart - offset) % PlotGridX) + GraphStart - unlockStart; offset = master->conn->PlotGridX-((GraphStart - offset) % master->conn->PlotGridX) + GraphStart - unlockStart;
} }
offset %= PlotGridX; offset %= master->conn->PlotGridX;
if (offset < 0) offset += PlotGridX; if (offset < 0) offset += master->conn->PlotGridX;
int i; int i;
int grid_delta_x = (int) (PlotGridX * GraphPixelsPerPoint); int grid_delta_x = (int) (master->conn->PlotGridX * GraphPixelsPerPoint);
int grid_delta_y = PlotGridY; int grid_delta_y = master->conn->PlotGridY;
if ((PlotGridX > 0) && ((PlotGridX * GraphPixelsPerPoint) > 1)) { if ((master->conn->PlotGridX > 0) && ((master->conn->PlotGridX * GraphPixelsPerPoint) > 1)) {
for(i = (offset * GraphPixelsPerPoint); i < r.right(); i += grid_delta_x) { for(i = (offset * GraphPixelsPerPoint); i < r.right(); i += grid_delta_x) {
painter->drawLine(r.left()+i, r.top(), r.left()+i, r.bottom()); painter->drawLine(r.left()+i, r.top(), r.left()+i, r.bottom());
} }
} }
if (PlotGridY > 0) { if (master->conn->PlotGridY > 0) {
for(i = 0; yCoordOf(i,r,g_absVMax) > r.top(); i += grid_delta_y) { for(i = 0; yCoordOf(i,r,g_absVMax) > r.top(); i += grid_delta_y) {
painter->drawLine( r.left(), yCoordOf(i,r,g_absVMax), r.right(), yCoordOf(i,r,g_absVMax) ); painter->drawLine( r.left(), yCoordOf(i,r,g_absVMax), r.right(), yCoordOf(i,r,g_absVMax) );
painter->drawLine( r.left(), yCoordOf(i*-1,r,g_absVMax), r.right(), yCoordOf(i*-1,r,g_absVMax) ); painter->drawLine( r.left(), yCoordOf(i*-1,r,g_absVMax), r.right(), yCoordOf(i*-1,r,g_absVMax) );
@ -478,14 +481,14 @@ void Plot::paintEvent(QPaintEvent *event)
GraphStart = 0; GraphStart = 0;
} }
if (CursorAPos > GraphTraceLen) if (CursorAPos > master->conn->GraphTraceLen)
CursorAPos= 0; CursorAPos= 0;
if(CursorBPos > GraphTraceLen) if(CursorBPos > master->conn->GraphTraceLen)
CursorBPos= 0; CursorBPos= 0;
if(CursorCPos > GraphTraceLen) if(master->conn->CursorCPos > master->conn->GraphTraceLen)
CursorCPos= 0; master->conn->CursorCPos= 0;
if(CursorDPos > GraphTraceLen) if(master->conn->CursorDPos > master->conn->GraphTraceLen)
CursorDPos= 0; master->conn->CursorDPos= 0;
QRect plotRect(WIDTH_AXES, 0, width()-WIDTH_AXES, height()-HEIGHT_INFO); QRect plotRect(WIDTH_AXES, 0, width()-WIDTH_AXES, height()-HEIGHT_INFO);
QRect infoRect(0, height()-HEIGHT_INFO, width(), HEIGHT_INFO); QRect infoRect(0, height()-HEIGHT_INFO, width(), HEIGHT_INFO);
@ -496,7 +499,7 @@ void Plot::paintEvent(QPaintEvent *event)
painter.fillRect(plotRect, QColor(0, 0, 0)); painter.fillRect(plotRect, QColor(0, 0, 0));
//init graph variables //init graph variables
setMaxAndStart(GraphBuffer,GraphTraceLen,plotRect); setMaxAndStart(master->conn->GraphBuffer,master->conn->GraphTraceLen,plotRect);
// center line // center line
int zeroHeight = plotRect.top() + (plotRect.bottom() - plotRect.top()) / 2; int zeroHeight = plotRect.top() + (plotRect.bottom() - plotRect.top()) / 2;
@ -506,14 +509,14 @@ void Plot::paintEvent(QPaintEvent *event)
plotGridLines(&painter, plotRect); plotGridLines(&painter, plotRect);
//Start painting graph //Start painting graph
PlotGraph(GraphBuffer, GraphTraceLen,plotRect,infoRect,&painter,0); PlotGraph(master->conn->GraphBuffer, master->conn->GraphTraceLen,plotRect,infoRect,&painter,0);
if (showDemod && DemodBufferLen > 8) { if (master->conn->showDemod && master->conn->DemodBufferLen > 8) {
PlotDemod(DemodBuffer, DemodBufferLen,plotRect,infoRect,&painter,2,g_DemodStartIdx); PlotDemod(master->conn->DemodBuffer, master->conn->DemodBufferLen,plotRect,infoRect,&painter,2,master->conn->g_DemodStartIdx);
} }
if (g_useOverlays) { if (g_useOverlays) {
//init graph variables //init graph variables
setMaxAndStart(s_Buff,GraphTraceLen,plotRect); setMaxAndStart(master->conn->s_Buff,master->conn->GraphTraceLen,plotRect);
PlotGraph(s_Buff, GraphTraceLen,plotRect,infoRect,&painter,1); PlotGraph(master->conn->s_Buff, master->conn->GraphTraceLen,plotRect,infoRect,&painter,1);
} }
// End graph drawing // End graph drawing
@ -528,29 +531,31 @@ void Plot::paintEvent(QPaintEvent *event)
painter.setPen(QColor(255, 0, 255)); painter.setPen(QColor(255, 0, 255));
painter.drawLine(xCoordOf(CursorBPos, plotRect),plotRect.top(),xCoordOf(CursorBPos, plotRect),plotRect.bottom()); painter.drawLine(xCoordOf(CursorBPos, plotRect),plotRect.top(),xCoordOf(CursorBPos, plotRect),plotRect.bottom());
} }
if(CursorCPos > GraphStart && xCoordOf(CursorCPos, plotRect) < plotRect.right()) if(master->conn->CursorCPos > GraphStart && xCoordOf(master->conn->CursorCPos, plotRect) < plotRect.right())
{ {
painter.setPen(QColor(255, 153, 0)); //orange painter.setPen(QColor(255, 153, 0)); //orange
painter.drawLine(xCoordOf(CursorCPos, plotRect),plotRect.top(),xCoordOf(CursorCPos, plotRect),plotRect.bottom()); painter.drawLine(xCoordOf(master->conn->CursorCPos, plotRect),plotRect.top(),xCoordOf(master->conn->CursorCPos, plotRect),plotRect.bottom());
} }
if(CursorDPos > GraphStart && xCoordOf(CursorDPos, plotRect) < plotRect.right()) if(master->conn->CursorDPos > GraphStart && xCoordOf(master->conn->CursorDPos, plotRect) < plotRect.right())
{ {
painter.setPen(QColor(0, 0, 205)); //light blue painter.setPen(QColor(0, 0, 205)); //light blue
painter.drawLine(xCoordOf(CursorDPos, plotRect),plotRect.top(),xCoordOf(CursorDPos, plotRect),plotRect.bottom()); painter.drawLine(xCoordOf(master->conn->CursorDPos, plotRect),plotRect.top(),xCoordOf(master->conn->CursorDPos, plotRect),plotRect.bottom());
} }
//Draw annotations //Draw annotations
char str[200]; char str[200];
sprintf(str, "@%d dt=%d [%2.2f] zoom=%2.2f CursorAPos=%d CursorBPos=%d GridX=%d GridY=%d (%s) GridXoffset=%d", sprintf(str, "@%d dt=%d [%2.2f] zoom=%2.2f CursorAPos=%d CursorBPos=%d GridX=%d GridY=%d (%s) GridXoffset=%d",
GraphStart, CursorBPos - CursorAPos, (CursorBPos - CursorAPos)/CursorScaleFactor, GraphStart, CursorBPos - CursorAPos, (CursorBPos - CursorAPos)/master->conn->CursorScaleFactor,
GraphPixelsPerPoint,CursorAPos,CursorBPos,PlotGridXdefault,PlotGridYdefault,GridLocked?"Locked":"Unlocked",GridOffset); GraphPixelsPerPoint,CursorAPos,CursorBPos,master->conn->PlotGridXdefault,master->conn->PlotGridYdefault,master->conn->GridLocked?"Locked":"Unlocked",master->conn->GridOffset);
painter.setPen(QColor(255, 255, 255)); painter.setPen(QColor(255, 255, 255));
painter.drawText(20, infoRect.bottom() - 3, str); painter.drawText(20, infoRect.bottom() - 3, str);
} }
Plot::Plot(QWidget *parent) : QWidget(parent), GraphStart(0), GraphPixelsPerPoint(1) Plot::Plot(QWidget *parent, ProxGuiQT *master) : QWidget(parent), GraphStart(0), GraphPixelsPerPoint(1)
{ {
this->master = master;
//Need to set this, otherwise we don't receive keypress events //Need to set this, otherwise we don't receive keypress events
setFocusPolicy( Qt::StrongFocus); setFocusPolicy( Qt::StrongFocus);
resize(600, 300); resize(600, 300);
@ -595,8 +600,8 @@ void Plot::keyPressEvent(QKeyEvent *event)
int offset; int offset;
if(event->modifiers() & Qt::ShiftModifier) { if(event->modifiers() & Qt::ShiftModifier) {
if (PlotGridX) if (master->conn->PlotGridX)
offset= PageWidth - (PageWidth % PlotGridX); offset= PageWidth - (PageWidth % master->conn->PlotGridX);
else else
offset= PageWidth; offset= PageWidth;
} else } else
@ -635,12 +640,12 @@ void Plot::keyPressEvent(QKeyEvent *event)
break; break;
case Qt::Key_G: case Qt::Key_G:
if(PlotGridX || PlotGridY) { if(master->conn->PlotGridX || master->conn->PlotGridY) {
PlotGridX= 0; master->conn->PlotGridX= 0;
PlotGridY= 0; master->conn->PlotGridY= 0;
} else { } else {
PlotGridX= PlotGridXdefault; master->conn->PlotGridX= master->conn->PlotGridXdefault;
PlotGridY= PlotGridYdefault; master->conn->PlotGridY= master->conn->PlotGridYdefault;
} }
break; break;
@ -666,9 +671,9 @@ void Plot::keyPressEvent(QKeyEvent *event)
break; break;
case Qt::Key_L: case Qt::Key_L:
GridLocked = !GridLocked; master->conn->GridLocked = !master->conn->GridLocked;
if (GridLocked) if (master->conn->GridLocked)
GridOffset += (GraphStart - unlockStart); master->conn->GridOffset += (GraphStart - unlockStart);
else else
unlockStart = GraphStart; unlockStart = GraphStart;
break; break;

View file

@ -24,6 +24,9 @@
#include "uart.h" #include "uart.h"
#include "ui/ui_overlays.h" #include "ui/ui_overlays.h"
#include "uart.h" #include "uart.h"
#include "comms.h"
class ProxGuiQT;
/** /**
* @brief The actual plot, black area were we paint the graph * @brief The actual plot, black area were we paint the graph
@ -31,6 +34,7 @@
class Plot: public QWidget class Plot: public QWidget
{ {
private: private:
ProxGuiQT *master;
int GraphStart; int GraphStart;
double GraphPixelsPerPoint; double GraphPixelsPerPoint;
int CursorAPos; int CursorAPos;
@ -44,7 +48,7 @@ private:
void setMaxAndStart(int *buffer, int len, QRect plotRect); void setMaxAndStart(int *buffer, int len, QRect plotRect);
QColor getColor(int graphNum); QColor getColor(int graphNum);
public: public:
Plot(QWidget *parent = 0); Plot(QWidget *parent = 0, ProxGuiQT *master = NULL);
protected: protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
@ -54,7 +58,6 @@ protected:
void keyPressEvent(QKeyEvent *event); void keyPressEvent(QKeyEvent *event);
}; };
class ProxGuiQT;
/** /**
* The window with plot and controls * The window with plot and controls
@ -108,8 +111,11 @@ class ProxGuiQT : public QObject
void ShowGraphWindow(void); void ShowGraphWindow(void);
void RepaintGraphWindow(void); void RepaintGraphWindow(void);
void HideGraphWindow(void); void HideGraphWindow(void);
void MainLoop(void); void MainLoop(pm3_connection *conn);
void Exit(void); void Exit(void);
// Shared for ProxWidget
pm3_connection *conn;
private slots: private slots:
void _ShowGraphWindow(void); void _ShowGraphWindow(void);
void _RepaintGraphWindow(void); void _RepaintGraphWindow(void);
@ -132,7 +138,7 @@ public:
private: private:
char *script_cmds_file = NULL; char *script_cmds_file = NULL;
bool usb_present; bool usb_present;
serial_port *sp = NULL; serial_port *port = NULL;
bool flush_after_write = false; bool flush_after_write = false;
}; };

View file

@ -56,6 +56,11 @@ void main_loop(char *script_cmds_file, bool usb_present, serial_port* port, bool
conn.offline = true; conn.offline = true;
} }
#ifdef HAVE_GUI
// Setup GUI with reference to our connection struct.
MainGraphics(&conn);
#endif
FILE *script_file = NULL; FILE *script_file = NULL;
char script_cmd_buf[256]; // iceman, needs lua script the same file_path_buffer as the rest char script_cmd_buf[256]; // iceman, needs lua script the same file_path_buffer as the rest
@ -234,14 +239,12 @@ int main(int argc, char* argv[]) {
#ifdef HAVE_GUI #ifdef HAVE_GUI
#ifdef _WIN32 #ifdef _WIN32
InitGraphics(argc, argv, script_cmds_file, usb_present, sp, flush_after_write); InitGraphics(argc, argv, script_cmds_file, usb_present, sp, flush_after_write);
MainGraphics();
#else #else
char* display = getenv("DISPLAY"); char* display = getenv("DISPLAY");
if (display && strlen(display) > 1) if (display && strlen(display) > 1)
{ {
InitGraphics(argc, argv, script_cmds_file, usb_present, sp, flush_after_write); InitGraphics(argc, argv, script_cmds_file, usb_present, sp, flush_after_write);
MainGraphics();
} }
else else
{ {
@ -249,7 +252,7 @@ int main(int argc, char* argv[]) {
} }
#endif #endif
#else #else
main_loop(script_cmds_file, usb_present, sp); main_loop(script_cmds_file, usb_present, sp, flush_after_write);
#endif #endif
// Clean up the port // Clean up the port

View file

@ -21,9 +21,9 @@ pthread_mutex_t print_lock;
extern uint8_t g_debugMode; extern uint8_t g_debugMode;
void ShowGui(void); void ShowGui(void);
void HideGraphWindow(pm3_connection* conn); void HideGraphWindow();
void ShowGraphWindow(pm3_connection* conn); void ShowGraphWindow();
void RepaintGraphWindow(pm3_connection* conn); void RepaintGraphWindow();
void PrintAndLog(char *fmt, ...); void PrintAndLog(char *fmt, ...);
void SetLogFilename(char *fn); void SetLogFilename(char *fn);
void SetFlushAfterWrite(bool flush_after_write); void SetFlushAfterWrite(bool flush_after_write);