SkyComposite

Search for usage in LXR

SkyComposite Class Reference

#include <skycomposite.h>

Inheritance diagram for SkyComposite:

Public Member Functions

 SkyComposite (SkyComposite *parent=nullptr)
 
 ~SkyComposite () override
 
void addComponent (SkyComponent *comp, int priority=1024)
 
QList< SkyComponent * > components ()
 
QMap< int, SkyComponent * > & componentsWithPriorities ()
 
void draw (SkyPainter *skyp) override
 
SkyObjectfindByName (const QString &name, bool exact=true) override
 
SkyObjectobjectNearest (SkyPoint *p, double &maxrad) override
 
void removeComponent (SkyComponent *const comp)
 
void update (KSNumbers *num=nullptr) override
 
- Public Member Functions inherited from SkyComponent
 SkyComponent (SkyComposite *parent=nullptr)
 
virtual void drawTrails (SkyPainter *skyp)
 
virtual void emitProgressText (const QString &message)
 
QHash< int, QVector< QPair< QString, const SkyObject * > > > & objectLists ()
 
QVector< QPair< QString, const SkyObject * > > & objectLists (int type)
 
QHash< int, QStringList > & objectNames ()
 
QStringListobjectNames (int type)
 
virtual void objectsInArea (QList< SkyObject * > &list, const SkyRegion &region)
 
SkyCompositeparent ()
 
void removeFromLists (const SkyObject *obj)
 
void removeFromNames (const SkyObject *obj)
 
virtual bool selected ()
 
virtual void updateMoons (KSNumbers *)
 
virtual void updateSolarSystemBodies (KSNumbers *)
 

Detailed Description

SkyComposite is a kind of container class for SkyComponent objects.

The SkyComposite is responsible for distributing calls to functions like draw() and update() to its children, which can be SkyComponents or other SkyComposites with their own children. This is based on the "composite/component" design pattern.

Performance tuning: Sometimes it will be better to override a virtual function and do the work in the composite instead of delegating the request to all sub components.

Author
Thomas Kabelmann
Version
0.1

Definition at line 29 of file skycomposite.h.

Constructor & Destructor Documentation

◆ SkyComposite()

SkyComposite::SkyComposite ( SkyComposite * parent = nullptr)
explicit

Constructor parent pointer to the parent SkyComponent.

Definition at line 12 of file skycomposite.cpp.

◆ ~SkyComposite()

SkyComposite::~SkyComposite ( )
override

Destructor

Definition at line 16 of file skycomposite.cpp.

Member Function Documentation

◆ addComponent()

void SkyComposite::addComponent ( SkyComponent * comp,
int priority = 1024 )

Add a new sub component to the composite comp Pointer to the SkyComponent to be added priority A priority ordering for various operations on the list of all sky components (notably objectNearest())

Definition at line 22 of file skycomposite.cpp.

◆ components()

QList< SkyComponent * > SkyComposite::components ( )
inline

Definition at line 97 of file skycomposite.h.

◆ componentsWithPriorities()

QMap< int, SkyComponent * > & SkyComposite::componentsWithPriorities ( )
inline

Definition at line 102 of file skycomposite.h.

◆ draw()

void SkyComposite::draw ( SkyPainter * skyp)
overridevirtual

Delegate draw requests to all sub components psky Reference to the QPainter on which to paint.

Implements SkyComponent.

Reimplemented in SkyMapComposite.

Definition at line 51 of file skycomposite.cpp.

◆ findByName()

SkyObject * SkyComposite::findByName ( const QString & name,
bool exact = true )
overridevirtual

Search the children of this SkyComposite for a SkyObject whose name matches the argument.

The objects' primary, secondary and long-form names will all be checked for a match. name the name to be matched exact If true, it will return an exact match, otherwise it can return a partial match.

Returns
a pointer to the SkyObject whose name matches the argument, or a nullptr pointer if no match was found.

Reimplemented from SkyComponent.

Reimplemented in SkyMapComposite.

Definition at line 64 of file skycomposite.cpp.

◆ objectNearest()

SkyObject * SkyComposite::objectNearest ( SkyPoint * p,
double & maxrad )
overridevirtual

Identify the nearest SkyObject to the given SkyPoint, among the children of this SkyComposite p pointer to the SkyPoint around which to search.

maxrad reference to current search radius

Returns
a pointer to the nearest SkyObject

Reimplemented from SkyComponent.

Reimplemented in SkyMapComposite.

Definition at line 75 of file skycomposite.cpp.

◆ removeComponent()

void SkyComposite::removeComponent ( SkyComponent *const comp)

Remove a sub component from the composite comp Pointer to the SkyComponent to be removed.

Definition at line 33 of file skycomposite.cpp.

◆ update()

void SkyComposite::update ( KSNumbers * num = nullptr)
overridevirtual

Delegate update-position requests to all sub components.

This function usually just updates the Horizontal (Azimuth/Altitude) coordinates. However, the precession and nutation must also be recomputed periodically. Requests to do so are sent through the doPrecess parameter. num Pointer to the KSNumbers object

See also
updatePlanets()
updateMoons()
Note
By default, the num parameter is nullptr, indicating that Precession/Nutation computation should be skipped; this computation is only occasionally required.

Reimplemented from SkyComponent.

Reimplemented in SolarSystemComposite, and SkyMapComposite.

Definition at line 58 of file skycomposite.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:05 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.