Stellarium 0.15.2
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  NOTIFY flagAngleMeasureChanged
77  )
78  Q_PROPERTY(bool dmsFormat
79  READ isDmsFormat
80  WRITE useDmsFormat)
81  Q_PROPERTY(bool paDisplayed
82  READ isPaDisplayed
83  WRITE showPositionAngle)
84 public:
85  AngleMeasure();
86  virtual ~AngleMeasure();
87 
89  // Methods defined in the StelModule class
90  virtual void init();
91  virtual void update(double deltaTime);
92  virtual void draw(StelCore* core);
93  virtual double getCallOrder(StelModuleActionName actionName) const;
94  virtual void handleKeys(class QKeyEvent* event);
95  virtual void handleMouseClicks(class QMouseEvent* event);
96  virtual bool handleMouseMoves(int x, int y, Qt::MouseButtons b);
97  virtual bool configureGui(bool show=true);
98  bool isEnabled() const {return flagShowAngleMeasure;}
99  bool isDmsFormat() const { return flagUseDmsFormat; }
100  bool isPaDisplayed() const { return flagShowPA; }
101  bool isEquatorial() const { return flagShowEquatorial; }
102  bool isHorizontal() const { return flagShowHorizontal; }
103  bool isHorizontalStartSkylinked() const { return flagShowHorizontalStartSkylinked; }
104  bool isHorizontalEndSkylinked() const { return flagShowHorizontalEndSkylinked; }
105  bool isHorPaDisplayed() const { return flagShowHorizontalPA; }
106 
111  void restoreDefaultSettings();
112 
118  void loadSettings();
119 
120 signals:
121  void flagAngleMeasureChanged(bool b);
122 
123 public slots:
124  void enableAngleMeasure(bool b);
125  void useDmsFormat(bool b);
126  void showPositionAngle(bool b);
127  void showPositionAngleHor(bool b);
128  void showEquatorial(bool b);
129  void showHorizontal(bool b);
130  void showHorizontalStartSkylinked(bool b);
131  void showHorizontalEndSkylinked(bool b);
132 
133 private slots:
134  void updateMessageText();
135  void clearMessage();
136 
137 private:
138  QFont font;
139  bool flagShowAngleMeasure;
140  bool withDecimalDegree;
141  LinearFader lineVisible;
142  LinearFader messageFader;
143  QTimer* messageTimer;
144  QString messageEnabled;
145  QString messageLeftButton;
146  QString messageRightButton;
147  QString messagePA;
148  bool dragging;
149  Vec3d startPoint;
150  Vec3d endPoint;
151  Vec3d perp1StartPoint;
152  Vec3d perp1EndPoint;
153  Vec3d perp2StartPoint;
154  Vec3d perp2EndPoint;
155  Vec3f textColor;
156  Vec3f lineColor;
157  double angle;
158  bool flagUseDmsFormat;
159  bool flagShowPA;
160  bool flagShowEquatorial;
161  bool flagShowHorizontal;
162  bool flagShowHorizontalPA;
163  bool flagShowHorizontalStartSkylinked;
164  bool flagShowHorizontalEndSkylinked;
165  Vec3f horTextColor;
166  Vec3f horLineColor;
167  Vec3d startPointHor;
168  Vec3d endPointHor;
169  Vec3d perp1StartPointHor;
170  Vec3d perp1EndPointHor;
171  Vec3d perp2StartPointHor;
172  Vec3d perp2EndPointHor;
173  double angleHor;
174 
175 
176  StelButton* toolbarButton;
177 
178  void calculateEnds();
179  void calculateEndsOneLine(const Vec3d start, const Vec3d end, Vec3d &perp1Start, Vec3d &perp1End, Vec3d &perp2Start, Vec3d &perp2End, double &angle);
180  QString calculateAngle(bool horizontal=false) const;
181  QString calculatePositionAngle(const Vec3d p1, const Vec3d p2) const;
182  void drawOne(StelCore *core, const StelCore::FrameType frameType, const StelCore::RefractionMode refractionMode, const Vec3f txtColor, const Vec3f lineColor);
183 
184  QSettings* conf;
185 
186  // GUI
187  AngleMeasureDialog* configDialog;
188 };
189 
190 
191 
192 #include <QObject>
193 #include "StelPluginInterface.hpp"
194 
197 {
198  Q_OBJECT
199  Q_PLUGIN_METADATA(IID StelPluginInterface_iid)
200  Q_INTERFACES(StelPluginInterface)
201 public:
202  virtual StelModule* getStelModule() const;
203  virtual StelPluginInfo getPluginInfo() const;
204 };
205 
206 #endif /*ANGLEMEASURE_HPP_*/
207 
virtual bool handleMouseMoves(int x, int y, Qt::MouseButtons b)
Handle mouse moves.
virtual void handleKeys(class QKeyEvent *event)
Handle key events.
Define the interface to implement when creating a plugin.
Implementation of StelFader which implements a linear transition.
Definition: StelFader.hpp:77
Main class of the Angle Measure plug-in.
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
This class is used by Qt to manage a plug-in interface.
FrameType
Supported reference frame types.
Definition: StelCore.hpp:69
virtual void init()
Initialize itself.
void restoreDefaultSettings()
Restore the plug-in&#39;s settings to the default state.
A Button Graphicsitem for use in Stellarium&#39;s graphic widgets.
StelModuleActionName
Define the possible action for which an order is defined.
Definition: StelModule.hpp:121
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.
virtual void update(double deltaTime)
Update the module with respect to the time.
void loadSettings()
Load the plug-in&#39;s settings from the configuration file.
virtual void draw(StelCore *core)
Execute all the drawing functions for this module.
Main window of the Angle Measure plug-in.
virtual void handleMouseClicks(class QMouseEvent *event)
Handle mouse clicks.
A templatized 3d vector compatible with openGL.
Definition: VecMath.hpp:33
RefractionMode
Available refraction mode.
Definition: StelCore.hpp:102
virtual bool configureGui(bool show=true)
Detect or show the configuration GUI elements for the module.
This is the common base class for all the main components of stellarium.
Definition: StelModule.hpp:49
Contains information about a Stellarium plugin.