• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

marble/src

MarbleWidget Class Reference

#include <MarbleWidget.h>

Inheritance diagram for MarbleWidget:

Inheritance graph
[legend]

List of all members.


Detailed Description

A widget class that displays a view of the earth.

This widget displays a view of the earth or any other globe, depending on which dataset is used. The user can navigate the globe using either a control widget, e.g. the MarbleControlBox, or the mouse. Only some aspects of the widget can be controlled by the mouse.

By clicking on the globe and moving the mouse, the position can be changed. The user can also zoom by using the scroll wheel of the mouse in the widget. The zoom value is not tied to any units, but is an abstract value without any physical meaning. A value around 1000 shows the full globe in a normal-sized window. Higher zoom values give a more zoomed-in view.

The MarbleWidget needs to be provided with a data model to work. This model is contained in the MarbleModel class. The widget can also construct its own model if none is given to the constructor. This data model contains 3 separate datatypes: tiles which provide the background, vectors which provide things like country borders and coastlines and placemarks which can show points of interest, such as cities, mountain tops or the poles.

In addition to navigating with the mouse, you can also use it to get information about items on the map. You can either click on a placemark with the left mouse button or with the right mouse button anywhere on the map.

The left mouse button opens up a menu with all the placemarks within a certain distance from the mouse pointer. When you choose one item from the menu, Marble will open up a dialog window with some information about the placemark and also try to connect to Wikipedia to retrieve an article about it. If there is such an article, you will get a mini-browser window with the article in a tab.

The right mouse button controls a distance tool. The distance tool is implemented as a menu where you can choose to either create or remove so called Measure Points. Marble will keep track of the Measure Points and show the total distance in the upper left of the widget. Measure Points are shown on the map as a little white cross.

See also:
MarbleControlBox

MarbleModel

Definition at line 99 of file MarbleWidget.h.


Public Slots

void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
void zoomView (int zoom)
void zoomViewBy (int zoomStep)
void zoomIn ()
void zoomOut ()
void rotateBy (const double &deltaLon, const double &deltaLat)
void rotateBy (const Quaternion &incRot)
void centerOn (const double &lon, const double &lat)
void centerOn (const QModelIndex &index)
void setCenterLatitude (double lat)
void setCenterLongitude (double lon)
void rotateTo (const double &lon, const double &lat)
void rotateTo (const double &lon, const double &lat, const double &psi)
void rotateTo (const Quaternion &quat)
Projection projection () const
void setProjection (int projection)
void home (double &lon, double &lat, int &zoom)
void setHome (const double lon, const double lat, const int zoom=1050)
void setHome (const GeoDataPoint &homePoint, int zoom=1050)
void moveLeft ()
void moveRight ()
void moveUp ()
void moveDown ()
void goHome ()
QString mapTheme () const
void setMapTheme (const QString &maptheme)
void setShowScaleBar (bool visible)
void setShowCompass (bool visible)
void setShowGrid (bool visible)
void setShowPlaces (bool visible)
void setShowCities (bool visible)
void setShowTerrain (bool visible)
void setShowOtherPlaces (bool visible)
void setShowRelief (bool visible)
void setShowElevationModel (bool visible)
void setShowIceLayer (bool visible)
void setShowBorders (bool visible)
void setShowRivers (bool visible)
void setShowLakes (bool visible)
void setShowGps (bool visible)
void setShowFrameRate (bool visible)
void changeCurrentPosition (double lon, double lat)
void notifyMouseClick (int x, int y)
void updateGps ()
void openGpxFile (QString &filename)
GpxFileModel * gpxFileModel ()
FileViewModel * fileViewModel () const
void setQuickDirty (bool enabled)
void creatingTilesStart (TileCreator *creator, const QString &name, const QString &description)
void updateChangedMap ()
void updateRegion (BoundingBox)
void setDownloadUrl (const QString &url)
void setDownloadUrl (const QUrl &url)

Signals

void zoomChanged (int zoom)
void distanceChanged (const QString &distanceString)
void themeChanged (QString theme)
void projectionChanged (int)
void mouseMoveGeoPosition (QString)
void mouseClickGeoPosition (double lon, double lat, GeoDataPoint::Unit)
void timeout ()
void framesPerSecond (double fps)

