From 6a657037b145d49ae5ea176e2ac909b63166edd9 Mon Sep 17 00:00:00 2001 From: timon Date: Mon, 22 Nov 2010 22:50:05 +0200 Subject: [PATCH] Changed: #1193 If switch between the force properties in a workspace erroneously marked that the particle system has been changed. --- .../3d/object_viewer_qt/src/description.h | 1 - .../object_viewer_qt/src/direction_widget.cpp | 76 ++------------- .../object_viewer_qt/src/direction_widget.h | 13 +-- .../3d/object_viewer_qt/src/emitter_page.cpp | 5 + .../src/particle_force_page.cpp | 92 +++++++++++++------ .../src/particle_force_page.h | 43 ++------- .../3d/object_viewer_qt/src/ps_mover_page.cpp | 24 +++-- .../3d/object_viewer_qt/src/ps_mover_page.h | 17 +--- .../object_viewer_qt/src/spinner_dialog.cpp | 91 ++++++++++-------- .../3d/object_viewer_qt/src/spinner_dialog.h | 25 ++--- 10 files changed, 161 insertions(+), 226 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/description.h b/code/nel/tools/3d/object_viewer_qt/src/description.h index f1e3fc8a7..a9f4c496f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/description.h +++ b/code/nel/tools/3d/object_viewer_qt/src/description.h @@ -84,7 +84,6 @@ Using this widget you can set the color(RGBA) using the four sliders or through CDirectionWidget
This widget helps to choose from several preset directions, or to choose a custom one. -To use it you have to create a wrapper.

