6#include "dsosymbolnode.h"
8#include "deepskyobject.h"
10#include "nodes/ellipsenode.h"
12#include <QSGFlatColorMaterial>
16 zoom = Options::zoomFactor();
23 dy1 = -1.0 * e * size / 2.;
32 dya = -1.0 * e * size / 4.;
45void StarSymbol::updateSymbol(
float x,
float y,
float e,
float size)
50 if (Options::useAntialias())
51 m_ellipse->updateGeometry(0, 0, size, e * size,
false);
53 m_ellipse->updateGeometry(0, 0,
int(size / 2),
int(size / 2),
false);
56AsterismSymbol::AsterismSymbol(
const QColor &color)
58 e1 =
new EllipseNode(color);
59 e2 =
new EllipseNode(color);
60 e3 =
new EllipseNode(color);
61 e4 =
new EllipseNode(color);
62 e5 =
new EllipseNode(color);
63 e6 =
new EllipseNode(color);
64 e7 =
new EllipseNode(color);
65 e8 =
new EllipseNode(color);
76void AsterismSymbol::updateSymbol(
float x,
float y,
float e,
float size)
85 e1->updateGeometry(xa, y1, psize, psize,
true);
86 e2->updateGeometry(xb, y1, psize, psize,
true);
87 e3->updateGeometry(xa, y2, psize, psize,
true);
88 e4->updateGeometry(xb, y2, psize, psize,
true);
89 e5->updateGeometry(x1, ya, psize, psize,
true);
90 e6->updateGeometry(x1, yb, psize, psize,
true);
91 e7->updateGeometry(x2, ya, psize, psize,
true);
92 e8->updateGeometry(x2, yb, psize, psize,
true);
95GlobularClusterSymbol::GlobularClusterSymbol(
const QColor &color) : e1(new
EllipseNode(color))
99 lines =
new QSGGeometryNode;
106 lines->setGeometry(geometry);
109 QSGFlatColorMaterial *material =
new QSGFlatColorMaterial;
111 lines->setOpaqueMaterial(material);
115void GlobularClusterSymbol::updateSymbol(
float x,
float y,
float e,
float size)
121 e1->updateGeometry(0, 0, size, e * size,
false);
123 QSGGeometry::Point2D *vertex = lines->geometry()->vertexDataAsPoint2D();
125 vertex[0].
set(dx1, 0);
126 vertex[1].
set(dx2, 0);
129 vertex[2].
set(0, dy1);
130 vertex[3].
set(0, dy2);
135DarkNebulaSymbol::DarkNebulaSymbol(
const QColor &color)
137 lines =
new QSGGeometryNode;
144 lines->setGeometry(geometry);
147 QSGFlatColorMaterial *material =
new QSGFlatColorMaterial;
149 lines->setOpaqueMaterial(material);
153void DarkNebulaSymbol::updateSymbol(
float x,
float y,
float e,
float size)
157 QSGGeometry::Point2D *vertex = lines->geometry()->vertexDataAsPoint2D();
159 vertex[0].
set(dx1, dy1);
160 vertex[1].
set(dx2, dy1);
163 vertex[2].
set(dx2, dy1);
164 vertex[3].
set(dx2, dy2);
167 vertex[4].
set(dx2, dy2);
168 vertex[5].
set(dx1, dy2);
171 vertex[6].
set(dx1, dy2);
172 vertex[7].
set(dx1, dy1);
177PlanetaryNebulaSymbol::PlanetaryNebulaSymbol(
const QColor &color)
179 e1 =
new EllipseNode(color);
182 lines =
new QSGGeometryNode;
189 lines->setGeometry(geometry);
192 QSGFlatColorMaterial *material =
new QSGFlatColorMaterial;
194 lines->setOpaqueMaterial(material);
198void PlanetaryNebulaSymbol::updateSymbol(
float x,
float y,
float e,
float size)
205 e1->updateGeometry(0, 0, size, e * size,
false);
207 QSGGeometry::Point2D *vertex = lines->geometry()->vertexDataAsPoint2D();
209 vertex[0].
set(0., dy1);
210 vertex[1].
set(0., dy1 - e * size / 2.);
213 vertex[2].
set(0., dy2);
214 vertex[3].
set(0., dy2 + e * size / 2.);
217 vertex[4].
set(dx1, 0.);
218 vertex[5].
set(dx1 - size / 2., 0.);
221 vertex[6].
set(dx2, 0.);
222 vertex[7].
set(dx2 + size / 2., 0.);
227SupernovaRemnantSymbol::SupernovaRemnantSymbol(
const QColor &color)
229 lines =
new QSGGeometryNode;
236 lines->setGeometry(geometry);
239 QSGFlatColorMaterial *material =
new QSGFlatColorMaterial;
241 lines->setOpaqueMaterial(material);
245void SupernovaRemnantSymbol::updateSymbol(
float x,
float y,
float e,
float size)
249 QSGGeometry::Point2D *vertex = lines->geometry()->vertexDataAsPoint2D();
252 vertex[0].
set(0., dy1);
253 vertex[1].
set(dx2, 0.);
256 vertex[2].
set(dx2, 0.);
257 vertex[3].
set(0., dy2);
260 vertex[4].
set(0., dy2);
261 vertex[5].
set(dx1, 0.);
264 vertex[6].
set(dx1, 0.);
265 vertex[7].
set(0., dy1);
275void GalaxySymbol::updateSymbol(
float x,
float y,
float e,
float size)
279 if (size < 1. && zoom > 20 * MINZOOM)
281 if (size < 1. && zoom > 5 * MINZOOM)
285 e1->updateGeometry(0, 0, size, e * size,
false);
289 e1->updateGeometry(0, 0, 1, 1,
false);
299 lines->setGeometry(geometry);
302 QSGFlatColorMaterial *material =
new QSGFlatColorMaterial;
304 lines->setOpaqueMaterial(material);
310void GalaxyClusterSymbol::updateSymbol(
float x,
float y,
float e,
float size)
318 QSGGeometry::Point2D *vertex = lines->geometry()->vertexDataAsPoint2D();
320 vertex[0].
set(xa - psize, y1);
321 vertex[1].
set(xa + psize, y1);
322 vertex[2].
set(xa, y1 - psize);
323 vertex[3].
set(xa, y1 + psize);
324 vertex[4].
set(xb - psize, y1);
325 vertex[5].
set(xb + psize, y1);
326 vertex[6].
set(xb, y1 - psize);
327 vertex[7].
set(xb, y1 + psize);
328 vertex[8].
set(xa - psize, y2);
329 vertex[9].
set(xa + psize, y2);
330 vertex[10].
set(xa, y2 - psize);
331 vertex[11].
set(xa, y2 + psize);
332 vertex[12].
set(xb - psize, y2);
333 vertex[13].
set(xb + psize, y2);
334 vertex[14].
set(xb, y2 - psize);
335 vertex[15].
set(xb, y2 + psize);
336 vertex[16].
set(x1 - psize, ya);
337 vertex[17].
set(x1 + psize, ya);
338 vertex[18].
set(x1, ya - psize);
339 vertex[19].
set(x1, ya + psize);
340 vertex[20].
set(x1 - psize, yb);
341 vertex[21].
set(x1 + psize, yb);
342 vertex[22].
set(x1, yb - psize);
343 vertex[23].
set(x1, yb + psize);
344 vertex[24].
set(x2 - psize, ya);
345 vertex[25].
set(x2 + psize, ya);
346 vertex[26].
set(x2, ya - psize);
347 vertex[27].
set(x2, ya + psize);
348 vertex[28].
set(x2 - psize, yb);
349 vertex[29].
set(x2 + psize, yb);
350 vertex[30].
set(x2, yb - psize);
351 vertex[31].
set(x2, yb + psize);
365 int type = m_dso->type();
371 m_symbol =
new StarSymbol(m_color);
375 m_symbol =
new AsterismSymbol(m_color);
378 m_symbol =
new GlobularClusterSymbol(m_color);
383 m_symbol =
new DarkNebulaSymbol(m_color);
387 m_symbol =
new PlanetaryNebulaSymbol(m_color);
391 m_symbol =
new SupernovaRemnantSymbol(m_color);
396 m_symbol =
new GalaxySymbol(m_color);
400 m_symbol =
new GalaxyClusterSymbol(m_color);
407 addChildNode(m_symbol);
413 QMatrix4x4 m(1, 0, 0, pos.
x(), 0, 1, 0, pos.
y(), 0, 0, 1, 0, 0, 0, 0, 1);
417 m.
rotate(positionangle, 0, 0, 1);
430 m_symbol->updateSymbol(pos.
x(), pos.
y(), m_dso->e(), size);
436 qDebug() <<
"Symbol for object " << m_dso->name() <<
" wasn't created. Check DSOSymbolNode::initSymbol()";
DSOSymbolNode(DeepSkyObject *skyObject, const QColor &color=QColor())
Constructor.
void changePos(const QPointF &pos, float positionangle)
Changes position and rotation angle of the symbol.
void initSymbol()
Create SymbolNode based on the type of m_dso.
QSGTransformNode derived node used to draw ellipses.
SkyObject * skyObject() const
returns SkyObject associated with this SkyNode
virtual void show()
shows all child nodes (sets opacity of m_opacity to 1)
virtual void update()
Updates coordinate of the object on SkyMapLite.
virtual void updateSymbol(float x, float y, float e, float size)
Update size and the symbol itself.
void rotate(const QQuaternion &quaternion)
void setColor(const QColor &color)
void set(float x, float y)
void allocate(int vertexCount, int indexCount)
const AttributeSet & defaultAttributes_Point2D()
void setDrawingMode(unsigned int mode)
void appendChildNode(QSGNode *node)
void markDirty(DirtyState bits)
NodeType type() const const