Added many additional graphing modes. They are loaded/saved in graph

definitions as well.

Incremented version number.
This commit is contained in:
Collin Kidder
2021-02-18 21:41:42 -05:00
parent b26aeac132
commit 2a03b4f35d
6 changed files with 309 additions and 133 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef CONFIG
#define CONFIG
#define VERSION 201
#define VERSION 202
//try to keep this in sync.
//SavvyCAN will complain if you connect a GVRET board with a revision
+78 -15
View File
@@ -78,7 +78,8 @@ GraphingWindow::GraphingWindow(const QVector<CANFrame> *frames, QWidget *parent)
ui->graphingView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->graphingView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequest(QPoint)));
selectedPen.setWidth(1);
selectedPen.setWidth(3);
selectedPen.setStyle(Qt::DashLine);
selectedPen.setColor(Qt::blue);
//ui->graphingView->setAttribute(Qt::WA_AcceptTouchEvents);
@@ -842,13 +843,36 @@ void GraphingWindow::saveDefinitions()
outFile->putChar(',');
outFile->write(QString::number(iter->stride).toUtf8());
outFile->putChar(',');
outFile->write(QString::number(iter->color.red()).toUtf8());
outFile->write(QString::number(iter->lineColor.red()).toUtf8());
outFile->putChar(',');
outFile->write(QString::number(iter->color.green()).toUtf8());
outFile->write(QString::number(iter->lineColor.green()).toUtf8());
outFile->putChar(',');
outFile->write(QString::number(iter->color.blue()).toUtf8());
outFile->write(QString::number(iter->lineColor.blue()).toUtf8());
outFile->putChar(',');
outFile->write(iter->graphName.toUtf8());
outFile->putChar(',');
outFile->write(QString::number(iter->fillColor.red()).toUtf8());
outFile->putChar(',');
outFile->write(QString::number(iter->fillColor.green()).toUtf8());
outFile->putChar(',');
outFile->write(QString::number(iter->fillColor.blue()).toUtf8());
outFile->putChar(',');
outFile->write(QString::number(iter->fillColor.alpha()).toUtf8());
outFile->putChar(',');
if (iter->drawOnlyPoints) outFile->putChar('Y');
else outFile->putChar('N');
outFile->putChar(',');
outFile->write(QString::number(iter->pointType).toUtf8());
outFile->putChar(',');
outFile->write(QString::number(iter->lineWidth).toUtf8());
if (iter->associatedSignal)
{
outFile->putChar(',');
outFile->write(iter->associatedSignal->parentMessage->name.toUtf8());
outFile->putChar(',');
outFile->write(iter->associatedSignal->name.toUtf8());
}
outFile->write("\n");
}
outFile->close();
@@ -891,6 +915,8 @@ void GraphingWindow::loadDefinitions()
QList<QByteArray> tokens = line.split(',');
gp.associatedSignal = nullptr; //might not be saved in the graph definition so default it to nothing
if (tokens[0] == "X") //newest format based around signals
{
gp.ID = tokens[1].toUInt(nullptr, 16);
@@ -908,13 +934,34 @@ void GraphingWindow::loadDefinitions()
gp.scale = tokens[7].toFloat();
gp.stride = tokens[8].toInt();
gp.color.setRed(tokens[9].toInt());
gp.color.setGreen(tokens[10].toInt());
gp.color.setBlue(tokens[11].toInt());
gp.lineColor.setRed( tokens[9].toInt() );
gp.lineColor.setGreen( tokens[10].toInt() );
gp.lineColor.setBlue( tokens[11].toInt() );
if (tokens.length() > 12)
gp.graphName = tokens[12];
else
gp.graphName = QString();
if (tokens.length() > 19) //even newer format with extra graph formatting options
{
gp.fillColor.setRed( tokens[13].toInt() );
gp.fillColor.setGreen( tokens[14].toInt() );
gp.fillColor.setBlue( tokens[15].toInt() );
gp.fillColor.setAlpha( tokens[16].toInt() );
if (tokens[17] == "Y") gp.drawOnlyPoints = true;
else gp.drawOnlyPoints = false;
gp.pointType = tokens[18].toInt();
gp.lineWidth = tokens[19].toInt();
}
if (tokens.length() > 21)
{
DBC_MESSAGE *msg = dbcHandler->findMessage(tokens[20]);
if (msg)
{
gp.associatedSignal = msg->sigHandler->findSignalByName(tokens[21]);
}
else qDebug() << "Couldn't find the message by name! " << tokens[20] << " " << tokens[21];
}
createGraph(gp, true);
}
else //one of the two older formats then
@@ -931,9 +978,9 @@ void GraphingWindow::loadDefinitions()
{
gp.mask = 0xFFFFFFFF;
gp.bias = (float)sig->bias;
gp.color.setRed(tokens[3].toInt());
gp.color.setGreen(tokens[4].toInt());
gp.color.setBlue(tokens[5].toInt());
gp.lineColor.setRed(tokens[3].toInt());
gp.lineColor.setGreen(tokens[4].toInt());
gp.lineColor.setBlue(tokens[5].toInt());
gp.graphName = sig->name;
gp.intelFormat = sig->intelByteOrder;
if (sig->valType == SIGNED_INT) gp.isSigned = true;
@@ -1020,9 +1067,9 @@ void GraphingWindow::loadDefinitions()
gp.bias = tokens[5].toFloat();
gp.scale = tokens[6].toFloat();
gp.stride = tokens[7].toInt();
gp.color.setRed(tokens[8].toInt());
gp.color.setGreen(tokens[9].toInt());
gp.color.setBlue(tokens[10].toInt());
gp.lineColor.setRed(tokens[8].toInt());
gp.lineColor.setGreen(tokens[9].toInt());
gp.lineColor.setBlue(tokens[10].toInt());
if (tokens.length() > 11)
gp.graphName = tokens[11];
else
@@ -1194,11 +1241,27 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
ui->graphingView->graph()->setProperty("id", params.ID);
ui->graphingView->graph()->setData(refParam->x,refParam->y);
ui->graphingView->graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)params.pointType));
if (params.drawOnlyPoints) ui->graphingView->graph()->setLineStyle(QCPGraph::lsNone); //Draw only the points, no connections, no fills
else
{
ui->graphingView->graph()->setLineStyle(QCPGraph::lsLine); //connect points with lines
}
QPen graphPen;
graphPen.setColor(params.color);
graphPen.setWidth(1);
graphPen.setColor(params.lineColor);
graphPen.setWidth(params.lineWidth);
ui->graphingView->graph()->setPen(graphPen);
if (params.fillColor.alpha() > 0) //only if there is some opacity will we set up a fill brush
{
qDebug() << "Drawing filled graph";
QBrush fillBrush;
fillBrush.setColor(params.fillColor);
fillBrush.setStyle(Qt::SolidPattern);
ui->graphingView->graph()->setBrush(fillBrush);
}
qDebug() << "xmin: " << xminval;
qDebug() << "xmax: " << xmaxval;
+5 -1
View File
@@ -23,7 +23,11 @@ public:
double scale;
int stride;
int strideSoFar;
QColor color;
QColor lineColor;
QColor fillColor;
int lineWidth;
bool drawOnlyPoints;
int pointType;
QCPGraph *ref;
QString graphName;
DBC_SIGNAL *associatedSignal;
+43 -2
View File
@@ -14,6 +14,7 @@ NewGraphDialog::NewGraphDialog(DBCHandler *handler, QWidget *parent) :
dbcHandler = handler;
connect(ui->colorSwatch, SIGNAL(clicked(bool)), this, SLOT(colorSwatchClick()));
connect(ui->fillSwatch, SIGNAL(clicked(bool)), this, SLOT(fillSwatchClick()));
connect(ui->btnAddGraph, SIGNAL(clicked(bool)), this, SLOT(addButtonClicked()));
QPalette p = ui->colorSwatch->palette();
@@ -21,6 +22,27 @@ NewGraphDialog::NewGraphDialog(DBCHandler *handler, QWidget *parent) :
p.setColor(QPalette::Button, QColor(QRandomGenerator::global()->bounded(160),QRandomGenerator::global()->bounded(160), QRandomGenerator::global()->bounded(160)));
ui->colorSwatch->setPalette(p);
QPalette p2 = ui->fillSwatch->palette();
p2.setColor(QPalette::Button, QColor(128,128,128,0)); //light gray, no opacity so it is disabled by default
ui->fillSwatch->setPalette(p2);
ui->coPointStyle->addItem("None");
ui->coPointStyle->addItem("Dot");
ui->coPointStyle->addItem("Cross");
ui->coPointStyle->addItem("Plus");
ui->coPointStyle->addItem("Circle");
ui->coPointStyle->addItem("Disc");
ui->coPointStyle->addItem("Square");
ui->coPointStyle->addItem("Diamond");
ui->coPointStyle->addItem("Star");
ui->coPointStyle->addItem("Triangle");
ui->coPointStyle->addItem("TriangleInverted");
ui->coPointStyle->addItem("Cross Inside Square");
ui->coPointStyle->addItem("Plus Inside Square");
ui->coPointStyle->addItem("Cross Inside Circle");
ui->coPointStyle->addItem("Plus Inside Circle");
ui->coPointStyle->addItem("Peace Sign");
connect(ui->cbMessages, SIGNAL(currentIndexChanged(int)), this, SLOT(loadSignals(int)));
connect(ui->gridData, SIGNAL(gridClicked(int,int)), this, SLOT(bitfieldClicked(int,int)));
connect(ui->txtDataLen, SIGNAL(textChanged(QString)), this, SLOT(handleDataLenUpdate()));
@@ -81,7 +103,15 @@ void NewGraphDialog::colorSwatchClick()
QPalette p = ui->colorSwatch->palette();
p.setColor(QPalette::Button, newColor);
ui->colorSwatch->setPalette(p);
}
void NewGraphDialog::fillSwatchClick()
{
QColor newColor = QColorDialog::getColor(ui->fillSwatch->palette().button().color(), nullptr, "Pick A Color", QColorDialog::ShowAlphaChannel);
QPalette p = ui->fillSwatch->palette();
p.setColor(QPalette::Button, newColor);
ui->fillSwatch->setPalette(p);
}
//check whether the current values on the left match the signal selected on the right
@@ -170,8 +200,14 @@ void NewGraphDialog::setParams(GraphParams &params)
ui->txtID->setText(Utility::formatCANID(params.ID));
ui->txtName->setText(params.graphName);
QPalette p = ui->colorSwatch->palette();
p.setColor(QPalette::Button, params.color);
p.setColor(QPalette::Button, params.lineColor);
ui->colorSwatch->setPalette(p);
QPalette p2 = ui->fillSwatch->palette();
p2.setColor(QPalette::Button, params.fillColor);
ui->fillSwatch->setPalette(p2);
ui->cbOnlyPoints->setChecked(params.drawOnlyPoints);
ui->spinLineWidth->setValue(params.lineWidth);
ui->coPointStyle->setCurrentIndex(params.pointType);
assocSignal = params.associatedSignal;
@@ -183,9 +219,14 @@ void NewGraphDialog::setParams(GraphParams &params)
void NewGraphDialog::getParams(GraphParams &params)
{
params.color = ui->colorSwatch->palette().button().color();
params.lineColor = ui->colorSwatch->palette().button().color();
params.fillColor = ui->fillSwatch->palette().button().color();
params.graphName = ui->txtName->text();
params.lineWidth = ui->spinLineWidth->value();
params.drawOnlyPoints = ui->cbOnlyPoints->isChecked();
params.pointType = ui->coPointStyle->currentIndex();
params.ID = Utility::ParseStringToNum(ui->txtID->text());
params.bias = ui->txtBias->text().toFloat();
params.isSigned = ui->cbSigned->isChecked();
+1
View File
@@ -24,6 +24,7 @@ public:
private slots:
void addButtonClicked();
void colorSwatchClick();
void fillSwatchClick();
void loadMessages();
void loadSignals(int idx);
void bitfieldClicked(int,int);
+179 -112
View File
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>681</width>
<height>670</height>
<height>806</height>
</rect>
</property>
<property name="windowTitle">
@@ -18,6 +18,16 @@
<layout class="QHBoxLayout" name="horizontalLayout" stretch="3,2">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Name:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="txtName"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
@@ -35,100 +45,6 @@
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Signed:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="cbSigned">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_4">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string>Mask:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="txtMask"/>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Bias:</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="txtBias"/>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Scale</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLineEdit" name="txtScale"/>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Stride</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QLineEdit" name="txtStride"/>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QPushButton" name="colorSwatch">
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text">
<string>CHANGE</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QPushButton" name="btnAddGraph">
<property name="text">
<string>Add this graph</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Name:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="txtName"/>
</item>
<item row="2" column="1">
<widget class="CANDataGrid" name="gridData" native="true">
<property name="minimumSize">
@@ -145,20 +61,6 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Little Endian</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="cbIntel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
@@ -169,13 +71,178 @@
<item row="3" column="1">
<widget class="QLineEdit" name="txtDataLen"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_15">
<item row="4" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>(LSB First)</string>
<string>Little Endian</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="cbIntel">
<property name="text">
<string> (LSB First)</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Signed:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="cbSigned">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_4">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string>Mask:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="txtMask"/>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Bias:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="txtBias"/>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Scale</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="txtScale"/>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Stride</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLineEdit" name="txtStride"/>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Only Points</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QCheckBox" name="cbOnlyPoints">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Point Style</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QComboBox" name="coPointStyle"/>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Line Thickness</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QSpinBox" name="spinLineWidth">
<property name="maximum">
<number>15</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Line Color</string>
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QPushButton" name="colorSwatch">
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text">
<string>CHANGE</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="label55">
<property name="text">
<string>Fill Color</string>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QPushButton" name="fillSwatch">
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text">
<string>CHANGE</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="16" column="1">
<widget class="QPushButton" name="btnAddGraph">
<property name="text">
<string>Add this graph</string>
</property>
</widget>
</item>
<item row="10" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>