Kstars

flagcomponent.h
1/*
2 SPDX-FileCopyrightText: 2009 Jerome SONRIER <jsid@emor3j.fr.eu.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "pointlistcomponent.h"
10
11#include <QColor>
12#include <QImage>
13#include <QObject>
14#include <QStringList>
15
16class SkyPainter;
17
18/**
19 * @class FlagComponent
20 * @short Represents a flag on the sky map.
21 * Each flag is composed by a SkyPoint where coordinates are stored, an
22 * epoch and a label. This class also stores flag images and associates
23 * each flag with an image.
24 * When FlagComponent is created, it seeks all file names beginning with
25 * "_flag" in the user directory and *consider* them as flag images.
26 *
27 * The file flags.dat stores coordinates, epoch, image name and label of each
28 * flags and is read to init FlagComponent
29 *
30 * @author Jerome SONRIER
31 * @version 1.1
32 */
34{
36
37 public:
38 /** @short Constructor. */
39 explicit FlagComponent(SkyComposite *);
40
41 virtual ~FlagComponent() override = default;
42
43 void draw(SkyPainter *skyp) override;
44
45 bool selected() override;
46
47 void update(KSNumbers *num = nullptr) override;
48
49 /**
50 * @short Add a flag.
51 * @param flagPoint Sky point in epoch coordinates
52 * @param epoch Moment for which celestial coordinates are specified
53 * @param image Image name
54 * @param label Label of the flag
55 * @param labelColor Color of the label
56 */
58
59 /**
60 * @short Remove a flag.
61 * @param index Index of the flag to be remove.
62 */
63 void remove(int index);
64
65 /**
66 * @short Update a flag.
67 * @param index index of the flag to be updated.
68 * @param flagPoint point of the flag.
69 * @param epoch new flag epoch.
70 * @param image new flag image.
71 * @param label new flag label.
72 * @param labelColor new flag label color.
73 */
74 void updateFlag(int index, const SkyPoint &flagPoint, QString epoch, QString image, QString label,
76
77 /**
78 * @short Return image names.
79 * @return the list of all image names
80 */
82
83 /**
84 * @short Return the numbers of flags.
85 * @return the size of m_PointList
86 */
87 int size();
88
89 /**
90 * @short Get epoch.
91 * @return the epoch as a string
92 * @param index Index of the flag
93 */
94 QString epoch(int index);
95
96 /**
97 * @short Get label.
98 * @return the label as a string
99 * @param index Index of the flag
100 */
101 QString label(int index);
102
103 /**
104 * @short Get label color.
105 * @return the label color
106 * @param index Index of the flag
107 */
108 QColor labelColor(int index);
109
110 /**
111 * @short Get image.
112 * @return the image associated with the flag
113 * @param index Index of the flag
114 */
115 QImage image(int index);
116
117 /**
118 * @short Get image name.
119 * @return the name of the image associated with the flag
120 * @param index Index of the flag
121 */
122 QString imageName(int index);
123
124 /**
125 * @short Get images.
126 * @return all images that can be use
127 */
129
130 /**
131 * @short Get image.
132 * @param index Index of the image in m_Images
133 * @return an image from m_Images
134 */
135 QImage imageList(int index);
136
137 /**
138 * @brief epochCoords return coordinates recorded in original epoch
139 * @param index index of the flag
140 * @return pair of RA/DEC in original epoch
141 */
142 QPair<double, double> epochCoords(int index);
143
144 /**
145 * @short Get list of flag indexes near specified SkyPoint with radius specified in pixels.
146 * @param point central SkyPoint.
147 * @param pixelRadius radius in pixels.
148 */
149 QList<int> getFlagsNearPix(SkyPoint *point, int pixelRadius);
150
151 /** @short Load flags from flags.dat file. */
152 void loadFromFile();
153
154 /** @short Save flags to flags.dat file. */
155 void saveToFile();
156
157 private:
158 // Convert from given epoch to J2000. If epoch is already J2000, do nothing
159 void toJ2000(SkyPoint *p, QString epoch);
160
161 /// List of epochs
162 QStringList m_Epoch;
163 /// RA/DEC stored in original epoch
164 QList<QPair<double, double>> m_EpochCoords;
165 /// List of image index
166 QList<int> m_FlagImages;
167 /// List of label
168 QStringList m_Labels;
169 /// List of label colors
170 QList<QColor> m_LabelColors;
171 /// List of image names
172 QStringList m_Names;
173 /// List of flag images
174 QList<QImage> m_Images;
175};
Represents a flag on the sky map.
void saveToFile()
Save flags to flags.dat file.
FlagComponent(SkyComposite *)
Constructor.
QColor labelColor(int index)
Get label color.
int size()
Return the numbers of flags.
void remove(int index)
Remove a flag.
QList< QImage > imageList()
Get images.
QString label(int index)
Get label.
void add(const SkyPoint &flagPoint, QString epoch, QString image, QString label, QColor labelColor)
Add a flag.
QString epoch(int index)
Get epoch.
void update(KSNumbers *num=nullptr) override
Update the sky position(s) of this component.
QString imageName(int index)
Get image name.
QStringList getNames()
Return image names.
void loadFromFile()
Load flags from flags.dat file.
bool selected() override
QPair< double, double > epochCoords(int index)
epochCoords return coordinates recorded in original epoch
void updateFlag(int index, const SkyPoint &flagPoint, QString epoch, QString image, QString label, QColor labelColor)
Update a flag.
QList< int > getFlagsNearPix(SkyPoint *point, int pixelRadius)
Get list of flag indexes near specified SkyPoint with radius specified in pixels.
void draw(SkyPainter *skyp) override
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
QImage image(int index)
Get image.
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition ksnumbers.h:43
An abstract parent class, to be inherited by SkyComponents that store a QList of SkyPoints.
SkyComposite is a kind of container class for SkyComponent objects.
Draws things on the sky, without regard to backend.
Definition skypainter.h:40
The sky coordinates of a point in the sky.
Definition skypoint.h:45
Q_OBJECTQ_OBJECT
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:41 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.