Stellarium 0.14.3
AngleMeasure.hpp
1 /*
2  * Copyright (C) 2009 Matthew Gates
3  * Copyright (C) 2014 Georg Zotti
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 ANGLEMEASURE_HPP_
21 #define ANGLEMEASURE_HPP_
22 
23 #include <QFont>
24 #include "VecMath.hpp"
25 #include "StelModule.hpp"
26 #include "StelFader.hpp"
27 #include "StelCore.hpp"
28 
29 class QTimer;
30 class QPixmap;
31 class StelButton;
32 class AngleMeasureDialog;
33 
64 class AngleMeasure : public StelModule
71 {
72  Q_OBJECT
73  Q_PROPERTY(bool enabled
74  READ isEnabled
75  WRITE enableAngleMeasure)
76  Q_PROPERTY(bool dmsFormat
77  READ isDmsFormat
78  WRITE useDmsFormat)
79  Q_PROPERTY(bool paDisplayed
80  READ isPaDisplayed
81  WRITE showPositionAngle)
82 public:
83  AngleMeasure();
84  virtual ~AngleMeasure();
85 
87  // Methods defined in the StelModule class
88  virtual void init();
89  virtual void update(double deltaTime);
90  virtual void draw(StelCore* core);
91  virtual double getCallOrder(StelModuleActionName actionName) const;
92  virtual void handleKeys(class QKeyEvent* event);
93  virtual void handleMouseClicks(class QMouseEvent* event);
94  virtual bool handleMouseMoves(int x, int y, Qt::MouseButtons b);
95  virtual bool configureGui(bool show=true);
96  bool isEnabled() const {return flagShowAngleMeasure;}
97  bool isDmsFormat() const { return flagUseDmsFormat; }
98  bool isPaDisplayed() const { return flagShowPA; }
99  bool isEquatorial() const { return flagShowEquatorial; }
100  bool isHorizontal() const { return flagShowHorizontal; }
101  bool isHorizontalStartSkylinked() const { return flagShowHorizontalStartSkylinked; }
102  bool isHorizontalEndSkylinked() const { return flagShowHorizontalEndSkylinked; }
103  bool isHorPaDisplayed() const { return flagShowHorizontalPA; }
104 
105 
110  void restoreDefaultSettings();
111 
117  void loadSettings();
118 
125  void saveSettings();
126 
127 public slots:
128  void enableAngleMeasure(bool b);
129  void useDmsFormat(bool b);
130  void showPositionAngle(bool b);
131  void showPositionAngleHor(bool b);
132  void showEquatorial(bool b);
133  void showHorizontal(bool b);
134  void showHorizontalStartSkylinked(bool b);
135  void showHorizontalEndSkylinked(bool b);
136 
137 private slots:
138  void updateMessageText();
139  void clearMessage();
140 
141 private:
142  QFont font;
143  bool flagShowAngleMeasure;
144  bool withDecimalDegree;
145  LinearFader lineVisible;
146  LinearFader messageFader;
147  QTimer* messageTimer;
148  QString messageEnabled;
149  QString messageLeftButton;
150  QString messageRightButton;
151  QString messagePA;
152  bool dragging;
153  Vec3d startPoint;
154  Vec3d endPoint;
155  Vec3d perp1StartPoint;
156  Vec3d perp1EndPoint;
157  Vec3d perp2StartPoint;
158  Vec3d perp2EndPoint;
159  Vec3f textColor;
160  Vec3f lineColor;
161  double angle;
162  bool flagUseDmsFormat;
163  bool flagShowPA;
164  bool flagShowEquatorial;
165  bool flagShowHorizontal;
166  bool flagShowHorizontalPA;
167  bool flagShowHorizontalStartSkylinked;
168  bool flagShowHorizontalEndSkylinked;
169  Vec3f horTextColor;
170  Vec3f horLineColor;
171  Vec3d startPointHor;
172  Vec3d endPointHor;
173  Vec3d perp1StartPointHor;
174  Vec3d perp1EndPointHor;
175  Vec3d perp2StartPointHor;
176  Vec3d perp2EndPointHor;
177  double angleHor;
178 
179 
180  StelButton* toolbarButton;
181 
182  void calculateEnds();
183  void calculateEndsOneLine(const Vec3d start, const Vec3d end, Vec3d &perp1Start, Vec3d &perp1End, Vec3d &perp2Start, Vec3d &perp2End, double &angle);
184  QString calculateAngle(bool horizontal=false) const;
185  QString calculatePositionAngle(const Vec3d p1, const Vec3d p2) const;
186  void drawOne(StelCore *core, const StelCore::FrameType frameType, const StelCore::RefractionMode refractionMode, const Vec3f txtColor, const Vec3f lineColor);
187 
188  QSettings* conf;
189 
190  // GUI
191  AngleMeasureDialog* configDialog;
192 };
193 
194 
195 
196 #include <QObject>
197 #include "StelPluginInterface.hpp"
198 
201 {
202  Q_OBJECT
203  Q_PLUGIN_METADATA(IID StelPluginInterface_iid)
204  Q_INTERFACES(StelPluginInterface)
205 public:
206  virtual StelModule* getStelModule() const;
207  virtual StelPluginInfo getPluginInfo() const;
208 };
209 
210 #endif /*ANGLEMEASURE_HPP_*/
211 
Main class of the Angle Measure plug-in.
This class is used by Qt to manage a plug-in interface.
virtual StelPluginInfo getPluginInfo() const =0
void restoreDefaultSettings()
Restore the plug-in's settings to the default state.
void saveSettings()
Save the plug-in's settings to the configuration file.
virtual class StelModule * getStelModule() const =0
void loadSettings()
Load the plug-in's settings from the configuration file.
Main window of the Angle Measure plug-in.