diff --git a/config.h b/config.h index 0e8517d..f09c682 100644 --- a/config.h +++ b/config.h @@ -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 diff --git a/re/graphingwindow.cpp b/re/graphingwindow.cpp index 82be855..331de61 100644 --- a/re/graphingwindow.cpp +++ b/re/graphingwindow.cpp @@ -78,7 +78,8 @@ GraphingWindow::GraphingWindow(const QVector *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 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,14 +934,35 @@ 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(); - createGraph(gp, true); + 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 ¶ms, bool createGraphParam) ui->graphingView->graph()->setProperty("id", params.ID); ui->graphingView->graph()->setData(refParam->x,refParam->y); - ui->graphingView->graph()->setLineStyle(QCPGraph::lsLine); //connect points with lines + + 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; diff --git a/re/graphingwindow.h b/re/graphingwindow.h index 20d35c1..34fece5 100644 --- a/re/graphingwindow.h +++ b/re/graphingwindow.h @@ -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; diff --git a/re/newgraphdialog.cpp b/re/newgraphdialog.cpp index f9917c7..87cd41d 100644 --- a/re/newgraphdialog.cpp +++ b/re/newgraphdialog.cpp @@ -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 ¶ms) 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 ¶ms) void NewGraphDialog::getParams(GraphParams ¶ms) { - 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(); diff --git a/re/newgraphdialog.h b/re/newgraphdialog.h index 9200f47..26283c3 100644 --- a/re/newgraphdialog.h +++ b/re/newgraphdialog.h @@ -24,6 +24,7 @@ public: private slots: void addButtonClicked(); void colorSwatchClick(); + void fillSwatchClick(); void loadMessages(); void loadSignals(int idx); void bitfieldClicked(int,int); diff --git a/ui/newgraphdialog.ui b/ui/newgraphdialog.ui index c99f7c1..28687a6 100644 --- a/ui/newgraphdialog.ui +++ b/ui/newgraphdialog.ui @@ -7,7 +7,7 @@ 0 0 681 - 670 + 806 @@ -18,6 +18,16 @@ + + + + <html><head/><body><p>Name:</p></body></html> + + + + + + @@ -35,100 +45,6 @@ - - - - Signed: - - - - - - - - - - - - - - QFrame::NoFrame - - - Mask: - - - - - - - - - - Bias: - - - - - - - - - - Scale - - - - - - - - - - Stride - - - - - - - - - - Color - - - - - - - true - - - CHANGE - - - true - - - - - - - Add this graph - - - - - - - <html><head/><body><p>Name:</p></body></html> - - - - - - @@ -145,20 +61,6 @@ - - - - Little Endian - - - - - - - - - - @@ -169,13 +71,178 @@ - - + + - (LSB First) + Little Endian + + + + (LSB First) + + + + + + + Signed: + + + + + + + + + + + + + + QFrame::NoFrame + + + Mask: + + + + + + + + + + Bias: + + + + + + + + + + Scale + + + + + + + + + + Stride + + + + + + + + + + Only Points + + + + + + + + + + + + + + Point Style + + + + + + + + + + Line Thickness + + + + + + + 15 + + + 1 + + + + + + + Line Color + + + + + + + true + + + CHANGE + + + true + + + + + + + Fill Color + + + + + + + true + + + CHANGE + + + true + + + + + + + Add this graph + + + + + + + Qt::Vertical + + + + 20 + 40 + + + +