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

 

         

pathfollower2delement.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 PATHFOLLOWER2DELEMENT_H
00012 #define PATHFOLLOWER2DELEMENT_H
00013 
00014 #include <orca/pathfollower2d.h>
00015 
00016 #include <gbxsickacfr/gbxiceutilacfr/store.h>
00017 #include <gbxsickacfr/gbxiceutilacfr/timer.h>
00018 
00019 #include <hydroqguielementutil/guielement2d.h>
00020 #include <orcaqgui2dfactory/pathfollowerpainter.h>
00021 #include <orcaqgui2dfactory/pathfolloweruserinteraction.h>
00022 
00023 namespace orcaqgui2d {
00024     
00025 class PathFollowerInput;
00026     
00028 // The consumer object. We need this here because PathFollower2dElement cannot inherit from IceStormGuiElement2d.
00029 // Reason is that PathFollower2dConsumer has several non-standard purely virtual member functions.
00030 class PathUpdateConsumer : public orca::PathFollower2dConsumer
00031 {
00032 public:
00033     
00034     void setData( const orca::PathFollower2dData& newPath, const ::Ice::Current& );
00035     void setState( const orca::PathFollower2dState& newState, const ::Ice::Current& );
00036 
00037     gbxiceutilacfr::Store<orca::PathFollower2dData> pathPipe_;
00038     gbxiceutilacfr::Store<orca::PathFollower2dState> statePipe_;
00039 };
00041 
00042 
00043 // We need to inherit from GuiElement2d, not from IceStormGuiElement2d. 
00044 // Reason is that PathFollower2dConsumer has a non-standard purely virtual 
00045 // member function setState. 
00046 // Disadvantage is that we have to subscribe ourselves.
00047 class PathFollower2dElement : public hydroqguielementutil::GuiElement2d
00048 {
00049 
00050 public: 
00051 
00052     PathFollower2dElement( const hydroqguielementutil::GuiElementInfo &guiElementInfo,
00053                            const orcaice::Context                     &context );
00054 
00055     // inherited from guielement
00056     void update();
00057     void paint( QPainter *p, int z );
00058     bool paintThisLayer( int z ) const
00059         { return painter_.paintThisLayer(z); }
00060     
00061     virtual bool isInGlobalCS() { return true; }
00062     virtual QStringList contextMenu();
00063     virtual void execute( int action );
00064     virtual void setColor( QColor color ) { painter_.setColor( color ); };
00065     virtual void setFocus( bool inFocus );
00066     virtual void setUseTransparency( bool useTransparency );
00067 
00068     virtual void noLongerMouseEventReceiver() { if ( pathUI_.get() ) pathUI_->noLongerMouseEventReceiver(); }
00069     virtual void mousePressEvent(QMouseEvent *e) { if ( pathUI_.get() ) pathUI_->mousePressEvent(e); }
00070     virtual void mouseMoveEvent(QMouseEvent *e) { if ( pathUI_.get() ) pathUI_->mouseMoveEvent(e); }
00071     virtual void mouseReleaseEvent(QMouseEvent *e) { if ( pathUI_.get() ) pathUI_->mouseReleaseEvent(e); }
00072     virtual void mouseDoubleClickEvent(QMouseEvent *e) { if ( pathUI_.get() ) pathUI_->mouseDoubleClickEvent(e); }
00073     
00074     // sets an inputFactory different from the default one
00075     void setInputFactory ( std::auto_ptr<hydroqguipath::PathInputFactory> inputFactory );
00076     
00077     void go();
00078     void stop();
00079     void sendPath( const hydroqguipath::IPathInput *pathInput, 
00080                    bool                             activateImmediately );
00081 
00082     void enableHI();
00083     void disableHI();
00084     bool isHIEnabled() { return pathUI_.get() != 0; }
00085 
00086     // pathUI_ will call this
00087     void toggleEnabled();
00088 
00089     PathFollowerPainter &pathPainter() { return painter_; }
00090 
00091     // Toolbar buttons can be enabled and disabled.
00092     // By default they are enabled.
00093     void enableToolbarButtons( bool enable );
00094     
00095     // returns the PathUserInteraction object to hook up actions to it via signal-slot
00096     QObject* pathUi();
00097 
00098 private: 
00099 
00100     PathFollowerPainter painter_;
00101 
00102     void connectToInterface();
00103     bool isConnected_;
00104 
00105     PathUpdateConsumer *pathUpdateConsumer_;
00106     orca::PathFollower2dConsumerPrx callbackPrx_;
00107     orca::PathFollower2dPrx pathFollower2dPrx_;
00108     std::string proxyString_;
00109 
00110     orcaice::Context context_;
00111     
00112     std::auto_ptr<hydroqguipath::PathInputFactory> inputFactory_;
00113     
00114     bool firstTime_;
00115     gbxiceutilacfr::Timer timer_;
00116     
00117     bool isInFocus_;
00118 
00119     bool isRemoteInterfaceSick_;
00120     
00121     // Handles human interface
00122     std::auto_ptr<PathFollowerUserInteraction> pathUI_;
00123     
00124     // returns 0 if remote call works otherwise -1
00125     int isFollowerEnabled( bool &isEnabled );
00126 
00127     bool enableToolbarButtons_;
00128     
00129 };
00130 
00131 }
00132 
00133 #endif
 

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


Generated for Orca Robotics by  doxygen 1.4.5