mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-22 12:54:14 +01:00
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@745 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
39aaf0868a
commit
54a48953a4
@ -52,167 +52,167 @@ namespace qmapcontrol
|
|||||||
*/
|
*/
|
||||||
class MapControl : public QWidget
|
class MapControl : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Declares what actions the mouse move has on the map
|
//! Declares what actions the mouse move has on the map
|
||||||
enum MouseMode
|
enum MouseMode
|
||||||
{
|
{
|
||||||
Panning, /*!< The map is moved */
|
Panning, /*!< The map is moved */
|
||||||
Dragging, /*!< A rectangular can be drawn */
|
Dragging, /*!< A rectangular can be drawn */
|
||||||
None, /*!< Mouse move events have no efect to the map */
|
None, /*!< Mouse move events have no efect to the map */
|
||||||
};
|
};
|
||||||
|
|
||||||
//! The constructor of MapControl
|
//! The constructor of MapControl
|
||||||
/*!
|
/*!
|
||||||
* The MapControl is the widget which displays the maps.
|
* The MapControl is the widget which displays the maps.
|
||||||
* The size describes the area, which gets filled with map data
|
* The size describes the area, which gets filled with map data
|
||||||
* When you give no MouseMode, the mouse is moving the map.
|
* When you give no MouseMode, the mouse is moving the map.
|
||||||
* You can change the MouseMode on runtime, to e.g. Dragging, which lets the user drag a rectangular box.
|
* You can change the MouseMode on runtime, to e.g. Dragging, which lets the user drag a rectangular box.
|
||||||
* After the dragging a signal with the size of the box is emitted.
|
* After the dragging a signal with the size of the box is emitted.
|
||||||
* The mousemode ´None´ can be used, to completely define the control of the map yourself.
|
* The mousemode ´None´ can be used, to completely define the control of the map yourself.
|
||||||
* @param size the size which the widget should fill with map data
|
* @param size the size which the widget should fill with map data
|
||||||
* @param mousemode the way mouseevents are handled
|
* @param mousemode the way mouseevents are handled
|
||||||
*/
|
*/
|
||||||
MapControl ( QSize size, MouseMode mousemode = Panning );
|
MapControl ( QSize size, MouseMode mousemode = Panning );
|
||||||
|
|
||||||
~MapControl();
|
~MapControl();
|
||||||
|
|
||||||
//! adds a layer
|
//! adds a layer
|
||||||
/*!
|
/*!
|
||||||
* If multiple layers are added, they are painted in the added order.
|
* If multiple layers are added, they are painted in the added order.
|
||||||
* @param layer the layer which should be added
|
* @param layer the layer which should be added
|
||||||
*/
|
*/
|
||||||
void addLayer ( Layer* layer );
|
void addLayer ( Layer* layer );
|
||||||
|
|
||||||
//! returns the layer with the given name
|
//! returns the layer with the given name
|
||||||
/*!
|
/*!
|
||||||
* @param layername name of the wanted layer
|
* @param layername name of the wanted layer
|
||||||
* @return the layer with the given name
|
* @return the layer with the given name
|
||||||
*/
|
*/
|
||||||
Layer* layer ( const QString& layername ) const;
|
Layer* layer ( const QString& layername ) const;
|
||||||
|
|
||||||
//! returns the names of all layers
|
//! returns the names of all layers
|
||||||
/*!
|
/*!
|
||||||
* @return returns a QList with the names of all layers
|
* @return returns a QList with the names of all layers
|
||||||
*/
|
*/
|
||||||
QList<QString> layers() const;
|
QList<QString> layers() const;
|
||||||
|
|
||||||
//! returns the number of existing layers
|
//! returns the number of existing layers
|
||||||
/*!
|
/*!
|
||||||
* @return returns the number of existing layers
|
* @return returns the number of existing layers
|
||||||
*/
|
*/
|
||||||
int numberOfLayers() const;
|
int numberOfLayers() const;
|
||||||
|
|
||||||
//! returns the coordinate of the center of the map
|
//! returns the coordinate of the center of the map
|
||||||
/*!
|
/*!
|
||||||
* @return returns the coordinate of the middle of the screen
|
* @return returns the coordinate of the middle of the screen
|
||||||
*/
|
*/
|
||||||
QPointF currentCoordinate() const;
|
QPointF currentCoordinate() const;
|
||||||
|
|
||||||
//! returns the current zoom level
|
//! returns the current zoom level
|
||||||
/*!
|
/*!
|
||||||
* @return returns the current zoom level
|
* @return returns the current zoom level
|
||||||
*/
|
*/
|
||||||
int currentZoom() const;
|
int currentZoom() const;
|
||||||
|
|
||||||
//! sets the middle of the map to the given coordinate
|
//! sets the middle of the map to the given coordinate
|
||||||
/*!
|
/*!
|
||||||
* @param coordinate the coordinate which the view´s middle should be set to
|
* @param coordinate the coordinate which the view´s middle should be set to
|
||||||
*/
|
*/
|
||||||
void setView ( const QPointF& coordinate ) const;
|
void setView ( const QPointF& coordinate ) const;
|
||||||
|
|
||||||
//! sets the view, so all coordinates are visible
|
//! sets the view, so all coordinates are visible
|
||||||
/*!
|
/*!
|
||||||
* @param coordinates the Coorinates which should be visible
|
* @param coordinates the Coorinates which should be visible
|
||||||
*/
|
*/
|
||||||
void setView ( const QList<QPointF> coordinates ) const;
|
void setView ( const QList<QPointF> coordinates ) const;
|
||||||
|
|
||||||
//! sets the view and zooms in, so all coordinates are visible
|
//! sets the view and zooms in, so all coordinates are visible
|
||||||
/*!
|
/*!
|
||||||
* The code of setting the view to multiple coordinates is "brute force" and pretty slow.
|
* The code of setting the view to multiple coordinates is "brute force" and pretty slow.
|
||||||
* Have to be reworked.
|
* Have to be reworked.
|
||||||
* @param coordinates the Coorinates which should be visible
|
* @param coordinates the Coorinates which should be visible
|
||||||
*/
|
*/
|
||||||
void setViewAndZoomIn ( const QList<QPointF> coordinates ) const;
|
void setViewAndZoomIn ( const QList<QPointF> coordinates ) const;
|
||||||
|
|
||||||
//! sets the view to the given Point
|
//! sets the view to the given Point
|
||||||
/*!
|
/*!
|
||||||
*
|
*
|
||||||
* @param point the geometric point the view should be set to
|
* @param point the geometric point the view should be set to
|
||||||
*/
|
*/
|
||||||
void setView ( const Point* point ) const;
|
void setView ( const Point* point ) const;
|
||||||
|
|
||||||
//! Keeps the center of the map on the Geometry, even when it moves
|
//! Keeps the center of the map on the Geometry, even when it moves
|
||||||
/*!
|
/*!
|
||||||
* To stop the following the method stopFollowing() have to be called
|
* To stop the following the method stopFollowing() have to be called
|
||||||
* @param geometry the Geometry which should stay centered.
|
* @param geometry the Geometry which should stay centered.
|
||||||
*/
|
*/
|
||||||
void followGeometry ( const Geometry* geometry ) const;
|
void followGeometry ( const Geometry* geometry ) const;
|
||||||
|
|
||||||
//TODO:
|
//TODO:
|
||||||
// void followGeometry(const QList<Geometry*>) const;
|
// void followGeometry(const QList<Geometry*>) const;
|
||||||
|
|
||||||
//! Stops the following of a Geometry
|
//! Stops the following of a Geometry
|
||||||
/*!
|
/*!
|
||||||
* if the view is set to follow a Geometry this method stops the trace.
|
* if the view is set to follow a Geometry this method stops the trace.
|
||||||
* See followGeometry().
|
* See followGeometry().
|
||||||
* @param geometry the Geometry which should not followed anymore
|
* @param geometry the Geometry which should not followed anymore
|
||||||
*/
|
*/
|
||||||
void stopFollowing ( Geometry* geometry );
|
void stopFollowing ( Geometry* geometry );
|
||||||
|
|
||||||
//! Smoothly moves the center of the view to the given Coordinate
|
//! Smoothly moves the center of the view to the given Coordinate
|
||||||
/*!
|
/*!
|
||||||
* @param coordinate the Coordinate which the center of the view should moved to
|
* @param coordinate the Coordinate which the center of the view should moved to
|
||||||
*/
|
*/
|
||||||
void moveTo ( QPointF coordinate );
|
void moveTo ( QPointF coordinate );
|
||||||
|
|
||||||
//! sets the Mouse Mode of the MapControl
|
//! sets the Mouse Mode of the MapControl
|
||||||
/*!
|
/*!
|
||||||
* There are three MouseModes declard by an enum.
|
* There are three MouseModes declard by an enum.
|
||||||
* The MouesMode Dragging draws an rectangular in the map while the MouseButton is pressed.
|
* The MouesMode Dragging draws an rectangular in the map while the MouseButton is pressed.
|
||||||
* When the Button is released a boxDragged() signal is emitted.
|
* When the Button is released a boxDragged() signal is emitted.
|
||||||
*
|
*
|
||||||
* The second MouseMode (the default) is Panning, which allows to drag the map around.
|
* The second MouseMode (the default) is Panning, which allows to drag the map around.
|
||||||
* @param mousemode the MouseMode
|
* @param mousemode the MouseMode
|
||||||
*/
|
*/
|
||||||
void setMouseMode ( MouseMode mousemode );
|
void setMouseMode ( MouseMode mousemode );
|
||||||
|
|
||||||
//! returns the current MouseMode
|
//! returns the current MouseMode
|
||||||
/*!
|
/*!
|
||||||
* For a explanation for the MouseModes see setMouseMode()
|
* For a explanation for the MouseModes see setMouseMode()
|
||||||
* @return the current MouseMode
|
* @return the current MouseMode
|
||||||
*/
|
*/
|
||||||
MapControl::MouseMode mouseMode();
|
MapControl::MouseMode mouseMode();
|
||||||
|
|
||||||
//int rotation;
|
//int rotation;
|
||||||
|
|
||||||
//! Enable persistent caching of map tiles
|
//! Enable persistent caching of map tiles
|
||||||
/*!
|
/*!
|
||||||
* Call this method to allow the QMapControl widget to save map tiles
|
* Call this method to allow the QMapControl widget to save map tiles
|
||||||
* persistent (also over application restarts).
|
* persistent (also over application restarts).
|
||||||
* Tiles are stored in the subdirectory "QMapControl.cache" within the
|
* Tiles are stored in the subdirectory "QMapControl.cache" within the
|
||||||
* user's home directory. This can be changed by giving a path.
|
* user's home directory. This can be changed by giving a path.
|
||||||
* @param path the path to the cache directory
|
* @param path the path to the cache directory
|
||||||
*/
|
*/
|
||||||
void enablePersistentCache ( const QDir& path=QDir::homePath() + "/QMapControl.cache" );
|
void enablePersistentCache ( const QDir& path=QDir::homePath() + "/QMapControl.cache" );
|
||||||
|
|
||||||
|
|
||||||
//! Sets the proxy for HTTP connections
|
//! Sets the proxy for HTTP connections
|
||||||
/*!
|
/*!
|
||||||
* This method sets the proxy for HTTP connections.
|
* This method sets the proxy for HTTP connections.
|
||||||
* This is not provided by the current Qtopia version!
|
* This is not provided by the current Qtopia version!
|
||||||
* @param host the proxy´s hostname or ip
|
* @param host the proxy´s hostname or ip
|
||||||
* @param port the proxy´s port
|
* @param port the proxy´s port
|
||||||
*/
|
*/
|
||||||
void setProxy ( QString host, int port );
|
void setProxy ( QString host, int port );
|
||||||
|
|
||||||
//! Displays the scale within the widget
|
//! Displays the scale within the widget
|
||||||
/*!
|
/*!
|
||||||
*
|
*
|
||||||
* @param show true if the scale should be displayed
|
* @param show true if the scale should be displayed
|
||||||
*/
|
*/
|
||||||
void showScale ( bool show );
|
void showScale ( bool show );
|
||||||
|
|
||||||
// added by cathy
|
// added by cathy
|
||||||
// show/hide the center latitude & longitude coord
|
// show/hide the center latitude & longitude coord
|
||||||
@ -224,122 +224,122 @@ namespace qmapcontrol
|
|||||||
void showLatLon(bool show);
|
void showLatLon(bool show);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LayerManager* layermanager;
|
LayerManager* layermanager;
|
||||||
QPoint screen_middle; // middle of the widget (half size)
|
QPoint screen_middle; // middle of the widget (half size)
|
||||||
|
|
||||||
QPoint pre_click_px; // used for scrolling (MouseMode Panning)
|
QPoint pre_click_px; // used for scrolling (MouseMode Panning)
|
||||||
QPoint current_mouse_pos; // used for scrolling and dragging (MouseMode Panning/Dragging)
|
QPoint current_mouse_pos; // used for scrolling and dragging (MouseMode Panning/Dragging)
|
||||||
|
|
||||||
QSize size; // size of the widget
|
QSize size; // size of the widget
|
||||||
|
|
||||||
bool mousepressed;
|
bool mousepressed;
|
||||||
MouseMode mymousemode;
|
MouseMode mymousemode;
|
||||||
|
|
||||||
bool scaleVisible;
|
bool scaleVisible;
|
||||||
bool latLonVisible;
|
bool latLonVisible;
|
||||||
|
|
||||||
bool m_loadingFlag;
|
bool m_loadingFlag;
|
||||||
|
|
||||||
QMutex moveMutex; // used for method moveTo()
|
QMutex moveMutex; // used for method moveTo()
|
||||||
QPointF target; // used for method moveTo()
|
QPointF target; // used for method moveTo()
|
||||||
int steps; // used for method moveTo()
|
int steps; // used for method moveTo()
|
||||||
|
|
||||||
QPointF clickToWorldCoordinate ( QPoint click );
|
QPointF clickToWorldCoordinate ( QPoint click );
|
||||||
MapControl& operator= ( const MapControl& rhs );
|
MapControl& operator= ( const MapControl& rhs );
|
||||||
MapControl ( const MapControl& old );
|
MapControl ( const MapControl& old );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent ( QPaintEvent* evnt );
|
void paintEvent ( QPaintEvent* evnt );
|
||||||
void mousePressEvent ( QMouseEvent* evnt );
|
void mousePressEvent ( QMouseEvent* evnt );
|
||||||
void mouseReleaseEvent ( QMouseEvent* evnt );
|
void mouseReleaseEvent ( QMouseEvent* evnt );
|
||||||
void mouseMoveEvent ( QMouseEvent* evnt );
|
void mouseMoveEvent ( QMouseEvent* evnt );
|
||||||
void wheelEvent(QWheelEvent *event); // added by cathy
|
void wheelEvent(QWheelEvent *event); // added by cathy
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
// void mouseEvent(const QMouseEvent* evnt);
|
// void mouseEvent(const QMouseEvent* evnt);
|
||||||
|
|
||||||
//! Emitted AFTER a MouseEvent occured
|
//! Emitted AFTER a MouseEvent occured
|
||||||
/*!
|
/*!
|
||||||
* This signals allows to receive click events within the MapWidget together with the world coordinate.
|
* This signals allows to receive click events within the MapWidget together with the world coordinate.
|
||||||
* It is emitted on MousePressEvents and MouseReleaseEvents.
|
* It is emitted on MousePressEvents and MouseReleaseEvents.
|
||||||
* The kind of the event can be obtained by checking the events type.
|
* The kind of the event can be obtained by checking the events type.
|
||||||
* @param evnt the QMouseEvent that occured
|
* @param evnt the QMouseEvent that occured
|
||||||
* @param coordinate the corresponding world coordinate
|
* @param coordinate the corresponding world coordinate
|
||||||
*/
|
*/
|
||||||
void mouseEventCoordinate ( const QMouseEvent* evnt, const QPointF coordinate );
|
void mouseEventCoordinate ( const QMouseEvent* evnt, const QPointF coordinate );
|
||||||
|
|
||||||
//! Emitted, after a Rectangular is dragged.
|
//! Emitted, after a Rectangular is dragged.
|
||||||
/*!
|
/*!
|
||||||
* It is possible to select a rectangular area in the map, if the MouseMode is set to Dragging.
|
* It is possible to select a rectangular area in the map, if the MouseMode is set to Dragging.
|
||||||
* The coordinates are in world coordinates
|
* The coordinates are in world coordinates
|
||||||
* @param QRectF the dragged Rect
|
* @param QRectF the dragged Rect
|
||||||
*/
|
*/
|
||||||
void boxDragged ( const QRectF );
|
void boxDragged ( const QRectF );
|
||||||
|
|
||||||
//! This signal is emitted, when a Geometry is clicked
|
//! This signal is emitted, when a Geometry is clicked
|
||||||
/*!
|
/*!
|
||||||
* @param geometry The clicked Geometry object
|
* @param geometry The clicked Geometry object
|
||||||
* @param coord_px The coordinate in pixel coordinates
|
* @param coord_px The coordinate in pixel coordinates
|
||||||
*/
|
*/
|
||||||
void geometryClicked ( Geometry* geometry, QPoint coord_px );
|
void geometryClicked ( Geometry* geometry, QPoint coord_px );
|
||||||
|
|
||||||
//! This signal is emitted, after the view have changed
|
//! This signal is emitted, after the view have changed
|
||||||
/*!
|
/*!
|
||||||
* @param coordinate The current coordinate
|
* @param coordinate The current coordinate
|
||||||
* @param zoom The current zoom
|
* @param zoom The current zoom
|
||||||
*/
|
*/
|
||||||
void viewChanged ( const QPointF &coordinate, int zoom );
|
void viewChanged ( const QPointF &coordinate, int zoom );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! zooms in one step
|
//! zooms in one step
|
||||||
void zoomIn();
|
void zoomIn();
|
||||||
|
|
||||||
//! zooms out one step
|
//! zooms out one step
|
||||||
void zoomOut();
|
void zoomOut();
|
||||||
|
|
||||||
//! sets the given zoomlevel
|
//! sets the given zoomlevel
|
||||||
/*!
|
/*!
|
||||||
* @param zoomlevel the zoomlevel
|
* @param zoomlevel the zoomlevel
|
||||||
*/
|
*/
|
||||||
void setZoom ( int zoomlevel );
|
void setZoom ( int zoomlevel );
|
||||||
|
|
||||||
//! scrolls the view to the left
|
//! scrolls the view to the left
|
||||||
void scrollLeft ( int pixel=10 );
|
void scrollLeft ( int pixel=10 );
|
||||||
|
|
||||||
//! scrolls the view to the right
|
//! scrolls the view to the right
|
||||||
void scrollRight ( int pixel=10 );
|
void scrollRight ( int pixel=10 );
|
||||||
|
|
||||||
//! scrolls the view up
|
//! scrolls the view up
|
||||||
void scrollUp ( int pixel=10 );
|
void scrollUp ( int pixel=10 );
|
||||||
|
|
||||||
//! scrolls the view down
|
//! scrolls the view down
|
||||||
void scrollDown ( int pixel=10 );
|
void scrollDown ( int pixel=10 );
|
||||||
|
|
||||||
//! scrolls the view by the given point
|
//! scrolls the view by the given point
|
||||||
void scroll ( const QPoint scroll );
|
void scroll ( const QPoint scroll );
|
||||||
|
|
||||||
//! updates the map for the given rect
|
//! updates the map for the given rect
|
||||||
/*!
|
/*!
|
||||||
* @param rect the area which should be repainted
|
* @param rect the area which should be repainted
|
||||||
*/
|
*/
|
||||||
void updateRequest ( QRect rect );
|
void updateRequest ( QRect rect );
|
||||||
|
|
||||||
//! updates the hole map by creating a new offscreen image
|
//! updates the hole map by creating a new offscreen image
|
||||||
/*!
|
/*!
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void updateRequestNew();
|
void updateRequestNew();
|
||||||
|
|
||||||
//! Resizes the map to the given size
|
//! Resizes the map to the given size
|
||||||
/*!
|
/*!
|
||||||
* @param newSize The new size
|
* @param newSize The new size
|
||||||
*/
|
*/
|
||||||
void resize(const QSize newSize);
|
void resize(const QSize newSize);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void tick();
|
void tick();
|
||||||
void loadingFinished();
|
void loadingFinished();
|
||||||
void positionChanged ( Geometry* geom );
|
void positionChanged ( Geometry* geom );
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,8 +27,7 @@
|
|||||||
namespace qmapcontrol
|
namespace qmapcontrol
|
||||||
{
|
{
|
||||||
OpenAerialMapAdapter::OpenAerialMapAdapter()
|
OpenAerialMapAdapter::OpenAerialMapAdapter()
|
||||||
// : TileMapAdapter("tile.openaerialmap.org", "/tiles/1.0.0/openaerialmap-900913/%1/%2/%3.png", 256, 0, 17)
|
: TileMapAdapter("tile.openaerialmap.org", "/tiles/1.0.0/openaerialmap-900913/%1/%2/%3.png", 256, 0, 17)
|
||||||
: TileMapAdapter("tile.openaerialmap.org", "/tiles/1.0.0/openaerialmap-900913/%1/%2/%3.png", 256, 0, 22) // cmoss .. max_zoom increased
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,7 @@
|
|||||||
namespace qmapcontrol
|
namespace qmapcontrol
|
||||||
{
|
{
|
||||||
OSMMapAdapter::OSMMapAdapter()
|
OSMMapAdapter::OSMMapAdapter()
|
||||||
// : TileMapAdapter("tile.openstreetmap.org", "/%1/%2/%3.png", 256, 0, 17)
|
: TileMapAdapter("tile.openstreetmap.org", "/%1/%2/%3.png", 256, 0, 17)
|
||||||
: TileMapAdapter("tile.openstreetmap.org", "/%1/%2/%3.png", 256, 0, 22) // cmoss .. max_zoom increased
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,7 @@
|
|||||||
namespace qmapcontrol
|
namespace qmapcontrol
|
||||||
{
|
{
|
||||||
WMSMapAdapter::WMSMapAdapter(QString host, QString serverPath, int tilesize)
|
WMSMapAdapter::WMSMapAdapter(QString host, QString serverPath, int tilesize)
|
||||||
// : MapAdapter(host, serverPath, tilesize, 0, 17)
|
: MapAdapter(host, serverPath, tilesize, 0, 17)
|
||||||
: MapAdapter(host, serverPath, tilesize, 0, 22) // cmoss .. max_zoom increased
|
|
||||||
{
|
{
|
||||||
// param1 = serverPath.indexOf("%1");
|
// param1 = serverPath.indexOf("%1");
|
||||||
// param2 = serverPath.indexOf("%2");
|
// param2 = serverPath.indexOf("%2");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user