mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-27 16:54:15 +01:00
OP37/GCS WayPoint overlay added. Doxygen tags added to mapcontrol namespace.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@926 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
515367d38c
commit
de029920f6
@ -1,5 +1,33 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file configuration.cpp
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
* @brief A class that centralizes most of the mapcontrol configurations
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup OPMapWidget
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
namespace mapcontrol
|
||||||
|
{
|
||||||
Configuration::Configuration()
|
Configuration::Configuration()
|
||||||
{
|
{
|
||||||
EmptytileBrush = Qt::cyan;
|
EmptytileBrush = Qt::cyan;
|
||||||
@ -8,7 +36,7 @@ Configuration::Configuration()
|
|||||||
EmptyTileBorders = QPen(Qt::white);
|
EmptyTileBorders = QPen(Qt::white);
|
||||||
ScalePen = QPen(Qt::blue);
|
ScalePen = QPen(Qt::blue);
|
||||||
SelectionPen = QPen(Qt::blue);
|
SelectionPen = QPen(Qt::blue);
|
||||||
DragButton = Qt::RightButton;
|
DragButton = Qt::LeftButton;
|
||||||
}
|
}
|
||||||
void Configuration::SetAccessMode(core::AccessMode::Types const& type)
|
void Configuration::SetAccessMode(core::AccessMode::Types const& type)
|
||||||
{
|
{
|
||||||
@ -26,3 +54,8 @@ core::LanguageType::Types Configuration::Language()
|
|||||||
{
|
{
|
||||||
return core::OPMaps::Instance()->GetLanguage();
|
return core::OPMaps::Instance()->GetLanguage();
|
||||||
}
|
}
|
||||||
|
void Configuration::SetUseMemoryCache(bool const& value)
|
||||||
|
{
|
||||||
|
core::OPMaps::Instance()->setUseMemoryCache(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,3 +1,31 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file configuration.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
* @brief A class that centralizes most of the mapcontrol configurations
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup OPMapWidget
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef CONFIGURATION_H
|
#ifndef CONFIGURATION_H
|
||||||
#define CONFIGURATION_H
|
#define CONFIGURATION_H
|
||||||
|
|
||||||
@ -8,33 +36,118 @@
|
|||||||
#include "../core/opmaps.h"
|
#include "../core/opmaps.h"
|
||||||
#include "../core/accessmode.h"
|
#include "../core/accessmode.h"
|
||||||
#include "../core/cache.h"
|
#include "../core/cache.h"
|
||||||
|
namespace mapcontrol
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A class that centralizes most of the mapcontrol configurations
|
||||||
|
*
|
||||||
|
* @class Configuration configuration.h "configuration.h"
|
||||||
|
*/
|
||||||
class Configuration
|
class Configuration
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Configuration();
|
Configuration();
|
||||||
|
/**
|
||||||
|
* @brief Used to draw empty map tiles
|
||||||
|
*
|
||||||
|
* @var EmptytileBrush
|
||||||
|
*/
|
||||||
QBrush EmptytileBrush;
|
QBrush EmptytileBrush;
|
||||||
|
/**
|
||||||
|
* @brief Used for empty tiles text
|
||||||
|
*
|
||||||
|
* @var EmptyTileText
|
||||||
|
*/
|
||||||
QString EmptyTileText;
|
QString EmptyTileText;
|
||||||
|
/**
|
||||||
|
* @brief Used to draw empty tile borders
|
||||||
|
*
|
||||||
|
* @var EmptyTileBorders
|
||||||
|
*/
|
||||||
QPen EmptyTileBorders;
|
QPen EmptyTileBorders;
|
||||||
|
/**
|
||||||
|
* @brief Used to Draw the maps scale
|
||||||
|
*
|
||||||
|
* @var ScalePen
|
||||||
|
*/
|
||||||
QPen ScalePen;
|
QPen ScalePen;
|
||||||
|
/**
|
||||||
|
* @brief Used to draw selection box
|
||||||
|
*
|
||||||
|
* @var SelectionPen
|
||||||
|
*/
|
||||||
QPen SelectionPen;
|
QPen SelectionPen;
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
*
|
||||||
|
* @var MissingDataFont
|
||||||
|
*/
|
||||||
QFont MissingDataFont;
|
QFont MissingDataFont;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Button used for dragging
|
||||||
|
*
|
||||||
|
* @var DragButton
|
||||||
|
*/
|
||||||
Qt::MouseButton DragButton;
|
Qt::MouseButton DragButton;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the access mode for the map (cache only, server and cache...)
|
||||||
|
*
|
||||||
|
* @param type access mode
|
||||||
|
*/
|
||||||
void SetAccessMode(core::AccessMode::Types const& type);
|
void SetAccessMode(core::AccessMode::Types const& type);
|
||||||
|
/**
|
||||||
|
* @brief Returns the access mode for the map (cache only, server and cache...)
|
||||||
|
*
|
||||||
|
* @return core::AccessMode::Types access mode for the map
|
||||||
|
*/
|
||||||
core::AccessMode::Types AccessMode();
|
core::AccessMode::Types AccessMode();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the language used for geocaching
|
||||||
|
*
|
||||||
|
* @param type The language to be used
|
||||||
|
*/
|
||||||
void SetLanguage(core::LanguageType::Types const& type);
|
void SetLanguage(core::LanguageType::Types const& type);
|
||||||
|
/**
|
||||||
|
* @brief Returns the language used for geocaching
|
||||||
|
*
|
||||||
|
* @return core::LanguageType::Types
|
||||||
|
*/
|
||||||
core::LanguageType::Types Language();
|
core::LanguageType::Types Language();
|
||||||
|
|
||||||
void SetUseMemoryCache(bool const& value){core::OPMaps::Instance()->setUseMemoryCache(value);}
|
/**
|
||||||
|
* @brief Used to allow disallow use of memory caching
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void SetUseMemoryCache(bool const& value);
|
||||||
|
/**
|
||||||
|
* @brief Return if memory caching is in use
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool UseMemoryCache(){return core::OPMaps::Instance()->UseMemoryCache();}
|
bool UseMemoryCache(){return core::OPMaps::Instance()->UseMemoryCache();}
|
||||||
|
|
||||||
void SetCacheLocation(QString const& dir){
|
/**
|
||||||
|
* @brief Sets the location for the SQLite Database used for caching and the geocoding cache files
|
||||||
|
*
|
||||||
|
* @param dir The path location for the cache file-IMPORTANT Must end with closing slash "/"
|
||||||
|
*/
|
||||||
|
void SetCacheLocation(QString const& dir)
|
||||||
|
{
|
||||||
core::Cache::Instance()->setCacheLocation(dir);
|
core::Cache::Instance()->setCacheLocation(dir);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @brief Returns the location for the SQLite Database used for caching and the geocoding cache files
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
QString CacheLocation(){return core::Cache::Instance()->CacheLocation();}
|
QString CacheLocation(){return core::Cache::Instance()->CacheLocation();}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
#endif // CONFIGURATION_H
|
#endif // CONFIGURATION_H
|
||||||
|
@ -1,3 +1,30 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file mapgraphicitem.cpp
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
* @brief The main graphicsItem used on the widget, contains the map and map logic
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup OPMapWidget
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
#include "mapgraphicitem.h"
|
#include "mapgraphicitem.h"
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
@ -23,6 +50,7 @@ namespace mapcontrol
|
|||||||
{
|
{
|
||||||
|
|
||||||
{
|
{
|
||||||
|
this->prepareGeometryChange();
|
||||||
maprect=boundingBox(scene()->sceneRect(),rotation);
|
maprect=boundingBox(scene()->sceneRect(),rotation);
|
||||||
this->setTransform(QTransform().translate(-(maprect.width()-scene()->width())/2,-(maprect.height()-scene()->height())/2));
|
this->setTransform(QTransform().translate(-(maprect.width()-scene()->width())/2,-(maprect.height()-scene()->height())/2));
|
||||||
this->setTransformOriginPoint(maprect.center().x(),maprect.center().y());
|
this->setTransformOriginPoint(maprect.center().x(),maprect.center().y());
|
||||||
@ -45,6 +73,12 @@ namespace mapcontrol
|
|||||||
void MapGraphicItem::Core_OnNeedInvalidation()
|
void MapGraphicItem::Core_OnNeedInvalidation()
|
||||||
{
|
{
|
||||||
this->update();
|
this->update();
|
||||||
|
foreach(QGraphicsItem* i,this->childItems())
|
||||||
|
{
|
||||||
|
WayPointItem* w=qgraphicsitem_cast<WayPointItem*>(i);
|
||||||
|
if(w)
|
||||||
|
w->RefreshPos();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void MapGraphicItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void MapGraphicItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
@ -262,6 +296,16 @@ namespace mapcontrol
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
core::Point MapGraphicItem::FromLatLngToLocal(internals::PointLatLng const& point)
|
||||||
|
{
|
||||||
|
core::Point ret = core->FromLatLngToLocal(point);
|
||||||
|
if(MapRenderTransform!=1)
|
||||||
|
{
|
||||||
|
ret.SetX((int) (ret.X() / MapRenderTransform));
|
||||||
|
ret.SetY((int) (ret.Y() / MapRenderTransform));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
internals::PointLatLng MapGraphicItem::FromLocalToLatLng(int x, int y)
|
internals::PointLatLng MapGraphicItem::FromLocalToLatLng(int x, int y)
|
||||||
{
|
{
|
||||||
if(MapRenderTransform!=-1)
|
if(MapRenderTransform!=-1)
|
||||||
|
@ -1,8 +1,37 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file mapgraphicitem.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
* @brief The main graphicsItem used on the widget, contains the map and map logic
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup OPMapWidget
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
#ifndef MAPGRAPHICITEM_H
|
#ifndef MAPGRAPHICITEM_H
|
||||||
#define MAPGRAPHICITEM_H
|
#define MAPGRAPHICITEM_H
|
||||||
|
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include "../internals/core.h"
|
#include "../internals/core.h"
|
||||||
|
//#include "../internals/point.h"
|
||||||
|
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QTransform>
|
#include <QTransform>
|
||||||
@ -10,79 +39,160 @@
|
|||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include "waypointitem.h"
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
class OPMapWidget;
|
class OPMapWidget;
|
||||||
class MapGraphicItem:public QObject,public QGraphicsItem
|
/**
|
||||||
{
|
* @brief The main graphicsItem used on the widget, contains the map and map logic
|
||||||
friend class mapcontrol::OPMapWidget;
|
*
|
||||||
Q_OBJECT
|
* @class MapGraphicItem mapgraphicitem.h "mapgraphicitem.h"
|
||||||
Q_INTERFACES(QGraphicsItem)
|
*/
|
||||||
public:
|
class MapGraphicItem:public QObject,public QGraphicsItem
|
||||||
MapGraphicItem(internals::Core *core,Configuration *configuration);
|
{
|
||||||
QRectF boundingRect() const;
|
friend class mapcontrol::OPMapWidget;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
Q_OBJECT
|
||||||
QWidget *widget);
|
Q_INTERFACES(QGraphicsItem)
|
||||||
|
public:
|
||||||
QSize sizeHint()const;
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
/**
|
||||||
void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
|
* @brief Contructer
|
||||||
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
*
|
||||||
void wheelEvent ( QGraphicsSceneWheelEvent * event );
|
* @param core
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
* @param configuration the configuration to be used
|
||||||
bool IsMouseOverMarker()const{return isMouseOverMarker;}
|
* @return
|
||||||
bool IsDragging()const{return core->IsDragging();}
|
*/
|
||||||
int ZoomStep()const;
|
MapGraphicItem(internals::Core *core,Configuration *configuration);
|
||||||
void SetZoomStep(int const& value);
|
QRectF boundingRect() const;
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget);
|
||||||
|
|
||||||
private:
|
QSize sizeHint()const;
|
||||||
|
/**
|
||||||
|
* @brief Convertes LatLong coordinates to local item coordinates
|
||||||
|
*
|
||||||
|
* @param point LatLong point to be converted
|
||||||
|
* @return core::Point Local item point
|
||||||
|
*/
|
||||||
|
core::Point FromLatLngToLocal(internals::PointLatLng const& point);
|
||||||
|
/**
|
||||||
|
* @brief Converts from local item coordinates to LatLong point
|
||||||
|
*
|
||||||
|
* @param x x local coordinate
|
||||||
|
* @param y y local coordinate
|
||||||
|
* @return internals::PointLatLng LatLng coordinate
|
||||||
|
*/
|
||||||
|
internals::PointLatLng FromLocalToLatLng(int x, int y);
|
||||||
|
/**
|
||||||
|
* @brief Returns true if map is being dragged
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool IsDragging()const{return core->IsDragging();}
|
||||||
|
|
||||||
internals::Core *core;
|
protected:
|
||||||
Configuration *config;
|
void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
bool showTileGridLines;
|
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
qreal MapRenderTransform;
|
void wheelEvent ( QGraphicsSceneWheelEvent * event );
|
||||||
void DrawMap2D(QPainter *painter);
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
///
|
bool IsMouseOverMarker()const{return isMouseOverMarker;}
|
||||||
// QFont MissingDataFont;
|
|
||||||
///
|
|
||||||
int maxZoom;
|
|
||||||
int minZoom;
|
|
||||||
internals::RectLatLng selectedArea;
|
|
||||||
internals::PointLatLng selectionStart;
|
|
||||||
internals::PointLatLng selectionEnd;
|
|
||||||
double zoomReal;
|
|
||||||
QRectF maprect;
|
|
||||||
bool isSelected;
|
|
||||||
bool isMouseOverMarker;
|
|
||||||
void SetIsMouseOverMarker(bool const& value){isMouseOverMarker = value;}
|
|
||||||
internals::PointLatLng FromLocalToLatLng(int x, int y);
|
|
||||||
qreal rotation;
|
|
||||||
QRectF boundingBox(QRectF const& rect, qreal const& angle);
|
|
||||||
int MaxZoom()const{return maxZoom;}
|
|
||||||
int MinZoom()const{return minZoom;}
|
|
||||||
internals::MouseWheelZoomType::Types GetMouseWheelZoomType(){return core->GetMouseWheelZoomType();}
|
|
||||||
void SetSelectedArea(internals::RectLatLng const& value){selectedArea = value;this->update();}
|
|
||||||
internals::RectLatLng BoundsOfMap;
|
|
||||||
void Offset(int const& x, int const& y);
|
|
||||||
bool CanDragMap()const{return core->CanDragMap;}
|
|
||||||
void SetCanDragMap(bool const& value){core->CanDragMap = value;}
|
|
||||||
double Zoom();
|
|
||||||
void SetZoom(double const& value);
|
|
||||||
void mapRotate ( qreal angle );
|
|
||||||
void start();
|
|
||||||
void ReloadMap(){core->ReloadMap();}
|
|
||||||
GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const& keys){return core->SetCurrentPositionByKeywords(keys);}
|
|
||||||
MapType::Types GetMapType(){return core->GetMapType();}
|
|
||||||
void SetMapType(MapType::Types const& value){core->SetMapType(value);}
|
|
||||||
|
|
||||||
private slots:
|
/**
|
||||||
void Core_OnNeedInvalidation();
|
* @brief Returns current map zoom
|
||||||
public slots:
|
*
|
||||||
void resize ( QRectF const &rect=QRectF() );
|
* @return int Current map zoom
|
||||||
signals:
|
*/
|
||||||
void zoomChanged(double zoom);
|
int ZoomStep()const;
|
||||||
};
|
/**
|
||||||
|
* @brief Sets map zoom
|
||||||
|
*
|
||||||
|
* @param value zoom value
|
||||||
|
*/
|
||||||
|
void SetZoomStep(int const& value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
internals::Core *core;
|
||||||
|
Configuration *config;
|
||||||
|
bool showTileGridLines;
|
||||||
|
qreal MapRenderTransform;
|
||||||
|
void DrawMap2D(QPainter *painter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Maximum possible zoom
|
||||||
|
*
|
||||||
|
* @var maxZoom
|
||||||
|
*/
|
||||||
|
int maxZoom;
|
||||||
|
/**
|
||||||
|
* @brief Minimum possible zoom
|
||||||
|
*
|
||||||
|
* @var minZoom
|
||||||
|
*/
|
||||||
|
int minZoom;
|
||||||
|
internals::RectLatLng selectedArea;
|
||||||
|
internals::PointLatLng selectionStart;
|
||||||
|
internals::PointLatLng selectionEnd;
|
||||||
|
double zoomReal;
|
||||||
|
QRectF maprect;
|
||||||
|
bool isSelected;
|
||||||
|
bool isMouseOverMarker;
|
||||||
|
void SetIsMouseOverMarker(bool const& value){isMouseOverMarker = value;}
|
||||||
|
|
||||||
|
qreal rotation;
|
||||||
|
/**
|
||||||
|
* @brief Creates a rectangle that represents the "view" of the cuurent map, to compensate
|
||||||
|
* rotation
|
||||||
|
*
|
||||||
|
* @param rect original rectangle
|
||||||
|
* @param angle angle of rotation
|
||||||
|
* @return QRectF
|
||||||
|
*/
|
||||||
|
QRectF boundingBox(QRectF const& rect, qreal const& angle);
|
||||||
|
/**
|
||||||
|
* @brief Returns the maximum allowed zoom
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
int MaxZoom()const{return maxZoom;}
|
||||||
|
/**
|
||||||
|
* @brief Returns the minimum allowed zoom
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
int MinZoom()const{return minZoom;}
|
||||||
|
internals::MouseWheelZoomType::Types GetMouseWheelZoomType(){return core->GetMouseWheelZoomType();}
|
||||||
|
void SetSelectedArea(internals::RectLatLng const& value){selectedArea = value;this->update();}
|
||||||
|
internals::RectLatLng BoundsOfMap;
|
||||||
|
void Offset(int const& x, int const& y);
|
||||||
|
bool CanDragMap()const{return core->CanDragMap;}
|
||||||
|
void SetCanDragMap(bool const& value){core->CanDragMap = value;}
|
||||||
|
double Zoom();
|
||||||
|
void SetZoom(double const& value);
|
||||||
|
void mapRotate ( qreal angle );
|
||||||
|
void start();
|
||||||
|
void ReloadMap(){core->ReloadMap();}
|
||||||
|
GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const& keys){return core->SetCurrentPositionByKeywords(keys);}
|
||||||
|
MapType::Types GetMapType(){return core->GetMapType();}
|
||||||
|
void SetMapType(MapType::Types const& value){core->SetMapType(value);}
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void Core_OnNeedInvalidation();
|
||||||
|
public slots:
|
||||||
|
/**
|
||||||
|
* @brief To be called when the scene size changes
|
||||||
|
*
|
||||||
|
* @param rect
|
||||||
|
*/
|
||||||
|
void resize ( QRectF const &rect=QRectF() );
|
||||||
|
signals:
|
||||||
|
/**
|
||||||
|
* @brief Fired when the current zoom is changed
|
||||||
|
*
|
||||||
|
* @param zoom
|
||||||
|
*/
|
||||||
|
void zoomChanged(double zoom);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
#endif // MAPGRAPHICITEM_H
|
#endif // MAPGRAPHICITEM_H
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/markers">
|
||||||
|
<file>images/bigMarkerGreen.png</file>
|
||||||
|
<file>images/marker.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
@ -3,17 +3,20 @@ TARGET = opmapwidget
|
|||||||
DEFINES += OPMAPWIDGET_LIBRARY
|
DEFINES += OPMAPWIDGET_LIBRARY
|
||||||
include(../../../../openpilotgcslibrary.pri)
|
include(../../../../openpilotgcslibrary.pri)
|
||||||
|
|
||||||
#DESTDIR = ../build
|
# DESTDIR = ../build
|
||||||
SOURCES += mapgraphicitem.cpp \
|
SOURCES += mapgraphicitem.cpp \
|
||||||
opmapwidget.cpp \
|
opmapwidget.cpp \
|
||||||
configuration.cpp
|
configuration.cpp \
|
||||||
|
waypointitem.cpp
|
||||||
LIBS += -L../build \
|
LIBS += -L../build \
|
||||||
-lcore \
|
-lcore \
|
||||||
-linternals \
|
-linternals \
|
||||||
-lcore
|
-lcore
|
||||||
HEADERS += mapgraphicitem.h \
|
HEADERS += mapgraphicitem.h \
|
||||||
opmapwidget.h \
|
opmapwidget.h \
|
||||||
configuration.h
|
configuration.h \
|
||||||
|
waypointitem.h
|
||||||
QT += opengl
|
QT += opengl
|
||||||
QT += network
|
QT += network
|
||||||
QT += sql
|
QT += sql
|
||||||
|
RESOURCES += mapresources.qrc
|
||||||
|
@ -1,33 +1,51 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file opmapwidget.cpp
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
* @brief The Map Widget, this is the part exposed to the user
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup OPMapWidget
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
#include "opmapwidget.h"
|
#include "opmapwidget.h"
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
|
#include "waypointitem.h"
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
// OPMapWidget::OPMapWidget(QWidget *parent):QGraphicsView(parent),useOpenGL(false)
|
|
||||||
// {
|
|
||||||
// setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
||||||
//
|
|
||||||
// core=new internals::Core;
|
|
||||||
// map=new MapGraphicItem(core);
|
|
||||||
// //text.setZValue(20);
|
|
||||||
// //QGraphicsTextItem *t=new QGraphicsTextItem(map);
|
|
||||||
// // t->setPos(10,10);
|
|
||||||
// mscene.addItem(map);
|
|
||||||
// map->setZValue(-1);
|
|
||||||
// //t->setZValue(10);
|
|
||||||
// this->setScene(&mscene);
|
|
||||||
// this->adjustSize();
|
|
||||||
// // t->setFlag(QGraphicsItem::ItemIsMovable,true);
|
|
||||||
// connect(&mscene,SIGNAL(sceneRectChanged(QRectF)),map,SLOT(resize(QRectF)));
|
|
||||||
// connect(map,SIGNAL(zoomChanged(double)),this,SIGNAL(zoomChanged(double)));
|
|
||||||
// }
|
|
||||||
OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config):QGraphicsView(parent),configuration(config),followmouse(true)
|
OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config):QGraphicsView(parent),configuration(config),followmouse(true)
|
||||||
{
|
{
|
||||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||||
core=new internals::Core;
|
core=new internals::Core;
|
||||||
map=new MapGraphicItem(core,config);
|
map=new MapGraphicItem(core,config);
|
||||||
mscene.addItem(map);
|
mscene.addItem(map);
|
||||||
map->setZValue(-1);
|
// WayPointItem* item2=new WayPointItem(internals::PointLatLng(20,20),100,map);
|
||||||
|
// item2->setParentItem(map);
|
||||||
|
// item=new WayPointItem(internals::PointLatLng(30,30),30,"kkk",map);
|
||||||
|
// item->setParentItem(map);
|
||||||
|
// item->setZValue(-2);
|
||||||
|
|
||||||
|
// map->setZValue(-1);
|
||||||
this->setScene(&mscene);
|
this->setScene(&mscene);
|
||||||
this->adjustSize();
|
this->adjustSize();
|
||||||
connect(&mscene,SIGNAL(sceneRectChanged(QRectF)),map,SLOT(resize(QRectF)));
|
connect(&mscene,SIGNAL(sceneRectChanged(QRectF)),map,SLOT(resize(QRectF)));
|
||||||
@ -64,6 +82,10 @@ namespace mapcontrol
|
|||||||
delete map;
|
delete map;
|
||||||
delete core;
|
delete core;
|
||||||
delete configuration;
|
delete configuration;
|
||||||
|
foreach(QGraphicsItem* i,this->items())
|
||||||
|
{
|
||||||
|
delete i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void OPMapWidget::closeEvent(QCloseEvent *event)
|
void OPMapWidget::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
@ -90,5 +112,107 @@ namespace mapcontrol
|
|||||||
p=map->mapFromParent(p);
|
p=map->mapFromParent(p);
|
||||||
currentmouseposition=map->FromLocalToLatLng(p.x(),p.y());
|
currentmouseposition=map->FromLocalToLatLng(p.x(),p.y());
|
||||||
}
|
}
|
||||||
|
////////////////WAYPOINT////////////////////////
|
||||||
|
WayPointItem* OPMapWidget::WPCreate()
|
||||||
|
{
|
||||||
|
WayPointItem* item=new WayPointItem(this->CurrentPosition(),0,map);
|
||||||
|
ConnectWP(item);
|
||||||
|
item->setParentItem(map);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
void OPMapWidget::WPCreate(WayPointItem* item)
|
||||||
|
{
|
||||||
|
ConnectWP(item);
|
||||||
|
item->setParentItem(map);
|
||||||
|
}
|
||||||
|
WayPointItem* OPMapWidget::WPCreate(internals::PointLatLng const& coord,int const& altitude)
|
||||||
|
{
|
||||||
|
WayPointItem* item=new WayPointItem(coord,altitude,map);
|
||||||
|
ConnectWP(item);
|
||||||
|
item->setParentItem(map);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
WayPointItem* OPMapWidget::WPCreate(internals::PointLatLng const& coord,int const& altitude, QString const& description)
|
||||||
|
{
|
||||||
|
WayPointItem* item=new WayPointItem(coord,altitude,description,map);
|
||||||
|
ConnectWP(item);
|
||||||
|
item->setParentItem(map);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
WayPointItem* OPMapWidget::WPInsert(const int &position)
|
||||||
|
{
|
||||||
|
WayPointItem* item=new WayPointItem(this->CurrentPosition(),0,map);
|
||||||
|
item->SetNumber(position);
|
||||||
|
ConnectWP(item);
|
||||||
|
item->setParentItem(map);
|
||||||
|
emit WPInserted(position,item);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
void OPMapWidget::WPInsert(WayPointItem* item,const int &position)
|
||||||
|
{
|
||||||
|
item->SetNumber(position);
|
||||||
|
ConnectWP(item);
|
||||||
|
item->setParentItem(map);
|
||||||
|
emit WPInserted(position,item);
|
||||||
|
|
||||||
|
}
|
||||||
|
WayPointItem* OPMapWidget::WPInsert(internals::PointLatLng const& coord,int const& altitude,const int &position)
|
||||||
|
{
|
||||||
|
WayPointItem* item=new WayPointItem(coord,altitude,map);
|
||||||
|
item->SetNumber(position);
|
||||||
|
ConnectWP(item);
|
||||||
|
item->setParentItem(map);
|
||||||
|
emit WPInserted(position,item);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
WayPointItem* OPMapWidget::WPInsert(internals::PointLatLng const& coord,int const& altitude, QString const& description,const int &position)
|
||||||
|
{
|
||||||
|
WayPointItem* item=new WayPointItem(coord,altitude,description,map);
|
||||||
|
item->SetNumber(position);
|
||||||
|
ConnectWP(item);
|
||||||
|
item->setParentItem(map);
|
||||||
|
emit WPInserted(position,item);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
void OPMapWidget::WPDelete(WayPointItem *item)
|
||||||
|
{
|
||||||
|
emit WPDeleted(item->Number());
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
void OPMapWidget::WPDeleteAll()
|
||||||
|
{
|
||||||
|
foreach(QGraphicsItem* i,map->childItems())
|
||||||
|
{
|
||||||
|
WayPointItem* w=qgraphicsitem_cast<WayPointItem*>(i);
|
||||||
|
if(w)
|
||||||
|
delete w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QList<WayPointItem*> OPMapWidget::WPSelected()
|
||||||
|
{
|
||||||
|
QList<WayPointItem*> list;
|
||||||
|
foreach(QGraphicsItem* i,mscene.selectedItems())
|
||||||
|
{
|
||||||
|
WayPointItem* w=qgraphicsitem_cast<WayPointItem*>(i);
|
||||||
|
if(w)
|
||||||
|
list.append(w);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
void OPMapWidget::WPRenumber(WayPointItem *item, const int &newnumber)
|
||||||
|
{
|
||||||
|
item->SetNumber(newnumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OPMapWidget::ConnectWP(WayPointItem *item)
|
||||||
|
{
|
||||||
|
connect(item,SIGNAL(WPNumberChanged(int,int,WayPointItem*)),this,SIGNAL(WPNumberChanged(int,int,WayPointItem*)));
|
||||||
|
connect(item,SIGNAL(WPValuesChanged(WayPointItem*)),this,SIGNAL(WPValuesChanged(WayPointItem*)));
|
||||||
|
connect(this,SIGNAL(WPInserted(int,WayPointItem*)),item,SLOT(WPInserted(int,WayPointItem*)));
|
||||||
|
connect(this,SIGNAL(WPNumberChanged(int,int,WayPointItem*)),item,SLOT(WPRenumbered(int,int,WayPointItem*)));
|
||||||
|
connect(this,SIGNAL(WPDeleted(int)),item,SLOT(WPDeleted(int)));
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,30 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file opmapwidget.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
* @brief The Map Widget, this is the part exposed to the user
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup OPMapWidget
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
#ifndef OPMAPWIDGET_H
|
#ifndef OPMAPWIDGET_H
|
||||||
#define OPMAPWIDGET_H
|
#define OPMAPWIDGET_H
|
||||||
|
|
||||||
@ -8,30 +35,82 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QtOpenGL/QGLWidget>
|
#include <QtOpenGL/QGLWidget>
|
||||||
|
#include "waypointitem.h"
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @brief Collection of static functions to help dealing with various enums used
|
||||||
|
* Contains functions for enumToString conversio, StringToEnum, QStringList of enum values...
|
||||||
|
*
|
||||||
|
* @class Helper opmapwidget.h "opmapwidget.h"
|
||||||
|
*/
|
||||||
class Helper
|
class Helper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Converts from String to Type
|
||||||
|
*
|
||||||
|
* @param value String to convert
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
static MapType::Types MapTypeFromString(QString const& value){return MapType::TypeByStr(value);}
|
static MapType::Types MapTypeFromString(QString const& value){return MapType::TypeByStr(value);}
|
||||||
|
/**
|
||||||
|
* @brief Converts from Type to String
|
||||||
|
*/
|
||||||
static QString StrFromMapType(MapType::Types const& value){return MapType::StrByType(value);}
|
static QString StrFromMapType(MapType::Types const& value){return MapType::StrByType(value);}
|
||||||
|
/**
|
||||||
|
* @brief Returns QStringList with string representing all the enum values
|
||||||
|
*/
|
||||||
static QStringList MapTypes(){return MapType::TypesList();}
|
static QStringList MapTypes(){return MapType::TypesList();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Converts from String to Type
|
||||||
|
*/
|
||||||
static GeoCoderStatusCode::Types GeoCoderStatusCodeFromString(QString const& value){return GeoCoderStatusCode::TypeByStr(value);}
|
static GeoCoderStatusCode::Types GeoCoderStatusCodeFromString(QString const& value){return GeoCoderStatusCode::TypeByStr(value);}
|
||||||
|
/**
|
||||||
|
* @brief Converts from Type to String
|
||||||
|
*/
|
||||||
static QString StrFromGeoCoderStatusCode(GeoCoderStatusCode::Types const& value){return GeoCoderStatusCode::StrByType(value);}
|
static QString StrFromGeoCoderStatusCode(GeoCoderStatusCode::Types const& value){return GeoCoderStatusCode::StrByType(value);}
|
||||||
|
/**
|
||||||
|
* @brief Returns QStringList with string representing all the enum values
|
||||||
|
*/
|
||||||
static QStringList GeoCoderTypes(){return GeoCoderStatusCode::TypesList();}
|
static QStringList GeoCoderTypes(){return GeoCoderStatusCode::TypesList();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Converts from String to Type
|
||||||
|
*/
|
||||||
static internals::MouseWheelZoomType::Types MouseWheelZoomTypeFromString(QString const& value){return internals::MouseWheelZoomType::TypeByStr(value);}
|
static internals::MouseWheelZoomType::Types MouseWheelZoomTypeFromString(QString const& value){return internals::MouseWheelZoomType::TypeByStr(value);}
|
||||||
|
/**
|
||||||
|
* @brief Converts from Type to String
|
||||||
|
*/
|
||||||
static QString StrFromMouseWheelZoomType(internals::MouseWheelZoomType::Types const& value){return internals::MouseWheelZoomType::StrByType(value);}
|
static QString StrFromMouseWheelZoomType(internals::MouseWheelZoomType::Types const& value){return internals::MouseWheelZoomType::StrByType(value);}
|
||||||
|
/**
|
||||||
|
* @brief Returns QStringList with string representing all the enum values
|
||||||
|
*/
|
||||||
static QStringList MouseWheelZoomTypes(){return internals::MouseWheelZoomType::TypesList();}
|
static QStringList MouseWheelZoomTypes(){return internals::MouseWheelZoomType::TypesList();}
|
||||||
|
/**
|
||||||
|
* @brief Converts from String to Type
|
||||||
|
*/
|
||||||
static core::LanguageType::Types LanguageTypeFromString(QString const& value){return core::LanguageType::TypeByStr(value);}
|
static core::LanguageType::Types LanguageTypeFromString(QString const& value){return core::LanguageType::TypeByStr(value);}
|
||||||
|
/**
|
||||||
|
* @brief Converts from Type to String
|
||||||
|
*/
|
||||||
static QString StrFromLanguageType(core::LanguageType::Types const& value){return core::LanguageType::StrByType(value);}
|
static QString StrFromLanguageType(core::LanguageType::Types const& value){return core::LanguageType::StrByType(value);}
|
||||||
|
/**
|
||||||
|
* @brief Returns QStringList with string representing all the enum values
|
||||||
|
*/
|
||||||
static QStringList LanguageTypes(){return core::LanguageType::TypesList();}
|
static QStringList LanguageTypes(){return core::LanguageType::TypesList();}
|
||||||
|
/**
|
||||||
|
* @brief Converts from String to Type
|
||||||
|
*/
|
||||||
static core::AccessMode::Types AccessModeFromString(QString const& value){return core::AccessMode::TypeByStr(value);}
|
static core::AccessMode::Types AccessModeFromString(QString const& value){return core::AccessMode::TypeByStr(value);}
|
||||||
|
/**
|
||||||
|
* @brief Converts from Type to String
|
||||||
|
*/
|
||||||
static QString StrFromAccessMode(core::AccessMode::Types const& value){return core::AccessMode::StrByType(value);}
|
static QString StrFromAccessMode(core::AccessMode::Types const& value){return core::AccessMode::StrByType(value);}
|
||||||
|
/**
|
||||||
|
* @brief Returns QStringList with string representing all the enum values
|
||||||
|
*/
|
||||||
static QStringList AccessModeTypes(){return core::AccessMode::TypesList();}
|
static QStringList AccessModeTypes(){return core::AccessMode::TypesList();}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -41,8 +120,6 @@ namespace mapcontrol
|
|||||||
|
|
||||||
Q_PROPERTY(int MaxZoom READ MaxZoom WRITE SetMaxZoom)
|
Q_PROPERTY(int MaxZoom READ MaxZoom WRITE SetMaxZoom)
|
||||||
Q_PROPERTY(int MinZoom READ MinZoom WRITE SetMinZoom)
|
Q_PROPERTY(int MinZoom READ MinZoom WRITE SetMinZoom)
|
||||||
// Q_PROPERTY(internals::MouseWheelZoomType::Types MouseWheelZoom READ GetMouseWheelZoomType WRITE SetMouseWheelZoomType)
|
|
||||||
// Q_PROPERTY(QString MouseWheelZoomStr READ GetMouseWheelZoomTypeStr WRITE SetMouseWheelZoomTypeByStr)
|
|
||||||
Q_PROPERTY(bool ShowTileGridLines READ ShowTileGridLines WRITE SetShowTileGridLines)
|
Q_PROPERTY(bool ShowTileGridLines READ ShowTileGridLines WRITE SetShowTileGridLines)
|
||||||
Q_PROPERTY(double Zoom READ Zoom WRITE SetZoom)
|
Q_PROPERTY(double Zoom READ Zoom WRITE SetZoom)
|
||||||
Q_PROPERTY(qreal Rotate READ Rotate WRITE SetRotate)
|
Q_PROPERTY(qreal Rotate READ Rotate WRITE SetRotate)
|
||||||
@ -51,22 +128,55 @@ namespace mapcontrol
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
QSize sizeHint() const;
|
QSize sizeHint() const;
|
||||||
|
/**
|
||||||
|
* @brief Constructor
|
||||||
|
*
|
||||||
|
* @param parent parent widget
|
||||||
|
* @param config pointer to configuration classed to be used
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
OPMapWidget(QWidget *parent=0,Configuration *config=new Configuration);
|
OPMapWidget(QWidget *parent=0,Configuration *config=new Configuration);
|
||||||
~OPMapWidget();
|
~OPMapWidget();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns true if map is showing gridlines
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
bool ShowTileGridLines()const {return map->showTileGridLines;}
|
bool ShowTileGridLines()const {return map->showTileGridLines;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Defines if map is to show gridlines
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
void SetShowTileGridLines(bool const& value){map->showTileGridLines=value;map->update();}
|
void SetShowTileGridLines(bool const& value){map->showTileGridLines=value;map->update();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the maximum zoom for the map
|
||||||
|
*
|
||||||
|
*/
|
||||||
int MaxZoom()const{return map->maxZoom;}
|
int MaxZoom()const{return map->maxZoom;}
|
||||||
|
|
||||||
void SetMaxZoom(int const& value){map->maxZoom = value;}
|
void SetMaxZoom(int const& value){map->maxZoom = value;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
*
|
||||||
|
*/
|
||||||
int MinZoom()const{return map->minZoom;}
|
int MinZoom()const{return map->minZoom;}
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
void SetMinZoom(int const& value){map->minZoom = value;}
|
void SetMinZoom(int const& value){map->minZoom = value;}
|
||||||
|
|
||||||
internals::MouseWheelZoomType::Types GetMouseWheelZoomType(){return map->core->GetMouseWheelZoomType();}
|
internals::MouseWheelZoomType::Types GetMouseWheelZoomType(){return map->core->GetMouseWheelZoomType();}
|
||||||
void SetMouseWheelZoomType(internals::MouseWheelZoomType::Types const& value){map->core->SetMouseWheelZoomType(value);}
|
void SetMouseWheelZoomType(internals::MouseWheelZoomType::Types const& value){map->core->SetMouseWheelZoomType(value);}
|
||||||
// void SetMouseWheelZoomTypeByStr(const QString &value){map->core->SetMouseWheelZoomType(internals::MouseWheelZoomType::TypeByStr(value));}
|
// void SetMouseWheelZoomTypeByStr(const QString &value){map->core->SetMouseWheelZoomType(internals::MouseWheelZoomType::TypeByStr(value));}
|
||||||
// QString GetMouseWheelZoomTypeStr(){return map->GetMouseWheelZoomTypeStr();}
|
// QString GetMouseWheelZoomTypeStr(){return map->GetMouseWheelZoomTypeStr();}
|
||||||
|
|
||||||
internals::RectLatLng SelectedArea()const{return map->selectedArea;}
|
internals::RectLatLng SelectedArea()const{return map->selectedArea;}
|
||||||
void SetSelectedArea(internals::RectLatLng const& value){ map->selectedArea = value;this->update();}
|
void SetSelectedArea(internals::RectLatLng const& value){ map->selectedArea = value;this->update();}
|
||||||
@ -102,6 +212,95 @@ namespace mapcontrol
|
|||||||
void SetFollowMouse(bool const& value){followmouse=value;this->setMouseTracking(followmouse);}
|
void SetFollowMouse(bool const& value){followmouse=value;this->setMouseTracking(followmouse);}
|
||||||
bool FollowMouse(){return followmouse;}
|
bool FollowMouse(){return followmouse;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Creates a new WayPoint on the center of the map
|
||||||
|
*
|
||||||
|
* @return WayPointItem a pointer to the WayPoint created
|
||||||
|
*/
|
||||||
|
WayPointItem* WPCreate();
|
||||||
|
/**
|
||||||
|
* @brief Creates a new WayPoint
|
||||||
|
*
|
||||||
|
* @param item the WayPoint to create
|
||||||
|
*/
|
||||||
|
void WPCreate(WayPointItem* item);
|
||||||
|
/**
|
||||||
|
* @brief Creates a new WayPoint
|
||||||
|
*
|
||||||
|
* @param coord the coordinates in LatLng of the WayPoint
|
||||||
|
* @param altitude the Altitude of the WayPoint
|
||||||
|
* @return WayPointItem a pointer to the WayPoint created
|
||||||
|
*/
|
||||||
|
WayPointItem* WPCreate(internals::PointLatLng const& coord,int const& altitude);
|
||||||
|
/**
|
||||||
|
* @brief Creates a new WayPoint
|
||||||
|
*
|
||||||
|
* @param coord the coordinates in LatLng of the WayPoint
|
||||||
|
* @param altitude the Altitude of the WayPoint
|
||||||
|
* @param description the description of the WayPoint
|
||||||
|
* @return WayPointItem a pointer to the WayPoint created
|
||||||
|
*/
|
||||||
|
WayPointItem* WPCreate(internals::PointLatLng const& coord,int const& altitude, QString const& description);
|
||||||
|
/**
|
||||||
|
* @brief Inserts a new WayPoint on the specified position
|
||||||
|
*
|
||||||
|
* @param position index of the WayPoint
|
||||||
|
* @return WayPointItem a pointer to the WayPoint created
|
||||||
|
*/
|
||||||
|
WayPointItem* WPInsert(int const& position);
|
||||||
|
/**
|
||||||
|
* @brief Inserts a new WayPoint on the specified position
|
||||||
|
*
|
||||||
|
* @param item the WayPoint to Insert
|
||||||
|
* @param position index of the WayPoint
|
||||||
|
*/
|
||||||
|
void WPInsert(WayPointItem* item,int const& position);
|
||||||
|
/**
|
||||||
|
* @brief Inserts a new WayPoint on the specified position
|
||||||
|
*
|
||||||
|
* @param coord the coordinates in LatLng of the WayPoint
|
||||||
|
* @param altitude the Altitude of the WayPoint
|
||||||
|
* @param position index of the WayPoint
|
||||||
|
* @return WayPointItem a pointer to the WayPoint Inserted
|
||||||
|
*/
|
||||||
|
WayPointItem* WPInsert(internals::PointLatLng const& coord,int const& altitude,int const& position);
|
||||||
|
/**
|
||||||
|
* @brief Inserts a new WayPoint on the specified position
|
||||||
|
*
|
||||||
|
* @param coord the coordinates in LatLng of the WayPoint
|
||||||
|
* @param altitude the Altitude of the WayPoint
|
||||||
|
* @param description the description of the WayPoint
|
||||||
|
* @param position index of the WayPoint
|
||||||
|
* @return WayPointItem a pointer to the WayPoint Inserted
|
||||||
|
*/
|
||||||
|
WayPointItem* WPInsert(internals::PointLatLng const& coord,int const& altitude, QString const& description,int const& position);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Deletes the WayPoint
|
||||||
|
*
|
||||||
|
* @param item the WayPoint to delete
|
||||||
|
*/
|
||||||
|
void WPDelete(WayPointItem* item);
|
||||||
|
/**
|
||||||
|
* @brief deletes all WayPoints
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void WPDeleteAll();
|
||||||
|
/**
|
||||||
|
* @brief Returns the currently selected WayPoints
|
||||||
|
*
|
||||||
|
* @return @return QList<WayPointItem *>
|
||||||
|
*/
|
||||||
|
QList<WayPointItem*> WPSelected();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Renumbers the WayPoint and all others as needed
|
||||||
|
*
|
||||||
|
* @param item the WayPoint to renumber
|
||||||
|
* @param newnumber the WayPoint's new number
|
||||||
|
*/
|
||||||
|
void WPRenumber(WayPointItem* item,int const& newnumber);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
internals::Core *core;
|
internals::Core *core;
|
||||||
MapGraphicItem *map;
|
MapGraphicItem *map;
|
||||||
@ -112,25 +311,91 @@ namespace mapcontrol
|
|||||||
core::AccessMode xx;
|
core::AccessMode xx;
|
||||||
internals::PointLatLng currentmouseposition;
|
internals::PointLatLng currentmouseposition;
|
||||||
bool followmouse;
|
bool followmouse;
|
||||||
|
void ConnectWP(WayPointItem* item);
|
||||||
|
|
||||||
|
WayPointItem* item;//apagar
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
void showEvent ( QShowEvent * event );
|
void showEvent ( QShowEvent * event );
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
void mouseMoveEvent ( QMouseEvent * event );
|
void mouseMoveEvent ( QMouseEvent * event );
|
||||||
// private slots:
|
// private slots:
|
||||||
signals:
|
|
||||||
void zoomChanged(double zoom);
|
|
||||||
signals:
|
signals:
|
||||||
|
void zoomChanged(double zoom);
|
||||||
|
/**
|
||||||
|
* @brief fires when one of the WayPoints numbers changes (not fired if due to a auto-renumbering)
|
||||||
|
*
|
||||||
|
* @param oldnumber WayPoint old number
|
||||||
|
* @param newnumber WayPoint new number
|
||||||
|
* @param waypoint a pointer to the WayPoint that was renumbered
|
||||||
|
*/
|
||||||
|
void WPNumberChanged(int const& oldnumber,int const& newnumber,WayPointItem* waypoint);
|
||||||
|
/**
|
||||||
|
* @brief Fired when the description, altitude or coordinates of a WayPoint changed
|
||||||
|
*
|
||||||
|
* @param waypoint a pointer to the WayPoint
|
||||||
|
*/
|
||||||
|
void WPValuesChanged(WayPointItem* waypoint);
|
||||||
|
/**
|
||||||
|
* @brief Fires when a new WayPoint is inserted
|
||||||
|
*
|
||||||
|
* @param number new WayPoint number
|
||||||
|
* @param waypoint WayPoint inserted
|
||||||
|
*/
|
||||||
|
void WPInserted(int const& number,WayPointItem* waypoint);
|
||||||
|
/**
|
||||||
|
* @brief Fires When a WayPoint is deleted
|
||||||
|
*
|
||||||
|
* @param number number of the deleted WayPoint
|
||||||
|
*/
|
||||||
|
void WPDeleted(int const& number);
|
||||||
|
/**
|
||||||
|
* @brief Fires when map position changes
|
||||||
|
*
|
||||||
|
* @param point the point in LatLng of the new center of the map
|
||||||
|
*/
|
||||||
void OnCurrentPositionChanged(internals::PointLatLng point);
|
void OnCurrentPositionChanged(internals::PointLatLng point);
|
||||||
|
/**
|
||||||
|
* @brief Fires when there are no more tiles to load
|
||||||
|
*
|
||||||
|
*/
|
||||||
void OnTileLoadComplete();
|
void OnTileLoadComplete();
|
||||||
|
/**
|
||||||
|
* @brief Fires when tiles loading begins
|
||||||
|
*
|
||||||
|
*/
|
||||||
void OnTileLoadStart();
|
void OnTileLoadStart();
|
||||||
|
/**
|
||||||
|
* @brief Fires when the map is dragged
|
||||||
|
*
|
||||||
|
*/
|
||||||
void OnMapDrag();
|
void OnMapDrag();
|
||||||
|
/**
|
||||||
|
* @brief Fires when map zoom changes
|
||||||
|
*
|
||||||
|
*/
|
||||||
void OnMapZoomChanged();
|
void OnMapZoomChanged();
|
||||||
|
/**
|
||||||
|
* @brief Fires when map type changes
|
||||||
|
*
|
||||||
|
* @param type The maps new type
|
||||||
|
*/
|
||||||
void OnMapTypeChanged(MapType::Types type);
|
void OnMapTypeChanged(MapType::Types type);
|
||||||
|
/**
|
||||||
|
* @brief Fires when an error ocurred while loading a tile
|
||||||
|
*
|
||||||
|
* @param zoom tile zoom
|
||||||
|
* @param pos tile position
|
||||||
|
*/
|
||||||
void OnEmptyTileError(int zoom, core::Point pos);
|
void OnEmptyTileError(int zoom, core::Point pos);
|
||||||
|
/**
|
||||||
|
* @brief Fires when the number of tiles in the load queue changes
|
||||||
|
*
|
||||||
|
* @param number the number of tiles still in the queue
|
||||||
|
*/
|
||||||
void OnTilesStillToLoad(int number);
|
void OnTilesStillToLoad(int number);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // OPMAPWIDGET_H
|
#endif // OPMAPWIDGET_H
|
||||||
|
237
ground/src/libs/opmapcontrol/src/mapwidget/waypointitem.cpp
Normal file
237
ground/src/libs/opmapcontrol/src/mapwidget/waypointitem.cpp
Normal file
@ -0,0 +1,237 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file waypointitem.cpp
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
* @brief A graphicsItem representing a WayPoint
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup OPMapWidget
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#include "waypointitem.h"
|
||||||
|
namespace mapcontrol
|
||||||
|
{
|
||||||
|
WayPointItem::WayPointItem(const internals::PointLatLng &coord,int const& altitude, MapGraphicItem *map):coord(coord),reached(false),map(map),description(""),shownumber(true),isDragging(false),altitude(altitude)
|
||||||
|
{
|
||||||
|
text=0;
|
||||||
|
numberI=0;
|
||||||
|
picture.load(QString::fromUtf8(":/markers/images/marker.png"));
|
||||||
|
RefreshToolTip();
|
||||||
|
number=WayPointItem::snumber;
|
||||||
|
++WayPointItem::snumber;
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsMovable,true);
|
||||||
|
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsSelectable,true);
|
||||||
|
transf.translate(picture.width()/2,picture.height());
|
||||||
|
this->setTransform(transf);
|
||||||
|
SetShowNumber(shownumber);
|
||||||
|
RefreshPos();
|
||||||
|
|
||||||
|
}
|
||||||
|
WayPointItem::WayPointItem(const internals::PointLatLng &coord,int const& altitude, const QString &description, MapGraphicItem *map):coord(coord),reached(false),map(map),description(description),shownumber(true),isDragging(false),altitude(altitude)
|
||||||
|
{
|
||||||
|
text=0;
|
||||||
|
numberI=0;
|
||||||
|
picture.load(QString::fromUtf8(":/markers/images/marker.png"));
|
||||||
|
RefreshToolTip();
|
||||||
|
number=WayPointItem::snumber;
|
||||||
|
++WayPointItem::snumber;
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsMovable,true);
|
||||||
|
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsSelectable,true);
|
||||||
|
transf.translate(picture.width()/2,picture.height());
|
||||||
|
this->setTransform(transf);
|
||||||
|
SetShowNumber(shownumber);
|
||||||
|
RefreshPos();
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF WayPointItem::boundingRect() const
|
||||||
|
{
|
||||||
|
return QRectF(-picture.width()/2,-picture.height(),picture.width(),picture.height());
|
||||||
|
//return QRectF(0,0,50,50);
|
||||||
|
}
|
||||||
|
void WayPointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
// if(!isDragging)
|
||||||
|
// {
|
||||||
|
// core::Point point=map->FromLatLngToLocal(coord);
|
||||||
|
// this->setPos(point.X(),point.Y());
|
||||||
|
// }
|
||||||
|
painter->drawPixmap(-picture.width()/2,-picture.height(),picture);
|
||||||
|
if(this->isSelected())
|
||||||
|
painter->drawRect(QRectF(-picture.width()/2,-picture.height(),picture.width()-1,picture.height()-1));
|
||||||
|
}
|
||||||
|
void WayPointItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
if(event->button()==Qt::LeftButton)
|
||||||
|
{
|
||||||
|
text=new QGraphicsSimpleTextItem(this);
|
||||||
|
text->setPen(QPen(Qt::red));
|
||||||
|
text->setPos(10,-picture.height());
|
||||||
|
RefreshToolTip();
|
||||||
|
isDragging=true;
|
||||||
|
}
|
||||||
|
QGraphicsItem::mousePressEvent(event);
|
||||||
|
}
|
||||||
|
void WayPointItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
if(event->button()==Qt::LeftButton)
|
||||||
|
{
|
||||||
|
delete text;
|
||||||
|
coord=map->FromLocalToLatLng(this->pos().x(),this->pos().y());
|
||||||
|
isDragging=false;
|
||||||
|
RefreshToolTip();
|
||||||
|
}
|
||||||
|
QGraphicsItem::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
void WayPointItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(isDragging)
|
||||||
|
{
|
||||||
|
coord=map->FromLocalToLatLng(this->pos().x(),this->pos().y());
|
||||||
|
QString coord_str = " " + QString::number(coord.Lat(), 'f', 6) + " " + QString::number(coord.Lng(), 'f', 6);
|
||||||
|
text->setText(coord_str);
|
||||||
|
}
|
||||||
|
QGraphicsItem::mouseMoveEvent(event);
|
||||||
|
}
|
||||||
|
void WayPointItem::SetAltitude(const int &value)
|
||||||
|
{
|
||||||
|
altitude=value;
|
||||||
|
RefreshToolTip();
|
||||||
|
|
||||||
|
emit WPValuesChanged(this);
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
void WayPointItem::SetCoord(const internals::PointLatLng &value)
|
||||||
|
{
|
||||||
|
coord=value;
|
||||||
|
emit WPValuesChanged(this);
|
||||||
|
RefreshPos();
|
||||||
|
RefreshToolTip();
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
void WayPointItem::SetDescription(const QString &value)
|
||||||
|
{
|
||||||
|
description=value;
|
||||||
|
RefreshToolTip();
|
||||||
|
emit WPValuesChanged(this);
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
void WayPointItem::SetNumber(const int &value)
|
||||||
|
{
|
||||||
|
emit WPNumberChanged(number,value,this);
|
||||||
|
number=value;
|
||||||
|
RefreshToolTip();
|
||||||
|
numberI->setText(QString::number(number));
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
void WayPointItem::SetReached(const bool &value)
|
||||||
|
{
|
||||||
|
reached=value;
|
||||||
|
emit WPValuesChanged(this);
|
||||||
|
if(value)
|
||||||
|
picture.load(QString::fromUtf8(":/markers/images/bigMarkerGreen.png"));
|
||||||
|
else
|
||||||
|
picture.load(QString::fromUtf8(":/markers/images/marker.png"));
|
||||||
|
this->update();
|
||||||
|
|
||||||
|
}
|
||||||
|
void WayPointItem::SetShowNumber(const bool &value)
|
||||||
|
{
|
||||||
|
shownumber=value;
|
||||||
|
if((numberI==0) && value)
|
||||||
|
{
|
||||||
|
numberI=new QGraphicsSimpleTextItem(this);
|
||||||
|
numberI->setPen(QPen(Qt::blue));
|
||||||
|
numberI->setPos(0,-10-picture.height());
|
||||||
|
numberI->setText(QString::number(number));
|
||||||
|
}
|
||||||
|
else if (!value && numberI)
|
||||||
|
{
|
||||||
|
delete numberI;
|
||||||
|
}
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
void WayPointItem::WPDeleted(const int &onumber)
|
||||||
|
{
|
||||||
|
if(number>onumber) --number;
|
||||||
|
numberI->setText(QString::number(number));
|
||||||
|
RefreshToolTip();
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
void WayPointItem::WPInserted(const int &onumber, WayPointItem *waypoint)
|
||||||
|
{
|
||||||
|
if(waypoint!=this)
|
||||||
|
{
|
||||||
|
if(onumber<=number) ++number;
|
||||||
|
numberI->setText(QString::number(number));
|
||||||
|
RefreshToolTip();
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void WayPointItem::WPRenumbered(const int &oldnumber, const int &newnumber, WayPointItem *waypoint)
|
||||||
|
{
|
||||||
|
if (waypoint!=this)
|
||||||
|
{
|
||||||
|
if(((oldnumber>number) && (newnumber<=number)))
|
||||||
|
{
|
||||||
|
++number;
|
||||||
|
numberI->setText(QString::number(number));
|
||||||
|
RefreshToolTip();
|
||||||
|
}
|
||||||
|
else if (((oldnumber<number) && (newnumber>number)))
|
||||||
|
{
|
||||||
|
--number;
|
||||||
|
numberI->setText(number==0? "0":QString::number(number));
|
||||||
|
RefreshToolTip();
|
||||||
|
}
|
||||||
|
else if (newnumber==number)
|
||||||
|
{
|
||||||
|
++number;
|
||||||
|
numberI->setText(QString::number(number));
|
||||||
|
RefreshToolTip();
|
||||||
|
}
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int WayPointItem::type() const
|
||||||
|
{
|
||||||
|
// Enable the use of qgraphicsitem_cast with this item.
|
||||||
|
return Type;
|
||||||
|
}
|
||||||
|
|
||||||
|
WayPointItem::~WayPointItem()
|
||||||
|
{
|
||||||
|
--WayPointItem::snumber;
|
||||||
|
}
|
||||||
|
void WayPointItem::RefreshPos()
|
||||||
|
{
|
||||||
|
core::Point point=map->FromLatLngToLocal(coord);
|
||||||
|
this->setPos(point.X(),point.Y());
|
||||||
|
}
|
||||||
|
void WayPointItem::RefreshToolTip()
|
||||||
|
{
|
||||||
|
QString coord_str = " " + QString::number(coord.Lat(), 'f', 6) + " " + QString::number(coord.Lng(), 'f', 6);
|
||||||
|
setToolTip(QString("WayPoint Number:%1\nDescription:%2\nCoordinate:%4\nAltitude:%5").arg(QString::number(WayPointItem::number)).arg(description).arg(coord_str).arg(QString::number(altitude)));
|
||||||
|
}
|
||||||
|
|
||||||
|
int WayPointItem::snumber=0;
|
||||||
|
}
|
205
ground/src/libs/opmapcontrol/src/mapwidget/waypointitem.h
Normal file
205
ground/src/libs/opmapcontrol/src/mapwidget/waypointitem.h
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file waypointitem.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
* @brief A graphicsItem representing a WayPoint
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup OPMapWidget
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#ifndef WAYPOINTITEM_H
|
||||||
|
#define WAYPOINTITEM_H
|
||||||
|
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QLabel>
|
||||||
|
#include "../internals/pointlatlng.h"
|
||||||
|
#include "mapgraphicitem.h"
|
||||||
|
#include <QObject>
|
||||||
|
namespace mapcontrol
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief A QGraphicsItem representing a WayPoint
|
||||||
|
*
|
||||||
|
* @class WayPointItem waypointitem.h "waypointitem.h"
|
||||||
|
*/
|
||||||
|
class WayPointItem:public QObject,public QGraphicsItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
enum { Type = UserType + 1 };
|
||||||
|
/**
|
||||||
|
* @brief Constructer
|
||||||
|
*
|
||||||
|
* @param coord coordinates in LatLng of the Waypoint
|
||||||
|
* @param altitude altitude of the WayPoint
|
||||||
|
* @param map pointer to map to use
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
WayPointItem(internals::PointLatLng const& coord,int const& altitude,MapGraphicItem* map);
|
||||||
|
/**
|
||||||
|
* @brief Constructer
|
||||||
|
*
|
||||||
|
* @param coord coordinates in LatLng of the WayPoint
|
||||||
|
* @param altitude altitude of the WayPoint
|
||||||
|
* @param description description fo the WayPoint
|
||||||
|
* @param map pointer to map to use
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
WayPointItem(internals::PointLatLng const& coord,int const& altitude,QString const& description,MapGraphicItem* map);
|
||||||
|
/**
|
||||||
|
* @brief Returns the WayPoint description
|
||||||
|
*
|
||||||
|
* @return QString
|
||||||
|
*/
|
||||||
|
QString Description(){return description;}
|
||||||
|
/**
|
||||||
|
* @brief Sets the WayPoint description
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
void SetDescription(QString const& value);
|
||||||
|
/**
|
||||||
|
* @brief Returns true if WayPoint is Reached
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
bool Reached(){return reached;}
|
||||||
|
/**
|
||||||
|
* @brief Sets if WayPoint is Reached
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
void SetReached(bool const& value);
|
||||||
|
/**
|
||||||
|
* @brief Returns the WayPoint number
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int Number(){return number;}
|
||||||
|
/**
|
||||||
|
* @brief Sets WayPoint number
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
void SetNumber(int const& value);
|
||||||
|
/**
|
||||||
|
* @brief Returns WayPoint LatLng coordinate
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
internals::PointLatLng Coord(){return coord;}
|
||||||
|
/**
|
||||||
|
* @brief Sets WayPoint LatLng coordinate
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
void SetCoord(internals::PointLatLng const& value);
|
||||||
|
/**
|
||||||
|
* @brief Used if WayPoint number is to be drawn on screen
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
bool ShowNumber(){return shownumber;}
|
||||||
|
/**
|
||||||
|
* @brief Used to set if WayPoint number is to be drawn on screen
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
void SetShowNumber(bool const& value);
|
||||||
|
/**
|
||||||
|
* @brief Returns the WayPoint altitude
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
int Altitude(){return altitude;}
|
||||||
|
/**
|
||||||
|
* @brief Sets the WayPoint Altitude
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
void SetAltitude(int const& value);
|
||||||
|
int type() const;
|
||||||
|
QRectF boundingRect() const;
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget);
|
||||||
|
void RefreshPos();
|
||||||
|
void RefreshToolTip();
|
||||||
|
~WayPointItem();
|
||||||
|
|
||||||
|
static int snumber;
|
||||||
|
protected:
|
||||||
|
void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
|
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
|
void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPixmap picture;
|
||||||
|
internals::PointLatLng coord;//coordinates of this WayPoint
|
||||||
|
QString description;
|
||||||
|
bool reached;
|
||||||
|
MapGraphicItem* map;
|
||||||
|
int number;
|
||||||
|
bool shownumber;
|
||||||
|
bool isDragging;
|
||||||
|
QGraphicsSimpleTextItem* text;
|
||||||
|
QGraphicsSimpleTextItem* numberI;
|
||||||
|
QTransform transf;
|
||||||
|
int altitude;
|
||||||
|
public slots:
|
||||||
|
/**
|
||||||
|
* @brief Called when a WayPoint is deleted
|
||||||
|
*
|
||||||
|
* @param number number of the WayPoint that was deleted
|
||||||
|
*/
|
||||||
|
void WPDeleted(int const& number);
|
||||||
|
/**
|
||||||
|
* @brief Called when a WayPoint is renumbered
|
||||||
|
*
|
||||||
|
* @param oldnumber the old WayPoint number
|
||||||
|
* @param newnumber the new WayPoint number
|
||||||
|
* @param waypoint a pointer to the WayPoint renumbered
|
||||||
|
*/
|
||||||
|
void WPRenumbered(int const& oldnumber,int const& newnumber,WayPointItem* waypoint);
|
||||||
|
/**
|
||||||
|
* @brief Called when a WayPoint is inserted
|
||||||
|
*
|
||||||
|
* @param number the number of the WayPoint
|
||||||
|
* @param waypoint a pointer to the WayPoint inserted
|
||||||
|
*/
|
||||||
|
void WPInserted(int const& number,WayPointItem* waypoint);
|
||||||
|
signals:
|
||||||
|
/**
|
||||||
|
* @brief fires when this WayPoint number changes (not fired if due to a auto-renumbering)
|
||||||
|
*
|
||||||
|
* @param oldnumber this WayPoint old number
|
||||||
|
* @param newnumber this WayPoint new number
|
||||||
|
* @param waypoint a pointer to this WayPoint
|
||||||
|
*/
|
||||||
|
void WPNumberChanged(int const& oldnumber,int const& newnumber,WayPointItem* waypoint);
|
||||||
|
/**
|
||||||
|
* @brief Fired when the description, altitude or coordinates change
|
||||||
|
*
|
||||||
|
* @param waypoint a pointer to this WayPoint
|
||||||
|
*/
|
||||||
|
void WPValuesChanged(WayPointItem* waypoint);
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif // WAYPOINTITEM_H
|
Loading…
x
Reference in New Issue
Block a user