2012-01-06 16:09:03 +00:00
|
|
|
#include "formrender.h"
|
|
|
|
|
2012-01-18 16:20:14 +00:00
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QMessageBox>
|
2012-01-06 16:09:03 +00:00
|
|
|
#include "dialogrender.h"
|
2012-01-27 23:01:21 +00:00
|
|
|
#include "inputcamera.h"
|
2012-01-24 13:16:20 +00:00
|
|
|
#include "../lib_paysages/render.h"
|
2012-01-27 23:01:21 +00:00
|
|
|
#include "../lib_paysages/scenery.h"
|
2012-01-18 16:20:14 +00:00
|
|
|
#include "../lib_paysages/shared/functions.h"
|
2012-01-06 16:09:03 +00:00
|
|
|
|
|
|
|
/**************** Form ****************/
|
|
|
|
FormRender::FormRender(QWidget *parent) :
|
2012-01-27 23:01:21 +00:00
|
|
|
BaseForm(parent, true)
|
2012-01-06 16:09:03 +00:00
|
|
|
{
|
|
|
|
QPushButton* button;
|
|
|
|
|
2012-01-27 23:01:21 +00:00
|
|
|
_quality = 5;
|
|
|
|
_width = 800;
|
|
|
|
_height = 600;
|
|
|
|
_camera = cameraCreateDefinition();
|
|
|
|
|
|
|
|
addInput(new InputCamera(this, "Camera", &_camera));
|
2012-01-06 16:09:03 +00:00
|
|
|
addInputInt("Quality", &_quality, 1, 10, 1, 1);
|
2012-01-10 20:51:27 +00:00
|
|
|
addInputInt("Image width", &_width, 100, 2000, 10, 100);
|
|
|
|
addInputInt("Image height", &_height, 100, 2000, 10, 100);
|
2012-01-06 16:09:03 +00:00
|
|
|
|
|
|
|
button = addButton("Start new render");
|
|
|
|
connect(button, SIGNAL(clicked()), this, SLOT(startRender()));
|
|
|
|
button = addButton("Show last render");
|
|
|
|
connect(button, SIGNAL(clicked()), this, SLOT(showRender()));
|
|
|
|
button = addButton("Save last render");
|
|
|
|
connect(button, SIGNAL(clicked()), this, SLOT(saveRender()));
|
|
|
|
|
|
|
|
revertConfig();
|
|
|
|
}
|
|
|
|
|
2012-01-27 23:01:21 +00:00
|
|
|
void FormRender::revertConfig()
|
|
|
|
{
|
|
|
|
sceneryGetCamera(&_camera);
|
|
|
|
BaseForm::revertConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormRender::applyConfig()
|
|
|
|
{
|
|
|
|
scenerySetCamera(&_camera);
|
|
|
|
BaseForm::applyConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormRender::configChangeEvent()
|
|
|
|
{
|
|
|
|
cameraValidateDefinition(&_camera);
|
|
|
|
BaseForm::configChangeEvent();
|
|
|
|
}
|
|
|
|
|
2012-01-06 16:09:03 +00:00
|
|
|
void FormRender::startRender()
|
|
|
|
{
|
2012-01-18 16:20:14 +00:00
|
|
|
DialogRender* dialog = new DialogRender(this);
|
|
|
|
dialog->startRender(_quality, _width, _height);
|
2012-01-24 13:16:20 +00:00
|
|
|
|
2012-01-06 16:09:03 +00:00
|
|
|
delete dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormRender::showRender()
|
|
|
|
{
|
2012-01-18 16:20:14 +00:00
|
|
|
DialogRender* dialog = new DialogRender(this);
|
|
|
|
dialog->loadLastRender();
|
2012-01-24 13:16:20 +00:00
|
|
|
|
2012-01-18 16:20:14 +00:00
|
|
|
delete dialog;
|
2012-01-06 16:09:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FormRender::saveRender()
|
|
|
|
{
|
2012-01-18 16:20:14 +00:00
|
|
|
QString filepath;
|
2012-01-24 13:16:20 +00:00
|
|
|
|
2012-01-18 16:20:14 +00:00
|
|
|
filepath = QFileDialog::getSaveFileName(this, "Choose a filename to save the last render");
|
|
|
|
if (!filepath.isNull())
|
|
|
|
{
|
|
|
|
renderSaveToFile((char*)filepath.toStdString().c_str());
|
|
|
|
QMessageBox::information(this, "Message", "The picture " + filepath + " has been saved.");
|
|
|
|
}
|
2012-01-06 16:09:03 +00:00
|
|
|
}
|