44 #include "LightWidget.hh" 50 updatingWidgets_(false)
57 std::cerr <<
"LightWidget could not cast given node to LightNode!" << std::endl;
73 connect(spotx,SIGNAL(editingFinished()),
this,SLOT(
spotChanged()));
74 connect(spoty,SIGNAL(editingFinished()),
this,SLOT(
spotChanged()));
75 connect(spotz,SIGNAL(editingFinished()),
this,SLOT(
spotChanged()));
77 connect(angle,SIGNAL(editingFinished()),
this,SLOT(
spotChanged()));
78 connect(exponent,SIGNAL(editingFinished()),
this,SLOT(
spotChanged()));
80 brightness->setTracking(
true);
81 connect(brightness, SIGNAL(valueChanged(
int)),
this, SLOT(
brightnessChanged(
int)));
83 connect(ambientR,SIGNAL(editingFinished()),
this,SLOT(
ambientChanged()));
84 connect(ambientG,SIGNAL(editingFinished()),
this,SLOT(
ambientChanged()));
85 connect(ambientB,SIGNAL(editingFinished()),
this,SLOT(
ambientChanged()));
86 connect(ambientA,SIGNAL(editingFinished()),
this,SLOT(
ambientChanged()));
88 connect(diffuseR,SIGNAL(editingFinished()),
this,SLOT(diffuseChanged()));
89 connect(diffuseG,SIGNAL(editingFinished()),
this,SLOT(diffuseChanged()));
90 connect(diffuseB,SIGNAL(editingFinished()),
this,SLOT(diffuseChanged()));
91 connect(diffuseA,SIGNAL(editingFinished()),
this,SLOT(diffuseChanged()));
93 connect(specularR,SIGNAL(editingFinished()),
this,SLOT(specularChanged()));
94 connect(specularG,SIGNAL(editingFinished()),
this,SLOT(specularChanged()));
95 connect(specularB,SIGNAL(editingFinished()),
this,SLOT(specularChanged()));
96 connect(specularA,SIGNAL(editingFinished()),
this,SLOT(specularChanged()));
98 connect(radius,SIGNAL(editingFinished()),
this,SLOT(
radiusChanged()));
107 updatingWidgets_ =
true;
112 if ( directional->isChecked() )
113 stackedWidget->setCurrentIndex(1);
115 stackedWidget->setCurrentIndex(0);
117 xdir->setText(QString::number(light_->
direction()[0]));
118 ydir->setText(QString::number(light_->
direction()[1]));
119 zdir->setText(QString::number(light_->
direction()[2]));
121 xpos->setText(QString::number(light_->
position()[0]));
122 ypos->setText(QString::number(light_->
position()[1]));
123 zpos->setText(QString::number(light_->
position()[2]));
131 angle->setText(QString::number(light_->spotCutoff()));
132 exponent->setText(QString::number(light_->spotExponent()));
134 ambientR->setText(QString::number(light_->
ambientColor()[0]));
135 ambientG->setText(QString::number(light_->
ambientColor()[1]));
136 ambientB->setText(QString::number(light_->
ambientColor()[2]));
137 ambientA->setText(QString::number(light_->
ambientColor()[3]));
139 diffuseR->setText(QString::number(light_->
diffuseColor()[0]));
140 diffuseG->setText(QString::number(light_->
diffuseColor()[1]));
141 diffuseB->setText(QString::number(light_->
diffuseColor()[2]));
142 diffuseA->setText(QString::number(light_->
diffuseColor()[3]));
144 specularR->setText(QString::number(light_->
specularColor()[0]));
145 specularG->setText(QString::number(light_->
specularColor()[1]));
146 specularB->setText(QString::number(light_->
specularColor()[2]));
147 specularA->setText(QString::number(light_->
specularColor()[3]));
149 brightness->setSliderPosition((
int)(light_->brightness()*100));
151 radius->setText(QString::number(light_->
radius()));
154 updatingWidgets_ =
false;
166 if ( directional->isChecked() )
167 stackedWidget->setCurrentIndex(1);
169 stackedWidget->setCurrentIndex(0);
171 if ( directional->isChecked() )
172 light_->
direction(
ACG::Vec3d( xdir->text().toDouble() ,ydir->text().toDouble() ,zdir->text().toDouble() ));
174 light_->
position(
ACG::Vec3d( xpos->text().toDouble() ,ypos->text().toDouble() ,zpos->text().toDouble() ));
198 ambientG->text().toDouble(),
199 ambientB->text().toDouble(),
200 ambientA->text().toDouble()));
204 void LightWidget::diffuseChanged() {
211 diffuseG->text().toDouble(),
212 diffuseB->text().toDouble(),
213 diffuseA->text().toDouble()));
217 void LightWidget::specularChanged() {
224 specularG->text().toDouble(),
225 specularB->text().toDouble(),
226 specularA->text().toDouble()));
236 float pos = _newValue;
239 light_->brightness(pos);
250 light_->
radius(radius->text().toDouble());
260 light_->
spotDirection(
ACG::Vec3d( spotx->text().toDouble() ,spoty->text().toDouble() ,spotz->text().toDouble() ));
261 light_->spotCutoff(angle->text().toDouble());
263 light_->spotExponent(exponent->text().toDouble());
272 if ( o_it->hasNode(node_) ) {
279 std::cerr <<
" Object not found! " << std::endl;
void position(Vec3d _pos)
Set position for LightSource.
void specularColor(Vec4f _color)
set Specular color for LightSource
LightObject * lightObject(BaseObjectData *_object)
Cast an BaseObject to a LightObject if possible.
void setDirty(bool _dirty=true)
mark node for redrawn
const QStringList ALL_OBJECTS
Iterable object range.
void ambientColor(Vec4f _color)
set Ambient color for LightSource
float radius() const
Get light source radius.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
void diffuseColor(Vec4f _color)
set Diffuse color for LightSource
virtual void update(UpdateType _type=UPDATE_ALL)
Update the Light Object.
Vec3d direction() const
Get direction of the light source.
void fixedPosition(bool _state)
make LightSource fixed or moveable with ModelViewMatrix
bool directional() const
Check if the light source is a directional light source.
void spotDirection(Vec3d _pos)
Set spot direction.
LightSource * lightSource(BaseObjectData *_object)
Get the lightSource in this Object.