• 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
  • printing
pwizobjectselection.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  pwizobjectselection.cpp - K Desktop Planetarium
3  -------------------
4  begin : Wed Aug 3 2011
5  copyright : (C) 2011 by Rafał Kułaga
6  email : rl.kulaga@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 "pwizobjectselection.h"
19 #include "printingwizard.h"
20 #include "kstars.h"
21 #include "skymap.h"
22 #include "dialogs/finddialog.h"
23 #include "dialogs/detaildialog.h"
24 #include "starobject.h"
25 #include "ksplanetbase.h"
26 #include "deepskyobject.h"
27 #include <QPointer>
28 
29 PWizObjectSelectionUI::PWizObjectSelectionUI(PrintingWizard *wizard, QWidget *parent) : QFrame(parent),
30  m_ParentWizard(wizard)
31 {
32  setupUi(this);
33 
34  detailsButton->setVisible(false);
35  selectedObjLabel->setVisible(false);
36  objInfoLabel->setVisible(false);
37 
38  connect(fromListButton, SIGNAL(clicked()), this, SLOT(slotSelectFromList()));
39  connect(pointButton, SIGNAL(clicked()), this, SLOT(slotPointObject()));
40  connect(detailsButton, SIGNAL(clicked()), this, SLOT(slotShowDetails()));
41 }
42 
43 void PWizObjectSelectionUI::setSkyObject(SkyObject *obj)
44 {
45  m_ParentWizard->setSkyObject(obj);
46  m_ParentWizard->updateStepButtons();
47 
48  QString infoStr = objectInfoString(obj);
49 
50  objInfoLabel->setText(infoStr);
51 
52  detailsButton->setVisible(true);
53  selectedObjLabel->setVisible(true);
54  objInfoLabel->setVisible(true);
55 }
56 
57 void PWizObjectSelectionUI::slotSelectFromList()
58 {
59  QPointer<FindDialog> findDlg( new FindDialog( this ) );
60  if(findDlg->exec() == QDialog::Accepted && findDlg)
61  {
62  SkyObject *obj = findDlg->selectedObject();
63  if(obj)
64  {
65  setSkyObject(obj);
66  m_ParentWizard->updateStepButtons();
67  }
68  }
69  delete findDlg;
70 }
71 
72 void PWizObjectSelectionUI::slotPointObject()
73 {
74  m_ParentWizard->beginPointing();
75 }
76 
77 void PWizObjectSelectionUI::slotShowDetails()
78 {
79  if(m_ParentWizard->getSkyObject())
80  {
81  QPointer<DetailDialog> detailDlg( new DetailDialog( m_ParentWizard->getSkyObject(), KStars::Instance()->data()->ut(),
82  KStars::Instance()->data()->geo(), this ) );
83  detailDlg->exec();
84  delete detailDlg;
85  }
86 }
87 
88 QString PWizObjectSelectionUI::objectInfoString(SkyObject *obj)
89 {
90  QString retVal;
91 
92  switch(obj->type())
93  {
94  case SkyObject::STAR:
95  {
96  StarObject *s = (StarObject *)obj;
97 
98  retVal = s->longname();
99 
100  if(s->getHDIndex() != 0)
101  {
102  if(!s->longname().isEmpty())
103  {
104  retVal += QString(", HD%1").arg(QString::number(s->getHDIndex()));
105  }
106 
107  else
108  {
109  retVal += QString(", HD%1").arg(QString::number(s->getHDIndex()));
110  }
111  }
112 
113  retVal += "; " + s->sptype() + ' ' + i18n("star");
114  retVal += "; " + i18nc("number in magnitudes", "%1 mag", KGlobal::locale()->formatNumber(s->mag(), 1));
115 
116  break;
117  }
118 
119  case SkyObject::ASTEROID: //[fall through to planets]
120  case SkyObject::COMET: //[fall through to planets]
121  case SkyObject::MOON: //[fall through to planets]
122 
123  case SkyObject::PLANET:
124  {
125  KSPlanetBase *ps = (KSPlanetBase *)obj;
126 
127  retVal = ps->longname();
128 
129  //Type is "G5 star" for Sun
130  QString type;
131  if(ps->name() == "Sun")
132  {
133  type = i18n("G5 star");
134  }
135 
136  else if(ps->name() == "Moon" )
137  {
138  type = ps->translatedName();
139  }
140 
141  else if( ps->name() == i18n("Pluto") || ps->name() == "Ceres" || ps->name() == "Eris" )
142  {
143  type = i18n("Dwarf planet");
144  }
145 
146  else
147  {
148  type = ps->typeName();
149  }
150 
151  retVal += "; " + type;
152  retVal += "; " + i18nc("number in magnitudes", "%1 mag", KGlobal::locale()->formatNumber(ps->mag(), 1));
153 
154  break;
155  }
156 
157  default: // deep-sky object
158  {
159  DeepSkyObject *dso = (DeepSkyObject *)obj;
160 
161  QString oname, pname;
162  //Show all names recorded for the object
163  if(!dso->longname().isEmpty() && dso->longname() != dso->name())
164  {
165  pname = dso->translatedLongName();
166  oname = dso->translatedName();
167  }
168 
169  else
170  {
171  pname = dso->translatedName();
172  }
173 
174  if(!dso->translatedName2().isEmpty())
175  {
176  if(oname.isEmpty())
177  {
178  oname = dso->translatedName2();
179  }
180 
181  else
182  {
183  oname += ", " + dso->translatedName2();
184  }
185  }
186 
187  if(dso->ugc())
188  {
189  if(!oname.isEmpty())
190  {
191  oname += ", ";
192  }
193 
194  oname += "UGC " + QString::number(dso->ugc());
195  }
196 
197  if(dso->pgc())
198  {
199  if(!oname.isEmpty())
200  {
201  oname += ", ";
202  }
203 
204  oname += "PGC " + QString::number(dso->pgc());
205  }
206 
207  if(!oname.isEmpty()) pname += ", " + oname;
208 
209  retVal = pname;
210  retVal += "; " + dso->typeName();
211 
212  break;
213  }
214  }
215 
216  return retVal;
217 }
ksplanetbase.h
DetailDialog
window showing detailed information for a selected object.
Definition: detaildialog.h:88
PrintingWizard::beginPointing
void beginPointing()
Set SkyMap to pointing mode and hide Printing Wizard.
Definition: printingwizard.cpp:84
SkyObject::translatedName
QString translatedName() const
Definition: skyobject.h:129
StarObject::sptype
QString sptype(void) const
Returns entire spectral type string.
Definition: starobject.cpp:340
detaildialog.h
deepskyobject.h
SkyObject::PLANET
Definition: skyobject.h:108
SkyObject::longname
virtual QString longname(void) const
Definition: skyobject.h:140
QWidget
PWizObjectSelectionUI::setSkyObject
void setSkyObject(SkyObject *obj)
Update UI elements for newly selected SkyObject.
Definition: pwizobjectselection.cpp:43
KStars::Instance
static KStars * Instance()
Definition: kstars.h:125
KStarsData::geo
GeoLocation * geo()
Definition: kstarsdata.h:164
SkyObject::COMET
Definition: skyobject.h:110
DeepSkyObject::pgc
int pgc() const
Definition: deepskyobject.h:158
PrintingWizard::updateStepButtons
void updateStepButtons()
Update Next/Previous step buttons.
Definition: printingwizard.cpp:72
StarObject::getHDIndex
int getHDIndex() const
Definition: starobject.h:226
skymap.h
i18nc
i18nc("string from libindi, used in the config dialog","100x")
SkyObject::MOON
Definition: skyobject.h:110
SkyObject::translatedLongName
QString translatedLongName() const
Definition: skyobject.h:145
PrintingWizard
Class representing Printing Wizard for KStars printed documents (currently only finder charts)...
Definition: printingwizard.h:66
printingwizard.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
SkyObject::type
int type(void) const
Definition: skyobject.h:164
finddialog.h
starobject.h
PrintingWizard::getSkyObject
SkyObject * getSkyObject()
Get selected SkyObject, for which FinderChart is created.
Definition: printingwizard.h:129
KStars::data
KStarsData * data() const
Definition: kstars.h:131
PrintingWizard::setSkyObject
void setSkyObject(SkyObject *obj)
Set SkyObject for which FinderChart is created.
Definition: printingwizard.h:159
StarObject::longname
virtual QString longname(void) const
If star is unnamed return "star" otherwise return the longname.
Definition: starobject.h:134
SkyObject::translatedName2
QString translatedName2() const
Definition: skyobject.h:135
KSPlanetBase
A subclass of TrailObject that provides additional information needed for most solar system objects...
Definition: ksplanetbase.h:63
SkyObject::ASTEROID
Definition: skyobject.h:110
PWizObjectSelectionUI::PWizObjectSelectionUI
PWizObjectSelectionUI(PrintingWizard *wizard, QWidget *parent=0)
Constructor.
Definition: pwizobjectselection.cpp:29
pwizobjectselection.h
PWizObjectSelectionUI::objectInfoString
static QString objectInfoString(SkyObject *obj)
Static function: get QString with basic information about SkyObject.
Definition: pwizobjectselection.cpp:88
KStarsData::ut
const KStarsDateTime & ut() const
Definition: kstarsdata.h:140
DeepSkyObject::ugc
int ugc() const
Definition: deepskyobject.h:153
SkyObject::name
virtual QString name(void) const
Definition: skyobject.h:124
StarObject
This is a subclass of SkyObject.
Definition: starobject.h:41
SkyObject::typeName
static QString typeName(const int t)
Definition: skyobject.cpp:319
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
QFrame
kstars.h
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