Kstars

mosaictiles.h
1 /*
2  SPDX-FileCopyrightText: 2022 Jasem Mutlaq <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "skyobject.h"
10 #include "config-kstars.h"
11 
12 #include <QBrush>
13 #include <QPen>
14 #include <memory>
15 
16 #ifdef HAVE_INDI
17 #include <lilxml.h>
18 #endif
19 
20 class QPainter;
21 
22 class MosaicTiles : public SkyObject
23 {
24  public:
25  MosaicTiles();
26  ~MosaicTiles();
27 
28  public:
29 
30  /***************************************************************************************************
31  * Import/Export Functions.
32  ***************************************************************************************************/
33 #ifdef HAVE_INDI
34  /**
35  * @brief fromXML Load Scheduler XML file and parse it to create tiles in operation mode.
36  * @param filename full path to filename
37  * @return True if parsing is successful, false otherwise.
38  */
39  bool fromXML(const QString &filename);
40 #endif
41 
42  /**
43  * @brief toJSON
44  * @param output
45  * @return
46  */
47  //bool toJSON(QJsonObject &output);
48 
49  /**
50  * @brief fromJSON
51  * @param input
52  * @return
53  */
54  //bool fromJSON(const QJsonObject &input);
55 
56  /***************************************************************************************************
57  * Operation Modes
58  ***************************************************************************************************/
59  typedef enum
60  {
61  MODE_PLANNING,
62  MODE_OPERATION
63  } OperationMode;
64 
65  OperationMode m_OperationMode {MODE_PLANNING};
66  OperationMode operationMode() const { return m_OperationMode;}
67  void setOperationMode(OperationMode value) {m_OperationMode = value;}
68 
69  /***************************************************************************************************
70  * Tile Functions.
71  ***************************************************************************************************/
72  typedef struct
73  {
74  QPointF pos;
76  SkyPoint skyCenter;
77  double rotation;
78  int index;
79  } OneTile;
80 
81  bool isValid() const;
82  void createTiles(bool s_shaped);
83  void appendTile(const OneTile &value);
84  void appendEmptyTile();
85  void clearTiles();
86  void draw(QPainter *painter);
87 
88  /**
89  * @brief syncFOVs Update camera and mosaic overall FOV from current settings.
90  */
91  void syncFOVs();
92 
93  // Getters
94  // Return Sky Point
95  double focalLength() const
96  {
97  return m_FocalLength;
98  }
99  double positionAngle() const
100  {
101  return m_PositionAngle;
102  }
103  QSize cameraSize() const
104  {
105  return m_CameraSize;
106  }
107  QSizeF pixelSize() const
108  {
109  return m_PixelSize;
110  }
111  QSize gridSize() const
112  {
113  return m_GridSize;
114  }
115  double overlap() const
116  {
117  return m_Overlap;
118  }
119  // Return Camera Field of View in arcminutes
120  QSizeF cameraFOV() const
121  {
122  return m_CameraFOV;
123  }
124  // Return Mosaic Field of View in arcminutes
125  QSizeF mosaicFOV() const
126  {
127  return m_MosaicFOV;
128  }
129 
130  // Setters
131  void setFocalLength(double value)
132  {
133  m_FocalLength = value;
134  }
135  void setPositionAngle(double value);
136  void setCameraSize(const QSize &value)
137  {
138  m_CameraSize = value;
139  }
140  void setPixelSize(const QSizeF &value)
141  {
142  m_PixelSize = value;
143  }
144  void setGridSize(const QSize &value)
145  {
146  m_GridSize = value;
147  }
148  void setOverlap(double value);
149  void setCameraFOV(const QSizeF &value)
150  {
151  m_CameraFOV = value;
152  }
153  void setMosaicFOV(const QSizeF &value)
154  {
155  m_MosaicFOV = value;
156  }
157  void setPainterAlpha(int value)
158  {
159  m_PainterAlpha = value;
160  }
161  void setPainterAlphaAuto(bool value)
162  {
163  m_PainterAlphaAuto = value;
164  }
165  const QString &targetName() const {return m_TargetName;}
166  void setTargetName(const QString &value)
167  {
168  m_TargetName = value;
169  }
170  const QString &sequenceFile() const {return m_SequenceFile;}
171  void setSequenceFile(const QString &value)
172  {
173  m_SequenceFile = value;
174  }
175  const QString &outputDirectory() const {return m_OutputDirectory;}
176  void setOutputDirectory(const QString &value)
177  {
178  m_OutputDirectory = value;
179  }
180  int focusEveryN() const {return m_FocusEveryN;}
181  void setFocusEveryN(int value)
182  {
183  m_FocusEveryN = value;
184  }
185  int alignEveryN() const {return m_AlignEveryN;}
186  void setAlignEveryN(int value)
187  {
188  m_AlignEveryN = value;
189  }
190  bool isTrackChecked() const {return m_TrackChecked;}
191  bool isFocusChecked() const {return m_FocusChecked;}
192  bool isAlignChecked() const {return m_AlignChecked;}
193  bool isGuideChecked() const {return m_GuideChecked;}
194  void setStepChecks(bool track, bool focus, bool align, bool guide)
195  {
196  m_TrackChecked = track;
197  m_FocusChecked = focus;
198  m_AlignChecked = align;
199  m_GuideChecked = guide;
200  }
201 
202  // Titles
203  const QList<std::shared_ptr<OneTile>> &tiles() const
204  {
205  return m_Tiles;
206  }
207  std::shared_ptr<OneTile> oneTile(int row, int col);
208 
209  private:
210 
211  // Overall properties
212  double m_FocalLength {0};
213  QSize m_CameraSize;
214  QSizeF m_PixelSize, m_CameraFOV, m_MosaicFOV;
215  QSize m_GridSize {1, 1};
216  double m_Overlap {10};
217  double m_PositionAngle {0};
218  bool m_SShaped {false};
219  int m_PainterAlpha {50};
220  bool m_PainterAlphaAuto {true};
221  QString m_TargetName;
222  QString m_SequenceFile;
223  QString m_OutputDirectory;
224  int m_FocusEveryN {1};
225  int m_AlignEveryN {1};
226  bool m_TrackChecked {true}, m_FocusChecked {true}, m_AlignChecked {true}, m_GuideChecked {true};
227 
228  QBrush m_Brush;
229  QPen m_Pen;
230  QBrush m_TextBrush;
231  QPen m_TextPen;
232 
234 
235  /**
236  * @brief adjustCoordinate This uses the mosaic center as reference and the argument resolution of the sky map at that center.
237  * @param tileCoord point to adjust
238  * @return Returns scaled offsets for a pixel local coordinate.
239  */
240  QSizeF adjustCoordinate(QPointF tileCoord);
241  void updateTiles();
242 
243  bool processJobInfo(XMLEle *root, int index);
244 
245  QPointF rotatePoint(QPointF pointToRotate, QPointF centerPoint, double paDegrees);
246 
247  QSizeF calculateTargetMosaicFOV() const;
248  QSize mosaicFOVToGrid() const;
249  QSizeF calculateCameraFOV() const;
250 
251 
252  private:
253 };
254 
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
bool isValid(QStringView ifopt)
QTextStream & center(QTextStream &stream)
Information about an object in the sky.
Definition: skyobject.h:41
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.