Several fixes and small changes

This commit is contained in:
Michaël Lemaire 2013-08-17 18:08:37 +02:00
parent c8f36643d0
commit f199963867
7 changed files with 70 additions and 45 deletions

View file

@ -14,6 +14,7 @@
<file>images/layer_down.png</file>
<file>images/layer_rename.png</file>
<file>images/layer_up.png</file>
<file>images/auto.png</file>
</qresource>
<qresource prefix="/tabs">
<file>images/tab_atmosphere.png</file>

View file

@ -39,15 +39,15 @@ bool FreeFormHelper::eventFilter(QObject* object, QEvent* event)
if (form_size.width() > 1400 && form_size.height() > 900)
{
preview_size = QSize(300, 300);
preview_size = QSize(320, 320);
}
else if (form_size.width() < 1000 || form_size.height() < 700)
{
preview_size = QSize(160, 160);
preview_size = QSize(200, 200);
}
else
{
preview_size = QSize(220, 220);
preview_size = QSize(260, 260);
}
for (int i = 0; i < _previews.size(); i++)

View file

@ -67,12 +67,26 @@ void FreeLayerHelper::setDelButton(QPushButton* button)
void FreeLayerHelper::setDownButton(QPushButton* button)
{
connect(button, SIGNAL(clicked()), this, SLOT(moveLayerDown()));
if (_reverse)
{
connect(button, SIGNAL(clicked()), this, SLOT(moveLayerDown()));
}
else
{
connect(button, SIGNAL(clicked()), this, SLOT(moveLayerUp()));
}
}
void FreeLayerHelper::setUpButton(QPushButton* button)
{
connect(button, SIGNAL(clicked()), this, SLOT(moveLayerUp()));
if (_reverse)
{
connect(button, SIGNAL(clicked()), this, SLOT(moveLayerUp()));
}
else
{
connect(button, SIGNAL(clicked()), this, SLOT(moveLayerDown()));
}
}
void FreeLayerHelper::addLayer()
@ -88,16 +102,30 @@ void FreeLayerHelper::deleteLayer()
{
layersDeleteLayer(_layers, _selected);
emit(layersChanged());
refreshLayers();
}
refreshLayers();
}
void FreeLayerHelper::moveLayerDown()
{
if (_selected > 0)
{
layersMove(_layers, _selected, _selected - 1);
_selected--;
emit(layersChanged());
refreshLayers();
}
}
void FreeLayerHelper::moveLayerUp()
{
if (_selected >= 0 && _selected < layersCount(_layers) - 1)
{
layersMove(_layers, _selected, _selected + 1);
_selected++;
emit(layersChanged());
refreshLayers();
}
}
void FreeLayerHelper::tableSelectionChanged(int row, int)

View file

@ -15,7 +15,6 @@
#include "basepreview.h"
#include "formclouds.h"
#include "formatmosphere.h"
#include "formtextures.h"
#include "formwater.h"
#include "formrender.h"
@ -92,16 +91,12 @@ MainWindow::MainWindow() :
connect(ui->action_explore, SIGNAL(triggered()), this, SLOT(explore3D()));
connect(ui->action_quick_render, SIGNAL(triggered()), this, SLOT(quickPreview()));
connect(ui->action_final_render, SIGNAL(triggered()), this, SLOT(finalRender()));
connect(ui->action_last_render, SIGNAL(triggered()), this, SLOT(showLastRender()));
connect(ui->action_file_new, SIGNAL(triggered()), this, SLOT(fileNew()));
connect(ui->action_file_save, SIGNAL(triggered()), this, SLOT(fileSave()));
connect(ui->action_file_load, SIGNAL(triggered()), this, SLOT(fileLoad()));
connect(ui->action_about, SIGNAL(triggered()), this, SLOT(showAboutDialog()));
form = new FormTextures(ui->tabs);
ui->tabs->addTab(form, QIcon(getDataPath("images/tab_textures.png")), tr("Textures"));
QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()), Qt::QueuedConnection);
_forms.append(form);
form = new FormWater(ui->tabs);
ui->tabs->addTab(form, QIcon(getDataPath("images/tab_water.png")), tr("Water"));
QObject::connect(form, SIGNAL(configApplied()), this, SLOT(refreshAll()), Qt::QueuedConnection);

View file