Public Member Functions

 MarbleWidget (QWidget *parent=0)
 MarbleWidget (MarbleModel *model, QWidget *parent=0)
virtual ~MarbleWidget ()
MarbleModel * model () const
void setInputHandler (MarbleWidgetInputHandler *handler)
void setDownloadManager (HttpDownloadManager *downloadManager)
const QRegion activeRegion ()
int radius () const
void setRadius (const int radius)
int zoom () const
QString distanceString () const
int minimumZoom () const
int maximumZoom () const
bool needsUpdate () const
void setNeedsUpdate ()
bool screenCoordinates (const double lon, const double lat, int &x, int &y)
int northPoleY ()
int northPoleZ ()
bool geoCoordinates (const int x, const int y, double &lon, double &lat, GeoDataPoint::Unit=GeoDataPoint::Degree)
bool globalQuaternion (int x, int y, Quaternion &q)
double centerLongitude () const
double centerLatitude () const
QAbstractItemModel * placeMarkModel () const
QItemSelectionModel * placeMarkSelectionModel () const
double moveStep ()
void addPlaceMarkFile (const QString &filename)
Quaternion planetAxis () const
QPixmap mapScreenShot ()
bool showScaleBar () const
bool showCompass () const
bool showGrid () const
bool showPlaces () const
bool showCities () const
bool showTerrain () const
bool showOtherPlaces () const
bool showRelief () const
bool showElevationModel () const
bool showIceLayer () const
bool showBorders () const
bool showRivers () const
bool showLakes () const
bool showGps () const
bool showFrameRate () const
bool quickDirty () const
bool globeCoversImage () const

Protected Member Functions

void leaveEvent (QEvent *event)
void paintEvent (QPaintEvent *event)
virtual void customPaint (ClipPainter *painter)
void resizeEvent (QResizeEvent *)
void connectNotify (const char *signal)
void disconnectNotify (const char *signal)

Properties

int zoom
double longitude
double latitude
bool showScaleBar
bool showCompass
bool showGrid
bool showPlaces
bool showCities
bool showTerrain
bool showOtherPlaces
bool showRelief
bool showElevationModel
bool showIceLayer
bool showBorders
bool showRivers
bool showLakes
bool quickDirty

Constructor & Destructor Documentation

MarbleWidget::MarbleWidget ( QWidget *  parent = 0  )  [explicit]

Construct a new MarbleWidget.

Parameters:
parent the parent widget
This constructor should be used when you will only use one MarbleWidget. The widget will create its own MarbleModel when created.

Definition at line 96 of file MarbleWidget.cpp.

MarbleWidget::MarbleWidget ( MarbleModel *  model,
QWidget *  parent = 0 
) [explicit]

Construct a new MarbleWidget.

Parameters:
model the data model for the widget.
parent the parent widget
This constructor should be used when you plan to use more than one MarbleWidget for the same MarbleModel (not yet supported, but will be soon).

Definition at line 106 of file MarbleWidget.cpp.

MarbleWidget::~MarbleWidget (  )  [virtual]

Definition at line 115 of file MarbleWidget.cpp.


Member Function Documentation

MarbleModel * MarbleWidget::model (  )  const

Return the model that this view shows.

Definition at line 193 of file MarbleWidget.cpp.

void MarbleWidget::setInputHandler ( MarbleWidgetInputHandler *  handler  ) 

Set the input handler.

Definition at line 199 of file MarbleWidget.cpp.

void MarbleWidget::setDownloadManager ( HttpDownloadManager *  downloadManager  ) 

Set the download manager to load missing tiles.

Parameters:
manager the manager instance
The instance will be destructed by MarbleWidget when not used any longer.

Definition at line 223 of file MarbleWidget.cpp.

const QRegion MarbleWidget::activeRegion (  ) 

Return the active region in which it's possible to drag the view using the mouse.

Definition at line 913 of file MarbleWidget.cpp.

int MarbleWidget::radius (  )  const

