|
orca-robotics INTRODUCTION Overview Download and Install Quick Start Documentation Publications REPOSITORY Interfaces Components Libraries Utilities Software Map DEVELOPER Tutorials Examples Dev Guide Dashboard Wiki login/pass: orca/orca PEOPLE Contributors Users Project Download Mailing lists
|
pathfollower2delement.h00001 /* 00002 * Orca-Robotics Project: Components for robotics 00003 * http://orca-robotics.sf.net/ 00004 * Copyright (c) 2004-2008 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/pathpainter.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 IceStormElement2d. 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 setWaypointIndex( int index, const ::Ice::Current& ); 00036 void setActivationTime( const orca::Time& absoluteTime, double relativeTime, const ::Ice::Current& ); 00037 void setEnabledState( bool enabledState, const ::Ice::Current& ); 00038 00039 gbxiceutilacfr::Store<orca::PathFollower2dData> pathPipe_; 00040 gbxiceutilacfr::Store<int> indexPipe_; 00041 gbxiceutilacfr::Store<double> relativeTimePipe_; 00042 }; 00044 00045 00046 // We need to inherit from GuiElement2d, not from IceStormElement2d. 00047 // Reason is that PathFollower2dConsumer has a non-standard purely virtual 00048 // member function setWaypointIndex. 00049 // Disadvantage is that we have to subscribe ourselves. 00050 class PathFollower2dElement : public hydroqguielementutil::GuiElement2d 00051 { 00052 00053 public: 00054 00055 PathFollower2dElement( const orcaice::Context & context, 00056 const std::string &proxyString, 00057 hydroqguielementutil::IHumanManager &humanManager, 00058 hydroqguielementutil::MouseEventManager &mouseEventManager, 00059 hydroqguielementutil::ShortcutKeyManager &shortcutKeyManager, 00060 const hydroqgui::GuiElementSet &guiElementSet ); 00061 00062 // inherited from guielement 00063 void update(); 00064 void paint( QPainter *p, int z ); 00065 bool paintThisLayer( int z ) const 00066 { return painter_.paintThisLayer(z); } 00067 00068 virtual bool isInGlobalCS() { return true; } 00069 virtual QStringList contextMenu(); 00070 virtual void execute( int action ); 00071 virtual void setColor( QColor color ) { painter_.setColor( color ); }; 00072 virtual void setFocus( bool inFocus ); 00073 virtual void setUseTransparency( bool useTransparency ); 00074 00075 virtual void noLongerMouseEventReceiver() { if ( pathUI_.get() ) pathUI_->noLongerMouseEventReceiver(); } 00076 virtual void mousePressEvent(QMouseEvent *e) { if ( pathUI_.get() ) pathUI_->mousePressEvent(e); } 00077 virtual void mouseMoveEvent(QMouseEvent *e) { if ( pathUI_.get() ) pathUI_->mouseMoveEvent(e); } 00078 virtual void mouseReleaseEvent(QMouseEvent *e) { if ( pathUI_.get() ) pathUI_->mouseReleaseEvent(e); } 00079 virtual void mouseDoubleClickEvent(QMouseEvent *e) { if ( pathUI_.get() ) pathUI_->mouseDoubleClickEvent(e); } 00080 00081 // sets an inputFactory different from the default one 00082 void setInputFactory ( std::auto_ptr<hydroqguipath::PathInputFactory> inputFactory ); 00083 00084 // Tries to enable or disable the remote interface. Returns true if successful 00085 bool tryEnableRemoteInterface( bool enable ); 00086 void go(); 00087 void stop(); 00088 void sendPath( const hydroqguipath::IPathInput *pathInput, 00089 bool activateImmediately ); 00090 00091 void enableHI(); 00092 void disableHI(); 00093 bool isHIEnabled() { return pathUI_.get() != 0; } 00094 00095 // pathUI_ will call this 00096 void toggleEnabled(); 00097 00098 PathPainter &pathPainter() { return painter_; } 00099 00100 private: 00101 00102 void doInitialSetup(); 00103 00104 PathPainter painter_; 00105 00106 int connectToInterface(); 00107 bool isConnected_; 00108 void getInitialData(); 00109 00110 PathUpdateConsumer *pathUpdateConsumer_; 00111 orca::PathFollower2dConsumerPrx callbackPrx_; 00112 orca::PathFollower2dPrx pathFollower2dPrx_; 00113 std::string proxyString_; 00114 00115 orcaice::Context context_; 00116 00117 hydroqguielementutil::IHumanManager &humanManager_; 00118 hydroqguielementutil::MouseEventManager &mouseEventManager_; 00119 hydroqguielementutil::ShortcutKeyManager &shortcutKeyManager_; 00120 const hydroqgui::GuiElementSet &guiElementSet_; 00121 00122 std::auto_ptr<hydroqguipath::PathInputFactory> inputFactory_; 00123 00124 bool firstTime_; 00125 gbxiceutilacfr::Timer timer_; 00126 00127 // toggle states 00128 bool displayWaypoints_; 00129 bool displayPastWaypoints_; 00130 bool displayFutureWaypoints_; 00131 bool displayOlympicMarker_; 00132 bool currentTransparency_; 00133 bool isInFocus_; 00134 00135 bool isRemoteInterfaceSick_; 00136 00137 // Handles human interface 00138 std::auto_ptr<PathFollowerUserInteraction> pathUI_; 00139 00140 // returns 0 if remote call works otherwise -1 00141 int isFollowerEnabled( bool &isEnabled ); 00142 00143 }; 00144 00145 } 00146 00147 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)
1.4.5