@ -12,13 +12,6 @@ MainTexturesForm::MainTexturesForm(QWidget *parent) : QWidget(parent), ui(new Ui
ui->setupUi(this);
form_helper = new FreeFormHelper(this);
form_helper->setApplyButton(ui->button_apply);
form_helper->setRevertButton(ui->button_revert);
form_helper->setExploreButton(ui->button_explore);
form_helper->setRenderButton(ui->button_render);
form_helper->startManaging();
layer_helper = new FreeLayerHelper(textures->layers, true);
layer_helper->setLayerTable(ui->layersGrid);
layer_helper->setAddButton(ui->layer_add);
@ -26,8 +19,16 @@ MainTexturesForm::MainTexturesForm(QWidget *parent) : QWidget(parent), ui(new Ui
layer_helper->setDownButton(ui->layer_down);
layer_helper->setUpButton(ui->layer_up);
connect(layer_helper, SIGNAL(tableUpdateNeeded()), this, SLOT(updateLayers()));
connect(layer_helper, SIGNAL(layersChanged()), form_helper, SLOT(processDataChange()));
connect(layer_helper, SIGNAL(selectionChanged(int)), this, SLOT(selectLayer(int)));
form_helper = new FreeFormHelper(this);
form_helper->setApplyButton(ui->button_apply);
form_helper->setRevertButton(ui->button_revert);
form_helper->setExploreButton(ui->button_explore);
form_helper->setRenderButton(ui->button_render);
form_helper->startManaging();
connect(layer_helper, SIGNAL(layersChanged()), form_helper, SLOT(processDataChange()));
}
MainTexturesForm::~MainTexturesForm()

View file

@ -77,11 +77,6 @@
<string>Material</string>
</property>
</column>
<column>
<property name="text">
<string>Modify terrain</string>
</property>
</column>
</widget>
</item>
<item>
@ -186,13 +181,13 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="layer_down">
<widget class="QPushButton" name="layer_up">
<property name="text">
<string>Move layer down</string>
<string>Move layer up</string>
</property>
<property name="icon">
<iconset resource="../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/layer_down.png</normaloff>:/buttons/logo/images/layer_down.png</iconset>
<normaloff>:/buttons/logo/images/layer_up.png</normaloff>:/buttons/logo/images/layer_up.png</iconset>
</property>
<property name="iconSize">
<size>
@ -203,13 +198,13 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="layer_up">
<widget class="QPushButton" name="layer_down">
<property name="text">
<string>Move layer up</string>
<string>Move layer down</string>
</property>
<property name="icon">
<iconset resource="../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/layer_up.png</normaloff>:/buttons/logo/images/layer_up.png</iconset>
<normaloff>:/buttons/logo/images/layer_down.png</normaloff>:/buttons/logo/images/layer_down.png</iconset>
</property>
<property name="iconSize">
<size>
@ -401,6 +396,17 @@
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QPushButton" name="button_preset">
<property name="text">
<string>Load preset</string>
</property>
<property name="icon">
<iconset resource="../../../data/ui_pictures.qrc">
<normaloff>:/buttons/logo/images/auto.png</normaloff>:/buttons/logo/images/auto.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_revert">
<property name="text">

View file

@ -86,8 +86,6 @@ typedef struct
RenderArea* area;
} RenderChunk;
#define RENDER_INVERSE 1
static void _callbackStart(int width, int height, Color background) {}
static void _callbackDraw(int x, int y, Color col) {}
static void _callbackUpdate(double progress) {}
@ -602,13 +600,9 @@ void* _renderPostProcessChunk(void* data)
RenderFragment* fragment;
RenderChunk* chunk = (RenderChunk*)data;
#ifdef RENDER_INVERSE
for (y = chunk->area->params.height * chunk->area->params.antialias - 1 - chunk->starty; y >= chunk->area->params.height * chunk->area->params.antialias - 1 - chunk->endy; y--)
#else
for (y = chunk->starty; y <= chunk->endy; y++)
#endif
{
for (x = chunk->startx; x <= chunk->endx; x++)
for (x = chunk->startx; x <= chunk->endx; x++)
{
for (y = chunk->starty; y <= chunk->endy; y++)
{
fragment = chunk->area->pixels + (y * chunk->area->params.width * chunk->area->params.antialias + x);
if (fragment->flags.dirty)
@ -681,7 +675,7 @@ void renderPostProcess(RenderArea* area, int nbchunks)
running = 0;
loops = 0;
while ((y < ny && !area->renderer->render_interrupt) || running > 0)
while ((x < nx && !area->renderer->render_interrupt) || running > 0)
{
timeSleepMs(50);
@ -703,7 +697,7 @@ void renderPostProcess(RenderArea* area, int nbchunks)
area->renderer->render_progress = 0.1 + ((double)area->pixel_done / (double)area->pixel_count) * 0.9;
if (y < ny && !chunks[i].thread && !area->renderer->render_interrupt)
if (x < nx && !chunks[i].thread && !area->renderer->render_interrupt)
{
chunks[i].finished = 0;
chunks[i].interrupt = 0;
@ -729,10 +723,10 @@ void renderPostProcess(RenderArea* area, int nbchunks)
chunks[i].thread = threadCreate(_renderPostProcessChunk, (void*)(chunks + i));
running++;
if (++x >= nx)
if (++y >= ny)
{
y++;
x = 0;
x++;
y = 0;
}
}
}