paysages: Qt GUI (WIP).
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@221 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
4b559f5cbb
commit
f91ed2c7f3
16 changed files with 2224 additions and 21 deletions
5
Makefile
5
Makefile
|
@ -1,13 +1,18 @@
|
|||
all:
|
||||
cd lib_paysages && make
|
||||
cd cli && make
|
||||
cd gui_gtk && make
|
||||
cd gui_qt && qmake && make
|
||||
|
||||
clean:
|
||||
cd lib_paysages && make clean
|
||||
cd cli && make clean
|
||||
cd gui_gtk && make clean
|
||||
cd gui_qt && make clean && rm -f Makefile paysages-qt
|
||||
|
||||
run_cli:
|
||||
LD_LIBRARY_PATH=lib_paysages ./cli/paysages-cli
|
||||
|
||||
run_gtk:
|
||||
LD_LIBRARY_PATH=lib_paysages ./gui_gtk/paysages-gtk
|
||||
|
||||
|
|
21
cli/Makefile
Normal file
21
cli/Makefile
Normal file
|
@ -0,0 +1,21 @@
|
|||
SOURCES=$(wildcard *.c)
|
||||
OBJECTS=${SOURCES:.c=.o}
|
||||
HEADERS=$(wildcard ../lib_paysages/shared/*.h ../lib_paysages/*.h *.h)
|
||||
RESULT=paysages-cli
|
||||
CC_FLAGS=-g -pg -Wall
|
||||
CC_LDFLAGS=-L../lib_paysages/ -lpaysages
|
||||
|
||||
all:${RESULT}
|
||||
|
||||
clean:
|
||||
rm -f ${OBJECTS}
|
||||
rm -f ${RESULT}
|
||||
|
||||
%.o:%.c ${HEADERS}
|
||||
${CC} -c ${CC_FLAGS} $< -o $@
|
||||
|
||||
${RESULT}:${OBJECTS}
|
||||
${CC} $^ ${CC_LDFLAGS} -o $@
|
||||
|
||||
.PHONY:all clean
|
||||
|
10
cli/main.c
Normal file
10
cli/main.c
Normal file
|
@ -0,0 +1,10 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../lib_paysages/shared/functions.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
paysagesInit();
|
||||
return 0;
|
||||
}
|
|
@ -67,7 +67,7 @@ void guiInit()
|
|||
gtk_init(&argc, &argv);
|
||||
|
||||
gui_definition = gtk_builder_new();
|
||||
gtk_builder_add_from_file(gui_definition, "data/gui.glade", &p_err);
|
||||
gtk_builder_add_from_file(gui_definition, "gui_gtk/gui.glade", &p_err);
|
||||
|
||||
_main_window = GTK_WINDOW(GET_WIDGET("main_window"));
|
||||
g_signal_connect(_main_window, "delete_event", G_CALLBACK(_cbQuit), NULL);
|
||||
|
|
2091
gui_gtk/gui.glade
Normal file
2091
gui_gtk/gui.glade
Normal file
File diff suppressed because it is too large
Load diff
|
@ -14,7 +14,6 @@
|
|||
BaseForm::BaseForm(QWidget* parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
QPushButton* button;
|
||||
QWidget* hwidget;
|
||||
QVBoxLayout* vlayout;
|
||||
QHBoxLayout* hlayout;
|
||||
|
@ -43,11 +42,14 @@ BaseForm::BaseForm(QWidget* parent) :
|
|||
|
||||
hwidget->setLayout(hlayout);
|
||||
this->setLayout(vlayout);
|
||||
this->setObjectName("_base_form_");
|
||||
|
||||
button = addButton("Apply");
|
||||
connect(button, SIGNAL(clicked()), this, SLOT(applyConfig()));
|
||||
button = addButton("Revert");
|
||||
connect(button, SIGNAL(clicked()), this, SLOT(revertConfig()));
|
||||
button_apply = addButton("Apply");
|
||||
button_apply->setEnabled(false);
|
||||
connect(button_apply, SIGNAL(clicked()), this, SLOT(applyConfig()));
|
||||
button_revert = addButton("Revert");
|
||||
button_revert->setEnabled(false);
|
||||
connect(button_revert, SIGNAL(clicked()), this, SLOT(revertConfig()));
|
||||
}
|
||||
|
||||
void BaseForm::applyConfigPreview()
|
||||
|
@ -57,6 +59,9 @@ void BaseForm::applyConfigPreview()
|
|||
{
|
||||
list_previews[i]->redraw();
|
||||
}
|
||||
|
||||
button_apply->setEnabled(true);
|
||||
button_revert->setEnabled(true);
|
||||
}
|
||||
|
||||
void BaseForm::revertConfig()
|
||||
|
@ -68,6 +73,9 @@ void BaseForm::revertConfig()
|
|||
}
|
||||
|
||||
BaseForm::applyConfigPreview();
|
||||
|
||||
button_apply->setEnabled(false);
|
||||
button_revert->setEnabled(false);
|
||||
}
|
||||
|
||||
void BaseForm::applyConfig()
|
||||
|
|
|
@ -35,6 +35,8 @@ private:
|
|||
QWidget* previews;
|
||||
QWidget* form;
|
||||
QWidget* buttons;
|
||||
QPushButton* button_apply;
|
||||
QPushButton* button_revert;
|
||||
};
|
||||
|
||||
#endif // _PAYSAGES_QT_BASEFORM_H_
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
DialogRender::DialogRender(QWidget *parent) :
|
||||
DialogRender::DialogRender(QWidget *parent, int quality, int width, int height):
|
||||
QDialog(parent)
|
||||
{
|
||||
QScrollArea* scroll;
|
||||
|
@ -74,7 +74,7 @@ DialogRender::DialogRender(QWidget *parent) :
|
|||
setLayout(new QVBoxLayout());
|
||||
|
||||
scroll = new QScrollArea(this);
|
||||
scroll->setMinimumSize(850, 650);
|
||||
scroll->setMinimumSize(width > 800 ? 850 : width + 50, height > 600 ? 650 : height + 50);
|
||||
scroll->setAlignment(Qt::AlignCenter);
|
||||
area = new RenderArea(scroll);
|
||||
scroll->setWidget(area);
|
||||
|
@ -83,13 +83,39 @@ DialogRender::DialogRender(QWidget *parent) :
|
|||
progress = new QProgressBar(this);
|
||||
progress->setMinimum(0);
|
||||
progress->setMaximum(1000);
|
||||
progress->setValue(0);
|
||||
layout()->addWidget(progress);
|
||||
progress_value = 0;
|
||||
|
||||
renderSetSize(800, 600);
|
||||
autoSetRenderQuality(5);
|
||||
renderSetSize(width, height);
|
||||
autoSetRenderQuality(quality);
|
||||
|
||||
renderSetPreviewCallbacks(_renderResize, _renderClear, _renderDraw, _renderUpdate);
|
||||
|
||||
render_thread = new RenderThread();
|
||||
render_thread->start();
|
||||
}
|
||||
|
||||
void DialogRender::closeEvent(QCloseEvent* e)
|
||||
{
|
||||
renderInterrupt();
|
||||
render_thread->wait();
|
||||
|
||||
renderSetPreviewCallbacks(NULL, NULL, NULL, NULL);
|
||||
|
||||
delete render_thread;
|
||||
delete pixbuf;
|
||||
}
|
||||
|
||||
void DialogRender::reject()
|
||||
{
|
||||
renderInterrupt();
|
||||
render_thread->wait();
|
||||
|
||||
renderSetPreviewCallbacks(NULL, NULL, NULL, NULL);
|
||||
|
||||
delete render_thread;
|
||||
delete pixbuf;
|
||||
|
||||
QDialog::reject();
|
||||
}
|
||||
|
|
|
@ -9,15 +9,17 @@ class DialogRender : public QDialog
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DialogRender(QWidget *parent = 0);
|
||||
explicit DialogRender(QWidget *parent, int quality, int width, int height);
|
||||
QImage* pixbuf;
|
||||
QWidget* area;
|
||||
QProgressBar* progress;
|
||||
int progress_value;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
virtual void reject();
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent* e);
|
||||
|
||||
private:
|
||||
QThread* render_thread;
|
||||
|
|
|
@ -5,11 +5,15 @@
|
|||
/**************** Form ****************/
|
||||
FormRender::FormRender(QWidget *parent) :
|
||||
BaseForm(parent),
|
||||
_quality(5)
|
||||
_quality(5),
|
||||
_width(800),
|
||||
_height(600)
|
||||
{
|
||||
QPushButton* button;
|
||||
|
||||
addInputInt("Quality", &_quality, 1, 10, 1, 1);
|
||||
addInputInt("Image width", &_width, 100, 2000, 10, 100);
|
||||
addInputInt("Image height", &_height, 100, 2000, 10, 100);
|
||||
|
||||
button = addButton("Start new render");
|
||||
connect(button, SIGNAL(clicked()), this, SLOT(startRender()));
|
||||
|
@ -23,7 +27,7 @@ FormRender::FormRender(QWidget *parent) :
|
|||
|
||||
void FormRender::startRender()
|
||||
{
|
||||
DialogRender* dialog = new DialogRender();
|
||||
DialogRender* dialog = new DialogRender(this, _quality, _width, _height);
|
||||
dialog->exec();
|
||||
|
||||
delete dialog;
|
||||
|
|
|
@ -17,6 +17,8 @@ private slots:
|
|||
|
||||
private:
|
||||
int _quality;
|
||||
int _width;
|
||||
int _height;
|
||||
};
|
||||
|
||||
#endif // _PAYSAGES_QT_FORMRENDER_H_
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "formwater.h"
|
||||
#include "formsky.h"
|
||||
#include "formrender.h"
|
||||
#include "dialogrender.h"
|
||||
|
||||
#include "../lib_paysages/shared/functions.h"
|
||||
|
||||
|
@ -36,28 +37,53 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
tabs->addTab(new FormSky(tabs), "Sky");
|
||||
tabs->addTab(new FormRender(tabs), "Render");
|
||||
|
||||
menu = menuBar()->addMenu("File");
|
||||
menu = menuBar()->addMenu("Scene");
|
||||
menu->addAction("New", this, SLOT(fileNew()));
|
||||
menu->addAction("Save", this, SLOT(fileSave()));
|
||||
menu->addAction("Load", this, SLOT(fileLoad()));
|
||||
menu->addAction("Quit", this, SLOT(close()));
|
||||
|
||||
menu = menuBar()->addMenu("Render");
|
||||
menu->addAction("Quick render", this, SLOT(quickPreview()), QKeySequence("F2"));
|
||||
|
||||
setCentralWidget(tabs);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::fileNew()
|
||||
{
|
||||
// TODO
|
||||
autoGenRealisticLandscape(0);
|
||||
refreshAll();
|
||||
}
|
||||
|
||||
void MainWindow::fileSave()
|
||||
{
|
||||
QString filepath = QFileDialog::getSaveFileName(this);
|
||||
autoSave((char*)filepath.toStdString().c_str());
|
||||
if (!filepath.isNull())
|
||||
{
|
||||
autoSave((char*)filepath.toStdString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::fileLoad()
|
||||
{
|
||||
QString filepath = QFileDialog::getOpenFileName(this);
|
||||
autoLoad((char*)filepath.toStdString().c_str());
|
||||
if (!filepath.isNull())
|
||||
{
|
||||
autoLoad((char*)filepath.toStdString().c_str());
|
||||
refreshAll();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::quickPreview()
|
||||
{
|
||||
DialogRender(this, 3, 400, 300).exec();
|
||||
}
|
||||
|
|
|
@ -15,9 +15,11 @@ public:
|
|||
explicit MainWindow(QWidget *parent = 0);
|
||||
|
||||
public slots:
|
||||
void refreshAll();
|
||||
void fileNew();
|
||||
void fileSave();
|
||||
void fileLoad();
|
||||
void quickPreview();
|
||||
};
|
||||
|
||||
#endif // _PAYSAGES_QT_MAINWINDOW_H_
|
||||
|
|
|
@ -2,8 +2,8 @@ SOURCES=$(wildcard *.c)
|
|||
OBJECTS=${SOURCES:.c=.o}
|
||||
HEADERS=$(wildcard shared/*.h *.h)
|
||||
RESULT=libpaysages.so
|
||||
CC_FLAGS=-g -pg -Wall $(shell pkg-config --cflags glib-2.0)
|
||||
CC_LDFLAGS=$(shell pkg-config --libs glib-2.0) -lIL -lILU
|
||||
CC_FLAGS=-g -pg -Wall $(shell pkg-config --cflags glib-2.0 gthread-2.0)
|
||||
CC_LDFLAGS=$(shell pkg-config --libs glib-2.0 gthread-2.0) -lIL -lILU
|
||||
|
||||
all:${RESULT}
|
||||
|
||||
|
|
|
@ -136,6 +136,8 @@ void renderClear()
|
|||
scanline_right = render_width - 1;
|
||||
|
||||
_progress = 0.0;
|
||||
_progress_step_start = 0.0;
|
||||
_progress_step_length = 0.0;
|
||||
_interrupt = 0;
|
||||
|
||||
_cb_preview_clear(background_color);
|
||||
|
|
|
@ -75,6 +75,8 @@ WaterDefinition waterCreateDefinition()
|
|||
{
|
||||
WaterDefinition result;
|
||||
|
||||
result.main_color = COLOR_BLACK;
|
||||
result.depth_color = COLOR_BLACK;
|
||||
result.height = -1000.0;
|
||||
result.height_noise = noiseCreateGenerator();
|
||||
result.height_noise_factor = 1.0;
|
||||
|
|
Loading…
Reference in a new issue