Return the radius of the globe in pixels.

Definition at line 235 of file MarbleWidget.cpp.

void MarbleWidget::setRadius ( const int  radius  ) 

Set the radius of the globe in pixels.

Parameters:
radius The new globe radius value in pixels.

Definition at line 240 of file MarbleWidget.cpp.

int MarbleWidget::zoom (  )  const

Return the current zoom level.

QString MarbleWidget::distanceString (  )  const

Return the current distance string.

Definition at line 1302 of file MarbleWidget.cpp.

int MarbleWidget::minimumZoom (  )  const

return the minimum zoom value for the current map theme.

Definition at line 299 of file MarbleWidget.cpp.

int MarbleWidget::maximumZoom (  )  const

return the minimum zoom value for the current map theme.

Definition at line 304 of file MarbleWidget.cpp.

bool MarbleWidget::needsUpdate (  )  const

return if the widget needs to be updated.

Definition at line 246 of file MarbleWidget.cpp.

void MarbleWidget::setNeedsUpdate (  ) 

Mark the widget as needing an update.

Definition at line 253 of file MarbleWidget.cpp.

bool MarbleWidget::screenCoordinates ( const double  lon,
const double  lat,
int &  x,
int &  y 
)

Get the screen coordinates corresponding to geographical coordinates in the widget.

Parameters:
lon the lon coordinate of the requested pixel position
lat the lat coordinate of the requested pixel position
x the x coordinate of the pixel is returned through this parameter
y the y coordinate of the pixel is returned through this parameter
Returns:
true if the geographical coordinates are visible on the screen false if the geographical coordinates are not visible on the screen

Definition at line 710 of file MarbleWidget.cpp.

int MarbleWidget::northPoleY (  ) 

Get the Y coordinate of the North Pole.

Returns:
the pixel address of the geographical north pole.

Definition at line 691 of file MarbleWidget.cpp.

int MarbleWidget::northPoleZ (  ) 

Get the Z coordinate of the North Pole.

Returns:
the Z coordinate of the geographical north pole.
This function returns the Z coordinate of the north pole. It will return a positive value if the north pole is visible, i.e. pointing towards the viewer. It will return a negative value if the north pole is behind the horizon, i.e. pointing away from the viewer.

Definition at line 700 of file MarbleWidget.cpp.

bool MarbleWidget::geoCoordinates ( const int  x,
const int  y,
double &  lon,
double &  lat,
GeoDataPoint::Unit  unit = GeoDataPoint::Degree 
)

Get the earth coordinates corresponding to a pixel in the widget.

Parameters:
x the x coordinate of the pixel
y the y coordinate of the pixel
lon the longitude angle is returned through this parameter
lat the latitude angle is returned through this parameter
Returns:
true if the pixel (x, y) is within the globe false if the pixel (x, y) is outside the globe, i.e. in space.

Definition at line 740 of file MarbleWidget.cpp.

bool MarbleWidget::globalQuaternion ( int  x,
int  y,
Quaternion &  q 
)

Get a quaternion representing a point on the earth corresponding to a pixel in the widget.

Parameters:
x the x coordinate of the pixel
y the y coordinate of the pixel
q the out parameter where the result is returned
Returns:
true if the pixel (x, y) is within the globe false if the pixel (x, y) is outside the globe, i.e. in space

Definition at line 801 of file MarbleWidget.cpp.

double MarbleWidget::centerLongitude (  )  const

Return the longitude of the center point.

Definition at line 291 of file MarbleWidget.cpp.

double MarbleWidget::centerLatitude (  )  const

Return the latitude of the center point.

Definition at line 283 of file MarbleWidget.cpp.

QAbstractItemModel * MarbleWidget::placeMarkModel (  )  const

returns the model for all the placemarks on the globe.

Definition at line 259 of file MarbleWidget.cpp.

QItemSelectionModel * MarbleWidget::placeMarkSelectionModel (  )  const

returns the selection model for all the placemarks on the globe.

Definition at line 264 of file MarbleWidget.cpp.

double MarbleWidget::moveStep (  ) 

Return how much the map will move if one of the move slots are called.

