mirror of https://github.com/EspoTek/Labrador.git
"Snapshot" asks user where they want to save w/ dialog
This commit is contained in:
parent
af2e29567f
commit
9ee91d2a42
|
@ -1,2 +1,3 @@
|
|||
*.csv
|
||||
/.project
|
||||
*.obj
|
||||
|
|
|
@ -1179,26 +1179,22 @@ void isoDriver::setTimeWindow(double newWindow){
|
|||
windowAtPause = window;
|
||||
}
|
||||
|
||||
void isoDriver::takeSnapshot(){
|
||||
void isoDriver::takeSnapshot(QString *fileName){
|
||||
snapshotEnabled = true;
|
||||
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
QString fileName_CH1 = now.toString("yyyyMMddhhmmsszzz");
|
||||
fileName_CH1.append("_CH1.csv");
|
||||
QString fname_CH1 = *(fileName);
|
||||
fname_CH1.append("_CH1.csv");
|
||||
|
||||
QString fileName_CH2 = now.toString("yyyyMMddhhmmsszzz");
|
||||
fileName_CH2.append("_CH2.csv");
|
||||
QString fname_CH2 = *(fileName);
|
||||
fname_CH2.append("_CH2.csv");
|
||||
|
||||
QDir *dir = new QDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));
|
||||
dir->mkdir("EspoTek");
|
||||
dir->cd("EspoTek");
|
||||
dir->mkdir("snapshots");
|
||||
dir->cd("snapshots");
|
||||
|
||||
snapshotFile_CH1 = new QFile(dir->filePath(fileName_CH1));
|
||||
snapshotFile_CH2 = new QFile(dir->filePath(fileName_CH2));
|
||||
qDebug() << fname_CH1;
|
||||
qDebug() << fname_CH2;
|
||||
|
||||
snapshotFile_CH1 = new QFile(fname_CH1);
|
||||
snapshotFile_CH2 = new QFile(fname_CH2);
|
||||
|
||||
free(dir);
|
||||
}
|
||||
|
||||
double isoDriver::meanVoltageLast(double seconds, unsigned char channel, int TOP){
|
||||
|
|
|
@ -181,7 +181,7 @@ public slots:
|
|||
void setTopRange(double newTop);
|
||||
void setBotRange(double newBot);
|
||||
void setTimeWindow(double newWindow);
|
||||
void takeSnapshot();
|
||||
void takeSnapshot(QString *fileName);
|
||||
void rSourceChanged(int newSource);
|
||||
};
|
||||
|
||||
|
|
|
@ -152,7 +152,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
connect(ui->controller_iso, SIGNAL(multimeterREnabled(int)), this, SLOT(rSourceIndexChanged(int)));
|
||||
connect(ui->controller_iso, SIGNAL(multimeterRMS(double)), ui->multimeterRmsDisplay, SLOT(display(double)));
|
||||
connect(ui->controller_iso, SIGNAL(sendMultimeterLabel4(QString)), ui->multimeterRmsLabel, SLOT(setText(QString)));
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -1158,7 +1157,17 @@ void MainWindow::on_actionRecord_triggered(bool checked)
|
|||
|
||||
void MainWindow::on_actionTake_Snapshot_triggered()
|
||||
{
|
||||
ui->controller_iso->takeSnapshot();
|
||||
QString fileName;
|
||||
showFileDialog(&fileName);
|
||||
qDebug() << fileName;
|
||||
int len = fileName.length();
|
||||
|
||||
if(len==0) return; //User cancelled
|
||||
|
||||
qDebug() << len;
|
||||
fileName.remove(len-4, 4);
|
||||
qDebug() << fileName;
|
||||
ui->controller_iso->takeSnapshot(&fileName);
|
||||
}
|
||||
|
||||
void MainWindow::reinitUsb(void){
|
||||
|
@ -1543,3 +1552,14 @@ void MainWindow::on_actionSingle_ep_async_triggered()
|
|||
settings->setValue("ConnectionType", 2);
|
||||
if(ui->controller_iso->driver->connected) reinitUsb();
|
||||
}
|
||||
|
||||
void MainWindow::showFileDialog(QString *fileName){
|
||||
QString filters("CSV files (*.csv)");
|
||||
QString defaultFilter("CSV files (*.csv)");
|
||||
|
||||
/* Static method approach */
|
||||
QString temp = QFileDialog::getSaveFileName(0, "Save file", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation),
|
||||
filters, &defaultFilter);
|
||||
|
||||
*(fileName) = temp;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void showFileDialog(QString *fileName);
|
||||
private slots:
|
||||
//Oscilloscope
|
||||
void on_actionGain0_5_triggered();
|
||||
|
|
Loading…
Reference in New Issue