File indexing completed on 2024-05-12 03:45:46
0001 /* 0002 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #include "pointnode.h" 0007 0008 #include "Options.h" 0009 #include "skymaplite.h" 0010 #include "../../rootnode.h" 0011 0012 #include <QQuickWindow> 0013 #include <QSGSimpleTextureNode> 0014 0015 PointNode::PointNode(RootNode *p, char sp, float size) 0016 : spType(sp), texture(new QSGSimpleTextureNode), m_rootNode(p), 0017 starColorMode(Options::starColorMode()) 0018 { 0019 appendChildNode(texture); 0020 setSize(size); 0021 } 0022 0023 void PointNode::setSize(float size) 0024 { 0025 int isize = qMin(static_cast<int>(size), 14); 0026 uint newStarCM = Options::starColorMode(); 0027 if (size != m_size || newStarCM != starColorMode) 0028 { 0029 texture->setTexture(m_rootNode->getCachedTexture(isize, spType)); 0030 0031 //We divide size of texture by ratio. Otherwise texture will be very large 0032 qreal ratio = SkyMapLite::Instance()->window()->effectiveDevicePixelRatio(); 0033 0034 QSize tSize = texture->texture()->textureSize(); 0035 QRectF oldRect = texture->rect(); 0036 texture->setRect(QRect(oldRect.x(), oldRect.y(), tSize.width() / ratio, tSize.height() / ratio)); 0037 m_size = size; 0038 starColorMode = newStarCM; 0039 } 0040 } 0041 0042 QSizeF PointNode::size() const 0043 { 0044 return texture->rect().size(); 0045 }