Kstars

pointnode.cpp
1/*
2 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
3 SPDX-License-Identifier: GPL-2.0-or-later
4*/
5
6#include "pointnode.h"
7
8#include "Options.h"
9#include "skymaplite.h"
10#include "../../rootnode.h"
11
12#include <QQuickWindow>
13#include <QSGSimpleTextureNode>
14
15PointNode::PointNode(RootNode *p, char sp, float size)
16 : spType(sp), texture(new QSGSimpleTextureNode), m_rootNode(p),
17 starColorMode(Options::starColorMode())
18{
19 appendChildNode(texture);
20 setSize(size);
21}
22
23void PointNode::setSize(float size)
24{
25 int isize = qMin(static_cast<int>(size), 14);
26 uint newStarCM = Options::starColorMode();
27 if (size != m_size || newStarCM != starColorMode)
28 {
29 texture->setTexture(m_rootNode->getCachedTexture(isize, spType));
30
31 //We divide size of texture by ratio. Otherwise texture will be very large
32 qreal ratio = SkyMapLite::Instance()->window()->effectiveDevicePixelRatio();
33
34 QSize tSize = texture->texture()->textureSize();
35 QRectF oldRect = texture->rect();
36 texture->setRect(QRect(oldRect.x(), oldRect.y(), tSize.width() / ratio, tSize.height() / ratio));
37 m_size = size;
38 starColorMode = newStarCM;
39 }
40}
41
42QSizeF PointNode::size() const
43{
44 return texture->rect().size();
45}
void setSize(float size)
setSize update size of PointNode with the given parameter
Definition pointnode.cpp:23
PointNode(RootNode *p, char sp='A', float size=1)
Constructor.
Definition pointnode.cpp:15
A QSGClipNode derived class used as a container for holding pointers to nodes and for clipping.
Definition rootnode.h:60
QSGTexture * getCachedTexture(int size, char spType)
returns cached texture from textureCache
Definition rootnode.cpp:185
QQuickWindow * window() const const
qreal effectiveDevicePixelRatio() const const
QSizeF size() const const
qreal x() const const
qreal y() const const
void appendChildNode(QSGNode *node)
QRectF rect() const const
void setRect(const QRectF &r)
void setTexture(QSGTexture *texture)
QSGTexture * texture() const const
virtual QSize textureSize() const const=0
int height() const const
int width() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.