Returns:
The move step.

Definition at line 269 of file MarbleWidget.cpp.

void MarbleWidget::addPlaceMarkFile ( const QString &  filename  ) 

Add a GeoDataPlacemark file to the model.

Parameters:
filename the filename of the file containing the PlaceMarks.

Definition at line 309 of file MarbleWidget.cpp.

Quaternion MarbleWidget::planetAxis (  )  const

Return the quaternion that specifies the rotation of the globe.

Returns:
The quaternion that describes the rotation of the globe.

Definition at line 229 of file MarbleWidget.cpp.

QPixmap MarbleWidget::mapScreenShot (  ) 

Return a QPixmap with the current contents of the widget.

Definition at line 314 of file MarbleWidget.cpp.

bool MarbleWidget::showScaleBar (  )  const

Return whether the scale bar is visible.

Returns:
The scale bar visibility.

bool MarbleWidget::showCompass (  )  const

Return whether the compass bar is visible.

Returns:
The compass visibility.

bool MarbleWidget::showGrid (  )  const

Return whether the coordinate grid is visible.

Returns:
The coordinate grid visibility.

bool MarbleWidget::showPlaces (  )  const

Return whether the place marks are visible.

Returns:
The place mark visibility.

bool MarbleWidget::showCities (  )  const

Return whether the city place marks are visible.

Returns:
The city place mark visibility.

bool MarbleWidget::showTerrain (  )  const

Return whether the terrain place marks are visible.

Returns:
The terrain place mark visibility.

bool MarbleWidget::showOtherPlaces (  )  const

Return whether other places are visible.

Returns:
The visibility of other places.

bool MarbleWidget::showRelief (  )  const

Return whether the relief is visible.

Returns:
The relief visibility.

bool MarbleWidget::showElevationModel (  )  const

Return whether the elevation model is visible.

Returns:
The elevation model visibility.

bool MarbleWidget::showIceLayer (  )  const

Return whether the ice layer is visible.

Returns:
The ice layer visibility.

bool MarbleWidget::showBorders (  )  const

Return whether the borders are visible.

Returns:
The border visibility.

bool MarbleWidget::showRivers (  )  const

Return whether the rivers are visible.

Returns:
The rivers' visibility.

bool MarbleWidget::showLakes (  )  const

Return whether the lakes are visible.

Returns:
The lakes' visibility.

bool MarbleWidget::showGps (  )  const

Return whether Gps Data is visible.

Returns:
The Gps Data's visibility.

Definition at line 384 of file MarbleWidget.cpp.

bool MarbleWidget::showFrameRate (  )  const

Return whether the frame rate gets displayed.

Returns:
the frame rates visibility

Definition at line 389 of file MarbleWidget.cpp.

bool MarbleWidget::quickDirty (  )  const

Return whether quick and dirty rendering is enabled.

Returns:
Quick and dirty rendering

bool MarbleWidget::globeCoversImage (  )  const

Definition at line 1324 of file MarbleWidget.cpp.

void MarbleWidget::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget 
) [slot]

paint the widget (FIXME: Not Yet Implemented)

Parameters:
painter the QPainter to paint with
option fixme
widget fixme

Definition at line 1030 of file MarbleWidget.cpp.

void MarbleWidget::zoomView ( int  zoom  )  [slot]

Zoom the view to a certain zoomlevel.

Parameters:
zoom the new zoom level.
The zoom level is an abstract value without physical interpretation. A zoom value around 1000 lets the viewer see all of the earth in the default window.

Definition at line 399 of file MarbleWidget.cpp.

void MarbleWidget::zoomViewBy ( int  zoomStep  )  [slot]

Zoom the view by a certain step.

Parameters:
zoomStep the difference between the old zoom and the new

Definition at line 449 of file MarbleWidget.cpp.

void MarbleWidget::zoomIn (  )  [slot]

Zoom in by the amount zoomStep.

Definition at line 455 of file MarbleWidget.cpp.

void MarbleWidget::zoomOut (  )  [slot]

Zoom out by the amount zoomStep.

Definition at line 460 of file MarbleWidget.cpp.

