added possibility to load data from csv file
This commit is contained in:
parent
e435684f9c
commit
b5445c8a11
@ -58,6 +58,9 @@ void InputParser::process()
|
||||
case '.':
|
||||
decimal=true;
|
||||
break;
|
||||
case '-':
|
||||
sign=-1;
|
||||
break;
|
||||
default:
|
||||
switch(index){
|
||||
case 0:
|
||||
@ -134,7 +137,7 @@ void InputParser::sendPixel()
|
||||
maxPow=newMax;
|
||||
}
|
||||
|
||||
int col=qRound(currentPowerValue-minPow)*255/(maxPow-minPow);
|
||||
int col=qRound(currentPowerValue-minPow*255/(maxPow-minPow));
|
||||
display->setPixel(currentX,currentY,qRgba(col,col,col,255));
|
||||
currentX++;
|
||||
currentPowerValue=0;
|
||||
|
10
main.cpp
10
main.cpp
@ -1,11 +1,21 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
QCommandLineParser argsParser;
|
||||
argsParser.setApplicationDescription("A live heatmap creator for soapy_power");
|
||||
argsParser.addHelpOption();
|
||||
argsParser.addPositionalArgument("source","csv file to read data from, default stdin");
|
||||
|
||||
argsParser.process(a);
|
||||
|
||||
MainWindow w;
|
||||
w.sendArgs(&argsParser);
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
|
@ -16,8 +16,29 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
{
|
||||
setCentralWidget(displayArea);
|
||||
|
||||
createActions();
|
||||
createMenus();
|
||||
|
||||
setWindowTitle(tr("LivePow"));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::sendArgs(QCommandLineParser *argsParser)
|
||||
{
|
||||
const QStringList posArgs = argsParser->positionalArguments();
|
||||
|
||||
FILE* input=stdin;
|
||||
|
||||
if(posArgs.length()==1){
|
||||
QFile file(posArgs.at(0));
|
||||
QFileInfo fileInfo(file);
|
||||
input=fopen(fileInfo.absoluteFilePath().toLatin1(),"r");
|
||||
}
|
||||
else if(posArgs.length()>1) fprintf(stderr,"too much positionnal args, using stdin");
|
||||
|
||||
parser=new InputParser(input,displayArea);
|
||||
|
||||
QThread* workerThread=new QThread();
|
||||
@ -26,15 +47,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
connect(workerThread, &QThread::started, parser, &InputParser::process);
|
||||
connect(workerThread, &QThread::finished, workerThread, &QThread::deleteLater);
|
||||
workerThread->start();
|
||||
|
||||
createActions();
|
||||
createMenus();
|
||||
|
||||
setWindowTitle(tr("LivePow"));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::save(){
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QCommandLineParser>
|
||||
|
||||
class DisplayArea;
|
||||
class InputParser;
|
||||
@ -14,7 +15,7 @@ public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
static void tick();
|
||||
void sendArgs(QCommandLineParser* argsParser);
|
||||
|
||||
InputParser *parser;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user