|
|
/*------------------------------------------------------------------------------
|
|
|
-- This file is a part of the QLop Software
|
|
|
-- Copyright (C) 2015, Plasma Physics Laboratory - CNRS
|
|
|
--
|
|
|
-- This program is free software; you can redistribute it and/or modify
|
|
|
-- it under the terms of the GNU General Public License as published by
|
|
|
-- the Free Software Foundation; either version 2 of the License, or
|
|
|
-- (at your option) any later version.
|
|
|
--
|
|
|
-- This program is distributed in the hope that it will be useful,
|
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
-- GNU General Public License for more details.
|
|
|
--
|
|
|
-- You should have received a copy of the GNU General Public License
|
|
|
-- along with this program; if not, write to the Free Software
|
|
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
-------------------------------------------------------------------------------*/
|
|
|
/*-- Author : Alexis Jeandet
|
|
|
-- Mail : alexis.jeandet@member.fsf.org
|
|
|
----------------------------------------------------------------------------*/
|
|
|
#include "mainwindow.h"
|
|
|
#include "ui_mainwindow.h"
|
|
|
#include <QFileDialog>
|
|
|
#include <QDir>
|
|
|
#include "qcustomplot.h"
|
|
|
#include <omp.h>
|
|
|
#include <QAction>
|
|
|
#include <downloadhistory.h>
|
|
|
#include <QDateTime>
|
|
|
#include <QDate>
|
|
|
#include <filedownloader.h>
|
|
|
#include <cassinitools.h>
|
|
|
#include <qlopplots.h>
|
|
|
#include <qlopdatabase.h>
|
|
|
#include <qlopsettings.h>
|
|
|
#include <qlopgui.h>
|
|
|
|
|
|
|
|
|
|
|
|
MainWindow::MainWindow(int OMP_THREADS, QWidget *parent) :
|
|
|
QMainWindow(parent),
|
|
|
ui(new Ui::MainWindow)
|
|
|
{
|
|
|
this->OMP_THREADS = OMP_THREADS;
|
|
|
ui->setupUi(this);
|
|
|
QLopGUI::registerMenuBar(menuBar());
|
|
|
this->setWindowIcon(QIcon(":img/QLop.svg"));
|
|
|
this->progressWidget = new QWidget();
|
|
|
this->progressLayout = new QVBoxLayout(this->progressWidget);
|
|
|
this->progressWidget->setLayout(this->progressLayout);
|
|
|
this->progressWidget->setWindowModality(Qt::WindowModal);
|
|
|
progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
|
|
|
for(int i=0;i<OMP_THREADS;i++)
|
|
|
{
|
|
|
this->progress.append(new QProgressBar(this->progressWidget));
|
|
|
this->progress.last()->setMinimum(0);
|
|
|
this->progress.last()->setMaximum(100);
|
|
|
this->progressLayout->addWidget(this->progress.last());
|
|
|
this->progressWidget->hide();
|
|
|
this->progressThreadIds[i] = -1;
|
|
|
}
|
|
|
this->progressWidget->setWindowTitle("Loading File");
|
|
|
const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
|
|
|
<<QLopDataBase::self()
|
|
|
<<FileDownloader::self()
|
|
|
<<CassiniTools::self()
|
|
|
<< QLopPlots::self();
|
|
|
|
|
|
for(int i=0;i<ServicesToLoad.count();i++)
|
|
|
{
|
|
|
qDebug()<<ServicesToLoad.at(i)->serviceName();
|
|
|
QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
|
|
|
wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
|
|
|
this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
|
|
|
PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
{
|
|
|
delete ui;
|
|
|
}
|
|
|
|
|
|
void MainWindow::updateProgress(int threadId, int percentProgress)
|
|
|
{
|
|
|
bool updated=false;
|
|
|
for(int i=0;i<OMP_THREADS;i++)
|
|
|
{
|
|
|
if(progressThreadIds[i]==threadId)
|
|
|
{
|
|
|
if(threadId<this->progress.count())
|
|
|
{
|
|
|
this->progress.at(i)->setValue(percentProgress);
|
|
|
updated=true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if(Q_UNLIKELY(updated==false))
|
|
|
{
|
|
|
for(int i=0;i<OMP_THREADS;i++)
|
|
|
{
|
|
|
if(progressThreadIds[i]==-1)
|
|
|
{
|
|
|
progressThreadIds[i] = threadId;
|
|
|
updateProgress(threadId,percentProgress);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void MainWindow::changeEvent(QEvent *e)
|
|
|
{
|
|
|
QMainWindow::changeEvent(e);
|
|
|
switch (e->type()) {
|
|
|
case QEvent::LanguageChange:
|
|
|
ui->retranslateUi(this);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|