summaryrefslogtreecommitdiffstats
path: root/kstars/kstars/kstars.h
blob: 0a5c3deecc3e93bf3bdb5a98150fdca934b495f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
/***************************************************************************
                          kstars.h  -  Trinity Desktop Planetarium
                             -------------------
    begin                : Mon Feb  5 01:11:45 PST 2001
    copyright            : (C) 2001 by Jason Harris
    email                : jharris@30doradus.org
 ***************************************************************************/
/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KSTARS_H
#define KSTARS_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <dcopclient.h>
#include <kapplication.h>
#include <kmainwindow.h>
#include <tqwidget.h>

#include "kstarsinterface.h"
#include "observinglist.h"

// forward declaration is enough. We only need pointers
class TQPalette;
class TQVBoxLayout;
class KActionMenu;
class KDialogBase;
class KKey;
class KToolBar;

class dms;
class KSNewStuff;
class KStarsData;
class KStarsSplash;
class SkyMap;
class GeoLocation;
class FindDialog;
class LocationDialog;
class TimeDialog;
class InfoBoxes;
class ToggleAction;
class TimeStepBox;

//class AstroCalc;
class INDIMenu;
class INDIDriver;
class imagesequence;

/**
	*@class KStars
	*@short This is the main window for KStars.
	*In addition to the GUI elements, the class contains the program clock,
	*KStarsData, and SkyMap objects.  It also contains functions for the DCOP interface.
	*@author Jason Harris
	*@version 1.0
	*/

class KStars : public KMainWindow, virtual public KStarsInterface
{

  Q_OBJECT
  
  public:
	/**
		*@short Constructor.
		*@param doSplash should the splash panel be displayed during
		*initialization.
		*@param startClockRunning should the clock be running on startup?
		*@param startDateString date (in string representation) to start running from.
		*
		* @todo Refer to documentation on date format.
		*/
		KStars( bool doSplash, bool startClockRunning = true, const TQString &startDateString = "" );

	/**Destructor.  Synchs config file.  Deletes objects.
		*/
		~KStars();

	/**@return pointer to KStarsData object which contains application data.
		*/
		KStarsData* data();

	/**@return pointer to the local sidereal time.
		*/
		dms* LST();

	/**@return pointer to SkyMap object which is the sky display widget.
		*/
		SkyMap* map();

        ObservingList* observingList();

	/**@return pointer to GeoLocation object which is the current geographic location.
		*/
		GeoLocation* geo();

	/**@return pointer to InfoBoxes object.
		*/
		InfoBoxes* infoBoxes();

	/**@return pointer to the INDI driver
		*/
		INDIDriver* getINDIDriver(void) { return indidriver; }

	/**@return pointer to the INDI menu
		*/
		INDIMenu* getINDIMenu(void) { return indimenu; }

	/** Establish the INDI system. No GUI
		*/
		void establishINDI();

	/**Add an item to the color-scheme action manu
		*@param name The name to use in the menu
		*@param actionName The internal name for the action (derived from filename)
		*/
		void addColorMenuItem( TQString name, TQString actionName );

	/**Remove an item from the color-scheme action manu
		*@param actionName The internal name of the action (derived from filename)
		*/
		void removeColorMenuItem( TQString actionName );

	/**DCOP interface function.  
		*Set focus to given Ra/Dec coordinates 
		*@p ra the Right Ascension coordinate for the focus (in Hours)
		*@p dec the Declination coordinate for the focus (in Degrees)
		*/
		ASYNC setRaDec( double ra, double dec );

	/**DCOP interface function.  
		*Set focus to given Alt/Az coordinates. 
		*@p alt the Altitude coordinate for the focus (in Degrees)
		*@p az the Azimuth coordinate for the focus (in Degrees)
		*/
		ASYNC setAltAz(double alt, double az);

	/**DCOP interface function.
		*Point in the direction described by the string argument.  
		*@p direction either an object name, a compass direction (e.g., "north"), or "zenith"
		*/
		ASYNC lookTowards( const TQString direction );

