Kstars

skycomposite.h
1/*
2 SPDX-FileCopyrightText: 2005 Thomas Kabelmann <thomas.kabelmann@gmx.de>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "skycomponent.h"
10
11#include <QList>
12#include <QMap>
13
14class KSNumbers;
15
16/**
17 * @class SkyComposite
18 * SkyComposite is a kind of container class for SkyComponent objects. The SkyComposite is
19 * responsible for distributing calls to functions like draw() and update() to its children,
20 * which can be SkyComponents or other SkyComposites with their own children. This is based
21 * on the "composite/component" design pattern.
22 *
23 * Performance tuning: Sometimes it will be better to override a virtual function and do
24 * the work in the composite instead of delegating the request to all sub components.
25 *
26 * @author Thomas Kabelmann
27 * @version 0.1
28 */
30{
31 public:
32 /**
33 * @short Constructor
34 * @p parent pointer to the parent SkyComponent
35 */
36 explicit SkyComposite(SkyComposite *parent = nullptr);
37
38 /** *@short Destructor */
39 ~SkyComposite() override;
40
41 /**
42 * @short Delegate draw requests to all sub components
43 * @p psky Reference to the QPainter on which to paint
44 */
45 void draw(SkyPainter *skyp) override;
46
47 /**
48 * @short Delegate update-position requests to all sub components
49 *
50 * This function usually just updates the Horizontal (Azimuth/Altitude) coordinates.
51 * However, the precession and nutation must also be recomputed periodically. Requests to
52 * do so are sent through the doPrecess parameter.
53 * @p num Pointer to the KSNumbers object
54 * @sa updatePlanets()
55 * @sa updateMoons()
56 * @note By default, the num parameter is nullptr, indicating that Precession/Nutation
57 * computation should be skipped; this computation is only occasionally required.
58 */
59 void update(KSNumbers *num = nullptr) override;
60
61 /**
62 * @short Add a new sub component to the composite
63 * @p comp Pointer to the SkyComponent to be added
64 * @p priority A priority ordering for various operations on the list of all sky components
65 * (notably objectNearest())
66 */
67 void addComponent(SkyComponent *comp, int priority = 1024);
68
69 /**
70 * @short Remove a sub component from the composite
71 * @p comp Pointer to the SkyComponent to be removed.
72 */
74
75 /**
76 * @short Search the children of this SkyComposite for a SkyObject whose name matches
77 * the argument.
78 *
79 * The objects' primary, secondary and long-form names will all be checked for a match.
80 * @p name the name to be matched
81 * @p exact If true, it will return an exact match, otherwise it can return
82 * a partial match.
83 * @return a pointer to the SkyObject whose name matches
84 * the argument, or a nullptr pointer if no match was found.
85 */
86 SkyObject *findByName(const QString &name, bool exact = true) override;
87
88 /**
89 * @short Identify the nearest SkyObject to the given SkyPoint, among the children of
90 * this SkyComposite
91 * @p p pointer to the SkyPoint around which to search.
92 * @p maxrad reference to current search radius
93 * @return a pointer to the nearest SkyObject
94 */
95 SkyObject *objectNearest(SkyPoint *p, double &maxrad) override;
96
97 QList<SkyComponent *> components()
98 {
99 return m_Components.values();
100 }
101
102 QMap<int, SkyComponent *> &componentsWithPriorities()
103 {
104 return m_Components;
105 }
106
107 private:
109};
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition ksnumbers.h:43
SkyComponent represents an object on the sky map.
SkyComposite * parent()
SkyComposite is a kind of container class for SkyComponent objects.
void addComponent(SkyComponent *comp, int priority=1024)
Add a new sub component to the composite comp Pointer to the SkyComponent to be added priority A prio...
void removeComponent(SkyComponent *const comp)
Remove a sub component from the composite comp Pointer to the SkyComponent to be removed.
SkyObject * objectNearest(SkyPoint *p, double &maxrad) override
Identify the nearest SkyObject to the given SkyPoint, among the children of this SkyComposite p point...
~SkyComposite() override
SkyObject * findByName(const QString &name, bool exact=true) override
Search the children of this SkyComposite for a SkyObject whose name matches the argument.
void draw(SkyPainter *skyp) override
Delegate draw requests to all sub components psky Reference to the QPainter on which to paint.
void update(KSNumbers *num=nullptr) override
Delegate update-position requests to all sub components.
SkyComposite(SkyComposite *parent=nullptr)
Constructor parent pointer to the parent SkyComponent.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
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
QList< T > values() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:55:03 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.