Kstars

fovitem.cpp
1 /*
2  SPDX-FileCopyrightText: 2016 Artem Fedoskin <[email protected]>
3  SPDX-License-Identifier: GPL-2.0-or-later
4 */
5 
6 #include "fovitem.h"
7 #include "labelsitem.h"
8 #include "skynodes/fovsymbolnode.h"
9 #include "Options.h"
10 
11 FOVItem::FOVItem(RootNode *rootNode) : SkyItem(LabelsItem::label_t::NO_LABEL, rootNode)
12 {
13  addSymbol(i18nc("use field-of-view for binoculars", "7x35 Binoculars"), 558, 558, 0, 0, 0, CIRCLE, "#AAAAAA");
14  addSymbol(i18nc("use a Telrad field-of-view indicator", "Telrad"), 30, 30, 0, 0, 0, BULLSEYE, "#AA0000");
15  addSymbol(i18nc("use 1-degree field-of-view indicator", "One Degree"), 60, 60, 0, 0, 0, CIRCLE, "#AAAAAA");
16  addSymbol(i18nc("use HST field-of-view indicator", "HST WFPC2"), 2.4, 2.4, 0, 0, 0, SQUARE, "#AAAAAA");
17  addSymbol(i18nc("use Radiotelescope HPBW", "30m at 1.3cm"), 1.79, 1.79, 0, 0, 0, SQUARE, "#AAAAAA");
18 }
19 
20 void FOVItem::addSymbol(const QString &name, float a, float b, float xoffset, float yoffset, float rot,
21  FOVItem::Shape shape, const QString &color)
22 {
23  SkyMapLite::Instance()->addFOVSymbol(name, false);
24  appendChildNode(new FOVSymbolNode(name, a, b, xoffset, yoffset, rot, shape, color));
25 }
26 
28 {
29  float zoomFactor = Options::zoomFactor();
30  SkyMapLite *map = SkyMapLite::Instance();
31 
32  QSGNode *n = firstChild();
33  int index = 0;
34  while (n != 0)
35  {
36  FOVSymbolNode *fov = static_cast<FOVSymbolNode *>(n);
37  if (map->isFOVVisible(index))
38  {
39  fov->update(zoomFactor);
40  }
41  else
42  {
43  fov->hide();
44  }
45  n = n->nextSibling();
46  index++;
47  }
48 }
A base class that is used for displaying SkyComponents on SkyMapLite.
Definition: skyitem.h:29
A container for nodes that holds collection of textures for stars and provides clipping.
Definition: rootnode.h:59
void addSymbol(const QString &name, float a, float b, float xoffset, float yoffset, float rot, FOVItem::Shape shape, const QString &color)
Add information about new symbol to SkyMapLite and create FOVSymbolNode SkyMapLite acts here as a bri...
Definition: fovitem.cpp:20
void appendChildNode(QSGNode *node)
QSGNode * firstChild() const const
Handles labels in SkyMapLite.
Definition: labelsitem.h:52
Q_INVOKABLE void addFOVSymbol(const QString &FOVName, bool initialState=false)
adds FOV symbol to m_FOVSymbols
Definition: skymaplite.cpp:918
FOVItem(RootNode *rootNode)
Constructor.
Definition: fovitem.cpp:11
Item for displaying sky objects; also handles user interaction events.
Definition: skymaplite.h:58
A SkyNode derived class that is used for displaying FOV symbol.
virtual void update() override
Update FOVSymbol if user switched it on.
Definition: fovitem.cpp:27
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void update(float zoomFactor)
Update this FOV symbol according to the zoomFactor.
QSGNode * nextSibling() const const
Shape
FOV symbol types.
Definition: fovitem.h:21
virtual void hide()
hides all child nodes (sets opacity of m_opacity to 0)
Definition: skynode.cpp:21
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 19 2022 03:57:51 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.