Kstars

mapcanvas.h
1/*
2 SPDX-FileCopyrightText: 2001 Jason Harris <jharris@30doradus.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#ifndef MAPCANVAS_H
8#define MAPCANVAS_H
9
10#include <QFrame>
11#include <QPixmap>
12#include <QMouseEvent>
13#include <QPaintEvent>
14#include <geolocation.h>
15
16/** @class MapCanvas
17 *Used in LocationDialog for displaying a map of the Earth.
18 *In addition, cities in the database are drawn as grey or white dots.
19 *Also, the widget processes mouse clicks, to trim the list of
20 *cities to those near the mouse click.
21 *@short Widget used in the LocationDialog for displaying the world map.
22 *@author Jason Harris
23 *@version 1.0
24 */
25
26class LocationDialog;
27class QPixmap;
28
29class MapCanvas : public QFrame
30{
32 public:
33 /**Default constructor. Initialize the widget: create pixmaps, load the
34 * world map image
35 * @param parent pointer to the parent LocationDialog
36 */
37 explicit MapCanvas(QWidget *parent);
38
39 /**Destructor (empty) */
40 ~MapCanvas() override;
41
42 /** Set location dialog */
43 // FIXME: This is temporary plug
44 void setLocationDialog(LocationDialog *loc) { ld = loc; }
45 public slots:
46 /**Set the geometry of the map widget (overloaded from QWidget).
47 * Resizes the size of the map pixmap to match the widget, and resets
48 * the Origin QPoint so it remains at the center of the widget.
49 * @note this is called automatically by resize events.
50 * @p x the x-position of the widget
51 * @p y the y-position of the widget
52 * @p w the width of the widget
53 * @p h the height of the widget
54 */
55 virtual void setGeometry(int x, int y, int w, int h);
56
57 /**Set the geometry of the map widget (overloaded from QWidget).
58 * Resizes the size of the map pixmap to match the widget, and resets
59 * the Origin QPoint so it remains at the center of the widget.
60 * This function behaves just like the above function. It differs
61 * only in the data type of its argument.
62 * @note this is called automatically by resize events.
63 * @p r QRect describing geometry
64 */
65 virtual void setGeometry(const QRect &r);
66
67 protected:
68 /**Draw the map. Draw grey dots on the locations of all cities,
69 * and highlight the cities which match the current filters as
70 * white dits. Also draw a red crosshairs on the
71 * currently-selected city.
72 * @see LocationDialog
73 */
74 void paintEvent(QPaintEvent *e) override;
75
76 /**Trim the list of cities so that only those within 2 degrees
77 * of the mouse click are shown in the list.
78 * @see LocationDialog
79 */
80 void mousePressEvent(QMouseEvent *e) override;
81
82 /**Convert geo co-ordinates to a scaled position on the map*/
84
85 private:
87 QPixmap *bgImage;
88 QString BGColor;
89 QPoint origin;
90 double xsize;
91 double ysize;
92 double ximage;
93 double yimage;
94 double ratio;
95 double xscale;
96 double yscale;
97};
98
99#endif
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
Definition geolocation.h:28
Dialog for changing the geographic location of the observer.
Used in LocationDialog for displaying a map of the Earth.
Definition mapcanvas.h:30
virtual void setGeometry(int x, int y, int w, int h)
Set the geometry of the map widget (overloaded from QWidget).
Definition mapcanvas.cpp:43
void paintEvent(QPaintEvent *e) override
Draw the map.
Definition mapcanvas.cpp:67
void convertAndScale(QPoint &o, GeoLocation &g)
Convert geo co-ordinates to a scaled position on the map.
~MapCanvas() override
Destructor (empty)
Definition mapcanvas.cpp:38
void mousePressEvent(QMouseEvent *e) override
Trim the list of cities so that only those within 2 degrees of the mouse click are shown in the list.
Definition mapcanvas.cpp:57
MapCanvas(QWidget *parent)
Default constructor.
Definition mapcanvas.cpp:21
void setLocationDialog(LocationDialog *loc)
Set location dialog.
Definition mapcanvas.h:44
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.