Commit 145e814e authored by Mike Kremer's avatar Mike Kremer
Browse files

Added radius text field to light source widget.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9126 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 87c12ced
...@@ -260,7 +260,7 @@ void LightNode::draw(GLState& _state, DrawModes::DrawMode /*_drawMode*/) { ...@@ -260,7 +260,7 @@ void LightNode::draw(GLState& _state, DrawModes::DrawMode /*_drawMode*/) {
ACG::Vec3f p = ACG::Vec3f(light_.realPosition_[0], ACG::Vec3f p = ACG::Vec3f(light_.realPosition_[0],
light_.realPosition_[1], light_.realPosition_[1],
light_.realPosition_[2]); light_.realPosition_[2]);
ACG::Vec3d spot = light_.realSpotDirection_; ACG::Vec3d spotDir = light_.realSpotDirection_;
ACG::Vec4f c = light_.ambientColor() * light_.brightness_; ACG::Vec4f c = light_.ambientColor() * light_.brightness_;
// Backup variables // Backup variables
...@@ -270,7 +270,7 @@ void LightNode::draw(GLState& _state, DrawModes::DrawMode /*_drawMode*/) { ...@@ -270,7 +270,7 @@ void LightNode::draw(GLState& _state, DrawModes::DrawMode /*_drawMode*/) {
GLUquadricObj* quadric = gluNewQuadric(); GLUquadricObj* quadric = gluNewQuadric();
// Origin // Origin
_state.push_modelview_matrix (); _state.push_modelview_matrix();
// Transform to light origin and direction // Transform to light origin and direction
_state.translate(p[0], p[1], p[2]); _state.translate(p[0], p[1], p[2]);
...@@ -291,7 +291,7 @@ void LightNode::draw(GLState& _state, DrawModes::DrawMode /*_drawMode*/) { ...@@ -291,7 +291,7 @@ void LightNode::draw(GLState& _state, DrawModes::DrawMode /*_drawMode*/) {
// Rotate into light direction // Rotate into light direction
ACG::Vec3d z = ACG::Vec3d(0.0f, 0.0f, 1.0f); ACG::Vec3d z = ACG::Vec3d(0.0f, 0.0f, 1.0f);
ACG::Vec3d spot = light_.spotDirection(); ACG::Vec3d spot = spotDir;
float angle = acos((z | spot)/(z.norm()*spot.norm())); float angle = acos((z | spot)/(z.norm()*spot.norm()));
angle = angle*360/(2*M_PI); angle = angle*360/(2*M_PI);
ACG::Vec3d rA = z % spot; ACG::Vec3d rA = z % spot;
......
...@@ -92,6 +92,8 @@ LightWidget::LightWidget( ACG::SceneGraph::BaseNode* _node, QWidget *parent) ...@@ -92,6 +92,8 @@ LightWidget::LightWidget( ACG::SceneGraph::BaseNode* _node, QWidget *parent)
connect(specularR,SIGNAL(editingFinished()),this,SLOT(specularChanged())); connect(specularR,SIGNAL(editingFinished()),this,SLOT(specularChanged()));
connect(specularG,SIGNAL(editingFinished()),this,SLOT(specularChanged())); connect(specularG,SIGNAL(editingFinished()),this,SLOT(specularChanged()));
connect(specularB,SIGNAL(editingFinished()),this,SLOT(specularChanged())); connect(specularB,SIGNAL(editingFinished()),this,SLOT(specularChanged()));
connect(radius,SIGNAL(editingFinished()),this,SLOT(radiusChanged()));
} }
void LightWidget::showEvent ( QShowEvent * event ) void LightWidget::showEvent ( QShowEvent * event )
...@@ -141,6 +143,8 @@ void LightWidget::showEvent ( QShowEvent * event ) ...@@ -141,6 +143,8 @@ void LightWidget::showEvent ( QShowEvent * event )
brightness->setSliderPosition((int)(light_->brightness()*100)); brightness->setSliderPosition((int)(light_->brightness()*100));
radius->setText(QString::number(light_->radius()));
// Allow updates // Allow updates
updatingWidgets_ = false; updatingWidgets_ = false;
...@@ -221,6 +225,17 @@ void LightWidget::brightnessChanged(int _newValue) { ...@@ -221,6 +225,17 @@ void LightWidget::brightnessChanged(int _newValue) {
updated(); updated();
} }
void LightWidget::radiusChanged() {
// Block if we currently update the widgets or if we dont get the object
if (updatingWidgets_ || !getObject() )
return;
light_->radius(radius->text().toDouble());
updated();
}
void LightWidget::spotChanged() { void LightWidget::spotChanged() {
// Block if we currently update the widgets or if we dont get the object // Block if we currently update the widgets or if we dont get the object
if (updatingWidgets_ || !getObject() ) if (updatingWidgets_ || !getObject() )
......
...@@ -65,6 +65,9 @@ class DLLEXPORT LightWidget : public QDialog, public Ui::LightWidgetBase ...@@ -65,6 +65,9 @@ class DLLEXPORT LightWidget : public QDialog, public Ui::LightWidgetBase
/// Brightness value has changed /// Brightness value has changed
void brightnessChanged(int _newValue); void brightnessChanged(int _newValue);
/// Light radius has changed
void radiusChanged();
/// Spot direction changed /// Spot direction changed
void spotChanged(); void spotChanged();
......
...@@ -6,16 +6,22 @@ ...@@ -6,16 +6,22 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>277</width> <width>312</width>
<height>636</height> <height>711</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Dialog</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="directional"> <widget class="QCheckBox" name="directional">
<property name="geometry">
<rect>
<x>4</x>
<y>4</y>
<width>176</width>
<height>23</height>
</rect>
</property>
<property name="toolTip"> <property name="toolTip">
<string>Directional Light source or lightsource with position</string> <string>Directional Light source or lightsource with position</string>
</property> </property>
...@@ -23,9 +29,15 @@ ...@@ -23,9 +29,15 @@
<string>Directional Light Source</string> <string>Directional Light Source</string>
</property> </property>
</widget> </widget>
</item>
<item>
<widget class="QCheckBox" name="fixedPosition"> <widget class="QCheckBox" name="fixedPosition">
<property name="geometry">
<rect>
<x>4</x>
<y>31</y>
<width>172</width>
<height>23</height>
</rect>
</property>
<property name="toolTip"> <property name="toolTip">
<string>Light source fixed relatively to the viewer</string> <string>Light source fixed relatively to the viewer</string>
</property> </property>
...@@ -33,7 +45,16 @@ ...@@ -33,7 +45,16 @@
<string>Fixed Position/Direction</string> <string>Fixed Position/Direction</string>
</property> </property>
</widget> </widget>
</item> <widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>291</width>
<height>621</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QStackedWidget" name="stackedWidget"> <widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex"> <property name="currentIndex">
...@@ -96,9 +117,15 @@ ...@@ -96,9 +117,15 @@
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="page_2"> <widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>4</x>
<y>4</y>
<width>261</width>
<height>90</height>
</rect>
</property>
<property name="title"> <property name="title">
<string>Direction</string> <string>Direction</string>
</property> </property>
...@@ -148,13 +175,17 @@ ...@@ -148,13 +175,17 @@
</item> </item>
</layout> </layout>
</widget> </widget>
</item>
</layout>
</widget> </widget>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBox_4"> <widget class="QGroupBox" name="SpotGroup">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title"> <property name="title">
<string>Spot</string> <string>Spot</string>
</property> </property>
...@@ -214,6 +245,12 @@ ...@@ -214,6 +245,12 @@
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBox_3"> <widget class="QGroupBox" name="groupBox_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title"> <property name="title">
<string>Parameters</string> <string>Parameters</string>
</property> </property>
...@@ -248,7 +285,7 @@ ...@@ -248,7 +285,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBox_6"> <widget class="QGroupBox" name="ColorGroup">
<property name="title"> <property name="title">
<string>Colors</string> <string>Colors</string>
</property> </property>
...@@ -437,19 +474,40 @@ ...@@ -437,19 +474,40 @@
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer"> <widget class="QGroupBox" name="groupBox_7">
<property name="orientation"> <property name="title">
<enum>Qt::Vertical</enum> <string>Misc</string>
</property> </property>
<property name="sizeHint" stdset="0"> <layout class="QVBoxLayout" name="verticalLayout_7">
<size> <item>
<width>20</width> <layout class="QGridLayout" name="gridLayout_10" columnminimumwidth="5,0">
<height>117</height> <property name="sizeConstraint">
</size> <enum>QLayout::SetNoConstraint</enum>
</property>
<item row="0" column="1">
<widget class="QLineEdit" name="radius">
<property name="toolTip">
<string>Determines the light source's radius. Note: This does not affect the standard OpenGL rendering.</string>
</property>
<property name="whatsThis">
<string>Determines the light source's radius. Note: This does not affect the standard OpenGL rendering.</string>
</property> </property>
</spacer> </widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_26">
<property name="text">
<string>Radius</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>
......
...@@ -583,6 +583,7 @@ void DataControlPlugin::slotEditLight() { ...@@ -583,6 +583,7 @@ void DataControlPlugin::slotEditLight() {
if(light == 0) return; if(light == 0) return;
LightWidget* widget = new LightWidget( light->lightNode() ); LightWidget* widget = new LightWidget( light->lightNode() );
widget->setWindowFlags(Qt::WindowStaysOnTopHint);
widget->show(); widget->show();
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment