Stellarium 0.15.2
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 3.1f
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 
79  Q_PROPERTY(bool enableOcular READ getEnableOcular WRITE enableOcular NOTIFY enableOcularChanged)
80  Q_PROPERTY(bool enableCrosshairs READ getEnableCrosshairs WRITE toggleCrosshairs NOTIFY enableCrosshairsChanged)
81  Q_PROPERTY(bool enableCCD READ getEnableCCD WRITE toggleCCD NOTIFY enableCCDChanged)
82  Q_PROPERTY(bool enableTelrad READ getEnableTelrad WRITE toggleTelrad NOTIFY enableTelradChanged)
83 
84  //BM: Temporary, until the GUI is finalized and some other method of getting
85  //info from the main class is implemented.
86  friend class OcularsGuiPanel;
87 
88 public:
89  Oculars();
90  virtual ~Oculars();
91  static QSettings* appSettings();
92 
94  // Methods defined in the StelModule class
95  virtual void init();
96  virtual void deinit();
97  virtual bool configureGui(bool show=true);
98  virtual void draw(StelCore* core);
99  virtual double getCallOrder(StelModuleActionName actionName) const;
104  virtual void handleKeys(class QKeyEvent* event);
105  virtual void handleMouseClicks(class QMouseEvent* event);
106  virtual void update(double) {;}
107  double ccdRotationAngle() const;
108 
109  QString getDimensionsString(double fovX, double fovY) const;
110  QString getFOVString(double fov) const;
111 
112 public slots:
116  void updateLists();
117  void ccdRotationReset();
118  void decrementCCDIndex();
119  void decrementOcularIndex();
120  void decrementTelescopeIndex();
121  void decrementLensIndex();
122  void displayPopupMenu();
125  void enableOcular(bool b);
126  bool getEnableOcular() const { return flagShowOculars; }
127  void incrementCCDIndex();
128  void incrementOcularIndex();
129  void incrementTelescopeIndex();
130  void incrementLensIndex();
131  void disableLens();
132  void rotateCCD(QString amount);
133  void selectCCDAtIndex(QString indexString);
134  void selectOcularAtIndex(QString indexString);
135  void selectTelescopeAtIndex(QString indexString);
136  void selectLensAtIndex(QString indexString);
137  void toggleCCD(bool show);
140  void toggleCCD();
141  bool getEnableCCD() const { return flagShowCCD; }
142  void toggleCrosshairs(bool show = true);
143  bool getEnableCrosshairs() const { return flagShowCrosshairs; }
145  void toggleTelrad(bool show);
146  bool getEnableTelrad() const { return flagShowTelrad; }
148  void toggleTelrad();
149  void enableGuiPanel(bool enable = true);
150 
151  void setFlagDecimalDegrees(const bool b);
152  bool getFlagDecimalDegrees(void) const;
153 
154  void setFlagLimitMagnitude(const bool b);
155  bool getFlagLimitMagnitude(void) const;
156 
157  void setFlagInitFovUsage(const bool b);
158  bool getFlagInitFovUsage(void) const;
159 
160  void setFlagInitDirectionUsage(const bool b);
161  bool getFlagInitDirectionUsage(void) const;
162 
163  void setFlagAutosetMountForCCD(const bool b);
164  bool getFlagAutosetMountForCCD(void) const;
165 
166  void setFlagUseSemiTransparency(const bool b);
167  bool getFlagUseSemiTransparency(void) const;
168 
169  void setFlagHideGridsLines(const bool b);
170  bool getFlagHideGridsLines(void) const;
171 
172 signals:
173  void enableOcularChanged(bool value);
174  void enableCrosshairsChanged(bool value);
175  void enableCCDChanged(bool value);
176  void enableTelradChanged(bool value);
177  void selectedCCDChanged();
178  void selectedOcularChanged();
179  void selectedTelescopeChanged();
180  void selectedLensChanged();
181 
182 private slots:
184  void instrumentChanged();
185  void determineMaxEyepieceAngle();
186  void setRequireSelection(bool state);
187  void setScaleImageCircle(bool state);
188  void setScreenFOVForCCD();
189  void retranslateGui();
190  void updateOcularReticle(void);
191 
192 private:
194  void initializeActivationActions();
195 
197  bool isBinocularDefined();
198 
200  void paintCCDBounds();
202  void paintCrosshairs();
204  void paintOcularMask(const StelCore * core);
206  void paintTelrad();
207 
210  void paintText(const StelCore * core);
211 
213  void unzoomOcular();
214 
221  void validateAndLoadIniFile();
222 
226  void zoom(bool zoomedIn);
227 
229  void zoomOcular();
230 
231  void hideUsageMessageIfDisplayed();
232 
234  QMenu* addLensSubmenu(QMenu* parent);
235 
237  QMenu* addTelescopeSubmenu(QMenu* parent);
238 
240  Lens* selectedLens();
241 
243  QList<CCD *> ccds;
244  QList<Ocular *> oculars;
245  QList<Telescope *> telescopes;
246  QList<Lens *> lense;
247 
248  int selectedCCDIndex;
249  int selectedOcularIndex;
250  int selectedTelescopeIndex;
251  int selectedLensIndex;
252 
253  QFont font;
254  bool flagShowCCD;
255  bool flagShowOculars;
256  bool flagShowCrosshairs;
257  bool flagShowTelrad;
258  int usageMessageLabelID;
259 
260  bool flagAzimuthalGrid;
261  bool flagGalacticGrid;
262  bool flagSupergalacticGrid;
263  bool flagEquatorJ2000Grid;
264  bool flagEquatorGrid;
265  bool flagEquatorJ2000Line;
266  bool flagEquatorLine;
267  bool flagEclipticJ2000Line;
268  bool flagEclipticLine;
269  bool flagEclipticJ2000Grid;
270  bool flagEclipticGrid;
271  bool flagMeridianLine;
272  bool flagLongitudeLine;
273  bool flagHorizonLine;
274  bool flagGalacticEquatorLine;
275  bool flagSupergalacticEquatorLine;
276  bool flagPrimeVerticalLine;
277  bool flagColureLines;
278  bool flagCircumpolarCircles;
279  bool flagPrecessionCircles;
280 
281  bool flagCardinalPoints;
282  bool flagCelestialJ2000Poles;
283  bool flagCelestialPoles;
284  bool flagZenithNadirPoints;
285  bool flagEclipticJ2000Poles;
286  bool flagEclipticPoles;
287  bool flagGalacticPoles;
288  bool flagSupergalacticPoles;
289  bool flagEquinoxJ2000Points;
290  bool flagEquinoxPoints;
291  bool flagSolsticeJ2000Points;
292  bool flagSolsticePoints;
293 
294  bool flagAdaptation;
295 
296  bool flagLimitStars;
297  float magLimitStars;
298  bool flagLimitDSOs;
299  float magLimitDSOs;
300  bool flagLimitPlanets;
301  float magLimitPlanets;
302 
303  bool flagMoonScale;
304 
305  double maxEyepieceAngle;
306  bool requireSelection;
307  bool flagLimitMagnitude;
308  bool useMaxEyepieceAngle;
309  bool guiPanelEnabled;
311  bool flagDecimalDegrees;
312  bool flagSemiTransporency;
313  bool flagHideGridsLines;
314  bool flipVert;
315  bool flipHorz;
316 
317  QSignalMapper * ccdRotationSignalMapper;
318  QSignalMapper * ccdsSignalMapper;
319  QSignalMapper * ocularsSignalMapper;
320  QSignalMapper * telescopesSignalMapper;
321  QSignalMapper * lenseSignalMapper;
322 
323  // for toolbar button
324  QPixmap * pxmapGlow;
325  QPixmap * pxmapOnIcon;
326  QPixmap * pxmapOffIcon;
327  StelButton * toolbarButton;
328 
329  OcularDialog *ocularDialog;
330  bool ready;
331 
332  StelAction * actionShowOcular;
333  StelAction * actionShowCrosshairs;
334  StelAction * actionShowSensor;
335  StelAction * actionShowTelrad;
336  StelAction * actionConfiguration;
337  StelAction * actionMenu;
338  StelAction * actionTelescopeIncrement;
339  StelAction * actionTelescopeDecrement;
340  StelAction * actionOcularIncrement;
341  StelAction * actionOcularDecrement;
342 
343  class OcularsGuiPanel * guiPanel;
344 
345  //Reticle
346  StelTextureSP reticleTexture;
347  double actualFOV;
348  double initialFOV;
349  bool flagInitFOVUsage;
350  bool flagInitDirectionUsage;
351  bool flagAutosetMountForCCD;
352  bool equatorialMountEnabled;
353  double reticleRotation;
354 };
355 
356 
357 
358 #include <QObject>
359 #include "StelPluginInterface.hpp"
360 
362 class OcularsStelPluginInterface : public QObject, public StelPluginInterface
363 {
364  Q_OBJECT
365  Q_PLUGIN_METADATA(IID StelPluginInterface_iid)
366  Q_INTERFACES(StelPluginInterface)
367 public:
368  virtual StelModule* getStelModule() const;
369  virtual StelPluginInfo getPluginInfo() const;
370 };
371 
372 #endif /*_OCULARS_HPP_*/
virtual bool configureGui(bool show=true)
Detect or show the configuration GUI elements for the module.
Define the interface to implement when creating a plugin.
void rotateCCD(QString amount)
amount must be a number.
Definition: Lens.hpp:31
virtual double getCallOrder(StelModuleActionName actionName) const
Return the value defining the order of call for the given action For example if stars.callOrder[ActionDraw] == 10 and constellation.callOrder[ActionDraw] == 11, the stars module will be drawn before the constellations.
void selectTelescopeAtIndex(QString indexString)
indexString must be an integer, in the range of -1:telescopes.count()
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
void toggleTelrad()
Toggles the Telrad sight overlay (overloaded for blind switching).
virtual void draw(StelCore *core)
Execute all the drawing functions for this module.
virtual void handleKeys(class QKeyEvent *event)
Returns the module-specific style sheet.
void toggleCCD()
Toggles the sensor frame overlay (overloaded for blind switching).
virtual void update(double)
Update the module with respect to the time.
Definition: Oculars.hpp:106
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.
Wrapper around an argumentless QObject slot or a bool Q_PROPERTY with WRITE method, allowing the slot to be called/property to be toggled using this action object.
A screen widget similar to InfoPanel.
void selectLensAtIndex(QString indexString)
indexString must be an integer, in the range -1:lense.count<()
A Button Graphicsitem for use in Stellarium&#39;s graphic widgets.
void selectOcularAtIndex(QString indexString)
indexString must be an integer, in the range of -1:oculars.count()
virtual void deinit()
Called before the module will be delete, and before the openGL context is suppressed.
StelModuleActionName
Define the possible action for which an order is defined.
Definition: StelModule.hpp:121
virtual void init()
Initialize itself.
Main class of the Oculars plug-in.
Definition: Oculars.hpp:75
QSharedPointer< StelTexture > StelTextureSP
Use shared pointer to simplify memory managment.
This class is used by Qt to manage a plug-in interface.
Definition: Oculars.hpp:362
virtual void handleMouseClicks(class QMouseEvent *event)
Handle mouse clicks.
This is the common base class for all the main components of stellarium.
Definition: StelModule.hpp:49
Contains information about a Stellarium plugin.