Fix free form refreshing from global data update

This commit is contained in:
Michaël Lemaire 2013-06-20 23:18:15 +02:00
parent 3d7aefe79d
commit da27cc9b1e
5 changed files with 78 additions and 57 deletions

View file

@ -1429,7 +1429,7 @@ Maintenir Ctrl : Plus rapide</translation>
<message> <message>
<location filename="../../src/editing/terrain/mainterrainform.ui" line="14"/> <location filename="../../src/editing/terrain/mainterrainform.ui" line="14"/>
<source>Terrain editor</source> <source>Terrain editor</source>
<translation type="unfinished"></translation> <translation>Editeur de terrain</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/terrain/mainterrainform.ui" line="122"/> <location filename="../../src/editing/terrain/mainterrainform.ui" line="122"/>
@ -1472,67 +1472,77 @@ Maintenir Ctrl : Plus rapide</translation>
<translation>Altitude relative de la couche d&apos;eau</translation> <translation>Altitude relative de la couche d&apos;eau</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/terrain/mainterrainform.ui" line="284"/> <location filename="../../src/editing/terrain/mainterrainform.ui" line="296"/>
<source>Go to textures to add small height displacements (rocks...)</source> <source>Go to textures to add small height displacements (rocks...)</source>
<translation>Aller aux textures pour ajouter des détails (roches...)</translation> <translation>Aller aux textures pour ajouter des détails (roches...)</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/terrain/mainterrainform.ui" line="334"/> <location filename="../../src/editing/terrain/mainterrainform.ui" line="346"/>
<source>Result preview</source> <source>Result preview</source>
<translation>Prévisualisation du résultat</translation> <translation>Prévisualisation du résultat</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/terrain/mainterrainform.ui" line="365"/> <location filename="../../src/editing/terrain/mainterrainform.ui" line="377"/>
<source>Render preview</source> <source>Render preview</source>
<translation>Rendu rapide</translation> <translation>Rendu rapide</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/terrain/mainterrainform.ui" line="376"/> <location filename="../../src/editing/terrain/mainterrainform.ui" line="388"/>
<source>Explore in 3D</source> <source>Explore in 3D</source>
<translation>Explorer en 3D</translation> <translation>Explorer en 3D</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/terrain/mainterrainform.ui" line="403"/> <location filename="../../src/editing/terrain/mainterrainform.ui" line="415"/>
<source>Actions</source> <source>Actions</source>
<translation>Actions</translation> <translation>Actions</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/terrain/mainterrainform.ui" line="412"/> <location filename="../../src/editing/terrain/mainterrainform.ui" line="424"/>
<source>Revert modifications</source> <source>Revert modifications</source>
<translation>Annuler les modifications</translation> <translation>Annuler les modifications</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/terrain/mainterrainform.ui" line="423"/> <location filename="../../src/editing/terrain/mainterrainform.ui" line="435"/>
<source>Apply modifications</source> <source>Apply modifications</source>
<translation>Valider les modifications</translation> <translation>Valider les modifications</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/terrain/mainterrainform.cpp" line="55"/> <location filename="../../src/editing/terrain/mainterrainform.cpp" line="59"/>
<source>Memory used by sculpted data: %1</source> <source>Memory used by sculpted data: %1</source>
<translation>Mémoire utilisée par les zones sculptées : %1</translation> <translation>Mémoire utilisée par les zones sculptées : %1</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/terrain/mainterrainform.cpp" line="59"/> <location filename="../../src/editing/terrain/mainterrainform.cpp" line="63"/>
<source>No manual scuplting done</source> <source>No manual scuplting done</source>
<translation>Aucune zone n&apos;a é sculptée</translation> <translation>Aucune zone n&apos;a é sculptée</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/terrain/mainterrainform.cpp" line="90"/> <location filename="../../src/editing/terrain/mainterrainform.cpp" line="78"/>
<source>No displacement textures</source>
<translation>Aucune texture de détail</translation>
</message>
<message>
<location filename="../../src/editing/terrain/mainterrainform.cpp" line="82"/>
<source>Maximal displacement : %1% of total height</source>
<translation>Déplacement maximal par textures : %1% du dénivelé total</translation>
</message>
<message>
<location filename="../../src/editing/terrain/mainterrainform.cpp" line="106"/>
<source>Paysages 3D - Base noise edition</source> <source>Paysages 3D - Base noise edition</source>
<translation>Paysages 3D - Edition de la forme de base</translation> <translation>Paysages 3D - Edition de la forme de base</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/terrain/mainterrainform.cpp" line="90"/> <location filename="../../src/editing/terrain/mainterrainform.cpp" line="106"/>
<source>You have manual modifications on this terrain, regenerating base noise may produce weird results.</source> <source>You have manual modifications on this terrain, regenerating base noise may produce weird results.</source>
<translation>Vous avez des modifications manuelles sur le terrain, modifier la forme de base peut produire des discontinuités.</translation> <translation>Vous avez des modifications manuelles sur le terrain, modifier la forme de base peut produire des discontinuités.</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/terrain/mainterrainform.cpp" line="90"/> <location filename="../../src/editing/terrain/mainterrainform.cpp" line="106"/>
<source>Keep my changes anyway</source> <source>Keep my changes anyway</source>
<translation>Garder mes changements</translation> <translation>Garder mes changements</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/terrain/mainterrainform.cpp" line="90"/> <location filename="../../src/editing/terrain/mainterrainform.cpp" line="106"/>
<source>Erase my changes</source> <source>Erase my changes</source>
<translation>Effacer mes changements</translation> <translation>Effacer mes changements</translation>
</message> </message>
@ -1766,87 +1776,87 @@ rapide (F5)</translation>
<translation>Caméra</translation> <translation>Caméra</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/common/mainwindow.cpp" line="173"/> <location filename="../../src/editing/common/mainwindow.cpp" line="178"/>
<source>Do you want to start a new scenery ? Any unsaved changes will be lost.</source> <source>Do you want to start a new scenery ? Any unsaved changes will be lost.</source>
<translation>Voulez-vous commencer un nouveau paysage ? Les modifications non sauvegardées seront perdues.</translation> <translation>Voulez-vous commencer un nouveau paysage ? Les modifications non sauvegardées seront perdues.</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/common/mainwindow.cpp" line="173"/> <location filename="../../src/editing/common/mainwindow.cpp" line="178"/>
<source>Paysages 3D - New scenery</source> <source>Paysages 3D - New scenery</source>
<translation>Paysages 3D - Nouvelle scène</translation> <translation>Paysages 3D - Nouvelle scène</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/common/mainwindow.cpp" line="182"/> <location filename="../../src/editing/common/mainwindow.cpp" line="187"/>
<source>Paysages 3D - Choose a file to save the scenery</source> <source>Paysages 3D - Choose a file to save the scenery</source>
<translation>Paysages 3D - Choisissez un fichier pour enregistrer la scène</translation> <translation>Paysages 3D - Choisissez un fichier pour enregistrer la scène</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/common/mainwindow.cpp" line="182"/> <location filename="../../src/editing/common/mainwindow.cpp" line="187"/>
<location filename="../../src/editing/common/mainwindow.cpp" line="208"/> <location filename="../../src/editing/common/mainwindow.cpp" line="213"/>
<source>Paysages 3D Scenery (*.p3d)</source> <source>Paysages 3D Scenery (*.p3d)</source>
<translation>Scène Paysages 3D (*.p3d)</translation> <translation>Scène Paysages 3D (*.p3d)</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/common/mainwindow.cpp" line="196"/> <location filename="../../src/editing/common/mainwindow.cpp" line="201"/>
<location filename="../../src/editing/common/mainwindow.cpp" line="199"/> <location filename="../../src/editing/common/mainwindow.cpp" line="204"/>
<source>Paysages 3D - File saving error</source> <source>Paysages 3D - File saving error</source>
<translation>Paysages 3D - Erreur d&apos;enregistrement</translation> <translation>Paysages 3D - Erreur d&apos;enregistrement</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/common/mainwindow.cpp" line="196"/> <location filename="../../src/editing/common/mainwindow.cpp" line="201"/>
<source>Can&apos;t write specified file : %1</source> <source>Can&apos;t write specified file : %1</source>
<translation>Impossible d&apos;écrire dans le fichier : %1</translation> <translation>Impossible d&apos;écrire dans le fichier : %1</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/common/mainwindow.cpp" line="199"/> <location filename="../../src/editing/common/mainwindow.cpp" line="204"/>
<source>Unexpected error while saving file : %1</source> <source>Unexpected error while saving file : %1</source>
<translation>Erreur inconnue durant l&apos;enregistrement : %1</translation> <translation>Erreur inconnue durant l&apos;enregistrement : %1</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/common/mainwindow.cpp" line="206"/> <location filename="../../src/editing/common/mainwindow.cpp" line="211"/>
<source>Do you want to load a scenery from file ? Any unsaved changes will be lost.</source> <source>Do you want to load a scenery from file ? Any unsaved changes will be lost.</source>
<translation>Voulez-vous charger une scène ? Les modifications non sauvegardées seront perdues.</translation> <translation>Voulez-vous charger une scène ? Les modifications non sauvegardées seront perdues.</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/common/mainwindow.cpp" line="206"/> <location filename="../../src/editing/common/mainwindow.cpp" line="211"/>
<source>Paysages 3D - Load scenery</source> <source>Paysages 3D - Load scenery</source>
<translation>Paysages 3D - Charger une scène</translation> <translation>Paysages 3D - Charger une scène</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/common/mainwindow.cpp" line="208"/> <location filename="../../src/editing/common/mainwindow.cpp" line="213"/>
<source>Paysages 3D - Choose a scenery file to load</source> <source>Paysages 3D - Choose a scenery file to load</source>
<translation>Paysages 3D - Choisissez un fichier de scène à charger</translation> <translation>Paysages 3D - Choisissez un fichier de scène à charger</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/common/mainwindow.cpp" line="218"/> <location filename="../../src/editing/common/mainwindow.cpp" line="223"/>
<location filename="../../src/editing/common/mainwindow.cpp" line="221"/> <location filename="../../src/editing/common/mainwindow.cpp" line="226"/>
<location filename="../../src/editing/common/mainwindow.cpp" line="224"/> <location filename="../../src/editing/common/mainwindow.cpp" line="229"/>
<location filename="../../src/editing/common/mainwindow.cpp" line="227"/> <location filename="../../src/editing/common/mainwindow.cpp" line="232"/>
<source>Paysages 3D - File loading error</source> <source>Paysages 3D - File loading error</source>
<translation>Paysages 3D - Erreur de chargement</translation> <translation>Paysages 3D - Erreur de chargement</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/common/mainwindow.cpp" line="218"/> <location filename="../../src/editing/common/mainwindow.cpp" line="223"/>
<source>Can&apos;t read specified file : %1</source> <source>Can&apos;t read specified file : %1</source>
<translation>Impossible de lire le fichier : %1</translation> <translation>Impossible de lire le fichier : %1</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/common/mainwindow.cpp" line="221"/> <location filename="../../src/editing/common/mainwindow.cpp" line="226"/>
<source>This file doesn&apos;t look like a Paysages 3D file : %1</source> <source>This file doesn&apos;t look like a Paysages 3D file : %1</source>
<translation>Le fichier ne semble pas être au format Paysages 3D : %1</translation> <translation>Le fichier ne semble pas être au format Paysages 3D : %1</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/common/mainwindow.cpp" line="224"/> <location filename="../../src/editing/common/mainwindow.cpp" line="229"/>
<source>This file was created with an incompatible Paysages 3D version : %1</source> <source>This file was created with an incompatible Paysages 3D version : %1</source>
<translation>Le fichier a é créé avec une version incompatible de Paysages 3D : %1</translation> <translation>Le fichier a é créé avec une version incompatible de Paysages 3D : %1</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/common/mainwindow.cpp" line="227"/> <location filename="../../src/editing/common/mainwindow.cpp" line="232"/>
<source>Unexpected error while loading file : %1</source> <source>Unexpected error while loading file : %1</source>
<translation>Erreur inconnue lors du chargement : %1</translation> <translation>Erreur inconnue lors du chargement : %1</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/common/mainwindow.cpp" line="235"/> <location filename="../../src/editing/common/mainwindow.cpp" line="240"/>
<source>A 3D landscape editing and rendering software. <source>A 3D landscape editing and rendering software.
Authors : Authors :
@ -1981,7 +1991,7 @@ GLib - http://www.gtk.org</translation>
</message> </message>
<message> <message>
<location filename="../../src/editing/common/mainwindow.ui" line="14"/> <location filename="../../src/editing/common/mainwindow.ui" line="14"/>
<location filename="../../src/editing/common/mainwindow.cpp" line="235"/> <location filename="../../src/editing/common/mainwindow.cpp" line="240"/>
<source>Paysages 3D</source> <source>Paysages 3D</source>
<translation>Paysages 3D</translation> <translation>Paysages 3D</translation>
</message> </message>

