Commit 09ae02eb authored by tecnosapiens's avatar tecnosapiens

functionalities to widget of WaypointGlobalView.cpp were added

parent d0bca7cb
......@@ -74,7 +74,8 @@ FORMS += src/ui/MainWindow.ui \
src/ui/watchdog/WatchdogView.ui \
src/ui/QGCFirmwareUpdate.ui \
src/ui/QGCPxImuFirmwareUpdate.ui \
src/ui/QGCDataPlot2D.ui
src/ui/QGCDataPlot2D.ui \
src/ui/WaypointGlobalView.ui
INCLUDEPATH += src \
src/ui \
src/ui/linechart \
......@@ -156,7 +157,8 @@ HEADERS += src/MG.h \
src/ui/map/Waypoint2DIcon.h \
src/ui/map/MAV2DIcon.h \
src/ui/map/QGC2DIcon.h \
src/WaypointGlobal.h
src/WaypointGlobal.h \
src/ui/WaypointGlobalView.h
SOURCES += src/main.cc \
src/Core.cc \
src/uas/UASManager.cc \
......@@ -220,7 +222,8 @@ SOURCES += src/main.cc \
src/ui/map/Waypoint2DIcon.cc \
src/ui/map/MAV2DIcon.cc \
src/ui/map/QGC2DIcon.cc \
src/WaypointGlobal.cpp
src/WaypointGlobal.cpp \
src/ui/WaypointGlobalView.cpp
RESOURCES = mavground.qrc
# Include RT-LAB Library
......
......@@ -102,6 +102,8 @@ MainWindow::MainWindow(QWidget *parent) :
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)));
// it notifies that a waypoint global goes to do create
connect(map, SIGNAL(createGlobalWP(bool)), waypoints, SLOT(setIsWPGlobal(bool)));
}
MainWindow::~MainWindow()
......
......@@ -299,12 +299,17 @@ void MapWidget::createPathButtonClicked(bool checked)
{
Q_UNUSED(checked);
if (createPath->isChecked())
{
// change the cursor shape
this->setCursor(Qt::PointingHandCursor);
mc->setMouseMode(qmapcontrol::MapControl::None);
// emit signal start to create a Waypoint global
emit createGlobalWP(true);
// // Clear the previous WP track
// // TODO: Move this to an actual clear track button and add a warning dialog
// mc->layer("Waypoints")->clearGeometries();
......@@ -315,8 +320,11 @@ void MapWidget::createPathButtonClicked(bool checked)
} else {
this->setCursor(Qt::ArrowCursor);
mc->setMouseMode(qmapcontrol::MapControl::Panning);
}
}
......@@ -345,6 +353,7 @@ void MapWidget::captureMapClick(const QMouseEvent* event, const QPointF coordina
// emit signal mouse was clicked
emit captureMapCoordinateClick(coordinate);
}
}
......
......@@ -116,6 +116,7 @@ protected:
signals:
//void movePoint(QPointF newCoord);
void captureMapCoordinateClick(const QPointF coordinate); //ROCA
void createGlobalWP(bool value);
private:
......
......@@ -37,6 +37,7 @@ This file is part of the PIXHAWK project
#include <UASManager.h>
#include <QDebug>
#include <QFileDialog>
#include "WaypointGlobalView.h"
WaypointList::WaypointList(QWidget *parent, UASInterface* uas) :
QWidget(parent),
......@@ -86,6 +87,7 @@ WaypointList::WaypointList(QWidget *parent, UASInterface* uas) :
updateStatusLabel("");
this->setVisible(false);
isGlobalWP = false;
}
WaypointList::~WaypointList()
......@@ -242,53 +244,113 @@ void WaypointList::waypointListChanged()
{
const QVector<Waypoint *> &waypoints = uas->getWaypointManager().getWaypointList();
// first remove all views of non existing waypoints
if (!wpViews.empty())
{
QMapIterator<Waypoint*,WaypointView*> viewIt(wpViews);
viewIt.toFront();
while(viewIt.hasNext())
// For Global Waypoints
if(isGlobalWP)
{
viewIt.next();
Waypoint *cur = viewIt.key();
int i;
for (i = 0; i < waypoints.size(); i++)
// first remove all views of non existing waypoints
if (!wpGlobalViews.empty())
{
if (waypoints[i] == cur)
QMapIterator<Waypoint*,WaypointGlobalView*> viewIt(wpGlobalViews);
viewIt.toFront();
while(viewIt.hasNext())
{
break;
viewIt.next();
Waypoint *cur = viewIt.key();
int i;
for (i = 0; i < waypoints.size(); i++)
{
if (waypoints[i] == cur)
{
break;
}
}
if (i == waypoints.size())
{
WaypointGlobalView* widget = wpGlobalViews.find(cur).value();
widget->hide();
listLayout->removeWidget(widget);
wpGlobalViews.remove(cur);
}
}
}
if (i == waypoints.size())
// then add/update the views for each waypoint in the list
for(int i = 0; i < waypoints.size(); i++)
{
WaypointView* widget = wpViews.find(cur).value();
widget->hide();
listLayout->removeWidget(widget);
wpViews.remove(cur);
}
Waypoint *wp = waypoints[i];
if (!wpGlobalViews.contains(wp))
{
WaypointGlobalView* wpview = new WaypointGlobalView(wp, this);
wpGlobalViews.insert(wp, wpview);
// connect(wpview, SIGNAL(moveDownWaypoint(Waypoint*)), this, SLOT(moveDown(Waypoint*)));
// connect(wpview, SIGNAL(moveUpWaypoint(Waypoint*)), this, SLOT(moveUp(Waypoint*)));
connect(wpview, SIGNAL(removeWaypoint(Waypoint*)), this, SLOT(removeWaypoint(Waypoint*)));
// connect(wpview, SIGNAL(currentWaypointChanged(quint16)), this, SLOT(currentWaypointChanged(quint16)));
// connect(wpview, SIGNAL(changeCurrentWaypoint(quint16)), this, SLOT(changeCurrentWaypoint(quint16)));
}
WaypointGlobalView *wpgv = wpGlobalViews.value(wp);
wpgv->updateValues();
listLayout->addWidget(wpgv);
}
}
// then add/update the views for each waypoint in the list
for(int i = 0; i < waypoints.size(); i++)
{
Waypoint *wp = waypoints[i];
if (!wpViews.contains(wp))
}
else
{
WaypointView* wpview = new WaypointView(wp, this);
wpViews.insert(wp, wpview);
connect(wpview, SIGNAL(moveDownWaypoint(Waypoint*)), this, SLOT(moveDown(Waypoint*)));
connect(wpview, SIGNAL(moveUpWaypoint(Waypoint*)), this, SLOT(moveUp(Waypoint*)));
connect(wpview, SIGNAL(removeWaypoint(Waypoint*)), this, SLOT(removeWaypoint(Waypoint*)));
connect(wpview, SIGNAL(currentWaypointChanged(quint16)), this, SLOT(currentWaypointChanged(quint16)));
connect(wpview, SIGNAL(changeCurrentWaypoint(quint16)), this, SLOT(changeCurrentWaypoint(quint16)));
// for local Waypoints
// first remove all views of non existing waypoints
if (!wpViews.empty())
{
QMapIterator<Waypoint*,WaypointView*> viewIt(wpViews);
viewIt.toFront();
while(viewIt.hasNext())
{
viewIt.next();
Waypoint *cur = viewIt.key();
int i;
for (i = 0; i < waypoints.size(); i++)
{
if (waypoints[i] == cur)
{
break;
}
}
if (i == waypoints.size())
{
WaypointView* widget = wpViews.find(cur).value();
widget->hide();
listLayout->removeWidget(widget);
wpViews.remove(cur);
}
}
}
// then add/update the views for each waypoint in the list
for(int i = 0; i < waypoints.size(); i++)
{
Waypoint *wp = waypoints[i];
if (!wpViews.contains(wp))
{
WaypointView* wpview = new WaypointView(wp, this);
wpViews.insert(wp, wpview);
connect(wpview, SIGNAL(moveDownWaypoint(Waypoint*)), this, SLOT(moveDown(Waypoint*)));
connect(wpview, SIGNAL(moveUpWaypoint(Waypoint*)), this, SLOT(moveUp(Waypoint*)));
connect(wpview, SIGNAL(removeWaypoint(Waypoint*)), this, SLOT(removeWaypoint(Waypoint*)));
connect(wpview, SIGNAL(currentWaypointChanged(quint16)), this, SLOT(currentWaypointChanged(quint16)));
connect(wpview, SIGNAL(changeCurrentWaypoint(quint16)), this, SLOT(changeCurrentWaypoint(quint16)));
}
WaypointView *wpv = wpViews.value(wp);
wpv->updateValues(); // update the values of the ui elements in the view
listLayout->addWidget(wpv);
}
}
WaypointView *wpv = wpViews.value(wp);
wpv->updateValues(); // update the values of the ui elements in the view
listLayout->addWidget(wpv);
}
}
}
void WaypointList::moveUp(Waypoint* wp)
......@@ -362,7 +424,28 @@ void WaypointList::on_clearWPListButton_clicked()
if (uas)
{
const QVector<Waypoint *> &waypoints = uas->getWaypointManager().getWaypointList();
if(isGlobalWP)
{
const QVector<Waypoint *> &waypoints = uas->getWaypointManager().getWaypointList();
while(!waypoints.isEmpty())//for(int i = 0; i <= waypoints.size(); i++)
{
//Waypoint *temp = waypoints[i];
WaypointGlobalView* widget = wpGlobalViews.find(waypoints[0]).value();
widget->remove();
}
isGlobalWP = false;
}
else
{
const QVector<Waypoint *> &waypoints = uas->getWaypointManager().getWaypointList();
while(!waypoints.isEmpty())//for(int i = 0; i <= waypoints.size(); i++)
{
//Waypoint *temp = waypoints[i];
......@@ -372,6 +455,7 @@ void WaypointList::on_clearWPListButton_clicked()
widget->remove();
}
}
}
}
......@@ -396,3 +480,9 @@ void WaypointList::addWaypointMouse(QPointF coordinate)
}
}
/** @brief it notifies that a global waypoint goes to do created */
void WaypointList::setIsWPGlobal(bool value)
{
isGlobalWP = value;
}
......@@ -41,6 +41,7 @@ This file is part of the QGROUNDCONTROL project
#include "Waypoint.h"
#include "UASInterface.h"
#include "WaypointView.h"
#include "WaypointGlobalView.h"
namespace Ui {
......@@ -75,7 +76,8 @@ public slots:
void addCurrentPositonWaypoint();
/** @brief Add a waypoint by mouse click over the map */
void addWaypointMouse(QPointF coordinate);
/** @brief it notifies that a global waypoint goes to do created */
void setIsWPGlobal(bool value);
//Update events
......@@ -104,12 +106,14 @@ protected:
protected:
QMap<Waypoint*, WaypointView*> wpViews;
QMap<Waypoint*, WaypointGlobalView*> wpGlobalViews;
QVBoxLayout* listLayout;
UASInterface* uas;
double mavX;
double mavY;
double mavZ;
double mavYaw;
bool isGlobalWP;
private:
Ui::WaypointList *m_ui;
......@@ -120,6 +124,7 @@ private:
private slots:
void on_clearWPListButton_clicked();
};
#endif // WAYPOINTLIST_H
......@@ -355,7 +355,7 @@ QProgressBar::chunk#thrustBar {
<string/>
</property>
<property name="icon">
<iconset resource="../../mavground.qrc">
<iconset>
<normaloff>:/images/actions/go-up.svg</normaloff>:/images/actions/go-up.svg</iconset>
</property>
</widget>
......@@ -375,7 +375,7 @@ QProgressBar::chunk#thrustBar {
<string/>
</property>
<property name="icon">
<iconset resource="../../mavground.qrc">
<iconset>
<normaloff>:/images/actions/go-down.svg</normaloff>:/images/actions/go-down.svg</iconset>
</property>
</widget>
......@@ -395,7 +395,7 @@ QProgressBar::chunk#thrustBar {
<string/>
</property>
<property name="icon">
<iconset resource="../../mavground.qrc">
<iconset>
<normaloff>:/images/actions/list-remove.svg</normaloff>:/images/actions/list-remove.svg</iconset>
</property>
</widget>
......@@ -405,8 +405,6 @@ QProgressBar::chunk#thrustBar {
</item>
</layout>
</widget>
<resources>
<include location="../../mavground.qrc"/>
</resources>
<resources/>
<connections/>
</ui>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment