Revision: 8954
http://playerstage.svn.sourceforge.net/playerstage/?rev=8954&view=rev
Author: natepak
Date: 2010-11-03 22:51:07 +0000 (Wed, 03 Nov 2010)
Log Message:
-----------
Updates to parameter setting
Modified Paths:
--------------
code/gazebo/trunk/server/wx/PhysicsPage.cc
code/gazebo/trunk/server/wx/PhysicsPage.hh
code/gazebo/trunk/server/wx/Properties.cc
code/gazebo/trunk/server/wx/Properties.hh
Modified: code/gazebo/trunk/server/wx/PhysicsPage.cc
===================================================================
--- code/gazebo/trunk/server/wx/PhysicsPage.cc 2010-11-03 16:52:46 UTC (rev
8953)
+++ code/gazebo/trunk/server/wx/PhysicsPage.cc 2010-11-03 22:51:07 UTC (rev
8954)
@@ -18,76 +18,34 @@
PhysicsEngine *engine = World::Instance()->GetPhysicsEngine();
wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL);
-
- this->propGrid = new wxPropertyGrid( this, wxID_ANY, wxDefaultPosition,
wxDefaultSize, wxPG_DEFAULT_STYLE|wxPG_SPLITTER_AUTO_CENTER);
- this->propGrid->Connect( wxEVT_PG_CHANGED, wxPropertyGridEventHandler(
PhysicsPage::OnPropertyChanged), NULL, this);
- unsigned int paramCount = engine->GetParamCount();
-
PropertyFactory::RegisterAll();
- for (unsigned int i = 0; i < paramCount; i++)
- {
- Param *param = engine->GetParam(i);
- Property *prop = PropertyFactory::CreateProperty(param, this->propGrid);
+ this->propGrid = new wxPropertyGrid( this, wxID_ANY, wxDefaultPosition,
wxDefaultSize, wxPG_DEFAULT_STYLE|wxPG_SPLITTER_AUTO_CENTER);
- /*wxString paramName = wxString::FromAscii(param->GetKey().c_str());
- wxString paramValue = wxString::FromAscii(param->GetAsString().c_str());
+ this->propManager = new PropertyManager(this->propGrid);
- wxPGProperty *prop = NULL;
- if (param->IsInt())
- prop = this->propGrid->Append(new wxIntProperty(paramName, wxPG_LABEL));
- else if (param->IsUInt())
- prop = this->propGrid->Append(new wxUIntProperty(paramName, wxPG_LABEL));
- else if (param->IsBool())
- {
- prop = this->propGrid->Append(new wxBoolProperty(paramName, wxPG_LABEL));
- if (param->GetAsString() == "1")
- paramValue = wxT("True");
- else
- paramValue = wxT("False");
- }
- else if (param->IsFloat() || param->IsDouble())
- prop = this->propGrid->Append(new wxFloatProperty(paramName,
wxPG_LABEL));
- else if (param->IsStr())
- prop = this->propGrid->Append(new wxStringProperty(paramName,
wxPG_LABEL));
+ unsigned int paramCount = engine->GetParamCount();
- if (prop)
- {
- prop->SetValueFromString( paramValue );
- prop->SetClientData( param );
- }
- */
+ for (unsigned int i = 0; i < paramCount; i++)
+ {
+ this->propManager->AddProperty( engine->GetParam(i) );
}
boxSizer->Add(this->propGrid, 1, wxEXPAND | wxALL,4);
this->SetSizer(boxSizer);
this->Layout();
-
}
////////////////////////////////////////////////////////////////////////////////
+// Destructor
PhysicsPage::~PhysicsPage()
{
- this->propGrid->Destroy();
+ delete this->propManager;
+ this->grid->Destroy();
}
////////////////////////////////////////////////////////////////////////////////
void PhysicsPage::Apply()
{
}
-
-////////////////////////////////////////////////////////////////////////////////
-// On property changed event callback
-void PhysicsPage::OnPropertyChanged(wxPropertyGridEvent &event)
-{
- wxPGProperty *wxprop = event.GetProperty();
-
- if (!wxprop)
- return;
-
- Property *prop = (Property*)(wxprop->GetClientData());
-
- if (prop)
- prop->Changed();
-}
Modified: code/gazebo/trunk/server/wx/PhysicsPage.hh
===================================================================
--- code/gazebo/trunk/server/wx/PhysicsPage.hh 2010-11-03 16:52:46 UTC (rev
8953)
+++ code/gazebo/trunk/server/wx/PhysicsPage.hh 2010-11-03 22:51:07 UTC (rev
8954)
@@ -8,6 +8,8 @@
namespace gazebo
{
+ class PropertyManager;
+
class PhysicsPage : public ParamPage
{
public: PhysicsPage(wxWindow *parent);
@@ -19,6 +21,7 @@
private: void OnPropertyChanged(wxPropertyGridEvent &event);
private: wxPropertyGrid *propGrid;
+ private: PropertyManager *propManager;
};
}
Modified: code/gazebo/trunk/server/wx/Properties.cc
===================================================================
--- code/gazebo/trunk/server/wx/Properties.cc 2010-11-03 16:52:46 UTC (rev
8953)
+++ code/gazebo/trunk/server/wx/Properties.cc 2010-11-03 22:51:07 UTC (rev
8954)
@@ -48,8 +48,48 @@
return NULL;
}
+////////////////////////////////////////////////////////////////////////////////
+// Constructor
+PropertyManager::PropertyManager()
+{
+ this->grid->Connect( wxEVT_PG_CHANGED, wxPropertyGridEventHandler(
PropertyManager::OnPropertyChanged), NULL, this);
+}
////////////////////////////////////////////////////////////////////////////////
+// Destructor
+PropertyManager::~PropertyManager()
+{
+ std::list<Property*>::iterator iter;
+
+ for (iter = this->properties.begin(); iter != this->properties.end(); iter++)
+ delete *iter;
+ this->properties.clear();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Add a property
+void PropertyManager::AddProperty(Param *p)
+{
+ Property *prop = PropertyFactory::CreateProperty( param, this->grid );
+ this->properties.push_back( prop );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// On property changed event callback
+void PropertyManager::OnPropertyChanged(wxPropertyGridEvent &event)
+{
+ wxPGProperty *wxprop = event.GetProperty();
+
+ if (!wxprop)
+ return;
+
+ Property *prop = (Property*)(wxprop->GetClientData());
+
+ if (prop)
+ prop->Changed();
+}
+
+////////////////////////////////////////////////////////////////////////////////
// Constructor
Property::Property(Param *p, wxPropertyGrid *grid)
: param(p), grid(grid), property(NULL)
@@ -241,6 +281,15 @@
this->property->SetValueFromString(
wxString::FromAscii(param->GetAsString().c_str()) );
+
+ Param<Quatern> *pv = (ParamT<Quatern>*)pv;
+ Vector3 rpy = (**pv).GetAsEuler();
+
+ this->roll = this->grid->AppendIn( this->property, new wxFloatProperty(
wxT("Roll"), wxT("Roll"), rpy.x) );
+ this->pitch = this->grid->AppendIn( this->property, new wxFloatProperty(
wxT("Pitch"), wxT("Pitch"), rpy.y ) );
+ this->yaw = this->grid->AppendIn( this->property, new wxFloatProperty(
wxT("Yaw"), wxT("Yaw"), rpy.z) );
+
+ this->grid->Collapse( this->property );
}
////////////////////////////////////////////////////////////////////////////////
@@ -261,6 +310,11 @@
this->property->SetValueFromString(
wxString::FromAscii(param->GetAsString().c_str()) );
+
+ this->sec = this->grid->AppendIn( this->property, new wxIntProperty(
wxT("Seconds"), wxT("Sec"), 0.0) );
+ this->msec = this->grid->AppendIn( this->property, new wxIntProperty(
wxT("Miliseconds"), wxT("Millisec"), 0.0) );
+
+ this->grid->Collapse( this->property );
}
////////////////////////////////////////////////////////////////////////////////
@@ -268,3 +322,23 @@
TimeProperty::~TimeProperty()
{
}
+
+////////////////////////////////////////////////////////////////////////////////
+// COLOR constructor
+ColorProperty::ColorProperty(Param *p, wxPropertyGrid *grid)
+ : Property(p,grid)
+{
+ this->property = this->grid->Append(
+ new wxStringProperty( wxString::FromAscii(param->GetKey().c_str()),
+ wxPG_LABEL ));
+ this->property->SetClientData(this);
+
+ this->property->SetValueFromString(
+ wxString::FromAscii(param->GetAsString().c_str()) );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// COLOR destructor
+ColorProperty::~ColorProperty()
+{
+}
Modified: code/gazebo/trunk/server/wx/Properties.hh
===================================================================
--- code/gazebo/trunk/server/wx/Properties.hh 2010-11-03 16:52:46 UTC (rev
8953)
+++ code/gazebo/trunk/server/wx/Properties.hh 2010-11-03 22:51:07 UTC (rev
8954)
@@ -25,7 +25,16 @@
protected: wxPGProperty *property;
};
+ class PropertyManager
+ {
+ public: PropertyManager();
+ public: virtual ~PropertyManager();
+ private: wxPropertyGrid *grid;
+ private: std::list<Property*> properties;
+ };
+
+
typedef Property* (*PropertyFactoryFn) (Param *, wxPropertyGrid *grid);
class PropertyFactory
@@ -107,14 +116,26 @@
{
public: QuaternProperty(Param *p, wxPropertyGrid *grid);
public: virtual ~QuaternProperty();
+
+ private: wxPGProperty *roll;
+ private: wxPGProperty *pitch;
+ private: wxPGProperty *yaw;
};
class TimeProperty : public Property
{
public: TimeProperty(Param *p, wxPropertyGrid *grid);
public: virtual ~TimeProperty();
+
+ private: wxPGProperty *sec;
+ private: wxPGProperty *ms;
};
+ class ColorProperty : public Property
+ {
+ public: ColorProperty(Param *p, wxPropertyGrid *grid);
+ public: virtual ~ColorProperty();
+ };
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit