It is now possible to save the flowview bitfield and the flowview graph to image files (right click)
This commit is contained in:
@@ -138,6 +138,28 @@ void CANDataGrid::paintEvent(QPaintEvent *event)
|
|||||||
gridSize.setY(ySector);
|
gridSize.setY(ySector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CANDataGrid::saveImage(QString filename, int width, int height)
|
||||||
|
{
|
||||||
|
//can't quite do the below commented out stuff
|
||||||
|
//it works but doesn't scale the image into that pixmap. Need to
|
||||||
|
//figure out how to draw the size of the pixmap
|
||||||
|
/*
|
||||||
|
QSize pSize;
|
||||||
|
|
||||||
|
if (width == 0) pSize.setWidth(this->size().width());
|
||||||
|
else pSize.setWidth(width);
|
||||||
|
|
||||||
|
if (height == 0) pSize.setHeight(this->size().height());
|
||||||
|
else pSize.setHeight(height);
|
||||||
|
|
||||||
|
QPixmap pixmap(pSize);
|
||||||
|
*/
|
||||||
|
QPixmap pixmap(this->size());
|
||||||
|
|
||||||
|
this->render(&pixmap);
|
||||||
|
pixmap.save(filename); //QT will automatically pick the file format given the extension
|
||||||
|
}
|
||||||
|
|
||||||
void CANDataGrid::setReference(unsigned char *newRef, bool bUpdate = true)
|
void CANDataGrid::setReference(unsigned char *newRef, bool bUpdate = true)
|
||||||
{
|
{
|
||||||
memcpy(refData, newRef, 8);
|
memcpy(refData, newRef, 8);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public:
|
|||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
void setReference(unsigned char *, bool);
|
void setReference(unsigned char *, bool);
|
||||||
void updateData(unsigned char *, bool);
|
void updateData(unsigned char *, bool);
|
||||||
|
void saveImage(QString filename, int width, int height);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|||||||
@@ -69,6 +69,11 @@ FlowViewWindow::FlowViewWindow(QVector<CANFrame> *frames, QWidget *parent) :
|
|||||||
|
|
||||||
connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int)));
|
connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int)));
|
||||||
|
|
||||||
|
ui->graphView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(ui->graphView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequestGraph(QPoint)));
|
||||||
|
ui->flowView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(ui->flowView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequestFlow(QPoint)));
|
||||||
|
|
||||||
playbackTimer->setInterval(ui->spinPlayback->value()); //set the timer to the default value of the control
|
playbackTimer->setInterval(ui->spinPlayback->value()); //set the timer to the default value of the control
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -94,6 +99,74 @@ FlowViewWindow::~FlowViewWindow()
|
|||||||
delete playbackTimer;
|
delete playbackTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FlowViewWindow::contextMenuRequestFlow(QPoint pos)
|
||||||
|
{
|
||||||
|
QMenu *menu = new QMenu(this);
|
||||||
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
|
menu->addAction(tr("Save image to file"), this, SLOT(saveFileFlow()));
|
||||||
|
|
||||||
|
menu->popup(ui->flowView->mapToGlobal(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlowViewWindow::contextMenuRequestGraph(QPoint pos)
|
||||||
|
{
|
||||||
|
QMenu *menu = new QMenu(this);
|
||||||
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
|
menu->addAction(tr("Save image to file"), this, SLOT(saveFileGraph()));
|
||||||
|
|
||||||
|
menu->popup(ui->graphView->mapToGlobal(pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlowViewWindow::saveFileGraph()
|
||||||
|
{
|
||||||
|
QString filename;
|
||||||
|
QFileDialog dialog(this);
|
||||||
|
|
||||||
|
QStringList filters;
|
||||||
|
filters.append(QString(tr("PDF Files (*.pdf)")));
|
||||||
|
filters.append(QString(tr("PNG Files (*.png)")));
|
||||||
|
filters.append(QString(tr("JPEG Files (*.jpg)")));
|
||||||
|
|
||||||
|
dialog.setFileMode(QFileDialog::AnyFile);
|
||||||
|
dialog.setNameFilters(filters);
|
||||||
|
dialog.setViewMode(QFileDialog::Detail);
|
||||||
|
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||||
|
|
||||||
|
if (dialog.exec() == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
filename = dialog.selectedFiles()[0];
|
||||||
|
|
||||||
|
if (dialog.selectedNameFilter() == filters[0]) ui->graphView->savePdf(filename, true, 0, 0);
|
||||||
|
if (dialog.selectedNameFilter() == filters[1]) ui->graphView->savePng(filename, 1024, 768);
|
||||||
|
if (dialog.selectedNameFilter() == filters[2]) ui->graphView->saveJpg(filename, 1024, 768);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlowViewWindow::saveFileFlow()
|
||||||
|
{
|
||||||
|
QString filename;
|
||||||
|
QFileDialog dialog(this);
|
||||||
|
|
||||||
|
QStringList filters;
|
||||||
|
filters.append(QString(tr("PNG Files (*.png)")));
|
||||||
|
filters.append(QString(tr("JPEG Files (*.jpg)")));
|
||||||
|
|
||||||
|
dialog.setFileMode(QFileDialog::AnyFile);
|
||||||
|
dialog.setNameFilters(filters);
|
||||||
|
dialog.setViewMode(QFileDialog::Detail);
|
||||||
|
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||||
|
|
||||||
|
if (dialog.exec() == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
filename = dialog.selectedFiles()[0];
|
||||||
|
|
||||||
|
if (dialog.selectedNameFilter() == filters[0]) ui->flowView->saveImage(filename, 1024, 768);
|
||||||
|
if (dialog.selectedNameFilter() == filters[1]) ui->flowView->saveImage(filename, 1024, 768);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FlowViewWindow::updatedFrames(int numFrames)
|
void FlowViewWindow::updatedFrames(int numFrames)
|
||||||
{
|
{
|
||||||
if (numFrames == -1) //all frames deleted. Kill the display
|
if (numFrames == -1) //all frames deleted. Kill the display
|
||||||
|
|||||||
+5
-1
@@ -28,7 +28,11 @@ private slots:
|
|||||||
void changeLooping(bool check);
|
void changeLooping(bool check);
|
||||||
void timerTriggered();
|
void timerTriggered();
|
||||||
void changeID(QString);
|
void changeID(QString);
|
||||||
void updatedFrames(int);
|
void updatedFrames(int);
|
||||||
|
void contextMenuRequestFlow(QPoint pos);
|
||||||
|
void contextMenuRequestGraph(QPoint pos);
|
||||||
|
void saveFileFlow();
|
||||||
|
void saveFileGraph();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::FlowViewWindow *ui;
|
Ui::FlowViewWindow *ui;
|
||||||
|
|||||||
+2
-7
@@ -21,13 +21,8 @@ Range state - Find things that range like accelerator pedal inputs, road speed,
|
|||||||
fuzzy scope - Try to find potential places where a given value might be stored - offer guesses and the program tries to find candidates for you
|
fuzzy scope - Try to find potential places where a given value might be stored - offer guesses and the program tries to find candidates for you
|
||||||
|
|
||||||
|
|
||||||
Things currently broken or in need of attention:
|
Things currently broken or in need of attention: (push these over to github issues as soon as you can)
|
||||||
1. Currently no screen supports dynamic updates when new frames come in.
|
1. If you load a file, use detailed view, clear it, load another, it seems to only show new IDs
|
||||||
2. Some of the save formats are not actually implemented and silently fail.
|
|
||||||
3. It would be nice to be able to save the graphing view in the flow view.
|
|
||||||
4. It would also be nice to be able to save an image of the bitfield grid too.
|
|
||||||
5. New GVRET firmware has a hard time sending data (6 frames per second!)
|
|
||||||
6. If you load a file, use detailed view, clear it, load another, it seems to only show new IDs
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QString MainWindow::loadedFileName = "";
|
QString MainWindow::loadedFileName = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user