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
|
pathplanner2delement.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 PATHPLANNER2DELEMENT_H 00012 #define PATHPLANNER2DELEMENT_H 00013 00014 #include <iostream> 00015 #include <orca/pathplanner2d.h> 00016 #include <gbxsickacfr/gbxiceutilacfr/store.h> 00017 #include <orcaqguielementutil/icestormelement.h> 00018 #include <orcaqgui2dfactory/pathpainter.h> 00019 #include <orcaqgui2dfactory/pathinput.h> 00020 00021 namespace orcaqgui2d { 00022 00023 class hydroqguielementutil::IHumanManager; 00024 00025 // There's two consumer objects: the first one for icestorm (pathplanner pushes out whatever it computed) which is part 00026 // of the base class IceStormElement. 00027 // The second one here is for answers to tasks which were set by the GUI. 00028 00030 class PathPlannerTaskAnswerConsumer : public orca::PathPlanner2dConsumer 00031 { 00032 public: 00033 00034 virtual void setData(const ::orca::PathPlanner2dData& data, const ::Ice::Current& = ::Ice::Current()); 00035 gbxsickacfr::gbxiceutilacfr::Store<QString> msgStore_; 00036 }; 00038 00039 00041 00042 // This class sets up all the buttons and actions for user interaction. 00043 // It can be instantiated on the heap and deleted, Qt cleans up for us 00044 class PathplannerButtons : public QObject 00045 { 00046 Q_OBJECT 00047 00048 public: 00049 PathplannerButtons( QObject *parent, hydroqguielementutil::IHumanManager &humanManager, std::string proxyString); 00050 ~PathplannerButtons() 00051 { 00052 // Qt cleans up for us 00053 }; 00054 void setWpButton( bool onOff ); 00055 00056 private: 00057 QAction *hiWaypoints_; 00058 }; 00060 00061 class PathPlanner2dElement; 00062 class PathPlannerHI : public QObject 00063 { 00064 Q_OBJECT 00065 00066 public: 00067 PathPlannerHI( PathPlanner2dElement *ppElement, 00068 std::string proxyString, 00069 hydroqguielementutil::IHumanManager &humanManager, 00070 hydroqguielementutil::MouseEventManager &mouseEventManager, 00071 PathPainter &painter, 00072 WaypointSettings wpSettings ); 00073 ~PathPlannerHI(); 00074 00075 void noLongerMouseEventReceiver(); 00076 void paint( QPainter *p ); 00077 00078 void mousePressEvent(QMouseEvent *e) 00079 {pathInput_->processPressEvent(e);} 00080 void mouseMoveEvent(QMouseEvent *e) {pathInput_->processMoveEvent(e);} 00081 void mouseReleaseEvent(QMouseEvent *e) {pathInput_->processReleaseEvent(e);} 00082 void mouseDoubleClickEvent(QMouseEvent *e) {pathInput_->processDoubleClickEvent(e);} 00083 void setFocus( bool inFocus ); 00084 void setUseTransparency( bool useTransparency ); 00085 00086 public slots: 00087 void savePathAs(); 00088 void savePath(); 00089 void waypointSettingsDialog(); 00090 void waypointModeSelected(); 00091 void send(); 00092 void cancel(); 00093 00094 private: 00095 00096 PathPlanner2dElement *ppElement_; 00097 std::string proxyString_; 00098 hydroqguielementutil::IHumanManager &humanManager_; 00099 hydroqguielementutil::MouseEventManager &mouseEventManager_; 00100 PathPainter &painter_; 00101 00102 QString pathFileName_; 00103 bool pathFileSet_; 00104 00105 WaypointSettings wpSettings_; 00106 00107 PathPlannerInput *pathInput_; 00108 00109 // sets up and destroys buttons and associated actions 00110 PathplannerButtons *buttons_; 00111 00112 // Do we own the global mode? 00113 bool gotMode_; 00114 00115 bool useTransparency_; 00116 }; 00117 00118 // 00119 // @author Tobias Kaupp 00120 // 00121 class PathPlanner2dElement : public orcaqguielementutil::IceStormElement<PathPainter, 00122 orca::PathPlanner2dData, 00123 orca::PathPlanner2dPrx, 00124 orca::PathPlanner2dConsumer, 00125 orca::PathPlanner2dConsumerPrx> 00126 { 00127 00128 public: 00129 00130 PathPlanner2dElement( const orcaice::Context &context, 00131 const std::string &proxyString, 00132 hydroqguielementutil::IHumanManager &humanManager, 00133 hydroqguielementutil::MouseEventManager &mouseEventManager ); 00134 ~PathPlanner2dElement(); 00135 00136 void update(); 00137 00138 // overriding paint since we have to paint human input 00139 void paint( QPainter *p, int z ); 00140 00141 virtual void actionOnConnection(); 00142 virtual bool isInGlobalCS() { return true; } 00143 virtual QStringList contextMenu(); 00144 virtual void execute( int action ); 00145 virtual void setColor( QColor color ) { painter_.setColor( color ); }; 00146 virtual void setFocus( bool inFocus ); 00147 virtual void setUseTransparency( bool useTransparency ); 00148 00149 virtual void noLongerMouseEventReceiver() { pathHI_.noLongerMouseEventReceiver(); } 00150 virtual void mousePressEvent(QMouseEvent *e) { pathHI_.mousePressEvent(e); } 00151 virtual void mouseMoveEvent(QMouseEvent *e) { pathHI_.mouseMoveEvent(e); } 00152 virtual void mouseReleaseEvent(QMouseEvent *e) { pathHI_.mouseReleaseEvent(e); } 00153 virtual void mouseDoubleClickEvent(QMouseEvent *e) { pathHI_.mouseDoubleClickEvent(e); } 00154 void sendPath( const PathPlannerInput &pathInput ); 00155 00156 private: 00157 00158 PathPainter painter_; 00159 00160 // Task answer 00161 PathPlannerTaskAnswerConsumer *pathTaskAnswerConsumer_; 00162 orca::PathPlanner2dConsumerPrx taskCallbackPrx_; 00163 Ice::ObjectPtr pathPlanner2dConsumerObj_; 00164 00165 orca::PathPlanner2dPrx pathPlanner2dPrx_; 00166 00167 orcaice::Context context_; 00168 std::string proxyString_; 00169 hydroqguielementutil::IHumanManager &humanManager_; 00170 00171 bool displayWaypoints_; 00172 bool currentTransparency_; 00173 00174 // Handles human interface 00175 PathPlannerHI pathHI_; 00176 00177 }; 00178 00179 } 00180 00181 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)