50 #include "LightWidget.hh"
56 updatingWidgets_(false)
63 std::cerr <<
"LightWidget could not cast given node to LightNode!" << std::endl;
79 connect(spotx,SIGNAL(editingFinished()),
this,SLOT(
spotChanged()));
80 connect(spoty,SIGNAL(editingFinished()),
this,SLOT(
spotChanged()));
81 connect(spotz,SIGNAL(editingFinished()),
this,SLOT(
spotChanged()));
83 connect(angle,SIGNAL(editingFinished()),
this,SLOT(
spotChanged()));
84 connect(exponent,SIGNAL(editingFinished()),
this,SLOT(
spotChanged()));
86 brightness->setTracking(
true);
87 connect(brightness, SIGNAL(valueChanged(
int)),
this, SLOT(
brightnessChanged(
int)));
89 connect(ambientR,SIGNAL(editingFinished()),
this,SLOT(
ambientChanged()));
90 connect(ambientG,SIGNAL(editingFinished()),
this,SLOT(
ambientChanged()));
91 connect(ambientB,SIGNAL(editingFinished()),
this,SLOT(
ambientChanged()));
92 connect(ambientA,SIGNAL(editingFinished()),
this,SLOT(
ambientChanged()));
94 connect(diffuseR,SIGNAL(editingFinished()),
this,SLOT(diffuseChanged()));
95 connect(diffuseG,SIGNAL(editingFinished()),
this,SLOT(diffuseChanged()));
96 connect(diffuseB,SIGNAL(editingFinished()),
this,SLOT(diffuseChanged()));
97 connect(diffuseA,SIGNAL(editingFinished()),
this,SLOT(diffuseChanged()));
99 connect(specularR,SIGNAL(editingFinished()),
this,SLOT(specularChanged()));
100 connect(specularG,SIGNAL(editingFinished()),
this,SLOT(specularChanged()));
101 connect(specularB,SIGNAL(editingFinished()),
this,SLOT(specularChanged()));
102 connect(specularA,SIGNAL(editingFinished()),
this,SLOT(specularChanged()));
104 connect(radius,SIGNAL(editingFinished()),
this,SLOT(
radiusChanged()));
113 updatingWidgets_ =
true;
118 if ( directional->isChecked() )
119 stackedWidget->setCurrentIndex(1);
121 stackedWidget->setCurrentIndex(0);
123 xdir->setText(QString::number(light_->
direction()[0]));
124 ydir->setText(QString::number(light_->
direction()[1]));
125 zdir->setText(QString::number(light_->
direction()[2]));
127 xpos->setText(QString::number(light_->
position()[0]));
128 ypos->setText(QString::number(light_->
position()[1]));
129 zpos->setText(QString::number(light_->
position()[2]));
137 angle->setText(QString::number(light_->spotCutoff()));
138 exponent->setText(QString::number(light_->spotExponent()));
140 ambientR->setText(QString::number(light_->
ambientColor()[0]));
141 ambientG->setText(QString::number(light_->
ambientColor()[1]));
142 ambientB->setText(QString::number(light_->
ambientColor()[2]));
143 ambientA->setText(QString::number(light_->
ambientColor()[3]));
145 diffuseR->setText(QString::number(light_->
diffuseColor()[0]));
146 diffuseG->setText(QString::number(light_->
diffuseColor()[1]));
147 diffuseB->setText(QString::number(light_->
diffuseColor()[2]));
148 diffuseA->setText(QString::number(light_->
diffuseColor()[3]));
150 specularR->setText(QString::number(light_->
specularColor()[0]));
151 specularG->setText(QString::number(light_->
specularColor()[1]));
152 specularB->setText(QString::number(light_->
specularColor()[2]));
153 specularA->setText(QString::number(light_->
specularColor()[3]));
155 brightness->setSliderPosition((
int)(light_->brightness()*100));
157 radius->setText(QString::number(light_->
radius()));
160 updatingWidgets_ =
false;
172 if ( directional->isChecked() )
173 stackedWidget->setCurrentIndex(1);
175 stackedWidget->setCurrentIndex(0);
177 if ( directional->isChecked() )
178 light_->
direction(
ACG::Vec3d( xdir->text().toDouble() ,ydir->text().toDouble() ,zdir->text().toDouble() ));
180 light_->
position(
ACG::Vec3d( xpos->text().toDouble() ,ypos->text().toDouble() ,zpos->text().toDouble() ));
204 ambientG->text().toDouble(),
205 ambientB->text().toDouble(),
206 ambientA->text().toDouble()));
210 void LightWidget::diffuseChanged() {
217 diffuseG->text().toDouble(),
218 diffuseB->text().toDouble(),
219 diffuseA->text().toDouble()));
223 void LightWidget::specularChanged() {
230 specularG->text().toDouble(),
231 specularB->text().toDouble(),
232 specularA->text().toDouble()));
242 float pos = _newValue;
245 light_->brightness(pos);
256 light_->
radius(radius->text().toDouble());
266 light_->
spotDirection(
ACG::Vec3d( spotx->text().toDouble() ,spoty->text().toDouble() ,spotz->text().toDouble() ));
267 light_->spotCutoff(angle->text().toDouble());
269 light_->spotExponent(exponent->text().toDouble());
278 if ( o_it->hasNode(node_) ) {
285 std::cerr <<
" Object not found! " << std::endl;
const QStringList ALL_OBJECTS
Iterable object range.
void radiusChanged()
Light radius has changed.
void ambientChanged()
Color values have changed.
void fixedPositionChanged()
The fixed position checkbox.
void diffuseColor(Vec4f _color)
set Diffuse color for LightSource
LightSource * lightSource(BaseObjectData *_object)
Get the lightSource in this Object.
void directionalToggled()
The directional checkbox changed -> update object.
void fixedPosition(bool _state)
make LightSource fixed or moveable with ModelViewMatrix
void spotChanged()
Spot direction changed.
LightObject * lightObject(BaseObjectData *_object)
Cast an BaseObject to a LightObject if possible.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
Vec3d direction() const
Get direction of the light source.
void updated()
Called when the object has been updated.
bool getObject()
Initializes the internal object. Returns true if successfull.
virtual void update(UpdateType _type=UPDATE_ALL)
Update the Light Object.
bool directional() const
Check if the light source is a directional light source.
void specularColor(Vec4f _color)
set Specular color for LightSource
virtual void showEvent(QShowEvent *event)
Initialize contents of widget before showing it.
float radius() const
Get light source radius.
void ambientColor(Vec4f _color)
set Ambient color for LightSource
void brightnessChanged(int _newValue)
Brightness value has changed.
void position(Vec3d _pos)
Set position for LightSource.
void spotDirection(Vec3d _pos)
Set spot direction.
void setDirty(bool _dirty=true)
mark node for redrawn