2011-12-25 21:19:32 +00:00
|
|
|
#include "mainwindow.h"
|
2012-01-08 10:31:01 +00:00
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QMenuBar>
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
2011-12-25 21:19:32 +00:00
|
|
|
#include "formwater.h"
|
2012-01-07 16:53:23 +00:00
|
|
|
#include "formsky.h"
|
2012-01-06 16:09:03 +00:00
|
|
|
#include "formrender.h"
|
2012-01-10 20:51:27 +00:00
|
|
|
#include "dialogrender.h"
|
2011-12-25 21:19:32 +00:00
|
|
|
|
2012-01-05 18:39:17 +00:00
|
|
|
#include "../lib_paysages/shared/functions.h"
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
2011-12-25 21:19:32 +00:00
|
|
|
{
|
2012-01-05 18:39:17 +00:00
|
|
|
paysagesInit();
|
2011-12-25 21:19:32 +00:00
|
|
|
|
2012-01-05 18:39:17 +00:00
|
|
|
QApplication app(argc, argv);
|
|
|
|
MainWindow window;
|
2011-12-25 21:19:32 +00:00
|
|
|
|
2012-01-05 18:39:17 +00:00
|
|
|
window.show();
|
|
|
|
|
|
|
|
Preview::startUpdater();
|
|
|
|
|
|
|
|
return app.exec();
|
2011-12-25 21:19:32 +00:00
|
|
|
}
|
|
|
|
|
2012-01-05 18:39:17 +00:00
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
|
|
|
QMainWindow(parent)
|
2011-12-25 21:19:32 +00:00
|
|
|
{
|
2012-01-05 18:39:17 +00:00
|
|
|
QTabWidget* tabs;
|
2012-01-08 10:31:01 +00:00
|
|
|
QMenu* menu;
|
2012-01-05 18:39:17 +00:00
|
|
|
|
|
|
|
tabs = new QTabWidget(this);
|
2012-01-06 16:09:03 +00:00
|
|
|
tabs->addTab(new BaseForm(tabs), "Temp");
|
2012-01-05 18:39:17 +00:00
|
|
|
tabs->addTab(new FormWater(tabs), "Water");
|
2012-01-07 16:53:23 +00:00
|
|
|
tabs->addTab(new FormSky(tabs), "Sky");
|
2012-01-06 16:09:03 +00:00
|
|
|
tabs->addTab(new FormRender(tabs), "Render");
|
2012-01-05 18:39:17 +00:00
|
|
|
|
2012-01-10 20:51:27 +00:00
|
|
|
menu = menuBar()->addMenu("Scene");
|
2012-01-08 10:31:01 +00:00
|
|
|
menu->addAction("New", this, SLOT(fileNew()));
|
|
|
|
menu->addAction("Save", this, SLOT(fileSave()));
|
|
|
|
menu->addAction("Load", this, SLOT(fileLoad()));
|
|
|
|
menu->addAction("Quit", this, SLOT(close()));
|
|
|
|
|
2012-01-10 20:51:27 +00:00
|
|
|
menu = menuBar()->addMenu("Render");
|
|
|
|
menu->addAction("Quick render", this, SLOT(quickPreview()), QKeySequence("F2"));
|
|
|
|
|
2012-01-05 18:39:17 +00:00
|
|
|
setCentralWidget(tabs);
|
2012-01-16 21:29:21 +00:00
|
|
|
|
|
|
|
setWindowTitle("Paysages 3D");
|
2011-12-25 21:19:32 +00:00
|
|
|
}
|
2012-01-08 10:31:01 +00:00
|
|
|
|
2012-01-10 20:51:27 +00:00
|
|
|
void MainWindow::refreshAll()
|
|
|
|
{
|
|
|
|
QList<BaseForm*> list_forms = this->findChildren<BaseForm*>("_base_form_");
|
|
|
|
for (int i = 0; i < list_forms.size(); i++)
|
|
|
|
{
|
|
|
|
list_forms[i]->revertConfig();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-08 10:31:01 +00:00
|
|
|
void MainWindow::fileNew()
|
|
|
|
{
|
2012-01-10 20:51:27 +00:00
|
|
|
autoGenRealisticLandscape(0);
|
|
|
|
refreshAll();
|
2012-01-08 10:31:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::fileSave()
|
|
|
|
{
|
|
|
|
QString filepath = QFileDialog::getSaveFileName(this);
|
2012-01-10 20:51:27 +00:00
|
|
|
if (!filepath.isNull())
|
|
|
|
{
|
|
|
|
autoSave((char*)filepath.toStdString().c_str());
|
|
|
|
}
|
2012-01-08 10:31:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::fileLoad()
|
|
|
|
{
|
|
|
|
QString filepath = QFileDialog::getOpenFileName(this);
|
2012-01-10 20:51:27 +00:00
|
|
|
if (!filepath.isNull())
|
|
|
|
{
|
|
|
|
autoLoad((char*)filepath.toStdString().c_str());
|
|
|
|
refreshAll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::quickPreview()
|
|
|
|
{
|
|
|
|
DialogRender(this, 3, 400, 300).exec();
|
2012-01-08 10:31:01 +00:00
|
|
|
}
|