Stellarium 0.14.3
Oculars.hpp
1 /*
2  * Copyright (C) 2009 Timothy Reaves
3  * Copyright (C) 2011 Bogdan Marinov
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef _OCULARS_HPP_
21 #define _OCULARS_HPP_
22 
23 #include "CCD.hpp"
24 #include "Lens.hpp"
25 #include "Ocular.hpp"
26 #include "OcularDialog.hpp"
27 #include "StelModule.hpp"
28 #include "StelTexture.hpp"
29 #include "Telescope.hpp"
30 #include "VecMath.hpp"
31 
32 #include <QFont>
33 #include <QSettings>
34 
35 #define MIN_OCULARS_INI_VERSION 2
36 
37 QT_BEGIN_NAMESPACE
38 class QKeyEvent;
39 class QMenu;
40 class QMouseEvent;
41 class QPixmap;
42 class QSettings;
43 class QSignalMapper;
44 QT_END_NAMESPACE
45 
46 class StelButton;
47 class StelAction;
48 
72 class Oculars : public StelModule
76 {
77  Q_OBJECT
78  //BM: Temporary, until the GUI is finalized and some other method of getting
79  //info from the main class is implemented.
80  friend class OcularsGuiPanel;
81 
82 public:
83  Oculars();
84  virtual ~Oculars();
85  static QSettings* appSettings();
86 
88  // Methods defined in the StelModule class
89  virtual void init();
90  virtual void deinit();
91  virtual bool configureGui(bool show=true);
92  virtual void draw(StelCore* core);
93  virtual double getCallOrder(StelModuleActionName actionName) const;
96  virtual const StelStyle getModuleStyleSheet(const StelStyle& style);
100  virtual void handleKeys(class QKeyEvent* event);
101  virtual void handleMouseClicks(class QMouseEvent* event);
102  virtual void update(double) {;}
103  double ccdRotationAngle() const;
104 
105  QString getDimensionsString(double fovX, double fovY) const;
106  QString getFOVString(double fov) const;
107 
108 public slots:
112  void updateLists();
113  void ccdRotationReset();
114  void decrementCCDIndex();
115  void decrementOcularIndex();
116  void decrementTelescopeIndex();
117  void decrementLensIndex();
118  void displayPopupMenu();
121  void enableOcular(bool b);
122  void incrementCCDIndex();
123  void incrementOcularIndex();
124  void incrementTelescopeIndex();
125  void incrementLensIndex();
126  void disableLens();
127  void rotateCCD(QString amount);
128  void selectCCDAtIndex(QString indexString);
129  void selectOcularAtIndex(QString indexString);
130  void selectTelescopeAtIndex(QString indexString);
131  void selectLensAtIndex(QString indexString);
132  void toggleCCD(bool show);
135  void toggleCCD();
136  void toggleCrosshairs(bool show = true);
138  void toggleTelrad(bool show);
140  void toggleTelrad();
141  void enableGuiPanel(bool enable = true);
142 
143  void setFlagDecimalDegrees(const bool b);
144  bool getFlagDecimalDegrees(void) const;
145 
146  void setFlagLimitMagnitude(const bool b);
147  bool getFlagLimitMagnitude(void) const;
148 
149  void setFlagInitFovUsage(const bool b);
150  bool getFlagInitFovUsage(void) const;
151 
152  void setFlagUseFlipForCCD(const bool b);
153  bool getFlagUseFlipForCCD(void) const;
154 
155  void setFlagUseSemiTransparency(const bool b);
156  bool getFlagUseSemiTransparency(void) const;
157 
158 signals:
159  void selectedCCDChanged();
160  void selectedOcularChanged();
161  void selectedTelescopeChanged();
162  void selectedLensChanged();
163 
164 private slots:
166  void instrumentChanged();
167  void determineMaxEyepieceAngle();
168  void setRequireSelection(bool state);
169  void setScaleImageCircle(bool state);
170  void setScreenFOVForCCD();
171  void retranslateGui();
172  void setStelStyle(const QString& style);
173  void updateOcularReticle(void);
174 
175 private:
177  void initializeActivationActions();
178 
180  bool isBinocularDefined();
181 
183  void paintCCDBounds();
185  void paintCrosshairs();
187  void paintOcularMask(const StelCore * core);
189  void paintTelrad();
190 
193  void paintText(const StelCore * core);
194 
196  void unzoomOcular();
197 
204  void validateAndLoadIniFile();
205 
209  void zoom(bool zoomedIn);
210 
212  void zoomOcular();
213 
214  void hideUsageMessageIfDisplayed();
215 
217  QMenu* addLensSubmenu(QMenu* parent);
218 
220  QMenu* addTelescopeSubmenu(QMenu* parent);
221 
223  Lens* selectedLens();
224 
226  QList<CCD *> ccds;
227  QList<Ocular *> oculars;
228  QList<Telescope *> telescopes;
229  QList<Lens *> lense;
230 
231  int selectedCCDIndex;
232  int selectedOcularIndex;
233  int selectedTelescopeIndex;
234  int selectedLensIndex;
235 
236  QFont font;
237  bool flagShowCCD;
238  bool flagShowOculars;
239  bool flagShowCrosshairs;
240  bool flagShowTelrad;
241  int usageMessageLabelID;
242 
243  bool flagAzimuthalGrid;
244  bool flagGalacticGrid;
245  bool flagEquatorGrid;
246  bool flagEquatorJ2000Grid;
247  bool flagEquatorLine;
248  bool flagEclipticLine;
249  bool flagEclipticJ2000Grid;
250  bool flagMeridianLine;
251  bool flagLongitudeLine;
252  bool flagHorizonLine;
253  bool flagGalacticEquatorLine;
254  bool flagAdaptation;
255 
256  bool flagLimitStars;
257  float magLimitStars;
258  bool flagLimitDSOs;
259  float magLimitDSOs;
260  bool flagLimitPlanets;
261  float magLimitPlanets;
262 
263  bool flagMoonScale;
264 
265  double maxEyepieceAngle;
266  bool requireSelection;
267  bool flagLimitMagnitude;
268  bool useMaxEyepieceAngle;
269  bool guiPanelEnabled;
271  bool flagDecimalDegrees;
272  bool flagSemiTransporency;
273 
274  QSignalMapper * ccdRotationSignalMapper;
275  QSignalMapper * ccdsSignalMapper;
276  QSignalMapper * ocularsSignalMapper;
277  QSignalMapper * telescopesSignalMapper;
278  QSignalMapper * lenseSignalMapper;
279 
280  // for toolbar button
281  QPixmap * pxmapGlow;
282  QPixmap * pxmapOnIcon;
283  QPixmap * pxmapOffIcon;
284  StelButton * toolbarButton;
285 
286  OcularDialog *ocularDialog;
287  bool ready;
288 
289  StelAction * actionShowOcular;
290  StelAction * actionShowCrosshairs;
291  StelAction * actionShowSensor;
292  StelAction * actionShowTelrad;
293  StelAction * actionConfiguration;
294  StelAction * actionMenu;
295  StelAction * actionTelescopeIncrement;
296  StelAction * actionTelescopeDecrement;
297  StelAction * actionOcularIncrement;
298  StelAction * actionOcularDecrement;
299 
300  class OcularsGuiPanel * guiPanel;
301 
302  //Styles
303  QByteArray normalStyleSheet;
304  QByteArray nightStyleSheet;
305 
306  //Reticle
307  StelTextureSP reticleTexture;
308  double actualFOV;
309  double initialFOV;
310  bool flagInitFOVUsage;
311  bool flagUseFlipForCCD;
312  double reticleRotation;
313 };
314 
315 
316 
317 #include <QObject>
318 #include "StelPluginInterface.hpp"
319 
321 class OcularsStelPluginInterface : public QObject, public StelPluginInterface
322 {
323  Q_OBJECT
324  Q_PLUGIN_METADATA(IID StelPluginInterface_iid)
325  Q_INTERFACES(StelPluginInterface)
326 public:
327  virtual StelModule* getStelModule() const;
328  virtual StelPluginInfo getPluginInfo() const;
329 };
330 
331 #endif /*_OCULARS_HPP_*/
void rotateCCD(QString amount)
amount must be a number.
Definition: Lens.hpp:31
virtual const StelStyle getModuleStyleSheet(const StelStyle &style)
Returns the module-specific style sheet.
void selectTelescopeAtIndex(QString indexString)
indexString must be an integer, in the range of -1:telescopes.count()
void toggleTelrad()
Toggles the Telrad sight overlay (overloaded for blind switching).
virtual void handleKeys(class QKeyEvent *event)
This method is needed because the MovementMgr classes handleKeys() method consumes the event...
void enableOcular(bool b)
This method is called with we detect that our hot key is pressed.
void toggleCCD()
Toggles the sensor frame overlay (overloaded for blind switching).
virtual StelPluginInfo getPluginInfo() const =0
void selectCCDAtIndex(QString indexString)
indexString must be an integer, in the range of -1:ccds.count()
void updateLists()
Update the ocular, telescope and sensor lists after the removal of a member.
A screen widget similar to InfoPanel.
void selectLensAtIndex(QString indexString)
indexString must be an integer, in the range -1:lense.count<()
void selectOcularAtIndex(QString indexString)
indexString must be an integer, in the range of -1:oculars.count()
virtual class StelModule * getStelModule() const =0
Main class of the Oculars plug-in.
Definition: Oculars.hpp:75
QSharedPointer< StelTexture > StelTextureSP
This class is used by Qt to manage a plug-in interface.
Definition: Oculars.hpp:321