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

 

         

simpleguielements.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 ORCAGUI_SIMPLE_GUI_ELEMENTS_H
00012 #define ORCAGUI_SIMPLE_GUI_ELEMENTS_H
00013 
00014 #include <orcaobj/bros1.h>
00015 
00016 #include <orcaqguielementutil/icestormguielement2d.h>
00017 #include <hydroqguielementutil/iknowsplatformposition2d.h>
00018 
00019 // Include various painter types
00020 #include <orcaqgui2dfactory/rangerarraypainter.h>
00021 #include <orcaqgui2dfactory/laserscanner2dpainter.h>
00022 #include <orcaqgui2dfactory/localise3dpainter.h>
00023 #include <orcaqgui2dfactory/odometry2dpainter.h>
00024 #include <orcaqgui2dfactory/particle2dpainter.h>
00025 #include <orcaqgui2dfactory/polarfeature2dpainter.h>
00026 #include <orcaqgui2dfactory/qgraphics2dpainter.h>
00027 #include <orcaqgui2dfactory/drivebicyclepainter.h>
00028 
00029 //
00030 // A list of simple gui elements that listen to one icestorm topic, for one object type.
00031 //
00032 
00033 namespace orcaqgui2d
00034 {
00035 
00037 class PolarFeature2dElement
00038     : public orcaqguielementutil::IceStormGuiElement2d<PolarFeature2dPainter,
00039                              orca::PolarFeature2dData,
00040                              orca::PolarFeature2dPrx,
00041                              orca::PolarFeature2dConsumer,
00042                              orca::PolarFeature2dConsumerPrx>
00043 {
00044 public:
00045     PolarFeature2dElement( const hydroqguielementutil::GuiElementInfo &guiElementInfo,
00046                            const orcaice::Context  &context,
00047                            int                      timeoutMs=30000 )
00048         : orcaqguielementutil::IceStormGuiElement2d<PolarFeature2dPainter,
00049                           orca::PolarFeature2dData,
00050                           orca::PolarFeature2dPrx,
00051                           orca::PolarFeature2dConsumer,
00052                           orca::PolarFeature2dConsumerPrx>( guiElementInfo, context, painter_, timeoutMs )
00053           {};
00054 
00055     virtual bool isInGlobalCS() { return false; }
00056     virtual void iceStormConnectedEvent() 
00057     { 
00058         getDescription();
00059     }
00060 
00061     virtual QStringList contextMenu() { return painter_.contextMenu(); }
00062     virtual void execute( int action ) { painter_.execute( action ); };
00063 
00064 private:
00065 
00066     void getDescription();
00067     PolarFeature2dPainter painter_;
00068 };
00069 
00071 class LaserScanner2dElement
00072     : public orcaqguielementutil::IceStormGuiElement2d<LaserScanner2dPainter,
00073                              orca::RangeScanner2dDataPtr,
00074                              orca::LaserScanner2dPrx,
00075                              orca::RangeScanner2dConsumer,
00076                              orca::RangeScanner2dConsumerPrx>
00077 {           
00078 public:
00079     LaserScanner2dElement( const hydroqguielementutil::GuiElementInfo &guiElementInfo,
00080                            const orcaice::Context  &context,
00081                            int                      timeoutMs=30000,
00082                            QColor                   outlineColor=QColor( 102,102,153, 255 ),
00083                            float                    outlineThickness=-1,
00084                            float                    brightReturnWidth=0.2 )
00085         : orcaqguielementutil::IceStormGuiElement2d<LaserScanner2dPainter,
00086                           orca::RangeScanner2dDataPtr,
00087                           orca::LaserScanner2dPrx,
00088                           orca::RangeScanner2dConsumer,
00089                           orca::RangeScanner2dConsumerPrx>(guiElementInfo, context, painter_, timeoutMs ),
00090           painter_( outlineColor, outlineThickness, brightReturnWidth )
00091         {};
00092 
00093     virtual bool isInGlobalCS() { return false; }
00094     virtual void iceStormConnectedEvent() { getLaserInfo(); }
00095     virtual QStringList contextMenu();
00096     virtual void execute( int action ) { painter_.execute( action ); };
00097     virtual void setColor( QColor color ) { painter_.setColor(color); }
00098     virtual void setFocus( bool inFocus ) { painter_.setFocus( inFocus ); };
00099 
00100 private:
00101     void getLaserInfo();
00102     LaserScanner2dPainter painter_;
00103     
00104 };
00105 
00107 class RangeScanner2dElement
00108     : public orcaqguielementutil::IceStormGuiElement2d<LaserScanner2dPainter,
00109                                 orca::RangeScanner2dDataPtr,
00110                                 orca::RangeScanner2dPrx,
00111                                 orca::RangeScanner2dConsumer,
00112                                 orca::RangeScanner2dConsumerPrx>
00113 {           
00114 public:
00115     RangeScanner2dElement( const hydroqguielementutil::GuiElementInfo &guiElementInfo,
00116                            const orcaice::Context  &context,
00117                            int                      timeoutMs=30000,
00118                            QColor                   outlineColor=QColor( 102,102,153, 255 ),
00119                            float                    outlineThickness=-1,
00120                            float                    brightReturnWidth=0.2 )
00121         : orcaqguielementutil::IceStormGuiElement2d<LaserScanner2dPainter,
00122                              orca::RangeScanner2dDataPtr,
00123                              orca::RangeScanner2dPrx,
00124                              orca::RangeScanner2dConsumer,
00125                              orca::RangeScanner2dConsumerPrx>(guiElementInfo, context, painter_, timeoutMs ),
00126           painter_( outlineColor, outlineThickness, brightReturnWidth )
00127         {};
00128 
00129     virtual bool isInGlobalCS() { return false; }
00130     virtual void iceStormConnectedEvent() { getScannerInfo(); }
00131     virtual QStringList contextMenu();
00132     virtual void execute( int action ) { painter_.execute( action ); };
00133     virtual void setColor( QColor color ) { painter_.setColor(color); }
00134     virtual void setFocus( bool inFocus ) { painter_.setFocus( inFocus ); };
00135 
00136 private:
00137     void getScannerInfo();
00138     LaserScanner2dPainter painter_;
00139     
00140 };
00141 
00142 
00144 class RangerArrayElement
00145     : public orcaqguielementutil::IceStormGuiElement2d<RangerArrayPainter,
00146                              orca::RangerArrayDataPtr,
00147                              orca::RangerArrayPrx,
00148                              orca::RangerArrayConsumer,
00149                              orca::RangerArrayConsumerPrx>
00150 {           
00151 public:
00152     RangerArrayElement( const hydroqguielementutil::GuiElementInfo &guiElementInfo,
00153                         const orcaice::Context  &context,
00154                         int                      timeoutMs=30000,
00155                         QColor                   outlineColor=QColor( 102,153,102, 255 ),
00156                         float                    outlineThickness=-1,
00157                         float                    brightReturnWidth=0.2 )
00158         : orcaqguielementutil::IceStormGuiElement2d<RangerArrayPainter,
00159                           orca::RangerArrayDataPtr,
00160                           orca::RangerArrayPrx,
00161                           orca::RangerArrayConsumer,
00162                           orca::RangerArrayConsumerPrx>(guiElementInfo, context, painter_, timeoutMs ),
00163           painter_( outlineColor, outlineThickness, brightReturnWidth )
00164         {};
00165 
00166     virtual bool isInGlobalCS() { return false; }
00167     virtual void iceStormConnectedEvent() { getRangerArrayInfo(); }
00168     virtual QStringList contextMenu();
00169     virtual void execute( int action ) { painter_.execute( action ); };
00170     virtual void setFocus( bool inFocus ) { painter_.setFocus( inFocus ); };
00171 
00172 private:
00173     void getRangerArrayInfo();
00174     RangerArrayPainter painter_;
00175     
00176 };
00177 
00179 class Localise3dElement
00180     : public orcaqguielementutil::IceStormGuiElement2d<Localise3dPainter,
00181                              orca::Localise3dData,
00182                              orca::Localise3dPrx,
00183                              orca::Localise3dConsumer,
00184                              orca::Localise3dConsumerPrx>,
00185       public hydroqguielementutil::IKnowsPlatformPosition2d
00186 {
00187 public:
00188     Localise3dElement( const hydroqguielementutil::GuiElementInfo &guiElementInfo,
00189                        const orcaice::Context  &context,
00190                        bool                     beginDisplayHistory=false,
00191                        int                      timeoutMs=30000 )
00192         : orcaqguielementutil::IceStormGuiElement2d<Localise3dPainter,
00193                             orca::Localise3dData,
00194                             orca::Localise3dPrx,
00195                             orca::Localise3dConsumer,
00196                             orca::Localise3dConsumerPrx>(guiElementInfo, context, painter_, timeoutMs ),
00197           painter_( beginDisplayHistory ),
00198           x_(0),
00199           y_(0),
00200           theta_(0)
00201 {
00202     Ice::PropertiesPtr prop = context_.properties();
00203     std::string prefix = context_.tag();
00204     prefix += ".Config.";
00205 
00206     orcaobj::setInit( origin_ );
00207     orcaobj::getPropertyAsCartesianPoint( prop, prefix+"General.Offset", origin_ );
00208 
00209 }
00210     virtual bool isInGlobalCS() { return true; }
00211     virtual void iceStormConnectedEvent();
00212     virtual QStringList contextMenu();
00213     virtual void execute( int action );
00214     
00215     virtual void setColor( QColor color ) { painter_.setColor(color); }
00216     virtual void setFocus( bool inFocus ) { painter_.setFocus( inFocus ); };
00217     virtual void setUseTransparency( bool useTransparency ) { painter_.setUseTransparency( useTransparency ); };
00218 
00219     // Need a special update function to set (x,y,theta)
00220     // The Localise3dElement needs this because it's special kind of GuiElement:
00221     //   A platform has a position in the world and various other things are
00222     //   drawn with respect to that position.
00223     virtual void update();
00224 
00225     // Access to ML estimate.
00226     virtual double x() const { return x_; }
00227     virtual double y() const { return y_; }
00228     virtual double theta() const { return theta_; }
00229     virtual int platformKnowledgeReliability() const { return 7; }
00230     virtual QPointF pos() const { return QPointF(x_,y_); };
00231 
00232 private:
00233     Localise3dPainter painter_;
00234 
00235     double x_;
00236     double y_;
00237     double theta_;
00238     
00239     void tryToGetGeometry();
00240     bool haveGeometry_;
00241 
00242     orca::CartesianPoint origin_; 
00243 };
00244 
00246 
00247 class Particle2dElement
00248     : public orcaqguielementutil::IceStormGuiElement2d<Particle2dPainter,
00249                              orca::Particle2dData,
00250                              orca::Particle2dPrx,
00251                              orca::Particle2dConsumer,
00252                              orca::Particle2dConsumerPrx>
00253 {
00254 public:
00255     Particle2dElement( const hydroqguielementutil::GuiElementInfo &guiElementInfo,
00256                        const orcaice::Context  &context,
00257                        int                      timeoutMs=60000 )
00258         : orcaqguielementutil::IceStormGuiElement2d<Particle2dPainter,
00259                             orca::Particle2dData,
00260                             orca::Particle2dPrx,
00261                             orca::Particle2dConsumer,
00262                             orca::Particle2dConsumerPrx>(guiElementInfo, context, painter_, timeoutMs )
00263         {};
00264 
00265     virtual bool isInGlobalCS() { return true; }
00266     virtual void setColor( QColor color ) { painter_.setColor(color); }
00267     virtual void setUseTransparency( bool useTransparency ) { painter_.setUseTransparency( useTransparency ); };
00268 
00269 private:
00270     Particle2dPainter painter_;
00271 };
00272 
00274 
00275 
00276 class QGraphics2dElement
00277     : public orcaqguielementutil::IceStormGuiElement2d<QGraphics2dPainter,
00278                              orca::QGraphics2dData,
00279                              orca::QGraphics2dPrx,
00280                              orca::QGraphics2dConsumer,
00281                              orca::QGraphics2dConsumerPrx>
00282 {
00283 public:
00284     QGraphics2dElement( const hydroqguielementutil::GuiElementInfo &guiElementInfo,
00285                         const orcaice::Context  &context,
00286                         int                      timeoutMs=-1 )
00287     : orcaqguielementutil::IceStormGuiElement2d<QGraphics2dPainter,
00288                           orca::QGraphics2dData,
00289                           orca::QGraphics2dPrx,
00290                           orca::QGraphics2dConsumer,
00291                           orca::QGraphics2dConsumerPrx>(guiElementInfo, context, painter_, timeoutMs )
00292     {
00293     };
00294 
00295     virtual bool isInGlobalCS() { return painter_.isInGlobalCS(); }
00296 
00297 private:
00298     QGraphics2dPainter painter_;
00299 };
00300 
00302 class Odometry2dElement
00303     : public orcaqguielementutil::IceStormGuiElement2d<Odometry2dPainter,
00304                              orca::Odometry2dData,
00305                              orca::Odometry2dPrx,
00306                              orca::Odometry2dConsumer,
00307                              orca::Odometry2dConsumerPrx>
00308 {
00309 public:
00310     Odometry2dElement( const hydroqguielementutil::GuiElementInfo &guiElementInfo,
00311                        const orcaice::Context  &context,
00312                        int                      timeoutMs=60000 )
00313         : orcaqguielementutil::IceStormGuiElement2d<Odometry2dPainter,
00314                             orca::Odometry2dData,
00315                             orca::Odometry2dPrx,
00316                             orca::Odometry2dConsumer,
00317                             orca::Odometry2dConsumerPrx>(guiElementInfo, context, painter_, timeoutMs )
00318         {};
00319 
00320     virtual bool isInGlobalCS() { return false; }
00321     virtual void setColor( QColor color ) { painter_.setColor(color); }
00322     virtual void setUseTransparency( bool useTransparency ) { painter_.setUseTransparency( useTransparency ); };
00323 
00324 private:
00325     Odometry2dPainter painter_;
00326 };
00327 
00329 class DriveBicycleElement
00330     : public orcaqguielementutil::IceStormGuiElement2d<DriveBicyclePainter,
00331                              orca::DriveBicycleData,
00332                              orca::DriveBicyclePrx,
00333                              orca::DriveBicycleConsumer,
00334                              orca::DriveBicycleConsumerPrx>
00335 {
00336 public:
00337     DriveBicycleElement( const hydroqguielementutil::GuiElementInfo &guiElementInfo,
00338                          const orcaice::Context                     &context,
00339                          int                                         timeoutMs = 60000 )
00340         : orcaqguielementutil::IceStormGuiElement2d<DriveBicyclePainter,
00341                             orca::DriveBicycleData,
00342                             orca::DriveBicyclePrx,
00343                             orca::DriveBicycleConsumer,
00344                             orca::DriveBicycleConsumerPrx>(guiElementInfo, context, painter_, timeoutMs )
00345         {};
00346 
00347     virtual bool isInGlobalCS() { return false; }
00348     virtual void iceStormConnectedEvent() { getDriveBicycleInfo(); }
00349     virtual QStringList contextMenu();
00350     virtual void execute( int action ) { painter_.execute( action ); };
00351     virtual void setFocus( bool inFocus ) { painter_.setFocus( inFocus ); };
00352 
00353 private:
00354     void getDriveBicycleInfo();
00355     DriveBicyclePainter painter_;
00356 };
00357 
00358 } // namespace
00359 
00360 #endif
 

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


Generated for Orca Robotics by  doxygen 1.4.5