area.h
Go to the documentation of this file.
00001 /*------------------------------------------------------------------------
00002  *---------------------           WMPSNIFFER          --------------------
00003  *------------------------------------------------------------------------
00004  *                                                         V7.0B  11/05/10
00005  *
00006  *
00007  *  File: area.h
00008  *  Authors: Danilo Tardioli
00009  *  ----------------------------------------------------------------------
00010  *  Copyright (C) 2000-2012, Universidad de Zaragoza, SPAIN
00011  *
00012  *  Contact Addresses: Danilo Tardioli                   dantard@unizar.es
00013  *
00014  *  RT-WMP is free software; you can  redistribute it and/or  modify it
00015  *  under the terms of the GNU General Public License  as published by the
00016  *  Free Software Foundation;  either  version 2, or (at  your option) any
00017  *  later version.
00018  *
00019  *  RT-WMP  is distributed  in the  hope  that  it will be   useful, but
00020  *  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
00021  *  MERCHANTABILITY  or  FITNESS FOR A  PARTICULAR PURPOSE.    See the GNU
00022  *  General Public License for more details.
00023  *
00024  *  You should have received  a  copy of  the  GNU General Public  License
00025  *  distributed with RT-WMP;  see file COPYING.   If not,  write to the
00026  *  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
00027  *  02111-1307, USA.
00028  *
00029  *  As a  special exception, if you  link this  unit  with other  files to
00030  *  produce an   executable,   this unit  does  not  by  itself cause  the
00031  *  resulting executable to be covered by the  GNU General Public License.
00032  *  This exception does  not however invalidate  any other reasons why the
00033  *  executable file might be covered by the GNU Public License.
00034  *
00035  *----------------------------------------------------------------------*/
00036 #ifndef _AREA_HH
00037 #define _AREA_HH
00038 #include <gtkmm/drawingarea.h>
00039 #include <semaphore.h>
00040 #include <string>
00041 
00042 #define LINK_SETS 5
00043 
00044 struct Link{
00045         int r1,r2;
00046         int col;
00047         int arrow;
00048         float value;
00049         bool has_value;
00050 };
00051 
00052 struct Robot{
00053         double x,y,a;
00054         int col;
00055         int has_mouse_over;
00056         int x_draw;
00057         int y_draw;
00058         std::string name;
00059 };
00060 
00061 struct Goal{
00062         float x,y,a;
00063         int r1;
00064         int col;
00065         int arrow;
00066         int x_draw;
00067         int y_draw;
00068 };
00069 
00070 struct Img{
00071         std::string filename, text;
00072         int scale_type;
00073         float x,y,scale;
00074         double sizex, sizey;
00075         int x_draw;
00076         int y_draw;
00077         Glib::RefPtr<Gdk::Pixbuf> pixbuf;
00078 };
00079 
00080 struct Point{
00081         double x,y;
00082         double cell_size;
00083         int robot;
00084         int col;
00085         int x_draw;
00086         int y_draw;
00087 };
00088 
00089 
00090 class area : public Gtk::DrawingArea{
00091 public:
00092                 area();
00093                 int get_selected();
00094                 int addRobot();
00095                 int addRobot(std::string name);
00096                 int getRobotPose(int id, double* x0, double* y0, double* ang);
00097         int getNumOfRobots();
00098         int getRobotId(std::string name);
00099         void setRobotColor(int idx, int c);
00100                 void setRobotPose(int id, double x0, double y0, double ang, int col);
00101                 void addLink(int r1, int r2, int arrow, int color, float value, int set=0);
00102                 void addLink(int r1, int r2, int arrow, int color, int set=0);
00103                 void addPoint(double x, double y, int color, int with_respect_to_robot=-1);
00104                 void addGridPoint(double x, double y, double cell_size, int color, int with_respect_to_robot=-1);
00105                 void addPoint(double y, int color);
00106                 void addLine(double x1, double y1, double x2, double y2,int color, bool permanent=false);
00107                 void addGoal(int r1, double x2, double y2, int color,int arrow);
00108                 int addImage(std::string s, double x, double y, double scale=1.0);
00109                 int addImage(std::string s, double x, double y, double scale, std::string s1);
00110                 int addImage(std::string s, double x, double y, double sizex, double sizey, std::string s1);
00111                 void setBackGroundImage(std::string s);
00112                 void clearLinks(int set=0);
00113                 void clearRobots();
00114                 void clearPoints();
00115                 void clearGoals();
00116                 void setMaximumNumOfPoints(int n);
00117                 void setJoinPoints(bool n);
00118                 void setMargins(double maxx,double maxy, double minx, double miny);
00119             void grabSnapshot();
00120             void setMaintainAspectRatio(bool val);
00121             void waitClick(double &x, double &y);
00122             void waitClickInterrupt();
00123 protected:
00124                 std::map<std::string,int> roboMap;
00125                 double xClick,yClick;
00126                 sem_t clickSem;
00127                 Glib::RefPtr<Gdk::Pixbuf> bg_image;
00128                 bool has_bg_image,interrupted;
00129                 bool maintain_aspect_ratio;
00130                 Pango::FontDescription *timesnr_12;
00131                 Pango::FontDescription *timesnr_8;
00132                 std::vector<Link> linkVec[LINK_SETS];
00133                 std::vector<Robot> roboVec;
00134                 std::vector<Goal> goalVec;
00135                 std::vector<Img> imgVec;
00136                 std::vector<Point> pointVec;
00137                 unsigned int snap_id;
00138                 pthread_mutex_t sem;
00139                 Gdk::Color cols[10];
00140             Glib::RefPtr<Gdk::Window> window;
00141             Glib::RefPtr<Gdk::GC> gc;
00142             double canvas_minx,canvas_miny,canvas_maxx,canvas_maxy;
00143             double max_x, max_y, min_x, min_y, scalex,scaley, zoom;
00144             int selected, painted, initialized,mouseover;
00145             unsigned maximumNumOfPoints;
00146             bool join_points,marginSetted;
00147             float fixed_scale;
00148             bool on_area_button_press_event(GdkEventButton *ev);
00149         bool on_area_button_release_event(GdkEventButton *ev);
00150         bool on_area_expose_event(GdkEventExpose *ev);
00151         virtual bool on_expose_event(GdkEventExpose* e);
00152         bool timer_callback();
00153         void draw_robot(double x, double y, double a,int col, int mouse_over, double scale);
00154         void draw_triangle(double x, double y, double a, int col, double scale);
00155         virtual void on_realize();
00156         void compute_environment();
00157         void paint();
00158         void on_size_alloc(Gtk::Allocation &al);
00159         virtual bool on_area_motion_notify_event(GdkEventMotion *ev);
00160 };
00161 
00162 #endif
00163 


ros_rt_wmp_sniffer
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Fri Jan 3 2014 12:08:32