-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUploadWindow.cpp
More file actions
144 lines (102 loc) · 6 KB
/
UploadWindow.cpp
File metadata and controls
144 lines (102 loc) · 6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include "UploadWindow.h"
#include "parsefile.h"
#include "ui_UploadWindow.h"
#include <fstream>
#include <QMessageBox>
#include <iostream>
#include <QDialog>
#include <QFileDialog>
UploadWindow::UploadWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::UploadWindow)
{
ui->setupUi(this);
ui->GeneFileText->setPlainText("Please select a TSV File (*.tsv).");
ui->SpatialFileText->setPlainText("Please select a CSV File (*.csv).");
ui->ExpressFileText->setPlainText("Please select a MTX File (*.mtx).");
PointerMenuWindow = new MenuWindow(this);
connect(PointerMenuWindow, &MenuWindow::UploadWindow, this, &UploadWindow::show);
}
UploadWindow::~UploadWindow()
{
delete ui;
delete PointerMenuWindow;
}
void UploadWindow::close(){
/*This function closes the upload window and sets the data for the menuwindow. It also calls makePlot()
* to generate the scatterplot and shows the menuwindow.
*/
// //sets the data
// PointerMenuWindow->setX(ExpressData.getX());
// PointerMenuWindow->setY(ExpressData.getY());
// PointerMenuWindow->setP(ExpressData.getP());
PointerMenuWindow->setFileObject(this->files);
computation object = computation(files,0,5000);
object.normalisation();
Eigen::MatrixXd plot = object.compute_tot_expr();
PointerMenuWindow->makePlot(plot);
// PointerMenuWindow->makePlot(); //generates the plot
PointerMenuWindow->show(); //shows menuwindow
this->hide(); //hides uploadwindow
}
void UploadWindow::on_GeneSelectButton_clicked()
{
/*This function opens the file explorer and allows the user to choose a file. Once that file is
* chosen, it sets the path as the text in the text edit.
*/
QString GFileFilter = "TSV File (*.tsv);;";//"TSV File (*.tsv);;"; //creates a file filter so that only the relevant formats can be chosen
QString GeneUserText = QFileDialog::getOpenFileName(this, "Open a File", "C:\\Users\\", GFileFilter); //opens the file explorer with the filter
ui->GeneFileText->setPlainText(GeneUserText); //sets the test in the text edit to be the flie location
qDebug() << "Gene name file = " << GeneUserText;
}
void UploadWindow::on_SpatialSelectButton_clicked(){
QString SFileFilter = "CSV File (*.csv);;"; //creates a file filter so that only the relevant formats can be chosen MTX File (*.mtx)
QString SpatialUserText = QFileDialog::getOpenFileName(this, "Open a File", "C:\\Users\\", SFileFilter); //opens the file explorer with the filter
ui->SpatialFileText->setPlainText(SpatialUserText); //sets the test in the text edit to be the flie location
qDebug() << "Spatial file = " << SpatialUserText;
};
void UploadWindow::on_ExpressSelectButton_clicked(){
QString EFileFilter = "MTX File (*.mtx);;";//"MTX File (*.mtx);;"; //creates a file filter so that only the relevant formats can be chosen
QString ExpressUserText = QFileDialog::getOpenFileName(this, "Open a File", "C:\\Users\\", EFileFilter); //opens the file explorer with the filter
ui->ExpressFileText->setPlainText(ExpressUserText); //sets the test in the text edit to be the flie location
qDebug() << "Expression file = " << ExpressUserText;
};
void UploadWindow::on_UploadButton_clicked()
{
/*This file uploads the data. It reads it and parses it, if everything is fine, then it opens the menu
* window and closes the upload window.
*/
files = parsefile();
// FileData Genedata;
// FileData Spatialdata;
GeneUserText = ui->GeneFileText->toPlainText(); //takes the file location
GeneFilename = GeneUserText.toStdString(); //converts the file location to std::string
// GeneBoolean = Genedata.readData(GeneFilename); //reads and parses the data, returns a boolean to check for sucessful upload
SpatialUserText = ui->SpatialFileText->toPlainText(); //takes the file location
SpatialFilename = SpatialUserText.toStdString(); //converts the file location to std::string
// SpatialBoolean = Spatialdata.readData(SpatialFilename); //reads and parses the data, returns a boolean to check for sucessful upload
ExpressUserText = ui->ExpressFileText->toPlainText(); //takes the file location
ExpressFilename = ExpressUserText.toStdString(); //converts the file location to std::string
// ExpressBoolean = ExpressData.readData(ExpressFilename); //reads and parses the data, returns a boolean to check for sucessful upload
int fileRead = files.readFiles(ExpressFilename, SpatialFilename, GeneFilename);
if(fileRead == 0){
QMessageBox::information(this, "Success", "File has been uploaded.", QMessageBox::Ok); //sucess message
close(); //closes this window and opens the menu
}else{
QString ErrorMesage = "Could not find all of the files.\n";
if(fileRead != 3){ErrorMesage.append("Gene File is allowed,\n");}else{ErrorMesage.append("Select Gene File again,\n");};
if(fileRead != 1){ErrorMesage.append("Spatial File is allowed,\n");}else{ErrorMesage.append("Select Spatial File again,\n");};
if(fileRead != 2){ErrorMesage.append("Express File is allowed.");}else{ErrorMesage.append("Select Express File again.");};
QMessageBox::information(this, "Error", ErrorMesage , QMessageBox::Ok); //error message
}
// if(GeneBoolean&&SpatialBoolean&&ExpressBoolean){
// QMessageBox::information(this, "Success", "File has been uploaded.", QMessageBox::Ok); //sucess message
// close(); //closes this window and opens the menu
// }else{
// QString ErrorMesage = "Could not find all of the files.\n";
// if(GeneBoolean){ErrorMesage.append("Gene File is allowed,\n");}else{ErrorMesage.append("Select Gene File again,\n");};
// if(SpatialBoolean){ErrorMesage.append("Spatial File is allowed,\n");}else{ErrorMesage.append("Select Spatial File again,\n");};
// if(ExpressBoolean){ErrorMesage.append("Express File is allowed.");}else{ErrorMesage.append("Select Express File again.");};
// QMessageBox::information(this, "Error", ErrorMesage , QMessageBox::Ok); //error message
// }
}