Added hex labeling option to graphs in flowview and frame info windows, a few tweaks for potential QT6 support

This commit is contained in:
Collin Kidder
2021-09-06 19:25:59 -04:00
parent da0f1fe87e
commit 1f421c5d2c
11 changed files with 75 additions and 12 deletions
+3 -1
View File
@@ -4,7 +4,7 @@
# #
#------------------------------------------------- #-------------------------------------------------
QT = core gui printsupport qml serialbus serialport widgets help network QT = core gui printsupport qml serialbus serialport widgets help network opengl
CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT
@@ -33,6 +33,7 @@ SOURCES += main.cpp\
mqtt/qmqtt_timer.cpp \ mqtt/qmqtt_timer.cpp \
mqtt/qmqtt_websocket.cpp \ mqtt/qmqtt_websocket.cpp \
mqtt/qmqtt_websocketiodevice.cpp \ mqtt/qmqtt_websocketiodevice.cpp \
qcpaxistickerhex.cpp \
re/dbccomparatorwindow.cpp \ re/dbccomparatorwindow.cpp \
mainwindow.cpp \ mainwindow.cpp \
canframemodel.cpp \ canframemodel.cpp \
@@ -117,6 +118,7 @@ HEADERS += mainwindow.h \
mqtt/qmqtt_timerinterface.h \ mqtt/qmqtt_timerinterface.h \
mqtt/qmqtt_websocket_p.h \ mqtt/qmqtt_websocket_p.h \
mqtt/qmqtt_websocketiodevice_p.h \ mqtt/qmqtt_websocketiodevice_p.h \
qcpaxistickerhex.h \
re/dbccomparatorwindow.h \ re/dbccomparatorwindow.h \
simplecrypt.h \ simplecrypt.h \
utility.h \ utility.h \
+8 -1
View File
@@ -28,7 +28,9 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
//defaults if nothing was stored (if this is the first time) //defaults if nothing was stored (if this is the first time)
ui->cbDisplayHex->setChecked(settings.value("Main/UseHex", true).toBool()); ui->cbDisplayHex->setChecked(settings.value("Main/UseHex", true).toBool());
ui->cbFlowAutoRef->setChecked(settings.value("FlowView/AutoRef", false).toBool()); ui->cbFlowAutoRef->setChecked(settings.value("FlowView/AutoRef", false).toBool());
ui->cbHexGraphFlow->setChecked(settings.value("FlowView/GraphHex", false).toBool());
ui->cbFlowUseTimestamp->setChecked(settings.value("FlowView/UseTimestamp", true).toBool()); ui->cbFlowUseTimestamp->setChecked(settings.value("FlowView/UseTimestamp", true).toBool());
ui->cbHexGraphInfo->setChecked(settings.value("InfoCompare/GraphHex", false).toBool());
ui->cbInfoAutoExpand->setChecked(settings.value("InfoCompare/AutoExpand", false).toBool()); ui->cbInfoAutoExpand->setChecked(settings.value("InfoCompare/AutoExpand", false).toBool());
ui->cbMainAutoScroll->setChecked(settings.value("Main/AutoScroll", false).toBool()); ui->cbMainAutoScroll->setChecked(settings.value("Main/AutoScroll", false).toBool());
ui->cbPlaybackLoop->setChecked(settings.value("Playback/AutoLoop", false).toBool()); ui->cbPlaybackLoop->setChecked(settings.value("Playback/AutoLoop", false).toBool());
@@ -74,7 +76,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
ui->comboSendingBus->setCurrentIndex(settings.value("Playback/SendingBus", 4).toInt()); ui->comboSendingBus->setCurrentIndex(settings.value("Playback/SendingBus", 4).toInt());
ui->cbUseFiltered->setChecked(settings.value("Main/UseFiltered", false).toBool()); ui->cbUseFiltered->setChecked(settings.value("Main/UseFiltered", false).toBool());
ui->cbUseOpenGL->setChecked(settings.value("Main/UseOpenGL", false).toBool()); ui->cbUseOpenGL->setChecked(settings.value("Main/UseOpenGL", false).toBool());
ui->cbFilterLabeling->setChecked(settings.value("Main/FilterLabeling", false).toBool()); ui->cbFilterLabeling->setChecked(settings.value("Main/FilterLabeling", true).toBool());
//just for simplicity they all call the same function and that function updates all settings at once //just for simplicity they all call the same function and that function updates all settings at once
connect(ui->cbDisplayHex, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); connect(ui->cbDisplayHex, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
@@ -99,6 +101,9 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
connect(ui->lineRemotePassword, SIGNAL(editingFinished()), this, SLOT(updateSettings())); connect(ui->lineRemotePassword, SIGNAL(editingFinished()), this, SLOT(updateSettings()));
connect(ui->cbLoadConnections, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); connect(ui->cbLoadConnections, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
connect(ui->cbFilterLabeling, SIGNAL(toggled(bool)), this, SLOT(updateSettings())); connect(ui->cbFilterLabeling, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
connect(ui->cbHexGraphFlow, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
connect(ui->cbHexGraphInfo, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
installEventFilter(this); installEventFilter(this);
} }
@@ -140,6 +145,8 @@ void MainSettingsDialog::updateSettings()
settings.setValue("Main/UseHex", ui->cbDisplayHex->isChecked()); settings.setValue("Main/UseHex", ui->cbDisplayHex->isChecked());
settings.setValue("FlowView/AutoRef", ui->cbFlowAutoRef->isChecked()); settings.setValue("FlowView/AutoRef", ui->cbFlowAutoRef->isChecked());
settings.setValue("FlowView/UseTimestamp", ui->cbFlowUseTimestamp->isChecked()); settings.setValue("FlowView/UseTimestamp", ui->cbFlowUseTimestamp->isChecked());
settings.setValue("FlowView/GraphHex", ui->cbHexGraphFlow->isChecked());
settings.setValue("InfoCompare/GraphHex", ui->cbHexGraphInfo->isChecked());
settings.setValue("InfoCompare/AutoExpand", ui->cbInfoAutoExpand->isChecked()); settings.setValue("InfoCompare/AutoExpand", ui->cbInfoAutoExpand->isChecked());
settings.setValue("Main/AutoScroll", ui->cbMainAutoScroll->isChecked()); settings.setValue("Main/AutoScroll", ui->cbMainAutoScroll->isChecked());
settings.setValue("Playback/AutoLoop", ui->cbPlaybackLoop->isChecked()); settings.setValue("Playback/AutoLoop", ui->cbPlaybackLoop->isChecked());
+8
View File
@@ -0,0 +1,8 @@
#include <Qt>
#include "qcpaxistickerhex.h"
QString QCPAxisTickerHex::getTickLabel (double tick, const QLocale &locale, QChar formatChar, int precision)
{
int64_t hexVal = static_cast<int64_t>(tick);
return QString::number(hexVal, 16);
}
+12
View File
@@ -0,0 +1,12 @@
#ifndef QCPAXISTICKERHEX_H
#define QCPAXISTICKERHEX_H
#include "qcustomplot.h"
class QCPAxisTickerHex: public QCPAxisTicker
{
public:
QString getTickLabel (double tick, const QLocale &locale, QChar formatChar, int precision);
};
#endif // QCPAXISTICKERHEX_H
+11 -1
View File
@@ -3,6 +3,7 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "helpwindow.h" #include "helpwindow.h"
#include "filterutility.h" #include "filterutility.h"
#include "qcpaxistickerhex.h"
const QColor FlowViewWindow::graphColors[8] = {Qt::blue, Qt::green, Qt::black, Qt::red, //0 1 2 3 const QColor FlowViewWindow::graphColors[8] = {Qt::blue, Qt::green, Qt::black, Qt::red, //0 1 2 3
Qt::gray, Qt::yellow, Qt::cyan, Qt::darkMagenta}; //4 5 6 7 Qt::gray, Qt::yellow, Qt::cyan, Qt::darkMagenta}; //4 5 6 7
@@ -34,6 +35,11 @@ FlowViewWindow::FlowViewWindow(const QVector<CANFrame> *frames, QWidget *parent)
ui->graphView->xAxis->setRange(0, 8); ui->graphView->xAxis->setRange(0, 8);
ui->graphView->yAxis->setRange(-10, 265); //run range a bit outside possible number so they aren't plotted in a hard to see place ui->graphView->yAxis->setRange(-10, 265); //run range a bit outside possible number so they aren't plotted in a hard to see place
if (useHexTicker)
{
QSharedPointer<QCPAxisTickerHex> hexTicker(new QCPAxisTickerHex);
ui->graphView->yAxis->setTicker(hexTicker);
}
ui->graphView->axisRect()->setupFullAxesBox(); ui->graphView->axisRect()->setupFullAxesBox();
QCPItemText *textLabel = new QCPItemText(ui->graphView); QCPItemText *textLabel = new QCPItemText(ui->graphView);
@@ -46,7 +52,9 @@ FlowViewWindow::FlowViewWindow(const QVector<CANFrame> *frames, QWidget *parent)
textLabel->setPen(QPen(Qt::black)); // show black border around text textLabel->setPen(QPen(Qt::black)); // show black border around text
ui->graphView->xAxis->setLabel("Time Axis"); ui->graphView->xAxis->setLabel("Time Axis");
ui->graphView->yAxis->setLabel("Value Axis"); if (useHexTicker) ui->graphView->yAxis->setLabel("Value Axis (HEX)");
else ui->graphView->yAxis->setLabel("Value Axis (dec)");
QFont legendFont = font(); QFont legendFont = font();
legendFont.setPointSize(10); legendFont.setPointSize(10);
QFont legendSelectedFont = font(); QFont legendSelectedFont = font();
@@ -150,6 +158,7 @@ void FlowViewWindow::closeEvent(QCloseEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
writeSettings(); writeSettings();
emit rejected(); //can be picked up by main window if needed
} }
void FlowViewWindow::readSettings() void FlowViewWindow::readSettings()
@@ -178,6 +187,7 @@ void FlowViewWindow::readSettings()
secondsMode = settings.value("Main/TimeSeconds", false).toBool(); secondsMode = settings.value("Main/TimeSeconds", false).toBool();
openGLMode = settings.value("Main/UseOpenGL", false).toBool(); openGLMode = settings.value("Main/UseOpenGL", false).toBool();
useHexTicker = settings.value("FlowView/GraphHex", false).toBool();
} }
void FlowViewWindow::writeSettings() void FlowViewWindow::writeSettings()
+1
View File
@@ -58,6 +58,7 @@ private:
static const QColor graphColors[8]; static const QColor graphColors[8];
bool secondsMode; bool secondsMode;
bool openGLMode; bool openGLMode;
bool useHexTicker;
QVector<double> x[8], y[8]; QVector<double> x[8], y[8];
QCPGraph *graphRef[8]; QCPGraph *graphRef[8];
+10 -2
View File
@@ -5,6 +5,7 @@
#include <QtDebug> #include <QtDebug>
#include <vector> #include <vector>
#include "filterutility.h" #include "filterutility.h"
#include "qcpaxistickerhex.h"
const QColor FrameInfoWindow::byteGraphColors[8] = {Qt::blue, Qt::green, Qt::black, Qt::red, //0 1 2 3 const QColor FrameInfoWindow::byteGraphColors[8] = {Qt::blue, Qt::green, Qt::black, Qt::red, //0 1 2 3
Qt::gray, Qt::yellow, Qt::cyan, Qt::darkMagenta}; //4 5 6 7 Qt::gray, Qt::yellow, Qt::cyan, Qt::darkMagenta}; //4 5 6 7
@@ -57,10 +58,16 @@ FrameInfoWindow::FrameInfoWindow(const QVector<CANFrame> *frames, QWidget *paren
ui->graphBytes->xAxis->setRange(0, 63); ui->graphBytes->xAxis->setRange(0, 63);
ui->graphBytes->yAxis->setRange(0, 265); ui->graphBytes->yAxis->setRange(0, 265);
if (useHexTicker)
{
QSharedPointer<QCPAxisTickerHex> hexTicker(new QCPAxisTickerHex);
ui->graphBytes->yAxis->setTicker(hexTicker);
}
ui->graphBytes->axisRect()->setupFullAxesBox(); ui->graphBytes->axisRect()->setupFullAxesBox();
ui->graphBytes->xAxis->setLabel("Time"); ui->graphBytes->xAxis->setLabel("Time");
ui->graphBytes->yAxis->setLabel("Value"); if (useHexTicker) ui->graphBytes->yAxis->setLabel("Value (HEX)");
else ui->graphBytes->yAxis->setLabel("Value (Dec)");
ui->graphBytes->legend->setVisible(false); ui->graphBytes->legend->setVisible(false);
@@ -154,6 +161,7 @@ void FrameInfoWindow::closeEvent(QCloseEvent *event)
{ {
Q_UNUSED(event) Q_UNUSED(event)
writeSettings(); writeSettings();
emit rejected();
} }
void FrameInfoWindow::readSettings() void FrameInfoWindow::readSettings()
@@ -175,7 +183,7 @@ void FrameInfoWindow::readSettings()
move(Utility::constrainedWindowPos(settings.value("FrameInfo/WindowPos", QPoint(50, 50)).toPoint())); move(Utility::constrainedWindowPos(settings.value("FrameInfo/WindowPos", QPoint(50, 50)).toPoint()));
} }
useOpenGL = settings.value("Main/UseOpenGL", false).toBool(); useOpenGL = settings.value("Main/UseOpenGL", false).toBool();
useHexTicker = settings.value("InfoCompare/GraphHex", false).toBool();
} }
void FrameInfoWindow::writeSettings() void FrameInfoWindow::writeSettings()
+1
View File
@@ -34,6 +34,7 @@ private:
QList<CANFrame> frameCache; QList<CANFrame> frameCache;
const QVector<CANFrame> *modelFrames; const QVector<CANFrame> *modelFrames;
bool useOpenGL; bool useOpenGL;
bool useHexTicker;
static const QColor byteGraphColors[8]; static const QColor byteGraphColors[8];
static QPen bytePens[8]; static QPen bytePens[8];
DBCHandler *dbcHandler; DBCHandler *dbcHandler;
+14
View File
@@ -197,6 +197,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="cbHexGraphFlow">
<property name="text">
<string>Hexadecimal Graph Y Axis</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@@ -281,6 +288,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="cbHexGraphInfo">
<property name="text">
<string>Hexadecimal Graph Y Axis</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
+1 -1
View File
@@ -8,7 +8,7 @@
#include <QDebug> #include <QDebug>
#include <QApplication> #include <QApplication>
#include <QRect> #include <QRect>
#include <QDesktopWidget> //#include <QDesktopWidget>
class Utility class Utility
{ {
+6 -6
View File
@@ -6,8 +6,8 @@
/* macros */ /* macros */
#define IS_EMPTY() ( mWIdx.load() == mRIdx.load() ) #define IS_EMPTY() ( mWIdx.loadAcquire() == mRIdx.loadAcquire() )
#define IS_FULL() ( (mWIdx.load()+1)%mSize == mRIdx.load() ) #define IS_FULL() ( (mWIdx.loadAcquire()+1)%mSize == mRIdx.loadAcquire() )
template<class T> template<class T>
@@ -38,8 +38,8 @@ public:
} }
void flush() { void flush() {
mRIdx.store(0); mRIdx.storeRelease(0);
mWIdx.store(0); mWIdx.storeRelease(0);
} }
T* get() { T* get() {
@@ -56,7 +56,7 @@ public:
qCritical() << "BUG: queueing in full queue"; qCritical() << "BUG: queueing in full queue";
#endif #endif
int wIdx = mWIdx.load(); int wIdx = mWIdx.loadAcquire();
mWIdx.storeRelease((wIdx+1)%mSize); mWIdx.storeRelease((wIdx+1)%mSize);
} }
@@ -75,7 +75,7 @@ public:
qCritical() << "BUG: dequeueing an empty queue"; qCritical() << "BUG: dequeueing an empty queue";
#endif #endif
int rIdx = mRIdx.load(); int rIdx = mRIdx.loadAcquire();
mRIdx.storeRelease((rIdx+1)%mSize); mRIdx.storeRelease((rIdx+1)%mSize);
} }