Kstars

avtplotwidget.h
1/*
2 SPDX-FileCopyrightText: 2007 Jason Harris <kstars@30doradus.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <kplotwidget.h>
10
11#include <QPoint>
12
13class GeoLocation;
14
15/**
16 * @class AVTPlotWidget
17 * @short An extension of the KPlotWidget for the AltVsTime tool.
18 * The biggest difference is that in addition to the plot objects, it draws the "ground" below
19 * Alt=0 and draws the sky light blue for day times, and black for night times. The transition
20 * between day and night is drawn with a gradient, and the position follows the actual
21 * sunrise/sunset times of the given date/location. Also, this plot widget provides two
22 * time axes (local time along the bottom, and local sideral time along the top). Finally, it
23 * provides user interaction: on mouse click, it draws crosshairs at the mouse position with
24 * labels for the time and altitude.
25 *
26 * @version 1.0
27 * @author Jason Harris
28 */
30{
32 public:
33 explicit AVTPlotWidget(QWidget *parent = nullptr);
34
35 /**
36 * Set the fractional positions of the Sunrise and Sunset positions, in units where last
37 * midnight was 0.0, and next midnight is 1.0. i.e., if Sunrise is at 06:00, then we set
38 * it as 0.25 in this function. Likewise, if Sunset is at 18:00, then we set it as
39 * 0.75 in this function.
40 * @param sr the fractional position of Sunrise
41 * @param ss the fractional position of Sunset
42 */
43 void setSunRiseSetTimes(double sr, double ss);
44
45 void setDawnDuskTimes(double da, double du);
46
47 void setMinMaxSunAlt(double min, double max);
48
49 /**
50 * Set the fractional positions of moonrise and moon set in units
51 * where last midnight was 0.0 and next midnight is 1.0
52 */
53 void setMoonRiseSetTimes(double mr, double ms);
54
55 /**
56 * @short Set the moon illumination
57 * @param mi Moon illuminated fraction (0.0 to 1.0)
58 * @note Used to determine the brightness of the gradient representing lunar skyglow
59 */
60 void setMoonIllum(double mi);
61
62 /**
63 * @short Set the GeoLocation
64 * @param geo_ Used to convert and format the current time correctly
65 * @warning Might be better to skip the entire shebang and include the KSAlmanac calls within AVTPlotWidget
66 */
67 inline void setGeoLocation(const GeoLocation *geo_) { geo = geo_; }
68
69 /**
70 * This is needed when not plotting from noon to noon.
71 * Set the offset from noon to start the plot (e.g. 6pm would be 6)
72 * and set the plot length in hours.
73 * @param noonOffset hours after noon when the plot should start
74 * @param plotDuration Number of hours that the plot represents.
75 * @warning This only affects moon and sub and mouse clicks. You must coordinate the points with this
76 */
77 void setPlotExtent(double noonOffset, double plotDuration);
78
79 protected:
80 /**
81 * Handle mouse move events. If the mouse button is down, draw crosshair lines
82 * centered at the cursor position. This allows the user to pinpoint specific
83 * position sin the plot.
84 */
85 void mouseMoveEvent(QMouseEvent *e) override;
86
87 /** Simply calls mouseMoveEvent(). */
88 void mousePressEvent(QMouseEvent *e) override;
89
90 /** Reset the MousePoint to a null value, to erase the crosshairs */
91 void mouseDoubleClickEvent(QMouseEvent *e) override;
92
93 /** Redraw the plot. */
94 void paintEvent(QPaintEvent *e) override;
95
96 private:
97 int convertCoords(int xCoord);
98
99 // The times below (SunRise, SunSet, Dawn, Dusk, MoonRise, MoonSet) are all in fractional
100 // parts of the day (e.g. 0.5 is 12 noon).
101 double SunRise { 0.25 };
102 double SunSet { 0.75 };
103 double Dawn { 0 };
104 double Dusk { 0 };
105 double SunMinAlt { 0 };
106 double SunMaxAlt { 0 };
107 double MoonRise { 0 };
108 double MoonSet { 0 };
109 double MoonIllum { 0 };
110 double noonOffset { 0.0}; // Default start plotting at noon plus this offset
111 double plotDuration { 24.0 }; // Default plot length is 24 hours
112 QPoint MousePoint;
113 const GeoLocation *geo { nullptr };
114};
An extension of the KPlotWidget for the AltVsTime tool.
void setGeoLocation(const GeoLocation *geo_)
Set the GeoLocation.
void setSunRiseSetTimes(double sr, double ss)
Set the fractional positions of the Sunrise and Sunset positions, in units where last midnight was 0....
void setMoonRiseSetTimes(double mr, double ms)
Set the fractional positions of moonrise and moon set in units where last midnight was 0....
void paintEvent(QPaintEvent *e) override
Redraw the plot.
void setPlotExtent(double noonOffset, double plotDuration)
This is needed when not plotting from noon to noon.
void mouseDoubleClickEvent(QMouseEvent *e) override
Reset the MousePoint to a null value, to erase the crosshairs.
void setMoonIllum(double mi)
Set the moon illumination.
void mousePressEvent(QMouseEvent *e) override
Simply calls mouseMoveEvent().
void mouseMoveEvent(QMouseEvent *e) override
Handle mouse move events.
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
Definition geolocation.h:28
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.