• 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
deepskyobject.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  deepskyobject.cpp - K Desktop Planetarium
3  -------------------
4  begin : Sun Feb 11 2001
5  copyright : (C) 2001 by Jason Harris
6  email : jharris@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 "deepskyobject.h"
19 
20 #include <kglobal.h>
21 
22 #include <QFile>
23 #include <QRegExp>
24 #include <QPainter>
25 #include <QImage>
26 
27 #include <assert.h>
28 
29 #include "kstarsdata.h"
30 #include "ksutils.h"
31 #include "dms.h"
32 #include "kspopupmenu.h"
33 #include "Options.h"
34 #include "skymap.h"
35 #include "texturemanager.h"
36 
37 #include <kdebug.h>
38 
39 DeepSkyObject::DeepSkyObject( const DeepSkyObject &o ) :
40  SkyObject( o ),
41  Catalog( o.Catalog ),
42  PositionAngle( o.PositionAngle ),
43  UGC( o.UGC ),
44  PGC( o.PGC ),
45  MajorAxis( o.MajorAxis ),
46  MinorAxis( o.MinorAxis ),
47  m_image( o.m_image )
48 {
49  customCat = NULL;
50  Flux = 0;
51  updateID = updateNumID = 0;
52 }
53 
54 DeepSkyObject::DeepSkyObject( int t, dms r, dms d, float m,
55  const QString &n, const QString &n2,
56  const QString &lname, const QString &cat,
57  float a, float b, double pa, int pgc, int ugc )
58  : SkyObject( t, r, d, m, n, n2, lname )
59 {
60  MajorAxis = a;
61  MinorAxis = b;
62  PositionAngle = pa;
63  PGC = pgc;
64  UGC = ugc;
65  setCatalog( cat );
66  updateID = updateNumID = 0;
67  customCat = NULL;
68  Flux = 0;
69  loadImage();
70 }
71 
72 DeepSkyObject* DeepSkyObject::clone() const
73 {
74  return new DeepSkyObject(*this);
75 }
76 
77 void DeepSkyObject::initPopupMenu( KSPopupMenu *pmenu ) {
78  pmenu->createDeepSkyObjectMenu( this );
79 }
80 
81 float DeepSkyObject::e() const {
82  if ( MajorAxis==0.0 || MinorAxis==0.0 )
83  return 1.0; //assume circular
84  return MinorAxis / MajorAxis;
85 }
86 
87 QString DeepSkyObject::catalog() const {
88  if ( isCatalogM() ) return QString("M");
89  if ( isCatalogNGC() ) return QString("NGC");
90  if ( isCatalogIC() ) return QString("IC");
91  return QString();
92 }
93 
94 void DeepSkyObject::setCatalog( const QString &cat ) {
95  if ( cat.toUpper() == "M" ) Catalog = (unsigned char)CAT_MESSIER;
96  else if ( cat.toUpper() == "NGC" ) Catalog = (unsigned char)CAT_NGC;
97  else if ( cat.toUpper() == "IC" ) Catalog = (unsigned char)CAT_IC;
98  else Catalog = (unsigned char)CAT_UNKNOWN;
99 }
100 
101 void DeepSkyObject::loadImage()
102 {
103  QString tname = name().toLower().remove(' ');
104  m_image = TextureManager::getImage( tname );
105 }
106 
107 double DeepSkyObject::labelOffset() const {
108  //Calculate object size in pixels
109  double majorAxis = a();
110  double minorAxis = b();
111  if ( majorAxis == 0.0 && type() == 1 ) { //catalog stars
112  majorAxis = 1.0;
113  minorAxis = 1.0;
114  }
115  double size = ((majorAxis + minorAxis) / 2.0 ) * dms::PI * Options::zoomFactor()/10800.0;
116  return 0.5*size + 4.;
117 }
118 
119 QString DeepSkyObject::labelString() const {
120  QString oName;
121  if( Options::showDeepSkyNames() ) {
122  if( Options::deepSkyLongLabels() && translatedLongName() != translatedName() )
123  oName = translatedLongName() + " (" + translatedName() + ')';
124  else
125  oName = translatedName();
126  }
127 
128  if( Options::showDeepSkyMagnitudes() ) {
129  if( Options::showDeepSkyNames() )
130  oName += "; ";
131  oName += KGlobal::locale()->formatNumber( mag(), 1 );
132  }
133 
134  return oName;
135 }
136 
137 
138 SkyObject::UID DeepSkyObject::getUID() const
139 {
140  // mag takes 10 bit
141  SkyObject::UID m = mag()*10;
142  if( m < 0 ) m = 0;
143 
144  // Both RA & dec fits in 24-bits
145  SkyObject::UID ra = ra0().Degrees() * 36000;
146  SkyObject::UID dec = (ra0().Degrees()+91) * 36000;
147 
148  assert("Magnitude is expected to fit into 10bits" && m>=0 && m<(1<<10));
149  assert("RA should fit into 24bits" && ra>=0 && ra <(1<<24));
150  assert("Dec should fit into 24bits" && dec>=0 && dec<(1<<24));
151 
152  // Choose kind of
153  SkyObject::UID kind = type() == SkyObject::GALAXY ? SkyObject::UID_GALAXY : SkyObject::UID_DEEPSKY;
154  return (kind << 60) | (m << 48) | (ra << 24) | dec;
155 }
DeepSkyObject::b
float b() const
Definition: deepskyobject.h:137
DeepSkyObject::CAT_MESSIER
Definition: deepskyobject.h:85
SkyPoint::ra
const dms & ra() const
Definition: skypoint.h:171
SkyObject::UID_GALAXY
static const UID UID_GALAXY
Definition: skyobject.h:57
DeepSkyObject::isCatalogIC
bool isCatalogIC() const
Definition: deepskyobject.h:179
DeepSkyObject::catalog
QString catalog(void) const
Definition: deepskyobject.cpp:87
KSPopupMenu
The KStars Popup Menu.
Definition: kspopupmenu.h:43
SkyObject::translatedName
QString translatedName() const
Definition: skyobject.h:129
Options::deepSkyLongLabels
static bool deepSkyLongLabels()
Get Show long names in deep-sky object name labels?
Definition: Options.h:2702
deepskyobject.h
DeepSkyObject::getUID
virtual SkyObject::UID getUID() const
Return UID for object.
Definition: deepskyobject.cpp:138
dms::Degrees
const double & Degrees() const
Definition: dms.h:98
SkyObject::GALAXY
Definition: skyobject.h:109
DeepSkyObject::CAT_UNKNOWN
Definition: deepskyobject.h:85
DeepSkyObject::CAT_NGC
Definition: deepskyobject.h:85
KSPopupMenu::createDeepSkyObjectMenu
void createDeepSkyObjectMenu(DeepSkyObject *obj)
Create a popup menu for a deep-sky object.
Definition: kspopupmenu.cpp:194
SkyPoint::ra0
const dms & ra0() const
Definition: skypoint.h:165
TextureManager::getImage
static const QImage & getImage(const QString &name)
Return texture image.
Definition: texturemanager.cpp:44
SkyObject::UID_DEEPSKY
static const UID UID_DEEPSKY
Definition: skyobject.h:58
DeepSkyObject::pgc
int pgc() const
Definition: deepskyobject.h:158
DeepSkyObject::loadImage
void loadImage()
Try to load the object's image.
Definition: deepskyobject.cpp:101
dms.h
kspopupmenu.h
texturemanager.h
DeepSkyObject::isCatalogNGC
bool isCatalogNGC() const
Definition: deepskyobject.h:174
DeepSkyObject::a
float a() const
Definition: deepskyobject.h:132
skymap.h
DeepSkyObject::clone
virtual DeepSkyObject * clone() const
Create copy of object.
Definition: deepskyobject.cpp:72
SkyObject::UID
qint64 UID
Type for Unique object IDenticator.
Definition: skyobject.h:53
SkyObject::translatedLongName
QString translatedLongName() const
Definition: skyobject.h:145
DeepSkyObject::pa
virtual double pa() const
Definition: deepskyobject.h:148
Options::showDeepSkyMagnitudes
static bool showDeepSkyMagnitudes()
Get Label deep-sky object magnitudes in the sky map?
Definition: Options.h:2234
dms
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:42
DeepSkyObject::DeepSkyObject
DeepSkyObject(int t=SkyObject::STAR, dms r=dms(0.0), dms d=dms(0.0), float m=0.0, const QString &n="unnamed", const QString &n2=QString(), const QString &lname=QString(), const QString &cat=QString(), float a=0.0, float b=0.0, double pa=0.0, int pgc=0, int ugc=0)
Constructor.
Definition: deepskyobject.cpp:54
SkyPoint::dec
const dms & dec() const
Definition: skypoint.h:174
DeepSkyObject::updateNumID
quint64 updateNumID
Definition: deepskyobject.h:192
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
DeepSkyObject::isCatalogM
bool isCatalogM() const
Definition: deepskyobject.h:169
DeepSkyObject::labelString
QString labelString() const
Definition: deepskyobject.cpp:119
SkyObject::type
int type(void) const
Definition: skyobject.h:164
NaN::d
const double d
Definition: nan.h:35
DeepSkyObject::setCatalog
void setCatalog(const QString &s)
Set the internal Catalog value according to the QString argument: "M" : CAT_MESSIER "NGC" : CAT_NGC "...
Definition: deepskyobject.cpp:94
PI
#define PI
Definition: satellite.cpp:43
Options::zoomFactor
static double zoomFactor()
Get Zoom Factor, in pixels per radian.
Definition: Options.h:2531
DeepSkyObject::updateID
quint64 updateID
Definition: deepskyobject.h:191
kstarsdata.h
DeepSkyObject::e
float e() const
Definition: deepskyobject.cpp:81
DeepSkyObject::ugc
int ugc() const
Definition: deepskyobject.h:153
SkyObject::name
virtual QString name(void) const
Definition: skyobject.h:124
ksutils.h
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
Options::showDeepSkyNames
static bool showDeepSkyNames()
Get Label deep-sky objects in the sky map?
Definition: Options.h:2253
DeepSkyObject::CAT_IC
Definition: deepskyobject.h:85
DeepSkyObject::labelOffset
virtual double labelOffset() const
Definition: deepskyobject.cpp:107
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