Kstars

mosaictilesmanager.h
1 /*
2  SPDX-FileCopyrightText: 2021 Jasem Mutlaq <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QGraphicsItem>
10 #include <QBrush>
11 #include <QPen>
12 
13 #include "skypoint.h"
14 
15 namespace Ekos
16 {
17 
18 class MosaicTilesManager : public QObject, public QGraphicsItem
19 {
20  Q_OBJECT
21 
22  public:
23  // TODO: make this struct a QGraphicsItem
24  typedef struct
25  {
26  QPointF pos;
28  SkyPoint skyCenter;
29  double rotation;
30  int index;
31  } OneTile;
32 
33  public:
34  MosaicTilesManager(QWidget *parent = nullptr);
35  ~MosaicTilesManager();
36 
37  public:
38  void setSkyCenter(SkyPoint center);
39  void setPositionAngle(double positionAngle);
40  void setGridDimensions(int width, int height);
41  void setSingleTileFOV(double fov_x, double fov_y);
42  void setMosaicFOV(double mfov_x, double mfov_y);
43  void setOverlap(double value);
44  void setPixelScale(const QSizeF &scale) {m_PixelScale = scale;}
45 
46  public:
47  int getWidth()
48  {
49  return m_HorizontalTiles;
50  }
51 
52  int getHeight()
53  {
54  return m_VerticalTiles;
55  }
56 
57  double getOverlap()
58  {
59  return overlap;
60  }
61 
62  double getPA()
63  {
64  return pa;
65  }
66 
67  void setPainterAlpha(int v)
68  {
69  m_PainterAlpha = v;
70  }
71 
72  public:
73  /// @internal Returns scaled offsets for a pixel local coordinate.
74  ///
75  /// This uses the mosaic center as reference and the argument resolution of the sky map at that center.
76  QSizeF adjustCoordinate(QPointF tileCoord);
77  virtual QRectF boundingRect() const override;
78  void updateTiles(QPointF skymapCenter, bool s_shaped);
79  OneTile *getTile(int row, int col);
80 
81  QList<OneTile *> getTiles() const
82  {
83  return tiles;
84  }
85 
86  protected:
87  virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
88  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
89  void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override;
90  QPointF rotatePoint(QPointF pointToRotate, QPointF centerPoint, double paDegrees);
91 
92  signals:
93  void newOffset(const QPointF &offset);
94 
95  private:
96  SkyPoint skyCenter;
97  double overlap { 0 };
98  uint8_t m_HorizontalTiles { 1 };
99  uint8_t m_VerticalTiles { 1 };
100  double fovW { 0 };
101  double fovH { 0 };
102  double mfovW { 0 };
103  double mfovH { 0 };
104  double pa { 0 };
105 
106  QSizeF m_PixelScale;
107  QBrush brush;
108  QPen pen;
109 
110  QBrush textBrush;
111  QPen textPen;
112 
113  int m_PainterAlpha { 50 };
114 
115  QPointF m_LastPosition;
116  QList<OneTile *> tiles;
117 };
118 
119 }
Q_OBJECTQ_OBJECT
Ekos is an advanced Astrophotography tool for Linux. It is based on a modular extensible framework to...
Definition: align.cpp:70
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
QTextStream & center(QTextStream &stream)
QPointF pos() const const
qreal rotation() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:55 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.