• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kstars

jmoontool.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           jmoontool.cpp  -  Display overhead view of the solar system
00003                              -------------------
00004     begin                : Sun May 25 2003
00005     copyright            : (C) 2003 by Jason Harris
00006     email                : jharris@30doradus.org
00007  ***************************************************************************/
00008 /***************************************************************************
00009  *                                                                         *
00010  *   This program is free software; you can redistribute it and/or modify  *
00011  *   it under the terms of the GNU General Public License as published by  *
00012  *   the Free Software Foundation; either version 2 of the License, or     *
00013  *   (at your option) any later version.                                   *
00014  *                                                                         *
00015  ***************************************************************************/
00016 
00017 #include <qlayout.h>
00018 #include <qlabel.h>
00019 
00020 #include <kdebug.h>
00021 #include <klocale.h>
00022 
00023 #include "jmoontool.h"
00024 #include "jupitermoons.h"
00025 #include "kstars.h"
00026 #include "kstarsdata.h"
00027 #include "ksplanet.h"
00028 #include "simclock.h"
00029 #include "planetcatalog.h"
00030 #include "dms.h"
00031 #include "ksnumbers.h"
00032 
00033 JMoonTool::JMoonTool(QWidget *parent, const char *name)
00034  : KDialogBase( KDialogBase::Plain, i18n("Jupiter Moons Tool"), Close, Close, parent, name )
00035 {
00036     ksw = (KStars*)parent;
00037     
00038     QFrame *page = plainPage();
00039     QVBoxLayout *vlay = new QVBoxLayout( page, 0, 0 );
00040     
00041     colJp = "White";
00042     colIo = "Red";
00043     colEu = "Yellow";
00044     colGn = "Orange";
00045     colCa = "YellowGreen";
00046     
00047     QLabel *labIo = new QLabel( "Io", page );
00048     QLabel *labEu = new QLabel( "Europa", page );
00049     QLabel *labGn = new QLabel( "Ganymede", page );
00050     QLabel *labCa = new QLabel( "Callisto", page );
00051     
00052     labIo->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
00053     labEu->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
00054     labGn->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
00055     labCa->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
00056     labIo->setAlignment( AlignHCenter );
00057     labEu->setAlignment( AlignHCenter );
00058     labGn->setAlignment( AlignHCenter );
00059     labCa->setAlignment( AlignHCenter );
00060 
00061     labIo->setPaletteForegroundColor( colIo );
00062     labEu->setPaletteForegroundColor( colEu );
00063     labGn->setPaletteForegroundColor( colGn );
00064     labCa->setPaletteForegroundColor( colCa );
00065     labIo->setPaletteBackgroundColor( "Black" );
00066     labEu->setPaletteBackgroundColor( "Black" );
00067     labGn->setPaletteBackgroundColor( "Black" );
00068     labCa->setPaletteBackgroundColor( "Black" );
00069     
00070     QGridLayout *glay = new QGridLayout( 2, 2, 0 );
00071     glay->addWidget( labIo, 0, 0 );
00072     glay->addWidget( labEu, 1, 0 );
00073     glay->addWidget( labGn, 0, 1 );
00074     glay->addWidget( labCa, 1, 1 );
00075     
00076     pw = new KStarsPlotWidget( 0.0, 1.0, 0.0, 1.0, page );
00077     pw->setShowGrid( false );
00078     pw->setYAxisType0( KStarsPlotWidget::TIME );
00079     pw->setLimits( -12.0, 12.0, -240.0, 240.0 );
00080     pw->setXAxisLabel( i18n( "offset from Jupiter (arcmin)" ) );
00081     pw->setYAxisLabel( i18n( "time since now (days)" ) );
00082     vlay->addLayout( glay );
00083     vlay->addWidget( pw );
00084     resize( 250, 500 );
00085 
00086     initPlotObjects();
00087     update();
00088 }
00089 
00090 JMoonTool::~JMoonTool()
00091 {
00092 }
00093 
00094 void JMoonTool::initPlotObjects() {
00095     KPlotObject *orbit[4];
00096     KPlotObject *jpath;
00097     long double jd0 = ksw->data()->ut().djd();
00098     KSSun *ksun = (KSSun*)ksw->data()->PCat->findByName( "Sun" );
00099     KSPlanet *jup = (KSPlanet*)ksw->data()->PCat->findByName( "Jupiter" );
00100     JupiterMoons jm;
00101     
00102     if ( pw->objectCount() ) pw->clearObjectList();
00103     
00104     orbit[0] = new KPlotObject( "io", colIo, KPlotObject::CURVE, 1, KPlotObject::SOLID );
00105     orbit[1] = new KPlotObject( "europa", colEu, KPlotObject::CURVE, 1, KPlotObject::SOLID );
00106     orbit[2] = new KPlotObject( "ganymede", colGn, KPlotObject::CURVE, 1, KPlotObject::SOLID );
00107     orbit[3] = new KPlotObject( "callisto", colCa, KPlotObject::CURVE, 1, KPlotObject::SOLID );
00108     jpath    = new KPlotObject( "jupiter", colJp, KPlotObject::CURVE, 1, KPlotObject::SOLID );
00109     
00110     double dy = 0.01*pw->dataHeight();
00111     
00112     //t is the offset from jd0, in hours.
00113     for ( double t=pw->y(); t<=pw->y2(); t+=dy ) {
00114         KSNumbers num( jd0 + t/24.0 );
00115         jm.findPosition( &num, jup, ksun );
00116         
00117         //jm.x(i) tells the offset from Jupiter, in units of Jupiter's angular radius.
00118         //multiply by 0.5*jup->angSize() to get arcminutes
00119         for ( unsigned int i=0; i<4; ++i ) 
00120             orbit[i]->addPoint( new DPoint( 0.5*jup->angSize()*jm.x(i), t ) );
00121         
00122         jpath->addPoint( new DPoint( 0.0, t ) );
00123     }
00124 
00125     for ( unsigned int i=0; i<4; ++i ) 
00126         pw->addObject( orbit[i] );
00127 
00128     pw->addObject( jpath );
00129 }
00130 
00131 void JMoonTool::keyPressEvent( QKeyEvent *e ) {
00132     switch ( e->key() ) {
00133         case Key_BracketRight:
00134         {
00135             double dy = 0.02*pw->dataHeight();
00136             pw->setLimits( pw->x(), pw->x2(), pw->y()+dy, pw->y2()+dy );
00137             initPlotObjects();
00138             pw->update();
00139             break;
00140         }
00141         case Key_BracketLeft:
00142         {
00143             double dy = 0.02*pw->dataHeight();
00144             pw->setLimits( pw->x(), pw->x2(), pw->y()-dy, pw->y2()-dy );
00145             initPlotObjects();
00146             pw->update();
00147             break;
00148         }
00149         case Key_Plus:
00150         case Key_Equal:
00151         {
00152             if ( pw->dataHeight() > 48.0 ) { 
00153                 double dy = 0.45*pw->dataHeight();
00154                 double y0 = pw->y() + 0.5*pw->dataHeight();
00155                 pw->setLimits( pw->x(), pw->x2(), y0-dy, y0+dy );
00156                 initPlotObjects();
00157                 pw->update();
00158             }
00159             break;
00160         }
00161         case Key_Minus:
00162         case Key_Underscore:
00163         {
00164             if ( pw->dataHeight() < 960.0 ) {
00165                 double dy = 0.55*pw->dataHeight();
00166                 double y0 = pw->y() + 0.5*pw->dataHeight();
00167                 pw->setLimits( pw->x(), pw->x2(), y0-dy, y0+dy );
00168                 initPlotObjects();
00169                 pw->update();
00170             }
00171             break;
00172         }
00173         case Key_Escape:
00174         {
00175             close();
00176             break;
00177         }
00178         
00179         default: { e->ignore(); break; }
00180     }
00181 }
00182 
00183 #include "jmoontool.moc"

kstars

Skip menu "kstars"
  • Main Page
  • Modules
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • keduca
  • kstars
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal