skymap.h 24.9 KB
Newer Older
Chris Howells's avatar
adding  
Chris Howells committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/***************************************************************************
                          skymap.h  -  K Desktop Planetarium
                             -------------------
    begin                : Sat Feb 10 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.                                   *
 *                                                                         *
 ***************************************************************************/

18 19
#ifndef SKYMAP_H_
#define SKYMAP_H_
Chris Howells's avatar
adding  
Chris Howells committed
20

21
#define USEGL
22

23
#include <QTimer>
24
#include <QGraphicsView>
Laurent Montel's avatar
q3to4  
Laurent Montel committed
25
#include <QPixmap>
26
#include <QTime>
Chris Howells's avatar
adding  
Chris Howells committed
27

28

29 30
#include "skyobjects/skypoint.h"
#include "skyobjects/skyline.h"
Chris Howells's avatar
adding  
Chris Howells committed
31

32 33 34
#include "skymapdrawabstract.h"
#include "skymapqdraw.h"

35 36
#include <config-kstars.h>

37
#define HOVER_INTERVAL 500
Jason Harris's avatar
Jason Harris committed
38

39 40 41
class QPainter;
class QPaintDevice;
class QPixmap;
42

43 44
//DEBUG_KIO_JOB
class KJob;
45 46 47 48 49

class dms;
class KStarsData;
class KSPopupMenu;
class SkyObject;
50
class InfoBoxWidget;
Alexey Khudyakov's avatar
Alexey Khudyakov committed
51
class InfoBoxes;
52
class Projector;
53

54 55
class QGraphicsScene;

56 57 58 59 60
#ifdef HAVE_OPENGL
class SkyMapGLDraw;
class SkyMapQDraw;
#endif

61 62 63
/**@class SkyMap
	*
	*This is the canvas on which the sky is painted.  It's the main widget for KStars.
64
	*Contains SkyPoint members for the map's Focus (current central position), Destination
65 66 67
	*(requested central position), FocusPoint (next queued position to be focused),
	*MousePoint (position of mouse cursor), and ClickedPoint (position of last mouse click).
	*Also contains the InfoBoxes for on-screen data display.
Laurent Montel's avatar
Laurent Montel committed
68
	*
69
	*SkyMap handles most user interaction events (both mouse and keyboard).
Chris Howells's avatar
adding  
Chris Howells committed
70
	*
71
	*@short Canvas widget for displaying the sky bitmap; also handles user interaction events.
Chris Howells's avatar
adding  
Chris Howells committed
72
	*@author Jason Harris
73
	*@version 1.0
Chris Howells's avatar
adding  
Chris Howells committed
74 75
	*/

76
class SkyMap : public QGraphicsView {
77

78 79
    Q_OBJECT;
        
80 81
    friend class SkyMapDrawAbstract; // FIXME: SkyMapDrawAbstract requires a lot of access to SkyMap
    friend class SkyMapQDraw; // FIXME: SkyMapQDraw requires access to computeSkymap
82

83
 protected:
84 85 86 87
    /**
    *Constructor.  Read stored settings from KConfig object (focus position,
    *zoom factor, sky color, etc.).  Run initPopupMenus().
    */
88
    explicit SkyMap();
89

90
 public:
91
    static SkyMap* Create();
Chris Howells's avatar
adding  
Chris Howells committed
92

93
    static SkyMap* Instance();
94

95
    static bool IsSlewing() { return pinstance->isSlewing(); }
Chris Howells's avatar
adding  
Chris Howells committed
96

97
    /** Destructor (empty) */
98 99
    ~SkyMap();

Alexey Khudyakov's avatar
Alexey Khudyakov committed
100 101 102 103 104 105 106
    enum Projection { Lambert,
                      AzimuthalEquidistant,
                      Orthographic,
                      Equirectangular,
                      Stereographic,
                      Gnomonic,
                      UnknownProjection };
107 108 109 110 111 112
		      
    /**@return the angular field of view of the sky map, in degrees. 	 
    *@note it must use either the height or the width of the window to calculate the 	 
    *FOV angle.  It chooses whichever is larger. 	 
    */ 	 
    float fov();
113

114
    /**@short Update object name and coordinates in the Focus InfoBox */
115
    void showFocusCoords();
116

117
    /**@short Update the focus position according to current options. */
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
    void updateFocus();

