Kstars

terrainrenderer.h
1/*
2 SPDX-FileCopyrightText: 2021 Hy Murveit <hy@murveit.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <memory>
10#include <QObject>
11#include <QImage>
12#include "projections/projector.h"
13
14class TerrainLookup;
15
16class TerrainRenderer : public QObject
17{
19 public:
20 // Create an instance of TerrainRenderer. We only have one.
21 static TerrainRenderer *Instance();
22
23 // Render terrainImage according to the loaded image and the projection.
24 bool render(uint16_t w, uint16_t h, QImage *terrainImage, const Projector *proj);
25 signals:
26
27 public slots:
28
29 private:
30 // Constructor is private. Only make it with Instance().
31 TerrainRenderer();
32
33 // Speed-up the image calculations by downsampling azimuth and altitude
34 // computations of the pixels in the input view.
35 void setupLookup(uint16_t w, uint16_t h, int sampling, const Projector *proj,
36 TerrainLookup *azLookup, TerrainLookup *altLookup);
37
38 // Returns the pixel in sourceImage for the given coordinates.
39 QRgb getPixel(double az, double alt) const;
40
41 // Checks to see if we can use the old rendering.
42 // If not, copies the view for the next call.
43 bool sameView(const Projector *proj, bool forceRefresh);
44
45 // This is the only instance we'll make.
46 static TerrainRenderer * _terrainRenderer;
47
48 // True if the terrain image is setup.
49 bool initialized = false;
50
51 // The terrain image projection.
52 QImage sourceImage;
53
54 // Save the input view and the computed image in case the image can be re-used.
55 ViewParams savedViewParams;
56 double savedAz, savedAlt;
57 QImage savedImage;
58
59 // Keep the parameters used to display the last image
60 // to see if something's changed and we need to redisplay.
61 QString sourceFilename;
62 int terrainDownsampling = 0;
63 bool terrainSkipSpeedup = false;
64 bool terrainSmoothPixels = false;
65 bool terrainTransparencySpeedup = false;
66 bool terrainSourceCorrectAz = 0;
67 bool terrainSourceCorrectAlt = 0;
68};
The Projector class is the primary class that serves as an interface to handle projections.
Definition projector.h:58
This is just a container that holds information needed to do projections.
Definition projector.h:37
Q_OBJECTQ_OBJECT
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.