Stellarium 0.15.2
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  {
70  };
71 
75  {
76  RaDecJ2000,
77  RaDec,
78  HourAngle,
79  Ecliptic,
80  EclipticJ2000,
81  AltAzi,
82  Galactic,
83  Supergalactic
84  };
85 
86 
88  virtual ~PointerCoordinates();
89 
90  virtual void init();
91  virtual void deinit();
92  virtual void update(double) {;}
93  virtual void draw(StelCore *core);
94  virtual double getCallOrder(StelModuleActionName actionName) const;
95  virtual bool configureGui(bool show);
96 
99  void restoreDefaultConfiguration(void);
100 
103  void loadConfiguration(void);
104 
106  void saveConfiguration(void);
107 
109  bool isEnabled() const
110  {
111  return flagShowCoordinates;
112  }
113 
115  int getFontSize(void)
116  {
117  return fontSize;
118  }
119  bool getFlagEnableAtStartup(void)
120  {
121  return flagEnableAtStartup;
122  }
123  bool getFlagShowCoordinatesButton(void)
124  {
125  return flagShowCoordinatesButton;
126  }
127 
128  QPair<int, int> getCoordinatesPlace(QString text);
129 
130  QPair<int, int> getCustomCoordinatesPlace()
131  {
132  return customPosition;
133  }
134 
135 signals:
136  void flagCoordinatesVisibilityChanged(bool b);
137 
138 public slots:
140  void enableCoordinates(bool b);
143  {
144  flagEnableAtStartup=b;
145  }
147  void setFontSize(int size)
148  {
149  fontSize=size;
150  }
152  void setFlagShowCoordinatesButton(bool b);
153 
156  {
157  currentPlace = place;
158  }
161  {
162  return currentPlace;
163  }
165  QString getCurrentCoordinatesPlaceKey(void) const;
167  void setCurrentCoordinatesPlaceKey(QString key);
168 
171  {
172  currentCoordinateSystem = cs;
173  }
176  {
177  return currentCoordinateSystem;
178  }
180  QString getCurrentCoordinateSystemKey(void) const;
182  void setCurrentCoordinateSystemKey(QString key);
183 
184  void setCustomCoordinatesPlace(int x, int y);
185 
186  void setFlagShowConstellation(bool b){flagShowConstellation=b;}
187  bool getFlagShowConstellation(void) const {return flagShowConstellation;}
188 private:
189  PointerCoordinatesWindow* mainWindow;
190  QSettings* conf;
191  StelGui* gui;
192 
193  // The current place for string with coordinates
194  CoordinatesPlace currentPlace;
195  // The current coordinate system
196  CoordinateSystem currentCoordinateSystem;
197 
198  QFont font;
199  bool flagShowCoordinates;
200  bool flagEnableAtStartup;
201  bool flagShowCoordinatesButton;
202  bool flagShowConstellation;
203  Vec3f textColor;
204  Vec3d coordinatesPoint;
205  int fontSize;
206  StelButton* toolbarButton;
207  QPair<int, int> customPosition;
208 };
209 
210 
211 #include <QObject>
212 #include "StelPluginInterface.hpp"
213 
216 {
217  Q_OBJECT
218  Q_PLUGIN_METADATA(IID StelPluginInterface_iid)
219  Q_INTERFACES(StelPluginInterface)
220 public:
221  virtual StelModule* getStelModule() const;
222  virtual StelPluginInfo getPluginInfo() const;
223 };
224 
225 #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.
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.