    /**@short Retrieve the Focus point; the position on the sky at the
    	*center of the skymap.
    	*@return a pointer to the central focus point of the sky map
    	*/
    SkyPoint* focus() { return &Focus; }

    /**@short retrieve the Destination position.
    	*
    	*The Destination is the point on the sky to which the focus will
    	*be moved.  
    	*
    	*@return a pointer to the destination point of the sky map
    	*/
    SkyPoint* destination() { return &Destination; }

    /**@short retrieve the FocusPoint position.
    	*
    	*The FocusPoint stores the position on the sky that is to be 
    	*focused next.  This is not exactly the same as the Destination 
    	*point, because when the Destination is set, it will begin slewing 
    	*immediately.
    	*
    	*@return a pointer to the sky point which is to be focused next.
    	*/
    SkyPoint* focusPoint() { return &FocusPoint; }

    /**@short sets the central focus point of the sky map.
    	*@param f a pointer to the SkyPoint the map should be centered on
    	*/
    void setFocus( SkyPoint *f );

    /**@short sets the focus point of the skymap, using ra/dec coordinates
    	*
    	*@note This function behaves essentially like the above function.  
    	*It differs only in the data types of its arguments.
    	*
    	*@param ra the new right ascension
    	*@param dec the new declination
    	*/
    void setFocus( const dms &ra, const dms &dec );

    /**@short sets the focus point of the sky map, using its alt/az coordinates
    	*@param alt the new altitude
    	*@param az the new azimuth
    	*/
    void setFocusAltAz( const dms &alt, const dms & az);

    /**@short sets the destination point of the sky map.
    	*@note setDestination() emits the destinationChanged() SIGNAL,
    	*which triggers the SLOT function SkyMap::slewFocus().  This
    	*function iteratively steps the Focus point toward Destination, 
    	*repainting the sky at each step (if Options::useAnimatedSlewing()==true).
    	*@param f a pointer to the SkyPoint the map should slew to
    	*/
    void setDestination( SkyPoint *f );

    /**@short sets the destination point of the skymap, using ra/dec coordinates.
    	*
    	*@note This function behaves essentially like the above function.  
    	*It differs only in the data types of its arguments.
    	*
    	*@param ra the new right ascension
    	*@param dec the new declination
    	*/
    void setDestination( const dms &ra, const dms &dec );

    /**@short sets the destination point of the sky map, using its alt/az coordinates.
    	*@param alt the new altitude
    	*@param az the new azimuth
    	*/
    void setDestinationAltAz( const dms &alt, const dms & az);

    /**@short set the FocusPoint; the position that is to be the next Destination.
    	*@param f a pointer to the FocusPoint SkyPoint.
    	*/
195
    void setFocusPoint( SkyPoint *f ) { if ( f ) FocusPoint = *f; }
196 197 198 199 200 201 202 203

    /**@short Retrieve the ClickedPoint position.
    	*
    	*When the user clicks on a point in the sky map, the sky coordinates of the mouse
    	*cursor are stored in the private member ClickedPoint.  This function retrieves
    	*a pointer to ClickedPoint.
    	*@return a pointer to ClickedPoint, the sky coordinates where the user clicked.
    	*/
Akarsh Simha's avatar
Akarsh Simha committed
204
    SkyPoint* clickedPoint() { return &ClickedPoint; }
205 206 207 208

    /**@short Set the ClickedPoint to the skypoint given as an argument.
    	*@param f pointer to the new ClickedPoint.
    	*/
209
    void setClickedPoint( SkyPoint *f );
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224

    /**@short Retrieve a pointer to MousePoint, the sky coordinates of the mouse cursor.
    	*
    	*When the user moves the mouse in the sky map, the sky coordinates of the mouse
    	*cursor are continually stored in MousePoint by the function mouseMoveEvent().  
    	*@return a pointer to MousePoint, the current sky coordinates of the mouse cursor.
    	*/
    SkyPoint* mousePoint() { return &MousePoint; }

