|
From: <jfa...@us...> - 2008-11-04 00:12:44
|
Revision: 6182
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=6182&view=rev
Author: jfaustwg
Date: 2008-11-04 00:12:37 +0000 (Tue, 04 Nov 2008)
Log Message:
-----------
Merge "nav viewified" visualizer from user branch
r11450@iad: jfaust | 2008-10-31 15:41:28 -0700
First pass at "tools" in the visualizer -- includes the goal/pose tools from nav_view
r11511@iad: jfaust | 2008-11-03 15:42:39 -0800
Added automatic map reloading based on metadata subscription
Also in this checkin:
Forgot to checkin a number of source files
Modified Paths:
--------------
pkg/trunk/visualization/ogre_visualizer/CMakeLists.txt
pkg/trunk/visualization/ogre_visualizer/VisualizationPanel.fbp
pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/generated/visualization_panel_generated.cpp
pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/generated/visualization_panel_generated.h
pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualization_manager.cpp
pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualization_manager.h
pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualization_panel.cpp
pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualization_panel.h
pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualizers/map_visualizer.cpp
pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualizers/map_visualizer.h
pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualizers/poly_line_2d_visualizer.cpp
pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualizers/poly_line_2d_visualizer.h
pkg/trunk/world_models/map_server/src/main.cpp
Added Paths:
-----------
pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/
pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/move_tool.cpp
pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/move_tool.h
pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/pose_tool.cpp
pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/pose_tool.h
pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/tool.cpp
pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/tool.h
Property Changed:
----------------
pkg/trunk/
Property changes on: pkg/trunk
___________________________________________________________________
Modified: svk:merge
- 920d6130-5740-4ec1-bb1a-45963d5fd813:/frameidpr:7015
920d6130-5740-4ec1-bb1a-45963d5fd813:/users/josh-pr:11054
920d6130-5740-4ec1-bb1a-45963d5fd813:/wgpkgtrunk:5865
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/rosbus:261
+ 920d6130-5740-4ec1-bb1a-45963d5fd813:/frameidpr:7015
920d6130-5740-4ec1-bb1a-45963d5fd813:/users/josh-pr:11511
920d6130-5740-4ec1-bb1a-45963d5fd813:/wgpkgtrunk:5865
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/rosbus:261
Modified: pkg/trunk/visualization/ogre_visualizer/CMakeLists.txt
===================================================================
--- pkg/trunk/visualization/ogre_visualizer/CMakeLists.txt 2008-11-04 00:06:37 UTC (rev 6181)
+++ pkg/trunk/visualization/ogre_visualizer/CMakeLists.txt 2008-11-04 00:12:37 UTC (rev 6182)
@@ -2,8 +2,8 @@
include(rosbuild)
include(FindPkgConfig)
-set(ROS_BUILD_TYPE RelWithDebInfo)
-#set(ROS_BUILD_TYPE Debug)
+#set(ROS_BUILD_TYPE RelWithDebInfo)
+set(ROS_BUILD_TYPE Debug)
rospack(ogre_visualizer)
@@ -61,6 +61,9 @@
rospack_add_library(${PROJECT_NAME} src/ogre_visualizer/properties/property.cpp
src/ogre_visualizer/properties/property_manager.cpp
+ src/ogre_visualizer/tools/tool.cpp
+ src/ogre_visualizer/tools/move_tool.cpp
+ src/ogre_visualizer/tools/pose_tool.cpp
src/ogre_visualizer/visualization_panel.cpp
src/ogre_visualizer/visualization_manager.cpp
src/ogre_visualizer/visualizer_base.cpp
Modified: pkg/trunk/visualization/ogre_visualizer/VisualizationPanel.fbp
===================================================================
--- pkg/trunk/visualization/ogre_visualizer/VisualizationPanel.fbp 2008-11-04 00:06:37 UTC (rev 6181)
+++ pkg/trunk/visualization/ogre_visualizer/VisualizationPanel.fbp 2008-11-04 00:12:37 UTC (rev 6182)
@@ -444,56 +444,118 @@
<property name="orient">wxVERTICAL</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="1">
- <property name="border">0</property>
+ <property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
- <object class="wxToolBar" expanded="1">
- <property name="bg"></property>
- <property name="bitmapsize"></property>
- <property name="context_help"></property>
- <property name="enabled">1</property>
- <property name="fg"></property>
- <property name="font"></property>
- <property name="hidden">0</property>
- <property name="id">wxID_ANY</property>
- <property name="margins"></property>
- <property name="maximum_size"></property>
+ <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
- <property name="name">views_</property>
- <property name="packing">1</property>
- <property name="permission">protected</property>
- <property name="pos"></property>
- <property name="separation">5</property>
- <property name="size"></property>
- <property name="style">wxTB_HORIZONTAL|wxTB_NOICONS|wxTB_TEXT</property>
- <property name="subclass"></property>
- <property name="tooltip"></property>
- <property name="window_extra_style"></property>
- <property name="window_name"></property>
- <property name="window_style"></property>
- <event name="OnChar"></event>
- <event name="OnEnterWindow"></event>
- <event name="OnEraseBackground"></event>
- <event name="OnKeyDown"></event>
- <event name="OnKeyUp"></event>
- <event name="OnKillFocus"></event>
- <event name="OnLeaveWindow"></event>
- <event name="OnLeftDClick"></event>
- <event name="OnLeftDown"></event>
- <event name="OnLeftUp"></event>
- <event name="OnMiddleDClick"></event>
- <event name="OnMiddleDown"></event>
- <event name="OnMiddleUp"></event>
- <event name="OnMotion"></event>
- <event name="OnMouseEvents"></event>
- <event name="OnMouseWheel"></event>
- <event name="OnPaint"></event>
- <event name="OnRightDClick"></event>
- <event name="OnRightDown"></event>
- <event name="OnRightUp"></event>
- <event name="OnSetFocus"></event>
- <event name="OnSize"></event>
- <event name="OnUpdateUI"></event>
+ <property name="name">bSizer9</property>
+ <property name="orient">wxHORIZONTAL</property>
+ <property name="permission">none</property>
+ <object class="sizeritem" expanded="1">
+ <property name="border">5</property>
+ <property name="flag">wxALL</property>
+ <property name="proportion">0</property>
+ <object class="wxChoice" expanded="1">
+ <property name="bg"></property>
+ <property name="choices"></property>
+ <property name="context_help"></property>
+ <property name="enabled">1</property>
+ <property name="fg"></property>
+ <property name="font"></property>
+ <property name="hidden">0</property>
+ <property name="id">wxID_ANY</property>
+ <property name="maximum_size"></property>
+ <property name="minimum_size">150,-1</property>
+ <property name="name">views_</property>
+ <property name="permission">protected</property>
+ <property name="pos"></property>
+ <property name="selection">0</property>
+ <property name="size"></property>
+ <property name="subclass"></property>
+ <property name="tooltip"></property>
+ <property name="window_extra_style"></property>
+ <property name="window_name"></property>
+ <property name="window_style"></property>
+ <event name="OnChar"></event>
+ <event name="OnChoice">onViewSelected</event>
+ <event name="OnEnterWindow"></event>
+ <event name="OnEraseBackground"></event>
+ <event name="OnKeyDown"></event>
+ <event name="OnKeyUp"></event>
+ <event name="OnKillFocus"></event>
+ <event name="OnLeaveWindow"></event>
+ <event name="OnLeftDClick"></event>
+ <event name="OnLeftDown"></event>
+ <event name="OnLeftUp"></event>
+ <event name="OnMiddleDClick"></event>
+ <event name="OnMiddleDown"></event>
+ <event name="OnMiddleUp"></event>
+ <event name="OnMotion"></event>
+ <event name="OnMouseEvents"></event>
+ <event name="OnMouseWheel"></event>
+ <event name="OnPaint"></event>
+ <event name="OnRightDClick"></event>
+ <event name="OnRightDown"></event>
+ <event name="OnRightUp"></event>
+ <event name="OnSetFocus"></event>
+ <event name="OnSize"></event>
+ <event name="OnUpdateUI"></event>
+ </object>
+ </object>
+ <object class="sizeritem" expanded="1">
+ <property name="border">0</property>
+ <property name="flag">wxEXPAND</property>
+ <property name="proportion">1</property>
+ <object class="wxToolBar" expanded="1">
+ <property name="bg"></property>
+ <property name="bitmapsize"></property>
+ <property name="context_help"></property>
+ <property name="enabled">1</property>
+ <property name="fg"></property>
+ <property name="font"></property>
+ <property name="hidden">0</property>
+ <property name="id">wxID_ANY</property>
+ <property name="margins"></property>
+ <property name="maximum_size"></property>
+ <property name="minimum_size"></property>
+ <property name="name">tools_</property>
+ <property name="packing">1</property>
+ <property name="permission">protected</property>
+ <property name="pos"></property>
+ <property name="separation">5</property>
+ <property name="size"></property>
+ <property name="style">wxTB_HORIZONTAL|wxTB_NOICONS|wxTB_TEXT</property>
+ <property name="subclass"></property>
+ <property name="tooltip"></property>
+ <property name="window_extra_style"></property>
+ <property name="window_name"></property>
+ <property name="window_style"></property>
+ <event name="OnChar"></event>
+ <event name="OnEnterWindow"></event>
+ <event name="OnEraseBackground"></event>
+ <event name="OnKeyDown"></event>
+ <event name="OnKeyUp"></event>
+ <event name="OnKillFocus"></event>
+ <event name="OnLeaveWindow"></event>
+ <event name="OnLeftDClick"></event>
+ <event name="OnLeftDown"></event>
+ <event name="OnLeftUp"></event>
+ <event name="OnMiddleDClick"></event>
+ <event name="OnMiddleDown"></event>
+ <event name="OnMiddleUp"></event>
+ <event name="OnMotion"></event>
+ <event name="OnMouseEvents"></event>
+ <event name="OnMouseWheel"></event>
+ <event name="OnPaint"></event>
+ <event name="OnRightDClick"></event>
+ <event name="OnRightDown"></event>
+ <event name="OnRightUp"></event>
+ <event name="OnSetFocus"></event>
+ <event name="OnSize"></event>
+ <event name="OnUpdateUI"></event>
+ </object>
+ </object>
</object>
</object>
</object>
Modified: pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/generated/visualization_panel_generated.cpp
===================================================================
--- pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/generated/visualization_panel_generated.cpp 2008-11-04 00:06:37 UTC (rev 6181)
+++ pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/generated/visualization_panel_generated.cpp 2008-11-04 00:12:37 UTC (rev 6182)
@@ -64,11 +64,23 @@
render_panel_ = new wxPanel( main_splitter_, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
render_sizer_ = new wxBoxSizer( wxVERTICAL );
- views_ = new wxToolBar( render_panel_, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL|wxTB_NOICONS|wxTB_TEXT );
- views_->Realize();
+ wxBoxSizer* bSizer9;
+ bSizer9 = new wxBoxSizer( wxHORIZONTAL );
- render_sizer_->Add( views_, 0, wxEXPAND, 0 );
+ wxArrayString views_Choices;
+ views_ = new wxChoice( render_panel_, wxID_ANY, wxDefaultPosition, wxDefaultSize, views_Choices, 0 );
+ views_->SetSelection( 0 );
+ views_->SetMinSize( wxSize( 150,-1 ) );
+ bSizer9->Add( views_, 0, wxALL, 5 );
+
+ tools_ = new wxToolBar( render_panel_, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL|wxTB_NOICONS|wxTB_TEXT );
+ tools_->Realize();
+
+ bSizer9->Add( tools_, 1, wxEXPAND, 0 );
+
+ render_sizer_->Add( bSizer9, 0, wxEXPAND, 5 );
+
render_panel_->SetSizer( render_sizer_ );
render_panel_->Layout();
render_sizer_->Fit( render_panel_ );
@@ -81,6 +93,7 @@
// Connect Events
new_display_->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( VisualizationPanelGenerated::onNewDisplay ), NULL, this );
delete_display_->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( VisualizationPanelGenerated::onDeleteDisplay ), NULL, this );
+ views_->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( VisualizationPanelGenerated::onViewSelected ), NULL, this );
}
VisualizationPanelGenerated::~VisualizationPanelGenerated()
@@ -88,6 +101,7 @@
// Disconnect Events
new_display_->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( VisualizationPanelGenerated::onNewDisplay ), NULL, this );
delete_display_->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( VisualizationPanelGenerated::onDeleteDisplay ), NULL, this );
+ views_->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( VisualizationPanelGenerated::onViewSelected ), NULL, this );
}
NewDisplayDialogGenerated::NewDisplayDialogGenerated( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
Modified: pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/generated/visualization_panel_generated.h
===================================================================
--- pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/generated/visualization_panel_generated.h 2008-11-04 00:06:37 UTC (rev 6181)
+++ pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/generated/visualization_panel_generated.h 2008-11-04 00:12:37 UTC (rev 6182)
@@ -16,6 +16,7 @@
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/button.h>
+#include <wx/choice.h>
#include <wx/toolbar.h>
#include <wx/splitter.h>
#include <wx/listbox.h>
@@ -43,11 +44,13 @@
wxButton* delete_display_;
wxPanel* render_panel_;
wxBoxSizer* render_sizer_;
- wxToolBar* views_;
+ wxChoice* views_;
+ wxToolBar* tools_;
// Virtual event handlers, overide them in your derived class
virtual void onNewDisplay( wxCommandEvent& event ){ event.Skip(); }
virtual void onDeleteDisplay( wxCommandEvent& event ){ event.Skip(); }
+ virtual void onViewSelected( wxCommandEvent& event ){ event.Skip(); }
public:
Added: pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/move_tool.cpp
===================================================================
--- pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/move_tool.cpp (rev 0)
+++ pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/move_tool.cpp 2008-11-04 00:12:37 UTC (rev 6182)
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2008, Willow Garage, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Willow Garage, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "move_tool.h"
+#include "visualization_manager.h"
+#include "visualization_panel.h"
+#include "ogre_tools/camera_base.h"
+
+#include <wx/wx.h>
+
+namespace ogre_vis
+{
+
+MoveTool::MoveTool( const std::string& name, VisualizationManager* manager )
+: Tool( name, manager )
+{
+
+}
+
+int MoveTool::processMouseEvent( wxMouseEvent& event, int last_x, int last_y )
+{
+ int flags = 0;
+
+ ogre_tools::CameraBase* camera = manager_->getVisualizationPanel()->getCurrentCamera();
+
+ if ( event.LeftDown() )
+ {
+ if ( event.ControlDown() )
+ {
+ manager_->pick( event.GetX(), event.GetY() );
+ }
+ else
+ {
+ camera->mouseLeftDown( event.GetX(), event.GetY() );
+ }
+
+ flags |= Render;
+ }
+ else if ( event.MiddleDown() )
+ {
+ camera->mouseMiddleDown( event.GetX(), event.GetY() );
+ flags |= Render;
+ }
+ else if ( event.RightDown() )
+ {
+ camera->mouseRightDown( event.GetX(), event.GetY() );
+ flags |= Render;
+ }
+ else if ( event.LeftUp() )
+ {
+ camera->mouseLeftUp( event.GetX(), event.GetY() );
+ flags |= Render;
+ }
+ else if ( event.MiddleUp() )
+ {
+ camera->mouseMiddleUp( event.GetX(), event.GetY() );
+ flags |= Render;
+ }
+ else if ( event.RightUp() )
+ {
+ camera->mouseRightUp( event.GetX(), event.GetY() );
+ flags |= Render;
+ }
+ else if ( event.Dragging() )
+ {
+ int32_t diff_x = event.GetX() - last_x;
+ int32_t diff_y = event.GetY() - last_y;
+
+ if ( event.LeftIsDown() )
+ {
+ camera->mouseLeftDrag( diff_x, diff_y );
+
+ flags |= Render;
+ }
+ else if ( event.MiddleIsDown() )
+ {
+ camera->mouseMiddleDrag( diff_x, diff_y );
+
+ flags |= Render;
+ }
+ else if ( event.RightIsDown() )
+ {
+ camera->mouseRightDrag( diff_x, diff_y );
+
+ flags |= Render;
+ }
+ }
+
+ if ( event.GetWheelRotation() != 0 )
+ {
+ camera->scrollWheel( event.GetWheelRotation() );
+
+ flags |= Render;
+ }
+
+ return flags;
+}
+
+}
+
Added: pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/move_tool.h
===================================================================
--- pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/move_tool.h (rev 0)
+++ pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/move_tool.h 2008-11-04 00:12:37 UTC (rev 6182)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2008, Willow Garage, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Willow Garage, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef OGRE_VISUALIZER_MOVE_TOOL_H
+#define OGRE_VISUALIZER_MOVE_TOOL_H
+
+#include "tool.h"
+
+namespace ogre_vis
+{
+
+class VisualizationManager;
+
+class MoveTool : public Tool
+{
+public:
+ MoveTool( const std::string& name, VisualizationManager* manager );
+
+ virtual void activate() {}
+ virtual void deactivate() {}
+
+ virtual int processMouseEvent( wxMouseEvent& event, int last_x, int last_y );
+};
+
+}
+
+#endif
+
Added: pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/pose_tool.cpp
===================================================================
--- pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/pose_tool.cpp (rev 0)
+++ pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/pose_tool.cpp 2008-11-04 00:12:37 UTC (rev 6182)
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2008, Willow Garage, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Willow Garage, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "pose_tool.h"
+#include "common.h"
+#include "visualization_manager.h"
+#include "visualization_panel.h"
+#include "ogre_tools/camera_base.h"
+#include "ogre_tools/arrow.h"
+#include "ogre_tools/wx_ogre_render_window.h"
+
+#include <std_msgs/Planner2DGoal.h>
+#include <std_msgs/Pose2DFloat32.h>
+
+#include <OgreRay.h>
+#include <OgrePlane.h>
+#include <OgreCamera.h>
+#include <OgreSceneNode.h>
+
+#include <ros/node.h>
+
+#include <wx/wx.h>
+
+namespace ogre_vis
+{
+
+PoseTool::PoseTool( const std::string& name, VisualizationManager* manager )
+: Tool( name, manager )
+, is_goal_( false )
+{
+ arrow_ = new ogre_tools::Arrow( scene_manager_, NULL, 2.0f, 0.2f, 0.5f, 0.35f );
+ arrow_->setColor( 0.0f, 1.0f, 0.0f, 1.0f );
+ arrow_->getSceneNode()->setVisible( false );
+
+ ros_node_->advertise<std_msgs::Planner2DGoal>("goal", 1);
+ ros_node_->advertise<std_msgs::Pose2DFloat32>("initialpose", 1);
+}
+
+PoseTool::~PoseTool()
+{
+ ros_node_->unadvertise("goal");
+ ros_node_->unadvertise("initialpose");
+
+ delete arrow_;
+}
+
+void PoseTool::activate()
+{
+ state_ = Position;
+
+}
+
+void PoseTool::deactivate()
+{
+ arrow_->getSceneNode()->setVisible( false );
+}
+
+void PoseTool::setIsGoal( bool is_goal )
+{
+ is_goal_ = is_goal;
+
+ arrow_->setColor( 0.0f, is_goal_ ? 1.0f : 0.0f, is_goal_ ? 0.0f : 1.0f, 1.0f );
+}
+
+Ogre::Vector3 PoseTool::getPositionFromMouseXY( int mouse_x, int mouse_y )
+{
+ int width, height;
+ manager_->getVisualizationPanel()->getRenderPanel()->GetSize( &width, &height );
+ Ogre::Ray mouse_ray = manager_->getVisualizationPanel()->getCurrentCamera()->getOgreCamera()->getCameraToViewportRay( (float)mouse_x / (float)width, (float)mouse_y / (float)height );
+ Ogre::Plane ground_plane( Ogre::Vector3::UNIT_Y, 0.0f );
+ std::pair<bool, Ogre::Real> intersection = mouse_ray.intersects( ground_plane );
+ if ( !intersection.first )
+ {
+ return Ogre::Vector3::ZERO;
+ }
+
+ return mouse_ray.getPoint( intersection.second );
+}
+
+int PoseTool::processMouseEvent( wxMouseEvent& event, int last_x, int last_y )
+{
+ int flags = 0;
+
+ if ( event.LeftDown() )
+ {
+ ROS_ASSERT( state_ == Position );
+
+ pos_ = getPositionFromMouseXY( event.GetX(), event.GetY() );
+ arrow_->setPosition( pos_ );
+
+ state_ = Orientation;
+ flags |= Render;
+ }
+ else if ( event.Dragging() )
+ {
+ if ( state_ == Orientation )
+ {
+ Ogre::Vector3 cur_pos = getPositionFromMouseXY( event.GetX(), event.GetY() );
+ double angle = atan2(pos_.z - cur_pos.z, cur_pos.x - pos_.x);
+
+ arrow_->getSceneNode()->setVisible( true );
+
+ Ogre::Quaternion base_orient = Ogre::Quaternion( Ogre::Radian(Ogre::Math::HALF_PI), Ogre::Vector3::NEGATIVE_UNIT_Z );
+ arrow_->setOrientation( Ogre::Quaternion( Ogre::Radian(angle - Ogre::Math::HALF_PI), Ogre::Vector3::UNIT_Y ) * base_orient );
+
+ flags |= Render;
+ }
+ }
+ else if ( event.LeftUp() )
+ {
+ if ( state_ == Orientation )
+ {
+ Ogre::Vector3 cur_pos = getPositionFromMouseXY( event.GetX(), event.GetY() );
+ double angle = atan2(pos_.z - cur_pos.z, cur_pos.x - pos_.x) - Ogre::Math::HALF_PI;
+
+ Ogre::Vector3 robot_pos = pos_;
+ ogreToRobot( robot_pos );
+
+ if ( is_goal_ )
+ {
+ std_msgs::Planner2DGoal goal;
+ goal.goal.x = robot_pos.x;
+ goal.goal.y = robot_pos.y;
+ goal.goal.th = angle;
+ goal.enable = 1;
+ goal.header.frame_id = "map";
+ ROS_INFO("setting goal: %.3f %.3f %.3f\n", goal.goal.x, goal.goal.y, goal.goal.th);
+ ros_node_->publish( "goal", goal );
+ }
+ else
+ {
+ std_msgs::Pose2DFloat32 pose;
+ pose.x = robot_pos.x;
+ pose.y = robot_pos.y;
+ pose.th = angle;
+ ROS_INFO( "setting pose: %.3f %.3f %.3f\n", pose.x, pose.y, pose.th );
+ ros_node_->publish( "initialpose", pose );
+ }
+
+ flags |= Finished;
+ }
+ }
+
+ return flags;
+}
+
+}
+
Added: pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/pose_tool.h
===================================================================
--- pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/pose_tool.h (rev 0)
+++ pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/pose_tool.h 2008-11-04 00:12:37 UTC (rev 6182)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2008, Willow Garage, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Willow Garage, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef OGRE_VISUALIZER_POSE_TOOL_H
+#define OGRE_VISUALIZER_POSE_TOOL_H
+
+#include "tool.h"
+
+#include <OgreVector3.h>
+
+namespace ogre_tools
+{
+class Arrow;
+}
+
+namespace ogre_vis
+{
+
+class VisualizationManager;
+
+class PoseTool : public Tool
+{
+public:
+ PoseTool( const std::string& name, VisualizationManager* manager );
+ virtual ~PoseTool();
+
+ void setIsGoal( bool is_goal );
+
+ virtual void activate();
+ virtual void deactivate();
+
+ virtual int processMouseEvent( wxMouseEvent& event, int last_x, int last_y );
+
+protected:
+ Ogre::Vector3 getPositionFromMouseXY( int mouse_x, int mouse_y );
+
+ ogre_tools::Arrow* arrow_;
+
+ enum State
+ {
+ Position,
+ Orientation
+ };
+ State state_;
+
+ Ogre::Vector3 pos_;
+
+ bool is_goal_;
+};
+
+}
+
+#endif
+
+
Added: pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/tool.cpp
===================================================================
--- pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/tool.cpp (rev 0)
+++ pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/tool.cpp 2008-11-04 00:12:37 UTC (rev 6182)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2008, Willow Garage, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Willow Garage, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tool.h"
+#include "visualization_manager.h"
+
+namespace ogre_vis
+{
+
+Tool::Tool( const std::string& name, VisualizationManager* manager )
+: scene_manager_( manager->getSceneManager() )
+, ros_node_( manager->getROSNode() )
+, manager_( manager )
+, name_( name )
+{
+
+}
+
+}
Added: pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/tool.h
===================================================================
--- pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/tool.h (rev 0)
+++ pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/tools/tool.h 2008-11-04 00:12:37 UTC (rev 6182)
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2008, Willow Garage, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Willow Garage, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef OGRE_VISUALIZER_TOOL_H
+#define OGRE_VISUALIZER_TOOL_H
+
+#include <string>
+
+class wxMouseEvent;
+
+namespace Ogre
+{
+class SceneManager;
+}
+
+namespace ros
+{
+class node;
+}
+
+namespace ogre_vis
+{
+
+class VisualizationManager;
+
+class Tool
+{
+public:
+ Tool( const std::string& name, VisualizationManager* manager );
+ virtual ~Tool() {}
+
+ const std::string& getName() { return name_; }
+
+ virtual void activate() = 0;
+ virtual void deactivate() = 0;
+
+ enum Flags
+ {
+ Render = 1 << 0,
+ Finished = 1 << 1
+ };
+ virtual int processMouseEvent( wxMouseEvent& event, int last_x, int last_y ) = 0;
+protected:
+ Ogre::SceneManager* scene_manager_;
+ ros::node* ros_node_;
+ VisualizationManager* manager_;
+
+ std::string name_;
+};
+
+}
+
+#endif
Modified: pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualization_manager.cpp
===================================================================
--- pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualization_manager.cpp 2008-11-04 00:06:37 UTC (rev 6181)
+++ pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualization_manager.cpp 2008-11-04 00:12:37 UTC (rev 6182)
@@ -37,6 +37,10 @@
#include "factory.h"
#include "new_display_dialog.h"
+#include "tools/tool.h"
+#include "tools/move_tool.h"
+#include "tools/pose_tool.h"
+
#include <ogre_tools/wx_ogre_render_window.h>
#include <ogre_tools/camera_base.h>
@@ -62,6 +66,7 @@
VisualizationManager::VisualizationManager( VisualizationPanel* panel )
: ogre_root_( Ogre::Root::getSingletonPtr() )
+, current_tool_( NULL )
, vis_panel_( panel )
, needs_reset_( false )
{
@@ -142,6 +147,14 @@
}
factories_.clear();
+ V_Tool::iterator tool_it = tools_.begin();
+ V_Tool::iterator tool_end = tools_.end();
+ for ( ; tool_it != tool_end; ++tool_it )
+ {
+ delete *tool_it;
+ }
+ tools_.clear();
+
delete tf_;
delete property_manager_;
@@ -152,6 +165,18 @@
ogre_root_->destroySceneManager( scene_manager_ );
}
+void VisualizationManager::initialize()
+{
+ MoveTool* move_tool = createTool< MoveTool >( "Move Camera" );
+ setCurrentTool( move_tool );
+ setDefaultTool( move_tool );
+
+ PoseTool* goal_tool = createTool< PoseTool >( "Set Goal" );
+ goal_tool->setIsGoal( true );
+
+ createTool< PoseTool >( "Set Pose" );
+}
+
VisualizationManager::VisualizerInfo* VisualizationManager::getVisualizerInfo( const VisualizerBase* visualizer )
{
V_VisualizerInfo::iterator vis_it = visualizers_.begin();
@@ -247,6 +272,39 @@
}
}
+void VisualizationManager::addTool( Tool* tool )
+{
+ tools_.push_back( tool );
+
+ vis_panel_->addTool( tool );
+}
+
+void VisualizationManager::setCurrentTool( Tool* tool )
+{
+ if ( current_tool_ )
+ {
+ current_tool_->deactivate();
+ }
+
+ current_tool_ = tool;
+ current_tool_->activate();
+
+ vis_panel_->setTool( tool );
+}
+
+void VisualizationManager::setDefaultTool( Tool* tool )
+{
+ default_tool_ = tool;
+}
+
+Tool* VisualizationManager::getTool( int index )
+{
+ ROS_ASSERT( index >= 0 );
+ ROS_ASSERT( index < (int)tools_.size() );
+
+ return tools_[ index ];
+}
+
inline void createParticle( Ogre::ParticleSystem* particle_sys, const Ogre::Vector3& position, float size )
{
Ogre::Particle* p = particle_sys->createParticle();
Modified: pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualization_manager.h
===================================================================
--- pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualization_manager.h 2008-11-04 00:06:37 UTC (rev 6181)
+++ pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualization_manager.h 2008-11-04 00:12:37 UTC (rev 6182)
@@ -85,6 +85,8 @@
class VisualizerBase;
class VisualizerFactory;
+class Tool;
+
typedef boost::signal<void (VisualizerBase*)> VisualizerSignal;
class VisualizationManager : public wxEvtHandler
@@ -99,6 +101,8 @@
VisualizationManager( VisualizationPanel* vis_panel );
virtual ~VisualizationManager();
+ void initialize();
+
/**
* \brief Create and then add a visualizer to this panel.
* @param name Display name of the visualizer
@@ -140,6 +144,22 @@
*/
void removeVisualizer( const std::string& name );
+ template< class T >
+ T* createTool( const std::string& name )
+ {
+ T* tool = new T( name, this );
+ addTool( tool );
+
+ return tool;
+ }
+
+ void addTool( Tool* tool );
+ Tool* getCurrentTool() { return current_tool_; }
+ Tool* getTool( int index );
+ void setCurrentTool( Tool* tool );
+ void setDefaultTool( Tool* tool );
+ Tool* getDefaultTool() { return default_tool_; }
+
/**
* \brief Load configuration
* @param config The wx config object to load from
@@ -203,6 +223,8 @@
Ogre::SceneNode* getTargetRelativeNode() { return target_relative_node_; }
+ VisualizationPanel* getVisualizationPanel() { return vis_panel_; }
+
void resetVisualizers();
protected:
@@ -251,6 +273,11 @@
typedef std::map<std::string, VisualizerFactory*> M_Factory;
M_Factory factories_; ///< Factories by visualizer type name
+ typedef std::vector< Tool* > V_Tool;
+ V_Tool tools_;
+ Tool* current_tool_;
+ Tool* default_tool_;
+
std::string target_frame_; ///< Target coordinate frame we're displaying everything in
std::string fixed_frame_; ///< Frame to transform fixed data to
Modified: pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualization_panel.cpp
===================================================================
--- pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualization_panel.cpp 2008-11-04 00:06:37 UTC (rev 6181)
+++ pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualization_panel.cpp 2008-11-04 00:12:37 UTC (rev 6182)
@@ -33,6 +33,7 @@
#include "new_display_dialog.h"
#include "properties/property.h"
#include "properties/property_manager.h"
+#include "tools/tool.h"
#include "ogre_tools/wx_ogre_render_window.h"
#include "ogre_tools/fps_camera.h"
@@ -50,16 +51,16 @@
namespace ogre_vis
{
-namespace IDs
+namespace Views
{
-enum ID
+enum View
{
- FPS = wxID_HIGHEST + 1,
Orbit,
+ FPS,
TopDownOrtho,
};
}
-typedef IDs::ID ID;
+typedef Views::View View;
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EVENT_TYPE(EVT_RENDER, wxID_ANY)
@@ -69,9 +70,6 @@
VisualizationPanel::VisualizationPanel( wxWindow* parent )
: VisualizationPanelGenerated( parent )
-, left_mouse_down_( false )
-, middle_mouse_down_( false )
-, right_mouse_down_( false )
, mouse_x_( 0 )
, mouse_y_( 0 )
, selected_visualizer_( NULL )
@@ -79,12 +77,11 @@
render_panel_ = new ogre_tools::wxOgreRenderWindow( Ogre::Root::getSingletonPtr(), VisualizationPanelGenerated::render_panel_ );
render_sizer_->Add( render_panel_, 1, wxALL|wxEXPAND, 0 );
- views_->AddRadioTool( IDs::Orbit, wxT("Orbit"), wxNullBitmap, wxNullBitmap, wxT("Orbit Camera Controls") );
- views_->AddRadioTool( IDs::FPS, wxT("FPS"), wxNullBitmap, wxNullBitmap, wxT("FPS Camera Controls") );
- views_->AddRadioTool( IDs::TopDownOrtho, wxT("Top-down Ortho"), wxNullBitmap, wxNullBitmap, wxT("Top-down Orthographic Camera") );
+ views_->Append( wxT( "Orbit" ) );
+ views_->Append( wxT( "FPS" ) );
+ views_->Append( wxT( "Top-down Orthographic" ) );
+ views_->SetSelection( 0 );
- views_->Connect( wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( VisualizationPanel::onViewClicked ), NULL, this );
-
render_panel_->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( VisualizationPanel::onRenderWindowMouseEvents ), NULL, this );
render_panel_->Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( VisualizationPanel::onRenderWindowMouseEvents ), NULL, this );
render_panel_->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( VisualizationPanel::onRenderWindowMouseEvents ), NULL, this );
@@ -115,6 +112,7 @@
delete_display_->Enable( false );
manager_ = new VisualizationManager( this );
+ manager_->initialize();
manager_->getVisualizerStateSignal().connect( boost::bind( &VisualizationPanel::onVisualizerStateChanged, this, _1 ) );
fps_camera_ = new ogre_tools::FPSCamera( manager_->getSceneManager() );
@@ -132,22 +130,23 @@
top_down_ortho_->pitch( -Ogre::Math::HALF_PI );
top_down_ortho_->setRelativeNode( manager_->getTargetRelativeNode() );
-
current_camera_ = orbit_camera_;
render_panel_->getViewport()->setCamera( current_camera_->getOgreCamera() );
+
+ tools_->Connect( wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( VisualizationPanel::onToolClicked ), NULL, this );
}
VisualizationPanel::~VisualizationPanel()
{
+ tools_->Disconnect( wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( VisualizationPanel::onToolClicked ), NULL, this );
+
delete fps_camera_;
delete orbit_camera_;
delete top_down_ortho_;
delete manager_;
- views_->Disconnect( wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( VisualizationPanel::onViewClicked ), NULL, this );
-
render_panel_->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( VisualizationPanel::onRenderWindowMouseEvents ), NULL, this );
render_panel_->Disconnect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( VisualizationPanel::onRenderWindowMouseEvents ), NULL, this );
render_panel_->Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( VisualizationPanel::onRenderWindowMouseEvents ), NULL, this );
@@ -168,6 +167,24 @@
render_panel_->Destroy();
}
+void VisualizationPanel::addTool( Tool* tool )
+{
+ tools_->AddRadioTool( tools_->GetToolsCount(), wxString::FromAscii( tool->getName().c_str() ), wxNullBitmap, wxNullBitmap );
+}
+
+void VisualizationPanel::setTool( Tool* tool )
+{
+ int count = tools_->GetToolsCount();
+ for ( int i = 0; i < count; ++i )
+ {
+ if ( manager_->getTool( i ) == tool )
+ {
+ tools_->ToggleTool( i, true );
+ break;
+ }
+ }
+}
+
void VisualizationPanel::queueRender()
{
wxCommandEvent event( EVT_RENDER, GetId() );
@@ -179,36 +196,45 @@
render_panel_->Refresh();
}
-void VisualizationPanel::onViewClicked( wxCommandEvent& event )
+void VisualizationPanel::onToolClicked( wxCommandEvent& event )
{
+ Tool* tool = manager_->getTool( event.GetId() );
+
+ manager_->setCurrentTool( tool );
+}
+
+
+void VisualizationPanel::onViewSelected( wxCommandEvent& event )
+{
ogre_tools::CameraBase* prev_camera = current_camera_;
bool set_from_old = false;
- switch ( event.GetId() )
+ switch ( views_->GetSelection() )
{
- case IDs::FPS:
+ case Views::FPS:
{
- current_camera_ = fps_camera_;
-
if ( current_camera_ == orbit_camera_ )
{
set_from_old = true;
}
+
+ current_camera_ = fps_camera_;
}
break;
- case IDs::Orbit:
+ case Views::Orbit:
{
- current_camera_ = orbit_camera_;
if ( current_camera_ == fps_camera_ )
{
set_from_old = true;
}
+
+ current_camera_ = orbit_camera_;
}
break;
- case IDs::TopDownOrtho:
+ case Views::TopDownOrtho:
{
current_camera_ = top_down_ortho_;
}
@@ -291,92 +317,17 @@
mouse_x_ = event.GetX();
mouse_y_ = event.GetY();
- if ( event.LeftDown() )
- {
- if ( event.ControlDown() )
- {
- manager_->pick( mouse_x_, mouse_y_ );
- }
- else
- {
- left_mouse_down_ = true;
- middle_mouse_down_ = false;
- right_mouse_down_ = false;
+ int flags = manager_->getCurrentTool()->processMouseEvent( event, last_x, last_y );
- current_camera_->mouseLeftDown( mouse_x_, mouse_y_ );
- }
- }
- else if ( event.MiddleDown() )
+ if ( flags & Tool::Render )
{
- left_mouse_down_ = false;
- middle_mouse_down_ = true;
- right_mouse_down_ = false;
-
- current_camera_->mouseMiddleDown( mouse_x_, mouse_y_ );
+ queueRender();
}
- else if ( event.RightDown() )
- {
- left_mouse_down_ = false;
- middle_mouse_down_ = false;
- right_mouse_down_ = true;
- current_camera_->mouseRightDown( mouse_x_, mouse_y_ );
- }
- else if ( event.LeftUp() )
+ if ( flags & Tool::Finished )
{
- left_mouse_down_ = false;
-
- current_camera_->mouseLeftUp( mouse_x_, mouse_y_ );
+ manager_->setCurrentTool( manager_->getDefaultTool() );
}
- else if ( event.MiddleUp() )
- {
- middle_mouse_down_ = false;
-
- current_camera_->mouseMiddleUp( mouse_x_, mouse_y_ );
- }
- else if ( event.RightUp() )
- {
- right_mouse_down_ = false;
-
- current_camera_->mouseRightUp( mouse_x_, mouse_y_ );
- }
- else if ( event.Dragging() )
- {
- int32_t diff_x = mouse_x_ - last_x;
- int32_t diff_y = mouse_y_ - last_y;
-
- bool handled = false;
- if ( left_mouse_down_ )
- {
- current_camera_->mouseLeftDrag( diff_x, diff_y );
-
- handled = true;
- }
- else if ( middle_mouse_down_ )
- {
- current_camera_->mouseMiddleDrag( diff_x, diff_y );
-
- handled = true;
- }
- else if ( right_mouse_down_ )
- {
- current_camera_->mouseRightDrag( diff_x, diff_y );
-
- handled = true;
- }
-
- if ( handled )
- {
- queueRender();
- }
- }
-
- if ( event.GetWheelRotation() != 0 )
- {
- current_camera_->scrollWheel( event.GetWheelRotation() );
-
- queueRender();
- }
}
void VisualizationPanel::onNewDisplay( wxCommandEvent& event )
Modified: pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualization_panel.h
===================================================================
--- pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualization_panel.h 2008-11-04 00:06:37 UTC (rev 6181)
+++ pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualization_panel.h 2008-11-04 00:12:37 UTC (rev 6182)
@@ -100,6 +100,7 @@
class VisualizerBase;
class VisualizationManager;
+class Tool;
/**
* \class VisualizationPanel
@@ -138,6 +139,9 @@
VisualizationManager* getManager() { return manager_; }
ogre_tools::CameraBase* getCurrentCamera() { return current_camera_; }
+ void addTool( Tool* tool );
+ void setTool( Tool* tool );
+
/**
* \brief Load configuration. Simply passes through to the VisualizationManager, here for convenience
* @param config The wx config object to load from
@@ -150,8 +154,6 @@
void saveConfig( wxConfigBase* config );
protected:
- /// Called when a "view" (camera) is selected from the list
- void onViewClicked( wxCommandEvent& event );
/// Called when a mouse event happens inside the render window
void onRenderWindowMouseEvents( wxMouseEvent& event );
/// Called when our custom EVT_RENDER is fired
@@ -162,7 +164,11 @@
void onPropertyChanged( wxPropertyGridEvent& event );
/// Called when a property is selected
void onPropertySelected( wxPropertyGridEvent& event );
+ /// Called when a tool is selected
+ void onToolClicked( wxCommandEvent& event );
+ /// Called when a "view" (camera) is selected from the list
+ void onViewSelected( wxCommandEvent& event );
/// Called when the "New Display" button is pressed
virtual void onNewDisplay( wxCommandEvent& event );
/// Called when the "Delete Display" button is pressed
@@ -180,9 +186,6 @@
ogre_tools::OrthoCamera* top_down_ortho_; ///< Top-down orthographic camera
// Mouse handling
- bool left_mouse_down_; ///< Is the left mouse button down?
- bool middle_mouse_down_; ///< Is the middle mouse button down?
- bool right_mouse_down_; ///< Is the right mouse button down?
int mouse_x_; ///< X position of the last mouse event
int mouse_y_; ///< Y position of the last mouse event
Modified: pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualizers/map_visualizer.cpp
===================================================================
--- pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualizers/map_visualizer.cpp 2008-11-04 00:06:37 UTC (rev 6181)
+++ pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualizers/map_visualizer.cpp 2008-11-04 00:12:37 UTC (rev 6182)
@@ -59,6 +59,8 @@
, width_( 0.0f )
, height_( 0.0f )
, load_timer_( 2.0f )
+, new_metadata_( false )
+, last_loaded_map_time_( 0 )
, service_property_( NULL )
, resolution_property_( NULL )
, width_property_( NULL )
@@ -85,15 +87,34 @@
void MapVisualizer::onEnable()
{
+ subscribe();
+
scene_node_->setVisible( true );
}
void MapVisualizer::onDisable()
{
+ unsubscribe();
+
scene_node_->setVisible( false );
clear();
}
+void MapVisualizer::subscribe()
+{
+ if ( !isEnabled() )
+ {
+ return;
+ }
+
+ ros_node_->subscribe( "map_metadata", metadata_message_, &MapVisualizer::incomingMetaData, this, 1 );
+}
+
+void MapVisualizer::unsubscribe()
+{
+ ros_node_->unsubscribe( "map_metadata", &MapVisualizer::incomingMetaData, this );
+}
+
void MapVisualizer::setAlpha( float alpha )
{
alpha_ = alpha;
@@ -201,7 +222,7 @@
pixels[pidx+0] = val;
pixels[pidx+1] = val;
pixels[pidx+2] = val;
- //pixels[pidx+3] = 1.0f;
+ //pixels[pidx+3] = 1.0f;stamp
}
}
@@ -324,6 +345,17 @@
void MapVisualizer::update( float dt )
{
+ if ( new_metadata_ )
+ {
+ /// @todo implement ros::Time::operator!=
+ if ( !(metadata_message_.map_load_time == last_loaded_map_time_) )
+ {
+ last_loaded_map_time_ = metadata_message_.map_load_time;
+
+ clear();
+ }
+ }
+
if ( !loaded_ )
{
load_timer_ += dt;
@@ -362,4 +394,9 @@
clear();
}
+void MapVisualizer::incomingMetaData()
+{
+ new_metadata_ = true;
+}
+
} // namespace ogre_vis
Modified: pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualizers/map_visualizer.h
===================================================================
--- pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualizers/map_visualizer.h 2008-11-04 00:06:37 UTC (rev 6181)
+++ pkg/trunk/visualization/ogre_visualizer/src/ogre_visualizer/visualizers/map_visualizer.h 2008-11-04 00:12:37 UTC (rev 6182)
@@ -35,6 +35,9 @@
#include <OgreTexture.h>
#include <OgreMaterial.h>
+#include <std_msgs/MapMetaData.h>
+#include <ros/time.h>
+
namespace Ogre
{
class SceneNode;
@@ -8...
[truncated message content] |