Revision: 8828
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8828&view=rev
Author:   natepak
Date:     2010-07-22 16:01:47 +0000 (Thu, 22 Jul 2010)

Log Message:
-----------
More improvements to wx gazebo

Modified Paths:
--------------
    code/gazebo/branches/wx/server/wx/RenderPanel.cc
    code/gazebo/branches/wx/server/wx/RenderPanel.hh
    code/gazebo/branches/wx/server/wx/SimulationFrame.cc
    code/gazebo/branches/wx/server/wx/SimulationFrame.hh

Modified: code/gazebo/branches/wx/server/wx/RenderPanel.cc
===================================================================
--- code/gazebo/branches/wx/server/wx/RenderPanel.cc    2010-07-21 22:23:22 UTC 
(rev 8827)
+++ code/gazebo/branches/wx/server/wx/RenderPanel.cc    2010-07-22 16:01:47 UTC 
(rev 8828)
@@ -17,16 +17,22 @@
 using namespace gazebo;
 
 IMPLEMENT_CLASS(RenderPanel, wxControl)
+BEGIN_EVENT_TABLE(RenderPanel, wxControl)
+EVT_SIZE (RenderPanel::OnSize)
+END_EVENT_TABLE()
 
 
////////////////////////////////////////////////////////////////////////////////
 // Constructor
 RenderPanel::RenderPanel(wxWindow *parent)
   : wxControl(parent, wxID_ANY, wxDefaultPosition, wxSize(320,240), 
wxSUNKEN_BORDER, wxDefaultValidator)
 {
+
   this->userCamera = NULL;
   this->cursorState = "default";
   this->currMaker = NULL;
 
+  SetFocus();
+
   Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( RenderPanel::OnMouseEvent ), 
NULL, this );
   Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( RenderPanel::OnMouseEvent 
), NULL, this );
   Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( RenderPanel::OnMouseEvent ), 
NULL, this );
@@ -101,10 +107,20 @@
   this->mouseEvent.left = event.LeftIsDown() ? MouseEvent::DOWN : 
MouseEvent::UP;
   this->mouseEvent.right = event.RightIsDown() ? MouseEvent::DOWN : 
MouseEvent::UP;
   this->mouseEvent.middle = event.MiddleIsDown() ? MouseEvent::DOWN : 
MouseEvent::UP;
+ 
+  if (event.GetWheelRotation() < 0) 
+  {
+    this->mouseEvent.scroll.y = 1;
+    this->mouseEvent.middle = MouseEvent::SCROLL;
+  }
+  else if (event.GetWheelRotation() > 0)
+  {
+    this->mouseEvent.scroll.y = -1;
+    this->mouseEvent.middle = MouseEvent::SCROLL;
+  }
 
   this->mouseEvent.dragging = event.Dragging();
 
-
   if (this->currMaker)
   {
     if (event.LeftDown())
@@ -204,6 +220,7 @@
   this->userCamera->Load(NULL);
 }
 
+////////////////////////////////////////////////////////////////////////////////
 void RenderPanel::Init()
 {
   Pose3d pose;
@@ -213,6 +230,7 @@
   this->userCamera->SetWorldPose(pose);
 }
 
+////////////////////////////////////////////////////////////////////////////////
 void RenderPanel::CreateEntity(std::string name)
 {
   if (this->currMaker)
@@ -244,3 +262,17 @@
   if (this->currMaker)
     this->currMaker->Start();
 }
+
+void RenderPanel::OnSize( wxSizeEvent &evt )
+{
+  int width;
+  int height;
+  wxSize size = evt.GetSize ();
+  width = size.GetWidth ();
+  height = size.GetHeight ();
+
+  if (this->userCamera)
+    this->userCamera->Resize(width,height);
+
+  evt.Skip();
+}

