• 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
eqplotwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  eqplotwidget.cpp - description
3  -------------------
4  begin : Thu 16 Mar 2007
5  copyright : (C) 2007 by Jason Harris
6  email : kstars@30doradus.org
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 "eqplotwidget.h"
19 #include <QPainter>
20 #include <KGlobal>
21 #include <KLocale>
22 #include <kdebug.h>
23 #include "kstarsdatetime.h"
24 #include "modcalcvizequinox.h"
25 
26 eqPlotWidget::eqPlotWidget( QWidget *parent )
27  : KPlotWidget( parent )
28 {
29 }
30 
31 //Draw rotated labels and month names on top axis
32 void eqPlotWidget::paintEvent( QPaintEvent *e ) {
33  KPlotWidget::paintEvent(e);
34 
35  QPainter p;
36  p.begin(this);
37 
38  modCalcEquinox *mc = (modCalcEquinox*)(parent()->parent()->parent()->parent());
39  KStarsDateTime dt( QDate(mc->Year->value(), 1, 1), QTime(0,0,0) );
40  long double jd0 = dt.djd(); //save JD on Jan 1st
41 
42  QPointF pSpring = mapToWidget( QPointF( mc->dSpring.djd() - jd0 - 4, -28.0 ) );
43  QPointF pSummer = mapToWidget( QPointF( mc->dSummer.djd() - jd0 - 4, -28.0 ) );
44  QPointF pAutumn = mapToWidget( QPointF( mc->dAutumn.djd() - jd0 - 4, -28.0 ) );
45  QPointF pWinter = mapToWidget( QPointF( mc->dWinter.djd() - jd0 - 4, -28.0 ) );
46 
47  p.setPen( Qt::yellow );
48  QFont f = p.font();
49  f.setPointSize( f.pointSize() - 2 );
50  p.setFont( f );
51 
52  p.save();
53  p.translate( leftPadding() + pSpring.x(), topPadding() + pSpring.y() );
54  p.rotate(-90);
55  p.drawText( 0, 0, i18n("Vernal equinox:") );
56  p.drawText( 0, 14, KGlobal::locale()->formatDateTime( mc->dSpring, KLocale::LongDate ) );
57  p.restore();
58 
59  p.save();
60  p.translate( leftPadding() + pSummer.x(), topPadding() + pSummer.y() );
61  p.rotate(-90);
62  p.drawText( 0, 0, i18n("Summer solstice:") );
63  p.drawText( 0, 14, KGlobal::locale()->formatDateTime( mc->dSummer, KLocale::LongDate ) );
64  p.restore();
65 
66  p.save();
67  p.translate( leftPadding() + pAutumn.x(), topPadding() + pAutumn.y() );
68  p.rotate(-90);
69  p.drawText( 0, 0, i18n("Autumnal equinox:") );
70  p.drawText( 0, 14, KGlobal::locale()->formatDateTime( mc->dAutumn, KLocale::LongDate ) );
71  p.restore();
72 
73  p.save();
74  p.translate( leftPadding() + pWinter.x(), topPadding() + pWinter.y() );
75  p.rotate(-90);
76  p.drawText( 0, 0, i18n("Winter solstice:") );
77  p.drawText( 0, 14, KGlobal::locale()->formatDateTime( mc->dWinter, KLocale::LongDate ) );
78  p.restore();
79 
80  //Draw month labels along top axis
81  p.setPen( Qt::white );
82  p.save();
83  p.translate( leftPadding(), topPadding() );
84  double y = mc->Plot->dataRect().bottom() + 1.5;
85  for ( int i=0; i<12; i++ ) {
86  QPoint c;
87  if (i<11) {
88  c = mc->Plot->mapToWidget( QPointF( 0.5*(mc->dmonth(i)+mc->dmonth(i+1)), y ) ).toPoint();
89  } else {
90  c = mc->Plot->mapToWidget( QPointF( 0.5*(mc->dmonth(i)+mc->Plot->dataRect().right()), y ) ).toPoint();
91  }
92  QRect r( -16, -8, 32, 16 );
93  r.moveCenter( c );
94  p.drawText( r, Qt::AlignCenter, QDate::shortMonthName(i+1) );
95  }
96  p.restore();
97  p.end();
98 }
99 
100 #include "eqplotwidget.moc"
modCalcEquinox::dSpring
KStarsDateTime dSpring
Definition: modcalcvizequinox.h:38
QWidget
eqplotwidget.h
modCalcEquinox::dSummer
KStarsDateTime dSummer
Definition: modcalcvizequinox.h:38
eqPlotWidget::paintEvent
virtual void paintEvent(QPaintEvent *)
Definition: eqplotwidget.cpp:32
modCalcEquinox::dWinter
KStarsDateTime dWinter
Definition: modcalcvizequinox.h:38
NaN::f
const float f
Definition: nan.h:36
modcalcvizequinox.h
KStarsDateTime::djd
long double djd() const
Definition: kstarsdatetime.h:145
modCalcEquinox::dAutumn
KStarsDateTime dAutumn
Definition: modcalcvizequinox.h:38
KPlotWidget
KStarsDateTime
Extension of KDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day...
Definition: kstarsdatetime.h:45
eqPlotWidget::eqPlotWidget
eqPlotWidget(QWidget *parent=0)
Definition: eqplotwidget.cpp:26
modCalcEquinox::dmonth
double dmonth(int imonth)
Definition: modcalcvizequinox.cpp:67
modCalcEquinox
Definition: modcalcvizequinox.h:30
kstarsdatetime.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