Implemented preliminary ability to edit the starting bit for signals.

This commit is contained in:
Collin Kidder
2015-06-10 20:13:20 -04:00
parent c855a0998b
commit 993a026a48
4 changed files with 47 additions and 1 deletions
+25 -1
View File
@@ -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;
@@ -111,7 +131,11 @@ void CANDataGrid::paintEvent(QPaintEvent *event)
//painter.fillRect(viewport.left() + (x+2) * xSector, viewport.top() + (y+2) * ySector, xSector, ySector, redBrush);
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)