Stellarium  0.16.1
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  Q_PROPERTY(bool flagHideGridsLines READ getFlagHideGridsLines WRITE setFlagHideGridsLines NOTIFY hideGridsLinesChanged)
84 
85  //BM: Temporary, until the GUI is finalized and some other method of getting
86  //info from the main class is implemented.
87  friend class OcularsGuiPanel;
88 
89 public:
90  Oculars();
91  virtual ~Oculars();
92  static QSettings* appSettings();
93 
95  // Methods defined in the StelModule class
96  virtual void init();
97  virtual void deinit();
98  virtual bool configureGui(bool show=true);
99  virtual void draw(StelCore* core);
100  virtual double getCallOrder(StelModuleActionName actionName) const;
105  virtual void handleKeys(class QKeyEvent* event);
106  virtual void handleMouseClicks(class QMouseEvent* event);
107  virtual void update(double) {;}
108  double ccdRotationAngle() const;
109 
110  QString getDimensionsString(double fovX, double fovY) const;
111  QString getFOVString(double fov) const;
112 
113 public slots:
117  void updateLists();
118  void ccdRotationReset();
119  void decrementCCDIndex();
120  void decrementOcularIndex();
121  void decrementTelescopeIndex();
122  void decrementLensIndex();
123  void displayPopupMenu();
126  void enableOcular(bool b);
127  bool getEnableOcular() const { return flagShowOculars; }
128  void incrementCCDIndex();
129  void incrementOcularIndex();
130  void incrementTelescopeIndex();
131  void incrementLensIndex();
132  void disableLens();
133  void rotateCCD(QString amount);
134  void selectCCDAtIndex(QString indexString);
135  void selectOcularAtIndex(QString indexString);
136  void selectTelescopeAtIndex(QString indexString);
137  void selectLensAtIndex(QString indexString);
138  void toggleCCD(bool show);
141  void toggleCCD();
142  bool getEnableCCD() const { return flagShowCCD; }
143  void toggleCrosshairs(bool show = true);
144  bool getEnableCrosshairs() const { return flagShowCrosshairs; }
146  void toggleTelrad(bool show);
147  bool getEnableTelrad() const { return flagShowTelrad; }
149  void toggleTelrad();
150  void enableGuiPanel(bool enable = true);
151 
152  void setFlagDecimalDegrees(const bool b);
153  bool getFlagDecimalDegrees(void) const;
154 
155  void setFlagLimitMagnitude(const bool b);
156  bool getFlagLimitMagnitude(void) const;
157 
158  void setFlagInitFovUsage(const bool b);
159  bool getFlagInitFovUsage(void) const;
160 
161  void setFlagInitDirectionUsage(const bool b);
162  bool getFlagInitDirectionUsage(void) const;
163 
164  void setFlagAutosetMountForCCD(const bool b);
165  bool getFlagAutosetMountForCCD(void) const;
166 
167  void setFlagUseSemiTransparency(const bool b);
168  bool getFlagUseSemiTransparency(void) const;
169 
170  void setFlagShowResolutionCriterions(const bool b);
171  bool getFlagShowResolutionCriterions(void) const;
172 
173  void setFlagHideGridsLines(const bool b);
174  bool getFlagHideGridsLines(void) const;
175 
176 signals:
177  void enableOcularChanged(bool value);
178  void enableCrosshairsChanged(bool value);
179  void enableCCDChanged(bool value);
180  void enableTelradChanged(bool value);
181  void selectedCCDChanged();
182  void selectedOcularChanged();
183  void selectedTelescopeChanged();
184  void selectedLensChanged();
185  void hideGridsLinesChanged(bool value);
186 
187 private slots:
189  void instrumentChanged();
190  void determineMaxEyepieceAngle();
191  void setRequireSelection(bool state);
192  void setScaleImageCircle(bool state);
193  void setScreenFOVForCCD();
194  void retranslateGui();
195  void updateOcularReticle(void);
196 
197 private:
199  void initializeActivationActions();
200 
202  bool isBinocularDefined();
203 
205  void paintCCDBounds();
207  void paintCrosshairs();
209  void paintOcularMask(const StelCore * core);
211  void paintTelrad();
212 
215  void paintText(const StelCore * core);
216 
218  void unzoomOcular();
219 
226  void validateAndLoadIniFile();
227 
232  void zoom(bool zoomedIn);
233 
235  void zoomOcular();
236 
237  void hideUsageMessageIfDisplayed();
238 
240  QMenu* addLensSubmenu(QMenu* parent);
241 
243  QMenu* addTelescopeSubmenu(QMenu* parent);
244 
246  Lens* selectedLens();
247 
249  QList<CCD *> ccds;
250  QList<Ocular *> oculars;
251  QList<Telescope *> telescopes;
252  QList<Lens *> lenses;
253 
254  int selectedCCDIndex;
255  int selectedOcularIndex;
256  int selectedTelescopeIndex;
257  int selectedLensIndex;
258 
259  QFont font;
260  bool flagShowCCD;
261  bool flagShowOculars;
262  bool flagShowCrosshairs;
263  bool flagShowTelrad;
264  int usageMessageLabelID;
265 
266  bool flagCardinalPoints;
267  bool flagAdaptation;
268 
269  bool flagLimitStars;
270  float magLimitStars;
271  bool flagLimitDSOs;
272  float magLimitDSOs;
273  bool flagLimitPlanets;
274  float magLimitPlanets;
275  float relativeStarScaleMain;
276  float absoluteStarScaleMain;
277  float relativeStarScaleOculars;
278  float absoluteStarScaleOculars;
279  float relativeStarScaleCCD;
280  float absoluteStarScaleCCD;
281  bool flagMoonScale;
282 
283  double maxEyepieceAngle;
284  bool requireSelection;
285  bool flagLimitMagnitude;
286  bool useMaxEyepieceAngle;
287  bool guiPanelEnabled;
289  bool flagDecimalDegrees;
290  bool flagSemiTransparency;
291  bool flagHideGridsLines;
292  bool flagGridLinesDisplayedMain;
293  bool flagConstellationLines;
294  bool flagAsterismLines;
295  bool flipVert;
296  bool flipHorz;
297 
298  QSignalMapper * ccdRotationSignalMapper;
299  QSignalMapper * ccdsSignalMapper;
300  QSignalMapper * ocularsSignalMapper;
301  QSignalMapper * telescopesSignalMapper;
302  QSignalMapper * lensesSignalMapper;
303 
304  // for toolbar button
305  QPixmap * pxmapGlow;
306  QPixmap * pxmapOnIcon;
307  QPixmap * pxmapOffIcon;
308  StelButton * toolbarButton;
309 
310  OcularDialog *ocularDialog;
311  bool ready;
312 
313  StelAction * actionShowOcular;
314  StelAction * actionShowCrosshairs;
315  StelAction * actionShowSensor;
316  StelAction * actionShowTelrad;
317  StelAction * actionConfiguration;
318  StelAction * actionMenu;
319  StelAction * actionTelescopeIncrement;
320  StelAction * actionTelescopeDecrement;
321  StelAction * actionOcularIncrement;
322  StelAction * actionOcularDecrement;
323 
324  class OcularsGuiPanel * guiPanel;
325 
326  //Reticle
327  StelTextureSP reticleTexture;
328  double actualFOV;
329  double initialFOV;
330  bool flagInitFOVUsage;
331  bool flagInitDirectionUsage;
332  bool flagAutosetMountForCCD;
333  bool flagShowResolutionCriterions;
334  bool equatorialMountEnabled;
335  double reticleRotation;
336 };
337 
338 
339 
340 #include <QObject>
341 #include "StelPluginInterface.hpp"
342 
344 class OcularsStelPluginInterface : public QObject, public StelPluginInterface
345 {
346  Q_OBJECT
347  Q_PLUGIN_METADATA(IID StelPluginInterface_iid)
348  Q_INTERFACES(StelPluginInterface)
349 public:
350  virtual StelModule* getStelModule() const;
351  virtual StelPluginInfo getPluginInfo() const;
352  virtual QObjectList getExtensionList() const { return QObjectList(); }
353 };
354 
355 #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:107
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:344
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.
virtual QObjectList getExtensionList() const
A mechanism to provide abitrary QObjects to the StelModuleMgr.
Definition: Oculars.hpp:352