Kstars

constellationartnode.cpp
1/*
2 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
3 SPDX-License-Identifier: GPL-2.0-or-later
4*/
5#include "skyobject.h"
6#include "Options.h"
7
8#include <QQuickWindow>
9#include <QSGSimpleTextureNode>
10
11#include "constellationartnode.h"
12#include "constellationsart.h"
13#include "nodes/pointnode.h"
14
15#include "../rootnode.h"
16#include "../labelsitem.h"
17#include "labelnode.h"
18
20 : SkyNode(obj), m_art(obj), m_texture(new QSGSimpleTextureNode)
21{
22 m_texture->setTexture(
23 SkyMapLite::Instance()->window()->createTextureFromImage(m_art->image(), QQuickWindow::TextureCanUseAtlas));
25 m_opacity->appendChildNode(m_texture);
26 update();
27}
28
30{
31 double zoom = Options::zoomFactor();
32
33 const Projector *m_proj = SkyMapLite::Instance()->projector();
34 if (!m_proj->checkVisibility(m_art))
35 {
36 hide();
37 return;
38 }
39
40 bool visible = false;
41 m_art->EquatorialToHorizontal(KStarsData::Instance()->lst(), KStarsData::Instance()->geo()->lat());
42 QPointF constellationmidpoint = m_proj->toScreen(m_art, true, &visible);
43
44 if (!visible || !m_proj->onScreen(constellationmidpoint))
45 {
46 hide();
47 return;
48 }
49
50 m_opacity->setOpacity(0.7);
51
52 //qDebug() << "o->pa() " << obj->pa();
53 float positionangle = m_proj->findPA(m_art, constellationmidpoint.x(), constellationmidpoint.y());
54 //qDebug() << " final PA " << positionangle;
55
56 float w = m_art->getWidth() * 60 * dms::PI * zoom / 10800;
57 float h = m_art->getHeight() * 60 * dms::PI * zoom / 10800;
58
59 m_texture->setRect(0, 0, w, h);
60
62}
63
65{
66 QSizeF size = m_texture->rect().size();
67 QMatrix4x4 m(1, 0, 0, pos.x(), 0, 1, 0, pos.y(), 0, 0, 1, 0, 0, 0, 0, 1);
68 m.rotate(positionangle, 0, 0, 1);
69 m.translate(-0.5 * size.width(), -0.5 * size.height());
70
71 setMatrix(m);
73}
74
76{
77 //m_point->hide();
79}
virtual void hide() override
hides all child nodes (sets opacity of m_opacity to 0)
virtual void update() override
Updates coordinate of the object on SkyMapLite.
ConstellationArtNode(ConstellationsArt *obj)
Constructor.
void changePos(QPointF pos, double positionangle)
changePos change the position of this node
Information about a ConstellationsArt object.
const QImage & image()
The Projector class is the primary class that serves as an interface to handle projections.
Definition projector.h:58
QPointF toScreen(const SkyPoint *o, bool oRefract=true, bool *onVisibleHemisphere=nullptr) const
This is exactly the same as toScreenVec but it returns a QPointF.
Definition projector.cpp:93
double findPA(const SkyObject *o, float x, float y) const
Determine the on-screen position angle of a SkyObject.
bool onScreen(const QPointF &p) const
Check whether the projected point is on-screen.
Definition projector.cpp:98
bool checkVisibility(const SkyPoint *p) const
Determine if the skypoint p is likely to be visible in the display window.
Provides virtual functions for update of coordinates and nodes hiding.
Definition skynode.h:28
virtual void hide()
hides all child nodes (sets opacity of m_opacity to 0)
Definition skynode.cpp:21
bool visible()
Definition skynode.cpp:44
void EquatorialToHorizontal(const CachingDms *LST, const CachingDms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates,...
Definition skypoint.cpp:77
static constexpr double PI
PI is a const static member; it's public so that it can be used anywhere, as long as dms....
Definition dms.h:385
qreal x() const const
qreal y() const const
QSizeF size() const const
void appendChildNode(QSGNode *node)
void markDirty(DirtyState bits)
void setOpacity(qreal opacity)
QRectF rect() const const
void setFiltering(QSGTexture::Filtering filtering)
void setRect(const QRectF &r)
void setTexture(QSGTexture *texture)
void setMatrix(const QMatrix4x4 &matrix)
qreal height() const const
qreal width() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:49:22 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.