• 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
catalogcomponent.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  catalogcomponent.cpp - K Desktop Planetarium
3  -------------------
4  begin : 2005/17/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 "catalogcomponent.h"
19 
20 #include <kdebug.h>
21 #include <klocale.h>
22 #include <kmessagebox.h>
23 #include <QDir>
24 #include <QFile>
25 #include <QPixmap>
26 #include <QTextStream>
27 #include "kstars/Options.h"
28 #include "kstars/kstarsdata.h"
29 #include "kstars/skymap.h"
30 #include "skyobjects/starobject.h"
31 #include "skyobjects/deepskyobject.h"
32 #include "kstars/skypainter.h"
33 
34 QStringList CatalogComponent::m_Columns
35  = QString( "ID RA Dc Tp Nm Mg Flux Mj Mn PA Ig" )
36  .split( ' ',QString::SkipEmptyParts );
37 
38 CatalogComponent::CatalogComponent(SkyComposite *parent,
39  const QString &catname,
40  bool showerrs, int index)
41  : ListComponent(parent), m_catName(catname),
42  m_Showerrs(showerrs), m_ccIndex(index) {
43  loadData();
44 }
45 
46 CatalogComponent::~CatalogComponent() {
47 }
48 
49 void CatalogComponent::loadData() {
50  emitProgressText( i18n("Loading custom catalog: %1", m_catName ) );
51 
52  QList < QPair <int, QString> > names;
53 
54  KStarsData::Instance()->catalogdb()->GetAllObjects(m_catName,
55  m_ObjectList,
56  names,
57  this);
58  for (int iter = 0; iter < names.size(); iter++) {
59  if (names.at(iter).first <= SkyObject::TYPE_UNKNOWN) {
60  if (!objectNames(names.at(iter).first).contains(names.at(iter).second))
61  objectNames(names.at(iter).first).append(names.at(iter).second);
62  }
63  }
64 
65  CatalogData loaded_catalog_data;
66  KStarsData::Instance()->catalogdb()->GetCatalogData(m_catName, loaded_catalog_data);
67  m_catPrefix = loaded_catalog_data.prefix;
68  m_catColor = loaded_catalog_data.color;
69  m_catFluxFreq = loaded_catalog_data.fluxfreq;
70  m_catFluxUnit = loaded_catalog_data.fluxunit;
71  m_catEpoch = loaded_catalog_data.epoch;
72 }
73 
74 void CatalogComponent::update( KSNumbers * ) {
75  if ( selected() ) {
76  KStarsData *data = KStarsData::Instance();
77  foreach ( SkyObject *obj, m_ObjectList ) {
78  DeepSkyObject *dso = dynamic_cast< DeepSkyObject * >( obj );
79  StarObject *so = dynamic_cast< StarObject *>( obj );
80  Q_ASSERT( dso || so ); // We either have stars, or deep sky objects
81  if( dso ) {
82  // Update the deep sky object if need be
83  if ( dso->updateID != data->updateID() ) {
84  dso->updateID = data->updateID();
85  if ( dso->updateNumID != data->updateNumID() ) {
86  dso->updateCoords( data->updateNum() );
87 
88  }
89  dso->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
90  }
91  }
92  else {
93  // Do exactly the same thing for stars
94  if ( so->updateID != data->updateID() ) {
95  so->updateID = data->updateID();
96  if ( so->updateNumID != data->updateNumID() ) {
97  so->updateCoords( data->updateNum() );
98  }
99  so->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
100  }
101  }
102  }
103  this->updateID = data->updateID();
104  }
105 }
106 
107 void CatalogComponent::draw( SkyPainter *skyp ) {
108  if ( ! selected() ) return;
109 
110  skyp->setBrush( Qt::NoBrush );
111  skyp->setPen( QColor( m_catColor ) );
112 
113  // Check if the coordinates have been updated
114  if( updateID != KStarsData::Instance()->updateID() )
115  update( 0 );
116 
117  //Draw Custom Catalog objects
118  foreach ( SkyObject *obj, m_ObjectList ) {
119  if ( obj->type()==0 ) {
120  StarObject *starobj = static_cast<StarObject*>(obj);
121  // FIXME SKYPAINTER
122  skyp->drawPointSource(starobj, starobj->mag(), starobj->spchar() );
123  } else {
124  // FIXME: this PA calc is totally different from the one that was
125  // in DeepSkyComponent which is now in SkyPainter .... O_o
126  // --hdevalence
127  // PA for Deep-Sky objects is 90 + PA because major axis is
128  // horizontal at PA=0
129  // double pa = 90. + map->findPA( dso, o.x(), o.y() );
130  DeepSkyObject *dso = static_cast<DeepSkyObject*>(obj);
131  skyp->drawDeepSkyObject(dso, true);
132  }
133  }
134 }
135 
136 bool CatalogComponent::selected() {
137  if (Options::showCatalogNames().contains(m_catName))
138  return true;
139  return false;
140 }
SkyPainter::drawPointSource
virtual bool drawPointSource(SkyPoint *loc, float mag, char sp= 'A')=0
Draw a point source (e.g., a star).
SkyPainter::setBrush
virtual void setBrush(const QBrush &brush)=0
Set the brush of the painter.
KStarsData
KStarsData is the backbone of KStars.
Definition: kstarsdata.h:66
KStarsData::updateID
unsigned int updateID()
Definition: kstarsdata.h:224
SkyObject::TYPE_UNKNOWN
Definition: skyobject.h:112
CatalogComponent::draw
virtual void draw(SkyPainter *skyp)
Draw custom catalog objects on the sky map.
Definition: catalogcomponent.cpp:107
deepskyobject.h
ListComponent::m_ObjectList
QList< SkyObject * > m_ObjectList
Definition: listcomponent.h:64
KStarsData::lst
dms * lst()
Definition: kstarsdata.h:161
KStarsData::Instance
static KStarsData * Instance()
Definition: kstarsdata.h:92
CatalogDB::GetAllObjects
void GetAllObjects(const QString &catalog_name, QList< SkyObject * > &sky_list, QList< QPair< int, QString > > &object_names, CatalogComponent *catalog_pointer)
Creates objects of type SkyObject and assigns them to references.
Definition: catalogdb.cpp:674
CatalogData::epoch
float epoch
Definition: catalogdata.h:44
skypainter.h
SkyPoint::updateCoords
virtual void updateCoords(KSNumbers *num, bool includePlanets=true, const dms *lat=0, const dms *LST=0, bool forceRecompute=false)
Determine the current coordinates (RA, Dec) from the catalog coordinates (RA0, Dec0), accounting for both precession and nutation.
Definition: skypoint.cpp:317
StarObject::updateCoords
virtual void updateCoords(KSNumbers *num, bool includePlanets=true, const dms *lat=0, const dms *LST=0, bool forceRecompute=false)
Determine the current coordinates (RA, Dec) from the catalog coordinates (RA0, Dec0), accounting for both precession and nutation.
Definition: starobject.cpp:244
KStarsData::catalogdb
CatalogDB * catalogdb()
Definition: kstarsdata.h:155
KStarsData::geo
GeoLocation * geo()
Definition: kstarsdata.h:164
KStarsData::updateNumID
unsigned int updateNumID()
Definition: kstarsdata.h:225
ListComponent
An abstract parent class, to be inherited by SkyComponents that store a QList of SkyObjects.
Definition: listcomponent.h:36
CatalogComponent::~CatalogComponent
virtual ~CatalogComponent()
Destructor.
Definition: catalogcomponent.cpp:46
CatalogData::fluxfreq
QString fluxfreq
Definition: catalogdata.h:45
KStarsData::updateNum
KSNumbers * updateNum()
Definition: kstarsdata.h:226
CatalogData::color
QString color
Definition: catalogdata.h:43
StarObject::updateID
quint64 updateID
Definition: starobject.h:265
CatalogData
Add the catalog with given details into the database.
Definition: catalogdata.h:38
StarObject::updateNumID
quint64 updateNumID
Definition: starobject.h:266
CatalogComponent::CatalogComponent
CatalogComponent(SkyComposite *, const QString &fname, bool showerrs, int index)
Constructor parent Pointer to the parent SkyComposite object.
Definition: catalogcomponent.cpp:38
skymap.h
CatalogData::prefix
QString prefix
Definition: catalogdata.h:42
SkyComposite
SkyComposite is a kind of container class for SkyComponent objects.
Definition: skycomposite.h:43
DeepSkyObject::updateNumID
quint64 updateNumID
Definition: deepskyobject.h:192
StarObject::spchar
char spchar() const
Returns just the first character of the spectral type string.
Definition: starobject.cpp:344
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
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
KSNumbers
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition: ksnumbers.h:43
GeoLocation::lat
const dms * lat() const
Definition: geolocation.h:79
CatalogData::fluxunit
QString fluxunit
Definition: catalogdata.h:46
SkyObject::type
int type(void) const
Definition: skyobject.h:164
Options::showCatalogNames
static QStringList showCatalogNames()
Get List for displaying custom object catalogs.
Definition: Options.h:467
starobject.h
SkyComponent::emitProgressText
virtual void emitProgressText(const QString &message)
Emit signal about progress.
Definition: skycomponent.cpp:35
DeepSkyObject::updateID
quint64 updateID
Definition: deepskyobject.h:191
kstarsdata.h
CatalogDB::GetCatalogData
void GetCatalogData(const QString &catalog_name, CatalogData &catalog_data)
Get information about the catalog like Prefix etc.
Definition: catalogdb.cpp:654
CatalogComponent::update
virtual void update(KSNumbers *num)
Update the sky positions of this component.
Definition: catalogcomponent.cpp:74
SkyComponent::objectNames
QHash< int, QStringList > & objectNames()
Definition: skycomponent.h:127
StarObject
This is a subclass of SkyObject.
Definition: starobject.h:41
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
catalogcomponent.h
SkyPainter::drawDeepSkyObject
virtual bool drawDeepSkyObject(DeepSkyObject *obj, bool drawImage=false)=0
Draw a deep sky object.
QList
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:19 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