Stellarium 0.14.3
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 
59 public:
62  enum CoordinatesPlace
63  {
64  TopCenter,
65  TopRight,
66  RightBottomCorner,
67  Custom
68  };
69 
72  enum CoordinateSystem
73  {
74  RaDecJ2000,
75  RaDec,
76  HourAngle,
77  Ecliptic,
78  EclipticJ2000,
79  AltAzi,
80  Galactic
81  };
82 
83 
85  virtual ~PointerCoordinates();
86 
87  virtual void init();
88  virtual void deinit();
89  virtual void update(double) {;}
90  virtual void draw(StelCore *core);
91  virtual double getCallOrder(StelModuleActionName actionName) const;
92  virtual bool configureGui(bool show);
93 
96  void restoreDefaultConfiguration(void);
97 
100  void loadConfiguration(void);
101 
103  void saveConfiguration(void);
104 
106  bool isEnabled() const
107  {
108  return flagShowCoordinates;
109  }
110 
112  int getFontSize(void)
113  {
114  return fontSize;
115  }
116  bool getFlagEnableAtStartup(void)
117  {
118  return flagEnableAtStartup;
119  }
120  bool getFlagShowCoordinatesButton(void)
121  {
122  return flagShowCoordinatesButton;
123  }
124 
125  QPair<int, int> getCoordinatesPlace(QString text);
126 
127  QPair<int, int> getCustomCoordinatesPlace()
128  {
129  return customPosition;
130  }
131 
132 public slots:
134  void enableCoordinates(bool b);
137  {
138  flagEnableAtStartup=b;
139  }
141  void setFontSize(int size)
142  {
143  fontSize=size;
144  }
146  void setFlagShowCoordinatesButton(bool b);
147 
149  void setCurrentCoordinatesPlace(CoordinatesPlace place)
150  {
151  currentPlace = place;
152  }
154  CoordinatesPlace getCurrentCoordinatesPlace() const
155  {
156  return currentPlace;
157  }
159  QString getCurrentCoordinatesPlaceKey(void) const;
161  void setCurrentCoordinatesPlaceKey(QString key);
162 
164  void setCurrentCoordinateSystem(CoordinateSystem cs)
165  {
166  currentCoordinateSystem = cs;
167  }
169  CoordinateSystem getCurrentCoordinateSystem() const
170  {
171  return currentCoordinateSystem;
172  }
174  QString getCurrentCoordinateSystemKey(void) const;
176  void setCurrentCoordinateSystemKey(QString key);
177 
178  void setCustomCoordinatesPlace(int x, int y);
179 
180 private:
181  PointerCoordinatesWindow* mainWindow;
182  QSettings* conf;
183  StelGui* gui;
184 
185  // The current place for string with coordinates
186  CoordinatesPlace currentPlace;
187  // The current coordinate system
188  CoordinateSystem currentCoordinateSystem;
189 
190  QFont font;
191  bool flagShowCoordinates;
192  bool flagEnableAtStartup;
193  bool flagShowCoordinatesButton;
194  Vec3f textColor;
195  Vec3d coordinatesPoint;
196  int fontSize;
197  StelButton* toolbarButton;
198  QPair<int, int> customPosition;
199 };
200 
201 
202 #include <QObject>
203 #include "StelPluginInterface.hpp"
204 
207 {
208  Q_OBJECT
209  Q_PLUGIN_METADATA(IID StelPluginInterface_iid)
210  Q_INTERFACES(StelPluginInterface)
211 public:
212  virtual StelModule* getStelModule() const;
213  virtual StelPluginInfo getPluginInfo() const;
214 };
215 
216 #endif /* _POINTERCOORDINATES_HPP_ */
QString getCurrentCoordinateSystemKey(void) const
Get the current coordinate system key.
Main window of the Pointer Coordinates plug-in.
virtual StelPluginInfo getPluginInfo() const =0
void setFlagShowCoordinatesButton(bool b)
Display plugin button on toolbar.
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 class StelModule * getStelModule() const =0
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.
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.
CoordinateSystem getCurrentCoordinateSystem() const
Get the current coordinate system.
void setFontSize(int size)
Set font size for message.
void enableCoordinates(bool b)
Enable plugin usage.
QString getCurrentCoordinatesPlaceKey(void) const
Get the current place of the string with coordinates.