Stellarium 0.15.2
ZodiacalLight.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2002 Fabien Chereau
4  * Copyright (C) 2014 Georg Zotti: ZodiacalLight
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, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
19  */
20 
21 #ifndef _ZODIACALLIGHT_
22 #define _ZODIACALLIGHT_
23 
24 #include <QVector>
25 #include "StelModule.hpp"
26 #include "VecMath.hpp"
27 #include "StelTextureTypes.hpp"
28 #include "StelLocation.hpp"
29 
35 // GZ OCRed and hand-edited the table in Excel, first filling the missing data around the sun with values based on
36 // Leinert 1975: Zodiacal Light - A Measure of the Interplanetary Environment. Space Science Reviews 18, 281-339.
37 // From the combined table, I tried to create a texture. Image editing hides the numbers, so I finally exported the
38 // data (power 0.75) into a 3D surface which I edited in Sketchup: fill the data hole "mountain" with believeable values.
39 // Export to OBJ, extract and mirror vertices. Then, in ArcGIS10,
40 // 3D Analyst Toolbox -> From File -> ASCII 3D to Feature Class
41 // 3D Analyst Toolbox -> Raster Interpolation -> IDW: cell size: 1 (degree), power:2, var.dist., 12points.
42 // Spatial Analyst Tools -> Math -> Power: 1.3333 (to invert the 0.75 above)
43 // Spatial Analyst Tools -> Math -> Log2 (to provide better scaling, matches better with visual impression)
44 // This float32 texture was then exported to a regular 8bit grayscale PNG texture.
45 // It turned out that the original distribution had a quite boxy appearance around the data hole.
46 // I had to do more editing, finally also within the data values, but I think much of the error is in these published data values.
47 // The true values would massively concentrate further around the sun, but a single 8bit texture cannot deliver more dynamic range in brightness.
48 // The current solution matches my own observations in a very dark location in Namibia, May 2014, and photos taken in Libya in March 2006.
49 
50 class ZodiacalLight : public StelModule
51 {
52  Q_OBJECT
53  Q_PROPERTY(bool flagZodiacalLightDisplayed
54  READ getFlagShow
55  WRITE setFlagShow
56  NOTIFY zodiacalLightDisplayedChanged)
57  Q_PROPERTY(double intensity
58  READ getIntensity
59  WRITE setIntensity
60  NOTIFY intensityChanged)
61  Q_PROPERTY(Vec3f color
62  READ getColor
63  WRITE setColor
64  NOTIFY colorChanged)
65 
66 public:
67  ZodiacalLight();
68  virtual ~ZodiacalLight();
69 
71  // Methods defined in the StelModule class
75  virtual void init();
76 
78  virtual void draw(StelCore* core);
79 
82  virtual void update(double deltaTime);
83 
86  virtual double getCallOrder(StelModuleActionName actionName) const;
87 
89  // Setter and getters
90 public slots:
92  double getIntensity() const {return intensity;}
95  void setIntensity(double aintensity) {if(aintensity!=intensity){intensity = aintensity; emit intensityChanged(intensity);}}
96 
98  Vec3f getColor() const {return color;}
105  void setColor(const Vec3f& c) {if (c!=color) { color=c; emit colorChanged(c);}}
106 
112  void setFlagShow(bool b);
114  bool getFlagShow(void) const;
115 
116 private slots:
118  void handleLocationChanged(StelLocation loc);
119 
120 signals:
121  void zodiacalLightDisplayedChanged(const bool displayed);
122  void intensityChanged(double intensity);
123  void colorChanged(Vec3f color);
124 
125 private:
126  StelTextureSP tex;
127  Vec3f color; // global color
128  double intensity;
129  class LinearFader* fader;
130  double lastJD; // keep date of last computation. Position will be updated only if far enough away from last computation.
131 
132  struct StelVertexArray* vertexArray;
133  QVector<Vec3d> eclipticalVertices;
134 };
135 
136 #endif // _ZODIACALLIGHT_HPP_
Store the informations for a location on a planet.
Vec3f getColor() const
Get the color used for rendering the Zodiacal Light. It is modulated by intensity, light pollution and atmospheric extinction.
Implementation of StelFader which implements a linear transition.
Definition: StelFader.hpp:77
Define the StelTextureSP type.
bool getFlagShow(void) const
Gets whether the Zodiacal Light is displayed.
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
Manages the displaying of the Zodiacal Light.
virtual void init()
Initialize the class.
double getIntensity() const
Get Zodiacal Light intensity.
virtual double getCallOrder(StelModuleActionName actionName) const
Used to determine the order in which the various modules are drawn.
virtual void update(double deltaTime)
Update and time-dependent state.
StelModuleActionName
Define the possible action for which an order is defined.
Definition: StelModule.hpp:121
void setFlagShow(bool b)
Sets whether to show the Zodiacal Light.
void setColor(const Vec3f &c)
Sets the color to use for rendering the Zodiacal Light.
QSharedPointer< StelTexture > StelTextureSP
Use shared pointer to simplify memory managment.
void setIntensity(double aintensity)
Set Zodiacal Light intensity.
virtual void draw(StelCore *core)
Draw the Zodiacal Light.
This is the common base class for all the main components of stellarium.
Definition: StelModule.hpp:49