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())
53 m_ellipse->
updateGeometry(0, 0,
int(size / 2),
int(size / 2),
false);
56AsterismSymbol::AsterismSymbol(
const QColor &color)
76void AsterismSymbol::updateSymbol(
float x,
float y,
float e,
float size)
95GlobularClusterSymbol::GlobularClusterSymbol(
const QColor &color) : e1(new
EllipseNode(color))
106 lines->setGeometry(geometry);
111 lines->setOpaqueMaterial(material);
115void GlobularClusterSymbol::updateSymbol(
float x,
float y,
float e,
float size)
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)
153void DarkNebulaSymbol::updateSymbol(
float x,
float y,
float e,
float size)
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)
198void PlanetaryNebulaSymbol::updateSymbol(
float x,
float y,
float e,
float size)
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)
245void SupernovaRemnantSymbol::updateSymbol(
float x,
float y,
float e,
float size)
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)
299 lines->setGeometry(geometry);
304 lines->setOpaqueMaterial(material);
310void GalaxyClusterSymbol::updateSymbol(
float x,
float y,
float e,
float size)
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);
357 : m_color(color), m_dso(skyObject)
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);
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.
void updateGeometry(float x, float y, int width, int height, bool filled)
Redraw ellipse with the given width, height and positions (x,y)
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 setGeometry(QSGGeometry *geometry)
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)
Point2D * vertexDataAsPoint2D()
void setOpaqueMaterial(QSGMaterial *material)
void appendChildNode(QSGNode *node)
void markDirty(DirtyState bits)
void setFlag(Flag f, bool enabled)
NodeType type() const const