View file

@ -66,6 +66,7 @@ bool FreeFormHelper::eventFilter(QObject* object, QEvent* event)
void FreeFormHelper::startManaging() void FreeFormHelper::startManaging()
{ {
_form_widget->installEventFilter(this); _form_widget->installEventFilter(this);
connect(MainWindow::instance(), SIGNAL(refreshed()), this, SLOT(processGlobalRefresh()));
connect(this, SIGNAL(needLocalRefreshing()), _form_widget, SLOT(refreshFromLocalData())); connect(this, SIGNAL(needLocalRefreshing()), _form_widget, SLOT(refreshFromLocalData()));
connect(this, SIGNAL(needGlobalRefreshing()), _form_widget, SLOT(refreshFromFellowData())); connect(this, SIGNAL(needGlobalRefreshing()), _form_widget, SLOT(refreshFromFellowData()));
@ -73,9 +74,7 @@ void FreeFormHelper::startManaging()
connect(this, SIGNAL(needCommitting()), _form_widget, SLOT(commitLocalDataToScenery())); connect(this, SIGNAL(needCommitting()), _form_widget, SLOT(commitLocalDataToScenery()));
connect(this, SIGNAL(needAlterRenderer(Renderer*)), _form_widget, SLOT(alterRenderer(Renderer*))); connect(this, SIGNAL(needAlterRenderer(Renderer*)), _form_widget, SLOT(alterRenderer(Renderer*)));
emit needLocalRefreshing(); processGlobalRefresh();
emit needGlobalRefreshing();
emit needReverting();
} }
void FreeFormHelper::addPreview(BasePreview* preview, PreviewRenderer* renderer) void FreeFormHelper::addPreview(BasePreview* preview, PreviewRenderer* renderer)
@ -197,11 +196,7 @@ void FreeFormHelper::openDialog(QDialog* dialog)
void FreeFormHelper::gotoMainTab(int position) void FreeFormHelper::gotoMainTab(int position)
{ {
QWidget* window = _form_widget->window(); MainWindow::instance()->openTab(position);
if (window->inherits("MainWindow"))
{
((MainWindow*)window)->openTab(position);
}
} }
void FreeFormHelper::processDataChange() void FreeFormHelper::processDataChange()
@ -224,6 +219,13 @@ void FreeFormHelper::processDataChange()
emit needLocalRefreshing(); emit needLocalRefreshing();
} }
void FreeFormHelper::processGlobalRefresh()
{
emit needGlobalRefreshing();
processRevertClicked();
}
void FreeFormHelper::processRevertClicked() void FreeFormHelper::processRevertClicked()
{ {
emit needReverting(); emit needReverting();
@ -261,15 +263,7 @@ void FreeFormHelper::processApplyClicked()
{ {
emit needCommitting(); emit needCommitting();
_data_changed = false; MainWindow::instance()->refreshAll();
if (_button_apply)
{
_button_apply->setEnabled(false);
}
if (_button_revert)
{
_button_revert->setEnabled(false);
}
} }
void FreeFormHelper::processExploreClicked() void FreeFormHelper::processExploreClicked()

View file

@ -53,6 +53,7 @@ signals:
public slots: public slots:
void processDataChange(); void processDataChange();
void processGlobalRefresh();
void processRevertClicked(); void processRevertClicked();
void processApplyClicked(); void processApplyClicked();
void processExploreClicked(); void processExploreClicked();

View file

@ -28,6 +28,8 @@
#include "rendering/scenery.h" #include "rendering/scenery.h"
#include "tools.h" #include "tools.h"
MainWindow* MainWindow::_instance = NULL;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
MainWindow* window; MainWindow* window;
@ -78,10 +80,11 @@ int main(int argc, char** argv)
return result; return result;
} }
MainWindow::MainWindow(QWidget *parent) : MainWindow::MainWindow() :
QMainWindow(parent), QMainWindow(),
ui(new Ui::MainWindow) ui(new Ui::MainWindow)
{ {
_instance = this;
ui->setupUi(this); ui->setupUi(this);
BaseForm* form; BaseForm* form;
@ -155,7 +158,6 @@ void MainWindow::refreshAll()
{ {
_forms[i]->revertConfig(); _forms[i]->revertConfig();
} }
// TODO Refresh free forms
// Refresh preview OSD // Refresh preview OSD
CameraDefinition* camera = cameraCreateDefinition(); CameraDefinition* camera = cameraCreateDefinition();
@ -166,6 +168,8 @@ void MainWindow::refreshAll()
item->drawCamera(camera); item->drawCamera(camera);
item->setToolTip(QString(tr("Camera"))); item->setToolTip(QString(tr("Camera")));
cameraDeleteDefinition(camera); cameraDeleteDefinition(camera);
emit refreshed();
} }
void MainWindow::openTab(int position) void MainWindow::openTab(int position)

View file

@ -12,19 +12,27 @@ namespace Ui {
class MainWindow; class MainWindow;
} }
class MainWindow;
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit MainWindow(QWidget *parent = 0); MainWindow();
~MainWindow(); ~MainWindow();
virtual bool event(QEvent* event); virtual bool event(QEvent* event);
static inline MainWindow* instance()
{
return _instance;
}
static void guiSaveCallback(PackStream* stream, void* data); static void guiSaveCallback(PackStream* stream, void* data);
static void guiLoadCallback(PackStream* stream, void* data); static void guiLoadCallback(PackStream* stream, void* data);
protected:
public slots: public slots:
void refreshAll(); void refreshAll();
@ -42,7 +50,11 @@ public slots:
void explore3D(); void explore3D();
signals:
void refreshed();
private: private:
static MainWindow* _instance;
Ui::MainWindow *ui; Ui::MainWindow *ui;
void guiSave(PackStream* stream); void guiSave(PackStream* stream);