void MarbleWidget::rotateBy ( const double &  deltaLon,
const double &  deltaLat 
) [slot]

Rotate the view by the two angles phi and theta.

Parameters:
deltaLon an angle that specifies the change in terms of longitude
deltaLat an angle that specifies the change in terms of latitude
This function rotates the view by two angles, deltaLon ("theta") and deltaLat ("phi"). If we start at (0, 0), the result will be the exact equivalent of (lon, lat), otherwise the resulting angle will be the sum of the previous position and the two offsets.

This method automatically updates the view

Definition at line 481 of file MarbleWidget.cpp.

void MarbleWidget::rotateBy ( const Quaternion &  incRot  )  [slot]

Rotate the view by the angle specified by a Quaternion.

Parameters:
incRot a quaternion specifying the rotation * This method automatically updates the view

Definition at line 474 of file MarbleWidget.cpp.

void MarbleWidget::centerOn ( const double &  lon,
const double &  lat 
) [slot]

Center the view on a geographical point.

Parameters:
lat an angle parallel to the latitude lines +90(N) - -90(S)
lon an angle parallel to the longitude lines +180(W) - -180(E)
This method automatically updates the view

Definition at line 494 of file MarbleWidget.cpp.

void MarbleWidget::centerOn ( const QModelIndex &  index  )  [slot]

Center the view on a point.

Parameters:
index an index for a QModel, indicating a city
This method automatically updates the view

Definition at line 503 of file MarbleWidget.cpp.

void MarbleWidget::setCenterLatitude ( double  lat  )  [slot]

Set the latitude for the center point.

Parameters:
lat the new value for the latitude
This method automatically updates the view

Definition at line 529 of file MarbleWidget.cpp.

void MarbleWidget::setCenterLongitude ( double  lon  )  [slot]

Set the longitude for the center point.

Parameters:
lon the new value for the longitude
This method automatically updates the view

Definition at line 534 of file MarbleWidget.cpp.

void MarbleWidget::rotateTo ( const double &  lon,
const double &  lat 
) [slot]

Center the view on a point.

Parameters:
lat an angle parallel to the latitude lines +90(N) - -90(S)
lon an angle parallel to the longitude lines +180(W) - -180(E)
This method does NOT automatically update the view and is meant to be used during subsequent transformations

Definition at line 838 of file MarbleWidget.cpp.

void MarbleWidget::rotateTo ( const double &  lon,
const double &  lat,
const double &  psi 
) [slot]

Center the view on a point.

Parameters:
lat an angle parallel to the latitude lines +90(N) - -90(S)
lon an angle parallel to the longitude lines +180(W) - -180(E)
psi clockwise rotation of the globe -180(anti-clockwise) - +180(clockwise)
This method does NOT automatically update the view and is meant to be used during subsequent transformations

Definition at line 831 of file MarbleWidget.cpp.

void MarbleWidget::rotateTo ( const Quaternion &  quat  )  [slot]

Center the view on a point.

Parameters:
quat a quaternion specifying the rotation
This method does NOT automatically update the view and is meant to be used during subsequent transformations

Definition at line 465 of file MarbleWidget.cpp.

Projection MarbleWidget::projection (  )  const [slot]

Get the Projection used for the map.

Returns:
Spherical a Globe

Equirectangular a flat map

Mercator another flat map

Definition at line 539 of file MarbleWidget.cpp.

void MarbleWidget::setProjection ( int  projection  )  [slot]

Set the Projection used for the map.

Parameters:
projection projection type (e.g. Spherical, Equirectangular, Mercator)

Definition at line 545 of file MarbleWidget.cpp.

void MarbleWidget::home ( double &  lon,
double &  lat,
int &  zoom 
) [slot]

get the home point

Parameters:
lon the longitude of the home point.
lat the latitude of the home point.
zoom the default zoom level of the home point.

Definition at line 585 of file MarbleWidget.cpp.

void MarbleWidget::setHome ( const double  lon,
const double  lat,
const int  zoom = 1050 
) [slot]

Set the home point.

