Changed: #1171 Changed the order of initialization. OVQT weather & sun color dock window.
This commit is contained in:
parent
936545fe64
commit
9526081ca1
10 changed files with 50 additions and 134 deletions
|
@ -22,6 +22,7 @@ SET(OBJECT_VIEWER_HDR main_window.h graphics_viewport.h animation_dialog.h
|
|||
vegetable_dialog.h global_wind_dialog.h day_night_dialog.h sun_color_dialog.h
|
||||
vegetable_noise_value_widget.h vegetable_density_page.h vegetable_landscape_page.h
|
||||
vegetable_scale_page.h vegetable_appearance_page.h vegetable_rotate_page.h
|
||||
tune_mrm_dialog.h
|
||||
extension_system/iplugin_manager.h extension_system/plugin_manager.h)
|
||||
|
||||
SET(OBJECT_VIEWER_UIS animation_form.ui animation_set_form.ui settings_form.ui
|
||||
|
@ -35,7 +36,7 @@ SET(OBJECT_VIEWER_UIS animation_form.ui animation_set_form.ui settings_form.ui
|
|||
particle_link_skeleton_form.ui water_pool_form.ui vegetable_dialog_form.ui
|
||||
vegetable_noise_value_form.ui global_wind_form.ui sun_color_form.ui day_night_form.ui
|
||||
vegetable_density_form.ui vegetable_apperance_form.ui vegetable_landscape_form.ui
|
||||
vegetable_rotate_form.ui vegetable_scale_form.ui)
|
||||
vegetable_rotate_form.ui vegetable_scale_form.ui tune_mrm_form.ui)
|
||||
|
||||
SET(OBJECT_VIEWER_RCS object_viewer_qt.qrc)
|
||||
|
||||
|
|
|
@ -32,8 +32,9 @@ CGlobalWindDialog::CGlobalWindDialog(QWidget *parent)
|
|||
{
|
||||
_ui.setupUi(this);
|
||||
|
||||
_ui.horizontalSlider->setValue(int(Modules::objView().getScene()->getGlobalWindPower() * _ui.horizontalSlider->maximum()));
|
||||
|
||||
connect(_ui.horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(setWndPower(int)));
|
||||
connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(updateWnd(bool)));
|
||||
}
|
||||
|
||||
CGlobalWindDialog::~CGlobalWindDialog()
|
||||
|
@ -47,12 +48,4 @@ void CGlobalWindDialog::setWndPower(int value)
|
|||
Modules::objView().getScene()->setGlobalWindPower(fValue);
|
||||
}
|
||||
|
||||
void CGlobalWindDialog::updateWnd(bool visible)
|
||||
{
|
||||
if (!visible || !Modules::objView().getScene())
|
||||
return;
|
||||
|
||||
_ui.horizontalSlider->setValue(int(Modules::objView().getScene()->getGlobalWindPower() * _ui.horizontalSlider->maximum()));
|
||||
}
|
||||
|
||||
} /* namespace NLQT */
|
|
@ -41,7 +41,6 @@ public:
|
|||
|
||||
private Q_SLOTS:
|
||||
void setWndPower(int value);
|
||||
void updateWnd(bool visible);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ void CGraphicsViewport::init()
|
|||
|
||||
Modules::objView().init((nlWindow)winId(), width(), height());
|
||||
Modules::psEdit().init();
|
||||
Modules::veget().init();
|
||||
|
||||
setMouseTracking(true);
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
@ -77,7 +78,8 @@ void CGraphicsViewport::release()
|
|||
{
|
||||
//H_AUTO2
|
||||
nldebug("CGraphicsViewport::release");
|
||||
|
||||
|
||||
Modules::veget().release();
|
||||
Modules::psEdit().release();
|
||||
Modules::objView().release();
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.7 KiB |
|
@ -47,6 +47,7 @@
|
|||
#include "global_wind_dialog.h"
|
||||
#include "day_night_dialog.h"
|
||||
#include "sun_color_dialog.h"
|
||||
#include "tune_mrm_dialog.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
|
@ -60,8 +61,6 @@ CMainWindow::CMainWindow(QWidget *parent)
|
|||
_isGraphicsEnabled(false),
|
||||
_isSoundInitialized(false),
|
||||
_isSoundEnabled(false),
|
||||
_isLandscapeInitialized(false),
|
||||
_isLandscapeEnabled(false),
|
||||
_GraphicsViewport(NULL),
|
||||
_lastDir("."),
|
||||
_mouseMode(NL3D::U3dMouseListener::edit3d)
|
||||
|
@ -79,6 +78,16 @@ CMainWindow::CMainWindow(QWidget *parent)
|
|||
_originalPalette = QApplication::palette();
|
||||
Modules::config().setAndCallback("QtStyle", CConfigCallback(this, &CMainWindow::cfcbQtStyle));
|
||||
Modules::config().setAndCallback("QtPalette", CConfigCallback(this, &CMainWindow::cfcbQtPalette));
|
||||
Modules::config().setAndCallback("SoundEnabled", CConfigCallback(this, &CMainWindow::cfcbSoundEnabled));
|
||||
|
||||
_GraphicsViewport->init();
|
||||
_isGraphicsInitialized = true;
|
||||
|
||||
if (_isSoundEnabled)
|
||||
{
|
||||
Modules::sound().init();
|
||||
_isSoundInitialized = true;
|
||||
}
|
||||
|
||||
_SkeletonTreeModel = new CSkeletonTreeModel(this);
|
||||
|
||||
|
@ -96,24 +105,16 @@ CMainWindow::CMainWindow(QWidget *parent)
|
|||
restoreGeometry(settings.value("QtWindowGeometry").toByteArray());
|
||||
settings.endGroup();
|
||||
|
||||
_isGraphicsEnabled = true;
|
||||
_isLandscapeEnabled = true;
|
||||
|
||||
// As a special case, a QTimer with a timeout of 0 will time out as soon as all the events in the window system's event queue have been processed.
|
||||
// This can be used to do heavy work while providing a snappy user interface.
|
||||
_mainTimer = new QTimer(this);
|
||||
connect(_mainTimer, SIGNAL(timeout()), this, SLOT(updateRender()));
|
||||
// timer->start(); // <- timeout 0
|
||||
// it's heavy on cpu, though, when no 3d driver initialized :)
|
||||
_mainTimer->start(23); // 25fps
|
||||
|
||||
_statusBarTimer = new QTimer(this);
|
||||
connect(_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar()));
|
||||
_statusBarTimer->start(1000);
|
||||
|
||||
_statusInfo = new QLabel(this);
|
||||
this->statusBar()->addPermanentWidget(_statusInfo);
|
||||
Modules::config().setAndCallback("SoundEnabled", CConfigCallback(this, &CMainWindow::cfcbSoundEnabled));
|
||||
}
|
||||
|
||||
CMainWindow::~CMainWindow()
|
||||
|
@ -131,15 +132,18 @@ CMainWindow::~CMainWindow()
|
|||
Modules::config().dropCallback("QtPalette");
|
||||
Modules::config().dropCallback("QtStyle");
|
||||
|
||||
_mainTimer->stop();
|
||||
_statusBarTimer->stop();
|
||||
|
||||
delete _AnimationDialog;
|
||||
delete _AnimationSetDialog;
|
||||
delete _SlotManagerDialog;
|
||||
delete _SetupFog;
|
||||
delete _TuneMRMDialog;
|
||||
delete _ParticleControlDialog;
|
||||
delete _ParticleWorkspaceDialog;
|
||||
|
||||
if (_isSoundInitialized)
|
||||
Modules::sound().releaseGraphics();
|
||||
|
||||
_GraphicsViewport->release();
|
||||
delete _GraphicsViewport;
|
||||
}
|
||||
|
||||
|
@ -152,11 +156,17 @@ void CMainWindow::setVisible(bool visible)
|
|||
if (visible)
|
||||
{
|
||||
QMainWindow::setVisible(true);
|
||||
updateInitialization(true);
|
||||
if (_isSoundInitialized)
|
||||
Modules::sound().initGraphics();
|
||||
_mainTimer->start(23);
|
||||
_statusBarTimer->start(1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
updateInitialization(false);
|
||||
_mainTimer->stop();
|
||||
_statusBarTimer->stop();
|
||||
if (_isSoundInitialized)
|
||||
Modules::sound().releaseGraphics();
|
||||
QMainWindow::setVisible(false);
|
||||
}
|
||||
}
|
||||
|
@ -273,95 +283,6 @@ void CMainWindow::updateStatusBar()
|
|||
}
|
||||
}
|
||||
|
||||
void CMainWindow::updateInitialization(bool visible)
|
||||
{
|
||||
bool done;
|
||||
do
|
||||
{
|
||||
done = true; // set false whenever change
|
||||
bool wantSound = _isSoundEnabled && visible;
|
||||
bool wantGraphics = _isGraphicsEnabled && visible;
|
||||
// TODO WARNING: made Landscape stuff
|
||||
bool wantLandscape = wantGraphics && _isGraphicsInitialized && _isLandscapeEnabled;
|
||||
|
||||
// .. stuff that depends on other stuff goes on top to prioritize deinitialization
|
||||
|
||||
// Landscape
|
||||
if (_isLandscapeInitialized)
|
||||
{
|
||||
if (!wantLandscape)
|
||||
{
|
||||
_isLandscapeInitialized = false;
|
||||
// if (_isGraphicsInitialized)
|
||||
// Modules::veget().releaseGraphics();
|
||||
Modules::veget().release();
|
||||
done = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wantLandscape)
|
||||
{
|
||||
Modules::veget().init();
|
||||
// if (_isGraphicsInitialized)
|
||||
// Modules::veget().initGraphics();
|
||||
_isLandscapeInitialized = true;
|
||||
done = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Graphics (Driver)
|
||||
if (_isGraphicsInitialized)
|
||||
{
|
||||
if (!wantGraphics)
|
||||
{
|
||||
_isGraphicsInitialized = false;
|
||||
if (_isSoundInitialized)
|
||||
Modules::sound().releaseGraphics();
|
||||
_GraphicsViewport->release();
|
||||
done = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wantGraphics)
|
||||
{
|
||||
_GraphicsViewport->init();
|
||||
if (_isSoundInitialized)
|
||||
Modules::sound().initGraphics();
|
||||
_isGraphicsInitialized = true;
|
||||
done = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Sound (AudioMixer)
|
||||
if (_isSoundInitialized)
|
||||
{
|
||||
if (!wantSound)
|
||||
{
|
||||
_isSoundInitialized = false;
|
||||
if (_isGraphicsInitialized)
|
||||
Modules::sound().releaseGraphics();
|
||||
Modules::sound().release();
|
||||
done = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wantSound)
|
||||
{
|
||||
Modules::sound().init();
|
||||
if (_isGraphicsInitialized)
|
||||
Modules::sound().initGraphics();
|
||||
_isSoundInitialized = true;
|
||||
done = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
while (!done);
|
||||
}
|
||||
|
||||
void CMainWindow::createActions()
|
||||
{
|
||||
_openAction = new QAction(tr("&Open..."), this);
|
||||
|
@ -477,6 +398,9 @@ void CMainWindow::createMenus()
|
|||
|
||||
_toolsMenu->addAction(_SunColorDialog->toggleViewAction());
|
||||
|
||||
//_toolsMenu->addAction(_TuneMRMDialog->toggleViewAction());
|
||||
_TuneMRMDialog->toggleViewAction()->setIcon(QIcon(":/images/ico_mrm_mesh.png"));
|
||||
|
||||
connect(_ParticleControlDialog->toggleViewAction(), SIGNAL(triggered(bool)),
|
||||
_ParticleWorkspaceDialog, SLOT(setVisible(bool)));
|
||||
|
||||
|
@ -518,6 +442,7 @@ void CMainWindow::createToolBars()
|
|||
_toolsBar->addAction(_VegetableDialog->toggleViewAction());
|
||||
_toolsBar->addAction(_GlobalWindDialog->toggleViewAction());
|
||||
_toolsBar->addAction(_SkeletonScaleDialog->toggleViewAction());
|
||||
// _toolsBar->addAction(_TuneMRMDialog->toggleViewAction());
|
||||
}
|
||||
|
||||
void CMainWindow::createStatusBar()
|
||||
|
@ -591,6 +516,11 @@ void CMainWindow::createDialogs()
|
|||
addDockWidget(Qt::RightDockWidgetArea, _SetupFog);
|
||||
_SetupFog->setVisible(false);
|
||||
|
||||
// create tune mrm dialog
|
||||
_TuneMRMDialog = new CTuneMRMDialog(this);
|
||||
addDockWidget(Qt::BottomDockWidgetArea, _TuneMRMDialog);
|
||||
_TuneMRMDialog->setVisible(false);
|
||||
|
||||
connect(_ParticleControlDialog, SIGNAL(changeState()), _ParticleWorkspaceDialog, SLOT(setNewState()));
|
||||
connect(_ParticleWorkspaceDialog, SIGNAL(changeActiveNode()), _ParticleControlDialog, SLOT(updateActiveNode()));
|
||||
connect(_AnimationSetDialog->ui.setLengthPushButton, SIGNAL(clicked()), _AnimationDialog, SLOT(changeAnimLength()));
|
||||
|
@ -637,8 +567,6 @@ void CMainWindow::cfcbSoundEnabled(NLMISC::CConfigFile::CVar &var)
|
|||
|
||||
void CMainWindow::updateRender()
|
||||
{
|
||||
updateInitialization(isVisible());
|
||||
|
||||
if (isVisible())
|
||||
{
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ class CVegetableDialog;
|
|||
class CGlobalWindDialog;
|
||||
class CDayNightDialog;
|
||||
class CSunColorDialog;
|
||||
class CTuneMRMDialog;
|
||||
|
||||
class CMainWindow : public QMainWindow
|
||||
{
|
||||
|
@ -93,7 +94,6 @@ private:
|
|||
void createStatusBar();
|
||||
void createDialogs();
|
||||
|
||||
void updateInitialization(bool visible);
|
||||
bool loadFile(const QString &fileName, const QString &skelName);
|
||||
|
||||
void cfcbQtStyle(NLMISC::CConfigFile::CVar &var);
|
||||
|
@ -102,7 +102,6 @@ private:
|
|||
|
||||
bool _isGraphicsInitialized, _isGraphicsEnabled;
|
||||
bool _isSoundInitialized, _isSoundEnabled;
|
||||
bool _isLandscapeInitialized, _isLandscapeEnabled;
|
||||
|
||||
CGraphicsViewport *_GraphicsViewport;
|
||||
CAnimationDialog *_AnimationDialog;
|
||||
|
@ -117,7 +116,7 @@ private:
|
|||
CSkeletonScaleDialog *_SkeletonScaleDialog;
|
||||
CDayNightDialog *_DayNightDialog;
|
||||
CSunColorDialog *_SunColorDialog;
|
||||
|
||||
CTuneMRMDialog *_TuneMRMDialog;
|
||||
CSkeletonTreeModel *_SkeletonTreeModel;
|
||||
|
||||
QPalette _originalPalette;
|
||||
|
@ -140,7 +139,6 @@ private:
|
|||
QAction *_renderModeAction;
|
||||
QAction *_frameDelayAction;
|
||||
QAction *_lightGroupAction;
|
||||
QAction *_tuneMRMAction;
|
||||
QAction *_reloadTexturesAction;
|
||||
QAction *_cameraModeAction;
|
||||
QAction *_resetCameraAction;
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
<file>images/ico_bgcolor.png</file>
|
||||
<file>images/ico_framedelay.png</file>
|
||||
<file>images/ico_skelscale.png</file>
|
||||
<file>images/ico_mrm_mesh.png</file>
|
||||
<file>images/ico_light_group.png</file>
|
||||
<file>images/clear.png</file>
|
||||
<file>images/insert.png</file>
|
||||
<file>images/new.png</file>
|
||||
|
|
|
@ -34,7 +34,11 @@ CSunColorDialog::CSunColorDialog(QWidget *parent)
|
|||
{
|
||||
_ui.setupUi(this);
|
||||
|
||||
connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(updateSunColor(bool)));
|
||||
_ui.ambientWidget->setColor(Modules::objView().getScene()->getSunAmbient());
|
||||
_ui.diffuseWidget->setColor(Modules::objView().getScene()->getSunDiffuse());
|
||||
_ui.specularWidget->setColor(Modules::objView().getScene()->getSunSpecular());
|
||||
|
||||
//connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(updateSunColor(bool)));
|
||||
connect(_ui.ambientWidget, SIGNAL(colorChanged(NLMISC::CRGBA)), this, SLOT(setAmbientSunColor(NLMISC::CRGBA)));
|
||||
connect(_ui.diffuseWidget, SIGNAL(colorChanged(NLMISC::CRGBA)), this, SLOT(setDiffuseSunColor(NLMISC::CRGBA)));
|
||||
connect(_ui.specularWidget, SIGNAL(colorChanged(NLMISC::CRGBA)), this, SLOT(setSpecularSunColor(NLMISC::CRGBA)));
|
||||
|
@ -44,16 +48,6 @@ CSunColorDialog::~CSunColorDialog()
|
|||
{
|
||||
}
|
||||
|
||||
void CSunColorDialog::updateSunColor(bool visible)
|
||||
{
|
||||
if (!visible || !Modules::objView().getScene())
|
||||
return;
|
||||
|
||||
_ui.ambientWidget->setColor(Modules::objView().getScene()->getSunAmbient());
|
||||
_ui.diffuseWidget->setColor(Modules::objView().getScene()->getSunDiffuse());
|
||||
_ui.specularWidget->setColor(Modules::objView().getScene()->getSunSpecular());
|
||||
}
|
||||
|
||||
void CSunColorDialog::setAmbientSunColor(NLMISC::CRGBA color)
|
||||
{
|
||||
Modules::objView().getScene()->setSunAmbient(color);
|
||||
|
|
|
@ -44,7 +44,6 @@ public:
|
|||
~CSunColorDialog();
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateSunColor(bool visible);
|
||||
void setAmbientSunColor(NLMISC::CRGBA color);
|
||||
void setDiffuseSunColor(NLMISC::CRGBA color);
|
||||
void setSpecularSunColor(NLMISC::CRGBA color);
|
||||
|
|
Loading…
Reference in a new issue