	/**DCOP interface function.  Zoom in one step. */
		ASYNC zoomIn(void) { slotZoomIn(); }

	/**DCOP interface function.  Zoom out one step. */
		ASYNC zoomOut(void){ slotZoomOut(); }

	/**DCOP interface function.  reset to the default zoom level. */
		ASYNC defaultZoom(void) { slotDefaultZoom(); }

	/**DCOP interface function.  Set zoom level to specified value. 
		*@p a the zoom level.  Units are pixels per radian.
		*/
		ASYNC zoom(double z);

	/**DCOP interface function.  Set local time and date. 
		*@p yr year of date
		*@p mth month of date
		*@p day day of date
		*@p hr hour of time
		*@p min minute of time
		*@p sec second of time
		*/
		ASYNC setLocalTime(int yr, int mth, int day, int hr, int min, int sec);

	/**DCOP interface function.  Delay further execution of DCOP commands. 
		*@p t number of seconds to delay
		*/
		ASYNC waitFor( double t );

	/**DCOP interface function.  Pause further DCOP execution until a key is pressed. 
		*@p k the key which will resume DCOP execution
		*/
		ASYNC waitForKey( const TQString k );

	/**DCOP interface function.  Toggle tracking. 
		*@p track engage tracking if true; else disengage tracking
		*/
		ASYNC setTracking( bool track );

	/**DCOP interface function.  modify a view option. 
		*@p option the name of the option to be modified
		*@p value the option's new value
		*/
		ASYNC changeViewOption( const TQString option, const TQString value );

	/**DCOP interface function.
		*@p name the name of the option to query
		*@return the current value of the named option
		*/
		TQString getOption( const TQString &name );

	/**DCOP interface function.  Read config file. 
		*This function is useful for restoring the user settings from the config file, 
		*after having modified the settings in memory.
		*@sa writeConfig()
		*/
		ASYNC readConfig();

	/**DCOP interface function.  Write current settings to config file. 
		*This function is useful for storing user settings before modifying them with a DCOP
		*script.  The original settings can be restored with readConfig().
		*@sa readConfig()
		*/
		ASYNC writeConfig();

	/**DCOP interface function.  Show text message in a popup window. 
		*@note Not Yet Implemented
		*@p x x-coordinate for message window
		*@p y y-coordinate for message window
		*@p message the text to display in the message window
		*/
		ASYNC popupMessage( int x, int y, const TQString message );

	/**DCOP interface function.  Draw a line on the sky map. 
		*@note Not Yet Implemented
		*@p x1 starting x-coordinate of line
		*@p y1 starting y-coordinate of line
		*@p x2 ending x-coordinate of line
		*@p y2 ending y-coordinate of line
		*@p speed speed at which line should appear from start to end points (in pixels per second)
		*/
		ASYNC drawLine( int x1, int y1, int x2, int y2, int speed );

	/**DCOP interface function.  Set the geographic location. 
		*@p city the city name of the location
		*@p province the province name of the location
		*@p country the country name of the location
		*/
		ASYNC setGeoLocation( const TQString city, const TQString province, const TQString country );

	/**DCOP interface function.  Modify a color. 
		*@p colorName the name of the color to be modified (e.g., "SkyColor")
		*@p value the new color to use
		*/
		ASYNC setColor( const TQString colorName, const TQString value );

	/**DCOP interface function.  Load a color scheme. 
		*@p name the name of the color scheme to load (e.g., "Moonless Night")
		*/
		ASYNC loadColorScheme( const TQString name );

	/**DCOP interface function.  Export the sky image to a file. 
		*@p filename the filename for the exported image
		*@p width the width for the exported image
		*@p height the height for the exported image
		*/
		ASYNC exportImage( const TQString filename, int width, int height );

	/**DCOP interface function.  Print the sky image. 
		*@p usePrintDialog if true, the TDE print dialog will be shown; otherwise, default parameters will be used
		*@p useChartColors if true, the "Star Chart" color scheme will be used for the printout, which will save ink.
		*/
		ASYNC printImage( bool usePrintDialog, bool useChartColors );
		
	/**DCOP interface function.  Establish an INDI driver. 
		*@p driverName the name of the driver to be established
		*@p useLocal establish driver locally?
		*/
		ASYNC startINDI (TQString driverName, bool useLocal);
		
	/**DCOP interface function. Shutdown an INDI driver. 
		*@p driverName the name of the driver to be shut down
		*/
		ASYNC shutdownINDI (TQString driverName);
		
	/**DCOP interface function.  Turn INDI driver on/off. 
		*@p driverName the name of the driver to be switched on/off
		*@p turnOn if true, turn driver on; otherwise turn off
		*/
		ASYNC switchINDI(TQString driverName, bool turnOn);
	
	/**DCOP interface function.  Set INDI connection port. 
		*@p driverName the name of the driver for which the port will be set
		*@p port the port identifier
		*/
		ASYNC setINDIPort(TQString driverName, TQString port);
	
	/**DCOP interface function.  Set INDI target RA/DEC coordinates
		*@p driverName the name of the driver 
		*@p RA the target's Right Ascension coordinate (in Hours) 
		*@p DEC the target's Declination coordinate (in Degrees) 
		*/
		ASYNC setINDITargetCoord(TQString driverName, double RA, double DEC);
	
	/**DCOP interface function.  Set INDI target to a named object. 
		*@p driverName the name of the driver 
		*@p objectName the name of the object to be targeted
		*/
		ASYNC setINDITargetName(TQString driverName, TQString objectName);
	
	/**DCOP interface function.  Set INDI action. 
		*@p driverName the name of the driver 
		*@p action the action to set
		*/
		ASYNC setINDIAction(TQString driverName, TQString action);
	
	/**DCOP interface function.  Pause DCOP execution until named INDI action is completed. 
		*@p driverName the name of the driver 
		*@p action the action which is to be completed before resuming DCOP execution
		*/
		ASYNC waitForINDIAction(TQString driverName, TQString action);
	
	/**DCOP interface function.  Set INDI focus speed. 
		*@p driverName the name of the driver 
		*@p action the name of the action (??)
		*/
		ASYNC setINDIFocusSpeed(TQString driverName,unsigned int speed);
	
	/**DCOP interface function.  Set INDI focus direction and focus. 
		*@p driverName the name of the driver 
		*@p focusDir 0 = focus in; 1 = focus out
		*/
		ASYNC startINDIFocus(TQString driverName, int focusDir);
	
	/**DCOP interface function.  Set INDI geographical information. 
		*@p driverName the name of the driver 
		*@p longitude the longitude to set, in Degrees
		*@p latitude the latitude to set, in Degrees
		*/
		ASYNC setINDIGeoLocation(TQString driverName, double longitude, double latitude);
	
	/**DCOP interface function.  Sets focus operation timeout. 
		*@p driverName the name of the driver 
		*@p timeout the timeout interval, in seconds (?)
		*/
		ASYNC setINDIFocusTimeout(TQString driverName, int timeout);
	
	/**DCOP interface function.  Start camera exposure with a timeout. 
		*@p driverName the name of the driver 
		*@p timeout the exposure time, in seconds (?)
		*/
		ASYNC startINDIExposure(TQString driverName, int timeout);
		
	/**DCOP interface function.  Set INDI UTC date and time. 
		*@p driverName the name of the driver 
		*@p UTCDateTime the UTC date and time (e.g., "23 June 2004 12:30:00" ?)
		*/
		ASYNC setINDIUTC(TQString driverName, TQString UTCDateTime);
	
	/**DCOP interface function. Set INDI Telescope action. 
		*@p deviceName the name of the telescope device 
		*@p action the action to set
		*/
		ASYNC setINDIScopeAction(TQString deviceName, TQString action);
		
