11#include "kstars_debug.h"
14#include "projections/projector.h"
15#include "projections/lambertprojector.h"
20HIPSFinder * HIPSFinder::m_Instance =
nullptr;
25HIPSFinder *HIPSFinder::Instance()
27 if (m_Instance ==
nullptr)
29 m_Instance =
new HIPSFinder();
38HIPSFinder::HIPSFinder()
40 m_ScanRender.
reset(
new ScanRender());
41 m_HEALpix.
reset(
new HEALPix());
47bool HIPSFinder::render(
SkyPoint *center, uint8_t level,
double zoom,
QImage *destinationImage,
double &fov_w,
50 double ra =
center->ra0().radians();
51 double de =
center->dec0().radians();
55 if (std::isnan(ra) || std::isnan(de))
57 qCWarning(KSTARS) <<
"NAN Center, HiPS rendering failed.";
61 m_RenderedMap.
clear();
65 viewParams.width = destinationImage->
width();
66 viewParams.height = destinationImage->
height();
68 viewParams.useAltAz =
false;
69 viewParams.zoomFactor =
zoom;
75 int centerPix = m_HEALpix->getPix(level, ra, de);
81 m_HEALpix->getCornerPoints(level, centerPix, cornerSkyCoords);
87 for (
int i = 0; i < 2; i++)
88 tileLine[i] = m_Projector->toScreen(&cornerSkyCoords[i]);
90 int size = std::sqrt(std::pow(tileLine[0].x() - tileLine[1].x(), 2) + std::pow(tileLine[0].y() - tileLine[1].y(), 2));
92 size = HIPSManager::Instance()->getCurrentTileWidth();
94 m_ScanRender->setBilinearInterpolationEnabled(size >= HIPSManager::Instance()->getCurrentTileWidth());
96 renderRec(level, centerPix, destinationImage);
98 return !m_RenderedMap.
isEmpty();
104bool HIPSFinder::renderFOV(
SkyPoint *center,
double fov_radius,
double rotation,
QImage *destinationImage)
106 double ra =
center->ra0().radians();
107 double de =
center->dec0().radians();
111 if (std::isnan(ra) || std::isnan(de))
113 qCWarning(KSTARS) <<
"NAN Center, HiPS rendering failed.";
117 m_RenderedMap.
clear();
119 auto width = destinationImage->
width();
120 auto height = destinationImage->
height();
121 auto zoom = sqrt(width * width + height * height) / (fov_radius * 2 * M_PI / 180.0);
125 viewParams.width = width;
126 viewParams.height = height;
128 viewParams.useAltAz =
false;
129 viewParams.zoomFactor =
zoom;
130 viewParams.rotationAngle =
dms(rotation);
131 viewParams.focus =
center;
138 double minfov = 58.5;
139 double fov = m_Projector->fov() * width / height;
149 level = HIPSManager::Instance()->getUsableOfflineLevel(level);
152 int centerPix = m_HEALpix->getPix(level, ra, de);
154 m_ScanRender->setBilinearInterpolationEnabled(Options::hIPSBiLinearInterpolation());
156 renderRec(level, centerPix, destinationImage);
158 return !m_RenderedMap.
isEmpty();
165void HIPSFinder::renderRec(uint8_t level,
int pix,
QImage *destinationImage)
170 if (renderPix(level, pix, destinationImage))
172 m_RenderedMap.
insert(pix);
174 int nside = 1 <<
level;
176 m_HEALpix->neighbours(nside, pix, dirs);
178 renderRec(level, dirs[0], destinationImage);
179 renderRec(level, dirs[2], destinationImage);
180 renderRec(level, dirs[4], destinationImage);
181 renderRec(level, dirs[6], destinationImage);
188bool HIPSFinder::renderPix(
int level,
int pix,
QImage *destinationImage)
192 bool isVisible =
false;
194 m_HEALpix->getCornerPoints(level, pix, cornerSkyCoords);
196 for (
int i = 0; i < 4; i++)
198 cornerScreenCoords[i] = m_Projector->toScreen(&cornerSkyCoords[i]);
199 isVisible |= m_Projector->checkVisibility(&cornerSkyCoords[i]);
204 int dir = (pix / 10000) * 10000;
206 QString(
"/HIPS/Norder%1/Dir%2/Npix%3.jpg").arg(level).arg(dir).arg(pix));
209 if (!sourceImage.isNull())
235 m_HEALpix->getPixChilds(pix, childPixelID);
238 for (
int id : childPixelID)
240 int grandChildPixelID[4];
246 m_HEALpix->getPixChilds(
id, grandChildPixelID);
250 for (
int id2 : grandChildPixelID)
253 m_HEALpix->getCornerPoints(level + 2, id2, fineSkyPoints);
255 for (
int i = 0; i < 4; i++)
256 fineScreenCoords[i] = m_Projector->toScreen(&fineSkyPoints[i]);
258 m_ScanRender->renderPolygon(3, fineScreenCoords, destinationImage, &sourceImage, uv[j]);
Implememntation of Lambert azimuthal equal-area projection
The sky coordinates of a point in the sky.
dms angularDistanceTo(const SkyPoint *sp, double *const positionAngle=nullptr) const
Computes the angular distance between two SkyObjects.
This is just a container that holds information needed to do projections.
bool fillGround
If the ground is filled, then points below horizon are invisible.
An angle, stored as degrees, but expressible in many ways.
const double & Degrees() const
QString path(const QString &relativePath)
QStringView level(QStringView ifopt)
KIOCORE_EXPORT QString dir(const QString &fileClass)
QAction * zoom(const QObject *recvr, const char *slot, QObject *parent)
bool contains(const QSet< T > &other) const const
iterator insert(const T &value)
bool isEmpty() const const
QTextStream & center(QTextStream &stream)