    /**@short Set the MousePoint to the skypoint given as an argument.
    	*@note In this function, the argument is a SkyPoint, not a pointer to a SkyPoint.
    	*This is because setMousePoint always uses the function dXdYToRaDec() for the 
    	*argument, and this function returns by value.
    	*@param f the new MousePoint (typically the output of dXdYToRaDec()).
    	*/
225
    void setMousePoint( SkyPoint f ) { MousePoint = f; }
226 227 228 229 230 231 232 233

    /**@short Retrieve the object nearest to a mouse click event.
    	*
    	*If the user clicks on the sky map, a pointer to the nearest SkyObject is stored in
    	*the private member ClickedObject.  This function returns the ClickedObject pointer,
    	*or NULL if there is no CLickedObject.
    	*@return a pointer to the object nearest to a user mouse click.
    	*/
234
    SkyObject* clickedObject() const { return ClickedObject; }
235 236 237 238

    /**@short Set the ClickedObject pointer to the argument.
    	*@param o pointer to the SkyObject to be assigned as the ClickedObject
    	*/
239
    void setClickedObject( SkyObject *o );
240 241 242 243 244 245 246 247 248

    /**@short Retrieve the object which is centered in the sky map.
    	*
    	*If the user centers the sky map on an object (by double-clicking or using the
    	*Find Object dialog), a pointer to the "focused" object is stored in
    	*the private member FocusObject.  This function returns a pointer to the 
    	*FocusObject, or NULL if there is not FocusObject.
    	*@return a pointer to the object at the center of the sky map.
    	*/
249
    SkyObject* focusObject() const { return FocusObject; }
250 251 252 253 254 255 256 257 258 259 260 261 262 263

    /**@short Set the FocusObject pointer to the argument.
    	*@param o pointer to the SkyObject to be assigned as the FocusObject
    	*/
    void setFocusObject( SkyObject *o );

    /**@short Retrieve the object nearest to the point at which the mouse has hovered.
    	*
    	*When the mouse hovers near an object, it is set as the TransientObject (so named
    	*because a transient name label will be attached to it).  This function returns 
    	*a pointer to the current TransientObject, or NULL if no TransientObject is set.
    	*@return pointer to the SkyObject nearest to the mouse hover position.
    	*@see SkyMap::slotTransientLabel()
    	*/
264
    SkyObject* transientObject() const { return TransientObject; }
265 266 267 268 269 270

    /**@short Set the TransientObject pointer to the argument.
    	*@param o pointer to the SkyObject to be assigned as the TransientObject.
    	*/
    void setTransientObject( SkyObject *o ) { TransientObject = o; }

Henry de Valence's avatar
Purge.  
Henry de Valence committed
271 272 273
    /** @short Call to set up the projector before a draw cycle.
      */
    void setupProjector();
274

275
    /** Set zoom factor. */
276 277
    void setZoomFactor(double factor);

278 279 280 281
    bool isSlewing() const;

    bool isPointNull( const QPointF &p );

282
    // NOTE: This method is draw-backend independent.
283
    /**@short update the geometry of the angle ruler. */
284 285 286 287 288 289 290 291 292 293
    void updateAngleRuler();

    /**@return true if the object currently has a user label attached.
    	*@note this function only checks for a label explicitly added to the object
    	*with the right-click popup menu; other kinds of labels are not detected by
    	*this function.
    	*@param o pointer to the sky object to be tested for a User label.
    	*/
    bool isObjectLabeled( SkyObject *o );

294
    /*@*@short Convenience function for shutting off tracking mode.  Just calls KStars::slotTrack().
295 296 297
    	*/
    void stopTracking();

298 299 300 301
    /** Get the current projector.
        @return a pointer to the current projector. */
    const Projector * projector() const;

302
    // NOTE: These dynamic casts must not segfault. If they do, it's good because we know that there is a problem.
303 304
    /**
     *@short Proxy method for SkyMapDrawAbstract::exportSkyImage()
305
     */
306
    inline void exportSkyImage( QPaintDevice *pd ) { dynamic_cast<SkyMapDrawAbstract *>(m_SkyMapDraw)->exportSkyImage( pd ); }
307 308 309 310

