Stellarium  0.16.1
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
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  */
24 #include "StelObjectType.hpp"
25 #include "StelObjectModule.hpp"
26 #include "StelProjectorType.hpp"
28 #include <vector>
29 #include <QString>
30 #include <QStringList>
31 #include <QFont>
33 class StelToneReproducer;
34 class StarMgr;
35 class Constellation;
36 class StelProjector;
37 class StelPainter;
44 {
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)
93  NOTIFY constellationsDisplayStyleChanged)
94  Q_PROPERTY(int constellationLineThickness
97  NOTIFY constellationLineThicknessChanged)
99  //Register enum with Qt
102 public:
104  ConstellationMgr(StarMgr *stars);
106  virtual ~ConstellationMgr();
109  // Methods defined in the StelModule class
113  virtual void init();
116  virtual void draw(StelCore* core);
119  virtual void update(double deltaTime);
124  virtual double getCallOrder(StelModuleActionName actionName) const;
127  // Methods defined in StelObjectManager class
128  virtual QList<StelObjectP> searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
132  virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
136  virtual StelObjectP searchByName(const QString& name) const;
138  virtual StelObjectP searchByID(const QString &id) const;
140  // GZ: I see dubious descriptions and non-fitting var names: objPrefix should just be "string" or "obj",
141  // and useStartOfWord likely should be described as "decide if start of word is searched" (2x)
147  virtual QStringList listMatchingObjects(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false, bool inEnglish=false) const;
148  virtual QStringList listAllObjects(bool inEnglish) const;
149  virtual QString getName() const { return "Constellations"; }
150  virtual QString getStelObjectType() const;
153  {
154  constellationsAbbreviated = 0,
155  constellationsNative = 1,
156  constellationsTranslated = 2,
157  constellationsEnglish = 3 // Maybe this is not useful?
158  };
161  // Properties setters and getters
162 public slots:
164  void setFlagArt(const bool displayed);
166  bool getFlagArt(void) const;
169  void setArtFadeDuration(const float duration);
171  float getArtFadeDuration() const;
176  void setArtIntensity(const float intensity);
180  float getArtIntensity() const;
184  void setArtIntensityMinimumFov(const double fov);
187  double getArtIntensityMinimumFov() const;
192  void setArtIntensityMaximumFov(const double fov);
196  double getArtIntensityMaximumFov() const;
204  void setBoundariesColor(const Vec3f& color);
206  Vec3f getBoundariesColor() const;
209  void setFlagBoundaries(const bool displayed);
211  bool getFlagBoundaries(void) const;
214  void setFlagIsolateSelected(const bool isolate);
216  bool getFlagIsolateSelected(void) const;
219  void setFlagConstellationPick(const bool mode);
221  bool getFlagConstellationPick(void) const;
229  void setLinesColor(const Vec3f& color);
231  Vec3f getLinesColor() const;
234  void setFlagLines(const bool displayed);
236  bool getFlagLines(void) const;
244  void setLabelsColor(const Vec3f& color);
246  Vec3f getLabelsColor() const;
249  void setFlagLabels(const bool displayed);
251  bool getFlagLabels(void) const;
254  void setFontSize(const float newFontSize);
256  float getFontSize() const;
269  void setConstellationLineThickness(const int thickness);
271  int getConstellationLineThickness() const { return constellationLineThickness; }
273 signals:
274  void artDisplayedChanged(const bool displayed) const;
275  void artFadeDurationChanged(const float duration) const;
276  void artIntensityChanged(const double intensity) const;
277  void boundariesColorChanged(const Vec3f & color) const;
278  void boundariesDisplayedChanged(const bool displayed) const;
279  void fontSizeChanged(const float newSize) const;
280  void isolateSelectedChanged(const bool isolate) const;
281  void linesColorChanged(const Vec3f & color) const;
282  void linesDisplayedChanged(const bool displayed) const;
283  void namesColorChanged(const Vec3f & color) const;
284  void namesDisplayedChanged(const bool displayed) const;
285  void constellationsDisplayStyleChanged(const ConstellationMgr::ConstellationDisplayStyle style) const;
286  void constellationLineThicknessChanged(int thickness) const;
288 private slots:
293  void selectedObjectChange(StelModule::StelModuleSelectAction action);
297  void updateSkyCulture(const QString& skyCultureDir);
303  void updateI18n();
306  void deselectConstellations(void);
308 private:
313  void loadNames(const QString& namesFile);
320  void loadLinesAndArt(const QString& fileName, const QString& artfileName, const QString& cultureName);
335  bool loadBoundaries(const QString& conCatFile);
339  void loadSeasonalRules(const QString& rulesFile);
342  void drawLines(StelPainter& sPainter, const StelCore* core) const;
344  void drawArt(StelPainter& sPainter) const;
346  void drawNames(StelPainter& sPainter) const;
348  void drawBoundaries(StelPainter& sPainter) const;
350  void setSelectedConst(Constellation* c);
352  void unsetSelectedConst(Constellation* c);
354  void setSelected(const QString& abbreviation);
356  StelObjectP setSelectedStar(const QString& abbreviation);
358  void setSelected(const StelObject* s);
360  void deselect() { setSelected(Q_NULLPTR); }
364  StelObject* getSelected(void) const;
366  std::vector<Constellation*> selected; // More than one can be selected at a time
368  Constellation* isStarIn(const StelObject *s) const;
369  Constellation* isObjectIn(const StelObject *s) const;
370  Constellation* findFromAbbreviation(const QString& abbreviation) const;
371  std::vector<Constellation*> constellations;
372  QFont asterFont;
373  StarMgr* hipStarMgr;
375  bool isolateSelected; // true to pick individual constellations.
376  bool constellationPickEnabled;
377  std::vector<std::vector<Vec3f> *> allBoundarySegments;
379  QString lastLoadedSkyCulture; // Store the last loaded sky culture directory name
384  // These are THE master settings - individual constellation settings can vary based on selection status
385  float artFadeDuration;
386  float artIntensity;
387  double artIntensityMinimumFov;
388  double artIntensityMaximumFov;
389  bool artDisplayed;
390  bool boundariesDisplayed;
391  bool linesDisplayed;
392  bool namesDisplayed;
394  // Store the thickness of lines of the constellations
395  int constellationLineThickness;
396 };
Vec3f getLabelsColor() const
Get label color for names.
double getArtIntensityMinimumFov() const
Returns the lower bound on the FOV at which the art intensity fades to zero.
ConstellationMgr::ConstellationDisplayStyle getConstellationDisplayStyle()
get the way how constellation names are displayed: abbbreviated/as-given/translated ...
bool getFlagBoundaries(void) const
Get whether constellation boundaries lines are displayed.
void setFlagArt(const bool displayed)
Set whether constellation art will be displayed.
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
void setArtIntensityMinimumFov(const double fov)
Sets the lower bound on the FOV at which the art intensity fades to zero.
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:48
Specialization of StelModule which manages a collection of StelObject.
virtual StelObjectP searchByNameI18n(const QString &nameI18n) const
Return the matching constellation object&#39;s pointer if exists or Q_NULLPTR.
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.
double getArtIntensityMaximumFov() const
Returns the upper bound on the FOV at which the art intensity becomes the maximum set by setArtIntens...
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.
void setFlagConstellationPick(const bool mode)
Set whether only one selected constellation must be displayed.
void setConstellationDisplayStyle(ConstellationMgr::ConstellationDisplayStyle style)
Set the way how constellation names are displayed: abbbreviated/as-given/translated.
virtual StelObjectP searchByID(const QString &id) const
Return the StelObject with the given ID if exists or the empty StelObject if not found.
ConstellationDisplayStyle constellationDisplayStyle
this controls how constellations (and also star names) are printed: Abbreviated/as-given/translated ...
int getConstellationLineThickness() const
Get the thickness of lines of the constellations.
virtual QStringList listAllObjects(bool inEnglish) const
List all StelObjects.
Stores the star catalogue data.
Definition: StarMgr.hpp:98
void setLabelsColor(const Vec3f &color)
Set label color for names.
virtual QString getName() const
Gets a user-displayable name of the object category.
Define the possible action for which an order is defined.
Definition: StelModule.hpp:121
Describes how to display constellation labels. The viewDialog GUI has a combobox which corresponds to...
void setFlagLabels(const bool displayed)
Set whether constellation names will be displayed.
static QString getConstellationDisplayStyleString(ConstellationMgr::ConstellationDisplayStyle style)
Returns the currently set constellation display style as string, instead of enum. ...
bool getFlagIsolateSelected(void) const
Get whether selected constellation is displayed alone.
Display and manage the constellations.
float getArtIntensity() const
Return constellation maximum art intensity (between 0 and 1) Note that the art intensity is linearly ...
virtual StelObjectP searchByName(const QString &name) const
Return the matching constellation if exists or Q_NULLPTR.
void setArtIntensity(const float intensity)
Set constellation maximum art intensity (between 0 and 1) Note that the art intensity is linearly fad...
bool getFlagLabels(void) const
Set whether constellation names are displayed.
void setConstellationLineThickness(const int thickness)
Set the thickness of lines of the constellations.
float getArtFadeDuration() const
Get constellation art fade duration in second.
Enum used when selecting objects to define whether to add to, replace, or remove from the existing se...
Definition: StelModule.hpp:111
bool getFlagConstellationPick(void) const
Get whether only one selected constellation is displayed.
Define the StelProjectorP type.
bool getFlagLines(void) const
Get whether constellation lines are displayed.
virtual QStringList listMatchingObjects(const QString &objPrefix, int maxNbItem=5, bool useStartOfWords=false, bool inEnglish=false) const
Find and return the list of at most maxNbItem objects auto-completing the passed object name...
void setBoundariesColor(const Vec3f &color)
Define boundary color.
virtual void init()
Initialize the ConstellationMgr.
void setFlagLines(const bool displayed)
Set whether constellation lines will be displayed.
Vec3f getLinesColor() const
Get line color.
void setArtIntensityMaximumFov(const double fov)
Sets the upper bound on the FOV at which the art intensity becomes the maximum set by setArtIntensity...
virtual QString getStelObjectType() const
Returns the name that will be returned by StelObject::getType() for the objects this module manages...