Kstars

scheduleraltitudegraph.cpp
1/*
2 SPDX-FileCopyrightText: 2024 Hy Murveit <hy@murveit.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "scheduleraltitudegraph.h"
8#include "ui_scheduleraltitudegraph.h"
9#include "kplotwidget.h"
10#include "kplotobject.h"
11#include "kplotaxis.h"
12#include "ksalmanac.h"
13#include <QPen>
14
15namespace Ekos
16{
17SchedulerAltitudeGraph::SchedulerAltitudeGraph(QWidget *parent) :
18 QDialog(parent),
19 ui(new Ui::SchedulerAltitudeGraph)
20{
21 ui->setupUi(this);
22}
23
24void SchedulerAltitudeGraph::setTitle(const QString &title)
25{
26 //setWindowTitle(title);
27 ui->label->setText(title);
28}
29
30// If scheduledRun is true, you previously needed to call plot with it false.
31// It doesn't makes sense to call it with false after a call with it true,
32// as that would wipe out the data from the previous call.
33void SchedulerAltitudeGraph::plot(const GeoLocation *geo, KSAlmanac *ksal,
34 const QVector<double> &times, const QVector<double> &alts, bool scheduledRun)
35{
37 if (scheduledRun)
38 {
39 QPen pen;
40 pen.setWidth(10);
42 po->setLinePen(pen);
43 }
44 else
45 {
46 ui->avt->setLimits(times[0], times.last(), -90.0, 90.0);
47 ui->avt->setSecondaryLimits(times[0], times.last(), -90.0, 90.0);
48 ui->avt->axis(KPlotWidget::BottomAxis)->setTickLabelFormat('t');
49 ui->avt->axis(KPlotWidget::BottomAxis)->setLabel(i18n("Local Time"));
50 ui->avt->axis(KPlotWidget::TopAxis)->setTickLabelFormat('t');
51 ui->avt->axis(KPlotWidget::TopAxis)->setTickLabelsShown(true);
52 ui->avt->setGeoLocation(geo);
53
54 ui->avt->setSunRiseSetTimes(ksal->getSunRise(), ksal->getSunSet());
55 ui->avt->setDawnDuskTimes(ksal->getDawnAstronomicalTwilight(), ksal->getDuskAstronomicalTwilight());
56 ui->avt->setMinMaxSunAlt(ksal->getSunMinAlt(), ksal->getSunMaxAlt());
57 ui->avt->setMoonRiseSetTimes(ksal->getMoonRise(), ksal->getMoonSet());
58 ui->avt->setMoonIllum(ksal->getMoonIllum());
59
60 const double noonOffset = times[0] - -12;
61 const double plotDuration = times.last() - times[0];
62 ui->avt->setPlotExtent(noonOffset, plotDuration);
63 ui->avt->removeAllPlotObjects();
64 }
65
66 for (int i = 0; i < times.size(); ++i)
67 po->addPoint(times[i], alts[i]);
68 ui->avt->addPlotObject(po);
69
70 ui->avt->update();
71}
72
73SchedulerAltitudeGraph::~SchedulerAltitudeGraph()
74{
75 delete ui;
76}
77
78}
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
Definition geolocation.h:28
void addPoint(const QPointF &p, const QString &label=QString(), double barWidth=0.0)
void setLinePen(const QPen &p)
A class that implements methods to find sun rise, sun set, twilight begin / end times,...
Definition ksalmanac.h:27
double getSunMaxAlt() const
These functions return the max and min altitude of the sun during the course of the day in degrees.
Definition ksalmanac.h:75
double getMoonIllum() const
Definition ksalmanac.h:86
double getSunRise() const
All the functions returns the fraction of the day given by getDate() as their return value.
Definition ksalmanac.h:65
QString i18n(const char *text, const TYPE &arg...)
Ekos is an advanced Astrophotography tool for Linux.
Definition align.cpp:83
T & last()
qsizetype size() const const
void setColor(const QColor &color)
void setWidth(int width)
void setupUi(QWidget *widget)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.