paysages: Small improvements.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@298 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-04-16 18:28:40 +00:00 committed by ThunderK
parent 20bce5da8a
commit 6ebd78f030
3 changed files with 45 additions and 79 deletions

View file

@ -182,9 +182,16 @@ void BasePreview::paintEvent(QPaintEvent* event)
void BasePreview::forceRender()
{
this->lock_drawing->lock();
this->pixbuf->fill(0x00000000);
QImage part = pixbuf->copy();
pixbuf->fill(0x00000000);
QPainter painter(pixbuf);
painter.setOpacity(0.99);
painter.drawImage(0, 0, part);
this->need_rerender = false;
this->need_render = true;
this->lock_drawing->unlock();
}
@ -367,7 +374,7 @@ void BasePreview::wheelEvent(QWheelEvent* event)
lock_drawing->lock();
new_width = (int)floor(((double)width) * scaling / old_scaling);
new_height = (int)floor(((double)height) * scaling / old_scaling);
QImage part = pixbuf->copy((width - new_width) / 2, (height - new_height) / 2, new_width, new_height).scaled(width, height);
QImage part = pixbuf->copy((width - new_width) / 2, (height - new_height) / 2, new_width, new_height).scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
QPainter painter(pixbuf);
pixbuf->fill(0x00000000);
painter.setOpacity(0.99);
@ -386,7 +393,7 @@ void BasePreview::wheelEvent(QWheelEvent* event)
}
lock_drawing->lock();
QImage part = pixbuf->scaled((int)floor(((double)width) * old_scaling / scaling), (int)floor(((double)height) * old_scaling / scaling));
QImage part = pixbuf->scaled((int)floor(((double)width) * old_scaling / scaling), (int)floor(((double)height) * old_scaling / scaling), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
QPainter painter(pixbuf);
pixbuf->fill(0x00000000);
painter.setOpacity(0.99);
@ -403,70 +410,3 @@ void BasePreview::wheelEvent(QWheelEvent* event)
event->ignore();
}
}
//static void _scrollPixbuf(SmallPreview* preview, int dx, int dy)
//{
// int xstart, ystart, xsize, ysize, y;
// void* pixels = gdk_pixbuf_get_pixels(preview->pixbuf);
// int rowstride = gdk_pixbuf_get_rowstride(preview->pixbuf);
// preview->xoffset -= (double)dx * preview->scaling;
// preview->yoffset -= (double)dy * preview->scaling;
// /* TODO Use pixbuf size */
// if (dx == 0 && dy == 0)
// {
// return;
// }
// else if (dx <= -256 || dx >= 256 || dy <= -256 || dy >= 256)
// {
// _forceRender(preview);
// }
// else
// {
// if (dx < 0)
// {
// xstart = -dx;
// xsize = 256 + dx;
// }
// else
// {
// xstart = 0;
// xsize = 256 - dx;
// }
// if (dy < 0)
// {
// ystart = -dy;
// ysize = 256 + dy;
// }
// else
// {
// ystart = 0;
// ysize = 256 - dy;
// }
// memmove(pixels + (ystart + dy) * rowstride + (xstart + dx) * 4, pixels + ystart * rowstride + xstart * 4, (ysize - 1) * rowstride + xsize * 4);
// if (dy < 0)
// {
// memset(pixels + (256 + dy) * rowstride, 0, (-dy - 1) * rowstride + 256 * 4);
// }
// else if (dy > 0)
// {
// memset(pixels, 0, (dy - 1) * rowstride + 256 * 4);
// }
// if (dx < 0)
// {
// for (y = ystart + dy; y < ystart + dy + ysize; y++)
// {
// memset(pixels + y * rowstride + xsize * 4, 0, -dx * 4);
// }
// }
// else if (dx > 0)
// {
// for (y = ystart + dy; y < ystart + dy + ysize; y++)
// {
// memset(pixels + y * rowstride, 0, dx * 4);
// }
// }
// preview->need_render = 1;
// }
//}

View file

@ -137,9 +137,12 @@ void MainWindow::refreshAll()
void MainWindow::fileNew()
{
autoGenRealisticLandscape(0);
autoSetDaytime(8, 30);
refreshAll();
if (QMessageBox::question(this, tr("New lanscape"), tr("Do you want to start a new landscape ? Any unsaved changes will be lost."), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)
{
autoGenRealisticLandscape(0);
autoSetDaytime(8, 30);
refreshAll();
}
}
void MainWindow::fileSave()
@ -153,11 +156,14 @@ void MainWindow::fileSave()
void MainWindow::fileLoad()
{
QString filepath = QFileDialog::getOpenFileName(this);
if (!filepath.isNull())
if (QMessageBox::question(this, tr("Load lanscape"), tr("Do you want to load a landscape ? Any unsaved changes will be lost."), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)
{
paysagesLoad((char*)filepath.toStdString().c_str());
refreshAll();
QString filepath = QFileDialog::getOpenFileName(this);
if (!filepath.isNull())
{
paysagesLoad((char*)filepath.toStdString().c_str());
refreshAll();
}
}
}

View file

@ -823,12 +823,32 @@ rapide (F5)</translation>
<translation>&amp;A propos</translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="166"/>
<location filename="../gui_qt/mainwindow.cpp" line="140"/>
<source>New lanscape</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="140"/>
<source>Do you want to start a new landscape ? Any unsaved changes will be lost.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="159"/>
<source>Load lanscape</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="159"/>
<source>Do you want to load a landscape ? Any unsaved changes will be lost.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="172"/>
<source>Paysages 3D</source>
<translation>Paysages 3D</translation>
</message>
<message>
<location filename="../gui_qt/mainwindow.cpp" line="166"/>
<location filename="../gui_qt/mainwindow.cpp" line="172"/>
<source>A 3D landscape editing and rendering software.
Credits :