Stellarium 0.13.2
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(float artFadeDuration
52  WRITE setArtFadeDuration
53  NOTIFY artFadeDurationChanged)
54  Q_PROPERTY(float artIntensity
55  READ getArtIntensity
56  WRITE setArtIntensity
57  NOTIFY artIntensityChanged)
58  Q_PROPERTY(Vec3f boundariesColor
60  WRITE setBoundariesColor
61  NOTIFY boundariesColorChanged)
62  Q_PROPERTY(bool boundariesDisplayed
64  WRITE setFlagBoundaries
65  NOTIFY boundariesDisplayedChanged)
66  Q_PROPERTY(float fontSize
67  READ getFontSize
68  WRITE setFontSize
69  NOTIFY fontSizeChanged)
70  Q_PROPERTY(bool isolateSelected
73  NOTIFY isolateSelectedChanged)
74  Q_PROPERTY(Vec3f 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(Vec3f 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 QStringList listAllObjectsByType(const QString& objType, bool inEnglish) const { Q_UNUSED(objType) Q_UNUSED(inEnglish) return QStringList(); }
141  virtual QString getName() const { return "Constellations"; }
142 
144  // Properties setters and getters
145 public slots:
147  void setFlagArt(const bool displayed);
149  bool getFlagArt(void) const;
150 
152  void setArtFadeDuration(const float duration);
154  float getArtFadeDuration() const;
155 
157  void setArtIntensity(const double intensity);
159  double getArtIntensity() const;
160 
167  void setBoundariesColor(const Vec3f& color);
169  Vec3f getBoundariesColor() const;
170 
172  void setFlagBoundaries(const bool displayed);
174  bool getFlagBoundaries(void) const;
175 
177  void setFlagIsolateSelected(const bool isolate);
179  bool getFlagIsolateSelected(void) const;
180 
187  void setLinesColor(const Vec3f& color);
189  Vec3f getLinesColor() const;
190 
192  void setFlagLines(const bool displayed);
194  bool getFlagLines(void) const;
195 
202  void setLabelsColor(const Vec3f& color);
204  Vec3f getLabelsColor() const;
205 
207  void setFlagLabels(bool displayed);
209  bool getFlagLabels(void) const;
210 
212  void setFontSize(const float newFontSize);
214  float getFontSize() const;
215 
216 signals:
217  void artDisplayedChanged(const bool displayed) const;
218  void artFadeDurationChanged(const float duration) const;
219  void artIntensityChanged(const double intensity) const;
220  void boundariesColorChanged(const Vec3f & color) const;
221  void boundariesDisplayedChanged(const bool displayed) const;
222  void fontSizeChanged(const float newSize) const;
223  void isolateSelectedChanged(const bool isolate) const;
224  void linesColorChanged(const Vec3f & color) const;
225  void linesDisplayedChanged(const bool displayed) const;
226  void namesColorChanged(const Vec3f & color) const;
227  void namesDisplayedChanged(const bool displayed) const;
228 
229 private slots:
234  void selectedObjectChange(StelModule::StelModuleSelectAction action);
235 
237  void setStelStyle(const QString& section);
238 
241  void updateSkyCulture(const QString& skyCultureDir);
242 
247  void updateI18n();
248 
249 private:
252  void loadNames(const QString& namesFile);
253 
258  void loadLinesAndArt(const QString& fileName, const QString& artfileName, const QString& cultureName);
259 
273  bool loadBoundaries(const QString& conCatFile);
274 
277  void loadSeasonalRules(const QString& rulesFile);
278 
280  void drawLines(StelPainter& sPainter, const StelCore* core) const;
282  void drawArt(StelPainter& sPainter) const;
284  void drawNames(StelPainter& sPainter) const;
286  void drawBoundaries(StelPainter& sPainter) const;
288  void setSelectedConst(Constellation* c);
290  void unsetSelectedConst(Constellation* c);
292  void setSelected(const QString& abbreviation);
294  StelObjectP setSelectedStar(const QString& abbreviation);
296  void setSelected(const StelObject* s) {if (!s) setSelectedConst(NULL); else setSelectedConst(isStarIn(s));}
298  void deselect() {setSelected(NULL);}
302  StelObject* getSelected(void) const;
304  void deselectConstellations(void);
305 
306  std::vector<Constellation*> selected; // More than one can be selected at a time
307 
308  Constellation* isStarIn(const StelObject *s) const;
309  Constellation* findFromAbbreviation(const QString& abbreviation) const;
310  std::vector<Constellation*> asterisms;
311  QFont asterFont;
312  StarMgr* hipStarMgr;
313 
314  bool isolateSelected;
315  std::vector<std::vector<Vec3f> *> allBoundarySegments;
316 
317  QString lastLoadedSkyCulture; // Store the last loaded sky culture directory name
318 
319  // These are THE master settings - individual constellation settings can vary based on selection status
320  float artFadeDuration;
321  float artIntensity;
322  bool artDisplayed;
323  bool boundariesDisplayed;
324  bool linesDisplayed;
325  bool namesDisplayed;
326 };
327 
328 #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.
Main class for Stellarium core processing.
Definition: StelCore.hpp:46
Specialization of StelModule which manages a collection of StelObject.
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.
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:40
Provide the main interface to all operations of projecting coordinates from sky to screen...
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:119
bool getFlagIsolateSelected(void) const
Get whether selected constellation is displayed alone.
Display and manage the constellations.
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:111
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.