Parameters:
lon the longitude of the new home point.
lat the latitude of the new home point.
zoom the default zoom level for the new home point.

Definition at line 591 of file MarbleWidget.cpp.

void MarbleWidget::setHome ( const GeoDataPoint &  homePoint,
int  zoom = 1050 
) [slot]

Set the home point.

Parameters:
homePoint the new home point.
zoom the default zoom level for the new home point.

Definition at line 597 of file MarbleWidget.cpp.

void MarbleWidget::moveLeft (  )  [slot]

Move left by the moveStep.

Definition at line 604 of file MarbleWidget.cpp.

void MarbleWidget::moveRight (  )  [slot]

Move right by the moveStep.

Definition at line 617 of file MarbleWidget.cpp.

void MarbleWidget::moveUp (  )  [slot]

Move up by the moveStep.

Definition at line 631 of file MarbleWidget.cpp.

void MarbleWidget::moveDown (  )  [slot]

Move down by the moveStep.

Definition at line 636 of file MarbleWidget.cpp.

void MarbleWidget::goHome (  )  [slot]

Center the view on the default start point with the default zoom.

Definition at line 1038 of file MarbleWidget.cpp.

QString MarbleWidget::mapTheme (  )  const [slot]

Get the ID of the current map theme To ensure that a unique identifier is being used the theme does NOT get represented by its name but the by relative location of the file that specifies the theme:.

Example: maptheme = "bluemarble/bluemarble.dgml"

Definition at line 1052 of file MarbleWidget.cpp.

void MarbleWidget::setMapTheme ( const QString &  maptheme  )  [slot]

Set a new map theme.

Parameters:
maptheme The ID of the new maptheme. To ensure that a unique identifier is being used the theme does NOT get represented by its name but the by relative location of the file that specifies the theme:
Example: maptheme = "bluemarble/bluemarble.dgml"

Definition at line 1057 of file MarbleWidget.cpp.

void MarbleWidget::setShowScaleBar ( bool  visible  )  [slot]

Set whether the scale bar overlay is visible.

Parameters:
visible visibility of the scale bar

Definition at line 1069 of file MarbleWidget.cpp.

void MarbleWidget::setShowCompass ( bool  visible  )  [slot]

Set whether the compass overlay is visible.

Parameters:
visible visibility of the compass

Definition at line 1075 of file MarbleWidget.cpp.

void MarbleWidget::setShowGrid ( bool  visible  )  [slot]

Set whether the coordinate grid overlay is visible.

Parameters:
visible visibility of the coordinate grid

Definition at line 1081 of file MarbleWidget.cpp.

void MarbleWidget::setShowPlaces ( bool  visible  )  [slot]

Set whether the place mark overlay is visible.

Parameters:
visible visibility of the place marks

Definition at line 1087 of file MarbleWidget.cpp.

void MarbleWidget::setShowCities ( bool  visible  )  [slot]

Set whether the city place mark overlay is visible.

Parameters:
visible visibility of the city place marks

Definition at line 1093 of file MarbleWidget.cpp.

void MarbleWidget::setShowTerrain ( bool  visible  )  [slot]

Set whether the terrain place mark overlay is visible.

Parameters:
visible visibility of the terrain place marks

Definition at line 1099 of file MarbleWidget.cpp.

void MarbleWidget::setShowOtherPlaces ( bool  visible  )  [slot]

Set whether the other places overlay is visible.

Parameters:
visible visibility of other places

Definition at line 1105 of file MarbleWidget.cpp.

void MarbleWidget::setShowRelief ( bool  visible  )  [slot]

Set whether the relief is visible.

Parameters:
visible visibility of the relief

Definition at line 1111 of file MarbleWidget.cpp.

void MarbleWidget::setShowElevationModel ( bool  visible  )  [slot]

Set whether the elevation model is visible.

Parameters:
visible visibility of the elevation model

Definition at line 1119 of file MarbleWidget.cpp.

void MarbleWidget::setShowIceLayer ( bool  visible  )  [slot]

Set whether the ice layer is visible.

Parameters:
visible visibility of the ice layer

Definition at line 1127 of file MarbleWidget.cpp.