• 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
  • skyobjects
trailobject.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  trailobject.cpp - K Desktop Planetarium
3  -------------------
4  begin : Sat Oct 27 2007
5  copyright : (C) 2007 by Jason Harris
6  email : kstars@30doradus.org
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 <QPainter>
19 
20 #include "Options.h"
21 #include "kstarsdata.h"
22 #include "skymap.h"
23 #include "kspopupmenu.h"
24 #include "trailobject.h"
25 #include "skypainter.h"
26 
27 QSet<TrailObject*> TrailObject::trailObjects;
28 
29 TrailObject::TrailObject( int t, dms r, dms d, float m, const QString &n )
30  : SkyObject( t, r, d, m, n )
31 {}
32 
33 TrailObject::TrailObject( int t, double r, double d, float m, const QString &n )
34  : SkyObject( t, r, d, m, n )
35 {}
36 
37 TrailObject::~TrailObject() {
38  trailObjects.remove(this);
39 }
40 
41 TrailObject* TrailObject::clone() const {
42  return new TrailObject(*this);
43 }
44 
45 void TrailObject::updateTrail( dms *LST, const dms *lat ) {
46  for( int i=0; i < Trail.size(); ++i )
47  Trail[i].EquatorialToHorizontal( LST, lat );
48 }
49 
50 void TrailObject::initPopupMenu( KSPopupMenu *pmenu ) {
51  pmenu->createPlanetMenu( this );
52 }
53 
54 void TrailObject::addToTrail() {
55  Trail.append( SkyPoint( *this ) );
56  trailObjects.insert( this );
57 }
58 
59 void TrailObject::clipTrail() {
60  if( Trail.size() )
61  Trail.removeFirst();
62  if( Trail.size() )
63  trailObjects.remove( this );
64 }
65 
66 void TrailObject::clearTrail() {
67  Trail.clear();
68  trailObjects.remove( this );
69 }
70 
71 void TrailObject::clearTrailsExcept(SkyObject* o) {
72  TrailObject* keep = 0;
73  foreach(TrailObject* tr, trailObjects) {
74  if( tr != o )
75  tr->clearTrail();
76  else
77  keep = tr;
78  }
79 
80  trailObjects = QSet<TrailObject*>();
81  if( keep )
82  trailObjects.insert( keep );
83 }
84 
85 void TrailObject::drawTrail(SkyPainter* skyp) const {
86  if( !Trail.size() )
87  return;
88 
89  KStarsData *data = KStarsData::Instance();
90 
91  QColor tcolor = QColor( data->colorScheme()->colorNamed( "PlanetTrailColor" ) );
92  skyp->setPen( QPen(tcolor, 1) );
93  int n = Trail.size();
94  for(int i = 1; i < n; ++i) {
95  if ( Options::fadePlanetTrails() ) {
96  tcolor.setAlphaF(static_cast<qreal>(i)/static_cast<qreal>(n));
97  skyp->setPen( QPen( tcolor, 1 ) );
98  }
99  SkyPoint a = Trail[i-1];
100  SkyPoint b = Trail[i];
101  skyp->drawSkyLine(&a, &b);
102  }
103 }
SkyPainter::drawSkyLine
virtual void drawSkyLine(SkyPoint *a, SkyPoint *b)=0
Draw a line between points in the sky.
TrailObject::clone
virtual TrailObject * clone() const
Create copy of object.
Definition: trailobject.cpp:41
TrailObject::clearTrailsExcept
static void clearTrailsExcept(SkyObject *o)
Remove trail for all objects but one which is passed as parameter.
Definition: trailobject.cpp:71
KStarsData
KStarsData is the backbone of KStars.
Definition: kstarsdata.h:66
KSPopupMenu
The KStars Popup Menu.
Definition: kspopupmenu.h:43
KSPopupMenu::createPlanetMenu
void createPlanetMenu(SkyObject *p)
Create a popup menu for a solar system body.
Definition: kspopupmenu.cpp:203
TrailObject::clipTrail
void clipTrail()
removes the oldest point from the trail
Definition: trailobject.cpp:59
KStarsData::colorScheme
ColorScheme * colorScheme()
Definition: kstarsdata.h:149
TrailObject::trailObjects
static QSet< TrailObject * > trailObjects
Store list of objects with trails.
Definition: trailobject.h:74
KStarsData::Instance
static KStarsData * Instance()
Definition: kstarsdata.h:92
ColorScheme::colorNamed
QColor colorNamed(const QString &name) const
Retrieve a color by name.
Definition: colorscheme.cpp:97
skypainter.h
TrailObject::updateTrail
void updateTrail(dms *LST, const dms *lat)
update Horizontal coords of the trail
Definition: trailobject.cpp:45
TrailObject::TrailObject
TrailObject(int t=TYPE_UNKNOWN, dms r=dms(0.0), dms d=dms(0.0), float m=0.0, const QString &n=QString())
Constructor.
Definition: trailobject.cpp:29
TrailObject::clearTrail
void clearTrail()
clear the Trail
Definition: trailobject.cpp:66
kspopupmenu.h
SkyPoint
The sky coordinates of a point in the sky.
Definition: skypoint.h:50
TrailObject::Trail
QList< SkyPoint > Trail
Definition: trailobject.h:72
Options::fadePlanetTrails
static bool fadePlanetTrails()
Get Fade planet trails to background color?
Definition: Options.h:999
TrailObject::addToTrail
void addToTrail()
adds a point to the planet's trail
Definition: trailobject.cpp:54
SkyPoint::SkyPoint
SkyPoint()
Default constructor.
Definition: skypoint.cpp:37
skymap.h
trailobject.h
dms
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:42
SkyPoint::EquatorialToHorizontal
void EquatorialToHorizontal(const dms *LST, const dms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates, given the local sidereal time and the observer's latitude.
Definition: skypoint.cpp:55
SkyPainter::setPen
virtual void setPen(const QPen &pen)=0
Set the pen of the painter.
Options.h
NaN::d
const double d
Definition: nan.h:35
TrailObject
provides a SkyObject with an attachable Trail
Definition: trailobject.h:33
TrailObject::drawTrail
void drawTrail(SkyPainter *skyp) const
Definition: trailobject.cpp:85
kstarsdata.h
TrailObject::~TrailObject
virtual ~TrailObject()
Definition: trailobject.cpp:37
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
SkyPainter
Draws things on the sky, without regard to backend.
Definition: skypainter.h:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:21 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