    /**
     *@short Proxy method for SkyMapDrawAbstract::drawObjectLabels()
     */
311
    inline void drawObjectLabels( QList< SkyObject* >& labelObjects ) { dynamic_cast<SkyMapDrawAbstract *>(m_SkyMapDraw)->drawObjectLabels( labelObjects ); }
312 313


314

Chris Howells's avatar
adding  
Chris Howells committed
315
public slots:
316 317 318
    //DEBUG_KIO_JOB
    void slotJobResult( KJob *j );

319
    /**@short This overloaded function is used internally to resize the Sky pixmap to match the window size. */
320 321 322
    virtual void setGeometry( int x, int y, int w, int h );

    /**@short This overloaded function is used internally to resize the Sky pixmap to match the window size.
323 324
     * This function behaves essentially like the above function.  It differs only in the data types 	*of its arguments.
     */
325 326 327
    virtual void setGeometry( const QRect &r );

    /**Recalculates the positions of objects in the sky, and then repaints the sky map.
328 329 330 331
     * If the positions don't need to be recalculated, use update() instead of forceUpdate().
     * This saves a lot of CPU time.
     * @param now if true, paintEvent() is run immediately.  Otherwise, it is added to the event queue
     */
332 333 334
    void forceUpdate( bool now=false );

    /**@short Convenience function; simply calls forceUpdate(true).
335 336
     * @see forceUpdate()
     */
337 338
    void forceUpdateNow() { forceUpdate( true ); }

339 340 341 342 343 344 345 346 347 348 349 350
    /** Toggle visibility of geo infobox */
    void slotToggleGeoBox(bool);

    /** Toggle visibility of focus infobox */
    void slotToggleFocusBox(bool);

    /** Toggle visibility of time infobox */
    void slotToggleTimeBox(bool);

    /** Toggle visibility of all infoboxes */
    void slotToggleInfoboxes(bool);

351
    /**Step the Focus point toward the Destination point.  Do this iteratively, redrawing the Sky
352 353 354
     * Map after each step, until the Focus point is within 1 step of the Destination point.
     * For the final step, snap directly to Destination, and redraw the map.
     */
355
    void slewFocus();
356 357

    /**@short Center the display at the point ClickedPoint.
358 359 360 361 362 363 364 365 366
     * 
     * The essential part of the function is to simply set the Destination point, which will emit 
     * the destinationChanged() SIGNAL, which triggers the slewFocus() SLOT.  Additionally, this
     * function performs some bookkeeping tasks, such updating whether we are tracking the new 
     * object/position, adding a Planet Trail if required, etc.
     * 
     * @see destinationChanged()
     * @see slewFocus()
     */
367
    void slotCenter();
368 369

    /**@short Popup menu function: Display 1st-Generation DSS image with the Image Viewer.
370 371
     * @note the URL is generated using the coordinates of ClickedPoint.
     */
372
    void slotDSS();
373

374
    /**@short Popup menu function: Display Sloan Digital Sky Survey image with the Image Viewer.
375 376
     * @note the URL is generated using the coordinates of ClickedPoint.
     */
377
    void slotSDSS();
378 379

    /**@short Popup menu function: Show webpage about ClickedObject
380 381
     * (only available for some objects). 
     */
382 383 384
    void slotInfo();

    /**@short Popup menu function: Show image of ClickedObject
385 386
     * (only available for some objects). 
     */
387 388
    void slotImage();

389
    /**@short Popup menu function: Show the Detailed Information window for ClickedObject. */
390
    void slotDetail();
391 392

    /**Add ClickedObject to KStarsData::ObjLabelList, which stores pointers to SkyObjects which
393 394
     * have User Labels attached.
     */
395
    void slotAddObjectLabel();
396 397

    /**Remove ClickedObject from KStarsData::ObjLabelList, which stores pointers to SkyObjects which
398 399
     * have User Labels attached.
     */
400
    void slotRemoveObjectLabel();
401 402

