diff --git a/gui_qt/baseexplorerchunk.cpp b/gui_qt/baseexplorerchunk.cpp index 34867de..70b6379 100644 --- a/gui_qt/baseexplorerchunk.cpp +++ b/gui_qt/baseexplorerchunk.cpp @@ -3,10 +3,10 @@ BaseExplorerChunk::BaseExplorerChunk(Renderer* renderer) { _renderer = renderer; - + priority = 0.0; _reset_needed = false; - + _texture = new QImage(1, 1, QImage::Format_ARGB32); _texture_id = 0; _texture_changed = false; @@ -24,7 +24,7 @@ BaseExplorerChunk::~BaseExplorerChunk() bool BaseExplorerChunk::maintain() { bool subchanged; - + _lock_data.lock(); if (_reset_needed) { @@ -33,9 +33,9 @@ bool BaseExplorerChunk::maintain() onResetEvent(); } _lock_data.unlock(); - + subchanged = onMaintainEvent(); - + // Improve texture resolution if (_texture_current_size < _texture_max_size) { @@ -60,7 +60,7 @@ bool BaseExplorerChunk::maintain() _texture_current_size = new_texture_size; _texture_changed = true; _lock_data.unlock(); - + return true; } else @@ -108,7 +108,7 @@ void BaseExplorerChunk::render(QGLWidget* widget) glBindTexture(GL_TEXTURE_2D, _texture_id); } _lock_data.unlock(); - + // Delegate poly rendering to subclass onRenderEvent(widget); } @@ -123,7 +123,7 @@ void BaseExplorerChunk::setMaxTextureSize(int size) _texture_max_size = size; } -void BaseExplorerChunk::onCameraEvent(CameraDefinition* camera) +void BaseExplorerChunk::onCameraEvent(CameraDefinition*) { } @@ -136,16 +136,16 @@ bool BaseExplorerChunk::onMaintainEvent() return false; } -void BaseExplorerChunk::onRenderEvent(QGLWidget* widget) +void BaseExplorerChunk::onRenderEvent(QGLWidget*) { } -double BaseExplorerChunk::getDisplayedSizeHint(CameraDefinition* camera) +double BaseExplorerChunk::getDisplayedSizeHint(CameraDefinition*) { return 0.0; } -Color BaseExplorerChunk::getTextureColor(double x, double y) +Color BaseExplorerChunk::getTextureColor(double, double) { return COLOR_TRANSPARENT; } \ No newline at end of file diff --git a/gui_qt/dialogcolorgradation.cpp b/gui_qt/dialogcolorgradation.cpp index aa0a658..7071444 100644 --- a/gui_qt/dialogcolorgradation.cpp +++ b/gui_qt/dialogcolorgradation.cpp @@ -21,18 +21,18 @@ DialogColorGradation::DialogColorGradation(QWidget *parent, ColorGradation* grad QWidget* form; QGridLayout* form_layout; QLabel* label; - + _base = gradation; _current = colorGradationCreate(); colorGradationCopy(_base, _current); setLayout(new QVBoxLayout()); - + form = new QWidget(this); form_layout = new QGridLayout(); form->setLayout(form_layout); layout()->addWidget(form); - + label = new QLabel(tr("This is the curve editor for color components.\nClick on a component preview below to edit it.\nClick on points and drag them to move them.\nDouble click to add a new point.\nRight click on a point to delete it."), form); label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); label->setMinimumWidth(150); @@ -94,11 +94,11 @@ DialogColorGradation::DialogColorGradation(QWidget *parent, ColorGradation* grad _preview_final->setMaximumHeight(60); _preview_final->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); form_layout->addWidget(_preview_final, 4, 0); - + buttons = new QWidget(this); layout()->addWidget(buttons); buttons->setLayout(new QHBoxLayout()); - + _button_accept = new QPushButton(tr("Validate"), buttons); buttons->layout()->addWidget(_button_accept); QObject::connect(_button_accept, SIGNAL(clicked()), this, SLOT(accept())); @@ -137,7 +137,7 @@ bool DialogColorGradation::getGradation(QWidget* parent, ColorGradation* gradati return (result != 0) ? true : false; } -void DialogColorGradation::closeEvent(QCloseEvent* e) +void DialogColorGradation::closeEvent(QCloseEvent*) { reject(); } @@ -182,10 +182,10 @@ void DialogColorGradation::selectBlue() void DialogColorGradation::updateColors() { Curve* curve; - + curve = curveCreate(); _curve_editor->getCurve(curve); - + switch (_selected) { case 0: @@ -209,7 +209,7 @@ void DialogColorGradation::updateColors() ; } _preview_final->update(); - + curveDelete(curve); } diff --git a/gui_qt/dialogrender.cpp b/gui_qt/dialogrender.cpp index 773c084..c17bfbe 100644 --- a/gui_qt/dialogrender.cpp +++ b/gui_qt/dialogrender.cpp @@ -15,9 +15,12 @@ static DialogRender* _current_dialog; static void _renderStart(int width, int height, Color background) { + _current_dialog->pixbuf_lock->lock(); delete _current_dialog->pixbuf; _current_dialog->pixbuf = new QImage(width, height, QImage::Format_ARGB32); _current_dialog->pixbuf->fill(colorToQColor(background).rgb()); + _current_dialog->pixbuf_lock->unlock(); + _current_dialog->tellRenderSize(width, height); } @@ -61,18 +64,21 @@ public: void paintEvent(QPaintEvent*) { QPainter painter(this); + _current_dialog->pixbuf_lock->lock(); painter.drawImage(0, 0, *_current_dialog->pixbuf); + _current_dialog->pixbuf_lock->unlock(); } }; DialogRender::DialogRender(QWidget *parent, Renderer* renderer): QDialog(parent, Qt::WindowTitleHint | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint) { + pixbuf_lock = new QMutex(); pixbuf = new QImage(1, 1, QImage::Format_ARGB32); _current_dialog = this; _render_thread = NULL; _renderer = renderer; - + setModal(true); setWindowTitle(tr("Paysages 3D - Render")); setLayout(new QVBoxLayout()); @@ -82,21 +88,21 @@ DialogRender::DialogRender(QWidget *parent, Renderer* renderer): area = new RenderArea(_scroll); _scroll->setWidget(area); layout()->addWidget(_scroll); - + _info = new QWidget(this); _info->setLayout(new QHBoxLayout()); layout()->addWidget(_info); _timer = new QLabel(QString("0:00.00"), _info); _info->layout()->addWidget(_timer); - + _progress = new QProgressBar(_info); _progress->setMaximumHeight(12); _progress->setMinimum(0); _progress->setMaximum(1000); _progress->setValue(0); _info->layout()->addWidget(_progress); - + connect(this, SIGNAL(renderSizeChanged(int, int)), this, SLOT(applyRenderSize(int, int))); connect(this, SIGNAL(progressChanged(double)), this, SLOT(applyProgress(double))); } @@ -111,6 +117,7 @@ DialogRender::~DialogRender() delete _render_thread; } delete pixbuf; + delete pixbuf_lock; } void DialogRender::tellRenderSize(int width, int height) @@ -126,7 +133,7 @@ void DialogRender::tellProgressChange(double value) void DialogRender::startRender(RenderParams params) { _started = time(NULL); - + //applyRenderSize(params.width, params.height); rendererSetPreviewCallbacks(_renderer, _renderStart, _renderDraw, _renderUpdate); diff --git a/gui_qt/dialogrender.h b/gui_qt/dialogrender.h index 0a5c7ee..ad0d49b 100644 --- a/gui_qt/dialogrender.h +++ b/gui_qt/dialogrender.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "../lib_paysages/renderer.h" class DialogRender : public QDialog @@ -22,12 +23,13 @@ public: void loadLastRender(); QImage* pixbuf; + QMutex* pixbuf_lock; QWidget* area; - + private slots: void applyRenderSize(int width, int height); void applyProgress(double value); - + signals: void renderSizeChanged(int width, int height); void progressChanged(double value); diff --git a/gui_qt/formrender.cpp b/gui_qt/formrender.cpp index 3f3746d..f792ea4 100644 --- a/gui_qt/formrender.cpp +++ b/gui_qt/formrender.cpp @@ -91,7 +91,7 @@ private: lightingGetStatus((LightingDefinition*)renderer->customData[2], renderer, location, status); } - static Color _applyAerialPerspective(Renderer* renderer, Vector3 location, Color base) + static Color _applyAerialPerspective(Renderer*, Vector3, Color base) { return base; }