19 #include <QVBoxLayout>
20 #include <QGridLayout>
27 #include <KPlotWidget>
28 #include <KPlotObject>
46 setMainWidget( page );
47 setCaption( i18n(
"Jupiter Moons Tool") );
48 setButtons( KDialog::Close );
51 QVBoxLayout *vlay =
new QVBoxLayout( page );
53 vlay->setSpacing( 0 );
55 colJp = QColor(Qt::white);
56 colIo = QColor(Qt::red);
57 colEu = QColor(Qt::yellow);
58 colGn = QColor(Qt::cyan);
59 colCa = QColor(Qt::green);
66 labIo->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
67 labEu->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
68 labGn->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
69 labCa->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
70 labIo->setAlignment( Qt::AlignHCenter );
71 labEu->setAlignment( Qt::AlignHCenter );
72 labGn->setAlignment( Qt::AlignHCenter );
73 labCa->setAlignment( Qt::AlignHCenter );
75 QPalette p = palette();
76 p.setColor( QPalette::Window, Qt::black );
77 p.setColor( QPalette::WindowText, colIo );
78 labIo->setPalette( p );
79 p.setColor( QPalette::WindowText, colEu );
80 labEu->setPalette( p );
81 p.setColor( QPalette::WindowText, colGn );
82 labGn->setPalette( p );
83 p.setColor( QPalette::WindowText, colCa );
84 labCa->setPalette( p );
85 labIo->setAutoFillBackground(
true );
86 labEu->setAutoFillBackground(
true );
87 labGn->setAutoFillBackground(
true );
88 labCa->setAutoFillBackground(
true );
90 QGridLayout *glay =
new QGridLayout();
91 glay->addWidget( labIo, 0, 0 );
92 glay->addWidget( labEu, 1, 0 );
93 glay->addWidget( labGn, 0, 1 );
94 glay->addWidget( labCa, 1, 1 );
97 pw->setShowGrid(
false );
98 pw->setAntialiasing(
true );
99 pw->setLimits( -12.0, 12.0, -11.0, 11.0 );
100 pw->axis(KPlotWidget::BottomAxis)->setLabel( i18n(
"offset from Jupiter (arcmin)" ) );
101 pw->axis(KPlotWidget::LeftAxis)->setLabel( i18n(
"time since now (days)" ) );
102 vlay->addLayout( glay );
103 vlay->addWidget( pw );
114 void JMoonTool::initPlotObjects() {
115 KPlotObject *orbit[4];
117 long double jd0 = ksw->
data()->
ut().
djd();
122 pw->removeAllPlotObjects();
124 orbit[0] =
new KPlotObject( colIo, KPlotObject::Lines, 1.0 );
125 orbit[1] =
new KPlotObject( colEu, KPlotObject::Lines, 1.0 );
126 orbit[2] =
new KPlotObject( colGn, KPlotObject::Lines, 1.0 );
127 orbit[3] =
new KPlotObject( colCa, KPlotObject::Lines, 1.0 );
128 jpath =
new KPlotObject( colJp, KPlotObject::Lines, 1.0 );
130 QRectF dataRect = pw->dataRect();
131 double dy = 0.01*dataRect.height();
134 for (
double t=dataRect.y(); t<=dataRect.bottom(); t+=dy ) {
140 for (
unsigned int i=0; i<4; ++i )
141 orbit[i]->addPoint( 0.5*jup->
angSize()*jm.
x(i), t );
143 jpath->addPoint( 0.0, t );
146 for (
unsigned int i=0; i<4; ++i )
147 pw->addPlotObject( orbit[i] );
149 pw->addPlotObject( jpath );
153 QRectF dataRect = pw->dataRect();
154 switch ( e->key() ) {
155 case Qt::Key_BracketRight:
157 double dy = 0.02*dataRect.height();
158 pw->setLimits( dataRect.x(), dataRect.right(), dataRect.y()+dy, dataRect.bottom()+dy );
163 case Qt::Key_BracketLeft:
165 double dy = 0.02*dataRect.height();
166 pw->setLimits( dataRect.x(), dataRect.right(), dataRect.y()-dy, dataRect.bottom()-dy );
174 if ( dataRect.height() > 2.0 ) {
175 double dy = 0.45*dataRect.height();
176 double y0 = dataRect.y() + 0.5*dataRect.height();
177 pw->setLimits( dataRect.x(), dataRect.right(), y0-dy, y0+dy );
184 case Qt::Key_Underscore:
186 if ( dataRect.height() < 40.0 ) {
187 double dy = 0.55*dataRect.height();
188 double y0 = dataRect.y() + 0.5*dataRect.height();
189 pw->setLimits( dataRect.x(), dataRect.right(), y0-dy, y0+dy );
201 default: { e->ignore();
break; }
205 #include "jmoontool.moc"
A subclass of KSPlanetBase for seven of the major planets in the solar system (Earth and Pluto have t...
Child class of KSPlanetBase; encapsulates information about the Sun.
This is the main window for KStars.
SkyMapComposite * skyComposite()
virtual void findPosition(const KSNumbers *num, const KSPlanetBase *jup, const KSSun *sunptr)
Find the positions of each Moon, relative to Jupiter.
There are several time-dependent values used in position calculations, that are not specific to an ob...
Implements the four largest moons of Jupiter.
virtual SkyObject * findByName(const QString &name)
Search the children of this SkyMapComposite for a SkyObject whose name matches the argument...
KStarsData * data() const
const KStarsDateTime & ut() const