Revision: 8697
http://playerstage.svn.sourceforge.net/playerstage/?rev=8697&view=rev
Author: natepak
Date: 2010-05-20 01:07:08 +0000 (Thu, 20 May 2010)
Log Message:
-----------
Fixed UI issues
Modified Paths:
--------------
code/gazebo/trunk/server/Entity.cc
code/gazebo/trunk/server/Entity.hh
code/gazebo/trunk/server/gui/ParamBrowser.cc
code/gazebo/trunk/server/gui/ParamBrowser.hh
code/gazebo/trunk/server/gui/Sidebar.cc
code/gazebo/trunk/server/rendering/Light.cc
code/gazebo/trunk/server/rendering/Light.hh
Modified: code/gazebo/trunk/server/Entity.cc
===================================================================
--- code/gazebo/trunk/server/Entity.cc 2010-05-19 23:37:50 UTC (rev 8696)
+++ code/gazebo/trunk/server/Entity.cc 2010-05-20 01:07:08 UTC (rev 8697)
@@ -183,6 +183,14 @@
}
////////////////////////////////////////////////////////////////////////////////
+/// Get a child by name
+Entity *Entity::GetChild(const std::string &name )
+{
+ std::string fullName = this->GetCompleteScopedName() + "::" + name;
+ return World::Instance()->GetEntityByName(fullName);
+}
+
+////////////////////////////////////////////////////////////////////////////////
// Return this entitie's sceneNode
OgreVisual *Entity::GetVisualNode() const
{
Modified: code/gazebo/trunk/server/Entity.hh
===================================================================
--- code/gazebo/trunk/server/Entity.hh 2010-05-19 23:37:50 UTC (rev 8696)
+++ code/gazebo/trunk/server/Entity.hh 2010-05-20 01:07:08 UTC (rev 8697)
@@ -84,6 +84,9 @@
/// \brief Get all children
/// \return Vector of children entities
public: const std::vector< Entity* > &GetChildren() const;
+
+ /// \brief Get a child by name
+ public: Entity *GetChild(const std::string &name );
/// \brief Return this entity's sceneNode
/// \return Ogre scene node
Modified: code/gazebo/trunk/server/gui/ParamBrowser.cc
===================================================================
--- code/gazebo/trunk/server/gui/ParamBrowser.cc 2010-05-19 23:37:50 UTC
(rev 8696)
+++ code/gazebo/trunk/server/gui/ParamBrowser.cc 2010-05-20 01:07:08 UTC
(rev 8697)
@@ -1,4 +1,6 @@
#include "Param.hh"
+#include "World.hh"
+#include "Entity.hh"
#include "ParamBrowser.hh"
using namespace gazebo;
@@ -10,6 +12,7 @@
{
this->end();
this->resizable(NULL);
+ this->lines = 0;
}
////////////////////////////////////////////////////////////////////////////////
@@ -23,40 +26,66 @@
void ParamBrowser::Clear()
{
this->clear();
- this->labels.clear();
+ this->lines = 0;
this->redraw();
}
void ParamBrowser::AddDivider(const std::string& key, const std::string value)
{
- int y = this->labels.size()*20;
+ int y = this->y() + this->lines*20;
MyOutput *out = new MyOutput(this->x(), y,this->w()*.5, 20);
out->box(FL_BORDER_BOX);
out->value(key.c_str());
out->textcolor(fl_rgb_color(255,255,255));
- out->color(fl_rgb_color(3,20,179),fl_rgb_color(255,255,255) );
- this->labels.push_back(out);
+ out->color(fl_rgb_color(100,100,100));
MyOutput *out2 = new MyOutput(out->x() + out->w(), y, this->w()-out->w(),20);
out2->box(FL_BORDER_BOX);
out2->textcolor(fl_rgb_color(255,255,255));
- out2->color(fl_rgb_color(3,20,179), fl_rgb_color(255,255,255) );
+
+ Entity *ent = World::Instance()->GetSelectedEntity();
+ if (ent && ent->GetName() == value)
+ out2->color(fl_rgb_color(3,20,179));
+ else
+ out2->color(fl_rgb_color(100,100,100));
+
out2->value(value.c_str());
+ out2->callback(ParamBrowser::DividerCB, this);
+ this->lines++;
+
this->add(out);
this->add(out2);
this->redraw();
}
+void ParamBrowser::DividerCB(Fl_Widget *w, void *data)
+{
+ MyOutput *out = (MyOutput*)(w);
+ std::string childName = out->value();
+
+ out->color(fl_rgb_color(3,20,179), fl_rgb_color(255,255,255) );
+ out->redraw();
+
+ Entity *ent = World::Instance()->GetSelectedEntity();
+ Entity *child = NULL;
+
+ if (ent)
+ child = ent->GetChild(childName);
+
+ if (child)
+ World::Instance()->SetSelectedEntity(child);
+
+}
+
////////////////////////////////////////////////////////////////////////////////
/// Add a value to the param browser
void ParamBrowser::AddParam(Param *param)
{
- int y = this->labels.size()*20;
+ int y = this->y() + this->lines*20;
MyOutput *out = new MyOutput(this->x(), y,this->w()*.5, 20);
out->box(FL_BORDER_BOX);
out->value(param->GetKey().c_str());
- this->labels.push_back(out);
MyInput *in = new MyInput(out->x() + out->w(), y, this->w()*.5,20);
in->box(FL_BORDER_BOX);
@@ -64,8 +93,9 @@
in->callback( &ParamBrowser::SetParam, this );
in->when(FL_WHEN_ENTER_KEY | FL_WHEN_RELEASE );
in->user_data( param );
- //this->inputs.push_back(in);
+ this->lines++;
+
this->add(out);
this->add(in);
this->redraw();
Modified: code/gazebo/trunk/server/gui/ParamBrowser.hh
===================================================================
--- code/gazebo/trunk/server/gui/ParamBrowser.hh 2010-05-19 23:37:50 UTC
(rev 8696)
+++ code/gazebo/trunk/server/gui/ParamBrowser.hh 2010-05-20 01:07:08 UTC
(rev 8697)
@@ -29,6 +29,7 @@
public: void AddParam(Param *param);
public: static void SetParam(Fl_Widget *w, void *data);
+ public: static void DividerCB(Fl_Widget *w, void *data);
private: class MyOutput : public Fl_Output
{
@@ -67,7 +68,7 @@
}
};
- private: std::vector<MyOutput*> labels;
+ private: int lines;
};
}
#endif
Modified: code/gazebo/trunk/server/gui/Sidebar.cc
===================================================================
--- code/gazebo/trunk/server/gui/Sidebar.cc 2010-05-19 23:37:50 UTC (rev
8696)
+++ code/gazebo/trunk/server/gui/Sidebar.cc 2010-05-20 01:07:08 UTC (rev
8697)
@@ -139,86 +139,18 @@
model = (Model*)(entity->GetParent());
else if (entity && entity->GetType() == Entity::MODEL)
{
- //this->paramBrowser->deselect();
model = (Model*)(entity);
}
if (model)
{
this->paramBrowser->Clear();
+
this->Helper(model);
+ //std::cout << "Value[" <<
((Fl_Valuator*)&this->paramBrowser->scrollbar)->value() << "]\n";
- // Reference
- /*for (int i=1; i <= this->entityBrowser->size(); i++)
- {
- std::string lineText = this->entityBrowser->text(i);
- if (lineText == model->GetCompleteScopedName())
- this->entityBrowser->value(i);
- }
-
- std::string value = "@b...@b52@s...@c" + model->GetTypeString();
- this->AddToParamBrowser(value);
- this->AddEntityToParamBrowser(model, "");
-
- const std::vector<Entity*> children = model->GetChildren();
- std::vector<Entity*>::const_iterator iter;
-
- for (iter = children.begin(); iter != children.end(); iter++)
- {
- Body *body = dynamic_cast<Body*>(*iter);
-
- if (!body)
- continue;
-
- value = std::string("@b...@b52@s-") + body->GetTypeString() +
":~...@b@b...@s" + body->GetName();
- this->AddToParamBrowser(value);
-
- if (body->GetName() == entity->GetName())
- this->paramBrowser->value(this->paramBrowser->size());
-
- this->AddEntityToParamBrowser( body, " " );
-
- const std::vector<Entity*> children2 =
body->GetCoMEntity()->GetChildren();
- std::vector<Entity*>::const_iterator iter2;
-
- for (iter2 = children2.begin(); iter2 != children2.end(); iter2++)
- {
- if ((*iter2)->GetType() != Entity::GEOM &&
- (*iter2)->GetType() != Entity::LIGHT)
- continue;
-
- value = "@b...@b52@s -" + (*iter2)->GetTypeString()+ ":~...@b@b...@s"
+ (*iter2)->GetName();
- this->AddToParamBrowser(value);
- this->AddEntityToParamBrowser( (*iter2), " " );
-
- if ((*iter2)->GetType() == Entity::GEOM)
- {
- Geom *geom = (Geom*)(*iter2);
- for (unsigned int i=0; i < geom->GetVisualCount(); i++)
- {
- OgreVisual *vis = geom->GetVisual(i);
- std::ostringstream stream;
- stream << vis->GetId();
- value = "@b...@b52@s -Visual:~...@b@b...@s" + stream.str();
- this->AddToParamBrowser(value);
- this->AddEntityToParamBrowser( vis, " " );
- }
- }
- else if ((*iter2)->GetType() == Entity::LIGHT)
- {
- Light *light = (Light*)(*iter2);
-
- }
- }
- }
-
- // Clear the remaining lines
- while ( this->paramBrowser->text(this->paramCount+1) != NULL )
- {
- this->AddToParamBrowser("");
- }
- */
-
+ //((Fl_Valuator*)&this->paramBrowser->scrollbar)->value(20);
+ this->paramBrowser->redraw();
this->paramInput->hide();
}
@@ -233,9 +165,7 @@
if (!entity)
{
this->entityBrowser->deselect();
- //this->paramBrowser->deselect();
- //this->paramBrowser->value(0);
- //this->paramBrowser->clear();
+ this->paramBrowser->Clear();
}
}
@@ -272,7 +202,7 @@
int endLbl = 0;
int beginValue = 0;
int selected = browser->value();
-
+
if (selected <= 0)
return;
@@ -315,14 +245,6 @@
beginValue = endLbl+1;
while (lineText[beginValue] == '@') beginValue+=2;
- /*toolbar->paramInputLbl = lineText.substr(beginLbl, endLbl-beginLbl);
-
- toolbar->paramInput->label(toolbar->paramInputLbl.c_str());
-
- toolbar->paramInput->value( lineText.substr(beginValue, lineText.size() -
beginValue).c_str() );
-
- toolbar->paramInput->redraw();
- */
}
////////////////////////////////////////////////////////////////////////////////
@@ -338,76 +260,6 @@
double dblValue = boost::lexical_cast<double>(value);
Gui::forceMultiplier = dblValue;
}
-
- /*Fl_Input *input = (Fl_Input*)(w);
- Sidebar *toolbar = (Sidebar*)(data);
- Fl_Hold_Browser *browser = toolbar->paramBrowser;
- int selected = browser->value();
- Model *model = dynamic_cast<Model*>(World::Instance()->GetSelectedEntity());
-
-
- Body *body = NULL;
- Geom *geom = NULL;
- OgreVisual *vis = NULL;
-
- std::string geomName, bodyName, visNum, value, label;
-
- // Make sure we have a valid model
- if (!model)
- {
- gzerr(0) << "Somehow you selected something that is not a model.\n";
- return;
- }
-
- value = input->value();
- label = input->label();
-
- // Get rid of the ':' at the end
- label = label.substr(0, label.size()-1);
-
- // Get the name of the body and geom.
- while (selected > 0)
- {
- std::string lineText = browser->text(selected);
- int lastAmp = lineText.rfind("@")+2;
-
- if (lineText.find("-Geom:") != std::string::npos && geomName.empty())
- geomName = lineText.substr( lastAmp, lineText.size()-lastAmp );
- else if (lineText.find("-Body:") != std::string::npos && bodyName.empty())
- bodyName = lineText.substr( lastAmp, lineText.size()-lastAmp );
- else if (lineText.find("-Visual:") != std::string::npos && visNum.empty())
- visNum = lineText.substr( lastAmp, lineText.size()-lastAmp );
-
- selected--;
- }
-
- // Get the body
- if (!bodyName.empty())
- body = model->GetBody(bodyName);
-
- // Get the geom
- if (!geomName.empty() && body)
- geom = body->GetGeom(geomName);
-
- if (!visNum.empty() && geom)
- vis = geom->GetVisualById(boost::lexical_cast<int>(visNum));
-
- // Get the parameter
- Param *param = NULL;
- if (vis)
- param = vis->GetParam(label);
- else if (geom)
- param = geom->GetParam(label);
- else if (body)
- param = body->GetParam(label);
- else
- param = model->GetParam(label);
-
- if (param)
- {
- param->SetFromString( value, true );
- }
- */
}
////////////////////////////////////////////////////////////////////////////////
Modified: code/gazebo/trunk/server/rendering/Light.cc
===================================================================
--- code/gazebo/trunk/server/rendering/Light.cc 2010-05-19 23:37:50 UTC (rev
8696)
+++ code/gazebo/trunk/server/rendering/Light.cc 2010-05-20 01:07:08 UTC (rev
8697)
@@ -47,6 +47,15 @@
this->attenuationP = new ParamT<Vector3>("attenuation", Vector3(.1, 0.01,
.001), 1);
this->attenuationP->Callback(&Light::SetAttenuation, this);
+ this->spotInnerAngleP = new ParamT<double>("innerAngle", 10, 0);
+ this->spotInnerAngleP->Callback(&Light::SetSpotInnerAngle, this);
+
+ this->spotOutterAngleP = new ParamT<double>("outterAngle", 5, 0);
+ this->spotOutterAngleP->Callback(&Light::SetSpotOutterAngle, this);
+
+ this->spotFalloffP = new ParamT<double>("falloff", 1, 0);
+ this->spotFalloffP->Callback(&Light::SetSpotFalloff, this);
+
this->rangeP = new ParamT<double>("range",10,1);
this->rangeP->Callback(&Light::SetRange, this);
@@ -72,6 +81,9 @@
delete this->attenuationP;
delete this->rangeP;
delete this->castShadowsP;
+ delete this->spotInnerAngleP;
+ delete this->spotOutterAngleP;
+ delete this->spotFalloffP;
}
////////////////////////////////////////////////////////////////////////////////
@@ -99,6 +111,9 @@
this->attenuationP->Load(node);
this->rangeP->Load(node);
this->castShadowsP->Load(node);
+ this->spotInnerAngleP->Load(node);
+ this->spotOutterAngleP->Load(node);
+ this->spotFalloffP->Load(node);
this->SetLightType( **this->lightTypeP );
this->SetDiffuseColor(**this->diffuseP);
@@ -107,15 +122,18 @@
this->SetAttenuation(**this->attenuationP);
this->SetRange(**this->rangeP);
this->SetCastShadows(**this->castShadowsP);
+ this->SetSpotInnerAngle(**this->spotInnerAngleP);
+ this->SetSpotOutterAngle(**this->spotOutterAngleP);
+ this->SetSpotFalloff(**this->spotFalloffP);
// TODO: More options for Spot lights, etc.
// options for spotlights
- if ((**this->lightTypeP) == "spot")
+ /*if ((**this->lightTypeP) == "spot")
{
vec = node->GetVector3("spotCone", Vector3(5.0, 10.0, 1.0));
this->light->setSpotlightRange(Ogre::Radian(Ogre::Degree(vec.x)),
Ogre::Radian(Ogre::Degree(vec.y)), vec.z);
- }
+ }*/
this->parent->GetVisualNode()->AttachObject(light);
@@ -351,3 +369,44 @@
this->light->setCastShadows(cast);
}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Set the spot light inner angle
+void Light::SetSpotInnerAngle(const double &angle)
+{
+ if (**this->spotInnerAngleP != angle)
+ this->spotInnerAngleP->SetValue( angle );
+
+ this->light->setSpotlightRange(
+ Ogre::Radian(Ogre::Degree(**this->spotInnerAngleP)),
+ Ogre::Radian(Ogre::Degree(**this->spotOutterAngleP)),
+ **this->spotFalloffP);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Set the spot light outter angle
+void Light::SetSpotOutterAngle(const double &angle)
+{
+ if (**this->spotOutterAngleP != angle)
+ this->spotOutterAngleP->SetValue( angle );
+
+ this->light->setSpotlightRange(
+ Ogre::Radian(Ogre::Degree(**this->spotInnerAngleP)),
+ Ogre::Radian(Ogre::Degree(**this->spotOutterAngleP)),
+ **this->spotFalloffP);
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// Set the spot light falloff
+void Light::SetSpotFalloff(const double &angle)
+{
+ if (**this->spotFalloffP != angle)
+ this->spotFalloffP->SetValue( angle );
+
+ this->light->setSpotlightRange(
+ Ogre::Radian(Ogre::Degree(**this->spotInnerAngleP)),
+ Ogre::Radian(Ogre::Degree(**this->spotOutterAngleP)),
+ **this->spotFalloffP);
+
+}
Modified: code/gazebo/trunk/server/rendering/Light.hh
===================================================================
--- code/gazebo/trunk/server/rendering/Light.hh 2010-05-19 23:37:50 UTC (rev
8696)
+++ code/gazebo/trunk/server/rendering/Light.hh 2010-05-20 01:07:08 UTC (rev
8697)
@@ -55,6 +55,15 @@
/// \brief Set the attenuation
public: void SetAttenuation(const Vector3 &att);
+ /// \brief Set the spot light inner angle
+ public: void SetSpotInnerAngle(const double &angle);
+
+ /// \brief Set the spot light outter angle
+ public: void SetSpotOutterAngle(const double &angle);
+
+ /// \brief Set the spot light falloff
+ public: void SetSpotFalloff(const double &angle);
+
/// \brief Set the range
public: void SetRange(const double &range);
@@ -78,6 +87,9 @@
private: ParamT<Vector3> *attenuationP;
private: ParamT<double> *rangeP;
private: ParamT<bool> *castShadowsP;
+ private: ParamT<double> *spotInnerAngleP;
+ private: ParamT<double> *spotOutterAngleP;
+ private: ParamT<double> *spotFalloffP;
private: static unsigned int lightCounter;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit