5#include "crosshairnode.h"
8#include "nodes/ellipsenode.h"
10#include "../labelsitem.h"
12#include <QSGFlatColorMaterial>
14CrosshairNode::CrosshairNode(INDI::BaseDevice *baseDevice,
RootNode *rootNode)
22 lines->setGeometry(linesGeo);
27 lines->setMaterial(material);
34 labelsItem = rootNode->labelsItem();
35 label = labelsItem->addLabel(bd->getDeviceName(), LabelsItem::TELESCOPE_SYMBOL);
38CrosshairNode::~CrosshairNode()
40 labelsItem->deleteLabel(label);
44 delete lines->geometry();
51void CrosshairNode::setColor(
QColor color)
53 if (material->color() != color)
55 material->setColor(color);
62void CrosshairNode::update()
65 KStarsData *m_KStarsData = KStarsData::Instance();
68 float pxperdegree = Options::zoomFactor() / 57.3;
70 auto coordNP = bd->getNumber(
"EQUATORIAL_EOD_COORD");
74 coordNP = bd->getNumber(
"HORIZONTAL_COORD");
81 auto np = coordNP->findWidgetByName(
"AZ");
86 indi_sp.
setAz(np->getValue());
88 np = coordNP->findWidgetByName(
"ALT");
92 indi_sp.
setAlt(np->getValue());
98 autonp = coordNP->findWidgetByName(
"RA");
103 indi_sp.
setRA(np->value);
105 np = coordNP->findWidgetByName(
"DEC");
109 indi_sp.
setDec(np->getValue());
112 if (Options::useAltAz())
119 float s1 = 0.5 * pxperdegree;
120 float s2 = pxperdegree;
121 float s3 = 2.0 * pxperdegree;
125 float x1 = x0 - 0.5 * s1;
126 float y1 = y0 - 0.5 * s1;
128 float x3 = x0 - 0.5 * s3;
129 float y3 = y0 - 0.5 * s3;
133 QSGGeometry::Point2D *vertex = lines->geometry()->vertexDataAsPoint2D();
135 vertex[0].
set(x1, y0);
136 vertex[1].
set(x3, y0);
137 vertex[2].
set(x0 + s2, y0);
138 vertex[3].
set(x0 + 0.5 * s1, y0);
139 vertex[4].
set(x0, y1);
140 vertex[5].
set(x0, y3);
141 vertex[6].
set(x0, y0 + 0.5 * s1);
142 vertex[7].
set(x0, y0 + s2);
148 el1->updateGeometry(x0, y0, s1, s1,
false);
149 el2->updateGeometry(x0, y0, s2, s2,
false);
151 label->setLabelPos(QPointF(x0 + s2 + 2., y0));
154void CrosshairNode::hide()
QSGTransformNode derived node used to draw ellipses.
const CachingDms * lat() const
QPointF toScreen(const SkyPoint *o, bool oRefract=true, bool *onVisibleHemisphere=nullptr) const
This is exactly the same as toScreenVec but it returns a QPointF.
A QSGClipNode derived class used as a container for holding pointers to nodes and for clipping.
const Projector * projector() const
Get the current projector.
virtual void hide()
hides all child nodes (sets opacity of m_opacity to 0)
const CachingDms & dec() const
void setDec(dms d)
Sets Dec, the current Declination.
void setRA(dms &r)
Sets RA, the current Right Ascension.
const CachingDms & ra() const
void EquatorialToHorizontal(const CachingDms *LST, const CachingDms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates,...
void setAlt(dms alt)
Sets Alt, the Altitude.
void HorizontalToEquatorial(const dms *LST, const dms *lat)
Determine the (RA, Dec) coordinates of the SkyPoint from its (Altitude, Azimuth) coordinates,...
void setAz(dms az)
Sets Az, the Azimuth.
const double & Degrees() const
QString label(StandardShortcut id)
void set(float x, float y)
void allocate(int vertexCount, int indexCount)
const AttributeSet & defaultAttributes_Point2D()
void setDrawingMode(unsigned int mode)
void removeChildNode(QSGNode *node)