File indexing completed on 2024-04-21 03:44:55

0001 /*
0002     SPDX-FileCopyrightText: 2003 Jason Harris <jharris@30doradus.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "kstarsdatetime.h"
0010 #include "ui_planetviewer.h"
0011 
0012 #include <QDialog>
0013 #include <QTimer>
0014 
0015 class QKeyEvent;
0016 class QPaintEvent;
0017 
0018 #define AUMAX 48
0019 
0020 class KSPlanetBase;
0021 
0022 class PlanetViewerUI : public QFrame, public Ui::PlanetViewer
0023 {
0024     Q_OBJECT
0025 
0026   public:
0027     explicit PlanetViewerUI(QWidget *parent = nullptr);
0028 };
0029 
0030 /**
0031  * @class PlanetViewer
0032  * @short Display an overhead view of the solar system
0033  *
0034  * @version 1.0
0035  * @author Jason Harris
0036  */
0037 class PlanetViewer : public QDialog
0038 {
0039     Q_OBJECT
0040 
0041   public:
0042     explicit PlanetViewer(QWidget *parent = nullptr);
0043 
0044     inline QString centerPlanet() const { return CenterPlanet; }
0045     inline void setCenterPlanet(const QString &cp) { CenterPlanet = cp; }
0046 
0047     inline KPlotObject *planetObject(uint i) const { return planet[i]; }
0048     QString planetName(uint i) const;
0049 
0050   protected:
0051     void keyPressEvent(QKeyEvent *e) override;
0052     void paintEvent(QPaintEvent *) override;
0053 
0054   private slots:
0055     void initPlotObjects();
0056     void tick();
0057     void setTimeScale(float);
0058     void slotChangeDate();
0059     void slotRunClock();
0060     void slotToday();
0061     void slotCloseWindow();
0062 
0063   private:
0064     void updatePlanets();
0065 
0066     PlanetViewerUI *pw { nullptr };
0067     KStarsDateTime ut;
0068     double scale { 0 };
0069     bool isClockRunning { false };
0070     QTimer tmr;
0071     int UpdateInterval[9], LastUpdate[9];
0072     QString CenterPlanet;
0073     QList<KSPlanetBase *> PlanetList;
0074     KPlotObject *ksun { nullptr };
0075     KPlotObject *planet[9] { nullptr };
0076 };