    /**@short Add a Planet Trail to ClickedObject.
403 404 405 406 407
     * @note Trails are added simply by calling KSPlanetBase::addToTrail() to add the first point.
     * as long as the trail is not empty, new points will be automatically appended to it.
     * @note if ClickedObject is not a Solar System body, this function does nothing.
     * @see KSPlanetBase::addToTrail()
     */
408
    void slotAddPlanetTrail();
409 410

    /**@short Remove the PlanetTrail from ClickedObject.
411 412 413 414
     * @note The Trail is removed by simply calling KSPlanetBase::clearTrail().  As long as
     * the trail is empty, no new points will be automatically appended.
     * @see KSPlanetBase::clearTrail()
     */
415
    void slotRemovePlanetTrail();
416 417

    /**Popup menu function: Add a custom Image or Information URL.
418 419
     * Opens the AddLinkDialog window.
     */
420
    void addLink();
421 422

    /**Checks whether the timestep exceeds a threshold value.  If so, sets
423 424
     * ClockSlewing=true and sets the SimClock to ManualMode. 
     */
425 426
    void slotClockSlewing();

427
    // NOTE: This method is draw-backend independent.
428
    /**Enables the angular distance measuring mode. It saves the first
429 430 431
     * position of the ruler in a SkyPoint. It makes difference between
     * having clicked on the skymap and not having done so */
    void slotBeginAngularDistance();
432

433
    // NOTE: This method is draw-backend independent.
434
    /**Computes the angular distance, prints the result in the status
435 436 437 438 439 440
     * bar and disables the angular distance measuring mode
     * If the user has clicked on the map the status bar shows the 
     * name of the clicked object plus the angular distance. If 
     * the user did not clicked on the map, just pressed ], only 
     * the angular distance is printed */
    void slotEndAngularDistance();
441 442

    /**Disables the angular distance measuring mode. Nothing is printed
443 444
     * in the status bar */
    void slotCancelAngularDistance();
445

446 447 448 449
#ifdef HAVE_OPENGL
    void slotToggleGL();
#endif

450 451 452 453 454 455 456 457
#ifdef HAVE_XPLANET
    /**Run Xplanet to print a view on the screen*/
    void slotXplanetToScreen();

    /**Run Xplanet to print a view in a file */
    void slotXplanetToFile();
#endif

458
    /** Zoom in one step. */
459 460
    void slotZoomIn();

461
    /** Zoom out one step. */
462 463
    void slotZoomOut();

464
    /** Set default zoom. */
465 466
    void slotZoomDefault();

Chris Howells's avatar
adding  
Chris Howells committed
467
signals:
468
    /**Emitted by setDestination(), and connected to slewFocus().  Whenever the Destination
469 470 471 472 473
     * point is changed, slewFocus() will iteratively step the Focus toward Destination 
     * until it is reached.
     * @see SkyMap::setDestination()
     * @see SkyMap::slewFocus()
     */
474 475 476
    void destinationChanged();

    /**Emitted by SkyMap::addLink().  This Signal is used to inform the Details Dialog
477 478
     * that it needs to update its lists of URL links.
     */
479
    void linkAdded();
Laurent Montel's avatar
Laurent Montel committed
480

481
    /** Emitted when zoom level is changed. */
482
    void zoomChanged();
483 484 485 486 487 488 489

    /** Emitted when current object changed. */
    void objectChanged(SkyObject*);

    /** Emitted when pointing changed. (At least should) */
    void positionChanged(SkyPoint*);

490 491 492
    /** Emitted when position under mouse changed. */
    void mousePointChanged(SkyPoint*);

Chris Howells's avatar
adding  
Chris Howells committed
493
protected:
494
    /**Process keystrokes:
Alexey Khudyakov's avatar
Alexey Khudyakov committed
495 496 497 498 499 500 501 502 503 504
     * @li arrow keys  Slew the map
     * @li +/- keys  Zoom in and out
     * @li <i>Space</i>  Toggle between Horizontal and Equatorial coordinate systems
     * @li 0-9  Go to a major Solar System body (0=Sun; 1-9 are the major planets, except 3=Moon)
     * @li [  Place starting point for measuring an angular distance
     * @li ]  End point for Angular Distance; display measurement.
     * @li <i>Escape</i>  Cancel Angular measurement
     * @li ,/<  Step backward one time step
     * @li ./>  Step forward one time step
     */
505 506 507
    virtual void keyPressEvent( QKeyEvent *e );

    /**When keyRelease is triggered, just set the "slewing" flag to false,
Alexey Khudyakov's avatar
Alexey Khudyakov committed
508
     * and update the display (to draw objects that are hidden when slewing==true). */
509 510 511
    virtual void keyReleaseEvent( QKeyEvent *e );

    /**Determine RA, Dec coordinates of clicked location.  Find the SkyObject
Alexey Khudyakov's avatar
Alexey Khudyakov committed
512 513 514 515 516 517
     * which is nearest to the clicked location.
     *
     * If left-clicked: Set set mouseButtonDown==true, slewing==true; display
     * nearest object name in status bar.
     * If right-clicked: display popup menu appropriate for nearest object.
     */
518 519 520 521 522 523 524 525 526
    virtual void mousePressEvent( QMouseEvent *e );

    /**set mouseButtonDown==false, slewing==false */
    virtual void mouseReleaseEvent( QMouseEvent *e );

    /**Center SkyMap at double-clicked location  */
    virtual void mouseDoubleClickEvent( QMouseEvent *e );

    /**This function does several different things depending on the state of the program:
Alexey Khudyakov's avatar
Alexey Khudyakov committed
527 528 529 530 531 532 533 534
     * @li If Angle-measurement mode is active, update the end-ruler point to the mouse cursor,
     *     and continue this function.
     * @li If we are defining a ZoomBox, update the ZoomBox rectangle, redraw the screen,
     *     and return.
     * @li If dragging the mouse in the map, update focus such that RA, Dec under the mouse
     *     cursor remains constant.
     * @li If just moving the mouse, simply update the curso coordinates in the status bar.
     */
535 536 537 538 539 540
    virtual void mouseMoveEvent( QMouseEvent *e );

    /**Zoom in and out with the mouse wheel. */
    virtual void wheelEvent( QWheelEvent *e );

    /**If the skymap will be resized, the sky must be new computed. So this
541 542
     * function calls explicitly new computing of the skymap.
     */
543
    virtual void resizeEvent( QResizeEvent * );
Laurent Montel's avatar
Laurent Montel committed
544

Chris Howells's avatar
adding  
Chris Howells committed
545
private slots:
546 547 548 549 550 551
    /**Gradually fade the Transient Hover Label into the background sky color, and
    	*redraw the screen after each color change.  Once it has faded fully, set the 
    	*TransientObject pointer to NULL to remove the label.
    	*/
    void slotTransientTimeout();

552
    // NOTE: Akarsh believes that this method is backend-independent, and is pretty confident about that, but he thinks that it really requires a second inspection.
553 554 555 556 557 558 559 560 561 562 563 564 565
    /**@short attach transient label to object nearest the mouse cursor.
    	*This slot is connected to the timeout() signal of the HoverTimer, which is restarted
    	*in every mouseMoveEvent().  So this slot is executed only if the mouse does not move for 
    	*HOVER_INTERVAL msec.  It points TransientObject at the SkyObject nearest the 
    	*mouse cursor, and the TransientObject is subsequently labeled in paintEvent().
    	*Note that when TransientObject is not NULL, the next mouseMoveEvent() calls 
    	*fadeTransientLabel(), which fades the label color and then sets TransientLabel to NULL.
    	*@sa mouseMoveEvent(), paintEvent(), slotTransientTimeout(), fadeTransientLabel()
    	*/
    void slotTransientLabel();

    /**Set the shape of mouse cursor to a cross with 4 arrows. */
    void setMouseMoveCursor();
Laurent Montel's avatar
Laurent Montel committed
566

Chris Howells's avatar
adding  
Chris Howells committed
567
private:
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589

    /**@short Begin fading out the name label attached to TransientObject.
    	*
    	*mouseMoveEvent() will call fadeTransientLabel() when TransientObject is not a 
    	*NULL pointer, and the TransientTimer is not already active.  These conditions 
    	*are met when the mouse did not move for HOVER_INTERVAL msec (triggering a 
    	*TransientLabel), but the mouse has since been moved, thus ending the Hover event.  
    	*This function merely starts the TransientTimer, whose timeout SIGNAL is 
    	*connected to the slotTransientTimeout() SLOT, which handles the actual fading 
    	*of the transient label, and eventually resets TransientObject to NULL.
    	*@sa SkyMap::slotTransientLabel(), SkyMap::slotTransientTimeout()
    	*/
    void fadeTransientLabel() { TransientTimer.start( TransientTimeout ); }

    /**@short Sets the shape of the default mouse cursor to a cross.
    	*/
    void setDefaultMouseCursor();

    /**@short Sets the shape of the mouse cursor to a magnifying glass.
    	*/
    void setZoomMouseCursor();

Jason Harris's avatar
Jason Harris committed
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
    /** Calculate the zoom factor for the given keyboard modifier
     * @param modifier
     */
    double zoomFactor( const int modifier );

    /** calculate the magnitude factor (1, .5, .2, or .1) for the given
     * keyboard modifier.
     * @param modifier
     */
    double magFactor( const int modifier );

    /** Decrease the magnitude limit by a step size determined by the
     * keyboard modifier.
     * @param modifier
     */
    void decMagLimit( const int modifier );

     /** Increase the magnitude limit by a step size determined by the
     * keyboard modifier.
     * @param modifier
     */
    void incMagLimit( const int modifier );

    /** Convenience routine to either zoom in or incraase mag limit
     * depending on the Alt modifier.  The Shift and Control modiifers
     * will adjust the size of the zoom or the mag step.
     * @param modifier 
     */
    void zoomInOrMagStep( const int modifier );

    /** Convenience routine to either zoom out or decraase mag limit
     * depending on the Alt modifier.  The Shift and Control modiifers
     * will adjust the size of the zoom or the mag step.
     * @param modifier 
     */
    void zoomOutOrMagStep( const int modifier );

627 628 629 630 631 632 633 634
#ifdef HAVE_XPLANET
    /**
     * @short Strart xplanet.
     * @param outputFile Output file path.
     */
    void startXplanet ( const QString & outputFile="" );
#endif

635 636 637 638 639 640 641 642
    bool mouseButtonDown, midMouseButtonDown;
    bool mouseMoveCursor;  // true if mouseMoveEvent; needed by setMouseMoveCursor
    bool slewing, clockSlewing;
    bool computeSkymap;  //if false only old pixmap will repainted with bitBlt(), this saves a lot of cpu usage
    bool angularDistanceMode;
    int scrollCount;
    double y0;

Jason Harris's avatar
Jason Harris committed
643 644
    double m_Scale;

645 646
    KStarsData *data;
    KSPopupMenu *pmenu;
647
    SkyPoint  Focus, ClickedPoint, FocusPoint, MousePoint, Destination;
648 649
    SkyObject *ClickedObject, *FocusObject, *TransientObject;

650 651
    Projector *m_proj;

652 653 654 655 656 657 658 659
    SkyLine AngularRuler; //The line for measuring angles in the map
    QRect ZoomRect; //The manual-focus circle.

    //data for transient object labels
    QTimer TransientTimer, HoverTimer;
    QColor TransientColor;
    unsigned int TransientTimeout;

660 661 662 663
    // InfoBoxes. Used in desctructor to save state
    InfoBoxWidget* m_timeBox;
    InfoBoxWidget* m_geoBox;
    InfoBoxWidget* m_objBox;
Alexey Khudyakov's avatar
Alexey Khudyakov committed
664
    InfoBoxes*     m_iboxes;
665

666 667 668 669 670 671 672 673

    QWidget *m_SkyMapDraw; // Can be dynamic_cast<> to SkyMapDrawAbstract

    // NOTE: These are pointers to the individual widgets
    #ifdef HAVE_OPENGL
    SkyMapQDraw *m_SkyMapQDraw;
    SkyMapGLDraw *m_SkyMapGLDraw;
    #endif
674

675
    QGraphicsScene *m_Scene;
676

677
    static SkyMap* pinstance;
678

Chris Howells's avatar
adding  
Chris Howells committed
679 680 681
};

#endif