From 9188865046cfd23a6a6c35b82669488d6aa5d2d9 Mon Sep 17 00:00:00 2001 From: tecnosapiens Date: Fri, 3 Sep 2010 15:19:28 -0500 Subject: [PATCH] add WaypointGlobal class to create Waypoints with earth cordinate. add widget WaypointView to widget WaypointList when create a waypoint with mouse over the map --- .cproject | 148 +++++++++++++++++++++++++++++++++++++++++ .project | 88 ++++++++++++++++++++++++ qgroundcontrol.pro | 6 +- src/Waypoint.h | 2 +- src/WaypointGlobal.cpp | 10 +++ src/WaypointGlobal.h | 29 ++++++++ src/ui/MainWindow.cc | 8 ++- src/ui/MapWidget.cc | 3 + src/ui/MapWidget.h | 2 + src/ui/WaypointList.cc | 36 +++++++++- src/ui/WaypointList.h | 4 +- 11 files changed, 328 insertions(+), 8 deletions(-) create mode 100644 .cproject create mode 100644 .project create mode 100644 src/WaypointGlobal.cpp create mode 100644 src/WaypointGlobal.h diff --git a/.cproject b/.cproject new file mode 100644 index 000000000..43f99020a --- /dev/null +++ b/.cproject @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + mingw32-make + + release + false + false + true + + + mingw32-make + + debug + false + false + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 000000000..fc9b8c2de --- /dev/null +++ b/.project @@ -0,0 +1,88 @@ + + + qgroundcontrol + + + + + + com.trolltech.qtcppproject.QtMakefileGenerator + + + + + org.eclipse.cdt.make.core.makeBuilder + clean,full,incremental, + + + org.eclipse.cdt.core.errorOutputParser + org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.VCErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.MakeErrorParser; + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.build.arguments + + + + org.eclipse.cdt.make.core.build.command + mingw32-make + + + org.eclipse.cdt.make.core.build.target.auto + debug + + + org.eclipse.cdt.make.core.build.target.clean + clean + + + org.eclipse.cdt.make.core.build.target.inc + debug + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.enabledIncrementalBuild + true + + + org.eclipse.cdt.make.core.environment + QMAKESPEC=win32-g++|PATH=C:\\Qt\\2010.04\\qt\\bin;${env_var:PATH}| + + + org.eclipse.cdt.make.core.stopOnError + false + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + false + + + + + org.eclipse.cdt.make.core.ScannerConfigBuilder + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.make.core.makeNature + org.eclipse.cdt.make.core.ScannerConfigNature + com.trolltech.qtcppproject.QtNature + + diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 44a1974de..4ae3cbd17 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -155,7 +155,8 @@ HEADERS += src/MG.h \ src/ui/linechart/IncrementalPlot.h \ src/ui/map/Waypoint2DIcon.h \ src/ui/map/MAV2DIcon.h \ - src/ui/map/QGC2DIcon.h + src/ui/map/QGC2DIcon.h \ + src/WaypointGlobal.h SOURCES += src/main.cc \ src/Core.cc \ src/uas/UASManager.cc \ @@ -218,7 +219,8 @@ SOURCES += src/main.cc \ src/ui/linechart/IncrementalPlot.cc \ src/ui/map/Waypoint2DIcon.cc \ src/ui/map/MAV2DIcon.cc \ - src/ui/map/QGC2DIcon.cc + src/ui/map/QGC2DIcon.cc \ + src/WaypointGlobal.cpp RESOURCES = mavground.qrc # Include RT-LAB Library diff --git a/src/Waypoint.h b/src/Waypoint.h index 053f6cbb0..d8baeba9e 100644 --- a/src/Waypoint.h +++ b/src/Waypoint.h @@ -59,7 +59,7 @@ public: bool load(QTextStream &loadStream); -private: +protected: quint16 id; float x; float y; diff --git a/src/WaypointGlobal.cpp b/src/WaypointGlobal.cpp new file mode 100644 index 000000000..fc5526f1c --- /dev/null +++ b/src/WaypointGlobal.cpp @@ -0,0 +1,10 @@ +#include "WaypointGlobal.h" + +#include + +WaypointGlobal::WaypointGlobal(const QPointF coordinate): + Waypoint(id, x, y, z, yaw, autocontinue, current, orbit, holdTime) +{ + coordinateWP = coordinate; + +} diff --git a/src/WaypointGlobal.h b/src/WaypointGlobal.h new file mode 100644 index 000000000..4a3bc4e94 --- /dev/null +++ b/src/WaypointGlobal.h @@ -0,0 +1,29 @@ +#ifndef WAYPOINTGLOBAL_H +#define WAYPOINTGLOBAL_H + +#include "Waypoint.h" +#include + +class WaypointGlobal: public Waypoint { + Q_OBJECT + +public: + WaypointGlobal(const QPointF coordinate); + + public slots: + +// void set_latitud(double latitud); +// void set_longitud(double longitud); +// double get_latitud(); +// double get_longitud(); + +private: + QPointF coordinateWP; + + + + + +}; + +#endif // WAYPOINTGLOBAL_H diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 9fbc2e675..208b75e8e 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -92,14 +92,16 @@ MainWindow::MainWindow(QWidget *parent) : // Create actions connectActions(); - // Load widgets and show application window + // Load widgets and show application windowa loadWidgets(); // Adjust the size adjustSize(); - //waypoints->setMapHandle(map); - connect(waypoints, SIGNAL(clearPahtclicked()), map, SLOT(clearPath())); + // clear path create on the map + connect(waypoints, SIGNAL(clearPathclicked()), map, SLOT(clearPath())); + // add Waypoint widget in the WaypointList widget when mouse clicked + connect(map, SIGNAL(captureMapCoordinateClick(QPointF)), waypoints, SLOT(addWaypointMouse(QPointF))); } MainWindow::~MainWindow() diff --git a/src/ui/MapWidget.cc b/src/ui/MapWidget.cc index b60702fdd..9ae5e6c7a 100644 --- a/src/ui/MapWidget.cc +++ b/src/ui/MapWidget.cc @@ -342,6 +342,9 @@ void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordina // Refresh the screen mc->updateRequestNew(); + + // emit signal mouse was clicked + emit captureMapCoordinateClick(coordinate); } } diff --git a/src/ui/MapWidget.h b/src/ui/MapWidget.h index 68b4055ed..b9ca39a8d 100644 --- a/src/ui/MapWidget.h +++ b/src/ui/MapWidget.h @@ -115,6 +115,8 @@ protected: signals: //void movePoint(QPointF newCoord); + void captureMapCoordinateClick(const QPointF coordinate); //ROCA + private: Ui::MapWidget *m_ui; diff --git a/src/ui/WaypointList.cc b/src/ui/WaypointList.cc index bb4ef439e..90e4a472e 100644 --- a/src/ui/WaypointList.cc +++ b/src/ui/WaypointList.cc @@ -358,5 +358,39 @@ void WaypointList::changeEvent(QEvent *e) void WaypointList::on_clearWPListButton_clicked() { - emit clearPahtclicked(); + emit clearPathclicked(); + +// if (uas) +// { +// const QVector &waypoints = uas->getWaypointManager().getWaypointList(); +// for(int i = 0; i <=waypoints.size(); i++) +// { +// WaypointView* widget = wpViews.find(waypoints[i]).value(); + +// widget->remove(); + +// } + +// } +} + +/** @brief Add a waypoint by mouse click over the map */ +void WaypointList::addWaypointMouse(QPointF coordinate) +{ + if (uas) + { + const QVector &waypoints = uas->getWaypointManager().getWaypointList(); + if (waypoints.size() > 0) + { + Waypoint *last = waypoints.at(waypoints.size()-1); + Waypoint *wp = new Waypoint(0, coordinate.x(), coordinate.y(), last->getZ(), last->getYaw(), last->getAutoContinue(), false, last->getOrbit(), last->getHoldTime()); + uas->getWaypointManager().localAddWaypoint(wp); + } + else + { + Waypoint *wp = new Waypoint(0, coordinate.x(), coordinate.y(), -0.8, 0.0, true, true, 0.15, 2000); + uas->getWaypointManager().localAddWaypoint(wp); + } + } + } diff --git a/src/ui/WaypointList.h b/src/ui/WaypointList.h index 88b53a671..e39a21bc3 100644 --- a/src/ui/WaypointList.h +++ b/src/ui/WaypointList.h @@ -73,6 +73,8 @@ public slots: void add(); /** @brief Add a waypoint at the current MAV position */ void addCurrentPositonWaypoint(); + /** @brief Add a waypoint by mouse click over the map */ + void addWaypointMouse(QPointF coordinate); @@ -93,7 +95,7 @@ public slots: signals: - void clearPahtclicked(); + void clearPathclicked(); -- 2.22.0