Modified: code/gazebo/branches/wx/server/wx/RenderPanel.hh
===================================================================
--- code/gazebo/branches/wx/server/wx/RenderPanel.hh    2010-07-21 22:23:22 UTC 
(rev 8827)
+++ code/gazebo/branches/wx/server/wx/RenderPanel.hh    2010-07-22 16:01:47 UTC 
(rev 8828)
@@ -19,6 +19,7 @@
   class RenderPanel : public wxControl
   {
     DECLARE_CLASS(RenderPanel)
+    DECLARE_EVENT_TABLE()
 
     /// \brief Constructor
     public: RenderPanel(wxWindow *parent);
@@ -40,8 +41,11 @@
     /// \brief Create the camera
     public: void CreateCamera();
 
+    protected: virtual void OnSize( wxSizeEvent &evt );
+
     private: void CreateEntity(std::string name);
 
+
     private: UserCamera *userCamera;
 
     private: MouseEvent mouseEvent;

Modified: code/gazebo/branches/wx/server/wx/SimulationFrame.cc
===================================================================
--- code/gazebo/branches/wx/server/wx/SimulationFrame.cc        2010-07-21 
22:23:22 UTC (rev 8827)
+++ code/gazebo/branches/wx/server/wx/SimulationFrame.cc        2010-07-22 
16:01:47 UTC (rev 8828)
@@ -51,6 +51,20 @@
   image.Load("cylinder_create_blue.png");
   wxBitmap cylinder_bitmap(wxString::FromAscii(image.GetFilename().c_str()), 
wxBITMAP_TYPE_PNG);
 
+  image.Load("pointlight.png");
+  wxBitmap pointlight_bitmap(wxString::FromAscii(image.GetFilename().c_str()), 
wxBITMAP_TYPE_PNG);
+
+  image.Load("spotlight.png");
+  wxBitmap spotlight_bitmap(wxString::FromAscii(image.GetFilename().c_str()), 
wxBITMAP_TYPE_PNG);
+
+  image.Load("directionallight.png");
+  wxBitmap 
directionallight_bitmap(wxString::FromAscii(image.GetFilename().c_str()), 
wxBITMAP_TYPE_PNG);
+
+  image.Load("cursor.png");
+  wxBitmap cursor_bitmap(wxString::FromAscii(image.GetFilename().c_str()), 
wxBITMAP_TYPE_PNG);
+
+
+
   this->toolbar = new wxToolBar(this, wxID_ANY, wxDefaultPosition, 
wxDefaultSize, wxNO_BORDER|wxTB_HORIZONTAL);
   this->toolbar->Connect( wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( 
SimulationFrame::OnToolClicked), NULL , this );
 
@@ -59,9 +73,14 @@
   this->toolbar->AddCheckTool(STEP, wxT("Step"), step_bitmap, wxNullBitmap, 
wxT("Step the simulation"));
   this->toolbar->AddSeparator();
 
-  this->toolbar->AddCheckTool(BOX, wxT("Box"), box_bitmap, wxNullBitmap, 
wxT("Create a box"));
-  this->toolbar->AddCheckTool(SPHERE, wxT("Sphere"), sphere_bitmap, 
wxNullBitmap, wxT("Create a sphere"));
-  this->toolbar->AddCheckTool(CYLINDER, wxT("Cylinder"), cylinder_bitmap, 
wxNullBitmap, wxT("Create a cylinder"));
+
+  this->toolbar->AddRadioTool(CURSOR, wxT("Cursor"), cursor_bitmap, 
wxNullBitmap, wxT("Camera movement"));
+  this->toolbar->AddRadioTool(BOX, wxT("Box"), box_bitmap, wxNullBitmap, 
wxT("Create a box"));
+  this->toolbar->AddRadioTool(SPHERE, wxT("Sphere"), sphere_bitmap, 
wxNullBitmap, wxT("Create a sphere"));
+  this->toolbar->AddRadioTool(CYLINDER, wxT("Cylinder"), cylinder_bitmap, 
wxNullBitmap, wxT("Create a cylinder"));
+  this->toolbar->AddRadioTool(POINT, wxT("Point"), pointlight_bitmap, 
wxNullBitmap, wxT("Create a point light source"));
+  this->toolbar->AddRadioTool(POINT, wxT("Spot"), spotlight_bitmap, 
wxNullBitmap, wxT("Create a spot light"));
+  this->toolbar->AddRadioTool(POINT, wxT("Directional"), 
directionallight_bitmap, wxNullBitmap, wxT("Create a directional light"));
   this->toolbar->Realize();
  
 #endif
@@ -74,8 +93,9 @@
     this->auiManager->AddPane(this->toolbar, 
wxAuiPaneInfo().ToolbarPane().RightDockable(false).LeftDockable(false).MinSize(100,30).Top().Name(wxT("Tools")).Caption(wxT("Tools")));
   this->auiManager->Update();
 
- this->auiManager->Update();
+  Connect(wxEVT_AUI_PANE_CLOSE, 
wxAuiManagerEventHandler(SimulationFrame::OnPaneClosed), NULL, this);
 
+
  Simulator::Instance()->ConnectPauseSignal( 
boost::bind(&SimulationFrame::OnPause, this, _1) );
 }
 
