QMapControl
0.9.7.4
|
The control element of the widget and also the widget itself. More...
#include <mapcontrol.h>
Public Types | |
enum | MouseMode { Panning, Dragging, None } |
Declares what actions mouse movements have on the map. More... | |
Public Slots | |
void | resize (const QSize newSize) |
Resizes the map to the given size. More... | |
void | scroll (const QPoint scroll) |
scrolls the view by the given point | |
void | scrollDown (int pixel=10) |
scrolls the view down | |
void | scrollLeft (int pixel=10) |
scrolls the view to the left | |
void | scrollRight (int pixel=10) |
scrolls the view to the right | |
void | scrollUp (int pixel=10) |
scrolls the view up | |
void | setZoom (int zoomlevel) |
sets the given zoomlevel More... | |
void | updateRequest (QRect rect) |
updates the map for the given rect More... | |
void | updateRequestNew () |
updates the hole map by creating a new offscreen image | |
void | zoomIn () |
zooms in one step | |
void | zoomOut () |
zooms out one step | |
Signals | |
void | boxDragged (const QRectF) |
Emitted, after a Rectangular is dragged. More... | |
void | geometryClicked (Geometry *geometry, QPoint coord_px) |
This signal is emitted, when a Geometry is clicked. More... | |
void | mouseEventCoordinate (const QMouseEvent *evnt, const QPointF coordinate) |
Emitted AFTER a MouseEvent occured. More... | |
void | viewChanged (const QPointF &coordinate, int zoom) const |
This signal is emitted, after the view have changed. More... | |
Public Member Functions | |
void | addLayer (Layer *layer) |
adds a layer More... | |
QPointF | currentCoordinate () const |
returns the coordinate of the center of the map More... | |
int | currentZoom () const |
returns the current zoom level More... | |
void | enableMouseWheelEvents (bool enabled=true) |
enable mouse wheel events More... | |
void | enablePersistentCache (int tileExpiry=-1, const QDir &path=QDir::homePath()+"/QMapControl.cache") |
Enable persistent caching of map tiles. More... | |
void | followGeometry (const Geometry *geometry) const |
Keeps the center of the map on the Geometry, even when it moves. More... | |
QRectF | getBoundingBox () |
Get current bounding box. More... | |
QRectF | getViewport () |
Get viewport rect. More... | |
bool | isBoundingBoxEnabled () |
Check if bounding box is being used. More... | |
bool | isGeometryVisible (Geometry *geometry) |
returns if a geometry is visible on viewport More... | |
Layer * | layer (const QString &layername) const |
returns the layer with the given name More... | |
QList< QString > | layers () const |
returns the names of all layers More... | |
int | loadingQueueSize () |
returns loading images queue size More... | |
MapControl (QWidget *parent=0, Qt::WindowFlags windowFlags=0) | |
The QWidget constructor of MapControl for use with QtDesigner. More... | |
MapControl (QSize size, MouseMode mousemode=Panning, bool showScale=false, bool showCrosshairs=true, QWidget *parent=0, Qt::WindowFlags windowFlags=0) | |
The constructor of MapControl. More... | |
MapControl::MouseMode | mouseMode () |
returns the current MouseMode More... | |
bool | mouseWheelEventsEnabled () |
returns mouse wheel allowed More... | |
void | moveTo (QPointF coordinate) |
Smoothly moves the center of the view to the given Coordinate. More... | |
int | numberOfLayers () const |
returns the number of existing layers More... | |
void | removeLayer (Layer *layer) |
removes a layer More... | |
void | setBoundingBox (QRectF &rect) |
Set constraints for bounding box. More... | |
void | setMouseMode (MouseMode mousemode) |
sets the Mouse Mode of the MapControl More... | |
void | setProxy (QString host, int port, const QString username=QString(), const QString password=QString()) |
Sets the proxy for HTTP connections. More... | |
void | setUseBoundingBox (bool usebounds) |
Set whether to enable a view bounding box. More... | |
void | setView (const QPointF &coordinate) const |
sets the middle of the map to the given coordinate More... | |
void | setView (const QList< QPointF > coordinates) const |
sets the view, so all coordinates are visible More... | |
void | setView (const Point *point) const |
sets the view to the given Point More... | |
void | setViewAndZoomIn (const QList< QPointF > coordinates) const |
sets the view and zooms in, so all coordinates are visible More... | |
void | showScale (bool visible) |
Displays the scale within the widget. More... | |
void | stopFollowing (const Geometry *geometry) const |
Stops the following of a Geometry. More... | |
void | updateView () const |
update screen | |
The control element of the widget and also the widget itself.
This is the main widget. To this control layers can be added. A MapControl has to be instantiated with a QSize which sets the size the widget takes in a layout. The given size is also the size which is assured to be filled with map images.
enum MouseMode |
MapControl | ( | QWidget * | parent = 0 , |
Qt::WindowFlags | windowFlags = 0 |
||
) |
The QWidget constructor of MapControl for use with QtDesigner.
References MapControl::Panning.
MapControl | ( | QSize | size, |
MouseMode | mousemode = Panning , |
||
bool | showScale = false , |
||
bool | showCrosshairs = true , |
||
QWidget * | parent = 0 , |
||
Qt::WindowFlags | windowFlags = 0 |
||
) |
The constructor of MapControl.
The MapControl is the widget which displays the maps. The size describes the area which gets filled with map data When you give no MouseMode, the mouse moves the map. You can change the MouseMode at runtime, e.g. to Dragging, which lets the user drag a rectangular box. 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.
size | the size which the widget should fill with map data |
mousemode | the way mouse events are handled |
showScale | true if the scale should be displayed |
showCrossHairs | true if crosshairs should be shown at the centre of the map |
parent | QWidget parent |
windowFlags | QWidget Window flags |
References MapControl::updateRequestNew().
void addLayer | ( | Layer * | layer | ) |
adds a layer
If multiple layers are added, they are painted in the added order.
layer | the layer which should be added |
|
signal |
Emitted, after a Rectangular is dragged.
It is possible to select a rectangular area in the map, if the MouseMode is set to Dragging. The coordinates are in world coordinates
QRectF | the dragged Rect |
QPointF currentCoordinate | ( | ) | const |
returns the coordinate of the center of the map
Referenced by MapControl::resize(), MapControl::setView(), MapControl::setViewAndZoomIn(), MapControl::setZoom(), MapControl::updateView(), MapControl::zoomIn(), and MapControl::zoomOut().
int currentZoom | ( | ) | const |
returns the current zoom level
Referenced by MapControl::resize(), MapControl::setView(), MapControl::setViewAndZoomIn(), MapControl::setZoom(), MapControl::updateView(), MapControl::zoomIn(), and MapControl::zoomOut().
void enableMouseWheelEvents | ( | bool | enabled = true | ) |
enable mouse wheel events
enable mouse event
void enablePersistentCache | ( | int | tileExpiry = -1 , |
const QDir & | path = QDir::homePath() + "/QMapControl.cache" |
||
) |
Enable persistent caching of map tiles.
Call this method to allow the QMapControl widget to save map tiles persistent (also over application restarts). Tiles are stored in the subdirectory "QMapControl.cache" within the user's home directory. This can be changed by giving a path.
tileExpiry | how long to keep in cache before requesting a new image. 0 or -1 to disable and keep forever |
path | the path to the cache directory |
void followGeometry | ( | const Geometry * | geometry | ) | const |
Keeps the center of the map on the Geometry, even when it moves.
To stop the following the method stopFollowing() have to be called
geometry | the Geometry which should stay centered. |
References MapControl::stopFollowing().
|
signal |
QRectF getBoundingBox | ( | ) |
Get current bounding box.
QRectF getViewport | ( | ) |
bool isBoundingBoxEnabled | ( | ) |
Check if bounding box is being used.
bool isGeometryVisible | ( | Geometry * | geometry | ) |
returns if a geometry is visible on viewport
geometry | the Geometry object to check |
References Geometry::boundingBox(), and MapControl::getViewport().
Layer * layer | ( | const QString & | layername | ) | const |
returns the layer with the given name
layername | name of the wanted layer |
QList< QString > layers | ( | ) | const |
returns the names of all layers
int loadingQueueSize | ( | ) |
returns loading images queue size
|
signal |
Emitted AFTER a MouseEvent occured.
This signals allows to receive click events within the MapWidget together with the world coordinate. It is emitted on MousePressEvents and MouseReleaseEvents. The kind of the event can be obtained by checking the events type.
evnt | the QMouseEvent that occured |
coordinate | the corresponding world coordinate |
MapControl::MouseMode mouseMode | ( | ) |
returns the current MouseMode
For a explanation for the MouseModes see setMouseMode()
bool mouseWheelEventsEnabled | ( | ) |
returns mouse wheel allowed
void moveTo | ( | QPointF | coordinate | ) |
Smoothly moves the center of the view to the given Coordinate.
coordinate | the Coordinate which the center of the view should moved to |
int numberOfLayers | ( | ) | const |
returns the number of existing layers
void removeLayer | ( | Layer * | layer | ) |
removes a layer
Removes a layer and redraws existing layers
layer | the layer which should be removed |
|
slot |
Resizes the map to the given size.
newSize | The new size |
References MapControl::currentCoordinate(), MapControl::currentZoom(), and MapControl::viewChanged().
void setBoundingBox | ( | QRectF & | rect | ) |
Set constraints for bounding box.
rect | specified bounds for view to stay within |
void setMouseMode | ( | MouseMode | mousemode | ) |
sets the Mouse Mode of the MapControl
There are three MouseModes declard by an enum. The MouesMode Dragging draws an rectangular in the map while the MouseButton is pressed. When the Button is released a boxDragged() signal is emitted.
The second MouseMode (the default) is Panning, which allows to drag the map around.
mousemode | the MouseMode |
void setProxy | ( | QString | host, |
int | port, | ||
const QString | username = QString() , |
||
const QString | password = QString() |
||
) |
Sets the proxy for HTTP connections.
This method sets the proxy for HTTP connections. This is not provided by the current Qtopia version!
host | the proxy´s hostname or ip |
port | the proxy´s port |
username | the proxy´s username |
password | the proxy´s password |
void setUseBoundingBox | ( | bool | usebounds | ) |
Set whether to enable a view bounding box.
usebounds | enable/disable use of bounding box |
void setView | ( | const QPointF & | coordinate | ) | const |
sets the middle of the map to the given coordinate
coordinate | the coordinate which the view´s middle should be set to |
References MapControl::currentCoordinate(), MapControl::currentZoom(), and MapControl::viewChanged().
void setView | ( | const QList< QPointF > | coordinates | ) | const |
sets the view, so all coordinates are visible
coordinates | the Coorinates which should be visible |
References MapControl::currentCoordinate(), MapControl::currentZoom(), and MapControl::viewChanged().
void setView | ( | const Point * | point | ) | const |
sets the view to the given Point
point | the geometric point the view should be set to |
References Point::coordinate().
void setViewAndZoomIn | ( | const QList< QPointF > | coordinates | ) | const |
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. Have to be reworked.
coordinates | the Coorinates which should be visible |
References MapControl::currentCoordinate(), MapControl::currentZoom(), and MapControl::viewChanged().
|
slot |
sets the given zoomlevel
zoomlevel | the zoomlevel |
References MapControl::currentCoordinate(), MapControl::currentZoom(), MapControl::updateView(), and MapControl::viewChanged().
void showScale | ( | bool | visible | ) |
Displays the scale within the widget.
show | true if the scale should be displayed |
void stopFollowing | ( | const Geometry * | geometry | ) | const |
Stops the following of a Geometry.
if the view is set to follow a Geometry this method stops the trace. See followGeometry().
geometry | the Geometry which should not followed anymore |
Referenced by MapControl::followGeometry().
|
slot |
updates the map for the given rect
rect | the area which should be repainted |
|
signal |
This signal is emitted, after the view have changed.
coordinate | The current coordinate |
zoom | The current zoom |
Referenced by MapControl::resize(), MapControl::setView(), MapControl::setViewAndZoomIn(), MapControl::setZoom(), MapControl::updateView(), MapControl::zoomIn(), and MapControl::zoomOut().