File indexing completed on 2024-04-28 15:09:02

0001 /*  Ekos Alignment View
0002     Child of FITSView with few additions necessary for Alignment functions
0003 
0004     SPDX-FileCopyrightText: 2017 Jasem Mutlaq <mutlaqja@ikarustech.com>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #pragma once
0010 
0011 #include "fitsviewer/fitsview.h"
0012 
0013 #include <QVector3D>
0014 
0015 class QPainter;
0016 
0017 class AlignView : public FITSView
0018 {
0019         Q_OBJECT
0020     public:
0021         explicit AlignView(QWidget *parent = nullptr, FITSMode mode = FITS_NORMAL, FITSScale filter = FITS_NONE);
0022 
0023         // Calculate WCS header info and update WCS info.
0024         // If the expensive computations are not included, e.g. extras == false, then there's
0025         // no reason to block (i.e. use the wcsWatcher). The computations are quick.
0026         bool injectWCS(double orientation, double ra, double dec, double pixscale, bool eastToTheRight, bool block = true);
0027 
0028         void drawOverlay(QPainter *, double scale) override;
0029 
0030         // Resets the marker and lines, celestial pole point and raAxis.
0031         void reset();
0032 
0033         // Setup correction triangle
0034         void setCorrectionParams(const QPointF &from, const QPointF &to, const QPointF &altTo);
0035 
0036         void setRaAxis(const QPointF &value);
0037         void setCelestialPole(const QPointF &value);
0038         void setRefreshEnabled(bool enable);
0039 
0040         // When non-null, alignview draws a small circle in the pixel position specified.
0041         void setStarCircle(const QPointF &pixel = QPointF());
0042 
0043         void holdOnToImage();
0044         void releaseImage();
0045         const QSharedPointer<FITSData> keptImage() const
0046         {
0047             return keptImagePointer;
0048         }
0049 
0050     protected:
0051         // Draw the polar-align triangle which guides the user how to correct polar alignment.
0052         void drawTriangle(QPainter *painter, const QPointF &from, const QPointF &to, const QPointF &altTo);
0053         // Draws the mounts current RA axis (set in setRaAxis() above).
0054         void drawRaAxis(QPainter *painter);
0055         // Draw the circle around the star used to help the user correct polar alignment.
0056         void drawStarCircle(QPainter *painter, const QPointF &center, double radius, const QColor &color);
0057 
0058         virtual void processMarkerSelection(int x, int y) override;
0059 
0060     private:
0061         // Correction points. from=user-selected point. to=destination for the point.
0062         // altTo = destination to correct altitude only.
0063         QPointF correctionFrom, correctionTo, correctionAltTo;
0064         // The celestial pole's position on the image.
0065         QPointF celestialPolePoint;
0066         // The mount's RA axis' position on the image.
0067         QPointF raAxis;
0068         QSharedPointer<FITSData> keptImagePointer;
0069         // The position of a star being tracked in the polar-alignment routine.
0070         QPointF starCircle;
0071 
0072     signals:
0073         void newCorrectionVector(QLineF correctionVector);
0074 };