7#include "fovsymbolnode.h"
9#include "nodes/rectnode.h"
10#include "nodes/ellipsenode.h"
12#include <QSGFlatColorMaterial>
20 m_sizeY = (b < 0.0) ? a : b;
33 m_symbol =
new SquareFOV();
36 m_symbol =
new CircleFOV();
38 case FOVItem::CROSSHAIRS:
39 m_symbol =
new CrosshairFOV();
41 case FOVItem::BULLSEYE:
42 m_symbol =
new BullsEyeFOV();
44 case FOVItem::SOLIDCIRCLE:
45 m_symbol =
new SolidCircleFOV();
52 addChildNode(m_symbol);
58 float pixelSizeX = m_sizeX * zoomFactor / 57.3 / 60.0;
59 float pixelSizeY = m_sizeY * zoomFactor / 57.3 / 60.0;
61 float offsetXPixelSize = m_offsetX * zoomFactor / 57.3 / 60.0;
62 float offsetYPixelSize = m_offsetY * zoomFactor / 57.3 / 60.0;
67 if (m_center.ra().Degrees() > 0)
69 m_center.EquatorialToHorizontal(KStarsData::Instance()->lst(), KStarsData::Instance()->geo()->lat());
70 QPointF skypoint_center =
map->projector()->toScreen(&m_center);
76 newMatrix.
translate(center.x(), center.y());
79 newMatrix.
translate(offsetXPixelSize, offsetYPixelSize);
80 newMatrix.
rotate(m_rotation + m_northPA, 0, 0, 1);
82 m_symbol->setMatrix(newMatrix);
84 m_symbol->updateSymbol(m_color, pixelSizeX, pixelSizeY);
106 lines->geometry()->allocate(6);
107 lines->geometry()->setDrawingMode(GL_LINES);
110void SquareFOV::updateSymbol(
QColor color,
float pixelSizeX,
float pixelSizeY)
122 rect1->setRect(
center.x() - pixelSizeX / 2,
center.y() - pixelSizeY / 2, pixelSizeX, pixelSizeY);
123 rect1->setColor(color);
125 rect2->setRect(
center.x(),
center.y() - (3 * pixelSizeY / 5), pixelSizeX / 40, pixelSizeX / 10);
126 rect2->setColor(color);
128 QSGFlatColorMaterial *material =
static_cast<QSGFlatColorMaterial *
>(lines->opaqueMaterial());
129 if (material->
color() != color)
135 QSGGeometry::Point2D *vertex = lines->geometry()->vertexDataAsPoint2D();
136 vertex[0].
set(
center.x() - pixelSizeX / 30,
center.y() - (3 * pixelSizeY / 5));
137 vertex[1].
set(
center.x() + pixelSizeX / 20,
center.y() - (3 * pixelSizeY / 5));
139 vertex[2].
set(
center.x() - pixelSizeX / 30,
center.y() - (3 * pixelSizeY / 5));
140 vertex[3].
set(
center.x() + pixelSizeX / 70,
center.y() - (0.7 * pixelSizeY));
142 vertex[4].
set(
center.x() + pixelSizeX / 20,
center.y() - (3 * pixelSizeY / 5));
143 vertex[5].
set(
center.x() + pixelSizeX / 70,
center.y() - (0.7 * pixelSizeY));
150 el =
new EllipseNode();
154void CircleFOV::updateSymbol(
QColor color,
float pixelSizeX,
float pixelSizeY)
157 el->updateGeometry(0, 0, pixelSizeX / 2, pixelSizeY / 2,
false);
162 lines =
new QSGGeometryNode;
166 lines->setOpaqueMaterial(
new QSGFlatColorMaterial);
169 lines->geometry()->allocate(8);
170 lines->geometry()->setDrawingMode(GL_LINES);
172 el1 =
new EllipseNode;
175 el2 =
new EllipseNode;
179void CrosshairFOV::updateSymbol(
QColor color,
float pixelSizeX,
float pixelSizeY)
183 QSGGeometry::Point2D *vertex = lines->geometry()->vertexDataAsPoint2D();
199 el1->setColor(color);
200 el1->updateGeometry(
center.x(),
center.y(), 0.5 * pixelSizeX, 0.5 * pixelSizeY,
false);
202 el2->setColor(color);
203 el1->updateGeometry(
center.x(),
center.y(), pixelSizeX, pixelSizeY,
false);
208 el1 =
new EllipseNode;
211 el2 =
new EllipseNode;
214 el3 =
new EllipseNode;
218void BullsEyeFOV::updateSymbol(
QColor color,
float pixelSizeX,
float pixelSizeY)
220 el1->setColor(color);
221 el1->updateGeometry(0, 0, 0.5 * pixelSizeX, 0.5 * pixelSizeY,
false);
223 el2->setColor(color);
224 el2->updateGeometry(0, 0, 2.0 * pixelSizeX, 2.0 * pixelSizeY,
false);
226 el3->setColor(color);
227 el3->updateGeometry(0, 0, 4.0 * pixelSizeX, 4.0 * pixelSizeY,
false);
232 el =
new EllipseNode;
236void SolidCircleFOV::updateSymbol(
QColor color,
float pixelSizeX,
float pixelSizeY)
238 QColor colorAlpha = color;
240 el->setColor(colorAlpha);
241 el->updateGeometry(0, 0, pixelSizeX / 2, pixelSizeY / 2,
false);
This class handles representation of FOV symbols in SkyMapLite.
FOVSymbolBase is a virtual class that should be subclassed by every type of FOV symbol.
FOVSymbolBase(FOVItem::Shape shape)
FOVSymbolNode(const QString &name, float a, float b, float xoffset, float yoffset, float rot, FOVItem::Shape shape=FOVItem::SQUARE, const QString &color="#FFFFFF")
Constructor.
QSGGeometryNode derived class that draws filled and non-filled rectangles.
This is the main item that displays all SkyItems.
virtual void show()
shows all child nodes (sets opacity of m_opacity to 1)
virtual void update()
Updates coordinate of the object on SkyMapLite.
SkyMapLite * map() const
short function to access SkyMapLite
void rotate(const QQuaternion &quaternion)
void translate(const QVector3D &vector)
QPoint toPoint() const const
const QColor & color() const const
void setColor(const QColor &color)
void set(float x, float y)
const AttributeSet & defaultAttributes_Point2D()
void appendChildNode(QSGNode *node)
QTextStream & center(QTextStream &stream)