• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
  • skycomponents
skycomposite.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  skycomposite.cpp - K Desktop Planetarium
3  -------------------
4  begin : 2005/07/08
5  copyright : (C) 2005 by Thomas Kabelmann
6  email : thomas.kabelmann@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "skycomposite.h"
19 
20 #include "skyobjects/skyobject.h"
21 
22 SkyComposite::SkyComposite(SkyComposite *parent ) :
23  SkyComponent( parent )
24 { }
25 
26 SkyComposite::~SkyComposite()
27 {
28  qDeleteAll( components() );
29 }
30 
31 void SkyComposite::addComponent(SkyComponent *component)
32 {
33  components().append(component);
34 }
35 
36 void SkyComposite::removeComponent(SkyComponent *component)
37 {
38  int index = components().indexOf(component);
39  if (index != -1)
40  delete components().takeAt(index);
41 }
42 
43 void SkyComposite::draw( SkyPainter *skyp )
44 {
45  if( selected() )
46  foreach ( SkyComponent *component, components() )
47  component->draw( skyp );
48 }
49 
50 void SkyComposite::update( KSNumbers *num )
51 {
52  foreach (SkyComponent *component, components())
53  component->update( num );
54 }
55 
56 SkyObject* SkyComposite::findByName( const QString &name ) {
57  foreach ( SkyComponent *comp, components() ) {
58  SkyObject* o = comp->findByName( name );
59  if ( o ) return o;
60  }
61  return 0;
62 }
63 
64 SkyObject* SkyComposite::objectNearest( SkyPoint *p, double &maxrad ) {
65  if ( !selected() )
66  return 0;
67  SkyObject *oBest = 0;
68  foreach( SkyComponent *comp, components() ) {
69  SkyObject* oTry = comp->objectNearest( p, maxrad );
70  if ( oTry )
71  oBest = oTry; //found a closer object
72  }
73  return oBest; //will be 0 if no object nearer than maxrad was found
74 }
skyobject.h
SkyComponent
SkyComponent represents an object on the sky map.
Definition: skycomponent.h:44
SkyComposite::update
virtual void update(KSNumbers *num=0)
Delegate update-position requests to all sub components.
Definition: skycomposite.cpp:50
SkyComposite::draw
virtual void draw(SkyPainter *skyp)
Delegate draw requests to all sub components psky Reference to the QPainter on which to paint...
Definition: skycomposite.cpp:43
SkyComponent::findByName
virtual SkyObject * findByName(const QString &name)
Search the children of this SkyComponent for a SkyObject whose name matches the argument name the nam...
Definition: skycomponent.cpp:39
SkyComposite::addComponent
void addComponent(SkyComponent *comp)
Add a new sub component to the composite comp Pointer to the SkyComponent to be added.
Definition: skycomposite.cpp:31
SkyComponent::objectNearest
virtual SkyObject * objectNearest(SkyPoint *p, double &maxrad)
Find the SkyObject nearest the given SkyPoint.
Definition: skycomponent.cpp:43
SkyPoint
The sky coordinates of a point in the sky.
Definition: skypoint.h:50
SkyComposite::SkyComposite
SkyComposite(SkyComposite *parent)
Constructor parent pointer to the parent SkyComponent.
Definition: skycomposite.cpp:22
SkyComposite::objectNearest
virtual SkyObject * objectNearest(SkyPoint *p, double &maxrad)
Identify the nearest SkyObject to the given SkyPoint, among the children of this SkyComposite p point...
Definition: skycomposite.cpp:64
SkyComposite::removeComponent
void removeComponent(SkyComponent *comp)
Remove a sub component from the composite comp Pointer to the SkyComponent to be removed.
Definition: skycomposite.cpp:36
skycomposite.h
SkyComposite
SkyComposite is a kind of container class for SkyComponent objects.
Definition: skycomposite.h:43
SkyComposite::components
QList< SkyComponent * > & components()
Definition: skycomposite.h:103
KSNumbers
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition: ksnumbers.h:43
SkyComponent::update
virtual void update(KSNumbers *)
Update the sky position(s) of this component.
Definition: skycomponent.h:74
SkyComposite::~SkyComposite
virtual ~SkyComposite()
Definition: skycomposite.cpp:26
SkyObject
Provides all necessary information about an object in the sky: its coordinates, name(s), type, magnitude, and QStringLists of URLs for images and webpages regarding the object.
Definition: skyobject.h:46
SkyComponent::selected
virtual bool selected()
Definition: skycomponent.h:79
SkyComponent::draw
virtual void draw(SkyPainter *skyp)=0
Draw the object on the SkyMap skyp a pointer to the SkyPainter to use.
SkyPainter
Draws things on the sky, without regard to backend.
Definition: skypainter.h:47
SkyComposite::findByName
virtual SkyObject * findByName(const QString &name)
Search the children of this SkyComposite for a SkyObject whose name matches the argument.
Definition: skycomposite.cpp:56
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

Skip menu "kstars"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal