field_view.h

00001
00002 /***************************************************************************
00003  *  field_view.h - Draws the field and the robots on it
00004  *
00005  *  Created: Wed April 09 20:58:20 2008
00006  *  Copyright  2008  Daniel Beck
00007  *
00008  ****************************************************************************/
00009
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022
00023 #ifndef __TOOL_WORLDINFO_VIEWER_FIELD_VIEW_H_
00024 #define __TOOL_WORLDINFO_VIEWER_FIELD_VIEW_H_
00025 
00026 #include <gtkmm/drawingarea.h>
00027 #include <geometry/hom_vector.h>
00028 #include <geometry/hom_point.h>
00029 #include <geometry/hom_pose.h>
00030 #include <map>
00031
00032 namespace fawkes {
00033   class WorldInfoDataContainer;
00034 }
00035
00036 class FieldView : public Gtk::DrawingArea
00037 {
00038  public:
00039   FieldView( fawkes::WorldInfoDataContainer* data,
00040              bool show_pose = true,
00041              bool show_ball = true,
00042              bool show_opponents = false );
00043   virtual ~FieldView();
00044
00045   bool toggle_show_pose( Glib::ustring name );
00046   bool toggle_show_ball( Glib::ustring name );
00047   bool toggle_show_opponents( Glib::ustring name );
00048
00049   void remove_host( Glib::ustring name );
00050
00051  protected:
00052   virtual bool on_expose_event(GdkEventExpose* event);
00053
00054  private:
00055   void draw_field_msl( Cairo::RefPtr<Cairo::Context> context );
00056   void draw_robot( Cairo::RefPtr<Cairo::Context> context,
00057                    float x, float y, float ori,
00058                    Glib::ustring name );
00059   void draw_obstacle( Cairo::RefPtr<Cairo::Context> context,
00060                       float x, float y, float extend );
00061   void draw_ball( Cairo::RefPtr<Cairo::Context> context,
00062                   float ball_x, float ball_y, float bot_x, float bot_y );
00063
00064   fawkes::WorldInfoDataContainer* m_data_container;
00065
00066   std::map< Glib::ustring, bool > m_show_pose;
00067   std::map< Glib::ustring, bool > m_show_ball;
00068   std::map< Glib::ustring, bool > m_show_opponents;
00069   bool m_show_pose_default;
00070   bool m_show_ball_default;
00071   bool m_show_opponents_default;
00072 };
00073
00074 #endif /* __TOOL_WORLDINFO_VIEWER_FIELD_VIEW_H_ */