File indexing completed on 2024-04-21 14:47:11

0001 /*
0002     SPDX-FileCopyrightText: 2010 Henry de Valence <hdevalence@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef SKYGLPAINTER_H
0008 #define SKYGLPAINTER_H
0009 
0010 #include <cstddef>
0011 #include <Eigen/Core>
0012 
0013 #include "skypainter.h"
0014 #include "skyobjects/skyobject.h"
0015 #include "projections/projector.h"
0016 
0017 class QGLWidget;
0018 
0019 class SkyGLPainter : public SkyPainter
0020 {
0021     public:
0022         explicit SkyGLPainter(QGLWidget *widget);
0023         bool drawPlanet(KSPlanetBase *planet) override;
0024         bool drawPointSource(const SkyPoint *loc, float mag, char sp = 'A') override;
0025         void drawSkyPolygon(LineList *list, bool forceClip = true) override;
0026         void drawSkyPolyline(LineList *list, SkipHashList *skipList = nullptr,
0027                              LineListLabel *label = nullptr) override;
0028         void drawSkyLine(SkyPoint *a, SkyPoint *b) override;
0029         void drawSkyBackground() override;
0030         void drawObservingList(const QList<SkyObject *> &obs) override;
0031         void drawFlags() override;
0032         void end() override;
0033         void begin() override;
0034         void setBrush(const QBrush &brush) override;
0035         void setPen(const QPen &pen) override;
0036         void drawHorizon(bool filled, SkyPoint *labelPoint = nullptr,
0037                          bool *drawLabel = nullptr) override;
0038         bool drawSatellite(Satellite *sat) override;
0039         bool drawSupernova(Supernova *sup) override;
0040         void drawText(int x, int y, const QString text, QFont font, QColor color);
0041         bool drawConstellationArtImage(ConstellationsArt *obj) override;
0042         bool drawHips(bool useCache = false) override;
0043 
0044     private:
0045         bool addItem(SkyPoint *p, int type, float width, char sp = 'a');
0046         void drawBuffer(int type);
0047         void drawPolygon(const QVector<Eigen::Vector2f> &poly, bool convex = true,
0048                          bool flush_buffers = true);
0049 
0050         /** Render textured rectangle on screeen. Parameters are texture
0051              *  to be used, position, orientation and size of rectangle*/
0052         void drawTexturedRectangle(const QImage &img, const Eigen::Vector2f &pos, const float angle,
0053                                    const float sizeX, const float sizeY);
0054 
0055         const Projector *m_proj;
0056 
0057         Eigen::Vector4f m_pen;
0058         static const int BUFSIZE = 512;
0059         ///FIXME: what kind of TYPE_UNKNOWN objects are there?
0060         static const int NUMTYPES = (int)SkyObject::TYPE_UNKNOWN + 1;
0061         static Eigen::Vector2f m_vertex[NUMTYPES][6 * BUFSIZE];
0062         static Eigen::Vector2f m_texcoord[NUMTYPES][6 * BUFSIZE];
0063         static Eigen::Vector3f m_color[NUMTYPES][6 * BUFSIZE];
0064         static int m_idx[NUMTYPES];
0065         static bool m_init;  ///< keep track of whether we have filled the texcoord array
0066         QGLWidget *m_widget; // Pointer to (GL) widget on which we are painting
0067 };
0068 
0069 #endif // SKYGLPAINTER_H