Kstars

targetlistcomponent.h
1 /*
2  SPDX-FileCopyrightText: 2010 Akarsh Simha <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "skycomponent.h"
10 
11 #include <QPen>
12 
13 /**
14  * @class TargetListComponent
15  * @short Highlights objects present in certain lists by drawing "target" symbols around them.
16  *
17  * To represent lists of specific objects on the skymap (eg: A star
18  * hopping route, or a list of planned observation targets), one would
19  * typically like to draw over the skymap, a bunch of symbols
20  * highlighting the locations of these objects. This class manages
21  * drawing of such lists. Along with the list, we also associate a pen
22  * to use to represent objects from that list. Once this class is made
23  * aware of a list to plot (which is stored somewhere else), it does
24  * so when called from the SkyMapComposite. The class may be supplied
25  * with pointers to two methods that tell it whether to draw symbols /
26  * labels or not. Disabling symbol drawing is equivalent to disabling
27  * the list. If the pointers are nullptr, the symbols are always drawn,
28  * but the labels are not drawn.
29  *
30  * @note This does not inherit from ListComponent because it is not
31  * necessary. ListComponent has extra methods like objectNearest(),
32  * which we don't want. Also, ListComponent maintains its own list,
33  * whereas this class merely holds a pointer to a list that's
34  * manipulated from elsewhere.
35  */
36 
38 {
39  public:
40  /**
41  * @short Default constructor.
42  */
44 
45  /**
46  * @short Constructor that sets up this target list
47  */
49  bool (*optionDrawSymbols)(void) = nullptr, bool (*optionDrawLabels)(void) = nullptr);
50 
51  ~TargetListComponent() override;
52 
53  /**
54  * @short Draw this component by iterating over the list.
55  *
56  * @note This method does not bother refreshing the coordinates of
57  * the objects on the list. So this must be called only after the
58  * objects are drawn in a given draw cycle.
59  */
60  void draw(SkyPainter *skyp) override;
61 
62  // FIXME: Maybe we should make these member objects private / protected?
63  /// Pointer to list of objects to draw
64  std::unique_ptr<SkyObjectList> list;
65  /// Pointer to list of objects to draw
67  /// Pen to use to draw
69 
70  /**
71  * @short Pointer to static method that tells us whether to draw this list or not
72  * @note If the pointer is nullptr, the list is drawn nevertheless
73  */
74  bool (*drawSymbols)(void);
75 
76  /**
77  * @short Pointer to static method that tells us whether to draw labels for this list or not
78  * @note If the pointer is nullptr, labels are not drawn
79  */
80  bool (*drawLabels)(void);
81 };
void draw(SkyPainter *skyp) override
Draw this component by iterating over the list.
bool(* drawSymbols)(void)
Pointer to static method that tells us whether to draw this list or not.
SkyComposite * parent()
Definition: skycomponent.h:137
bool(* drawLabels)(void)
Pointer to static method that tells us whether to draw labels for this list or not.
Draws things on the sky, without regard to backend.
Definition: skypainter.h:37
TargetListComponent(SkyComposite *parent)
Default constructor.
Highlights objects present in certain lists by drawing "target" symbols around them.
QPen pen
Pen to use to draw.
std::unique_ptr< SkyObjectList > list
Pointer to list of objects to draw.
QList< QSharedPointer< SkyObject > > list2
Pointer to list of objects to draw.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Tue Aug 9 2022 04:06:07 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.