Stellarium  0.16.1
PointerCoordinates.hpp
1 /*
2  * Pointer Coordinates plug-in for Stellarium
3  *
4  * Copyright (C) 2014 Alexander Wolf
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef _POINTERCOORDINATES_HPP_
21 #define _POINTERCOORDINATES_HPP_
22 
23 #include "StelGui.hpp"
24 #include "StelModule.hpp"
25 
26 #include <QFont>
27 #include <QString>
28 #include <QPair>
29 
30 class QPixmap;
31 class StelButton;
33 
46 class PointerCoordinates : public StelModule
51 {
52  Q_OBJECT
53  Q_ENUMS(CoordinatesPlace)
54  Q_ENUMS(CoordinateSystem)
55  Q_PROPERTY(bool enabled
56  READ isEnabled
57  WRITE enableCoordinates
58  NOTIFY flagCoordinatesVisibilityChanged
59  )
60 
61 public:
65  {
71  };
72 
76  {
77  RaDecJ2000,
78  RaDec,
79  HourAngle,
80  Ecliptic,
81  EclipticJ2000,
82  AltAzi,
83  Galactic,
84  Supergalactic
85  };
86 
87 
89  virtual ~PointerCoordinates();
90 
91  virtual void init();
92  virtual void deinit();
93  virtual void update(double) {;}
94  virtual void draw(StelCore *core);
95  virtual double getCallOrder(StelModuleActionName actionName) const;
96  virtual bool configureGui(bool show);
97 
100  void restoreDefaultConfiguration(void);
101 
104  void loadConfiguration(void);
105 
107  void saveConfiguration(void);
108 
110  bool isEnabled() const
111  {
112  return flagShowCoordinates;
113  }
114 
116  int getFontSize(void)
117  {
118  return fontSize;
119  }
120  bool getFlagEnableAtStartup(void)
121  {
122  return flagEnableAtStartup;
123  }
124  bool getFlagShowCoordinatesButton(void)
125  {
126  return flagShowCoordinatesButton;
127  }
128  bool getFlagShowCrossedLines(void)
129  {
130  return flagShowCrossedLines;
131  }
132 
133  QPair<int, int> getCoordinatesPlace(QString text);
134 
135  QPair<int, int> getCustomCoordinatesPlace()
136  {
137  return customPosition;
138  }
139 
140 signals:
141  void flagCoordinatesVisibilityChanged(bool b);
142 
143 public slots:
145  void enableCoordinates(bool b);
148  {
149  flagEnableAtStartup=b;
150  }
152  void setFontSize(int size)
153  {
154  fontSize=size;
155  }
157  void setFlagShowCoordinatesButton(bool b);
158 
159  void setFlagShowCrossedLines(bool b)
160  {
161  flagShowCrossedLines=b;
162  }
163 
166  {
167  currentPlace = place;
168  }
171  {
172  return currentPlace;
173  }
175  QString getCurrentCoordinatesPlaceKey(void) const;
177  void setCurrentCoordinatesPlaceKey(QString key);
178 
181  {
182  currentCoordinateSystem = cs;
183  }
186  {
187  return currentCoordinateSystem;
188  }
190  QString getCurrentCoordinateSystemKey(void) const;
192  void setCurrentCoordinateSystemKey(QString key);
193 
194  void setCustomCoordinatesPlace(int x, int y);
195 
196  void setFlagShowConstellation(bool b){flagShowConstellation=b;}
197  bool getFlagShowConstellation(void) const {return flagShowConstellation;}
198 private:
199  PointerCoordinatesWindow* mainWindow;
200  QSettings* conf;
201  StelGui* gui;
202 
203  // The current place for string with coordinates
204  CoordinatesPlace currentPlace;
205  // The current coordinate system
206  CoordinateSystem currentCoordinateSystem;
207 
208  QFont font;
209  bool flagShowCoordinates;
210  bool flagEnableAtStartup;
211  bool flagShowCoordinatesButton;
212  bool flagShowConstellation;
213  bool flagShowCrossedLines;
214  Vec3f textColor;
215  Vec3d coordinatesPoint;
216  int fontSize;
217  StelButton* toolbarButton;
218  QPair<int, int> customPosition;
219 };
220 
221 
222 #include <QObject>
223 #include "StelPluginInterface.hpp"
224 
227 {
228  Q_OBJECT
229  Q_PLUGIN_METADATA(IID StelPluginInterface_iid)
230  Q_INTERFACES(StelPluginInterface)
231 public:
232  virtual StelModule* getStelModule() const;
233  virtual StelPluginInfo getPluginInfo() const;
234  virtual QObjectList getExtensionList() const { return QObjectList(); }
235 };
236 
237 #endif /* _POINTERCOORDINATES_HPP_ */
Define the interface to implement when creating a plugin.
QString getCurrentCoordinateSystemKey(void) const
Get the current coordinate system key.
int getFontSize(void)
Get font size for messages.
void loadConfiguration(void)
Read (or re-read) settings from the main config file.
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.
The custom position on the screen.
virtual void deinit()
Called before the module will be delete, and before the openGL context is suppressed.
virtual void draw(StelCore *core)
Execute all the drawing functions for this module.
virtual bool configureGui(bool show)
Detect or show the configuration GUI elements for the module.
In center of the top right half of the screen.
void saveConfiguration(void)
Save the settings to the main configuration file.
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
bool isEnabled() const
Is plugin enabled?
The top center of the screen.
CoordinatesPlace
Available places of string with coordinates.
virtual QObjectList getExtensionList() const
A mechanism to provide abitrary QObjects to the StelModuleMgr.
CoordinateSystem
Available coordinate systems.
Main window of the Pointer Coordinates plug-in.
void setFlagShowCoordinatesButton(bool b)
Display plugin button on toolbar.
void restoreDefaultConfiguration(void)
Set up the plugin with default values.
CoordinatesPlace getCurrentCoordinatesPlace() const
Get the current place of the string with coordinates.
This class is used by Qt to manage a plug-in interface.
Main class of the Pointer Coordinates plugin.
virtual void update(double)
Update the module with respect to the time.
A Button Graphicsitem for use in Stellarium&#39;s graphic widgets.
void setCurrentCoordinatesPlace(CoordinatesPlace place)
Set the current place of the string with coordinates.
void setCurrentCoordinatesPlaceKey(QString key)
Set the current place of the string with coordinates from its key.
StelModuleActionName
Define the possible action for which an order is defined.
Definition: StelModule.hpp:121
void setCurrentCoordinateSystem(CoordinateSystem cs)
Set the current coordinate system.
void setFlagEnableAtStartup(bool b)
Enable plugin usage at startup.
void setCurrentCoordinateSystemKey(QString key)
Set the current coordinate system from its key.
virtual void init()
Initialize itself.
CoordinateSystem getCurrentCoordinateSystem() const
Get the current coordinate system.
The right bottom corner of the screen.
void setFontSize(int size)
Set font size for message.
void enableCoordinates(bool b)
Enable plugin usage.
Main class for the GUI based on QGraphicView.
Definition: StelGui.hpp:53
QString getCurrentCoordinatesPlaceKey(void) const
Get the current place of the string with coordinates.
This is the common base class for all the main components of stellarium.
Definition: StelModule.hpp:49
Contains information about a Stellarium plugin.