skyview.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #ifndef SKYVIEW_H
  2. #define SKYVIEW_H
  3. #include <QDeclarativeItem>
  4. class SkyViewPrivate;
  5. class SkyView : public QDeclarativeItem
  6. {
  7. Q_OBJECT
  8. Q_PROPERTY(qreal azimuth READ azimuth WRITE setAzimuth NOTIFY azimuthChanged)
  9. Q_PROPERTY(qreal altitude READ altitude WRITE setAltitude NOTIFY altitudeChanged)
  10. Q_PROPERTY(qreal fov READ fov WRITE setFov NOTIFY fovChanged)
  11. Q_PROPERTY(qreal viewportWidthHours READ viewportWidthHours NOTIFY viewportWidthHoursChanged)
  12. Q_PROPERTY(qreal viewportHeightDegrees READ viewportHeightDegrees NOTIFY viewportHeightDegreesChanged)
  13. public:
  14. explicit SkyView(QDeclarativeItem *parent = 0);
  15. virtual ~SkyView();
  16. /** @overload QDeclarativeItem::paint()
  17. */
  18. void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
  19. /** Get current view azimuth.
  20. * @return azimuth in hours.
  21. */
  22. qreal azimuth() const;
  23. /** Get current view altitude.
  24. * @return altitude in degrees.
  25. */
  26. qreal altitude() const;
  27. /** Get current field of view setting.
  28. * @return field of view in radians.
  29. */
  30. qreal fov() const;
  31. /** Get current viewport width in decimal hours.
  32. * @return viewport width in decimal hours.
  33. */
  34. qreal viewportWidthHours() const;
  35. /** Get current vieport height in decimal degrees.
  36. * @return viewport height in decimal degrees.
  37. */
  38. qreal viewportHeightDegrees() const;
  39. signals:
  40. /** Emitted when view azimuth changes.
  41. */
  42. void azimuthChanged();
  43. /** Emitted when view altitude changes.
  44. */
  45. void altitudeChanged();
  46. /** Emitted when field of view changes.
  47. */
  48. void fovChanged();
  49. /** Emitted when field of view changes.
  50. */
  51. void viewportWidthHoursChanged();
  52. /** Emitted when field of view changes.
  53. */
  54. void viewportHeightDegreesChanged();
  55. public slots:
  56. /** Set new view azimuth.
  57. * @param azimuth new azimuth in hours.
  58. */
  59. void setAzimuth(qreal azimuth);
  60. /** Set new view altitude.
  61. * @param altitude new altitude in degrees.
  62. */
  63. void setAltitude(qreal altitude);
  64. /** Set new field of view.
  65. * @param fov new field of view in radians.
  66. */
  67. void setFov(qreal fov);
  68. private:
  69. friend class SkyViewPrivate;
  70. SkyViewPrivate* const d;
  71. /** Paint sky view background
  72. * @param painter painter as passed to paint().
  73. */
  74. void paintGrid(QPainter* painter) const;
  75. /** Paint sky objects
  76. * @param painter painter as passed to paint().
  77. */
  78. void paintObjects(QPainter* painter) const;
  79. /** Map given RA and DEC to screen coordinates.
  80. * @param ra the right ascension in radians.
  81. * @param dec the declination in radians.
  82. * @return a point in screen coordinates.
  83. */
  84. QPoint mapToScreenPoint(qreal ra, qreal dec) const;
  85. /** Get azimuth of left edge of viewport in hours.
  86. * @return azimuth of left edge of viewport in hours.
  87. */
  88. qreal leftEdgeAzimuth() const;
  89. };
  90. #endif // SKYVIEW_H