CDirectionWidget @see diff --git a/code/nel/tools/3d/object_viewer_qt/src/direction_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/direction_widget.cpp index 79af10959..dee9d1b47 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/direction_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/direction_widget.cpp @@ -25,12 +25,11 @@ // NeL includes #include -#include namespace NLQT { CDirectionWidget::CDirectionWidget(QWidget *parent) - : QWidget(parent), _Wrapper(NULL), _DirectionWrapper(NULL), _globalName("") + : QWidget(parent), _globalName("") { _ui.setupUi(this); @@ -59,31 +58,10 @@ CDirectionWidget::~CDirectionWidget() { } -void CDirectionWidget::enableGlobalVariable() +void CDirectionWidget::enabledGlobalVariable(bool enabled) { - _ui.globalPushButton->setVisible(true); - _globalName = ""; -} - -void CDirectionWidget::setWrapper(IPSWrapper *wrapper) -{ - _Wrapper = wrapper; - _ui.globalPushButton->hide(); -} - -void CDirectionWidget::setDirectionWrapper(NL3D::CPSDirection *wrapper) -{ - _DirectionWrapper = wrapper; - if (_DirectionWrapper && _DirectionWrapper->supportGlobalVectorValue()) - _ui.globalPushButton->show(); - else - _ui.globalPushButton->hide(); -} - -void CDirectionWidget::updateUi() -{ - setValue(_Wrapper->get(), false); - checkEnabledGlobalDirection(); + _ui.globalPushButton->setVisible(enabled); + setGlobalName("", false); } void CDirectionWidget::setValue(const NLMISC::CVector &value, bool emit) @@ -97,8 +75,6 @@ void CDirectionWidget::setValue(const NLMISC::CVector &value, bool emit) if (emit) { Q_EMIT valueChanged(_value); - if (_Wrapper) - _Wrapper->setAndUpdateModifiedFlag(_value); } } @@ -122,24 +98,13 @@ void CDirectionWidget::setGlobalName(const QString &globalName, bool emit) void CDirectionWidget::setGlobalDirection() { - nlassert(_DirectionWrapper); - bool ok; QString text = QInputDialog::getText(this, tr("Enter Name"), "", QLineEdit::Normal, - QString(_DirectionWrapper->getGlobalVectorValueName().c_str()), &ok); + QString(_globalName), &ok); if (ok) - { setGlobalName(text); - - _DirectionWrapper->enableGlobalVectorValue(text.toStdString()); - if (!_globalName.isEmpty()) - { - // take a non NULL value for the direction - NL3D::CParticleSystem::setGlobalVectorValue(text.toStdString(), NLMISC::CVector::I); - } - } } void CDirectionWidget::incVecI() @@ -175,11 +140,7 @@ void CDirectionWidget::decVecK() void CDirectionWidget::setNewVecXZ(float x, float y) { const float epsilon = 10E-3f; - NLMISC::CVector v; - if (_Wrapper) - v = _Wrapper->get(); - else - v = _value; + NLMISC::CVector v = _value; v.x = x; v.z = y; @@ -202,11 +163,7 @@ void CDirectionWidget::setNewVecXZ(float x, float y) void CDirectionWidget::setNewVecYZ(float x, float y) { const float epsilon = 10E-3f; - NLMISC::CVector v; - if (_Wrapper) - v = _Wrapper->get(); - else - v = _value; + NLMISC::CVector v = _value; v.y = x; v.z = y; @@ -226,23 +183,4 @@ void CDirectionWidget::setNewVecYZ(float x, float y) setValue(v); } -void CDirectionWidget::checkEnabledGlobalDirection() -{ - bool enableUserDirection = true; - _ui.xzWidget->show(); - _ui.yzWidget->show(); - if (_DirectionWrapper && _DirectionWrapper->supportGlobalVectorValue() && !_DirectionWrapper->getGlobalVectorValueName().empty()) - { - enableUserDirection = false; - _ui.xzWidget->hide(); - _ui.yzWidget->hide(); - } - _ui.incVecIPushButton->setEnabled(enableUserDirection); - _ui.incVecJPushButton->setEnabled(enableUserDirection); - _ui.incVecKPushButton->setEnabled(enableUserDirection); - _ui.decVecIPushButton->setEnabled(enableUserDirection); - _ui.decVecJPushButton->setEnabled(enableUserDirection); - _ui.decVecKPushButton->setEnabled(enableUserDirection); -} - } /* namespace NLQT */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/direction_widget.h b/code/nel/tools/3d/object_viewer_qt/src/direction_widget.h index 5f0093da1..aaee615a1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/direction_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/direction_widget.h @@ -28,7 +28,6 @@ #include // Project includes -#include "ps_wrapper.h" namespace NLQT { @@ -45,13 +44,7 @@ public: CDirectionWidget(QWidget *parent = 0); ~CDirectionWidget(); - void enableGlobalVariable(); - void setWrapper(IPSWrapper *wrapper); - - /// The CPSDirection object is used to see if a global variable can be bound to the direction. - /// When set to NULL it has no effect (the default) - void setDirectionWrapper(NL3D::CPSDirection *wrapper); - void updateUi(); + void enabledGlobalVariable(bool enabled); Q_SIGNALS: void valueChanged(const NLMISC::CVector &value); @@ -73,10 +66,6 @@ private Q_SLOTS: void setNewVecYZ(float x, float y); private: - void checkEnabledGlobalDirection(); - - IPSWrapper *_Wrapper ; - NL3D::CPSDirection *_DirectionWrapper; NLMISC::CVector _value; QString _globalName; diff --git a/code/nel/tools/3d/object_viewer_qt/src/emitter_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/emitter_page.cpp index 5c3021277..f77a3498d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/emitter_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/emitter_page.cpp @@ -280,17 +280,20 @@ void CEmitterPage::setDirectionMode(int index) void CEmitterPage::setSpeedInheritanceFactor(float value) { _Emitter->setSpeedInheritanceFactor(value); + updateModifiedFlag(); } void CEmitterPage::setConicEmitterRadius(float value) { dynamic_cast(_Emitter)->setRadius(value); + updateModifiedFlag(); } void CEmitterPage::setEmitDelay(float value) { _Emitter->setEmitDelay(value); Modules::psEdit().resetAutoCount(_Node); + updateModifiedFlag(); } void CEmitterPage::setMaxEmissionCount(uint32 value) @@ -304,6 +307,7 @@ void CEmitterPage::setMaxEmissionCount(uint32 value) QMessageBox::Ok); _ui.maxEmissionCountWidget->setValue((uint32)_Emitter->getMaxEmissionCount(), false); + updateModifiedFlag(); } Modules::psEdit().resetAutoCount(_Node); } @@ -311,6 +315,7 @@ void CEmitterPage::setMaxEmissionCount(uint32 value) void CEmitterPage::setDir(const NLMISC::CVector &value) { dynamic_cast(_Emitter)->setDir(value); + updateModifiedFlag(); } void CEmitterPage::updatePeriodWidget() diff --git a/code/nel/tools/3d/object_viewer_qt/src/particle_force_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/particle_force_page.cpp index b2d516022..766a89898 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/particle_force_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/particle_force_page.cpp @@ -41,18 +41,17 @@ CForcePage::CForcePage(QWidget *parent) _ui.forceIntensityWidget->init(); _ui.parametricFactorWidget->setRange(0.0, 64.0); - _ui.parametricFactorWidget->setWrapper(&_ParamFactorWrapper); - _ui.radialViscosityWidget->setRange(0.0, 1.0); - _ui.radialViscosityWidget->setWrapper(&_RadialViscosityWrapper); - _ui.tangentialViscosityWidget->setRange(0, 1); - _ui.tangentialViscosityWidget->setWrapper(&_TangentialViscosityWrapper); - - _ui.directionWidget->setWrapper(&_DirectionWrapper); connect(_ui.toTargetsPushButton, SIGNAL(clicked()), this, SLOT(addTarget())); connect(_ui.toAvaibleTargetsPushButton, SIGNAL(clicked()), this, SLOT(removeTarget())); + + connect(_ui.parametricFactorWidget, SIGNAL(valueChanged(float)), this, SLOT(setFactorBrownianForce(float))); + connect(_ui.radialViscosityWidget, SIGNAL(valueChanged(float)), this, SLOT(setRadialViscosity(float))); + connect(_ui.tangentialViscosityWidget, SIGNAL(valueChanged(float)), this, SLOT(setTangentialViscosity(float))); + connect(_ui.directionWidget, SIGNAL(valueChanged(NLMISC::CVector)), this, SLOT(setDir(NLMISC::CVector))); + connect(_ui.directionWidget, SIGNAL(globalNameChanged(QString)), this, SLOT(setGlobalName(QString))); } CForcePage::~CForcePage() @@ -61,10 +60,11 @@ CForcePage::~CForcePage() void CForcePage::setEditedItem(CWorkspaceNode *ownerNode, NL3D::CPSLocatedBindable *locatedBindable) { - hideWrappersWidget(); + nlassert(locatedBindable); + + hideAdditionalWidget(); _Node = ownerNode; _LBTarget = static_cast(locatedBindable); - updateTargets(); // force with intensity case @@ -77,41 +77,33 @@ void CForcePage::setEditedItem(CWorkspaceNode *ownerNode, NL3D::CPSLocatedBindab } // vortex (to tune viscosity) - if (dynamic_cast(_LBTarget)) + NL3D::CPSCylindricVortex *cylindricVortex = dynamic_cast(_LBTarget); + if (cylindricVortex) { - _RadialViscosityWrapper.OwnerNode = _Node; - _RadialViscosityWrapper.V = dynamic_cast(_LBTarget); - - _ui.radialViscosityWidget->updateUi(); + _ui.radialViscosityWidget->setValue(cylindricVortex->getRadialViscosity(), false); _ui.radialViscosityLabel->show(); _ui.radialViscosityWidget->show(); - _TangentialViscosityWrapper.OwnerNode = _Node; - _TangentialViscosityWrapper.V = dynamic_cast(_LBTarget); - - _ui.tangentialViscosityWidget->updateUi(); + _ui.tangentialViscosityWidget->setValue(cylindricVortex->getTangentialViscosity(), false); _ui.tangentialViscosityLabel->show(); _ui.tangentialViscosityWidget->show(); } // deals with emitters that have a direction - if (dynamic_cast(_LBTarget)) + NL3D::CPSDirection *direction = dynamic_cast(_LBTarget); + if (direction) { - _DirectionWrapper.OwnerNode = _Node; - _DirectionWrapper.E = dynamic_cast(_LBTarget); - _ui.directionWidget->setDirectionWrapper(dynamic_cast(_LBTarget)); - - _ui.directionWidget->updateUi(); + _ui.directionWidget->setValue(direction->getDir(), false); + _ui.directionWidget->enabledGlobalVariable(direction->supportGlobalVectorValue()); + _ui.directionWidget->setGlobalName(QString(direction->getGlobalVectorValueName().c_str()), false); _ui.directionWidget->show(); } // Brownian (to tune parametric factor) - if (dynamic_cast(_LBTarget)) + NL3D::CPSBrownianForce *brownianForce = dynamic_cast(_LBTarget); + if (brownianForce) { - _ParamFactorWrapper.OwnerNode = _Node; - _ParamFactorWrapper.F = static_cast(_LBTarget); - - _ui.parametricFactorWidget->updateUi(); + _ui.parametricFactorWidget->setValue(brownianForce->getParametricFactor(), false); _ui.parametricFactorLabel->show(); _ui.parametricFactorWidget->show(); } @@ -168,8 +160,47 @@ void CForcePage::removeTarget() _ui.avaibleTargetsListWidget->addItem(item); updateModifiedFlag(); } +void CForcePage::setRadialViscosity(float value) +{ + nlassert(_LBTarget); + dynamic_cast(_LBTarget)->setRadialViscosity(value); + updateModifiedFlag(); +} -void CForcePage::hideWrappersWidget() +void CForcePage::setTangentialViscosity(float value) +{ + nlassert(_LBTarget); + dynamic_cast(_LBTarget)->setTangentialViscosity(value); + updateModifiedFlag(); +} + +void CForcePage::setDir(const NLMISC::CVector &value) +{ + nlassert(_LBTarget); + dynamic_cast(_LBTarget)->setDir(value); + updateModifiedFlag(); +} + +void CForcePage::setGlobalName(const QString &globalName) +{ + nlassert(_LBTarget); + dynamic_cast(_LBTarget)->enableGlobalVectorValue(globalName.toStdString()); + if (!globalName.isEmpty()) + { + // take a non NULL value for the direction + NL3D::CParticleSystem::setGlobalVectorValue(globalName.toStdString(), NLMISC::CVector::I); + } + updateModifiedFlag(); +} + +void CForcePage::setFactorBrownianForce(float value) +{ + nlassert(_LBTarget); + dynamic_cast(_LBTarget)->setParametricFactor(value); + updateModifiedFlag(); +} + +void CForcePage::hideAdditionalWidget() { _ui.directionWidget->hide(); _ui.parametricFactorLabel->hide(); @@ -182,6 +213,7 @@ void CForcePage::hideWrappersWidget() void CForcePage::updateTargets() { + nlassert(_LBTarget); uint k; uint nbTarg = _LBTarget->getNbTargets(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/particle_force_page.h b/code/nel/tools/3d/object_viewer_qt/src/particle_force_page.h index 80c1f541a..37d5a89dd 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/particle_force_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/particle_force_page.h @@ -71,7 +71,13 @@ public: private Q_SLOTS: void addTarget(); void removeTarget(); - + + void setRadialViscosity(float value); + void setTangentialViscosity(float value); + void setDir(const NLMISC::CVector &value); + void setGlobalName(const QString &globalName); + void setFactorBrownianForce(float value); + private: /// wrapper to tune the intensity of a force @@ -84,40 +90,7 @@ private: void setScheme(scheme_type *s) {F->setIntensityScheme(s); } } _ForceIntensityWrapper; - /// wrapper to tune the radial viscosity for vortices - struct CRadialViscosityWrapper : public IPSWrapperFloat - { - NL3D::CPSCylindricVortex *V; - float get(void) const { return V->getRadialViscosity(); } - void set(const float &value) { V->setRadialViscosity(value); } - } _RadialViscosityWrapper; - - /// wrapper to tune the tangential viscosity for vortices - struct CTangentialViscosityWrapper : public IPSWrapperFloat - { - NL3D::CPSCylindricVortex *V; - float get(void) const { return V->getTangentialViscosity(); } - void set(const float &value) { V->setTangentialViscosity(value); } - } _TangentialViscosityWrapper; - - /// wrappers to tune the direction - struct CDirectionWrapper : public IPSWrapper - { - NL3D::CPSDirection *E; - NLMISC::CVector get(void) const { return E->getDir(); } - void set(const NLMISC::CVector &d){ E->setDir(d); } - } _DirectionWrapper; - - /// wrappers to tune the parametric factor of brownian force - struct CParamFactorWrapper : public IPSWrapperFloat - { - NL3D::CPSBrownianForce *F; - float get(void) const { return F->getParametricFactor(); } - void set(const float &f){ F->setParametricFactor(f); } - } _ParamFactorWrapper; - - - void hideWrappersWidget(); + void hideAdditionalWidget(); void updateTargets(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/ps_mover_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/ps_mover_page.cpp index fa717591f..2afd5b66d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/ps_mover_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/ps_mover_page.cpp @@ -48,12 +48,14 @@ CPSMoverPage::CPSMoverPage(QWidget *parent) _ui.scaleZWidget->setRange(0.f, 4.f); _ui.scaleZWidget->setWrapper(&_ZScaleWrapper); - _ui.directionWidget->setWrapper(&_DirectionWrapper); + //_ui.directionWidget->setWrapper(&_DirectionWrapper); connect(_ui.xDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setXPosition(double))); connect(_ui.yDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setYPosition(double))); connect(_ui.zDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setZPosition(double))); - + + connect(_ui.directionWidget, SIGNAL(valueChanged(NLMISC::CVector)), this, SLOT(setDir(NLMISC::CVector))); + connect(_ui.listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(changeSubComponent())); } @@ -71,7 +73,7 @@ void CPSMoverPage::setEditedItem(CWorkspaceNode *ownerNode, NL3D::CPSLocated *lo updatePosition(); _ui.listWidget->clear(); - hideWrappersWidget(); + hideAdditionalWidget(); uint numBound = _EditedLocated->getNbBoundObjects(); @@ -101,7 +103,7 @@ void CPSMoverPage::updatePosition(void) } -void CPSMoverPage::hideWrappersWidget() +void CPSMoverPage::hideAdditionalWidget() { _ui.scaleLabel->hide(); _ui.scaleXLabel->hide(); @@ -162,7 +164,7 @@ void CPSMoverPage::setZPosition(double value) void CPSMoverPage::changeSubComponent() { - hideWrappersWidget(); + hideAdditionalWidget(); NL3D::IPSMover *m = getMoverInterface(); if (!m) return; @@ -213,15 +215,17 @@ void CPSMoverPage::changeSubComponent() if (m->onlyStoreNormal()) { - _DirectionWrapper.OwnerNode = _Node; - _DirectionWrapper.M = m; - _DirectionWrapper.Index = _EditedLocatedIndex; - - _ui.directionWidget->updateUi(); + _ui.directionWidget->setValue(getMoverInterface()->getNormal(getLocatedIndex()), false); _ui.directionWidget->show(); } } +void CPSMoverPage::setDir(const NLMISC::CVector &value) +{ + getMoverInterface()->setNormal(getLocatedIndex(), value); + updateModifiedFlag(); +} + NL3D::IPSMover *CPSMoverPage::getMoverInterface(void) { nlassert(_EditedLocated); diff --git a/code/nel/tools/3d/object_viewer_qt/src/ps_mover_page.h b/code/nel/tools/3d/object_viewer_qt/src/ps_mover_page.h index f2403ca7f..d3e9e37b4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/ps_mover_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/ps_mover_page.h @@ -92,6 +92,8 @@ private Q_SLOTS: void setZPosition(double value); void changeSubComponent(); + void setDir(const NLMISC::CVector &value); + private: /// wrappers to scale objects @@ -142,19 +144,10 @@ private: } } _ZScaleWrapper ; - /// wrapper for direction - struct CDirectionWrapper : public IPSWrapper - { - uint32 Index ; - NL3D::IPSMover *M ; - NLMISC::CVector get(void) const { return M->getNormal(Index) ; } - void set(const NLMISC::CVector &v) { M->setNormal(Index, v) ; } - - - } _DirectionWrapper ; - - void hideWrappersWidget(); + void hideAdditionalWidget(); + void updateModifiedFlag() { if (_Node) _Node->setModified(true); } + /// update the mouse listener position when the user entered a value with the keyboard void updateListener(void) ; diff --git a/code/nel/tools/3d/object_viewer_qt/src/spinner_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/spinner_dialog.cpp index 9915e1fda..713a1b393 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/spinner_dialog.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/spinner_dialog.cpp @@ -1,19 +1,19 @@ /* - Object Viewer Qt - Copyright (C) 2010 Dzmitry Kamiahin +Object Viewer Qt +Copyright (C) 2010 Dzmitry Kamiahin - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see . +You should have received a copy of the GNU General Public License +along with this program. If not, see . */ @@ -21,48 +21,59 @@ #include "spinner_dialog.h" namespace NLQT { - + CSpinnerDialog::CSpinnerDialog(NL3D::CPSBasisSpinner *sf, CWorkspaceNode *ownerNode, QWidget *parent) - : QDialog(parent) + : QDialog(parent), _Node(ownerNode), _BasicSpinner(sf) { - _verticalLayout = new QVBoxLayout(this); - _nbSamplesLabel = new QLabel(this); - _verticalLayout->addWidget(_nbSamplesLabel); + nlassert(_BasicSpinner); - _nbSamplesWidget = new NLQT::CEditRangeUIntWidget(this); - QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - sizePolicy.setHorizontalStretch(0); - sizePolicy.setVerticalStretch(0); - sizePolicy.setHeightForWidth(_nbSamplesWidget->sizePolicy().hasHeightForWidth()); - _nbSamplesWidget->setSizePolicy(sizePolicy); - _verticalLayout->addWidget(_nbSamplesWidget); + _verticalLayout = new QVBoxLayout(this); + _nbSamplesLabel = new QLabel(this); + _verticalLayout->addWidget(_nbSamplesLabel); + + _nbSamplesWidget = new NLQT::CEditRangeUIntWidget(this); + QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(_nbSamplesWidget->sizePolicy().hasHeightForWidth()); + _nbSamplesWidget->setSizePolicy(sizePolicy); + _verticalLayout->addWidget(_nbSamplesWidget); + + _dirWidget = new NLQT::CDirectionWidget(this); + sizePolicy.setHeightForWidth(_dirWidget->sizePolicy().hasHeightForWidth()); + _dirWidget->setSizePolicy(sizePolicy); + _verticalLayout->addWidget(_dirWidget); - _dirWidget = new NLQT::CDirectionWidget(this); - sizePolicy.setHeightForWidth(_dirWidget->sizePolicy().hasHeightForWidth()); - _dirWidget->setSizePolicy(sizePolicy); - _verticalLayout->addWidget(_dirWidget); - setWindowTitle(tr("Edit spinner")); - _nbSamplesLabel->setText(tr("Nb samples:")); - - _AxisWrapper.OwnerNode = ownerNode; - _NbSampleWrapper.OwnerNode = ownerNode; - _NbSampleWrapper.S = sf; - _AxisWrapper.S = sf; + _nbSamplesLabel->setText(tr("Nb samples:")); _nbSamplesWidget->setRange(1, 512); - _nbSamplesWidget->setWrapper(&_NbSampleWrapper); _nbSamplesWidget->enableLowerBound(0, true); - _nbSamplesWidget->updateUi(); - - _dirWidget->setWrapper(&_AxisWrapper); - _dirWidget->updateUi(); + _nbSamplesWidget->setValue(_BasicSpinner->_F.getNumSamples(), false); + _dirWidget->setValue(_BasicSpinner->_F.getAxis()); setFixedHeight(sizeHint().height()); + + connect(_nbSamplesWidget, SIGNAL(valueChanged(uint32)), this, SLOT(setNumSamples(uint32))); + connect(_dirWidget, SIGNAL(valueChanged(NLMISC::CVector)), this, SLOT(setAxis(NLMISC::CVector))); } CSpinnerDialog::~CSpinnerDialog() { } +void CSpinnerDialog::setNumSamples(uint32 value) +{ + nlassert(_BasicSpinner); + _BasicSpinner->_F.setNumSamples(value); + updateModifiedFlag(); +} + +void CSpinnerDialog::setAxis(const NLMISC::CVector &axis) +{ + nlassert(_BasicSpinner); + _BasicSpinner->_F.setAxis(axis); + updateModifiedFlag(); +} + } /* namespace NLQT */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/spinner_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/spinner_dialog.h index 62497b8bc..416f06d91 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/spinner_dialog.h +++ b/code/nel/tools/3d/object_viewer_qt/src/spinner_dialog.h @@ -43,29 +43,20 @@ public: CSpinnerDialog(NL3D::CPSBasisSpinner *sf, CWorkspaceNode *ownerNode, QWidget *parent = 0); ~CSpinnerDialog(); +private Q_SLOTS: + void setNumSamples(uint32 value); + void setAxis(const NLMISC::CVector &axis); + protected: - - /// Wrapper to set the number of samples in the spinner - struct CNbSampleWrapper : public IPSWrapperUInt - { - NL3D::CPSBasisSpinner *S; - uint32 get(void) const { return S->_F.getNumSamples(); } - void set(const uint32 &val) { S->_F.setNumSamples(val); } - } _NbSampleWrapper; + void updateModifiedFlag() { if (_Node) _Node->setModified(true); } - - /// Wrapper to set the axis of the spinner - struct CAxisWrapper : public IPSWrapper - { - NL3D::CPSBasisSpinner *S; - NLMISC::CVector get(void) const { return S->_F.getAxis(); } - void set(const NLMISC::CVector &axis) { S->_F.setAxis(axis); } - } _AxisWrapper; - QLabel *_nbSamplesLabel; QVBoxLayout *_verticalLayout; CEditRangeUIntWidget *_nbSamplesWidget; CDirectionWidget *_dirWidget; + + CWorkspaceNode *_Node; + NL3D::CPSBasisSpinner *_BasicSpinner; }; } /* namespace NLQT */