Implemented preliminary ability to edit the starting bit for signals.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <QPainter>
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
|
||||
CANDataGrid::CANDataGrid(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
@@ -19,6 +20,25 @@ CANDataGrid::~CANDataGrid()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CANDataGrid::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
QPoint clickedPoint = event->pos();
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
//qDebug() << "Mouse Loc " << clickedPoint;
|
||||
clickedPoint -= upperLeft;
|
||||
if (clickedPoint.x() < 0 || clickedPoint.y() < 0)
|
||||
{
|
||||
//qDebug() << "Clicked outside the grid you wanker";
|
||||
return;
|
||||
}
|
||||
int x = clickedPoint.x() / gridSize.x();
|
||||
int y = clickedPoint.y() / gridSize.y();
|
||||
//qDebug() << "Grid square clicked " << x << " " << y;
|
||||
emit gridClicked(x,y);
|
||||
}
|
||||
}
|
||||
|
||||
void CANDataGrid::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
int x, y;
|
||||
@@ -112,6 +132,10 @@ void CANDataGrid::paintEvent(QPaintEvent *event)
|
||||
painter.drawRect(viewport.left() + (x+2) * xSector, viewport.top() + (y+2) * ySector, xSector, ySector);
|
||||
}
|
||||
}
|
||||
upperLeft.setX(viewport.left() + 2 * xSector);
|
||||
upperLeft.setY(viewport.top() + 2 * ySector);
|
||||
gridSize.setX(xSector);
|
||||
gridSize.setY(ySector);
|
||||
}
|
||||
|
||||
void CANDataGrid::setReference(unsigned char *newRef, bool bUpdate = true)
|
||||
|
||||
@@ -18,10 +18,17 @@ public:
|
||||
void setReference(unsigned char *, bool);
|
||||
void updateData(unsigned char *, bool);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
signals:
|
||||
void gridClicked(int x,int y);
|
||||
|
||||
private:
|
||||
Ui::CANDataGrid *ui;
|
||||
unsigned char refData[8];
|
||||
unsigned char data[8];
|
||||
QPoint upperLeft, gridSize;
|
||||
};
|
||||
|
||||
#endif // CANDATAGRID_H
|
||||
|
||||
@@ -29,6 +29,7 @@ DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
|
||||
}
|
||||
|
||||
connect(ui->signalsList, SIGNAL(currentRowChanged(int)), this, SLOT(clickSignalList(int)));
|
||||
connect(ui->bitfield, SIGNAL(gridClicked(int,int)), this, SLOT(bitfieldClicked(int,int)));
|
||||
}
|
||||
|
||||
DBCSignalEditor::~DBCSignalEditor()
|
||||
@@ -89,6 +90,10 @@ void DBCSignalEditor::fillSignalForm(DBC_SIGNAL *sig)
|
||||
}
|
||||
|
||||
endBit = startBit + sig->signalSize - 1;
|
||||
if (endBit > 63)
|
||||
{
|
||||
endBit = 63;
|
||||
}
|
||||
|
||||
bitpattern[startBit / 8] |= 1 << (startBit % 8);
|
||||
ui->bitfield->setReference(bitpattern, false);
|
||||
@@ -155,3 +160,12 @@ void DBCSignalEditor::clickSignalList(int row)
|
||||
fillValueTable(thisSig);
|
||||
|
||||
}
|
||||
|
||||
void DBCSignalEditor::bitfieldClicked(int x, int y)
|
||||
{
|
||||
int bit = (x) + (y * 8);
|
||||
DBC_SIGNAL *thisSig = dbcHandler->findSignalByIdx(dbcMessage, ui->signalsList->currentRow());
|
||||
if (thisSig == NULL) return;
|
||||
thisSig->startBit = bit;
|
||||
fillSignalForm(thisSig);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public:
|
||||
|
||||
private slots:
|
||||
void clickSignalList(int);
|
||||
void bitfieldClicked(int x, int y);
|
||||
|
||||
private:
|
||||
Ui::DBCSignalEditor *ui;
|
||||
|
||||
Reference in New Issue
Block a user