mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-21 00:18:43 +00:00
Changed: #1193 If switch between the force properties in a workspace erroneously marked that the particle system has been changed.
This commit is contained in:
parent
afca6154f9
commit
fb8dff80cf
10 changed files with 161 additions and 226 deletions
|
@ -84,7 +84,6 @@ Using this widget you can set the color(RGBA) using the four sliders or through
|
|||
CDirectionWidget
|
||||
</b><br>
|
||||
This widget helps to choose from several preset directions, or to choose a custom one.
|
||||
To use it you have to create a wrapper.
|
||||
<br><br>
|
||||
<img src="cdirection_widget.png" alt="CDirectionWidget">
|
||||
@see
|
||||
|
|
|
@ -25,12 +25,11 @@
|
|||
|
||||
// NeL includes
|
||||
#include <nel/misc/vector.h>
|
||||
#include <nel/3d/particle_system.h>
|
||||
|
||||
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<NLMISC::CVector> *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 */
|
|
@ -28,7 +28,6 @@
|
|||
#include <nel/3d/ps_direction.h>
|
||||
|
||||
// Project includes
|
||||
#include "ps_wrapper.h"
|
||||
|
||||
namespace NLQT {
|
||||
|
||||
|
@ -45,13 +44,7 @@ public:
|
|||
CDirectionWidget(QWidget *parent = 0);
|
||||
~CDirectionWidget();
|
||||
|
||||
void enableGlobalVariable();
|
||||
void setWrapper(IPSWrapper<NLMISC::CVector> *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<NLMISC::CVector> *_Wrapper ;
|
||||
NL3D::CPSDirection *_DirectionWrapper;
|
||||
NLMISC::CVector _value;
|
||||
QString _globalName;
|
||||
|
||||
|
|
|
@ -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<NL3D::CPSEmitterConic *>(_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<NL3D::CPSDirection *>(_Emitter)->setDir(value);
|
||||
updateModifiedFlag();
|
||||
}
|
||||
|
||||
void CEmitterPage::updatePeriodWidget()
|
||||
|
|
|
@ -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<NL3D::CPSTargetLocatedBindable *>(locatedBindable);
|
||||
|
||||
updateTargets();
|
||||
|
||||
// force with intensity case
|
||||
|
@ -77,41 +77,33 @@ void CForcePage::setEditedItem(CWorkspaceNode *ownerNode, NL3D::CPSLocatedBindab
|
|||
}
|
||||
|
||||
// vortex (to tune viscosity)
|
||||
if (dynamic_cast<NL3D::CPSCylindricVortex *>(_LBTarget))
|
||||
NL3D::CPSCylindricVortex *cylindricVortex = dynamic_cast<NL3D::CPSCylindricVortex *>(_LBTarget);
|
||||
if (cylindricVortex)
|
||||
{
|
||||
_RadialViscosityWrapper.OwnerNode = _Node;
|
||||
_RadialViscosityWrapper.V = dynamic_cast<NL3D::CPSCylindricVortex *>(_LBTarget);
|
||||
|
||||
_ui.radialViscosityWidget->updateUi();
|
||||
_ui.radialViscosityWidget->setValue(cylindricVortex->getRadialViscosity(), false);
|
||||
_ui.radialViscosityLabel->show();
|
||||
_ui.radialViscosityWidget->show();
|
||||
|
||||
_TangentialViscosityWrapper.OwnerNode = _Node;
|
||||
_TangentialViscosityWrapper.V = dynamic_cast<NL3D::CPSCylindricVortex *>(_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<NL3D::CPSDirection *>(_LBTarget))
|
||||
NL3D::CPSDirection *direction = dynamic_cast<NL3D::CPSDirection *>(_LBTarget);
|
||||
if (direction)
|
||||
{
|
||||
_DirectionWrapper.OwnerNode = _Node;
|
||||
_DirectionWrapper.E = dynamic_cast<NL3D::CPSDirection *>(_LBTarget);
|
||||
_ui.directionWidget->setDirectionWrapper(dynamic_cast<NL3D::CPSDirection *>(_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<NL3D::CPSBrownianForce *>(_LBTarget))
|
||||
NL3D::CPSBrownianForce *brownianForce = dynamic_cast<NL3D::CPSBrownianForce *>(_LBTarget);
|
||||
if (brownianForce)
|
||||
{
|
||||
_ParamFactorWrapper.OwnerNode = _Node;
|
||||
_ParamFactorWrapper.F = static_cast<NL3D::CPSBrownianForce *>(_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<NL3D::CPSCylindricVortex *>(_LBTarget)->setRadialViscosity(value);
|
||||
updateModifiedFlag();
|
||||
}
|
||||
|
||||
void CForcePage::hideWrappersWidget()
|
||||
void CForcePage::setTangentialViscosity(float value)
|
||||
{
|
||||
nlassert(_LBTarget);
|
||||
dynamic_cast<NL3D::CPSCylindricVortex *>(_LBTarget)->setTangentialViscosity(value);
|
||||
updateModifiedFlag();
|
||||
}
|
||||
|
||||
void CForcePage::setDir(const NLMISC::CVector &value)
|
||||
{
|
||||
nlassert(_LBTarget);
|
||||
dynamic_cast<NL3D::CPSDirection *>(_LBTarget)->setDir(value);
|
||||
updateModifiedFlag();
|
||||
}
|
||||
|
||||
void CForcePage::setGlobalName(const QString &globalName)
|
||||
{
|
||||
nlassert(_LBTarget);
|
||||
dynamic_cast<NL3D::CPSDirection *>(_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<NL3D::CPSBrownianForce *>(_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();
|
||||
|
||||
|
|
|
@ -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<NLMISC::CVector>
|
||||
{
|
||||
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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<NLMISC::CVector>
|
||||
{
|
||||
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) ;
|
||||
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
Object Viewer Qt
|
||||
Copyright (C) 2010 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
Object Viewer Qt
|
||||
Copyright (C) 2010 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
|
@ -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 */
|
|
@ -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<NLMISC::CVector>
|
||||
{
|
||||
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 */
|
||||
|
|
Loading…
Reference in a new issue