Stellarium 0.13.0
ConstellationMgr.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2002 Fabien Chereau
4  * Copyright (C) 2012 Timothy Reaves
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 _CONSTELLATIONMGR_HPP_
22 #define _CONSTELLATIONMGR_HPP_
23 
24 #include "StelObjectType.hpp"
25 #include "StelObjectModule.hpp"
26 #include "StelProjectorType.hpp"
27 
28 #include <vector>
29 #include <QString>
30 #include <QStringList>
31 #include <QFont>
32 
33 class StelToneReproducer;
34 class StarMgr;
35 class Constellation;
36 class StelProjector;
37 class StelPainter;
38 
44 {
45  Q_OBJECT
46  Q_PROPERTY(bool artDisplayed
47  READ getFlagArt
48  WRITE setFlagArt
49  NOTIFY artDisplayedChanged)
50  Q_PROPERTY(bool artFadeDuration
52  WRITE setArtFadeDuration
53  NOTIFY artFadeDurationChanged)
54  Q_PROPERTY(bool artIntensity
55  READ getArtIntensity
56  WRITE setArtIntensity
57  NOTIFY artIntensityChanged)
58  Q_PROPERTY(bool boundariesColor
60  WRITE setBoundariesColor
61  NOTIFY boundariesColorChanged)
62  Q_PROPERTY(bool boundariesDisplayed
64  WRITE setFlagBoundaries
65  NOTIFY boundariesDisplayedChanged)
66  Q_PROPERTY(bool fontSize
67  READ getFontSize
68  WRITE setFontSize
69  NOTIFY fontSizeChanged)
70  Q_PROPERTY(bool isolateSelected
73  NOTIFY isolateSelectedChanged)
74  Q_PROPERTY(bool linesColor
75  READ getLinesColor
76  WRITE setLinesColor
77  NOTIFY linesColorChanged)
78  Q_PROPERTY(bool linesDisplayed
79  READ getFlagLines
80  WRITE setFlagLines
81  NOTIFY linesDisplayedChanged)
82  Q_PROPERTY(bool namesColor
83  READ getLabelsColor
84  WRITE setLabelsColor
85  NOTIFY namesColorChanged)
86  Q_PROPERTY(bool namesDisplayed
87  READ getFlagLabels
88  WRITE setFlagLabels
89  NOTIFY namesDisplayedChanged)
90 
91 public:
93  ConstellationMgr(StarMgr *stars);
95  virtual ~ConstellationMgr();
96 
98  // Methods defined in the StelModule class
102  virtual void init();
103 
105  virtual void draw(StelCore* core);
106 
108  virtual void update(double deltaTime);
109 
113  virtual double getCallOrder(StelModuleActionName actionName) const;
114 
116  // Methods defined in StelObjectManager class
117  virtual QList<StelObjectP> searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
118 
121  virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
122 
125  virtual StelObjectP searchByName(const QString& name) const;
126 
132  virtual QStringList listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false) const;
138  virtual QStringList listMatchingObjects(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false) const;
139  virtual QStringList listAllObjects(bool inEnglish) const;
140  virtual QString getName() const { return "Constellations"; }
141 
143  // Properties setters and getters
144 public slots:
146  void setFlagArt(const bool displayed);
148  bool getFlagArt(void) const;
149 
151  void setArtFadeDuration(const float duration);
153  float getArtFadeDuration() const;
154 
156  void setArtIntensity(const double intensity);
158  double getArtIntensity() const;
159 
166  void setBoundariesColor(const Vec3f& color);
168  Vec3f getBoundariesColor() const;
169 
171  void setFlagBoundaries(const bool displayed);
173  bool getFlagBoundaries(void) const;
174 
176  void setFlagIsolateSelected(const bool isolate);
178  bool getFlagIsolateSelected(void) const;
179 
186  void setLinesColor(const Vec3f& color);
188  Vec3f getLinesColor() const;
189 
191  void setFlagLines(const bool displayed);
193  bool getFlagLines(void) const;
194 
201  void setLabelsColor(const Vec3f& color);
203  Vec3f getLabelsColor() const;
204 
206  void setFlagLabels(bool displayed);
208  bool getFlagLabels(void) const;
209 
211  void setFontSize(const float newFontSize);
213  float getFontSize() const;
214 
215 signals:
216  void artDisplayedChanged(const bool displayed) const;
217  void artFadeDurationChanged(const float duration) const;
218  void artIntensityChanged(const double intensity) const;
219  void boundariesColorChanged(const Vec3f & color) const;
220  void boundariesDisplayedChanged(const bool displayed) const;
221  void fontSizeChanged(const float newSize) const;
222  void isolateSelectedChanged(const bool isolate) const;
223  void linesColorChanged(const Vec3f & color) const;
224  void linesDisplayedChanged(const bool displayed) const;
225  void namesColorChanged(const Vec3f & color) const;
226  void namesDisplayedChanged(const bool displayed) const;
227 
228 private slots:
233  void selectedObjectChange(StelModule::StelModuleSelectAction action);
234 
236  void setStelStyle(const QString& section);
237 
240  void updateSkyCulture(const QString& skyCultureDir);
241 
246  void updateI18n();
247 
248 private:
251  void loadNames(const QString& namesFile);
252 
257  void loadLinesAndArt(const QString& fileName, const QString& artfileName, const QString& cultureName);
258 
272  bool loadBoundaries(const QString& conCatFile);
274  void drawLines(StelPainter& sPainter, const StelCore* core) const;
276  void drawArt(StelPainter& sPainter) const;
278  void drawNames(StelPainter& sPainter) const;
280  void drawBoundaries(StelPainter& sPainter) const;
282  void setSelectedConst(Constellation* c);
284  void unsetSelectedConst(Constellation* c);
286  void setSelected(const QString& abbreviation);
288  StelObjectP setSelectedStar(const QString& abbreviation);
290  void setSelected(const StelObject* s) {if (!s) setSelectedConst(NULL); else setSelectedConst(isStarIn(s));}
292  void deselect() {setSelected(NULL);}
296  StelObject* getSelected(void) const;
298  void deselectConstellations(void);
299 
300  std::vector<Constellation*> selected; // More than one can be selected at a time
301 
302  Constellation* isStarIn(const StelObject *s) const;
303  Constellation* findFromAbbreviation(const QString& abbreviation) const;
304  std::vector<Constellation*> asterisms;
305  QFont asterFont;
306  StarMgr* hipStarMgr;
307 
308  bool isolateSelected;
309  std::vector<std::vector<Vec3f> *> allBoundarySegments;
310 
311  QString lastLoadedSkyCulture; // Store the last loaded sky culture directory name
312 
313  // These are THE master settings - individual constellation settings can vary based on selection status
314  float artFadeDuration;
315  float artIntensity;
316  bool artDisplayed;
317  bool boundariesDisplayed;
318  bool linesDisplayed;
319  bool namesDisplayed;
320 };
321 
322 #endif // _CONSTELLATIONMGR_HPP_
Vec3f getLabelsColor() const
Get label color for names.
bool getFlagBoundaries(void) const
Get whether constellation boundaries lines are displayed.
void setFlagArt(const bool displayed)
Set whether constellation art will be displayed.
virtual ~ConstellationMgr()
Destructor.
virtual void draw(StelCore *core)
Draw constellation lines, art, names and boundaries.
void setFlagBoundaries(const bool displayed)
Set whether constellation boundaries lines will be displayed.
The base abstract class for sky objects used in Stellarium like Stars, Planets, Constellations etc...
Definition: StelObject.hpp:36
virtual void update(double deltaTime)
Updates time-varying state for each Constellation.
bool getFlagArt(void) const
Get whether constellation art is displayed.
The Constellation class models a grouping of stars in a Sky Culture.
Definition: Constellation.hpp:42
Main class for Stellarium core processing.
Definition: StelCore.hpp:46
Specialization of StelModule which manages a collection of StelObject.
Definition: StelObjectModule.hpp:35
virtual StelObjectP searchByNameI18n(const QString &nameI18n) const
Return the matching constellation object's pointer if exists or NULL.
void setArtFadeDuration(const float duration)
Set constellation art fade duration in second.
virtual QList< StelObjectP > searchAround(const Vec3d &v, double limitFov, const StelCore *core) const
Search for StelObject in an area around a specifid point.
Vec3f getBoundariesColor() const
Get current boundary color.
void setFlagIsolateSelected(const bool isolate)
Set whether selected constellation must be displayed alone.
Converts tones in function of the eye adaptation to luminance.
Definition: StelToneReproducer.hpp:53
virtual QStringList listMatchingObjects(const QString &objPrefix, int maxNbItem=5, bool useStartOfWords=false) const
Find and return the list of at most maxNbItem objects auto-completing the passed object English name...
void setFontSize(const float newFontSize)
Set the font size used for constellation names display.
void setLinesColor(const Vec3f &color)
Define line color.
Define the StelObjectP type.
Provides functions for performing openGL drawing operations.
Definition: StelPainter.hpp:71
Provide the main interface to all operations of projecting coordinates from sky to screen...
Definition: StelProjector.hpp:37
float getFontSize() const
Get the font size used for constellation names display.
virtual double getCallOrder(StelModuleActionName actionName) const
Return the value defining the order of call for the given action.
double getArtIntensity() const
Set constellation maximum art intensity (between 0 and 1)
virtual QStringList listMatchingObjectsI18n(const QString &objPrefix, int maxNbItem=5, bool useStartOfWords=false) const
Find and return the list of at most maxNbItem objects auto-completing the passed object I18n name...
void setArtIntensity(const double intensity)
Set constellation maximum art intensity (between 0 and 1)
Stores the star catalogue data.
Definition: StarMgr.hpp:80
void setFlagLabels(bool displayed)
Set whether constellation names will be displayed.
void setLabelsColor(const Vec3f &color)
Set label color for names.
StelModuleActionName
Define the possible action for which an order is defined.
Definition: StelModule.hpp:120
bool getFlagIsolateSelected(void) const
Get whether selected constellation is displayed alone.
Display and manage the constellations.
Definition: ConstellationMgr.hpp:43
virtual StelObjectP searchByName(const QString &name) const
Return the matching constellation if exists or NULL.
bool getFlagLabels(void) const
Set whether constellation names are displayed.
float getArtFadeDuration() const
Get constellation art fade duration in second.
StelModuleSelectAction
Enum used when selecting objects to define whether to add to, replace, or remove from the existing se...
Definition: StelModule.hpp:112
Define the StelProjectorP type.
bool getFlagLines(void) const
Get whether constellation path lines are displayed.
void setBoundariesColor(const Vec3f &color)
Define boundary color.
virtual void init()
Initialize the ConstellationMgr.
void setFlagLines(const bool displayed)
Set whether constellation path lines will be displayed.
Vec3f getLinesColor() const
Get line color.
ConstellationMgr(StarMgr *stars)
Constructor.