File indexing completed on 2024-04-28 03:43:41

0001 /*
0002     SPDX-FileCopyrightText: 2015 Jasem Mutlaq <mutlaqja@ikarustech.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "skypoint.h"
0010 
0011 #include <QGraphicsScene>
0012 #include <QGraphicsItem>
0013 #include <QDialog>
0014 #include <QBrush>
0015 #include <QPen>
0016 
0017 namespace Ui
0018 {
0019 class FramingAssistant;
0020 }
0021 
0022 namespace Ekos
0023 {
0024 class Scheduler;
0025 class MosaicTilesManager;
0026 class MosaicTilesScene;
0027 
0028 class FramingAssistant : public QDialog
0029 {
0030         Q_OBJECT
0031         Q_PROPERTY(double focalLength MEMBER m_FocalLength)
0032         Q_PROPERTY(double overlap MEMBER m_Overlap)
0033         Q_PROPERTY(double rotation MEMBER m_Rotation)
0034         Q_PROPERTY(QSize cameraSize MEMBER m_CameraSize)
0035         Q_PROPERTY(QSizeF pixelSize MEMBER m_PixelSize)
0036         Q_PROPERTY(QSize gridSize MEMBER m_GridSize)
0037 
0038     public:
0039         static FramingAssistant *Instance();
0040 
0041     public:
0042         Ui::FramingAssistant* ui { nullptr };
0043 
0044         void setCenter(const SkyPoint &value);
0045         QString getJobsDir() const;
0046         void syncModelToGUI();
0047         void syncGUIToModel();
0048 
0049     public:
0050         typedef struct _Job
0051         {
0052             SkyPoint center;
0053             double rotation;
0054             bool doAlign;
0055             bool doFocus;
0056         } Job;
0057 
0058         QList <Job> getJobs() const;
0059 
0060     protected:
0061         virtual void showEvent(QShowEvent *) override;
0062         virtual void resizeEvent(QResizeEvent *) override;        
0063 
0064         /// @brief Camera information validity checker.
0065         bool isScopeInfoValid() const;
0066 
0067         /// @brief Expected arcmin field width for the current number of tiles.
0068         double getTargetWFOV() const;
0069 
0070         /// @brief Expected arcmin field height for the current number of tiles.
0071         double getTargetHFOV() const;
0072 
0073         /// @brief Expected number of tiles for the current target field width.
0074         double getTargetMosaicW() const;
0075 
0076         /// @brief Expected number of tiles for the current target field height.
0077         double getTargetMosaicH() const;
0078 
0079         /**
0080          * @brief goAndSolve Go to current center, capture an image, and solve.
0081          */
0082         void goAndSolve();
0083 
0084     public slots:
0085         void updateTargetFOVFromGrid();
0086         void updateGridFromTargetFOV();
0087         void constructMosaic();
0088         void calculateFOV();
0089         void updateTargetFOV();
0090         void saveJobsDirectory();
0091         void resetFOV();
0092         void fetchINDIInformation();
0093         void rewordStepEvery(int v);
0094 
0095     private:
0096 
0097         FramingAssistant();
0098         ~FramingAssistant() override;
0099 
0100         static FramingAssistant *_FramingAssistant;
0101 
0102         SkyPoint m_CenterPoint;
0103         QImage *m_skyChart { nullptr };
0104 
0105         QPixmap targetPix;
0106         QGraphicsPixmapItem *m_SkyPixmapItem { nullptr };
0107 
0108         MosaicTilesManager *m_MosaicTilesManager { nullptr };
0109 
0110         double pixelsPerArcminRA { 0 }, pixelsPerArcminDE { 0 };
0111         double renderedWFOV { 0 }, renderedHFOV { 0 };
0112         double premosaicZoomFactor { 0 };
0113 
0114         QPointF screenPoint;
0115         QGraphicsScene m_TilesScene;
0116 
0117         bool m_RememberAltAzOption {false}, m_RememberShowGround {false};
0118 
0119         QTimer *updateTimer { nullptr };
0120 
0121         // Equipment
0122         double m_FocalLength {0};
0123         QSize m_CameraSize;
0124         QSizeF m_PixelSize, m_cameraFOV, m_MosaicFOV;
0125         QSize m_GridSize {1,1};
0126         double m_Overlap {10}, m_Rotation {0};
0127 };
0128 }