• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • plugins
  • render
  • stars
StarsPlugin.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2008 Torsten Rahn <tackat@kde.org>
9 // Copyright 2011-2013 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
10 //
11 
12 #include "StarsPlugin.h"
13 
14 #include "ui_StarsConfigWidget.h"
15 #include <QRectF>
16 #include <QSize>
17 #include <QDateTime>
18 #include <QRegion>
19 #include <QContextMenuEvent>
20 #include <QMenu>
21 #include <QColorDialog>
22 #include <qmath.h>
23 
24 #include "MarbleClock.h"
25 #include "MarbleDebug.h"
26 #include "MarbleDirs.h"
27 #include "MarbleModel.h"
28 #include "MarbleWidget.h"
29 #include "AbstractFloatItem.h"
30 #include "GeoPainter.h"
31 #include "Planet.h"
32 #include "SunLocator.h"
33 #include "ViewportParams.h"
34 
35 #include "src/lib/astro/solarsystem.h"
36 
37 namespace Marble
38 {
39 
40 StarsPlugin::StarsPlugin( const MarbleModel *marbleModel )
41  : RenderPlugin( marbleModel ),
42  m_nameIndex( 0 ),
43  m_configDialog( 0 ),
44  ui_configWidget( 0 ),
45  m_renderStars( true ),
46  m_renderConstellationLines( true ),
47  m_renderConstellationLabels( true ),
48  m_renderDsos( true ),
49  m_renderDsoLabels( true ),
50  m_renderSun( true ),
51  m_renderMoon( true ),
52  m_renderEcliptic( true ),
53  m_renderCelestialEquator( true ),
54  m_renderCelestialPole( true ),
55  m_starsLoaded( false ),
56  m_starPixmapsCreated( false ),
57  m_constellationsLoaded( false ),
58  m_dsosLoaded( false ),
59  m_zoomSunMoon( true ),
60  m_viewSolarSystemLabel( true ),
61  m_magnitudeLimit( 100 ),
62  m_zoomCoefficient( 4 ),
63  m_constellationBrush( Marble::Oxygen::aluminumGray5 ),
64  m_constellationLabelBrush( Marble::Oxygen::aluminumGray5 ),
65  m_dsoLabelBrush( Marble::Oxygen::aluminumGray5 ),
66  m_eclipticBrush( Marble::Oxygen::aluminumGray5 ),
67  m_celestialEquatorBrush( Marble::Oxygen::aluminumGray5 ),
68  m_celestialPoleBrush( Marble::Oxygen::aluminumGray5 ),
69  m_contextMenu(0),
70  m_constellationsAction(0),
71  m_sunMoonAction(0),
72  m_planetsAction(0),
73  m_dsoAction(0),
74  m_doRender( false )
75 {
76  prepareNames();
77 }
78 
79 StarsPlugin::~StarsPlugin()
80 {
81  delete m_contextMenu;
82  delete m_constellationsAction;
83  delete m_sunMoonAction;
84  delete m_planetsAction;
85  delete m_dsoAction;
86 }
87 
88 QStringList StarsPlugin::backendTypes() const
89 {
90  return QStringList( "stars" );
91 }
92 
93 QString StarsPlugin::renderPolicy() const
94 {
95  return QString( "SPECIFIED_ALWAYS" );
96 }
97 
98 QStringList StarsPlugin::renderPosition() const
99 {
100  return QStringList() << "STARS";
101 }
102 
103 RenderPlugin::RenderType StarsPlugin::renderType() const
104 {
105  return RenderPlugin::ThemeRenderType;
106 }
107 
108 QString StarsPlugin::name() const
109 {
110  return tr( "Stars" );
111 }
112 
113 QString StarsPlugin::guiString() const
114 {
115  return tr( "&Stars" );
116 }
117 
118 QString StarsPlugin::nameId() const
119 {
120  return QString( "stars" );
121 }
122 
123 QString StarsPlugin::version() const
124 {
125  return "1.2";
126 }
127 
128 QString StarsPlugin::description() const
129 {
130  return tr( "A plugin that shows the Starry Sky and the Sun." );
131 }
132 
133 QString StarsPlugin::copyrightYears() const
134 {
135  return "2008-2012";
136 }
137 
138 QList<PluginAuthor> StarsPlugin::pluginAuthors() const
139 {
140  return QList<PluginAuthor>()
141  << PluginAuthor( "Torsten Rahn", "tackat@kde.org" )
142  << PluginAuthor( "Rene Kuettner", "rene@bitkanal.net" )
143  << PluginAuthor( "Timothy Lanzi", "trlanzi@gmail.com" );
144 }
145 
146 QIcon StarsPlugin::icon() const
147 {
148  return QIcon(":/icons/stars.png");
149 }
150 
151 void StarsPlugin::initialize()
152 {
153 }
154 
155 bool StarsPlugin::isInitialized() const
156 {
157  return true;
158 }
159 
160 QDialog *StarsPlugin::configDialog()
161 {
162  if (!m_configDialog) {
163  // Initializing configuration dialog
164  m_configDialog = new QDialog;
165  ui_configWidget = new Ui::StarsConfigWidget;
166  ui_configWidget->setupUi( m_configDialog );
167 
168  readSettings();
169 
170  connect( ui_configWidget->m_buttonBox, SIGNAL(accepted()), SLOT(writeSettings()) );
171  connect( ui_configWidget->m_buttonBox, SIGNAL(rejected()), SLOT(readSettings()) );
172 
173  connect( ui_configWidget->m_constellationColorButton, SIGNAL(clicked()), this,
174  SLOT(constellationGetColor()) );
175 
176  connect( ui_configWidget->m_constellationLabelColorButton, SIGNAL(clicked()), this,
177  SLOT(constellationLabelGetColor()) );
178 
179  connect( ui_configWidget->m_dsoLabelColorButton, SIGNAL(clicked()), this,
180  SLOT(dsoLabelGetColor()) );
181 
182  connect( ui_configWidget->m_eclipticColorButton, SIGNAL(clicked()), this,
183  SLOT(eclipticGetColor()) );
184 
185  connect( ui_configWidget->m_celestialEquatorColorButton, SIGNAL(clicked()), this,
186  SLOT(celestialEquatorGetColor()) );
187 
188  connect( ui_configWidget->m_celestialPoleColorButton, SIGNAL(clicked()), this,
189  SLOT(celestialPoleGetColor()) );
190  }
191 
192  return m_configDialog;
193 }
194 
195 QHash<QString, QVariant> StarsPlugin::settings() const
196 {
197  QHash<QString, QVariant> settings = RenderPlugin::settings();
198 
199  settings["nameIndex"] = m_nameIndex;
200  settings["renderStars"] = m_renderStars;
201  settings["renderConstellationLines"] = m_renderConstellationLines;
202  settings["renderConstellationLabels"] = m_renderConstellationLabels;
203  settings["renderDsos"] = m_renderDsos;
204  settings["renderDsoLabels"] = m_renderDsoLabels;
205  settings["renderSun"] = m_renderSun;
206  settings["renderMoon"] = m_renderMoon;
207 
208  QStringList planetState;
209  foreach (const QString &key, m_renderPlanet.keys())
210  planetState.append(key+QChar(':')+QString::number((int)m_renderPlanet[key]));
211  settings["renderPlanet"] = planetState.join(QChar('|'));
212 
213  settings["renderEcliptic"] = m_renderEcliptic;
214  settings["renderCelestialEquator"] = m_renderCelestialEquator;
215  settings["renderCelestialPole"] = m_renderCelestialPole;
216  settings["zoomSunMoon"] = m_zoomSunMoon;
217  settings["viewSolarSystemLabel"] = m_viewSolarSystemLabel;
218  settings["magnitudeLimit"] = m_magnitudeLimit;
219  settings["constellationBrush"] = m_constellationBrush.color().rgb();
220  settings["constellationLabelBrush"] = m_constellationLabelBrush.color().rgb();
221  settings["dsoLabelBrush"] = m_dsoLabelBrush.color().rgb();
222  settings["eclipticBrush"] = m_eclipticBrush.color().rgb();
223  settings["celestialEaquatorBrush"] = m_celestialEquatorBrush.color().rgb();
224  settings["celestialPoleBrush"] = m_celestialPoleBrush.color().rgb();
225 
226  return settings;
227 }
228 
229 void StarsPlugin::setSettings( const QHash<QString, QVariant> &settings )
230 {
231  RenderPlugin::setSettings( settings );
232 
233  m_nameIndex = readSetting<int>( settings, "nameIndex", 0 );
234  m_renderStars = readSetting<bool>( settings, "renderStars", true );
235  m_renderConstellationLines = readSetting<bool>( settings, "renderConstellationLines", true );
236  m_renderConstellationLabels = readSetting<bool>( settings, "renderConstellationLabels", true );
237  m_renderDsos = readSetting<bool>( settings, "renderDsos", true );
238  m_renderDsoLabels = readSetting<bool>( settings, "renderDsoLabels", true);
239  m_renderSun = readSetting<bool>( settings, "renderSun", true );
240  m_renderMoon = readSetting<bool>( settings, "renderMoon", true );
241 
242  m_renderPlanet.clear();
243  const QString renderPlanet = readSetting<QString>( settings, "renderPlanet", "" );
244  const QStringList renderStates = renderPlanet.split(QChar('|'));
245  foreach(const QString state, renderStates) {
246  const QStringList stateList = state.split(QChar(':'));
247  if (stateList.size() == 2)
248  m_renderPlanet[stateList[0]] = (bool)stateList[1].toInt();
249  }
250 
251  m_renderEcliptic = readSetting<bool>( settings, "renderEcliptic", true );
252  m_renderCelestialEquator = readSetting<bool>( settings, "renderCelestialEquator", true );
253  m_renderCelestialPole = readSetting<bool>( settings, "renderCelestialPole", true );
254  m_zoomSunMoon = readSetting<bool>( settings, "zoomSunMoon", true );
255  m_viewSolarSystemLabel = readSetting<bool>( settings, "viewSolarSystemLabel", true );
256  m_magnitudeLimit = readSetting<int>( settings, "magnitudeLimit", 100 );
257  QColor const defaultColor = Marble::Oxygen::aluminumGray5;
258  m_constellationBrush = QColor( readSetting<QRgb>( settings, "constellationBrush", defaultColor.rgb() ) );
259  m_constellationLabelBrush = QColor( readSetting<QRgb>( settings, "constellationLabelBrush", defaultColor.rgb()) );
260  m_dsoLabelBrush = QColor( readSetting<QRgb>( settings, "dsoLabelBrush", defaultColor.rgb() ) );
261  m_eclipticBrush = QColor( readSetting<QRgb>( settings, "eclipticBrush", defaultColor.rgb() ) );
262  m_celestialEquatorBrush = QColor( readSetting<QRgb>( settings, "celestialEquatorBrush", defaultColor.rgb() ) );
263  m_celestialPoleBrush = QColor( readSetting<QRgb>( settings, "celestialPoleBrush", defaultColor.rgb() ) );
264 }
265 
266 QPixmap StarsPlugin::starPixmap(qreal mag, int colorId) const
267 {
268  if ( mag < -1 ) {
269  return m_pixN1Stars.at(colorId);
270  } else if ( mag < 0 ) {
271  return m_pixP0Stars.at(colorId);
272  } else if ( mag < 1 ) {
273  return m_pixP1Stars.at(colorId);
274  } else if ( mag < 2 ) {
275  return m_pixP2Stars.at(colorId);
276  } else if ( mag < 3 ) {
277  return m_pixP3Stars.at(colorId);
278  } else if ( mag < 4 ) {
279  return m_pixP4Stars.at(colorId);
280  } else if ( mag < 5 ) {
281  return m_pixP5Stars.at(colorId);
282  } else if ( mag < 6 ) {
283  return m_pixP6Stars.at(colorId);
284  } else {
285  return m_pixP7Stars.at(colorId);
286  }
287 
288  return QPixmap();
289 }
290 
291 void StarsPlugin::prepareNames()
292 {
293 
294  QFile names( MarbleDirs::path( "stars/names.csv" ) );
295  if ( !names.open( QIODevice::ReadOnly ) ) {
296  return;
297  }
298 
299  QTextStream in( &names );
300  while ( !in.atEnd() ) {
301  QString line = in.readLine();
302  QStringList list = line.split( ';' );
303  if ( list.size() == 3 ) {
304  m_nativeHash[ list.at( 0 ) ] = tr( list.at( 1 ).toUtf8().constData() );
305  m_abbrHash[ list.at( 0 ) ] = list.at( 2 );
306  }
307  }
308  names.close();
309 
310 }
311 
312 QString StarsPlugin::assembledConstellation(const QString &name)
313 {
314  switch (m_nameIndex) {
315  case 0:
316  return name;
317  case 1:
318  return m_nativeHash[name];
319  case 2:
320  return m_abbrHash[name];
321  default:
322  return name;
323  }
324 }
325 
326 void StarsPlugin::readSettings()
327 {
328  if ( !m_configDialog ) {
329  return;
330  }
331 
332  ui_configWidget->constellationNamesComboBox->setCurrentIndex(m_nameIndex);
333 
334  Qt::CheckState const constellationLineState = m_renderConstellationLines ? Qt::Checked : Qt::Unchecked;
335  ui_configWidget->m_viewConstellationLinesCheckbox->setCheckState( constellationLineState );
336 
337  Qt::CheckState const constellationLabelState = m_renderConstellationLabels ? Qt::Checked : Qt::Unchecked;
338  ui_configWidget->m_viewConstellationLabelsCheckbox->setCheckState( constellationLabelState );
339 
340  Qt::CheckState const dsoState = m_renderDsos ? Qt::Checked : Qt::Unchecked;
341  ui_configWidget->m_viewDsosCheckbox->setCheckState( dsoState );
342 
343  Qt::CheckState const dsoLabelState = m_renderDsoLabels ? Qt::Checked : Qt::Unchecked;
344  ui_configWidget->m_viewDsoLabelCheckbox->setCheckState( dsoLabelState );
345 
346  Qt::CheckState const sunState = m_renderSun ? Qt::Checked : Qt::Unchecked;
347  ui_configWidget->m_solarSystemListWidget->item( 0 )->setCheckState( sunState );
348 
349  Qt::CheckState const moonState = m_renderMoon ? Qt::Checked : Qt::Unchecked;
350  ui_configWidget->m_solarSystemListWidget->item( 1 )->setCheckState( moonState );
351 
352  Qt::CheckState const mercuryState = m_renderPlanet["mercury"] ? Qt::Checked : Qt::Unchecked;
353  ui_configWidget->m_solarSystemListWidget->item( 2 )->setCheckState(mercuryState);
354 
355  Qt::CheckState const venusState = m_renderPlanet["venus"] ? Qt::Checked : Qt::Unchecked;
356  ui_configWidget->m_solarSystemListWidget->item( 3 )->setCheckState(venusState);
357 
358  Qt::CheckState const marsState = m_renderPlanet["mars"] ? Qt::Checked : Qt::Unchecked;
359  ui_configWidget->m_solarSystemListWidget->item( 5 )->setCheckState(marsState);
360 
361  Qt::CheckState const jupiterState = m_renderPlanet["jupiter"] ? Qt::Checked : Qt::Unchecked;
362  ui_configWidget->m_solarSystemListWidget->item( 6 )->setCheckState(jupiterState);
363 
364  Qt::CheckState const saturnState = m_renderPlanet["saturn"] ? Qt::Checked : Qt::Unchecked;
365  ui_configWidget->m_solarSystemListWidget->item( 7 )->setCheckState(saturnState);
366 
367  Qt::CheckState const uranusState = m_renderPlanet["uranus"] ? Qt::Checked : Qt::Unchecked;
368  ui_configWidget->m_solarSystemListWidget->item( 8 )->setCheckState(uranusState);
369 
370  Qt::CheckState const neptuneState = m_renderPlanet["neptune"] ? Qt::Checked : Qt::Unchecked;
371  ui_configWidget->m_solarSystemListWidget->item( 9 )->setCheckState(neptuneState);
372 
373  Qt::CheckState const eclipticState = m_renderEcliptic ? Qt::Checked : Qt::Unchecked;
374  ui_configWidget->m_viewEclipticCheckbox->setCheckState( eclipticState );
375 
376  Qt::CheckState const celestialEquatorState = m_renderCelestialEquator ? Qt::Checked : Qt::Unchecked;
377  ui_configWidget->m_viewCelestialEquatorCheckbox->setCheckState( celestialEquatorState );
378 
379  Qt::CheckState const celestialPoleState = m_renderCelestialPole ? Qt::Checked : Qt::Unchecked;
380  ui_configWidget->m_viewCelestialPoleCheckbox->setCheckState( celestialPoleState );
381 
382  Qt::CheckState const zoomSunMoonState = m_zoomSunMoon ? Qt::Checked : Qt::Unchecked;
383  ui_configWidget->m_zoomSunMoonCheckbox->setCheckState( zoomSunMoonState );
384 
385  Qt::CheckState const viewSolarSystemLabelState = m_viewSolarSystemLabel ? Qt::Checked : Qt::Unchecked;
386  ui_configWidget->m_viewSolarSystemLabelCheckbox->setCheckState( viewSolarSystemLabelState );
387 
388  int magState = m_magnitudeLimit;
389  if ( magState < ui_configWidget->m_magnitudeSlider->minimum() ) {
390  magState = ui_configWidget->m_magnitudeSlider->minimum();
391  }
392  else if ( magState > ui_configWidget->m_magnitudeSlider->maximum() ) {
393  magState = ui_configWidget->m_magnitudeSlider->maximum();
394  }
395 
396  ui_configWidget->m_magnitudeSlider->setValue(magState);
397 
398  QPalette constellationPalette;
399  constellationPalette.setColor( QPalette::Button, m_constellationBrush.color() );
400  ui_configWidget->m_constellationColorButton->setPalette( constellationPalette );
401 
402  QPalette constellationLabelPalette;
403  constellationLabelPalette.setColor( QPalette::Button, m_constellationLabelBrush.color() );
404  ui_configWidget->m_constellationLabelColorButton->setPalette( constellationLabelPalette );
405 
406  QPalette dsoLabelPalette;
407  dsoLabelPalette.setColor( QPalette::Button, m_dsoLabelBrush.color() );
408  ui_configWidget->m_dsoLabelColorButton->setPalette( dsoLabelPalette );
409 
410  QPalette eclipticPalette;
411  eclipticPalette.setColor( QPalette::Button, m_eclipticBrush.color() );
412  ui_configWidget->m_eclipticColorButton->setPalette( eclipticPalette );
413 
414  QPalette celestialEquatorPalette;
415  celestialEquatorPalette.setColor( QPalette::Button, m_celestialEquatorBrush.color() );
416  ui_configWidget->m_celestialEquatorColorButton->setPalette( celestialEquatorPalette );
417 
418  QPalette celestialPolePalette;
419  celestialPolePalette.setColor( QPalette::Button, m_celestialPoleBrush.color() );
420  ui_configWidget->m_celestialPoleColorButton->setPalette( celestialPolePalette );
421 
422 
423 }
424 
425 void StarsPlugin::writeSettings()
426 {
427  m_nameIndex = ui_configWidget->constellationNamesComboBox->currentIndex();
428  m_renderConstellationLines = ui_configWidget->m_viewConstellationLinesCheckbox->checkState() == Qt::Checked;
429  m_renderConstellationLabels = ui_configWidget->m_viewConstellationLabelsCheckbox->checkState() == Qt::Checked;
430  m_renderDsos = ui_configWidget->m_viewDsosCheckbox->checkState() == Qt::Checked;
431  m_renderDsoLabels = ui_configWidget->m_viewDsoLabelCheckbox->checkState() == Qt::Checked;
432  m_renderSun = ui_configWidget->m_solarSystemListWidget->item( 0 )->checkState() == Qt::Checked;
433  m_renderMoon = ui_configWidget->m_solarSystemListWidget->item( 1 )->checkState() == Qt::Checked;
434 
435  m_renderPlanet["mercury"] = ui_configWidget->m_solarSystemListWidget->item( 2 )->checkState()
436  == Qt::Checked;
437  m_renderPlanet["venus"] = ui_configWidget->m_solarSystemListWidget->item( 3 )->checkState()
438  == Qt::Checked;
439  m_renderPlanet["mars"] = ui_configWidget->m_solarSystemListWidget->item( 5 )->checkState()
440  == Qt::Checked;
441  m_renderPlanet["jupiter"] = ui_configWidget->m_solarSystemListWidget->item( 6 )->checkState()
442  == Qt::Checked;
443  m_renderPlanet["saturn"] = ui_configWidget->m_solarSystemListWidget->item( 7 )->checkState()
444  == Qt::Checked;
445  m_renderPlanet["uranus"] = ui_configWidget->m_solarSystemListWidget->item( 8 )->checkState()
446  == Qt::Checked;
447  m_renderPlanet["neptune"] = ui_configWidget->m_solarSystemListWidget->item( 9 )->checkState()
448  == Qt::Checked;
449 
450  m_renderEcliptic = ui_configWidget->m_viewEclipticCheckbox->checkState() == Qt::Checked;
451  m_renderCelestialEquator = ui_configWidget->m_viewCelestialEquatorCheckbox->checkState() == Qt::Checked;
452  m_renderCelestialPole = ui_configWidget->m_viewCelestialPoleCheckbox->checkState() == Qt::Checked;
453  m_zoomSunMoon = ui_configWidget->m_zoomSunMoonCheckbox->checkState() == Qt::Checked;
454  m_viewSolarSystemLabel = ui_configWidget->m_viewSolarSystemLabelCheckbox->checkState() == Qt::Checked;
455  m_magnitudeLimit = ui_configWidget->m_magnitudeSlider->value();
456  m_constellationBrush = QBrush( ui_configWidget->m_constellationColorButton->palette().color( QPalette::Button) );
457  m_constellationLabelBrush = QBrush( ui_configWidget->m_constellationLabelColorButton->palette().color( QPalette::Button) );
458  m_dsoLabelBrush = QBrush( ui_configWidget->m_dsoLabelColorButton->palette().color( QPalette::Button) );
459  m_eclipticBrush = QBrush( ui_configWidget->m_eclipticColorButton->palette().color( QPalette::Button) );
460  m_celestialEquatorBrush = QBrush( ui_configWidget->m_celestialEquatorColorButton->palette().color( QPalette::Button) );
461  m_celestialPoleBrush = QBrush( ui_configWidget->m_celestialPoleColorButton->palette().color( QPalette::Button) );
462  emit settingsChanged( nameId() );
463 }
464 
465 void StarsPlugin::constellationGetColor()
466 {
467  const QColor c = QColorDialog::getColor( m_constellationBrush.color(), 0, tr("Please choose the color for the constellation lines.") );
468 
469  if ( c.isValid() ) {
470  QPalette palette = ui_configWidget->m_constellationColorButton->palette();
471  palette.setColor( QPalette::Button, c );
472  ui_configWidget->m_constellationColorButton->setPalette( palette );
473  }
474 }
475 
476 void StarsPlugin::constellationLabelGetColor()
477 {
478  const QColor c = QColorDialog::getColor( m_constellationLabelBrush.color(), 0, tr("Please choose the color for the constellation labels.") );
479 
480  if ( c.isValid() ) {
481  QPalette palette = ui_configWidget->m_constellationLabelColorButton->palette();
482  palette.setColor( QPalette::Button, c );
483  ui_configWidget->m_constellationLabelColorButton->setPalette( palette );
484  }
485 }
486 
487 void StarsPlugin::dsoLabelGetColor()
488 {
489  const QColor c = QColorDialog::getColor( m_dsoLabelBrush.color(), 0, tr("Please choose the color for the dso labels.") );
490 
491  if ( c.isValid() ) {
492  QPalette palette = ui_configWidget->m_dsoLabelColorButton->palette();
493  palette.setColor( QPalette::Button, c );
494  ui_configWidget->m_dsoLabelColorButton->setPalette( palette );
495  }
496 }
497 
498 void StarsPlugin::eclipticGetColor()
499 {
500  const QColor c = QColorDialog::getColor( m_eclipticBrush.color(), 0, tr("Please choose the color for the ecliptic.") );
501 
502  if ( c.isValid() ) {
503  QPalette palette = ui_configWidget->m_eclipticColorButton->palette();
504  palette.setColor( QPalette::Button, c );
505  ui_configWidget->m_eclipticColorButton->setPalette( palette );
506  }
507 }
508 
509 void StarsPlugin::celestialEquatorGetColor()
510 {
511  const QColor c = QColorDialog::getColor( m_celestialEquatorBrush.color(), 0, tr("Please choose the color for the celestial equator.") );
512 
513  if ( c.isValid() ) {
514  QPalette palette = ui_configWidget->m_celestialEquatorColorButton->palette();
515  palette.setColor( QPalette::Button, c );
516  ui_configWidget->m_celestialEquatorColorButton->setPalette( palette );
517  }
518 }
519 
520 void StarsPlugin::celestialPoleGetColor()
521 {
522  const QColor c = QColorDialog::getColor( m_celestialPoleBrush.color(), 0, tr("Please choose the color for the celestial equator.") );
523 
524  if ( c.isValid() ) {
525  QPalette palette = ui_configWidget->m_celestialPoleColorButton->palette();
526  palette.setColor( QPalette::Button, c );
527  ui_configWidget->m_celestialPoleColorButton->setPalette( palette );
528  }
529 }
530 
531 void StarsPlugin::loadStars()
532 {
533  //mDebug() << Q_FUNC_INFO;
534  // Load star data
535  m_stars.clear();
536 
537  QFile starFile( MarbleDirs::path( "stars/stars.dat" ) );
538  starFile.open( QIODevice::ReadOnly );
539  QDataStream in( &starFile );
540 
541  // Read and check the header
542  quint32 magic;
543  in >> magic;
544  if ( magic != 0x73746172 ) {
545  return;
546  }
547 
548  // Read the version
549  qint32 version;
550  in >> version;
551  if ( version > 004 ) {
552  mDebug() << "stars.dat: file too new.";
553  return;
554  }
555 
556  if ( version == 003 ) {
557  mDebug() << "stars.dat: file version no longer supported.";
558  return;
559  }
560 
561  int maxid = 0;
562  int id = 0;
563  int starIndex = 0;
564  double ra;
565  double de;
566  double mag;
567  int colorId = 2;
568 
569  mDebug() << "Star Catalog Version " << version;
570 
571  while ( !in.atEnd() ) {
572  if ( version >= 2 ) {
573  in >> id;
574  }
575  if ( id > maxid ) {
576  maxid = id;
577  }
578  in >> ra;
579  in >> de;
580  in >> mag;
581 
582  if ( version >= 4 ) {
583  in >> colorId;
584  }
585 
586  StarPoint star( id, ( qreal )( ra ), ( qreal )( de ), ( qreal )( mag ), colorId );
587  // Create entry in stars database
588  m_stars << star;
589  // Create key,value pair in idHash table to map from star id to
590  // index in star database vector
591  m_idHash[id] = starIndex;
592  // Increment Index for use in hash
593  ++starIndex;
594  }
595 
596  // load the Sun pixmap
597  // TODO: adjust pixmap size according to distance
598  m_pixmapSun.load( MarbleDirs::path( "svg/sun.png" ) );
599  m_pixmapMoon.load( MarbleDirs::path( "svg/moon.png" ) );
600 
601  m_starsLoaded = true;
602 }
603 
604 void StarsPlugin::createStarPixmaps()
605 {
606  // Load star pixmaps
607  QVector<QPixmap> pixBigStars;
608  pixBigStars.clear();
609  pixBigStars.append(QPixmap(MarbleDirs::path("bitmaps/stars/star_0_blue.png")));
610  pixBigStars.append(QPixmap(MarbleDirs::path("bitmaps/stars/star_0_bluewhite.png")));
611  pixBigStars.append(QPixmap(MarbleDirs::path("bitmaps/stars/star_0_white.png")));
612  pixBigStars.append(QPixmap(MarbleDirs::path("bitmaps/stars/star_0_yellow.png")));
613  pixBigStars.append(QPixmap(MarbleDirs::path("bitmaps/stars/star_0_orange.png")));
614  pixBigStars.append(QPixmap(MarbleDirs::path("bitmaps/stars/star_0_red.png")));
615  pixBigStars.append(QPixmap(MarbleDirs::path("bitmaps/stars/star_0_garnetred.png")));
616 
617  QVector<QPixmap> pixSmallStars;
618  pixSmallStars.clear();
619  pixSmallStars.append(QPixmap(MarbleDirs::path("bitmaps/stars/star_3_blue.png")));
620  pixSmallStars.append(QPixmap(MarbleDirs::path("bitmaps/stars/star_3_bluewhite.png")));
621  pixSmallStars.append(QPixmap(MarbleDirs::path("bitmaps/stars/star_3_white.png")));
622  pixSmallStars.append(QPixmap(MarbleDirs::path("bitmaps/stars/star_3_yellow.png")));
623  pixSmallStars.append(QPixmap(MarbleDirs::path("bitmaps/stars/star_3_orange.png")));
624  pixSmallStars.append(QPixmap(MarbleDirs::path("bitmaps/stars/star_3_red.png")));
625  pixSmallStars.append(QPixmap(MarbleDirs::path("bitmaps/stars/star_3_garnetred.png")));
626 
627 
628  // Pre-Scale Star Pixmaps
629  m_pixN1Stars.clear();
630  for ( int p=0; p < pixBigStars.size(); ++p) {
631  int width = 1.0*pixBigStars.at(p).width();
632  m_pixN1Stars.append(pixBigStars.at(p).scaledToWidth(width,Qt::SmoothTransformation));
633  }
634 
635  m_pixP0Stars.clear();
636  for ( int p=0; p < pixBigStars.size(); ++p) {
637  int width = 0.90*pixBigStars.at(p).width();
638  m_pixP0Stars.append(pixBigStars.at(p).scaledToWidth(width,Qt::SmoothTransformation));
639  }
640 
641  m_pixP1Stars.clear();
642  for ( int p=0; p < pixBigStars.size(); ++p) {
643  int width = 0.80*pixBigStars.at(p).width();
644  m_pixP1Stars.append(pixBigStars.at(p).scaledToWidth(width,Qt::SmoothTransformation));
645  }
646 
647  m_pixP2Stars.clear();
648  for ( int p=0; p < pixBigStars.size(); ++p) {
649  int width = 0.70*pixBigStars.at(p).width();
650  m_pixP2Stars.append(pixBigStars.at(p).scaledToWidth(width,Qt::SmoothTransformation));
651  }
652 
653  m_pixP3Stars.clear();
654  for ( int p=0; p < pixSmallStars.size(); ++p) {
655  int width = 14;
656  m_pixP3Stars.append(pixSmallStars.at(p).scaledToWidth(width,Qt::SmoothTransformation));
657  }
658 
659  m_pixP4Stars.clear();
660  for ( int p=0; p < pixSmallStars.size(); ++p) {
661  int width = 10;
662  m_pixP4Stars.append(pixSmallStars.at(p).scaledToWidth(width,Qt::SmoothTransformation));
663  }
664 
665  m_pixP5Stars.clear();
666  for ( int p=0; p < pixSmallStars.size(); ++p) {
667  int width = 6;
668  m_pixP5Stars.append(pixSmallStars.at(p).scaledToWidth(width,Qt::SmoothTransformation));
669  }
670 
671  m_pixP6Stars.clear();
672  for ( int p=0; p < pixSmallStars.size(); ++p) {
673  int width = 4;
674  m_pixP6Stars.append(pixSmallStars.at(p).scaledToWidth(width,Qt::SmoothTransformation));
675  }
676 
677  m_pixP7Stars.clear();
678  for ( int p=0; p < pixSmallStars.size(); ++p) {
679  int width = 1;
680  m_pixP7Stars.append(pixSmallStars.at(p).scaledToWidth(width,Qt::SmoothTransformation));
681  }
682 
683  m_starPixmapsCreated = true;
684 }
685 
686 void StarsPlugin::loadConstellations()
687 {
688  // Load star data
689  m_constellations.clear();
690 
691  QFile constellationFile( MarbleDirs::path( "stars/constellations.dat" ) );
692  constellationFile.open( QIODevice::ReadOnly );
693  QTextStream in( &constellationFile );
694  QString line;
695  QString indexList;
696 
697  while ( !in.atEnd() ) {
698  line = in.readLine();
699 
700  // Check for null line at end of file
701  if ( line.isNull() ) {
702  continue;
703  }
704 
705  // Ignore Comment lines in header and
706  // between constellation entries
707  if ( line.startsWith( '#' ) ) {
708  continue;
709  }
710 
711  indexList = in.readLine();
712 
713  // Make sure we have a valid label and indexList
714  if ( indexList.isNull() ) {
715  break;
716  }
717 
718  Constellation constellation( this, line, indexList );
719  m_constellations << constellation;
720 
721  }
722  m_constellationsLoaded = true;
723 
724 }
725 
726 void StarsPlugin::loadDsos()
727 {
728  // Load star data
729  m_dsos.clear();
730 
731  QFile dsoFile( MarbleDirs::path( "stars/dso.dat" ) );
732  dsoFile.open( QIODevice::ReadOnly );
733  QTextStream in( &dsoFile );
734  QString line;
735 
736  while ( !in.atEnd() ) {
737  line = in.readLine();
738 
739  // Check for null line at end of file
740  if ( line.isNull() ) {
741  continue;
742  }
743 
744  // Ignore Comment lines in header and
745  // between dso entries
746  if ( line.startsWith( '#' ) ) {
747  continue;
748  }
749 
750  QStringList entries = line.split( QLatin1Char( ',' ) );
751 
752  QString id = entries.at( 0 );
753 
754  double raH = entries.at( 1 ).toDouble();
755  double raM = entries.at( 2 ).toDouble();
756  double raS = entries.at( 3 ).toDouble();
757  double decD = entries.at( 4 ).toDouble();
758  double decM = entries.at( 5 ).toDouble();
759  double decS = entries.at( 6 ).toDouble();
760 
761  double raRad = ( raH+raM/60.0+raS/3600.0 )*15.0*M_PI/180.0;
762  double decRad;
763 
764  if ( decD >= 0.0 ) {
765  decRad = ( decD+decM/60.0+decS/3600.0 )*M_PI/180.0;
766  }
767  else {
768  decRad = ( decD-decM/60.0-decS/3600.0 )*M_PI/180.0;
769  }
770 
771  DsoPoint dso( id, ( qreal )( raRad ), ( qreal )( decRad ) );
772  // Create entry in stars database
773  m_dsos << dso;
774  }
775 
776  m_dsoImage.load( MarbleDirs::path( "stars/deepsky.png" ) );
777  m_dsosLoaded = true;
778 }
779 
780 bool StarsPlugin::render( GeoPainter *painter, ViewportParams *viewport,
781  const QString& renderPos, GeoSceneLayer * layer )
782 {
783  Q_UNUSED( renderPos )
784  Q_UNUSED( layer )
785 
786  QString planetId = marbleModel()->planetId();
787  const bool doRender = !viewport->mapCoversViewport() &&
788  viewport->projection() == Spherical &&
789  planetId == "earth"; // So far displaying stars is only supported on earth.
790 
791  if ( doRender != m_doRender ) {
792  if ( doRender ) {
793  connect( marbleModel()->clock(), SIGNAL(timeChanged()),
794  this, SLOT(requestRepaint()) );
795  } else {
796  disconnect( marbleModel()->clock(), SIGNAL(timeChanged()),
797  this, SLOT(requestRepaint()) );
798  }
799 
800  m_doRender = doRender;
801  }
802 
803  painter->save();
804 
805  SolarSystem sys;
806  QDateTime dateTime = marbleModel()->clock()->dateTime();
807  sys.setCurrentMJD(
808  dateTime.date().year(), dateTime.date().month(), dateTime.date().day(),
809  dateTime.time().hour(), dateTime.time().minute(),
810  (double)dateTime.time().second());
811  QString const pname = planetId.at(0).toUpper() + planetId.right(planetId.size() - 1);
812  QByteArray const name = pname.toLatin1();
813  sys.setCentralBody( name.data() );
814 
815  Vec3 skyVector = sys.getPlanetocentric (0.0, 0.0);
816  qreal skyRotationAngle = -atan2(skyVector[1], skyVector[0]);
817 
818  const qreal centerLon = viewport->centerLongitude();
819  const qreal centerLat = viewport->centerLatitude();
820 
821  const qreal skyRadius = 0.6 * sqrt( ( qreal )viewport->width() * viewport->width() + viewport->height() * viewport->height() );
822 
823  if ( doRender ) {
824  if (!m_starPixmapsCreated) {
825  createStarPixmaps();
826  m_starPixmapsCreated = true;
827  }
828 
829  // Delayed initialization:
830  // Load the star database only if the sky is actually being painted...
831  if ( !m_starsLoaded ) {
832  loadStars();
833  m_starsLoaded = true;
834  }
835 
836  if ( !m_constellationsLoaded ) {
837  loadConstellations();
838  m_constellationsLoaded = true;
839  }
840 
841  if ( !m_dsosLoaded ) {
842  loadDsos();
843  m_dsosLoaded = true;
844  }
845 
846  const qreal earthRadius = viewport->radius();
847 
848  // List of Pens used to draw the sky
849  QPen polesPen( m_celestialPoleBrush, 2, Qt::SolidLine );
850  QPen constellationPenSolid( m_constellationBrush, 1, Qt::SolidLine );
851  QPen constellationPenDash( m_constellationBrush, 1, Qt::DashLine );
852  QPen constellationLabelPen( m_constellationLabelBrush, 1, Qt::SolidLine );
853  QPen eclipticPen( m_eclipticBrush, 1, Qt::DotLine );
854  QPen equatorPen( m_celestialEquatorBrush, 1, Qt::DotLine );
855  QPen dsoLabelPen (m_dsoLabelBrush, 1, Qt::SolidLine);
856 
857 
858  const Quaternion skyAxis = Quaternion::fromEuler( -centerLat , centerLon + skyRotationAngle, 0.0 );
859  matrix skyAxisMatrix;
860  skyAxis.inverse().toMatrix( skyAxisMatrix );
861 
862  if ( m_renderCelestialPole ) {
863 
864  polesPen.setWidth( 2 );
865  painter->setPen( polesPen );
866 
867  Quaternion qpos1;
868  qpos1 = Quaternion::fromSpherical( 0, 90 * DEG2RAD );
869  qpos1.rotateAroundAxis( skyAxisMatrix );
870 
871  if ( qpos1.v[Q_Z] < 0 ) {
872  const int x1 = ( int )( viewport->width() / 2 + skyRadius * qpos1.v[Q_X] );
873  const int y1 = ( int )( viewport->height() / 2 - skyRadius * qpos1.v[Q_Y] );
874  painter->drawLine( x1, y1, x1+10, y1 );
875  painter->drawLine( x1+5, y1-5, x1+5, y1+5 );
876  painter->drawText( x1+8, y1+12, "NP" );
877  }
878 
879  Quaternion qpos2;
880  qpos2 = Quaternion::fromSpherical( 0, -90 * DEG2RAD );
881  qpos2.rotateAroundAxis( skyAxisMatrix );
882  if ( qpos2.v[Q_Z] < 0 ) {
883  const int x1 = ( int )( viewport->width() / 2 + skyRadius * qpos2.v[Q_X] );
884  const int y1 = ( int )( viewport->height() / 2 - skyRadius * qpos2.v[Q_Y] );
885  painter->drawLine( x1, y1, x1+10, y1 );
886  painter->drawLine( x1+5, y1-5, x1+5, y1+5 );
887  painter->drawText( x1+8, y1+12, "SP" );
888  }
889  }
890 
891  if( m_renderEcliptic ) {
892  const Quaternion eclipticAxis = Quaternion::fromEuler( 0.0, 0.0, -marbleModel()->planet()->epsilon() );
893  matrix eclipticAxisMatrix;
894  (eclipticAxis * skyAxis).inverse().toMatrix( eclipticAxisMatrix );
895 
896  painter->setPen(eclipticPen);
897 
898  int previousX = -1;
899  int previousY = -1;
900  for ( int i = 0; i <= 36; ++i) {
901  Quaternion qpos;
902  qpos = Quaternion::fromSpherical( i * 10 * DEG2RAD, 0 );
903  qpos.rotateAroundAxis( eclipticAxisMatrix );
904 
905  int x = ( int )( viewport->width() / 2 + skyRadius * qpos.v[Q_X] );
906  int y = ( int )( viewport->height() / 2 - skyRadius * qpos.v[Q_Y] );
907 
908  if ( qpos.v[Q_Z] < 0 && previousX >= 0 ) painter->drawLine(previousX, previousY, x, y);
909 
910  previousX = x;
911  previousY = y;
912  }
913  }
914 
915  if( m_renderCelestialEquator ) {
916  painter->setPen(equatorPen);
917 
918  int previousX = -1;
919  int previousY = -1;
920  for ( int i = 0; i <= 36; ++i) {
921  Quaternion qpos;
922  qpos = Quaternion::fromSpherical( i * 10 * DEG2RAD, 0 );
923  qpos.rotateAroundAxis( skyAxisMatrix );
924 
925  int x = ( int )( viewport->width() / 2 + skyRadius * qpos.v[Q_X] );
926  int y = ( int )( viewport->height() / 2 - skyRadius * qpos.v[Q_Y] );
927 
928  if ( qpos.v[Q_Z] < 0 && previousX > 0 ) painter->drawLine(previousX, previousY, x, y);
929 
930  previousX = x;
931  previousY = y;
932  }
933  }
934 
935  if ( m_renderDsos ) {
936  painter->setPen(dsoLabelPen);
937  // Render Deep Space Objects
938  for ( int d = 0; d < m_dsos.size(); ++d ) {
939  Quaternion qpos = m_dsos.at( d ).quaternion();
940  qpos.rotateAroundAxis( skyAxisMatrix );
941 
942  if ( qpos.v[Q_Z] > 0 ) {
943  continue;
944  }
945 
946  qreal earthCenteredX = qpos.v[Q_X] * skyRadius;
947  qreal earthCenteredY = qpos.v[Q_Y] * skyRadius;
948 
949  // Don't draw high placemarks (e.g. satellites) that aren't visible.
950  if ( qpos.v[Q_Z] < 0
951  && ( ( earthCenteredX * earthCenteredX
952  + earthCenteredY * earthCenteredY )
953  < earthRadius * earthRadius ) ) {
954  continue;
955  }
956 
957  // Let (x, y) be the position on the screen of the placemark..
958  const int x = ( int )( viewport->width() / 2 + skyRadius * qpos.v[Q_X] );
959  const int y = ( int )( viewport->height() / 2 - skyRadius * qpos.v[Q_Y] );
960 
961  // Skip placemarks that are outside the screen area
962  if ( x < 0 || x >= viewport->width() ||
963  y < 0 || y >= viewport->height() ) {
964  continue;
965  }
966 
967  // Hard Code DSO Size for now
968  qreal size = 20;
969 
970  // Center Image on x,y location
971  painter->drawImage( QRectF( x-size/2, y-size/2, size, size ),m_dsoImage );
972  if (m_renderDsoLabels) {
973  painter->drawText( x+8, y+12, m_dsos.at( d ).id() );
974  }
975  }
976  }
977 
978  if ( m_renderConstellationLines || m_renderConstellationLabels )
979  {
980  // Render Constellations
981  for ( int c = 0; c < m_constellations.size(); ++c ) {
982  int xMean = 0;
983  int yMean = 0;
984  int endptCount = 0;
985  painter->setPen( constellationPenSolid );
986 
987  for ( int s = 0; s < ( m_constellations.at( c ).size() - 1 ); ++s ) {
988  int starId1 = m_constellations.at( c ).at( s );
989  int starId2 = m_constellations.at( c ).at( s + 1 );
990 
991  if ( starId1 == -1 || starId2 == -1 ) {
992  // starId == -1 means we don't draw this segment
993  continue;
994  } else if ( starId1 == -2 || starId2 == -2 ) {
995  painter->setPen( constellationPenDash );
996  } else if ( starId1 == -3 || starId2 == -3 ) {
997  painter->setPen( constellationPenSolid );
998  }
999 
1000  int idx1 = m_idHash.value( starId1,-1 );
1001  int idx2 = m_idHash.value( starId2,-1 );
1002 
1003 
1004  if ( idx1 < 0 ) {
1005  mDebug() << "unknown star, "
1006  << starId1 << ", in constellation "
1007  << m_constellations.at( c ).name();
1008  continue;
1009  }
1010 
1011  if ( idx2 < 0 ) {
1012  mDebug() << "unknown star, "
1013  << starId1 << ", in constellation "
1014  << m_constellations.at( c ).name();
1015  continue;
1016  }
1017  // Fetch quaternion from star s in constellation c
1018  Quaternion q1 = m_stars.at( idx1 ).quaternion();
1019  // Fetch quaternion from star s+1 in constellation c
1020  Quaternion q2 = m_stars.at( idx2 ).quaternion();
1021 
1022  q1.rotateAroundAxis( skyAxisMatrix );
1023  q2.rotateAroundAxis( skyAxisMatrix );
1024 
1025  if ( q1.v[Q_Z] > 0 || q2.v[Q_Z] > 0 ) {
1026  continue;
1027  }
1028 
1029 
1030  // Let (x, y) be the position on the screen of the placemark..
1031  int x1 = ( int )( viewport->width() / 2 + skyRadius * q1.v[Q_X] );
1032  int y1 = ( int )( viewport->height() / 2 - skyRadius * q1.v[Q_Y] );
1033  int x2 = ( int )( viewport->width() / 2 + skyRadius * q2.v[Q_X] );
1034  int y2 = ( int )( viewport->height() / 2 - skyRadius * q2.v[Q_Y] );
1035 
1036 
1037  xMean = xMean + x1 + x2;
1038  yMean = yMean + y1 + y2;
1039  endptCount = endptCount + 2;
1040 
1041  if ( m_renderConstellationLines ) {
1042  painter->drawLine( x1, y1, x2, y2 );
1043  }
1044 
1045  }
1046 
1047  // Skip constellation labels that are outside the screen area
1048  if ( endptCount > 0 ) {
1049  xMean = xMean / endptCount;
1050  yMean = yMean / endptCount;
1051  }
1052 
1053  if ( endptCount < 1 || xMean < 0 || xMean >= viewport->width()
1054  || yMean < 0 || yMean >= viewport->height() )
1055  continue;
1056 
1057  painter->setPen( constellationLabelPen );
1058  if ( m_renderConstellationLabels ) {
1059  painter->drawText( xMean, yMean, m_constellations.at( c ).name() );
1060  }
1061 
1062  }
1063  }
1064 
1065  // Render Stars
1066 
1067  for ( int s = 0; s < m_stars.size(); ++s ) {
1068  Quaternion qpos = m_stars.at(s).quaternion();
1069 
1070  qpos.rotateAroundAxis( skyAxisMatrix );
1071 
1072  if ( qpos.v[Q_Z] > 0 ) {
1073  continue;
1074  }
1075 
1076  qreal earthCenteredX = qpos.v[Q_X] * skyRadius;
1077  qreal earthCenteredY = qpos.v[Q_Y] * skyRadius;
1078 
1079  // Don't draw high placemarks (e.g. satellites) that aren't visible.
1080  if ( qpos.v[Q_Z] < 0
1081  && ( ( earthCenteredX * earthCenteredX
1082  + earthCenteredY * earthCenteredY )
1083  < earthRadius * earthRadius ) ) {
1084  continue;
1085  }
1086 
1087  // Let (x, y) be the position on the screen of the placemark..
1088  const int x = ( int )( viewport->width() / 2 + skyRadius * qpos.v[Q_X] );
1089  const int y = ( int )( viewport->height() / 2 - skyRadius * qpos.v[Q_Y] );
1090 
1091  // Skip placemarks that are outside the screen area
1092  if ( x < 0 || x >= viewport->width()
1093  || y < 0 || y >= viewport->height() )
1094  continue;
1095 
1096  // Show star if it is brighter than magnitude threshold
1097  if ( m_stars.at(s).magnitude() < m_magnitudeLimit ) {
1098 
1099  // colorId is used to select which pixmap in vector to display
1100  int colorId = m_stars.at(s).colorId();
1101  QPixmap s_pixmap = starPixmap(m_stars.at(s).magnitude(), colorId);
1102  int sizeX = s_pixmap.width();
1103  int sizeY = s_pixmap.height();
1104  painter->drawPixmap( x-sizeX/2, y-sizeY/2 ,s_pixmap );
1105  }
1106  }
1107 
1108  if ( m_renderSun ) {
1109  // sun
1110  double ra = 0.0;
1111  double decl = 0.0;
1112  sys.getSun( ra, decl );
1113  ra = 15.0 * sys.DmsDegF( ra );
1114  decl = sys.DmsDegF( decl );
1115 
1116  Quaternion qpos = Quaternion::fromSpherical( ra * DEG2RAD, decl * DEG2RAD );
1117  qpos.rotateAroundAxis( skyAxisMatrix );
1118 
1119  if ( qpos.v[Q_Z] <= 0 ) {
1120  QPixmap glow(MarbleDirs::path( "svg/glow.png" ));
1121  qreal deltaX = glow.width() / 2.;
1122  qreal deltaY = glow.height() / 2.;
1123  int x = (int)(viewport->width() / 2 + skyRadius * qpos.v[Q_X]);
1124  int y = (int)(viewport->height() / 2 - skyRadius * qpos.v[Q_Y]);
1125 
1126  bool glowDrawn = false;
1127  if (!(x < -glow.width() || x >= viewport->width() ||
1128  y < -glow.height() || y >= viewport->height())) {
1129  painter->drawPixmap( x - deltaX, y - deltaY, glow );
1130  glowDrawn = true;
1131  }
1132 
1133  if (glowDrawn) {
1134  double diameter = 0.0, mag = 0.0;
1135  sys.getPhysSun(diameter, mag);
1136  const int coefficient = m_zoomSunMoon ? m_zoomCoefficient : 1;
1137  const qreal size = skyRadius * qSin(diameter) * coefficient;
1138  const qreal factor = size/m_pixmapSun.width();
1139  QPixmap sun = m_pixmapSun.transformed(QTransform().scale(factor, factor),
1140  Qt::SmoothTransformation);
1141  deltaX = sun.width() / 2.;
1142  deltaY = sun.height() / 2.;
1143  x = (int)(viewport->width() / 2 + skyRadius * qpos.v[Q_X]);
1144  y = (int)(viewport->height() / 2 - skyRadius * qpos.v[Q_Y]);
1145 
1146  painter->drawPixmap( x - deltaX, y - deltaY, sun );
1147  }
1148 
1149  // It's labels' time!
1150  if (m_viewSolarSystemLabel)
1151  painter->drawText(x+deltaX*1.5, y+deltaY*1.5, tr("Sun"));
1152  }
1153  }
1154 
1155  if ( m_renderMoon && marbleModel()->planetId() == "earth" ) {
1156  // moon
1157  double ra=0.0;
1158  double decl=0.0;
1159  sys.getMoon(ra, decl);
1160  ra = 15.0 * sys.DmsDegF(ra);
1161  decl = sys.DmsDegF(decl);
1162 
1163  Quaternion qpos = Quaternion::fromSpherical( ra * DEG2RAD,
1164  decl * DEG2RAD );
1165  qpos.rotateAroundAxis( skyAxisMatrix );
1166 
1167  if ( qpos.v[Q_Z] <= 0 ) {
1168  // If zoom Sun and Moon is enabled size is multiplied by zoomCoefficient.
1169  const int coefficient = m_zoomSunMoon ? m_zoomCoefficient : 1;
1170 
1171  QPixmap moon = m_pixmapMoon.copy();
1172 
1173  const qreal size = skyRadius * qSin(sys.getDiamMoon()) * coefficient;
1174  qreal deltaX = size / 2.;
1175  qreal deltaY = size / 2.;
1176  const int x = (int)(viewport->width() / 2 + skyRadius * qpos.v[Q_X]);
1177  const int y = (int)(viewport->height() / 2 - skyRadius * qpos.v[Q_Y]);
1178 
1179 
1180  if (!(x < -size || x >= viewport->width() ||
1181  y < -size || y >= viewport->height())) {
1182  // Moon phases
1183  double phase = 0.0, ildisk = 0.0, amag = 0.0;
1184  sys.getLunarPhase(phase, ildisk, amag);
1185 
1186  QPainterPath path;
1187 
1188  QRectF fullMoonRect = moon.rect();
1189  if (ildisk < 0.05) {
1190  // small enough, so it's not visible
1191  path.addEllipse(fullMoonRect);
1192  } else if (ildisk < 0.95) { // makes sense to do smth
1193  QRectF halfEllipseRect;
1194  qreal ellipseWidth = 2 * qAbs(ildisk-0.5) * moon.width();
1195  halfEllipseRect.setX((fullMoonRect.width() - ellipseWidth) * 0.5);
1196  halfEllipseRect.setWidth(ellipseWidth);
1197  halfEllipseRect.setHeight(moon.height());
1198 
1199  if (phase < 0.5) {
1200  if (ildisk < 0.5) {
1201  path.moveTo(fullMoonRect.width()/2, moon.height());
1202  path.arcTo(fullMoonRect, -90, -180);
1203  path.arcTo(halfEllipseRect, 90, -180);
1204  } else {
1205  path.moveTo(fullMoonRect.width()/2, 0);
1206  path.arcTo(fullMoonRect, 90, 180);
1207  path.arcTo(halfEllipseRect, -90, -180);
1208  }
1209  } else {
1210  if (ildisk < 0.5) {
1211  path.moveTo(fullMoonRect.width()/2, moon.height());
1212  path.arcTo(fullMoonRect, -90, 180);
1213  path.arcTo(halfEllipseRect, 90, 180);
1214  } else {
1215  path.moveTo(fullMoonRect.width()/2, 0);
1216  path.arcTo(fullMoonRect, 90, -180);
1217  path.arcTo(halfEllipseRect, -90, 180);
1218  }
1219  }
1220 
1221  path.closeSubpath();
1222  }
1223 
1224  QPainter overlay;
1225  overlay.begin(&moon);
1226  overlay.setPen(Qt::NoPen);
1227  overlay.setBrush(QBrush(QColor(0, 0, 0, 180)));
1228  overlay.setRenderHint(QPainter::Antialiasing, true);
1229  overlay.drawPath(path);
1230  overlay.end();
1231 
1232  qreal angle = marbleModel()->planet()->epsilon() * qCos(ra * DEG2RAD) * RAD2DEG;
1233  if (viewport->polarity() < 0) angle += 180;
1234 
1235  QTransform form;
1236  const qreal factor = size / moon.size().width();
1237  moon = moon.transformed(form.rotate(angle).scale(factor, factor),
1238  Qt::SmoothTransformation);
1239 
1240  painter->drawPixmap( x - deltaX, y - deltaY, moon );
1241 
1242  // It's labels' time!
1243  if (m_viewSolarSystemLabel)
1244  painter->drawText(x+deltaX, y+deltaY, Planet("moon").name());
1245  }
1246  }
1247  }
1248 
1249  foreach(const QString &planet, m_renderPlanet.keys()) {
1250  if (m_renderPlanet[planet])
1251  renderPlanet(planet, painter, sys, viewport, skyRadius, skyAxisMatrix);
1252  }
1253  }
1254 
1255  painter->restore();
1256 
1257  return true;
1258 }
1259 
1260 void StarsPlugin::renderPlanet(const QString &planetId,
1261  GeoPainter *painter,
1262  SolarSystem &sys,
1263  ViewportParams *viewport,
1264  qreal skyRadius,
1265  matrix &skyAxisMatrix) const
1266 {
1267  double ra(.0), decl(.0), diam(.0), mag(.0), phase(.0);
1268  int color=0;
1269 
1270  // venus, mars, jupiter, uranus, neptune, saturn
1271  if (planetId == "venus") {
1272  sys.getVenus(ra, decl);
1273  sys.getPhysVenus(diam, mag, phase);
1274  color = 2;
1275  } else if (planetId == "mars") {
1276  sys.getMars(ra, decl);
1277  sys.getPhysMars(diam, mag, phase);
1278  color = 5;
1279  } else if (planetId == "jupiter") {
1280  sys.getJupiter(ra, decl);
1281  sys.getPhysJupiter(diam, mag, phase);
1282  color = 2;
1283  } else if (planetId == "mercury") {
1284  sys.getMercury(ra, decl);
1285  sys.getPhysMercury(diam, mag, phase);
1286  color = 3;
1287  } else if (planetId == "saturn") {
1288  sys.getSaturn(ra, decl);
1289  sys.getPhysSaturn(diam, mag, phase);
1290  color = 3;
1291  } else if (planetId == "uranus") {
1292  sys.getUranus(ra, decl);
1293  sys.getPhysUranus(diam, mag, phase);
1294  color = 0;
1295  } else if (planetId == "neptune") {
1296  sys.getNeptune(ra, decl);
1297  sys.getPhysNeptune(diam, mag, phase);
1298  color = 0;
1299  } else {
1300  return;
1301  }
1302 
1303  ra = 15.0 * sys.DmsDegF(ra);
1304  decl = sys.DmsDegF(decl);
1305 
1306  Quaternion qpos = Quaternion::fromSpherical( ra * DEG2RAD,
1307  decl * DEG2RAD );
1308  qpos.rotateAroundAxis( skyAxisMatrix );
1309 
1310  if ( qpos.v[Q_Z] <= 0 ) {
1311  QPixmap planetPixmap = starPixmap(mag, color);
1312 
1313  qreal deltaX = planetPixmap.width() / 2.;
1314  qreal deltaY = planetPixmap.height() / 2.;
1315  const int x = (int)(viewport->width() / 2 + skyRadius * qpos.v[Q_X]);
1316  const int y = (int)(viewport->height() / 2 - skyRadius * qpos.v[Q_Y]);
1317 
1318  if (!(x < 0 || x >= viewport->width() ||
1319  y < 0 || y >= viewport->height())) {
1320  painter->drawPixmap( x - deltaX, y - deltaY, planetPixmap );
1321  }
1322 
1323  // It's labels' time!
1324  if (m_viewSolarSystemLabel)
1325  painter->drawText(x+deltaX, y+deltaY, Planet(planetId).name());
1326  }
1327 }
1328 
1329 void StarsPlugin::requestRepaint()
1330 {
1331  emit repaintNeeded( QRegion() );
1332 }
1333 
1334 void StarsPlugin::toggleSunMoon()
1335 {
1336  QAction *sunMoonAction = qobject_cast<QAction*>(sender());
1337  sunMoonAction->setChecked(!sunMoonAction->isChecked());
1338 
1339  const bool changed = !(m_renderSun || m_renderMoon);
1340  m_renderSun = changed;
1341  m_renderMoon = changed;
1342  if (changed) {
1343  m_viewSolarSystemLabel = true;
1344  }
1345 
1346  Qt::CheckState state = changed ? Qt::Checked : Qt::Unchecked;
1347  if ( m_configDialog ) {
1348  ui_configWidget->m_solarSystemListWidget->item( 0 )->setCheckState( state );
1349  ui_configWidget->m_solarSystemListWidget->item( 1 )->setCheckState( state );
1350  ui_configWidget->m_viewSolarSystemLabelCheckbox->setChecked(m_viewSolarSystemLabel);
1351  }
1352  emit settingsChanged( nameId() );
1353  requestRepaint();
1354 }
1355 
1356 void StarsPlugin::toggleDsos()
1357 {
1358  QAction *dsosAction = qobject_cast<QAction*>(sender());
1359  dsosAction->setChecked(!dsosAction->isChecked());
1360 
1361  const bool changed = !(m_renderDsos || m_renderDsoLabels);
1362  m_renderDsos = changed;
1363  m_renderDsoLabels = changed;
1364 
1365  Qt::CheckState state = changed ? Qt::Checked : Qt::Unchecked;
1366  if ( m_configDialog ) {
1367  ui_configWidget->m_viewDsosCheckbox->setChecked(state);
1368  ui_configWidget->m_viewDsoLabelCheckbox->setChecked(state);
1369  }
1370  emit settingsChanged( nameId() );
1371  requestRepaint();
1372 }
1373 
1374 void StarsPlugin::toggleConstellations()
1375 {
1376  QAction *constellationsAction = qobject_cast<QAction*>(sender());
1377  constellationsAction->setChecked(!constellationsAction->isChecked());
1378 
1379  const bool changed = !(m_renderConstellationLines || m_renderConstellationLabels);
1380  m_renderConstellationLines = changed;
1381  m_renderConstellationLabels = changed;
1382 
1383  Qt::CheckState state = changed ? Qt::Checked : Qt::Unchecked;
1384  if ( m_configDialog ) {
1385  ui_configWidget->m_viewConstellationLinesCheckbox->setChecked( state );
1386  ui_configWidget->m_viewConstellationLabelsCheckbox->setChecked( state );
1387  }
1388  emit settingsChanged( nameId() );
1389  requestRepaint();
1390 }
1391 
1392 void StarsPlugin::togglePlanets()
1393 {
1394  QAction *planetsAction = qobject_cast<QAction*>(sender());
1395  planetsAction->setChecked(!planetsAction->isChecked());
1396 
1397  const bool changed = !planetsAction->isChecked();
1398  m_renderPlanet["venus"] = changed;
1399  m_renderPlanet["mars"] = changed;
1400  m_renderPlanet["jupiter"] = changed;
1401  m_renderPlanet["mercury"] = changed;
1402  m_renderPlanet["saturn"] = changed;
1403  m_renderPlanet["uranus"] = changed;
1404  m_renderPlanet["neptune"] = changed;
1405 
1406  Qt::CheckState state = changed ? Qt::Checked : Qt::Unchecked;
1407  if ( m_configDialog ) {
1408  // Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune
1409  ui_configWidget->m_solarSystemListWidget->item(2)->setCheckState(state);
1410  ui_configWidget->m_solarSystemListWidget->item(3)->setCheckState(state);
1411  ui_configWidget->m_solarSystemListWidget->item(5)->setCheckState(state);
1412  ui_configWidget->m_solarSystemListWidget->item(6)->setCheckState(state);
1413  ui_configWidget->m_solarSystemListWidget->item(7)->setCheckState(state);
1414  ui_configWidget->m_solarSystemListWidget->item(8)->setCheckState(state);
1415  ui_configWidget->m_solarSystemListWidget->item(9)->setCheckState(state);
1416  }
1417 
1418  emit settingsChanged( nameId() );
1419  requestRepaint();
1420 }
1421 
1422 bool StarsPlugin::eventFilter( QObject *object, QEvent *e )
1423 {
1424  if ( !enabled() || !visible() ) {
1425  return false;
1426  }
1427 
1428  if( e->type() == QEvent::ContextMenu )
1429  {
1430  MarbleWidget *widget = dynamic_cast<MarbleWidget *>( object );
1431  QContextMenuEvent *menuEvent = dynamic_cast<QContextMenuEvent *> ( e );
1432  if( widget && menuEvent )
1433  {
1434  qreal mouseLon, mouseLat;
1435  const bool aboveMap = widget->geoCoordinates( menuEvent->x(), menuEvent->y(),
1436  mouseLon, mouseLat, GeoDataCoordinates::Radian );
1437  if ( aboveMap ) {
1438  return false;
1439  }
1440 
1441  foreach ( AbstractFloatItem *floatItem, widget->floatItems() ) {
1442  if ( floatItem->enabled() && floatItem->visible()
1443  && floatItem->contains( menuEvent->pos() ) )
1444  {
1445  return false;
1446  }
1447  }
1448 
1449  bool scheduleConfigAction = false;
1450  if (!m_contextMenu) {
1451  m_contextMenu = new QMenu;
1452  scheduleConfigAction = true;
1453  }
1454 
1455  if (!m_constellationsAction) {
1456  m_constellationsAction =
1457  m_contextMenu->addAction( tr("Show &Constellations"),
1458  this, SLOT(toggleConstellations()) );
1459  }
1460 
1461  m_constellationsAction->setCheckable( true );
1462  m_constellationsAction->setChecked(
1463  m_renderConstellationLines || m_renderConstellationLabels );
1464 
1465 
1466  if (!m_sunMoonAction) {
1467  m_sunMoonAction = m_contextMenu->addAction( tr("Show &Sun and Moon"),
1468  this, SLOT(toggleSunMoon()) );
1469  }
1470 
1471  m_sunMoonAction->setCheckable( true );
1472  m_sunMoonAction->setChecked( m_renderSun || m_renderMoon || m_viewSolarSystemLabel );
1473 
1474  if (!m_planetsAction) {
1475  m_planetsAction = m_contextMenu->addAction( tr("Show &Planets"),
1476  this, SLOT(togglePlanets()));
1477  }
1478 
1479  m_planetsAction->setCheckable( true );
1480  if (m_renderPlanet["venus"] || m_renderPlanet["mars"] ||
1481  m_renderPlanet["jupiter"] || m_renderPlanet["mercury"] ||
1482  m_renderPlanet["saturn"] || m_renderPlanet["uranus"] ||
1483  m_renderPlanet["neptune"]) {
1484  // then
1485  m_planetsAction->setChecked( true );
1486  } else {
1487  m_planetsAction->setChecked( false );
1488  }
1489 
1490  if (!m_dsoAction) {
1491  m_dsoAction = m_contextMenu->addAction( tr("Show &Deep Sky Objects"),
1492  this, SLOT(toggleDsos()) );
1493  }
1494 
1495  m_dsoAction->setCheckable( true );
1496  m_dsoAction->setChecked( m_renderDsos || m_renderDsoLabels );
1497 
1498  if (scheduleConfigAction) {
1499  QDialog *dialog = configDialog();
1500  Q_ASSERT( dialog );
1501  m_contextMenu->addSeparator();
1502  QAction *configAction = m_contextMenu->addAction( tr( "&Configure..." ) );
1503  connect( configAction, SIGNAL(triggered()), dialog, SLOT(exec()) );
1504  }
1505 
1506  m_contextMenu->exec(widget->mapToGlobal(menuEvent->pos()));
1507  return true;
1508  }
1509  return false;
1510  } else {
1511  return RenderPlugin::eventFilter( object, e );
1512  }
1513 }
1514 
1515 }
1516 
1517 Q_EXPORT_PLUGIN2( StarsPlugin, Marble::StarsPlugin )
1518 
1519 #include "StarsPlugin.moc"
QPainterPath::addEllipse
void addEllipse(const QRectF &boundingRectangle)
Marble::Quaternion::toMatrix
void toMatrix(matrix &m) const
Definition: Quaternion.cpp:246
QTransform
Marble::StarsPlugin::isInitialized
bool isInitialized() const
Definition: StarsPlugin.cpp:155
Marble::RAD2DEG
const qreal RAD2DEG
Definition: MarbleGlobal.h:220
QTime::minute
int minute() const
Marble::RenderPlugin::enabled
bool enabled
Definition: RenderPlugin.h:51
Marble::StarsPlugin::~StarsPlugin
~StarsPlugin()
Definition: StarsPlugin.cpp:79
Marble::RenderPlugin::visible
bool visible() const
is visible
QEvent
QPixmap::size
QSize size() const
Marble::matrix
xmmfloat matrix[3]
Definition: Quaternion.h:38
Marble::StarsPlugin::writeSettings
void writeSettings()
Definition: StarsPlugin.cpp:425
SolarSystem::getUranus
void getUranus(double &ra, double &decl)
Definition: solarsystem.cpp:559
Marble::AbstractFloatItem::visible
bool visible() const
Check visibility of the float item.
Definition: AbstractFloatItem.cpp:137
Marble::StarsPlugin::description
QString description() const
Returns a user description of the plugin.
Definition: StarsPlugin.cpp:128
QEvent::type
Type type() const
Marble::GeoDataCoordinates::Radian
Definition: GeoDataCoordinates.h:65
QImage::load
bool load(QIODevice *device, const char *format)
SolarSystem::setCentralBody
void setCentralBody(const char *pname)
Definition: solarsystem.cpp:293
QSize::width
int width() const
QPixmap::width
int width() const
QPainter::end
bool end()
angle
double angle(double vec1[3], double vec2[3])
Definition: sgp4ext.cpp:164
QPixmap::copy
QPixmap copy(int x, int y, int width, int height) const
QPainter::setRenderHint
void setRenderHint(RenderHint hint, bool on)
Marble::MarbleDirs::path
static QString path(const QString &relativePath)
Definition: MarbleDirs.cpp:59
Vec3
Definition: attlib.h:27
QVector::append
void append(const T &value)
QPalette::setColor
void setColor(ColorGroup group, ColorRole role, const QColor &color)
Marble::StarsPlugin::eventFilter
bool eventFilter(QObject *object, QEvent *e)
Definition: StarsPlugin.cpp:1422
Marble::StarsPlugin::render
bool render(GeoPainter *painter, ViewportParams *viewport, const QString &renderPos, GeoSceneLayer *layer=0)
Renders the content provided by the layer on the viewport.
Definition: StarsPlugin.cpp:780
Marble::RenderPlugin::repaintNeeded
void repaintNeeded(QRegion dirtyRegion=QRegion())
This signal is emitted if an update of the view is needed.
SolarSystem::getPhysSun
void getPhysSun(double &pdiam, double &pmag)
Definition: solarsystem.cpp:582
SolarSystem::getJupiter
void getJupiter(double &ra, double &decl)
Definition: solarsystem.cpp:537
QByteArray
QPainterPath::closeSubpath
void closeSubpath()
Marble::StarsPlugin
Definition: StarsPlugin.h:126
Marble::GeoPainter
A painter that allows to draw geometric primitives on the map.
Definition: GeoPainter.h:98
Marble::StarsPlugin::renderPosition
QStringList renderPosition() const
Preferred level in the layer stack for the rendering.
Definition: StarsPlugin.cpp:98
QDataStream
QObject::sender
QObject * sender() const
QChar
QString::split
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
QAction::setChecked
void setChecked(bool)
Marble::RenderPlugin::eventFilter
bool eventFilter(QObject *, QEvent *)
Definition: RenderPlugin.cpp:216
MarbleModel.h
This file contains the headers for MarbleModel.
Marble::StarsPlugin::configDialog
QDialog * configDialog()
Returns a pointer to the configuration dialog of the plugin.
Definition: StarsPlugin.cpp:160
AbstractFloatItem.h
QList::at
const T & at(int i) const
Marble::MarbleModel::planetId
QString planetId() const
Definition: MarbleModel.cpp:532
Marble::StarsPlugin::celestialPoleGetColor
void celestialPoleGetColor()
Definition: StarsPlugin.cpp:520
Marble::PluginAuthor
Definition: PluginInterface.h:28
Marble::MarbleModel::clock
MarbleClock * clock()
Definition: MarbleModel.cpp:537
Marble::StarsPlugin::backendTypes
QStringList backendTypes() const
Returns the name(s) of the backend that the plugin can render This method should return the name of t...
Definition: StarsPlugin.cpp:88
QWidget::mapToGlobal
QPoint mapToGlobal(const QPoint &pos) const
QPainter::save
void save()
Marble::StarsPlugin::renderPolicy
QString renderPolicy() const
Return how the plugin settings should be used.
Definition: StarsPlugin.cpp:93
QDateTime::time
QTime time() const
QPainterPath::moveTo
void moveTo(const QPointF &point)
Marble::StarsPlugin::dsoLabelGetColor
void dsoLabelGetColor()
Definition: StarsPlugin.cpp:487
SolarSystem::getNeptune
void getNeptune(double &ra, double &decl)
Definition: solarsystem.cpp:570
QBrush
SolarSystem::DmsDegF
static double DmsDegF(double h)
Definition: solarsystem.cpp:100
Marble::ViewportParams::projection
Projection projection() const
Definition: ViewportParams.cpp:129
SunLocator.h
QStringList::join
QString join(const QString &separator) const
QPainter::drawLine
void drawLine(const QLineF &line)
Planet.h
Marble::MarbleModel::planet
const Planet * planet() const
Returns the planet object for the current map.
Definition: MarbleModel.cpp:644
QDate::month
int month() const
QMap::clear
void clear()
QObject::disconnect
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
MarbleDebug.h
QObject::tr
QString tr(const char *sourceText, const char *disambiguation, int n)
QFile
Marble::ViewportParams::height
int height() const
Definition: ViewportParams.cpp:255
QTime::second
int second() const
Marble::MarbleClock::dateTime
QDateTime dateTime() const
Returns the internal date and time.
Definition: MarbleClock.cpp:100
QTextStream
Marble::Quaternion::rotateAroundAxis
void rotateAroundAxis(const Quaternion &q)
Definition: Quaternion.cpp:191
QList::size
int size() const
QString::isNull
bool isNull() const
QRectF::setHeight
void setHeight(qreal height)
Marble::MarbleWidget
A widget class that displays a view of the earth.
Definition: MarbleWidget.h:104
QBrush::color
const QColor & color() const
QMap::keys
QList< Key > keys() const
SolarSystem::getLunarPhase
void getLunarPhase(double &phase, double &ildisk, double &amag)
Definition: solarsystem.cpp:902
QVector::clear
void clear()
QString::number
QString number(int n, int base)
QContextMenuEvent::x
int x() const
QContextMenuEvent::y
int y() const
Marble::MarbleGraphicsItem::contains
bool contains(const QPointF &point) const
Returns true if the Item contains point in parent coordinates.
Definition: MarbleGraphicsItem.cpp:110
QList::append
void append(const T &value)
Marble::GeoSceneLayer
Layer of a GeoScene document.
Definition: GeoSceneLayer.h:43
Marble::ViewportParams::width
int width() const
Definition: ViewportParams.cpp:250
QTransform::scale
QTransform & scale(qreal sx, qreal sy)
QHash< QString, QVariant >
QColor::rgb
QRgb rgb() const
QContextMenuEvent
QObject
SolarSystem
Definition: solarsystem.h:17
QPainter::setPen
void setPen(const QColor &color)
Marble::StarsPlugin::eclipticGetColor
void eclipticGetColor()
Definition: StarsPlugin.cpp:498
Marble::RenderPlugin::settingsChanged
void settingsChanged(QString nameId)
This signal is emitted if the settings of the RenderPlugin changed.
Marble::AbstractFloatItem
The abstract class for float item plugins.
Definition: AbstractFloatItem.h:45
Marble::ViewportParams::mapCoversViewport
bool mapCoversViewport() const
Definition: ViewportParams.cpp:398
QPainter
MarbleDirs.h
Marble::StarsPlugin::icon
QIcon icon() const
Returns an icon for the plugin.
Definition: StarsPlugin.cpp:146
Marble::StarsPlugin::renderType
virtual RenderType renderType() const
Render type of the plugin.
Definition: StarsPlugin.cpp:103
QDate::day
int day() const
Marble::StarsPlugin::settings
QHash< QString, QVariant > settings() const
Settings of the plugin.
Definition: StarsPlugin.cpp:195
Marble::Planet
Definition: Planet.h:25
QString::startsWith
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
StarsPlugin.h
Marble::Q_Z
Definition: Quaternion.h:32
QPainter::setBrush
void setBrush(const QBrush &brush)
QDate::year
int year() const
QString
QList
QColor
GeoPainter.h
Marble::ViewportParams::polarity
int polarity() const
Definition: ViewportParams.cpp:150
Marble::DEG2RAD
const qreal DEG2RAD
Definition: MarbleGlobal.h:219
QPixmap::load
bool load(const QString &fileName, const char *format, QFlags< Qt::ImageConversionFlag > flags)
QStringList
Marble::ViewportParams
A public class that controls what is visible in the viewport of a Marble map.
Definition: ViewportParams.h:44
epsilon
qreal epsilon
Definition: shp2pn2.cpp:63
QPixmap
Q_EXPORT_PLUGIN2
#define Q_EXPORT_PLUGIN2(a, b)
Definition: marble_export.h:34
QTime::hour
int hour() const
Marble::Q_Y
Definition: Quaternion.h:31
solarsystem.h
QHash::value
const T value(const Key &key) const
QMenu
Marble::GeoPainter::drawImage
void drawImage(const GeoDataCoordinates &centerPosition, const QImage &image)
Draws an image at the given position. The image is placed with its center located at the given center...
Definition: GeoPainter.cpp:428
Marble::StarsPlugin::version
QString version() const
Definition: StarsPlugin.cpp:123
Marble::StarsPlugin::constellationLabelGetColor
void constellationLabelGetColor()
Definition: StarsPlugin.cpp:476
Marble::Q_X
Definition: Quaternion.h:30
QLatin1Char
QPixmap::height
int height() const
MarbleClock.h
QColorDialog::getColor
QColor getColor(const QColor &initial, QWidget *parent, const QString &title, QFlags< QColorDialog::ColorDialogOption > options)
ViewportParams.h
This file contains the headers for ViewportParams.
Marble::StarsPlugin::guiString
QString guiString() const
String that should be displayed in GUI.
Definition: StarsPlugin.cpp:113
Marble::StarsPlugin::constellationGetColor
void constellationGetColor()
Definition: StarsPlugin.cpp:465
Marble::ViewportParams::centerLatitude
qreal centerLatitude() const
Definition: ViewportParams.cpp:294
QPainter::restore
void restore()
QTransform::rotate
QTransform & rotate(qreal angle, Qt::Axis axis)
Marble::StarsPlugin::celestialEquatorGetColor
void celestialEquatorGetColor()
Definition: StarsPlugin.cpp:509
Marble::GeoPainter::drawText
void drawText(const GeoDataCoordinates &position, const QString &text)
Draws the given text at a given geographic position. The text is drawn starting at the given position...
Definition: GeoPainter.cpp:264
QVector::at
const T & at(int i) const
Marble::MarbleModel
The data model (not based on QAbstractModel) for a MarbleWidget.
Definition: MarbleModel.h:97
Marble::StarsPlugin::nameId
QString nameId() const
Returns the unique name of the plugin.
Definition: StarsPlugin.cpp:118
Marble::StarsPlugin::copyrightYears
QString copyrightYears() const
Definition: StarsPlugin.cpp:133
QPainterPath
QContextMenuEvent::pos
const QPoint & pos() const
QString::toLatin1
QByteArray toLatin1() const
QRectF::width
qreal width() const
SolarSystem::getVenus
void getVenus(double &ra, double &decl)
Definition: solarsystem.cpp:504
QDateTime::date
QDate date() const
QPainter::drawPath
void drawPath(const QPainterPath &path)
QVector< QPixmap >
Marble::Quaternion::inverse
Quaternion inverse() const
Definition: Quaternion.cpp:81
SolarSystem::getPhysUranus
void getPhysUranus(double &pdiam, double &pmag, double &pphase)
Definition: solarsystem.cpp:813
QPen::setWidth
void setWidth(int width)
QPixmap::transformed
QPixmap transformed(const QMatrix &matrix, Qt::TransformationMode mode) const
Marble::Oxygen::aluminumGray5
QColor const aluminumGray5
Definition: MarbleColors.h:91
QChar::toUpper
QChar toUpper() const
Marble::ViewportParams::radius
int radius() const
Definition: ViewportParams.cpp:195
Marble::ViewportParams::centerLongitude
qreal centerLongitude() const
Definition: ViewportParams.cpp:289
SolarSystem::getSun
void getSun(double &ra, double &decl)
Definition: solarsystem.cpp:471
QRectF
Marble::StarsPlugin::initialize
void initialize()
Definition: StarsPlugin.cpp:151
QRectF::setWidth
void setWidth(qreal width)
Marble::StarsPlugin::setSettings
void setSettings(const QHash< QString, QVariant > &settings)
Set the settings of the plugin.
Definition: StarsPlugin.cpp:229
SolarSystem::getPhysVenus
void getPhysVenus(double &pdiam, double &pmag, double &pphase)
Definition: solarsystem.cpp:635
Marble::MarbleWidget::geoCoordinates
bool geoCoordinates(int x, int y, qreal &lon, qreal &lat, GeoDataCoordinates::Unit=GeoDataCoordinates::Degree) const
Get the earth coordinates corresponding to a pixel in the widget.
Definition: MarbleWidget.cpp:668
QString::at
const QChar at(int position) const
Marble::Quaternion
Definition: Quaternion.h:41
QAction
SolarSystem::getMercury
void getMercury(double &ra, double &decl)
Definition: solarsystem.cpp:493
Marble::StarsPlugin::assembledConstellation
QString assembledConstellation(const QString &name)
Definition: StarsPlugin.cpp:312
QByteArray::data
char * data()
SolarSystem::getSaturn
void getSaturn(double &ra, double &decl)
Definition: solarsystem.cpp:548
M_PI
#define M_PI
Definition: GeoDataCoordinates.h:26
Marble::Quaternion::v
xmmfloat v
Definition: Quaternion.h:87
QPen
QDialog
MarbleWidget.h
This file contains the headers for MarbleWidget.
Marble::StarsPlugin::name
QString name() const
Returns the user-visible name of the plugin.
Definition: StarsPlugin.cpp:108
SolarSystem::getMoon
void getMoon(double &ra, double &decl)
Definition: solarsystem.cpp:482
Marble::Planet::epsilon
qreal epsilon() const
obliquity of the ecliptic plane
Definition: Planet.cpp:235
SolarSystem::getPhysSaturn
void getPhysSaturn(double &pdiam, double &pmag, double &pphase)
Definition: solarsystem.cpp:777
Marble::RenderPlugin::enabled
bool enabled() const
is enabled
SolarSystem::getPhysJupiter
void getPhysJupiter(double &pdiam, double &pmag, double &pphase)
Definition: solarsystem.cpp:742
mag
double mag(double x[3])
Definition: sgp4ext.cpp:68
Marble::RenderPlugin::ThemeRenderType
Definition: RenderPlugin.h:64
Marble::StarsPlugin::readSettings
void readSettings()
Definition: StarsPlugin.cpp:326
QRectF::setX
void setX(qreal x)
Marble::StarsPlugin::StarsPlugin
StarsPlugin(const MarbleModel *marbleModel=0)
Definition: StarsPlugin.cpp:40
SolarSystem::getPhysMars
void getPhysMars(double &pdiam, double &pmag, double &pphase)
Definition: solarsystem.cpp:707
SolarSystem::getDiamMoon
double getDiamMoon()
Definition: solarsystem.cpp:882
Marble::Spherical
Spherical projection.
Definition: MarbleGlobal.h:45
Marble::RenderPlugin::marbleModel
const MarbleModel * marbleModel() const
Access to the MarbleModel.
Definition: RenderPlugin.cpp:83
SolarSystem::setCurrentMJD
void setCurrentMJD(int year, int month, int day, int hour, int min, double sec)
Definition: solarsystem.cpp:193
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Marble::RenderPlugin::settings
virtual QHash< QString, QVariant > settings() const
Settings of the plugin.
Definition: RenderPlugin.cpp:185
QVector::size
int size() const
QPainter::begin
bool begin(QPaintDevice *device)
Marble::RenderPlugin::RenderType
RenderType
A Type of plugin.
Definition: RenderPlugin.h:59
QPainterPath::arcTo
void arcTo(const QRectF &rectangle, qreal startAngle, qreal sweepLength)
QPixmap::rect
QRect rect() const
SolarSystem::getPhysNeptune
void getPhysNeptune(double &pdiam, double &pmag, double &pphase)
Definition: solarsystem.cpp:848
Marble::mDebug
QDebug mDebug()
a function to replace qDebug() in Marble library code
Definition: MarbleDebug.cpp:36
Marble::MarbleWidget::floatItems
QList< AbstractFloatItem * > floatItems() const
Returns a list of all FloatItems on the widget.
Definition: MarbleWidget.cpp:1146
Marble::GeoPainter::drawPixmap
void drawPixmap(const GeoDataCoordinates &centerPosition, const QPixmap &pixmap)
Draws a pixmap at the given position. The pixmap is placed with its center located at the given cente...
Definition: GeoPainter.cpp:452
Marble::RenderPlugin
The abstract class that creates a renderable item.
Definition: RenderPlugin.h:43
Marble::RenderPlugin::setSettings
virtual void setSettings(const QHash< QString, QVariant > &settings)
Set the settings of the plugin.
Definition: RenderPlugin.cpp:195
Marble::Quaternion::fromEuler
static Quaternion fromEuler(qreal pitch, qreal yaw, qreal roll)
Definition: Quaternion.cpp:105
QPalette
Marble::StarsPlugin::pluginAuthors
QList< PluginAuthor > pluginAuthors() const
Definition: StarsPlugin.cpp:138
QRegion
Marble::Quaternion::fromSpherical
static Quaternion fromSpherical(qreal lon, qreal lat)
used to generate Quaternion from longitude and latitude
Definition: Quaternion.cpp:38
QIcon
QDateTime
QColor::isValid
bool isValid() const
SolarSystem::getPlanetocentric
Vec3 getPlanetocentric(double ra, double decl)
Definition: solarsystem.cpp:1363
SolarSystem::getMars
void getMars(double &ra, double &decl)
Definition: solarsystem.cpp:526
SolarSystem::getPhysMercury
void getPhysMercury(double &pdiam, double &pmag, double &pphase)
Definition: solarsystem.cpp:599
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:42 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • 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
  • 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