Stellarium 0.12.4
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 <vector>
25 #include <QString>
26 #include <QStringList>
27 #include <QFont>
28 
29 #include "StelObjectType.hpp"
30 #include "StelObjectModule.hpp"
31 #include "StelProjectorType.hpp"
32 
33 class StelToneReproducer;
34 class StarMgr;
35 class Constellation;
36 class StelProjector;
37 
43 {
44  Q_OBJECT
45  Q_PROPERTY(bool artDisplayed
46  READ getFlagArt
47  WRITE setFlagArt
48  NOTIFY artDisplayedChanged)
49  Q_PROPERTY(bool artFadeDuration
51  WRITE setArtFadeDuration
52  NOTIFY artFadeDurationChanged)
53  Q_PROPERTY(bool artIntensity
54  READ getArtIntensity
55  WRITE setArtIntensity
56  NOTIFY artIntensityChanged)
57  Q_PROPERTY(bool boundariesColor
59  WRITE setBoundariesColor
60  NOTIFY boundariesColorChanged)
61  Q_PROPERTY(bool boundariesDisplayed
63  WRITE setFlagBoundaries
64  NOTIFY boundariesDisplayedChanged)
65  Q_PROPERTY(bool fontSize
66  READ getFontSize
67  WRITE setFontSize
68  NOTIFY fontSizeChanged)
69  Q_PROPERTY(bool isolateSelected
72  NOTIFY isolateSelectedChanged)
73  Q_PROPERTY(bool linesColor
74  READ getLinesColor
75  WRITE setLinesColor
76  NOTIFY linesColorChanged)
77  Q_PROPERTY(bool linesDisplayed
78  READ getFlagLines
79  WRITE setFlagLines
80  NOTIFY linesDisplayedChanged)
81  Q_PROPERTY(bool namesColor
82  READ getLabelsColor
83  WRITE setLabelsColor
84  NOTIFY namesColorChanged)
85  Q_PROPERTY(bool namesDisplayed
86  READ getFlagLabels
87  WRITE setFlagLabels
88  NOTIFY namesDisplayedChanged)
89 
90 public:
92  ConstellationMgr(StarMgr *stars);
94  virtual ~ConstellationMgr();
95 
97  // Methods defined in the StelModule class
101  virtual void init();
102 
104  virtual void draw(StelCore* core, class StelRenderer* renderer);
105 
107  virtual void update(double deltaTime);
108 
112  virtual double getCallOrder(StelModuleActionName actionName) const;
113 
115  // Methods defined in StelObjectManager class
116  virtual QList<StelObjectP> searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
117 
120  virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
121 
124  virtual StelObjectP searchByName(const QString& name) const;
125 
131  virtual QStringList listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false) const;
137  virtual QStringList listMatchingObjects(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false) const;
138  virtual QStringList listAllObjects(bool inEnglish) const;
139  virtual QString getName() const { return "Constellations"; }
140 
142  // Properties setters and getters
143 public slots:
145  void setFlagArt(const bool displayed);
147  bool getFlagArt(void) const;
148 
150  void setArtFadeDuration(const float duration);
152  float getArtFadeDuration() const;
153 
155  void setArtIntensity(const double intensity);
157  double getArtIntensity() const;
158 
160  void setBoundariesColor(const Vec3f& color);
162  Vec3f getBoundariesColor() const;
163 
165  void setFlagBoundaries(const bool displayed);
167  bool getFlagBoundaries(void) const;
168 
170  void setFlagIsolateSelected(const bool isolate);
172  bool getFlagIsolateSelected(void) const;
173 
175  void setLinesColor(const Vec3f& color);
177  Vec3f getLinesColor() const;
178 
180  void setFlagLines(const bool displayed);
182  bool getFlagLines(void) const;
183 
185  void setLabelsColor(const Vec3f& color);
187  Vec3f getLabelsColor() const;
188 
190  void setFlagLabels(bool displayed);
192  bool getFlagLabels(void) const;
193 
195  void setFontSize(const float newFontSize);
197  float getFontSize() const;
198 
199 signals:
200  void artDisplayedChanged(const bool displayed) const;
201  void artFadeDurationChanged(const float duration) const;
202  void artIntensityChanged(const double intensity) const;
203  void boundariesColorChanged(const Vec3f & color) const;
204  void boundariesDisplayedChanged(const bool displayed) const;
205  void fontSizeChanged(const float newSize) const;
206  void isolateSelectedChanged(const bool isolate) const;
207  void linesColorChanged(const Vec3f & color) const;
208  void linesDisplayedChanged(const bool displayed) const;
209  void namesColorChanged(const Vec3f & color) const;
210  void namesDisplayedChanged(const bool displayed) const;
211 
212 private slots:
217  void selectedObjectChange(StelModule::StelModuleSelectAction action);
218 
220  void setStelStyle(const QString& section);
221 
224  void updateSkyCulture(const QString& skyCultureDir);
225 
230  void updateI18n();
231 
232 private:
235  void loadNames(const QString& namesFile);
236 
241  void loadLinesAndArt(const QString& fileName, const QString& artfileName, const QString& cultureName);
242 
256  bool loadBoundaries(const QString& conCatFile);
258  void drawLines(class StelRenderer* renderer, StelProjectorP projector, const StelCore* core) const;
263  void drawArt(class StelRenderer* renderer, StelProjectorP projector) const;
269  void drawNames(class StelRenderer* renderer, StelProjectorP projector, QFont& font) const;
274  void drawBoundaries(StelRenderer* renderer, StelProjectorP projector) const;
276  void setSelectedConst(Constellation* c);
278  void unsetSelectedConst(Constellation* c);
280  void setSelected(const QString& abbreviation);
282  StelObjectP setSelectedStar(const QString& abbreviation);
284  void setSelected(const StelObject* s) {if (!s) setSelectedConst(NULL); else setSelectedConst(isStarIn(s));}
286  void deselect() {setSelected(NULL);}
290  StelObject* getSelected(void) const;
292  void deselectConstellations(void);
293 
294  std::vector<Constellation*> selected; // More than one can be selected at a time
295 
296  Constellation* isStarIn(const StelObject *s) const;
297  Constellation* findFromAbbreviation(const QString& abbreviation) const;
298  std::vector<Constellation*> asterisms;
299  QFont asterFont;
300  StarMgr* hipStarMgr;
301 
302  bool isolateSelected;
303  std::vector<std::vector<Vec3f> *> allBoundarySegments;
304 
305  QString lastLoadedSkyCulture; // Store the last loaded sky culture directory name
306 
307  // These are THE master settings - individual constellation settings can vary based on selection status
308  float artFadeDuration;
309  float artIntensity;
310  bool artDisplayed;
311  bool boundariesDisplayed;
312  bool linesDisplayed;
313  bool namesDisplayed;
314 };
315 
316 #endif // _CONSTELLATIONMGR_HPP_