@@ -135,6 +155,14 @@
 {
   int id = event.GetId();
 
+  this->toolbar->ToggleTool(BOX, false);
+  this->toolbar->ToggleTool(SPHERE, false);
+  this->toolbar->ToggleTool(CYLINDER, false);
+  this->toolbar->ToggleTool(SPOT, false);
+  this->toolbar->ToggleTool(POINT, false);
+  this->toolbar->ToggleTool(DIRECTIONAL, false);
+
+
   if (id == PLAY)
   {
     this->toolbar->ToggleTool(PAUSE, false);
@@ -155,33 +183,46 @@
   }
   else if (id == BOX)
   {
-    this->toolbar->ToggleTool(SPHERE, false);
-    this->toolbar->ToggleTool(CYLINDER, false);
-
-    if (this->toolbar->GetToolState(BOX))
-      Events::createEntitySignal("box");
-    else
-      Events::createEntitySignal("");
+    this->renderPanel->SetCursor(*wxCROSS_CURSOR);
+    Events::createEntitySignal("box");
   }
   else if (id == SPHERE)
   {
-    this->toolbar->ToggleTool(BOX, false);
-    this->toolbar->ToggleTool(CYLINDER, false);
-
-    if (this->toolbar->GetToolState(SPHERE))
-      Events::createEntitySignal("sphere");
-    else
-      Events::createEntitySignal("");
+    this->renderPanel->SetCursor(*wxCROSS_CURSOR);
+    Events::createEntitySignal("sphere");
   }
   else if (id == CYLINDER)
   {
-    this->toolbar->ToggleTool(BOX, false);
-    this->toolbar->ToggleTool(SPHERE, false);
-
-    if (this->toolbar->GetToolState(CYLINDER))
-      Events::createEntitySignal("cylinder");
-    else
-      Events::createEntitySignal("");
+    this->renderPanel->SetCursor(*wxCROSS_CURSOR);
+    Events::createEntitySignal("cylinder");
   }
+  else if (id == POINT)
+  {
+    this->renderPanel->SetCursor(*wxCROSS_CURSOR);
+    Events::createEntitySignal("pointlight");
+  }
+  else if (id == SPOT)
+  {
+    this->renderPanel->SetCursor(*wxCROSS_CURSOR);
+    Events::createEntitySignal("spolight");
+  }
+  else if (id == DIRECTIONAL)
+  {
+    this->renderPanel->SetCursor(*wxCROSS_CURSOR);
+    Events::createEntitySignal("directionallight");
+  }
+  else if (id == CURSOR)
+  {
+    this->renderPanel->SetCursor(*wxSTANDARD_CURSOR);
+    Events::createEntitySignal("");
+  }
 
 }
+
+void SimulationFrame::OnPaneClosed(wxAuiManagerEvent &event)
+{
+  this->auiManager->Update();
+  //wxAuiPaneInfo* pane = event.GetPane();
+  //wxWindow* window = pane->window;
+  //menubar_->Check(window->GetId(), false);
+}

Modified: code/gazebo/branches/wx/server/wx/SimulationFrame.hh
===================================================================
--- code/gazebo/branches/wx/server/wx/SimulationFrame.hh        2010-07-21 
22:23:22 UTC (rev 8827)
+++ code/gazebo/branches/wx/server/wx/SimulationFrame.hh        2010-07-22 
16:01:47 UTC (rev 8828)
@@ -1,6 +1,7 @@
 #include <wx/wx.h>
 
 class wxAuiManager;
+class wxAuiManagerEvent;
 
 namespace gazebo
 {
@@ -9,7 +10,7 @@
 
   class SimulationFrame : public wxFrame
   {
-    enum ToolbarButtons {PLAY, PAUSE, STEP, BOX, SPHERE, CYLINDER};
+    enum ToolbarButtons {PLAY, PAUSE, STEP, BOX, SPHERE, CYLINDER, 
DIRECTIONAL, POINT, SPOT, CURSOR};
 
     public: SimulationFrame(wxWindow *parent);
     public: virtual ~SimulationFrame();
@@ -27,6 +28,8 @@
 
     private: void OnToolClicked( wxCommandEvent &event );
 
+    private: void OnPaneClosed(wxAuiManagerEvent &event);
+
     private: RenderPanel *renderPanel;
     private: TimePanel *timePanel;
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to