Files
DEC/DEC_GUI/mainwindow.cpp
2024-10-03 18:43:04 +07:00

194 lines
6.2 KiB
C++

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "createdialogs.h"
#include <QMenuBar>
#include <QFile>
#include <QMessageBox>
#include <QFileDialog>
#include <Agressor/manager.h>
#include "DEC-0.0/processor/KolchShindyalov.h"
#include "DEC-0.0/processor/Processor.h"
#include "DEC-0.0/processor/Settings.h"
#include "DEC-0.0/DerevyankoReport.h"
#include "DEC-0.0/DerevyankoReport2014.h"
#include "DEC-0.0/processor/Settings.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
createActions();
createMenus();
connect(this, SIGNAL(drawDefaultGraphs()), &derrep2014window, SLOT(startDefault()));
connect(this, SIGNAL(drawRep2013()), &derrep2013window, SLOT(startDraw()));
connect(this, SIGNAL(drawBreed(int)), &breedWindow, SLOT(startDraw(int)));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::createActions()
{
openAct = new QAction(tr("&Open..."), this);
openAct->setShortcuts(QKeySequence::Open);
openAct->setStatusTip(tr("Open an existing file"));
connect(openAct, SIGNAL(triggered()), this, SLOT(openFile()));
chooseModel = new QAction(tr("&Choose model.."), this);
connect(chooseModel, SIGNAL(triggered()), this, SLOT(showChooseModelDialog()));
}
void MainWindow::createMenus()
{
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(openAct);
fileMenu->addSeparator();
controlMenu = menuBar()->addMenu(tr("&Control"));
controlMenu->addAction(chooseModel);
helpMenu = menuBar()->addMenu(tr("&Help"));
//helpMenu->addAction(aboutAct);
}
void MainWindow::openFile()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "",
tr("Text Files (*.txt);;C++ Files (*.cpp *.h)"));
if (fileName != "")
{
/*QFile file(fileName);
if (!file.open(QIODevice::ReadOnly))
{
QMessageBox::critical(this, tr("Error"), tr("Could not open file"));
return;
}*/
}
}
void MainWindow::showChooseModelDialog()
{
CreateDialogs dialog(this, 1, "lol"); //choose model dialog
int ret = dialog.exec();
if (ret == QDialog::Rejected)
{
return;
}
if (dialog.checkDerRep2014_button())
{
CreateDialogs dialogDerRep2014(this, 2, "Homo");
int ret = dialogDerRep2014.exec();
if (ret == QDialog::Rejected)
{
return;
}
if (dialogDerRep2014.checkLoci())
{
QMessageBox::information(this, "Information", "Press 'Default' button or enter locis", QMessageBox::Ok, 0);
return;
}
Settings::numLoci = dialogDerRep2014.getNumLociVal();
Settings::PopulationHomoInitSize = dialogDerRep2014.getSizeNum();
Settings::percentDiffLoci = dialogDerRep2014.getPerDiffLoci();
Settings::initMtDNA = dialogDerRep2014.getInitHomoGen();
CreateDialogs dialogDerRep2014_2(this, 3, "Ancient");
int rets = dialogDerRep2014_2.exec();
if (rets == QDialog::Rejected)
{
return;
}
if (dialogDerRep2014_2.checkLoci())
{
QMessageBox::information(this, "Information", "Press 'Default' button or enter locis", QMessageBox::Ok, 0);
return;
}
Settings::PopulationAncientInitSize = dialogDerRep2014.getSizeNum();
Settings::initMtDNA_ancient = dialogDerRep2014.getInitAncientGen();
DerevyankoReport2014::report2014_01(/*argc,argv*/);
derrep2014window.setWindowTitle("DerevyankoReport2014");
derrep2014window.setParametersSettings();
derrep2014window.show();
derrep2014window.raise();
derrep2014window.setFocus();
derrep2014window.activateWindow();
emit drawDefaultGraphs();
//std::cout << Settings::ancientCommonSize.size() << std::endl;
}
if (dialog.checkDerRepRFBR_button())
{
CreateDialogs dialogDerRep2013(this, 4, "Pop_f");
int ret = dialogDerRep2013.exec();
if (ret == QDialog::Rejected)
{
return;
}
if (dialogDerRep2013.checkLoci())
{
QMessageBox::information(this, "Information", "Press 'Default' button or enter locis", QMessageBox::Ok, 0);
return;
}
CreateDialogs dialogDerRep2013_2(this, 5, "Pop_G");
int rets = dialogDerRep2013_2.exec();
if (rets == QDialog::Rejected)
{
return;
}
if (dialogDerRep2013_2.checkLoci())
{
QMessageBox::information(this, "Information", "Press 'Default' button or enter locis", QMessageBox::Ok, 0);
return;
}
DerevyankoReport::reportRFBR2013_01();
derrep2013window.setWindowTitle("DerevyankoReport2013");
derrep2013window.show();
derrep2013window.raise();
derrep2013window.setFocus();
derrep2013window.activateWindow();
emit drawRep2013();
}
if (dialog.checkKolch_button())
{
kolchshindwindow.setWindowTitle("Kolch_Shind");
kolchshindwindow.show();
kolchshindwindow.raise();
kolchshindwindow.setFocus();
kolchshindwindow.activateWindow();
//KolchShindyalov::test01();
}
if (dialog.checkInOutBreed_bitton())
{
CreateDialogs dialog(this, 7, "Breed");
int ret = dialog.exec();
if (ret == QDialog::Rejected)
{
return;
}
Settings::Iterations = dialog.getMaxGen();
Settings::InitPopSize = dialog.getInitPopSize();
Settings::InitRatioBetweenPops = dialog.getBetweenRatio();
Settings::KMaxParameter = dialog.getMaxIndivids();
Processor::testInOutBreeding02();
breedWindow.setWindowTitle("InOutBreeding");
breedWindow.setPopComboBoxes();
breedWindow.show();
breedWindow.raise();
breedWindow.setFocus();
breedWindow.activateWindow();
emit drawBreed(0);
}
if (dialog.checkAgressor_button())
{
Manager *man = new Manager();
}
}