	/**DCOP interface function. Set CCD camera frame type. 
		*@p deviceName the name of the CCD device 
		*@p type the frame type
		*/
		ASYNC setINDIFrameType(TQString deviceName, TQString type);
		
	/**DCOP interface function. Set CCD filter. 
		*@p deviceName the name of the CCD device 
		*@p filter_num identifier of the CCD filter
		*/
		ASYNC setINDIFilterNum(TQString deviceName, int filter_num);

	/**DCOP interface function. Set CCD target temperature. 
		*@p deviceName the name of the CCD device 
		*@p temp the target CCD temperature (in Celsius ?)
		*/
		ASYNC setINDICCDTemp(TQString deviceName, int temp);
		

	/**@short Apply config options throughout the program.
		*In most cases, options are set in the "Options" object directly, 
		*but for some things we have to manually react to config changes.
		*/
		void applyConfig();

	public slots:
		/**
			*Update time-dependent data and (possibly) repaint the sky map.
			*@p automaticDSTchange change DST status automatically?
			*/
		void updateTime( const bool automaticDSTchange = true );

		/**
			*Apply new settings and redraw skymap
			*/
		void slotApplyConfigChanges( void );

		/**
			*action slot: Zoom in one step
			*/
		void slotZoomIn();

		/**
			*action slot: Zoom out one step
			*/
		void slotZoomOut();

		/**
			*action slot: Set the zoom level to its default value
			*/
		void slotDefaultZoom();

		/**
			*action slot: Allow user to specify a field-of-view angle for the display window in degrees, 
			*and set the zoom level accordingly.
			*/
		void slotSetZoom();

	/**
		*action slot: Toggle whether kstars is tracking current position
		*/
		void slotTrack();

	/**
		*action slot: open dialog for selecting a new geographic location
		*/
		void slotGeoLocator();

	/**Delete FindDialog because ObjNames list has changed in KStarsData due to
		*reloading star data. So list in FindDialog must be new filled with current data.
		*/
		void clearCachedFindDialog();

	/**
		*Resume execution of DCOP commands
		*/
		void resumeDCOP( void ) { kapp->dcopClient()->resume(); }

	/**
		*Remove all trails which may have been added to solar system bodies
		*/
		void slotClearAllTrails();

	private slots:
		/**
			*action slot: sync kstars clock to system time
			*/
		void slotSetTimeToNow();

		/**
			*action slot: open a dialog for setting the time and date
			*/
		void slotSetTime();

		/**
			*action slot: toggle whether kstars clock is running or not
			*/
		void slotToggleTimer();

		/**
			*action slot: open dialog for finding a named object
			*/
		void slotFind();

		/**
		 * action slot: open KStars setup wizard
		 */
		void slotWizard();

		/**
		 * action slot: open KNewStuff window to download extra data.
		 */
		void slotDownload();

		/**
		 * action slot: open KStars calculator to compute astronomical
		 * ephemeris
		 */

		void slotCalculator();

		/**
		 * action slot: open KStars AAVSO Light Curve Generator
		 */

		void slotLCGenerator();

		/**
		* action slot: open Elevation vs. Time tool
		*/

		void slotAVT();

		/**
		 * action slot: open What's up tonight dialog
		 */
		 void slotWUT();

//FIXME GLOSSARY
//		 /**
//		  * action slot: open the glossary
//		  */
//		 void slotGlossary();

		/**
		 * action slot: open ScriptBuilder dialog
		 */
		void slotScriptBuilder();

		/**
		 * action slot: open Solar system viewer
		 */
		void slotSolarSystem();

		/**
		 * action slot: open Jupiter Moons tool
		 */
		void slotJMoonTool();

		/**
		 * action slot: open Telescope wizard
		 */
		void slotTelescopeWizard();

