syntax sugar

This commit is contained in:
iceman1001 2017-08-11 18:15:01 +02:00
commit dc0e0aa93f
3 changed files with 53 additions and 53 deletions

View file

@ -31,7 +31,6 @@ extern "C" void ShowGraphWindow(void)
{ {
if (!gui) if (!gui)
return; return;
gui->ShowGraphWindow(); gui->ShowGraphWindow();
} }
@ -39,7 +38,6 @@ extern "C" void HideGraphWindow(void)
{ {
if (!gui) if (!gui)
return; return;
gui->HideGraphWindow(); gui->HideGraphWindow();
} }

View file

@ -26,7 +26,6 @@
#include <string.h> #include <string.h>
#include "proxgui.h" #include "proxgui.h"
#include <QtGui> #include <QtGui>
// #include <ctime>
bool g_useOverlays = false; bool g_useOverlays = false;
int g_absVMax = 0; int g_absVMax = 0;
@ -434,16 +433,14 @@ void Plot::plotGridLines(QPainter* painter,QRect r) {
void Plot::paintEvent(QPaintEvent *event) void Plot::paintEvent(QPaintEvent *event)
{ {
QPainter painter(this); QPainter painter(this);
QBrush brush(QColor(100, 255, 100)); QBrush brush(QColor(100, 255, 100));
QPen pen(QColor(100, 255, 100)); QPen pen(QColor(100, 255, 100));
painter.setFont(QFont("Courier New", 10)); painter.setFont(QFont("Courier New", 10));
if(GraphStart < 0) { if(GraphStart < 0)
GraphStart = 0; GraphStart = 0;
}
if (CursorAPos > GraphTraceLen) if (CursorAPos > GraphTraceLen)
CursorAPos= 0; CursorAPos= 0;
@ -485,23 +482,19 @@ void Plot::paintEvent(QPaintEvent *event)
// End graph drawing // End graph drawing
//Draw the cursors //Draw the cursors
if(CursorAPos > GraphStart && xCoordOf(CursorAPos, plotRect) < plotRect.right()) if (CursorAPos > GraphStart && xCoordOf(CursorAPos, plotRect) < plotRect.right()) {
{
painter.setPen(QColor(255, 255, 0)); painter.setPen(QColor(255, 255, 0));
painter.drawLine(xCoordOf(CursorAPos, plotRect),plotRect.top(),xCoordOf(CursorAPos, plotRect),plotRect.bottom()); painter.drawLine(xCoordOf(CursorAPos, plotRect),plotRect.top(),xCoordOf(CursorAPos, plotRect),plotRect.bottom());
} }
if(CursorBPos > GraphStart && xCoordOf(CursorBPos, plotRect) < plotRect.right()) if (CursorBPos > GraphStart && xCoordOf(CursorBPos, plotRect) < plotRect.right()) {
{
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 (CursorCPos > GraphStart && xCoordOf(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(CursorCPos, plotRect),plotRect.top(),xCoordOf(CursorCPos, plotRect),plotRect.bottom());
} }
if(CursorDPos > GraphStart && xCoordOf(CursorDPos, plotRect) < plotRect.right()) if (CursorDPos > GraphStart && xCoordOf(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(CursorDPos, plotRect),plotRect.top(),xCoordOf(CursorDPos, plotRect),plotRect.bottom());
} }
@ -509,11 +502,19 @@ void Plot::paintEvent(QPaintEvent *event)
//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,
GraphPixelsPerPoint,CursorAPos,CursorBPos,PlotGridXdefault,PlotGridYdefault,GridLocked?"Locked":"Unlocked",GridOffset); CursorBPos - CursorAPos,
(CursorBPos - CursorAPos)/CursorScaleFactor,
GraphPixelsPerPoint,
CursorAPos,
CursorBPos,
PlotGridXdefault,
PlotGridYdefault,
GridLocked ? "Locked" : "Unlocked",
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) : QWidget(parent), GraphStart(0), GraphPixelsPerPoint(1)
@ -552,8 +553,6 @@ void Plot::mouseMoveEvent(QMouseEvent *event)
} else if (event->buttons() & Qt::RightButton) { } else if (event->buttons() & Qt::RightButton) {
CursorBPos = x; CursorBPos = x;
} }
this->update(); this->update();
} }

View file

@ -40,6 +40,7 @@ class Plot: public QWidget
int valueOf_yCoord(int y, QRect r, int maxVal); int valueOf_yCoord(int y, QRect r, int maxVal);
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);
@ -49,7 +50,6 @@ class Plot: public QWidget
void mouseMoveEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event) { mouseMoveEvent(event); } void mousePressEvent(QMouseEvent *event) { mouseMoveEvent(event); }
void keyPressEvent(QKeyEvent *event); void keyPressEvent(QKeyEvent *event);
}; };
class ProxGuiQT; class ProxGuiQT;
@ -107,11 +107,13 @@ class ProxGuiQT : public QObject
void HideGraphWindow(void); void HideGraphWindow(void);
void MainLoop(void); void MainLoop(void);
void Exit(void); void Exit(void);
private slots: private slots:
void _ShowGraphWindow(void); void _ShowGraphWindow(void);
void _RepaintGraphWindow(void); void _RepaintGraphWindow(void);
void _HideGraphWindow(void); void _HideGraphWindow(void);
void _Exit(void); void _Exit(void);
signals: signals:
void ShowGraphWindowSignal(void); void ShowGraphWindowSignal(void);
void RepaintGraphWindowSignal(void); void RepaintGraphWindowSignal(void);
@ -119,13 +121,14 @@ class ProxGuiQT : public QObject
void ExitSignal(void); void ExitSignal(void);
}; };
class WorkerThread : public QThread { class WorkerThread : public QThread {
Q_OBJECT; Q_OBJECT;
public: public:
WorkerThread(char*, bool); WorkerThread(char*, bool);
~WorkerThread(); ~WorkerThread();
void run(); void run();
private: private:
char *script_cmds_file = NULL; char *script_cmds_file = NULL;
bool usb_present; bool usb_present;