• 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
kstarsinit.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  kstarsinit.cpp - K Desktop Planetarium
3  -------------------
4  begin : Mon Feb 25 2002
5  copyright : (C) 2002 by Jason Harris
6  email : jharris@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 <QFile>
19 #include <QDir>
20 #include <QTextStream>
21 
22 #include <kactioncollection.h>
23 #include <kactionmenu.h>
24 #include <kiconloader.h>
25 #include <kmenu.h>
26 #include <kstatusbar.h>
27 #include <ktip.h>
28 #include <kmessagebox.h>
29 #include <kstandardaction.h>
30 #include <kstandarddirs.h>
31 #include <ktoggleaction.h>
32 #include <ktoolbar.h>
33 #include <kicon.h>
34 #include <knewstuff3/knewstuffaction.h>
35 
36 #include "Options.h"
37 #include "fov.h"
38 #include "kstars.h"
39 #include "kstarsdata.h"
40 #include "skymap.h"
41 #include "skyobjects/skyobject.h"
42 #include "skyobjects/ksplanetbase.h"
43 #include "simclock.h"
44 #include "widgets/timestepbox.h"
45 #include "oal/equipmentwriter.h"
46 #include "oal/observeradd.h"
47 #include "skycomponents/skymapcomposite.h"
48 #include "texturemanager.h"
49 
50 #include <config-kstars.h>
51 
52 #ifdef HAVE_INDI_H
53 #include "indi/drivermanager.h"
54 #include "indi/guimanager.h"
55 #endif
56 
57 //This file contains functions that kstars calls at startup (except constructors).
58 //These functions are declared in kstars.h
59 
60 namespace {
61  // A lot of KAction is defined there. In order to decrease amount
62  // of boilerplate code a trick with << operator overloading is used.
63  // This makes code more concise and readable.
64  //
65  // When data type could not used directly. Either because of
66  // overloading rules or because one data type have different
67  // semantics its wrapped into struct.
68  //
69  // Downside is unfamiliar syntax and really unhelpful error
70  // messages due to general abuse of << overloading
71 
72  // Set KAction text
73  KAction* operator << (KAction* ka, QString text) {
74  ka->setText(text);
75  return ka;
76  }
77  // Set icon for KAction
78  KAction* operator << (KAction* ka, const KIcon& icon) {
79  ka->setIcon(icon);
80  return ka;
81  }
82  // Set keyboard shortcut
83  KAction* operator << (KAction* ka, const KShortcut& sh) {
84  ka->setShortcuts(sh);
85  return ka;
86  }
87 
88  // Add action to group. AddToGroup struct acts as newtype wrapper
89  // in order to allow overloading.
90  struct AddToGroup {
91  QActionGroup* grp;
92  AddToGroup(QActionGroup* g) : grp(g) {}
93  };
94  KAction* operator << (KAction* ka, AddToGroup g) {
95  g.grp->addAction(ka);
96  return ka;
97  }
98 
99  // Set checked property. Checked is newtype wrapper.
100  struct Checked {
101  bool flag;
102  Checked(bool f) : flag(f) {}
103  };
104  KAction* operator << (KAction* ka, Checked chk) {
105  ka->setCheckable(true);
106  ka->setChecked(chk.flag);
107  return ka;
108  }
109 
110  // Set tool tip. ToolTip is used as newtype wrapper.
111  struct ToolTip {
112  QString tip;
113  ToolTip(QString msg) : tip(msg) {}
114  };
115  KAction* operator << (KAction* ka, const ToolTip& tool) {
116  ka->setToolTip(tool.tip);
117  return ka;
118  }
119 
120  // Create new KToggleAction and connect slot to toggled(bool) signal
121  KAction* newToggleAction(KActionCollection* col, QString name, QString text,
122  QObject* receiver, const char* member) {
123  KAction* ka = col->add<KToggleAction>(name) << text;
124  QObject::connect(ka, SIGNAL( toggled(bool) ), receiver, member);
125  return ka;
126  }
127 }
128 
129 void KStars::initActions() {
130  KIconLoader::global()->addAppDir( "kstars" );
131  KAction *ka;
132 
133  // ==== File menu ================
134  ka = KNS3::standardAction(i18n("Download New Data..."), this, SLOT(slotDownload()), actionCollection(), "get_data")
135  << KShortcut( Qt::CTRL+Qt::Key_D );
136  ka->setWhatsThis(i18n("Downloads new data"));
137  ka->setToolTip(ka->whatsThis());
138  ka->setStatusTip(ka->whatsThis());
139 
140 #ifdef HAVE_CFITSIO_H
141  actionCollection()->addAction("open_file", this, SLOT(slotOpenFITS()) )
142  << i18n("Open FITS...")
143  << KIcon("document-open")
144  << KShortcut( Qt::CTRL+Qt::Key_O );
145 #endif
146 
147  actionCollection()->addAction("export_image", this, SLOT( slotExportImage() ) )
148  << i18n("&Save Sky Image...")
149  << KIcon("document-export-image")
150  << KShortcut( Qt::CTRL+Qt::Key_I );
151  actionCollection()->addAction("run_script", this, SLOT( slotRunScript() ))
152  << i18n("&Run Script...")
153  << KIcon("system-run" )
154  << KShortcut( Qt::CTRL+Qt::Key_R );
155  actionCollection()->addAction("printing_wizard", this, SLOT(slotPrintingWizard() ) )
156  << i18nc("start Printing Wizard", "Printing &Wizard");
157  actionCollection()->addAction( KStandardAction::Print, "print", this, SLOT( slotPrint() ) );
158  actionCollection()->addAction( KStandardAction::Quit, "quit", this, SLOT( close() ) );
159 
160  // ==== Time Menu ================
161  actionCollection()->addAction("time_to_now", this, SLOT( slotSetTimeToNow() ))
162  << i18n("Set Time to &Now")
163  << KShortcut( Qt::CTRL+Qt::Key_E );
164 
165  actionCollection()->addAction("time_dialog", this, SLOT( slotSetTime() ) )
166  << i18nc("set Clock to New Time", "&Set Time..." )
167  << KShortcut( Qt::CTRL+Qt::Key_S )
168  << KIcon("view-history");
169 
170  ka = actionCollection()->add<KToggleAction>("clock_startstop")
171  << i18n("Stop &Clock" )
172  << KIcon("media-playback-pause" );
173  if ( ! StartClockRunning )
174  ka->toggle();
175  QObject::connect( ka, SIGNAL( triggered() ), this, SLOT( slotToggleTimer() ) );
176  QObject::connect(data()->clock(), SIGNAL(clockToggled(bool)), ka, SLOT(setChecked(bool)) );
177  //UpdateTime() if clock is stopped (so hidden objects get drawn)
178  QObject::connect(data()->clock(), SIGNAL(clockToggled(bool)), this, SLOT(updateTime()) );
179  actionCollection()->addAction("time_step_forward", this, SLOT( slotStepForward() ) )
180  << i18n("Advance one step forward in time")
181  << KIcon("media-skip-forward" )
182  << KShortcut( Qt::Key_Greater, Qt::Key_Period );
183  actionCollection()->addAction("time_step_backward", this, SLOT( slotStepBackward() ) )
184  << i18n("Advance one step backward in time")
185  << KIcon("media-skip-backward" )
186  << KShortcut( Qt::Key_Less, Qt::Key_Comma );
187 
188  // ==== Pointing Menu ================
189  actionCollection()->addAction("zenith", this, SLOT( slotPointFocus() ) )
190  << i18n("&Zenith")
191  << KShortcut("Z");
192  actionCollection()->addAction("north", this, SLOT( slotPointFocus() ) )
193  << i18n("&North")
194  << KShortcut("N");
195  actionCollection()->addAction("east", this, SLOT( slotPointFocus() ) )
196  << i18n("&East")
197  << KShortcut("E");
198  actionCollection()->addAction("south", this, SLOT( slotPointFocus() ) )
199  << i18n("&South")
200  << KShortcut("S");
201  actionCollection()->addAction("west", this, SLOT( slotPointFocus() ) )
202  << i18n("&West")
203  << KShortcut("W");
204 
205  actionCollection()->addAction("find_object", this, SLOT( slotFind() ) )
206  << i18n("&Find Object...")
207  << KIcon("edit-find")
208  << KShortcut( Qt::CTRL+Qt::Key_F );
209  actionCollection()->addAction("track_object", this, SLOT( slotTrack() ) )
210  << i18n("Engage &Tracking")
211  << KIcon("object-locked" )
212  << KShortcut( Qt::CTRL+Qt::Key_T );
213  actionCollection()->addAction("manual_focus", this, SLOT( slotManualFocus() ) )
214  << i18n("Set Coordinates &Manually..." )
215  << KShortcut( Qt::CTRL+Qt::Key_M );
216 
217  // ==== View Menu ================
218  actionCollection()->addAction( KStandardAction::ZoomIn, "zoom_in", map(), SLOT( slotZoomIn() ) );
219  actionCollection()->addAction( KStandardAction::ZoomOut, "zoom_out", map(), SLOT( slotZoomOut() ) );
220  actionCollection()->addAction("zoom_default", map(), SLOT( slotZoomDefault() ) )
221  << i18n("&Default Zoom")
222  << KIcon("zoom-fit-best" )
223  << KShortcut( Qt::CTRL+Qt::Key_Z );
224  actionCollection()->addAction("zoom_set", this, SLOT( slotSetZoom() ) )
225  << i18n("&Zoom to Angular Size..." )
226  << KIcon("zoom-original" )
227  << KShortcut( Qt::CTRL+Qt::SHIFT+Qt::Key_Z );
228 
229  actionCollection()->addAction( KStandardAction::FullScreen, this, SLOT( slotFullScreen() ) );
230 
231  actionCollection()->addAction("coordsys", this, SLOT( slotCoordSys() ) )
232  << (Options::useAltAz() ? i18n("Switch to star globe view (Equatorial &Coordinates)"): i18n("Switch to horizonal view (Horizontal &Coordinates)"))
233  << KShortcut("Space" );
234 
235  #ifdef HAVE_OPENGL
236  Q_ASSERT( SkyMap::Instance() ); // This assert should not fail, because SkyMap is already created by now. Just throwing it in anyway.
237  actionCollection()->addAction("opengl", SkyMap::Instance(), SLOT( slotToggleGL() ) )
238  << (Options::useGL() ? i18n("Switch to QPainter backend"): i18n("Switch to OpenGL backend"));
239  #endif
240 
241  actionCollection()->addAction("project_lambert", this, SLOT( slotMapProjection() ) )
242  << i18n("&Lambert Azimuthal Equal-area" )
243  << KShortcut("F5" )
244  << AddToGroup(projectionGroup)
245  << Checked(Options::projection() == SkyMap::Lambert);
246  actionCollection()->addAction("project_azequidistant", this, SLOT( slotMapProjection() ) )
247  << i18n("&Azimuthal Equidistant" )
248  << KShortcut("F6" )
249  << AddToGroup(projectionGroup)
250  << Checked(Options::projection() == SkyMap::AzimuthalEquidistant);
251  actionCollection()->addAction("project_orthographic", this, SLOT( slotMapProjection() ) )
252  << i18n("&Orthographic" )
253  << KShortcut("F7" )
254  << AddToGroup(projectionGroup)
255  << Checked(Options::projection() == SkyMap::Orthographic);
256  actionCollection()->addAction("project_equirectangular", this, SLOT( slotMapProjection() ) )
257  << i18n("&Equirectangular" )
258  << KShortcut("F8" )
259  << AddToGroup(projectionGroup)
260  << Checked(Options::projection() == SkyMap::Equirectangular);
261  actionCollection()->addAction("project_stereographic", this, SLOT( slotMapProjection() ) )
262  << i18n("&Stereographic" )
263  << KShortcut("F9" )
264  << AddToGroup(projectionGroup)
265  << Checked(Options::projection() == SkyMap::Stereographic);
266  actionCollection()->addAction("project_gnomonic", this, SLOT( slotMapProjection() ) )
267  << i18n("&Gnomonic" )
268  << KShortcut("F10" )
269  << AddToGroup(projectionGroup)
270  << Checked(Options::projection() == SkyMap::Gnomonic);
271 
272  //Settings Menu:
273  //Info Boxes option actions
274  KAction* kaBoxes = actionCollection()->add<KToggleAction>("show_boxes" )
275  << i18nc("Show the information boxes", "Show &Info Boxes")
276  << Checked( Options::showInfoBoxes() );
277  connect( kaBoxes, SIGNAL(toggled(bool)), map(), SLOT(slotToggleInfoboxes(bool)));
278  kaBoxes->setChecked( Options::showInfoBoxes() );
279 
280  ka = actionCollection()->add<KToggleAction>("show_time_box")
281  << i18nc("Show time-related info box", "Show &Time Box");
282  connect(kaBoxes, SIGNAL( toggled(bool) ), ka, SLOT( setEnabled(bool) ) );
283  connect(ka, SIGNAL( toggled(bool) ), map(), SLOT( slotToggleTimeBox(bool)));
284  ka->setChecked( Options::showTimeBox() );
285  ka->setEnabled( Options::showInfoBoxes() );
286 
287  ka = actionCollection()->add<KToggleAction>("show_focus_box")
288  << i18nc("Show focus-related info box", "Show &Focus Box");
289  connect(kaBoxes, SIGNAL( toggled(bool) ), ka, SLOT( setEnabled(bool) ) );
290  connect(ka, SIGNAL( toggled(bool) ), map(), SLOT( slotToggleFocusBox(bool)));
291  ka->setChecked( Options::showFocusBox() );
292  ka->setEnabled( Options::showInfoBoxes() );
293 
294  ka = actionCollection()->add<KToggleAction>("show_location_box")
295  << i18nc("Show location-related info box", "Show &Location Box");
296  connect(kaBoxes, SIGNAL( toggled(bool) ), ka, SLOT( setEnabled(bool) ) );
297  connect(ka, SIGNAL( toggled(bool) ), map(), SLOT( slotToggleGeoBox(bool)));
298  ka->setChecked( Options::showGeoBox() );
299  ka->setEnabled( Options::showInfoBoxes() );
300 
301 
302  //Toolbar options
303  newToggleAction( actionCollection(), "show_mainToolBar", i18n("Show Main Toolbar"),
304  toolBar("kstarsToolBar"), SLOT(setVisible(bool)));
305  newToggleAction( actionCollection(), "show_viewToolBar", i18n("Show View Toolbar"),
306  toolBar( "viewToolBar" ), SLOT(setVisible(bool)));
307 
308  //Statusbar view options
309  newToggleAction( actionCollection(), "show_statusBar", i18n("Show Statusbar"),
310  this, SLOT(slotShowGUIItem(bool)));
311  newToggleAction( actionCollection(), "show_sbAzAlt", i18n("Show Az/Alt Field"),
312  this, SLOT(slotShowGUIItem(bool)));
313  newToggleAction( actionCollection(), "show_sbRADec", i18n("Show RA/Dec Field"),
314  this, SLOT(slotShowGUIItem(bool)));
315 
316  //Color scheme actions. These are added to the "colorschemes" KActionMenu.
317  colorActionMenu = actionCollection()->add<KActionMenu>("colorschemes" );
318  colorActionMenu->setText( i18n("C&olor Schemes" ) );
319  addColorMenuItem( i18n("&Classic" ), "cs_classic" );
320  addColorMenuItem( i18n("&Star Chart" ), "cs_chart" );
321  addColorMenuItem( i18n("&Night Vision" ), "cs_night" );
322  addColorMenuItem( i18n("&Moonless Night" ), "cs_moonless-night" );
323 
324  //Add any user-defined color schemes:
325  QFile file( KStandardDirs::locate("appdata", "colors.dat" ) ); //determine filename in local user KDE directory tree.
326  if ( file.exists() && file.open( QIODevice::ReadOnly ) ) {
327  QTextStream stream( &file );
328  while ( !stream.atEnd() ) {
329  QString line = stream.readLine();
330  QString schemeName = line.left( line.indexOf( ':' ) );
331  QString actionname = "cs_" + line.mid( line.indexOf( ':' ) +1, line.indexOf( '.' ) - line.indexOf( ':' ) - 1 );
332  addColorMenuItem( i18n( schemeName.toLocal8Bit() ), actionname.toLocal8Bit() );
333  }
334  file.close();
335  }
336 
337  //Add FOV Symbol actions
338  fovActionMenu = actionCollection()->add<KActionMenu>("fovsymbols" );
339  fovActionMenu->setText( i18n("&FOV Symbols" ) );
340  repopulateFOV();
341 
342  actionCollection()->addAction("geolocation", this, SLOT( slotGeoLocator() ) )
343  << i18nc("Location on Earth", "&Geographic..." )
344  << KIcon("applications-internet" )
345  << KShortcut( Qt::CTRL+Qt::Key_G );
346  actionCollection()->addAction( KStandardAction::Preferences, "configure", this, SLOT( slotViewOps() ) );
347  actionCollection()->addAction("startwizard", this, SLOT( slotWizard() ) )
348  << i18n("Startup Wizard..." )
349  << KIcon("tools-wizard" );
350 
351  // Updates actions
352  actionCollection()->addAction( "update_comets", this, SLOT( slotUpdateComets() ) )
353  << i18n( "Update comets orbital elements" );
354  actionCollection()->addAction( "update_asteroids", this, SLOT( slotUpdateAsteroids() ) )
355  << i18n( "Update asteroids orbital elements" );
356  actionCollection()->addAction("update_supernovae", this, SLOT(slotUpdateSupernovae() ) )
357  << i18n( "Update Recent Supernovae data" );
358 
359  //Tools Menu:
360  actionCollection()->addAction("astrocalculator", this, SLOT( slotCalculator() ) )
361  << i18n("Calculator")
362  << KIcon("accessories-calculator" )
363  << KShortcut( Qt::CTRL+Qt::Key_C );
364 
365  actionCollection()->addAction("moonphasetool", this, SLOT( slotMoonPhaseTool() ) )
366  << i18n("Moon Phase Calendar");
367 
368  actionCollection()->addAction("obslist", this, SLOT( slotObsList() ) )
369  << i18n("Observation Planner")
370  << KShortcut( Qt::CTRL+Qt::Key_L );
371 
372  actionCollection()->addAction("altitude_vs_time", this, SLOT( slotAVT() ) )
373  << i18n("Altitude vs. Time")
374  << KShortcut( Qt::CTRL+Qt::Key_A );
375  actionCollection()->addAction("whats_up_tonight", this, SLOT( slotWUT() ) )
376  << i18n("What's up Tonight")
377  << KShortcut(Qt::CTRL+Qt::Key_U );
378  actionCollection()->addAction("whats_interesting", this, SLOT( slotWISettings() ) )
379  << i18n("What's Interesting...")
380  << KShortcut(Qt::CTRL+Qt::Key_W );
381  actionCollection()->addAction("skycalendar", this, SLOT( slotCalendar() ) )
382  << i18n("Sky Calendar");
383 
384 #ifdef HAVE_INDI_H
385 #ifndef Q_WS_WIN
386  actionCollection()->addAction("ekos", this, SLOT( slotEkos() ) )
387  << i18n("Ekos");
388 #endif
389 #endif
390 
391 //FIXME: implement glossary
392 // ka = actionCollection()->addAction("glossary");
393 // ka->setText( i18n("Glossary...") );
394 // ka->setShortcuts( KShortcut(Qt::CTRL+Qt::Key_K ) );
395 // connect( ka, SIGNAL( triggered() ), this, SLOT( slotGlossary() ) );
396 
397  actionCollection()->addAction("scriptbuilder", this, SLOT( slotScriptBuilder() ) )
398  << i18n("Script Builder")
399  << KShortcut(Qt::CTRL+Qt::Key_B );
400  actionCollection()->addAction("solarsystem", this, SLOT( slotSolarSystem() ) )
401  << i18n("Solar System")
402  << KShortcut(Qt::CTRL+Qt::Key_Y );
403  actionCollection()->addAction("jmoontool", this, SLOT( slotJMoonTool() ) )
404  << i18n("Jupiter's Moons")
405  << KShortcut(Qt::CTRL+Qt::Key_J );
406  actionCollection()->addAction("flagmanager", this, SLOT( slotFlagManager() ) )
407  << i18n("Flags");
408 
409  actionCollection()->addAction("ewriter", this, SLOT( slotEquipmentWriter() ) )
410  << i18n("Define Equipment...")
411  << KShortcut( Qt::CTRL+Qt::Key_0 );
412  actionCollection()->addAction("obsadd", this, SLOT( slotObserverAdd() ) )
413  << i18n( "Add Observer..." )
414  << KShortcut( Qt::CTRL+Qt::Key_1 );
415 
416  // ==== observation menu ================
417  ka = actionCollection()->addAction("execute", this, SLOT( slotExecute() ) )
418  << i18n( "Execute the session Plan..." )
419  << KShortcut( Qt::CTRL+Qt::Key_2 );
420 
421  // ==== devices Menu ================
422 #ifdef HAVE_INDI_H
423 #ifndef Q_WS_WIN
424 
425 
426  actionCollection()->addAction("telescope_wizard", this, SLOT( slotTelescopeWizard() ) )
427  << i18n("Telescope Wizard...")
428  << KIcon("tools-wizard" );
429  actionCollection()->addAction("device_manager", this, SLOT( slotINDIDriver() ) )
430  << i18n("Device Manager...")
431  << KIcon("network-server" );
432  ka = actionCollection()->addAction("indi_cpl", this, SLOT( slotINDIPanel() ) )
433  << i18n("INDI Control Panel...");
434  ka->setEnabled(false);
435 
436 
437 #endif
438 #endif
439 
440  //Help Menu:
441  actionCollection()->addAction( KStandardAction::TipofDay, "help_tipofday", this, SLOT( slotTipOfDay() ) )
442  ->setWhatsThis(i18n("Displays the Tip of the Day"));
443 
444  // KStandardAction::help(this, SLOT( appHelpActivated() ), actionCollection(), "help_contents" );
445 
446  //Add timestep widget for toolbar
447  TimeStep = new TimeStepBox( toolBar("kstarsToolBar") );
448  // Add a tool tip to TimeStep describing the weird nature of time steps
449  QString TSBToolTip = i18nc( "Tooltip describing the nature of the time step control", "Use this to set the rate at which time in the simulation flows.\nFor time step \'X\' up to 10 minutes, time passes at the rate of \'X\' per second.\nFor time steps larger than 10 minutes, frames are displayed at an interval of \'X\'." );
450  TimeStep->setToolTip( TSBToolTip );
451  TimeStep->tsbox()->setToolTip( TSBToolTip );
452  ka = actionCollection()->addAction("timestep_control")
453  << i18n("Time step control");
454  ka->setDefaultWidget( TimeStep );
455 
456  // ==== viewToolBar actions ================
457  actionCollection()->add<KToggleAction>("show_stars", this, SLOT( slotViewToolBar() ) )
458  << i18nc("Toggle Stars in the display", "Stars" )
459  << KIcon("kstars_stars" )
460  << ToolTip( i18n("Toggle stars") );
461  actionCollection()->add<KToggleAction>("show_deepsky", this, SLOT( slotViewToolBar() ) )
462  << i18nc("Toggle Deep Sky Objects in the display", "Deep Sky" )
463  << KIcon("kstars_deepsky" )
464  << ToolTip( i18n("Toggle deep sky objects") );
465  actionCollection()->add<KToggleAction>("show_planets", this, SLOT( slotViewToolBar() ) )
466  << i18nc("Toggle Solar System objects in the display", "Solar System" )
467  << KIcon("kstars_planets" )
468  << ToolTip( i18n("Toggle Solar system objects") );
469  actionCollection()->add<KToggleAction>("show_clines", this, SLOT( slotViewToolBar() ) )
470  << i18nc("Toggle Constellation Lines in the display", "Const. Lines" )
471  << KIcon("kstars_clines" )
472  << ToolTip( i18n("Toggle constellation lines") );
473  actionCollection()->add<KToggleAction>("show_cnames", this, SLOT( slotViewToolBar() ) )
474  << i18nc("Toggle Constellation Names in the display", "Const. Names" )
475  << KIcon("kstars_cnames" )
476  << ToolTip( i18n("Toggle constellation names") );
477  actionCollection()->add<KToggleAction>("show_cbounds", this, SLOT( slotViewToolBar() ) )
478  << i18nc("Toggle Constellation Boundaries in the display", "C. Boundaries" )
479  << KIcon("kstars_cbound" )
480  << ToolTip( i18n("Toggle constellation boundaries") );
481  actionCollection()->add<KToggleAction>("show_mw", this, SLOT( slotViewToolBar() ) )
482  << i18nc("Toggle Milky Way in the display", "Milky Way" )
483  << KIcon("kstars_mw" )
484  << ToolTip( i18n("Toggle milky way") );
485  actionCollection()->add<KToggleAction>("show_equatorial_grid", this, SLOT( slotViewToolBar() ) )
486  << i18nc("Toggle Equatorial Coordinate Grid in the display", "Equatorial coord. grid" )
487  << KIcon("kstars_grid" )
488  << ToolTip( i18n("Toggle equatorial coordinate grid") );
489  actionCollection()->add<KToggleAction>("show_horizontal_grid", this, SLOT( slotViewToolBar() ) )
490  << i18nc("Toggle Horizontal Coordinate Grid in the display", "Horizontal coord. grid" )
491  << KIcon("kstars_hgrid" )
492  << ToolTip( i18n("Toggle horizontal coordinate grid") );
493  actionCollection()->add<KToggleAction>("show_horizon", this, SLOT( slotViewToolBar() ) )
494  << i18nc("Toggle the opaque fill of the ground polygon in the display", "Ground" )
495  << KIcon("kstars_horizon" )
496  << ToolTip( i18n("Toggle opaque ground") );
497  actionCollection()->add<KToggleAction>("show_flags", this, SLOT( slotViewToolBar() ) )
498  << i18nc("Toggle flags in the display", "Flags" )
499  << KIcon("kstars_flag" )
500  << ToolTip( i18n("Toggle flags") );
501  actionCollection()->add<KToggleAction>("show_satellites", this, SLOT( slotViewToolBar() ) )
502  << i18nc("Toggle satellites in the display", "Satellites" )
503  << KIcon("kstars_satellites" )
504  << ToolTip( i18n("Toggle satellites") );
505  actionCollection()->add<KToggleAction>("show_supernovae", this, SLOT( slotViewToolBar() ) )
506  << i18nc("Toggle supernovae in the display", "Supernovae" )
507  << KIcon("kstars_supernovae" )
508  << ToolTip( i18n("Toggle supernovae") );
509 
510  setXMLFile("kstarsui.rc" );
511 
512  if (Options::fitsDir().isEmpty())
513  Options::setFitsDir(QDir:: homePath());
514 }
515 
516 void KStars::repopulateFOV() {
517  // Read list of all FOVs
518  qDeleteAll( data()->availFOVs );
519  data()->availFOVs = FOV::readFOVs();
520  data()->syncFOV();
521 
522  // Iterate through FOVs
523  fovActionMenu->menu()->clear();
524  foreach(FOV* fov, data()->availFOVs) {
525  KToggleAction *kta = actionCollection()->add<KToggleAction>( fov->name() );
526  kta->setText( fov->name() );
527  if( Options::fOVNames().contains( fov->name() ) ) {
528  kta->setChecked(true);
529  }
530  fovActionMenu->addAction( kta );
531  connect( kta, SIGNAL( toggled( bool ) ), this, SLOT( slotTargetSymbol(bool) ) );
532  }
533  // Add menu bottom
534  KAction* ka = actionCollection()->addAction("edit_fov", this, SLOT( slotFOVEdit() ) )
535  << i18n("Edit FOV Symbols...");
536  fovActionMenu->addSeparator();
537  fovActionMenu->addAction( ka );
538 }
539 
540 void KStars::initStatusBar() {
541  statusBar()->insertPermanentItem( i18n( " Welcome to KStars " ), 0, 1 );
542  statusBar()->setItemAlignment( 0, Qt::AlignLeft | Qt::AlignVCenter );
543 
544  QString s = "000d 00m 00s, +00d 00\' 00\""; //only need this to set the width
545  if ( Options::showAltAzField() ) {
546  statusBar()->insertPermanentFixedItem( s, 1 );
547  statusBar()->setItemAlignment( 1, Qt::AlignRight | Qt::AlignVCenter );
548  statusBar()->changeItem( QString(), 1 );
549  }
550 
551  if ( Options::showRADecField() ) {
552  statusBar()->insertPermanentFixedItem( s, 2 );
553  statusBar()->setItemAlignment( 2, Qt::AlignRight | Qt::AlignVCenter );
554  statusBar()->changeItem( QString(), 2 );
555  }
556 
557  if ( ! Options::showStatusBar() )
558  statusBar()->hide();
559 }
560 
561 void KStars::datainitFinished() {
562  //Time-related connections
563  connect( data()->clock(), SIGNAL( timeAdvanced() ),
564  this, SLOT( updateTime() ) );
565  connect( data()->clock(), SIGNAL( timeChanged() ),
566  this, SLOT( updateTime() ) );
567 
568  //Add GUI elements to main window
569  buildGUI();
570 
571  connect( data()->clock(), SIGNAL( scaleChanged( float ) ),
572  map(), SLOT( slotClockSlewing() ) );
573 
574  connect( data(), SIGNAL( update() ), map(), SLOT( forceUpdateNow() ) );
575  connect( TimeStep, SIGNAL( scaleChanged(float) ), data(), SLOT( setTimeDirection( float ) ) );
576  connect( TimeStep, SIGNAL( scaleChanged(float) ),
577  data()->clock(), SLOT( setClockScale( float )) );
578  connect( TimeStep, SIGNAL( scaleChanged(float) ), map(), SLOT( setFocus() ) );
579 
580 
581  //Initialize Observing List
582  obsList = new ObservingList( this );
583  eWriter = new EquipmentWriter();
584  oAdd = new ObserverAdd;
585 
586  //Do not start the clock if "--paused" specified on the cmd line
587  if ( StartClockRunning )
588  data()->clock()->start();
589 
590  // Connect cache function for Find dialog
591  connect( data(), SIGNAL( clearCache() ), this,
592  SLOT( clearCachedFindDialog() ) );
593 
594  //Propagate config settings
595  applyConfig( false );
596 
597  //show the window. must be before kswizard and messageboxes
598  show();
599 
600  //Initialize focus
601  initFocus();
602 
603  data()->setFullTimeUpdate();
604  updateTime();
605 
606  //If this is the first startup, show the wizard
607  if ( Options::runStartupWizard() ) {
608  slotWizard();
609  }
610 
611  //Show TotD
612  KTipDialog::showTip(this, "kstars/tips");
613 
614  //DEBUG
615  kDebug() << "The current Date/Time is: " << KStarsDateTime::currentDateTime().toString();
616 }
617 
618 void KStars::initFocus() {
619  //Case 1: tracking on an object
620  if ( Options::isTracking() && Options::focusObject() != i18n("nothing") ) {
621  SkyObject *oFocus;
622  if ( Options::focusObject() == i18n("star") ) {
623  SkyPoint p( Options::focusRA(), Options::focusDec() );
624  double maxrad = 1.0;
625 
626  oFocus = data()->skyComposite()->starNearest( &p, maxrad );
627  } else {
628  oFocus = data()->objectNamed( Options::focusObject() );
629  }
630 
631  if ( oFocus ) {
632  map()->setFocusObject( oFocus );
633  map()->setClickedObject( oFocus );
634  map()->setFocusPoint( oFocus );
635  } else {
636  kWarning() << "Cannot center on "
637  << Options::focusObject()
638  << ": no object found." << endl;
639  }
640 
641  //Case 2: not tracking, and using Alt/Az coords. Set focus point using
642  //FocusRA as the Azimuth, and FocusDec as the Altitude
643  } else if ( ! Options::isTracking() && Options::useAltAz() ) {
644  SkyPoint pFocus;
645  pFocus.setAz( Options::focusRA() );
646  pFocus.setAlt( Options::focusDec() );
647  pFocus.HorizontalToEquatorial( data()->lst(), data()->geo()->lat() );
648  map()->setFocusPoint( &pFocus );
649 
650  //Default: set focus point using FocusRA as the RA and
651  //FocusDec as the Dec
652  } else {
653  SkyPoint pFocus( Options::focusRA(), Options::focusDec() );
654  pFocus.EquatorialToHorizontal( data()->lst(), data()->geo()->lat() );
655  map()->setFocusPoint( &pFocus );
656  }
657  data()->setSnapNextFocus();
658  map()->setDestination( *map()->focusPoint() );
659  map()->setFocus( map()->destination() );
660 
661  map()->showFocusCoords();
662 
663  //Check whether initial position is below the horizon.
664  if ( Options::useAltAz() && Options::showGround() &&
665  map()->focus()->alt().Degrees() < -1.0 ) {
666  QString caption = i18n( "Initial Position is Below Horizon" );
667  QString message = i18n( "The initial position is below the horizon.\nWould you like to reset to the default position?" );
668  if ( KMessageBox::warningYesNo( this, message, caption,
669  KGuiItem(i18n("Reset Position")), KGuiItem(i18n("Do Not Reset")), "dag_start_below_horiz" ) == KMessageBox::Yes ) {
670  map()->setClickedObject( NULL );
671  map()->setFocusObject( NULL );
672  Options::setIsTracking( false );
673 
674  data()->setSnapNextFocus(true);
675 
676  SkyPoint DefaultFocus;
677  DefaultFocus.setAz( 180.0 );
678  DefaultFocus.setAlt( 45.0 );
679  DefaultFocus.HorizontalToEquatorial( data()->lst(), data()->geo()->lat() );
680  map()->setDestination( DefaultFocus );
681  }
682  }
683 
684  //If there is a focusObject() and it is a SS body, add a temporary Trail
685  if ( map()->focusObject() && map()->focusObject()->isSolarSystem()
686  && Options::useAutoTrail() ) {
687  ((KSPlanetBase*)map()->focusObject())->addToTrail();
688  data()->temporaryTrail = true;
689  }
690 }
691 
692 void KStars::buildGUI() {
693  //create the texture manager
694  TextureManager::Create();
695  //create the skymap
696  skymap = SkyMap::Create();
697  connect(skymap, SIGNAL(mousePointChanged(SkyPoint*)), SLOT(slotShowPositionBar(SkyPoint*)));
698  connect(skymap, SIGNAL(zoomChanged()), SLOT(slotZoomChanged()));
699  setCentralWidget( skymap );
700 
701  //Initialize menus, toolbars, and statusbars
702  initStatusBar();
703  initActions();
704 
705  setupGUI(StandardWindowOptions (Default & ~Create));
706 
707 #ifdef Q_WS_WIN
708  createGUI("kstarsui-win.rc");
709 #else
710  createGUI("kstarsui.rc");
711 #endif
712 
713  //get focus of keyboard and mouse actions (for example zoom in with +)
714  map()->QWidget::setFocus();
715  resize( Options::windowWidth(), Options::windowHeight() );
716 
717  // check zoom in/out buttons
718  if ( Options::zoomFactor() >= MAXZOOM ) actionCollection()->action("zoom_in")->setEnabled( false );
719  if ( Options::zoomFactor() <= MINZOOM ) actionCollection()->action("zoom_out")->setEnabled( false );
720 }
Options::focusRA
static double focusRA()
Get Right Ascension of focus position.
Definition: Options.h:1018
Options::focusDec
static double focusDec()
Get Declination of focus position.
Definition: Options.h:1037
KStars::addColorMenuItem
void addColorMenuItem(const QString &name, const QString &actionName)
Add an item to the color-scheme action manu.
Definition: kstarsactions.cpp:1154
ksplanetbase.h
KStarsData::objectNamed
SkyObject * objectNamed(const QString &name)
Find object by name.
Definition: kstarsdata.cpp:345
SkyMap::AzimuthalEquidistant
Definition: skymap.h:97
Options::showAltAzField
static bool showAltAzField()
Get Display Alt/Az coordinates in the statusbar?
Definition: Options.h:334
KStarsData::clock
SimClock * clock()
Definition: kstarsdata.h:158
Options::showRADecField
static bool showRADecField()
Get Display RA/Dec coordinates in the statusbar?
Definition: Options.h:353
observeradd.h
FOV
class encapulating a Field-of-View symbol
Definition: fov.h:32
KStars::map
SkyMap * map() const
Definition: kstars.h:134
SkyMap::setFocusObject
void setFocusObject(SkyObject *o)
Set the FocusObject pointer to the argument.
Definition: skymap.cpp:365
skyobject.h
SkyMap::setDestination
void setDestination(const SkyPoint &f)
sets the destination point of the sky map.
Definition: skymap.cpp:812
FOV::readFOVs
static QList< FOV * > readFOVs()
Read list of FOVs from "fov.dat".
Definition: fov.cpp:177
SkyMap::setClickedObject
void setClickedObject(SkyObject *o)
Set the ClickedObject pointer to the argument.
Definition: skymap.cpp:361
SkyMap::setFocus
void setFocus(SkyPoint *f)
sets the central focus point of the sky map.
Definition: skymap.cpp:789
SkyMap::Gnomonic
Definition: skymap.h:101
SkyPoint::setAz
void setAz(dms az)
Sets Az, the Azimuth.
Definition: skypoint.h:152
KStarsData::setFullTimeUpdate
void setFullTimeUpdate()
The Sky is updated more frequently than the moon, which is updated more frequently than the planets...
Definition: kstarsdata.cpp:260
Options::isTracking
static bool isTracking()
Get Is tracking engaged?
Definition: Options.h:1075
QObject
Options::useGL
static bool useGL()
Get Switch to OpenGL backend.
Definition: Options.h:2740
SkyMap::Lambert
Definition: skymap.h:96
SkyMapComposite::starNearest
SkyObject * starNearest(SkyPoint *p, double &maxrad)
Definition: skymapcomposite.cpp:379
Options::setFitsDir
static void setFitsDir(const QString &v)
Set FITS Default directory.
Definition: Options.h:685
Options::focusObject
static QString focusObject()
Get Name of focused object.
Definition: Options.h:1056
fov.h
guimanager.h
Options::showGround
static bool showGround()
Get Draw opaque ground in the sky map?
Definition: Options.h:1740
MAXZOOM
#define MAXZOOM
Definition: kstarsdata.h:39
SkyMap::Create
static SkyMap * Create()
Definition: skymap.cpp:134
Options::showGeoBox
static bool showGeoBox()
Get Display the geographic InfoBox?
Definition: Options.h:203
Options::windowHeight
static uint windowHeight()
Get Height of main window, in pixels.
Definition: Options.h:391
NaN::f
const float f
Definition: nan.h:36
KStars::slotSetZoom
void slotSetZoom()
action slot: Allow user to specify a field-of-view angle for the display window in degrees...
Definition: kstarsactions.cpp:992
TimeStepBox
This composite widget consists of a TimeSpinBox (a QSpinBox), coupled with a TimeUnitBox (a second pa...
Definition: timestepbox.h:34
Options::projection
static uint projection()
Get Mapping projection algorithm.
Definition: Options.h:2310
texturemanager.h
SkyPoint
The sky coordinates of a point in the sky.
Definition: skypoint.h:50
KStars::applyConfig
void applyConfig(bool doApplyFocus=true)
Apply config options throughout the program.
Definition: kstars.cpp:165
Options::fOVNames
static QStringList fOVNames()
Get Name of selected FOV indicators.
Definition: Options.h:980
timestepbox.h
SkyMap::showFocusCoords
void showFocusCoords()
Update object name and coordinates in the Focus InfoBox.
Definition: skymap.cpp:331
TimeStepBox::tsbox
TimeSpinBox * tsbox() const
Definition: timestepbox.h:43
KStars::slotShowPositionBar
void slotShowPositionBar(SkyPoint *)
Display position in the status bar.
Definition: kstarsactions.cpp:1208
TextureManager::Create
static TextureManager * Create()
Create the instance of TextureManager.
Definition: texturemanager.cpp:38
skymapcomposite.h
Options::setIsTracking
static void setIsTracking(bool v)
Set Is tracking engaged?
Definition: Options.h:1065
MINZOOM
#define MINZOOM
Definition: kstarsdata.h:38
Options::fitsDir
static QString fitsDir()
Get FITS Default directory.
Definition: Options.h:695
KStarsDateTime::currentDateTime
static KStarsDateTime currentDateTime(KDateTime::Spec ts=KDateTime::Spec::ClockTime())
Definition: kstarsdatetime.cpp:67
KStars::slotGeoLocator
void slotGeoLocator()
action slot: open dialog for selecting a new geographic location
Definition: kstarsactions.cpp:461
skymap.h
i18nc
i18nc("string from libindi, used in the config dialog","100x")
Options::runStartupWizard
static bool runStartupWizard()
Get Run Startup Wizard when KStars launches?
Definition: Options.h:410
KStars::updateTime
void updateTime(const bool automaticDSTchange=true)
Update time-dependent data and (possibly) repaint the sky map.
Definition: kstars.cpp:334
SkyPoint::HorizontalToEquatorial
void HorizontalToEquatorial(const dms *LST, const dms *lat)
Determine the (RA, Dec) coordinates of the SkyPoint from its (Altitude, Azimuth) coordinates, given the local sidereal time and the observer's latitude.
Definition: skypoint.cpp:102
KStarsData::skyComposite
SkyMapComposite * skyComposite()
Definition: kstarsdata.h:146
Options::showTimeBox
static bool showTimeBox()
Get Display the time InfoBox?
Definition: Options.h:165
simclock.h
KStars::slotFlagManager
void slotFlagManager()
action slot: open Flag Manager
Definition: kstarsactions.cpp:397
KStars::slotTrack
void slotTrack()
action slot: Toggle whether kstars is tracking current position
Definition: kstarsactions.cpp:892
equipmentwriter.h
SkyPoint::EquatorialToHorizontal
void EquatorialToHorizontal(const dms *LST, const dms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates, given the local sidereal time and the observer's latitude.
Definition: skypoint.cpp:55
KStars::slotZoomChanged
void slotZoomChanged()
Called when zoom level is changed.
Definition: kstarsactions.cpp:972
SkyMap::Equirectangular
Definition: skymap.h:99
KStarsData::syncFOV
void syncFOV()
Synchronize list of visible FOVs and list of selected FOVs in Options.
Definition: kstarsdata.cpp:1045
Options.h
Options::showInfoBoxes
static bool showInfoBoxes()
Get Meta-option to toggle display of all InfoBoxes.
Definition: Options.h:146
QTextStream
KStars::slotSetTimeToNow
void slotSetTimeToNow()
action slot: sync kstars clock to system time
Definition: kstarsactions.cpp:600
Options::windowWidth
static uint windowWidth()
Get Width of main window, in pixels.
Definition: Options.h:372
KStarsData::setSnapNextFocus
void setSnapNextFocus(bool b=true)
Disable or re-enable the slewing animation for the next Focus change.
Definition: kstarsdata.h:194
Options::zoomFactor
static double zoomFactor()
Get Zoom Factor, in pixels per radian.
Definition: Options.h:2531
Options::showStatusBar
static bool showStatusBar()
Get Display the statusbar?
Definition: Options.h:315
Options::showFocusBox
static bool showFocusBox()
Get Display the focus InfoBox?
Definition: Options.h:184
SkyMap::Instance
static SkyMap * Instance()
Definition: skymap.cpp:141
Options::useAltAz
static bool useAltAz()
Get Use horizontal coordinate system?
Definition: Options.h:2386
KStars::data
KStarsData * data() const
Definition: kstars.h:131
KStars::clearCachedFindDialog
void clearCachedFindDialog()
Delete FindDialog because ObjNames list has changed in KStarsData due to reloading star data...
Definition: kstars.cpp:152
KSPlanetBase
A subclass of TrailObject that provides additional information needed for most solar system objects...
Definition: ksplanetbase.h:63
SimClock::start
Q_SCRIPTABLE Q_NOREPLY void start()
DBUS function to start the SimClock.
Definition: simclock.cpp:117
FOV::name
QString name() const
Definition: fov.h:46
SkyPoint::setAlt
void setAlt(dms alt)
Sets Alt, the Altitude.
Definition: skypoint.h:141
SkyMap::Stereographic
Definition: skymap.h:100
kstarsdata.h
SkyMap::setFocusPoint
void setFocusPoint(SkyPoint *f)
set the FocusPoint; the position that is to be the next Destination.
Definition: skymap.h:191
SkyMap::focusObject
SkyObject * focusObject() const
Retrieve the object which is centered in the sky map.
Definition: skymap.h:229
SkyMap::Orthographic
Definition: skymap.h:98
SkyObject
Provides all necessary information about an object in the sky: its coordinates, name(s), type, magnitude, and QStringLists of URLs for images and webpages regarding the object.
Definition: skyobject.h:46
Options::useAutoTrail
static bool useAutoTrail()
Get Automatically add trail to centered solar system body?
Definition: Options.h:2424
kstars.h
drivermanager.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:20 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