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 protected:
70 /**
71 * Handle mouse move events. If the mouse button is down, draw crosshair lines
72 * centered at the cursor position. This allows the user to pinpoint specific
73 * position sin the plot.
74 */
75 void mouseMoveEvent(QMouseEvent *e) override;
76
77 /** Simply calls mouseMoveEvent(). */
78 void mousePressEvent(QMouseEvent *e) override;
79
80 /** Reset the MousePoint to a null value, to erase the crosshairs */
81 void mouseDoubleClickEvent(QMouseEvent *e) override;
82
83 /** Redraw the plot. */
84 void paintEvent(QPaintEvent *e) override;
85
86 private:
87 double SunRise { 0.25 };
88 double SunSet { 0.75 };
89 double Dawn { 0 };
90 double Dusk { 0 };
91 double SunMinAlt { 0 };
92 double SunMaxAlt { 0 };
93 double MoonRise { 0 };
94 double MoonSet { 0 };
95 double MoonIllum { 0 };
96 QPoint MousePoint;
97 const GeoLocation *geo { nullptr };
98};
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 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 Tue Mar 26 2024 11:19:04 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.