2011-12-25 21:19:32 +00:00
|
|
|
#include "mainwindow.h"
|
2012-01-08 10:31:01 +00:00
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QMenuBar>
|
2012-01-23 23:45:33 +00:00
|
|
|
#include <QMenu>
|
2012-01-08 10:31:01 +00:00
|
|
|
#include <QFileDialog>
|
2012-01-23 23:45:33 +00:00
|
|
|
#include <QTabWidget>
|
2012-01-08 10:31:01 +00:00
|
|
|
|
2012-01-26 23:08:09 +00:00
|
|
|
#include "formatmosphere.h"
|
|
|
|
#include "formclouds.h"
|
|
|
|
#include "formlighting.h"
|
|
|
|
#include "formsky.h"
|
2012-01-22 18:39:42 +00:00
|
|
|
#include "formterrain.h"
|
2012-01-26 23:08:09 +00:00
|
|
|
#include "formtextures.h"
|
2011-12-25 21:19:32 +00:00
|
|
|
#include "formwater.h"
|
2012-01-06 16:09:03 +00:00
|
|
|
#include "formrender.h"
|
2012-01-26 23:08:09 +00:00
|
|
|
|
2012-01-10 20:51:27 +00:00
|
|
|
#include "dialogrender.h"
|
2012-01-26 23:08:09 +00:00
|
|
|
#include "dialogwanderer.h"
|
2011-12-25 21:19:32 +00:00
|
|
|
|
2012-01-29 17:39:56 +00:00
|
|
|
#include "../lib_paysages/main.h"
|
2012-01-24 13:16:20 +00:00
|
|
|
#include "../lib_paysages/auto.h"
|
2012-01-27 14:47:08 +00:00
|
|
|
#include "../lib_paysages/scenery.h"
|
2012-01-05 18:39:17 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
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-26 22:30:20 +00:00
|
|
|
BaseForm* form;
|
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-26 22:30:20 +00:00
|
|
|
|
|
|
|
form = new FormTerrain(tabs);
|
|
|
|
tabs->addTab(form, "Terrain");
|
|
|
|
QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()));
|
|
|
|
|
2012-01-26 23:08:09 +00:00
|
|
|
form = new FormTextures(tabs);
|
|
|
|
tabs->addTab(form, "Textures");
|
|
|
|
QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()));
|
|
|
|
|
2012-01-26 22:30:20 +00:00
|
|
|
form = new FormWater(tabs);
|
|
|
|
tabs->addTab(form, "Water");
|
|
|
|
QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()));
|
|
|
|
|
2012-01-26 23:08:09 +00:00
|
|
|
form = new FormAtmosphere(tabs);
|
|
|
|
tabs->addTab(form, "Atmosphere");
|
|
|
|
QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()));
|
|
|
|
|
2012-01-26 22:30:20 +00:00
|
|
|
form = new FormSky(tabs);
|
|
|
|
tabs->addTab(form, "Sky");
|
|
|
|
QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()));
|
|
|
|
|
2012-01-26 23:08:09 +00:00
|
|
|
form = new FormClouds(tabs);
|
|
|
|
tabs->addTab(form, "Clouds");
|
|
|
|
QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()));
|
|
|
|
|
|
|
|
form = new FormLighting(tabs);
|
|
|
|
tabs->addTab(form, "Lighting");
|
|
|
|
QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()));
|
|
|
|
|
2012-01-26 22:30:20 +00:00
|
|
|
form = new FormRender(tabs);
|
|
|
|
tabs->addTab(form, "Render");
|
2012-01-26 23:08:09 +00:00
|
|
|
//QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()));
|
2012-01-05 18:39:17 +00:00
|
|
|
|
2012-01-10 20:51:27 +00:00
|
|
|
menu = menuBar()->addMenu("Scene");
|
2012-01-28 11:04:27 +00:00
|
|
|
menu->addAction("New", this, SLOT(fileNew()), QKeySequence(Qt::CTRL + Qt::Key_N));
|
|
|
|
menu->addSeparator();
|
|
|
|
menu->addAction("Save", this, SLOT(fileSave()), QKeySequence(Qt::CTRL + Qt::Key_S));
|
|
|
|
menu->addAction("Open", this, SLOT(fileLoad()), QKeySequence(Qt::CTRL + Qt::Key_O));
|
|
|
|
menu->addSeparator();
|
|
|
|
menu->addAction("Quit", this, SLOT(close()), QKeySequence(Qt::CTRL + Qt::Key_Q));
|
2012-01-08 10:31:01 +00:00
|
|
|
|
2012-01-26 23:08:09 +00:00
|
|
|
menu = menuBar()->addMenu("Actions");
|
|
|
|
menu->addAction("Explore in 3D", this, SLOT(explore3D()), QKeySequence("F2"));
|
|
|
|
menu->addAction("Quick render", this, SLOT(quickPreview()), QKeySequence("F5"));
|
2012-01-10 20:51:27 +00:00
|
|
|
|
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())
|
|
|
|
{
|
2012-01-22 22:06:11 +00:00
|
|
|
paysagesSave((char*)filepath.toStdString().c_str());
|
2012-01-10 20:51:27 +00:00
|
|
|
}
|
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())
|
|
|
|
{
|
2012-01-22 22:06:11 +00:00
|
|
|
paysagesLoad((char*)filepath.toStdString().c_str());
|
2012-01-10 20:51:27 +00:00
|
|
|
refreshAll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::quickPreview()
|
|
|
|
{
|
2012-01-18 16:20:14 +00:00
|
|
|
DialogRender* dialog = new DialogRender(this);
|
|
|
|
dialog->startRender(3, 400, 300);
|
2012-01-18 19:49:03 +00:00
|
|
|
|
2012-01-18 16:20:14 +00:00
|
|
|
delete dialog;
|
2012-01-08 10:31:01 +00:00
|
|
|
}
|
2012-01-26 23:08:09 +00:00
|
|
|
|
|
|
|
void MainWindow::explore3D()
|
|
|
|
{
|
2012-01-27 14:47:08 +00:00
|
|
|
CameraDefinition camera;
|
|
|
|
|
|
|
|
sceneryGetCamera(&camera);
|
|
|
|
|
2012-01-31 11:20:52 +00:00
|
|
|
DialogWanderer* dialog = new DialogWanderer(this, &camera, true);
|
2012-01-26 23:08:09 +00:00
|
|
|
dialog->exec();
|
2012-01-31 11:20:52 +00:00
|
|
|
|
|
|
|
scenerySetCamera(&camera);
|
2012-01-26 23:08:09 +00:00
|
|
|
|
|
|
|
delete dialog;
|
|
|
|
}
|