Now right clicking a different signal within DBC Sig Editor will switch editing to
that signal.
This commit is contained in:
@@ -136,6 +136,21 @@ void CANDataGrid::mousePressEvent(QMouseEvent *event)
|
|||||||
else if (bytesToDraw > 32) bytesToDraw = 8;
|
else if (bytesToDraw > 32) bytesToDraw = 8;
|
||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//right click is exactly like left click but the emitted signal is different so that
|
||||||
|
//external code can differentiate which button was pressed
|
||||||
|
if (event->button() == Qt::RightButton)
|
||||||
|
{
|
||||||
|
clickedPoint -= upperLeft;
|
||||||
|
if (clickedPoint.x() < 0 || clickedPoint.y() < 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int x = clickedPoint.x() / gridSize.x();
|
||||||
|
int y = clickedPoint.y() / gridSize.y();
|
||||||
|
int bitClicked = gridToBitPosition(x, y);
|
||||||
|
emit gridRightClicked(bitClicked);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CANDataGrid::setCellTextState(int bitPos, GridTextState state)
|
void CANDataGrid::setCellTextState(int bitPos, GridTextState state)
|
||||||
@@ -553,6 +568,8 @@ void CANDataGrid::setReference(unsigned char *newRef, bool bUpdate = true)
|
|||||||
{
|
{
|
||||||
int bytesToTransfer = (bytesToDraw + 7) & 0xF8; //force copying in 8 byte increments
|
int bytesToTransfer = (bytesToDraw + 7) & 0xF8; //force copying in 8 byte increments
|
||||||
memcpy(refData, newRef, bytesToTransfer);
|
memcpy(refData, newRef, bytesToTransfer);
|
||||||
|
//clear all data past that point just to be sure we don't have garbage left over
|
||||||
|
if (bytesToTransfer < 64) memset(refData + bytesToTransfer, 0, 64 - bytesToTransfer);
|
||||||
if (bUpdate) this->update();
|
if (bUpdate) this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,6 +577,8 @@ void CANDataGrid::updateData(unsigned char *newData, bool bUpdate = true)
|
|||||||
{
|
{
|
||||||
int bytesToTransfer = (bytesToDraw + 7) & 0xF8; //force copying in 8 byte increments
|
int bytesToTransfer = (bytesToDraw + 7) & 0xF8; //force copying in 8 byte increments
|
||||||
memcpy(data, newData, bytesToTransfer);
|
memcpy(data, newData, bytesToTransfer);
|
||||||
|
//clear all data past that point just to be sure we don't have garbage left over
|
||||||
|
if (bytesToTransfer < 64) memset(refData + bytesToTransfer, 0, 64 - bytesToTransfer);
|
||||||
if (bUpdate) this->update();
|
if (bUpdate) this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -567,5 +586,7 @@ void CANDataGrid::setUsed(unsigned char *newData, bool bUpdate = false)
|
|||||||
{
|
{
|
||||||
int bytesToTransfer = (bytesToDraw + 7) & 0xF8; //force copying in 8 byte increments
|
int bytesToTransfer = (bytesToDraw + 7) & 0xF8; //force copying in 8 byte increments
|
||||||
memcpy(usedData, newData, bytesToTransfer);
|
memcpy(usedData, newData, bytesToTransfer);
|
||||||
|
//clear all data past that point just to be sure we don't have garbage left over
|
||||||
|
if (bytesToTransfer < 64) memset(refData + bytesToTransfer, 0, 64 - bytesToTransfer);
|
||||||
if (bUpdate) this->update();
|
if (bUpdate) this->update();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ protected:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void gridClicked(int bitClicked);
|
void gridClicked(int bitClicked);
|
||||||
|
void gridRightClicked(int bitClicked);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::CANDataGrid *ui;
|
Ui::CANDataGrid *ui;
|
||||||
|
|||||||
+24
-2
@@ -37,7 +37,9 @@ DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
|
|||||||
|
|
||||||
ui->bitfield->setMode(GridMode::SIGNAL_VIEW);
|
ui->bitfield->setMode(GridMode::SIGNAL_VIEW);
|
||||||
|
|
||||||
connect(ui->bitfield, SIGNAL(gridClicked(int)), this, SLOT(bitfieldClicked(int)));
|
connect(ui->bitfield, SIGNAL(gridClicked(int)), this, SLOT(bitfieldLeftClicked(int)));
|
||||||
|
connect(ui->bitfield, SIGNAL(gridRightClicked(int)), this, SLOT(bitfieldRightClicked(int)));
|
||||||
|
|
||||||
connect(ui->valuesTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onCustomMenuValues(QPoint)));
|
connect(ui->valuesTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onCustomMenuValues(QPoint)));
|
||||||
ui->valuesTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
ui->valuesTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(ui->valuesTable, SIGNAL(cellChanged(int,int)), this, SLOT(onValuesCellChanged(int,int)));
|
connect(ui->valuesTable, SIGNAL(cellChanged(int,int)), this, SLOT(onValuesCellChanged(int,int)));
|
||||||
@@ -666,7 +668,8 @@ void DBCSignalEditor::fillValueTable(DBC_SIGNAL *sig)
|
|||||||
inhibitCellChanged = false;
|
inhibitCellChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBCSignalEditor::bitfieldClicked(int bit)
|
//Left clicking the grid sets the "starting bit" for the current signal
|
||||||
|
void DBCSignalEditor::bitfieldLeftClicked(int bit)
|
||||||
{
|
{
|
||||||
if (currentSignal == nullptr) return;
|
if (currentSignal == nullptr) return;
|
||||||
currentSignal->startBit = bit;
|
currentSignal->startBit = bit;
|
||||||
@@ -694,6 +697,25 @@ void DBCSignalEditor::bitfieldClicked(int bit)
|
|||||||
fillSignalForm(currentSignal);
|
fillSignalForm(currentSignal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Right clicking the grid starts editing on whichever signal currently "owns" that bit.
|
||||||
|
//If there is no other signal then nothing happens (right now).
|
||||||
|
//Would be possible to create a new signal in that case
|
||||||
|
void DBCSignalEditor::bitfieldRightClicked(int bit)
|
||||||
|
{
|
||||||
|
//will return -1 if there is no signal there. Otherwise, returns signal number
|
||||||
|
//which is quite luckily also the index into the signal handler table
|
||||||
|
int sigNum = ui->bitfield->getUsedSignalNum(bit);
|
||||||
|
if (sigNum < 0) return;
|
||||||
|
currentSignal = dbcMessage->sigHandler->findSignalByIdx(sigNum);
|
||||||
|
|
||||||
|
if (currentSignal)
|
||||||
|
{
|
||||||
|
fillSignalForm(currentSignal);
|
||||||
|
fillValueTable(currentSignal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DBCSignalEditor::generateUsedBits()
|
void DBCSignalEditor::generateUsedBits()
|
||||||
{
|
{
|
||||||
uint8_t usedBits[64];
|
uint8_t usedBits[64];
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ signals:
|
|||||||
void updatedTreeInfo(DBC_SIGNAL *sig);
|
void updatedTreeInfo(DBC_SIGNAL *sig);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void bitfieldClicked(int bit);
|
void bitfieldLeftClicked(int bit);
|
||||||
|
void bitfieldRightClicked(int bit);
|
||||||
void onValuesCellChanged(int row,int col);
|
void onValuesCellChanged(int row,int col);
|
||||||
void onCustomMenuValues(QPoint);
|
void onCustomMenuValues(QPoint);
|
||||||
void deleteCurrentValue();
|
void deleteCurrentValue();
|
||||||
|
|||||||
Reference in New Issue
Block a user