• 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
astrocalc.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  astrocalc.cpp - description
3  -------------------
4  begin : wed dec 19 16:20:11 CET 2002
5  copyright : (C) 2001-2005 by Pablo de Vicente
6  email : p.devicente@wanadoo.es
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 "astrocalc.h"
19 
20 #include <QSplitter>
21 #include <QStackedWidget>
22 #include <QTreeWidget>
23 #include <QTreeWidgetItem>
24 #include <KTextEdit>
25 #include <klocale.h>
26 #include <ktextedit.h>
27 
28 #include "dms.h"
29 #include "modcalcjd.h"
30 #include "modcalcgeodcoord.h"
31 #include "modcalcgalcoord.h"
32 #include "modcalcsidtime.h"
33 #include "modcalcapcoord.h"
34 #include "modcalcdaylength.h"
35 #include "modcalcaltaz.h"
36 #include "modcalcplanets.h"
37 #include "modcalceclipticcoords.h"
38 #include "modcalcangdist.h"
39 #include "modcalcvizequinox.h"
40 #include "modcalcvlsr.h"
41 #include "conjunctions.h"
42 
43 AstroCalc::AstroCalc( QWidget* parent ) :
44  KDialog( parent )
45 {
46  // List of messages. Maybe there is better place for it...
47  QString message =
48  i18n("<QT>"
49  "<H2>KStars Astrocalculator</H2>"
50  "<P>"
51  "The KStars Astrocalculator contains several <B>modules</b> "
52  "which perform a variety of astronomy-related calculations. "
53  "The modules are organized into several categories: "
54  "<UL>"
55  "<LI><B>Time calculators: </B>"
56  "Convert between time systems, and predict the timing of celestial events</LI>"
57  "<LI><B>Coordinate converters: </B>"
58  "Convert between various coordinate systems</LI>"
59  "<LI><B>Solar system: </B>"
60  "Predict the position of any planet, from a given location on Earth at a given time</LI>"
61  "</UL>"
62  "</QT>"
63  );
64  QString messageTime =
65  i18n("<QT>"
66  "Section which includes algorithms for computing time ephemeris"
67  "<UL><LI>"
68  "<B>Julian Day:</B> Julian Day/Calendar conversion"
69  "</LI><LI>"
70  "<B>Sidereal Time:</B> Sidereal/Universal time conversion"
71  "</LI><LI>"
72  "<B>Almanac:</B> Rise/Set/Transit timing and position data "
73  "for the Sun and Moon"
74  "</LI><LI>"
75  "<B>Equinoxes & Solstices:</B> Equinoxes, Solstices and duration of the "
76  "seasons"
77  "</LI></UL>"
78  "</QT>");
79  QString messageCoord =
80  i18n("<QT>"
81  "Section with algorithms for the conversion of "
82  "different astronomical systems of coordinates"
83  "<UL><LI>"
84  "<B>Galactic:</B> Galactic/Equatorial coordinates conversion"
85  "</LI><LI>"
86  "<B>Apparent:</B> Computation of current equatorial coordinates"
87  " from a given epoch"
88  "</LI><LI>"
89  "<B>Ecliptic:</B> Ecliptic/Equatorial coordinates conversion"
90  "</LI><LI>"
91  "<B>Horizontal:</B> Computation of azimuth and elevation for a "
92  "given source, time, and location on the Earth"
93  "</LI><LI>"
94  "<B>Angular Distance:</B> Computation of angular distance between "
95  "two objects whose positions are given in equatorial coordinates"
96  "</LI><LI>"
97  "<B>Geodetic Coords:</B> Geodetic/XYZ coordinate conversion"
98  "</LI><LI>"
99  "<B>LSR Velocity:</B> Computation of the heliocentric, geocentric "
100  "and topocentric radial velocity of a source from its LSR velocity"
101  "</LI></UL>"
102  "</QT>");
103  QString messageSolar =
104  i18n("<QT>"
105  "Section with algorithms regarding information "
106  "on solar system bodies coordinates and times"
107  "<UL><LI>"
108  "<B>Planets Coords:</B> Coordinates for the planets, moon and sun "
109  "at a given time and from a given position on Earth "
110  "</LI></UL>"
111  "</QT>");
112 
113  QSplitter* split = new QSplitter ( this );
114  setMainWidget(split);
115  setCaption( i18n("Calculator") );
116  setButtons( KDialog::Close );
117 
118  // Create navigation panel
119  navigationPanel = new QTreeWidget(split);
120  navigationPanel->setColumnCount(1);
121  navigationPanel->setHeaderLabels( QStringList(i18n("Calculator modules")) );
122  navigationPanel->setSortingEnabled( false );
123  //FIXME: Would be better to make the navigationPanel fit its contents,
124  //but I wasn't able to make it work
125  navigationPanel->setMinimumWidth( 200 );
126 
127  acStack = new QStackedWidget( split );
128 
129  splashScreen = new KTextEdit( message, acStack );
130  splashScreen->setReadOnly( true );
131  //FIXME: Minimum size is set to resize calculator to correct size
132  //when no modules is loaded. This is simply biggest size of
133  //calculator modules. I think it should be set in more cleverly.
134  splashScreen->setMinimumSize(640, 550);
135  acStack->addWidget( splashScreen );
136 
137 
138  // Load icons
139  QIcon jdIcon = QIcon ("jd.png");
140  QIcon geodIcon = QIcon ("geodetic.png");
141  QIcon solarIcon = QIcon ("geodetic.png");
142  // QIcon sunsetIcon = QIcon ("sunset.png"); // Its usage is commented out.
143  QIcon timeIcon = QIcon ("sunclock.png");
144 
145  /* Populate the tree widget and widget stack */
146  // Time-related entries
147  QTreeWidgetItem * timeItem = addTreeTopItem(navigationPanel, i18n("Time Calculators"), messageTime);
148  timeItem->setIcon(0,timeIcon);
149 
150  addTreeItem<modCalcJD> (timeItem, i18n("Julian Day"))->setIcon(0,jdIcon);
151  addTreeItem<modCalcSidTime> (timeItem, i18n("Sidereal Time"));
152  addTreeItem<modCalcDayLength>(timeItem, i18n("Almanac"));
153  addTreeItem<modCalcEquinox> (timeItem, i18n("Equinoxes & Solstices"));
154  // dayItem->setIcon(0,sunsetIcon);
155 
156  // Coordinate-related entries
157  QTreeWidgetItem * coordItem = addTreeTopItem(navigationPanel, i18n("Coordinate Converters"), messageCoord);
158  addTreeItem<modCalcGalCoord> (coordItem, i18n("Equatorial/Galactic"));
159  addTreeItem<modCalcApCoord> (coordItem, i18n("Apparent Coordinates"));
160  addTreeItem<modCalcAltAz> (coordItem, i18n("Horizontal Coordinates"));
161  addTreeItem<modCalcEclCoords>(coordItem, i18n("Ecliptic Coordinates"));
162  addTreeItem<modCalcAngDist> (coordItem, i18n("Angular Distance"));
163  addTreeItem<modCalcGeodCoord>(coordItem, i18n("Geodetic Coordinates"));
164  addTreeItem<modCalcVlsr> (coordItem, i18n("LSR Velocity"));
165 
166  // Solar System related entries
167  QTreeWidgetItem * solarItem = addTreeTopItem(navigationPanel, i18n("Solar System"), messageSolar);
168  solarItem->setIcon(0,solarIcon);
169  addTreeItem<modCalcPlanets> (solarItem, i18n("Planets Coordinates"));
170  addTreeItem<ConjunctionsTool>(solarItem, i18n("Conjunctions"));
171 
172  acStack->setCurrentWidget( splashScreen );
173  connect(navigationPanel, SIGNAL(itemClicked(QTreeWidgetItem *, int)),
174  this, SLOT(slotItemSelection(QTreeWidgetItem *)));
175 }
176 
177 template<typename T>
178 QWidget* AstroCalc::addToStack()
179 {
180  T* t = new T( acStack );
181  acStack->addWidget(t);
182  return t;
183 }
184 
185 template<typename T>
186 QTreeWidgetItem* AstroCalc::addTreeItem(QTreeWidgetItem* parent, QString title)
187 {
188  QTreeWidgetItem* item = new QTreeWidgetItem(parent, QStringList(title));
189  dispatchTable.insert(item,
190  WidgetThunk(this, &AstroCalc::addToStack<T>));
191  return item;
192 }
193 
194 QTreeWidgetItem* AstroCalc::addTreeTopItem(QTreeWidget* parent, QString title, QString html)
195 {
196  QTreeWidgetItem* item = new QTreeWidgetItem(parent, QStringList(title));
197  htmlTable.insert(item, html);
198  return item;
199 }
200 
201 AstroCalc::~AstroCalc() {}
202 
203 void AstroCalc::slotItemSelection(QTreeWidgetItem *item)
204 {
205  if ( item == 0)
206  return;
207  // Lookup in HTML table
208  QMap<QTreeWidgetItem*, QString>::iterator iterHTML = htmlTable.find(item);
209  if( iterHTML != htmlTable.end() ) {
210  splashScreen->setHtml(*iterHTML);
211  acStack->setCurrentWidget(splashScreen);
212  return;
213  }
214  // Lookup in frames table
215  QMap<QTreeWidgetItem*, WidgetThunk>::iterator iter = dispatchTable.find(item);
216  if( iter != dispatchTable.end() ) {
217  acStack->setCurrentWidget( iter->eval() );
218  }
219 }
220 
221 QSize AstroCalc::sizeHint() const
222 {
223  return QSize(640,430);
224 }
225 
226 QWidget* AstroCalc::WidgetThunk::eval()
227 {
228  if( widget == 0 ) {
229  // This is pointer to member function call.
230  widget = (calc->*func)();
231  }
232  return widget;
233 }
234 
235 #include "astrocalc.moc"
modcalcplanets.h
conjunctions.h
AstroCalc::~AstroCalc
~AstroCalc()
Definition: astrocalc.cpp:201
modcalcapcoord.h
QWidget
KDialog
AstroCalc::slotItemSelection
void slotItemSelection(QTreeWidgetItem *it)
Display calculator module or help text based on item selected.
Definition: astrocalc.cpp:203
astrocalc.h
dms.h
modcalcvizequinox.h
AstroCalc::sizeHint
QSize sizeHint() const
Definition: astrocalc.cpp:221
modcalcaltaz.h
modcalcangdist.h
modcalcdaylength.h
modcalcvlsr.h
modcalcgalcoord.h
AstroCalc::AstroCalc
AstroCalc(QWidget *parent=0)
Definition: astrocalc.cpp:43
modcalceclipticcoords.h
modcalcjd.h
KTextEdit
modcalcgeodcoord.h
modcalcsidtime.h
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