INTRODUCTION
Overview
Download and Install
Quick Start
Documentation
Publications

NONFRAMEWORK CODE
Driver Interfaces
Drivers
Libraries
Utilities

FRAMEWORK CODE
Interfaces
Components
Libraries
Utilities

Full Software Listings

DEVELOPER
Tutorials
Examples
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

pathfollowerpainter.h

00001 /*
00002  * Orca-Robotics Project: Components for robotics 
00003  *               http://orca-robotics.sf.net/
00004  * Copyright (c) 2004-2009 Alex Brooks, Alexei Makarenko, Tobias Kaupp
00005  *
00006  * This copy of Orca is licensed to you under the terms described in
00007  * the LICENSE file included in this distribution.
00008  *
00009  */
00010 
00011 #ifndef PATHFOLLOWERPAINTER_H
00012 #define PATHFOLLOWERPAINTER_H
00013 
00014 #include <QColor>
00015 #include <hydroqguipath/pathutils.h>
00016 #include <hydroqguielementutil/definitions2d.h>
00017 #include <gbxsickacfr/gbxiceutilacfr/timer.h>
00018 
00019 // forward declarations
00020 class QPainter;
00021 
00022 namespace orcaqgui2d {
00023 
00024 class WpColors;
00025 
00026 struct PathFollowerPainterConfig
00027 {
00028     PathFollowerPainterConfig()
00029     {
00030         displayWaypoints=true;
00031         displayPastWaypoints=true;
00032         displayFutureWaypoints=true;
00033         displayPathWhenFinished=true;
00034         displayPathWhenNotActivated=true;
00035         displayOlympicMarker=true;
00036         useTransparency=true;
00037     }
00038 
00039     void turnAllWpOff()
00040     {
00041         displayWaypoints=false;
00042         displayPastWaypoints=false;
00043         displayFutureWaypoints=false;
00044         displayPathWhenFinished=false;
00045         displayPathWhenNotActivated=false;
00046     }
00047     
00048     void turnAllWpOn()
00049     {
00050         displayWaypoints=true;
00051         displayPastWaypoints=true;
00052         displayFutureWaypoints=true;
00053         displayPathWhenFinished=true;
00054         displayPathWhenNotActivated=true;
00055     }
00056     
00057     bool displayWaypoints;
00058     bool displayPastWaypoints;
00059     bool displayFutureWaypoints;
00060     bool displayPathWhenFinished;
00061     bool displayPathWhenNotActivated;
00062     
00063     bool displayOlympicMarker;
00064     bool useTransparency;
00065 };
00066     
00067 class PathFollowerPainter
00068 {
00069 
00070   public:
00071     PathFollowerPainter();
00072     
00073     void initialize( PathFollowerPainterConfig &config )
00074         { config_ = config; }
00075     
00076     void setData( const orca::PathFollower2dData& path );
00077     
00078     void setState( const orca::PathFollower2dState& state );
00079 
00080     void paint( QPainter *p, int z );
00081     
00082     bool paintThisLayer(int z) const 
00083         { return z==hydroqguielementutil::Z_PATH; }
00084 
00085     void clear()
00086         { guiPath_.resize(0); }
00087     
00088     void togglePastWaypoints()
00089         { config_.displayPastWaypoints = !config_.displayPastWaypoints; }
00090     
00091     void toggleFutureWaypoints()
00092         { config_.displayFutureWaypoints = !config_.displayFutureWaypoints; }
00093 
00094     void toggleDisplayPathWhenFinished()
00095         { config_.displayPathWhenFinished = !config_.displayPathWhenFinished; }
00096 
00097     void toggleDisplayPathWhenNotActivate()
00098         { config_.displayPathWhenNotActivated = !config_.displayPathWhenNotActivated; }
00099     
00100     void toggleDisplayWaypoints()
00101         {
00102             if (config_.displayWaypoints)
00103                 config_.turnAllWpOff();
00104             else
00105                 config_.turnAllWpOn();
00106         }
00107 
00108     void toggleOlympicMarker()
00109         { config_.displayOlympicMarker = !config_.displayOlympicMarker; }
00110 
00111     void setDisplayPastWaypoints( bool display )   
00112         { config_.displayPastWaypoints = display; }
00113 
00114     bool displayPastWaypoints()
00115         { return config_.displayPastWaypoints; }
00116     
00117     void setDisplayFutureWaypoints( bool display ) 
00118         { config_.displayFutureWaypoints = display; }
00119 
00120     bool displayFutureWaypoints()
00121         { return config_.displayFutureWaypoints; }
00122 
00123     void setDisplayPathWhenFinished( bool display )
00124         { config_.displayPathWhenFinished = display; }
00125         
00126     void setDisplayPathWhenNotActivated( bool display )
00127         { config_.displayPathWhenNotActivated = display; }
00128 
00129     bool displayPathWhenFinished()
00130         { return config_.displayPathWhenFinished; }
00131 
00132     bool displayPathWhenNotActivated()
00133         { return config_.displayPathWhenNotActivated; }
00134     
00135     void setDisplayWaypoints( bool display )       
00136         {
00137             if (display)
00138                 config_.turnAllWpOn();
00139             else
00140                 config_.turnAllWpOff();
00141         }
00142 
00143     bool displayWaypoints()
00144         { return config_.displayWaypoints; }
00145 
00146     bool displayOlympicMarker()
00147         { return config_.displayOlympicMarker; }
00148 
00149     void setUseTransparency( bool useTransparency )
00150         { config_.useTransparency = useTransparency; };
00151 
00152     bool useTransparency()
00153         { return config_.useTransparency; };
00154     
00155     void setColor( QColor color ) 
00156         { color_ = color; };
00157     
00158     void setFocus( bool inFocus ) 
00159         { inFocus_  = inFocus; };
00160     
00161     const hydroqguipath::GuiPath &currentPath() const 
00162         { return guiPath_; }; 
00163     
00164   private:
00165 
00166     void setRelativeStartTime( double relativeStartTime );
00167     
00168     hydroqguipath::GuiPath guiPath_;
00169 
00170     // The index of the waypoint we're currently pursuing
00171     int wpIndex_;
00172     orca::PathActivationEnum activationState_;
00173 
00174     PathFollowerPainterConfig config_;
00175     
00176     QColor color_;
00177     bool inFocus_;
00178     
00179     double relativeStartTime_;
00180     gbxiceutilacfr::Timer olympicMarkerTimer_;
00181 
00182     void drawOlympicMarker( QPainter *painter, float x, float y, double velocity );
00183     // returns true if marker is already at the goal, otherwise false
00184     bool olympicMarkerPosAndSpeed( float &x, float &y, double &velocity );
00185 
00186 };
00187 
00188 }
00189 
00190 #endif
 

Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)


Generated for Orca Robotics by  doxygen 1.4.5