astrocalc.cpp 7.93 KB
Newer Older
Chris Howells's avatar
adding  
Chris Howells committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/***************************************************************************
                          astrocalc.cpp  -  description
                             -------------------
    begin                : wed dec 19 16:20:11 CET 2002
    copyright            : (C) 2001-2002 by Pablo de Vicente
    email                : vicente@oan.es
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "astrocalc.h"
Laurent Montel's avatar
Laurent Montel committed
19
#include "astrocalc.moc"
Chris Howells's avatar
adding  
Chris Howells committed
20 21 22 23 24 25 26 27 28
#include "dms.h"
#include "dmsbox.h"
#include "ksutils.h"
#include "modcalcjd.h"
#include "modcalcgeodcoord.h"
#include "geolocation.h"
#include "modcalcgalcoord.h"
#include "modcalcsidtime.h"
#include "modcalcprec.h"
29
#include "modcalcapcoord.h"
30
#include "modcalcdaylength.h"
31

Chris Howells's avatar
adding  
Chris Howells committed
32 33 34 35 36 37 38 39
#include <qvbox.h>
#include <qstring.h>
#include <qsplitter.h>
#include <qlistview.h>
#include <qtextview.h>
#include <klocale.h>
#include <kmenubar.h>

40
//#include <kapplication.h> ...already defined in astrocalc.h
41

42 43
AstroCalc::AstroCalc( QWidget* parent ) :
	KDialogBase( parent, "starscalculator", true,
44
	i18n("KStars Calculator"), Close ) {
Chris Howells's avatar
adding  
Chris Howells committed
45

46
	split = new QSplitter ( this );
47
	setMainWidget(split);
Chris Howells's avatar
adding  
Chris Howells committed
48 49 50

	navigationPanel = new QListView (split,"NavigationPanel");
	splashScreen = new QTextView (i18n("<H2>KStars Astrocalculator</H2>"),"",split);
51 52 53 54
	
	splashScreen->setMaximumWidth(550);
	splashScreen->setMinimumWidth(400);

Chris Howells's avatar
adding  
Chris Howells committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
	rightPanel = GenText;

	navigationPanel->addColumn("Section");
	navigationPanel->setRootIsDecorated(1);

	QPixmap jdIcon = QPixmap ("jd.png");
	QPixmap geodIcon = QPixmap ("geodetic.png");
	QPixmap sunsetIcon = QPixmap ("sunset.png");
	QPixmap timeIcon = QPixmap ("sunclock.png");
			
	QListViewItem * timeItem = new QListViewItem(navigationPanel,i18n("Time calculator"));
	timeItem->setPixmap(0,timeIcon);
	
	QListViewItem * jdItem = new QListViewItem(timeItem,i18n("Julian Day"));
	jdItem->setPixmap(0,jdIcon);

	QListViewItem * stItem = new QListViewItem(timeItem,i18n("Sidereal Time"));
72
	QListViewItem * dayItem = new QListViewItem(timeItem,i18n("Day duration"));
Chris Howells's avatar
adding  
Chris Howells committed
73 74 75
//	QListViewItem * dayItem = new QListViewItem(timeItem,i18n("Day duration"));
//	dayItem->setPixmap(0,sunsetIcon);
	
76
	QListViewItem * coordItem = new QListViewItem(navigationPanel,i18n("Coordinates converter"));
Chris Howells's avatar
adding  
Chris Howells committed
77 78
	QListViewItem * galItem = new QListViewItem(coordItem,i18n("Equatorial/Galactic"));
	QListViewItem * precItem = new QListViewItem(coordItem,i18n("Precession"));
79
	QListViewItem * appItem = new QListViewItem(coordItem,i18n("Apparent coordinates"));
Chris Howells's avatar
adding  
Chris Howells committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
	
	QListViewItem * geoItem = new QListViewItem(navigationPanel,i18n("Earth coordinates"));
	geoItem->setPixmap(0,geodIcon);

	QListViewItem * cartItem = new QListViewItem(geoItem,i18n("Geodetic coordinates"));

	connect(navigationPanel, SIGNAL(clicked(QListViewItem *)), this,
		SLOT(slotItemSelection(QListViewItem *)));
}

AstroCalc::~AstroCalc()
{
}

void AstroCalc::slotItemSelection(QListViewItem *item)
{
	QString election;
	
	if (item==0L) return;
	
	election = item->text(0);
	if(!(election.compare(i18n("Time calculator"))))
		genTimeText();
	if(!(election.compare(i18n("Sidereal Time"))))
		genSidFrame();
105
	if(!(election.compare(i18n("Coordinates converter"))))
Chris Howells's avatar
adding  
Chris Howells committed
106 107 108 109 110 111 112
		genCoordText();
	if(!(election.compare(i18n("Julian Day"))))
		genJdFrame();
	if(!(election.compare(i18n("Equatorial/Galactic"))))
		genGalFrame();
	if(!(election.compare(i18n("Precession"))))
		genPrecFrame();
113 114
	if(!(election.compare(i18n("Apparent coordinates"))))
		genAppFrame();
Chris Howells's avatar
adding  
Chris Howells committed
115 116 117 118
	if(!(election.compare(i18n("Earth coordinates"))))
		genGeodText();
	if(!(election.compare(i18n("Geodetic coordinates"))))
		genGeodCoordFrame();
119 120
	if(!(election.compare(i18n("Day duration"))))
		genDayFrame();
Chris Howells's avatar
adding  
Chris Howells committed
121 122 123 124 125 126 127 128 129 130
		
		previousElection = election;
			
}

void AstroCalc::genTimeText(void)
{

	delRightPanel();
	splashScreen = new QTextView ("","",split);
131 132
	splashScreen->setMaximumWidth(550);
	splashScreen->setMinimumWidth(400);
Chris Howells's avatar
adding  
Chris Howells committed
133 134 135 136 137
	splashScreen->show();
		
	splashScreen->setText(i18n("<QT>"
														 "Section which includes algorithms for computing time ephemeris"
														 "<UL><LI>"
138
														 "<B>Julian Day:</B> Julian Day/Calendar conversion"
Chris Howells's avatar
adding  
Chris Howells committed
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
														 "</LI><LI>"
														 "<B>Sidereal Time:</B> Sidereal/Universal time conversion"
														 "</LI><LI>"
														 "<B>Day duration:</B> Sunrise, Sunset and noon time and "
														 "positions for those events"
														 "</LI></UL>"
														 "</QT>"));
	
	rightPanel=TimeText;
														 	
}

void AstroCalc::genCoordText(void)
{
	delRightPanel();
	splashScreen = new QTextView ("","",split);
155 156
	splashScreen->setMaximumWidth(550);
	splashScreen->setMinimumWidth(400);
Chris Howells's avatar
adding  
Chris Howells committed
157 158 159
	splashScreen->show();
	
	splashScreen->setText(i18n("<QT>"
160
														 "Section with algorithms for the conversion of "
Chris Howells's avatar
adding  
Chris Howells committed
161 162 163 164 165 166 167
														 "different astronomical systems of coordinates"
														 "<UL><LI>"
														 "<B>Precessor:</B> Precession of coordinates between epochs"
														 "</LI><LI>"
														 "<B>Galactic:</B> Galactic/Equatorial coordinates conversion"
														 "</LI><LI>"
														 "<B>Apparent:</B> Computation of current equatorial coordinates"
Pablo de Vicente's avatar
Pablo de Vicente committed
168
														 " from a given epoch"
Chris Howells's avatar
adding  
Chris Howells committed
169 170 171
														 "</LI><LI>"
														 "<B>Ecliptic:</B> Ecliptic/Equatorial coordinates conversion"
														 "</LI><LI>"
172
														 "<B>Horizontal:</B> Computation of azimuth and elevation for a "
Chris Howells's avatar
adding  
Chris Howells committed
173 174 175 176 177 178 179 180 181 182 183 184
														 "given source, time, and location on the Earth"
														 "</LI></UL>"
														 "</QT>"));

	rightPanel=CoordText;

}

void AstroCalc::genGeodText(void)
{
	delRightPanel();
	splashScreen = new QTextView ("","",split);
185 186
	splashScreen->setMaximumWidth(550);
	splashScreen->setMinimumWidth(400);
Chris Howells's avatar
adding  
Chris Howells committed
187 188 189
	splashScreen->show();
	
	splashScreen->setText(i18n("<QT>"
190
														 "Section with algorithms for the conversion of "
Chris Howells's avatar
adding  
Chris Howells committed
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
														 "systems of coordinates for the Earth"
														 "<UL><LI>"
														 "<B>Geodetic Coords:</B> Geodetic/XYZ coordinate conversion"
														 "</LI></UL>"
														 "</QT>"));

	rightPanel=GeoText;
}

void AstroCalc::delRightPanel(void)
{
	if (rightPanel <= 3)
		delete splashScreen;
	else if (rightPanel == JD)
		delete JDFrame;
	else if (rightPanel == SidTime)
		delete SidFrame;
208 209
	else if (rightPanel == DayLength)
		delete DayFrame;
Chris Howells's avatar
adding  
Chris Howells committed
210 211 212 213 214 215
	else if (rightPanel == GeoCoord)
		delete GeodCoordFrame;
	else if (rightPanel == Galactic)
		delete GalFrame;
	else if (rightPanel == Precessor)
		delete PrecFrame;
216 217
	else if (rightPanel == Apparent)
		delete AppFrame;
Chris Howells's avatar
adding  
Chris Howells committed
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234

}

void AstroCalc::genJdFrame(void)
{
	delRightPanel();
	JDFrame = new modCalcJD(split,"JulianDay");
	rightPanel = JD;
}

void AstroCalc::genSidFrame(void)
{
	delRightPanel();
	SidFrame = new modCalcSidTime(split,"SiderealTime");
	rightPanel = SidTime;
}

235 236 237 238 239 240 241
void AstroCalc::genDayFrame(void)
{
	delRightPanel();
	DayFrame = new modCalcDayLength(split,"DayDuration");
	rightPanel = DayLength;
}

Chris Howells's avatar
adding  
Chris Howells committed
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262

void AstroCalc::genGeodCoordFrame(void)
{
	delRightPanel();
	GeodCoordFrame = new modCalcGeodCoord(split,"GeoCoord");
	rightPanel = GeoCoord;
}
void AstroCalc::genGalFrame(void)
{
	delRightPanel();
	GalFrame = new modCalcGalCoord(split,"Galactic");
	rightPanel = Galactic;
}

void AstroCalc::genPrecFrame(void)
{
	delRightPanel();
	PrecFrame = new modCalcPrec(split,"Precession");
	rightPanel = Precessor;
}

263 264 265 266 267 268 269
void AstroCalc::genAppFrame(void)
{
	delRightPanel();
	AppFrame = new modCalcApCoord(split,"Apparent");
	rightPanel = Apparent;
}

270 271 272 273
QSize AstroCalc::sizeHint() const
{
  return QSize(640,430);
}