• 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
  • tools
  • whatsinteresting
skyobjitem.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  skyobjitem.cpp - K Desktop Planetarium
3  -------------------
4  begin : 2012/21/06
5  copyright : (C) 2012 by Samikshan Bairagya
6  email : samikshan@gmail.com
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 "ksfilereader.h"
19 #include "kstarsdata.h"
20 #include "deepskyobject.h"
21 #include "ksplanetbase.h"
22 #include "skyobjitem.h"
23 #include "ksutils.h"
24 
25 SkyObjItem::SkyObjItem(SkyObject *so) : m_Name(so->name()), m_LongName(so->longname()),m_TypeName(so->typeName()), m_So(so)
26 {
27  switch (so->type())
28  {
29  case SkyObject::PLANET:
30  m_Type = Planet;
31  break;
32  case SkyObject::STAR:
33  m_Type = Star;
34  break;
35  case SkyObject::CONSTELLATION:
36  m_Type = Constellation;
37  break;
38  case SkyObject::GALAXY:
39  m_Type = Galaxy;
40  break;
41  case SkyObject::OPEN_CLUSTER:
42  case SkyObject::GLOBULAR_CLUSTER:
43  case SkyObject::GALAXY_CLUSTER:
44  m_Type = Cluster;
45  break;
46  case SkyObject::PLANETARY_NEBULA:
47  case SkyObject::GASEOUS_NEBULA:
48  case SkyObject::DARK_NEBULA:
49  m_Type = Nebula;
50  break;
51  }
52 
53  setPosition(m_So);
54 }
55 
56 QVariant SkyObjItem::data(int role)
57 {
58  switch(role)
59  {
60  case DispNameRole:
61  return getLongName();
62  case CategoryRole:
63  return getType();
64  case CategoryNameRole:
65  return getTypeName();
66  default:
67  return QVariant();
68  }
69 }
70 
71 QHash<int, QByteArray> SkyObjItem::roleNames() const
72 {
73  QHash<int, QByteArray> roles;
74  roles[DispNameRole] = "dispName";
75  roles[CategoryRole] = "type";
76  roles[CategoryNameRole] = "typeName";
77  return roles;
78 }
79 
80 void SkyObjItem::setPosition(SkyObject* so)
81 {
82  KStarsData *data = KStarsData::Instance();
83  KStarsDateTime ut = data->geo()->LTtoUT(KStarsDateTime(KDateTime::currentLocalDateTime()));
84  SkyPoint sp = so->recomputeCoords(ut, data->geo());
85 
86  //check altitude of object at this time.
87  sp.EquatorialToHorizontal(data->lst(), data->geo()->lat());
88  double rounded_altitude = (int)(sp.alt().Degrees()/5.0)*5.0;
89 
90  m_Position = i18n("Now visible: About %1 degrees above the %2 horizon", rounded_altitude, KSUtils::toDirectionString( sp.az() ) );
91 }
92 
93 QString SkyObjItem::getDesc() const
94 {
95  if (m_Type == Planet)
96  {
97  KSFileReader fileReader;
98  if (!fileReader.open("PlanetFacts.dat"))
99  return i18n("No Description found for selected sky-object");
100 
101  while (fileReader.hasMoreLines())
102  {
103  QString line = fileReader.readLine();
104  if(line.length() != 0 && line[0] != '#')
105  {
106  QString soname = line.split("::")[0];
107  QString desc = line.split("::")[1];
108  if (soname == m_Name)
109  {
110  return desc;
111  }
112  }
113  }
114  }
115  else if (m_Type == Star)
116  {
117  return i18n("Bright Star");
118  }
119  else if (m_Type == Constellation)
120  {
121  return i18n("Constellation");
122  }
123 
124  return getTypeName();
125 }
126 
127 QString SkyObjItem::getDescSource()
128 {
129  if (m_Type == Planet)
130  {
131  return i18n("(Source: Wikipedia)");
132  }
133  return i18n("(Source: N/A)");
134 }
135 
136 
137 QString SkyObjItem::getSurfaceBrightness() const
138 {
146  DeepSkyObject *dso = (DeepSkyObject *)m_So;
147  float SB = m_So->mag() + 2.5 * log10(dso->a() * dso->b() / 4);
148 
149  switch(getType())
150  {
151  case Galaxy:
152  case Nebula:
153  return KGlobal::locale()->formatNumber(SB, 2) + " mag/arcmin^2";
154  default:
155  return QString(" --"); // Not applicable for other sky-objects
156  }
157 }
158 
159 QString SkyObjItem::getSize() const
160 {
161  switch (getType())
162  {
163  case Galaxy:
164  case Cluster:
165  case Nebula:
166  return KGlobal::locale()->formatNumber(((DeepSkyObject *)m_So)->a(), 2) + " arcminutes";
167  case Planet:
168  return KGlobal::locale()->formatNumber(((KSPlanetBase *)m_So)->angSize(), 2) + " arcseconds";
169  default:
170  return QString(" --");
171  }
172 }
DeepSkyObject::b
float b() const
Definition: deepskyobject.h:137
SkyObjItem::Star
Definition: skyobjitem.h:42
KSFileReader::hasMoreLines
bool hasMoreLines()
Definition: ksfilereader.h:108
SkyObjItem::CategoryNameRole
Definition: skyobjitem.h:36
ksplanetbase.h
SkyObjItem::SkyObjItem
SkyObjItem(SkyObject *so=0)
Constructor.
Definition: skyobjitem.cpp:25
SkyObjItem::getTypeName
QString getTypeName() const
Get category of sky-object associated with the SkyObjItem as a QString.
Definition: skyobjitem.h:79
KStarsData
KStarsData is the backbone of KStars.
Definition: kstarsdata.h:66
SkyPoint::az
const dms & az() const
Definition: skypoint.h:177
SkyObject::DARK_NEBULA
Definition: skyobject.h:111
deepskyobject.h
SkyObject::PLANET
Definition: skyobject.h:108
KStarsData::lst
dms * lst()
Definition: kstarsdata.h:161
KStarsData::Instance
static KStarsData * Instance()
Definition: kstarsdata.h:92
dms::Degrees
const double & Degrees() const
Definition: dms.h:98
SkyObjItem::getDescSource
QString getDescSource()
Get source of description for the SkyObjItem.
Definition: skyobjitem.cpp:127
GeoLocation::LTtoUT
KStarsDateTime LTtoUT(const KStarsDateTime &lt) const
Definition: geolocation.h:234
SkyObjItem::getDesc
QString getDesc() const
Get description for the SkyObjItem.
Definition: skyobjitem.cpp:93
SkyObject::GALAXY
Definition: skyobject.h:109
SkyObjItem::Constellation
Definition: skyobjitem.h:42
KStarsData::geo
GeoLocation * geo()
Definition: kstarsdata.h:164
SkyObjItem::getType
int getType() const
Get category of sky-object associated with the SkyObjItem as an integer.
Definition: skyobjitem.h:85
KSFileReader::open
bool open(const QString &fname)
Definition: ksfilereader.cpp:46
SkyPoint
The sky coordinates of a point in the sky.
Definition: skypoint.h:50
SkyObject::GALAXY_CLUSTER
Definition: skyobject.h:111
DeepSkyObject::a
float a() const
Definition: deepskyobject.h:132
skyobjitem.h
SkyObjItem::Galaxy
Definition: skyobjitem.h:42
SkyObjItem::Cluster
Definition: skyobjitem.h:42
SkyObjItem::Nebula
Definition: skyobjitem.h:42
KStarsDateTime
Extension of KDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day...
Definition: kstarsdatetime.h:45
SkyObjItem::setPosition
void setPosition(SkyObject *so)
Set current position of the sky-object in the sky.
Definition: skyobjitem.cpp:80
SkyObjItem::DispNameRole
Definition: skyobjitem.h:36
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
SkyObjItem::getLongName
QString getLongName() const
Get longname of sky-object associated with the SkyObjItem.
Definition: skyobjitem.h:73
SkyObject::mag
float mag(void) const
Definition: skyobject.h:182
DeepSkyObject
Provides all necessary information about a deep-sky object: data inherited from SkyObject (coordinate...
Definition: deepskyobject.h:43
SkyObjItem::data
QVariant data(int role)
Get data associated with a particular role for the SkyObjItem.
Definition: skyobjitem.cpp:56
SkyObjItem::getSurfaceBrightness
QString getSurfaceBrightness() const
Get surface-brightness of sky-object associated with the SkyObjItem as a QString to be displayed on t...
Definition: skyobjitem.cpp:137
GeoLocation::lat
const dms * lat() const
Definition: geolocation.h:79
ksfilereader.h
SkyObject::recomputeCoords
SkyPoint recomputeCoords(const KStarsDateTime &dt, const GeoLocation *geo=0)
The coordinates for the object on date dt are computed and returned, but the object's internal coordi...
Definition: skyobject.cpp:296
KSFileReader::readLine
QString readLine()
Definition: ksfilereader.h:113
KSFileReader
Definition: ksfilereader.h:65
SkyObject::type
int type(void) const
Definition: skyobject.h:164
SkyObject::CONSTELLATION
Definition: skyobject.h:110
SkyObjItem::getSize
QString getSize() const
Get size of sky-object associated with the SkyObjItem as a QString to be displayed on the details-vie...
Definition: skyobjitem.cpp:159
SkyObject::PLANETARY_NEBULA
Definition: skyobject.h:109
KSPlanetBase
A subclass of TrailObject that provides additional information needed for most solar system objects...
Definition: ksplanetbase.h:63
KSUtils::toDirectionString
QString toDirectionString(dms angle)
Return a string corresponding to an angle specifying direction.
SkyObjItem::roleNames
QHash< int, QByteArray > roleNames() const
Create and return a QHash of rolenames for the SkyObjItem.
Definition: skyobjitem.cpp:71
kstarsdata.h
SkyObject::GASEOUS_NEBULA
Definition: skyobject.h:109
SkyPoint::alt
const dms & alt() const
Definition: skypoint.h:180
SkyObject::GLOBULAR_CLUSTER
Definition: skyobject.h:108
SkyObjItem::Planet
Definition: skyobjitem.h:42
ksutils.h
SkyObject::STAR
Definition: skyobject.h:108
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
SkyObject::OPEN_CLUSTER
Definition: skyobject.h:108
SkyObjItem::CategoryRole
Definition: skyobjitem.h:36
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