		/**
		 * action slot: open Telescope wizard
		 */
		void slotTelescopeProperties();

		/**
		 * action slot: open Image Sequence dialog
		 */
		void slotImageSequence();
		
		 /**
		 * action slot: open INDI driver panel
		 */
		void slotINDIDriver();

		 /**
		 * action slot: open INDI control panel
		 */
		void slotINDIPanel();

		/**
		 * action slot: open INDI configuration dialog
		 */
		void slotINDIConf();

		/**
			*action slot: open dialog for setting the view options
			*/
		void slotViewOps();

		/** finish setting up after the kstarsData has finished
		 */
		void datainitFinished(bool worked);

		/**Open new KStars window. */
		void newWindow();

		/**Close KStars window. */
		void closeWindow();
		
		/** Open FITS image. */
		void slotOpenFITS();

		/**Action slot to save the sky image to a file.*/
		void slotExportImage();

		/**Action slot to select a DCOP script and run it.*/
		void slotRunScript();

		/**Action slot to print skymap. */
		void slotPrint();

		/**Action slot to show tip-of-the-day window. */
		void slotTipOfDay();

		/**Action slot to set focus coordinates manually (opens FocusDialog). */
		void slotManualFocus();

		/**Meta-slot to point the focus at special points (zenith, N, S, E, W).
			*Uses the name of the Action which sent the Signal to identify the
			*desired direction.  */
		void slotPointFocus();

		/**Meta-slot to set the color scheme according to the name of the
			*Action which sent the activating signal.  */
		void slotColorScheme();

		/**Select the Target symbol (a.k.a. field-of-view indicator) */
		void slotTargetSymbol();

		/**Invoke the Field-of-View symbol editor window */
		void slotFOVEdit();

		/**Toggle between Equatorial and Ecliptic coordinte systems */
		void slotCoordSys();

		/**Toggle display of the observing list tool*/
		void slotObsList();

		/**Meta-slot to handle display toggles for all of the viewtoolbar buttons.
			*uses the name of the sender to identify the item to change.  */
		void slotViewToolBar();

		/**Meta-slot to handle toggling display of GUI elements (toolbars and infoboxes)
			*uses name of the sender action to identify the widget to hide/show.  */
		void slotShowGUIItem( bool );

		/**Re-assign the input focus to the SkyMap widget.
			*/
		void mapGetsFocus();
		
		/**Toggle to and from full screen mode */
		void slotFullScreen();

	private:
		/**
			*Initialize Menu bar, toolbars and all Actions.
			*/
		void initActions();

		/**
			*Initialize Field-of-View symbols and FOV submenu
			*/
		void initFOV();

		/**
			*Initialize Status bar.
			*/
		void initStatusBar();

		SkyMap *skymap;

		TQWidget *centralWidget;
		TQVBoxLayout *topLayout;

		KToolBar *viewToolBar;
		TimeStepBox *TimeStep;

		ToggleAction *actCoordSys;
		ToggleAction *actObsList;
		KActionMenu *colorActionMenu, *fovActionMenu;
		
		KDialogBase *AAVSODialog;
		FindDialog *findDialog;
		KSNewStuff *kns;
		
		INDIMenu *indimenu;
		INDIDriver *indidriver;
		imagesequence *indiseq;  /* We need imgsequence here because it runs in batch mode */

		int idSpinBox;
		bool DialogIsObsolete;
		bool StartClockRunning;
		TQString StartDateString;

		TQPalette OriginalPalette, DarkPalette;

		class privatedata;
		friend class privatedata;
		privatedata *pd;
        ObservingList *obsList;
};

class KStars::privatedata {
	public:
		KStars *ks;
		KStarsSplash *splash;
		KStarsData *kstarsData;

		/**Constructor */
		privatedata(KStars *parent) : ks(parent), splash(0), kstarsData(0) {}
		/**Destructor */
		~privatedata();

		/**Build the main KStars window */
		void buildGUI();
};

#endif