mirror of
https://gitlab.ethz.ch/gfattori/glocalize.git
synced 2026-05-03 13:44:26 +02:00
94 lines
2.6 KiB
C++
94 lines
2.6 KiB
C++
|
|
|
|
#include "mainw.h"
|
|
#include <qfile.h>
|
|
#include "itkTextOutput.h"
|
|
|
|
#include <qsettings.h>
|
|
|
|
|
|
#include <QVTKOpenGLNativeWidget.h>
|
|
#include <qsurfaceformat.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
std::cout << "Hello, world!" << std::endl;
|
|
|
|
vtkObject::SetGlobalWarningDisplay(false);
|
|
itk::OutputWindow::SetInstance(itk::TextOutput::New());
|
|
QSurfaceFormat::setDefaultFormat(QVTKOpenGLNativeWidget::defaultFormat());
|
|
|
|
QApplication app(argc,argv);
|
|
|
|
if(!QFile("config.ini").exists()){
|
|
QMessageBox msgBox;
|
|
msgBox.setIcon(QMessageBox::Icon::Critical);
|
|
msgBox.setText("gLocalize config file missing... Exiting.");
|
|
msgBox.setInformativeText("Please add config.ini file in the gLocalize path.");
|
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
|
int ret = msgBox.exec();
|
|
cout<<"prequit" <<endl;
|
|
app.quit();;
|
|
return -1;
|
|
}
|
|
|
|
|
|
QSettings *config = new QSettings ("config.ini",QSettings::IniFormat);
|
|
|
|
/*if in/out dir not found. just exit*/
|
|
if(!QDir(config->value("Path/inDir").toString()).exists() || !QDir(config->value("Path/outDir").toString()).exists()){
|
|
QString userMsg;
|
|
userMsg.clear();
|
|
userMsg.append("Please check config.ini file parameters:\n");
|
|
( QDir(config->value("Path/inDir").toString()).exists() == true? "" : userMsg.append("- Patient directory : [Path]/inDir\n") );
|
|
( QDir(config->value("Path/outDir").toString()).exists() == true? "" : userMsg.append("- Output directory : [Path]/outDir\n") );
|
|
|
|
QMessageBox msgBox;
|
|
msgBox.setIcon(QMessageBox::Icon::Critical);
|
|
msgBox.setText("gLocalize configuration error... Exiting.");
|
|
msgBox.setInformativeText(userMsg);
|
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
|
|
|
QSpacerItem* horizonatlSpacer= new QSpacerItem(300,0,QSizePolicy::Minimum,QSizePolicy::Expanding);
|
|
QGridLayout* layout = (QGridLayout*) msgBox.layout();
|
|
layout->addItem(horizonatlSpacer, layout->rowCount(), 0 ,1 ,layout->columnCount());
|
|
|
|
int ret = msgBox.exec();
|
|
cout<<"prequit" <<endl;
|
|
app.quit();
|
|
delete config;
|
|
return -1;
|
|
}
|
|
delete config;
|
|
|
|
|
|
QFile qss("style.qss");
|
|
if (!qss.open(QFile::ReadOnly)) {
|
|
qWarning() << "Failed to open stylesheet:" << qss.fileName() << qss.errorString();
|
|
} else {
|
|
app.setStyleSheet(qss.readAll());
|
|
qss.close();
|
|
}
|
|
|
|
|
|
|
|
QString loadPath;
|
|
loadPath.clear();
|
|
|
|
if(argc==2)
|
|
loadPath = app.arguments().at(1);
|
|
|
|
MainWindow* mainW= new MainWindow(loadPath);
|
|
std::cout<< "pre show" <<std::endl;
|
|
mainW->show();
|
|
int res= app.exec();
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
}
|