Stellarium  0.16.1
1 /*
2  * Stellarium
3  * Copyright (C) 2017 Alexander Wolf
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
20 #ifndef _ASTERISMMGR_HPP_
21 #define _ASTERISMMGR_HPP_
23 #include "StelObjectType.hpp"
24 #include "StelObjectModule.hpp"
25 #include "StelProjectorType.hpp"
27 #include <vector>
28 #include <QString>
29 #include <QStringList>
30 #include <QFont>
32 class StelToneReproducer;
33 class StarMgr;
34 class Asterism;
35 class StelProjector;
36 class StelPainter;
43 {
45  Q_PROPERTY(float fontSize
46  READ getFontSize
47  WRITE setFontSize
48  NOTIFY fontSizeChanged)
49  Q_PROPERTY(Vec3f linesColor
50  READ getLinesColor
51  WRITE setLinesColor
52  NOTIFY linesColorChanged)
53  Q_PROPERTY(bool linesDisplayed
54  READ getFlagLines
55  WRITE setFlagLines
56  NOTIFY linesDisplayedChanged)
57  Q_PROPERTY(Vec3f rayHelpersColor
59  WRITE setRayHelpersColor
60  NOTIFY rayHelpersColorChanged)
61  Q_PROPERTY(bool rayHelpersDisplayed
63  WRITE setFlagRayHelpers
64  NOTIFY rayHelpersDisplayedChanged)
65  Q_PROPERTY(Vec3f namesColor
66  READ getLabelsColor
67  WRITE setLabelsColor
68  NOTIFY namesColorChanged)
69  Q_PROPERTY(bool namesDisplayed
70  READ getFlagLabels
71  WRITE setFlagLabels
72  NOTIFY namesDisplayedChanged)
73  Q_PROPERTY(int asterismLineThickness
76  NOTIFY asterismLineThicknessChanged)
77  Q_PROPERTY(int rayHelperThickness
80  NOTIFY rayHelperThicknessChanged)
82 public:
84  AsterismMgr(StarMgr *stars);
86  virtual ~AsterismMgr();
89  // Methods defined in the StelModule class
93  virtual void init();
96  virtual void draw(StelCore* core);
99  virtual void update(double deltaTime);
104  virtual double getCallOrder(StelModuleActionName actionName) const;
107  // Methods defined in StelObjectManager class
108  virtual QList<StelObjectP> searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
112  virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
116  virtual StelObjectP searchByName(const QString& name) const;
118  virtual StelObjectP searchByID(const QString &id) const;
125  virtual QStringList listMatchingObjects(const QString& objPrefix, int maxNbItem=5, bool useStartOfWords=false, bool inEnglish=false) const;
126  virtual QStringList listAllObjects(bool inEnglish) const;
127  virtual QString getName() const { return "Asterisms"; }
128  virtual QString getStelObjectType() const;
131  // Properties setters and getters
132 public slots:
139  void setLinesColor(const Vec3f& color);
141  Vec3f getLinesColor() const;
144  void setFlagLines(const bool displayed);
146  bool getFlagLines(void) const;
154  void setRayHelpersColor(const Vec3f& color);
156  Vec3f getRayHelpersColor() const;
159  void setFlagRayHelpers(const bool displayed);
161  bool getFlagRayHelpers(void) const;
169  void setLabelsColor(const Vec3f& color);
171  Vec3f getLabelsColor() const;
174  void setFlagLabels(const bool displayed);
176  bool getFlagLabels(void) const;
179  void setFontSize(const float newFontSize);
181  float getFontSize() const;
185  void setAsterismLineThickness(const int thickness);
187  int getAsterismLineThickness() const { return asterismLineThickness; }
191  void setRayHelperThickness(const int thickness);
193  int getRayHelperThickness() const { return rayHelperThickness; }
195 signals:
196  void fontSizeChanged(const float newSize) const;
197  void linesColorChanged(const Vec3f & color) const;
198  void linesDisplayedChanged(const bool displayed) const;
199  void namesColorChanged(const Vec3f & color) const;
200  void namesDisplayedChanged(const bool displayed) const;
201  void asterismLineThicknessChanged(int thickness) const;
202  void rayHelpersColorChanged(const Vec3f & color) const;
203  void rayHelpersDisplayedChanged(const bool displayed) const;
204  void rayHelperThicknessChanged(int thickness) const;
206 private slots:
209  void updateSkyCulture(const QString& skyCultureDir);
215  void updateI18n();
217 private:
222  void loadNames(const QString& namesFile);
227  void loadLines(const QString& fileName);
230  void drawLines(StelPainter& sPainter, const StelCore* core) const;
232  void drawRayHelpers(StelPainter& sPainter, const StelCore* core) const;
234  void drawNames(StelPainter& sPainter) const;
236  Asterism* isStarIn(const StelObject *s) const;
237  Asterism* findFromAbbreviation(const QString& abbreviation) const;
239  //Constellation* isStarIn(const StelObject *s) const;
240  //Constellation* findFromAbbreviation(const QString& abbreviation) const;
241  std::vector<Asterism*> asterisms;
242  QFont asterFont;
243  StarMgr* hipStarMgr;
245  QString lastLoadedSkyCulture; // Store the last loaded sky culture directory name
246  QString currentSkyCultureID;
248  bool linesDisplayed;
249  bool rayHelpersDisplayed;
250  bool namesDisplayed;
251  bool hasAsterism;
253  // Store the thickness of lines of the asterisms
254  int asterismLineThickness;
255  int rayHelperThickness;
256 };
258 #endif // _ASTERISMMGR_HPP_
virtual QString getStelObjectType() const
Returns the name that will be returned by StelObject::getType() for the objects this module manages...
virtual StelObjectP searchByName(const QString &name) const
Return the matching asterism if exists or Q_NULLPTR.
void setFlagLabels(const bool displayed)
Set whether asterism names will be displayed.
void setLabelsColor(const Vec3f &color)
Set label color for names.
int getRayHelperThickness() const
Get the thickness of ray helper of the asterisms.
void setFlagLines(const bool displayed)
Set whether asterism lines will be displayed.
The base abstract class for sky objects used in Stellarium like Stars, Planets, Constellations etc...
Definition: StelObject.hpp:36
virtual QList< StelObjectP > searchAround(const Vec3d &v, double limitFov, const StelCore *core) const
Search for StelObject in an area around a specifid point.
Vec3f getLabelsColor() const
Get label color for names.
void setFontSize(const float newFontSize)
Set the font size used for asterism names display.
void setRayHelpersColor(const Vec3f &color)
Define ray helper color.
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
int getAsterismLineThickness() const
Get the thickness of lines of the asterisms.
virtual StelObjectP searchByNameI18n(const QString &nameI18n) const
Return the matching asterism object&#39;s pointer if exists or Q_NULLPTR.
void setRayHelperThickness(const int thickness)
Set the thickness of ray helpers of the asterisms.
Specialization of StelModule which manages a collection of StelObject.
virtual void update(double deltaTime)
Updates time-varying state for each Constellation.
bool getFlagLines(void) const
Get whether asterism lines are displayed.
float getFontSize() const
Get the font size used for asterism names display.
Converts tones in function of the eye adaptation to luminance.
Vec3f getLinesColor() const
Get line color.
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...
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...
Display and manage the asterisms.
Definition: AsterismMgr.hpp:42
virtual QStringList listAllObjects(bool inEnglish) const
List all StelObjects.
AsterismMgr(StarMgr *stars)
Vec3f getRayHelpersColor() const
Get ray helper color.
The Asterism class models a grouping of stars in a Sky Culture.
Definition: Asterism.hpp:42
virtual void init()
Initialize the AsterismMgr.
Stores the star catalogue data.
Definition: StarMgr.hpp:98
void setAsterismLineThickness(const int thickness)
Set the thickness of lines of the asterisms.
virtual QString getName() const
Gets a user-displayable name of the object category.
virtual double getCallOrder(StelModuleActionName actionName) const
Return the value defining the order of call for the given action.
Define the possible action for which an order is defined.
Definition: StelModule.hpp:121
virtual void draw(StelCore *core)
Draw constellation lines, art, names and boundaries.
virtual ~AsterismMgr()
void setLinesColor(const Vec3f &color)
Define line color.
Define the StelProjectorP type.
bool getFlagRayHelpers(void) const
Get whether ray helpers are displayed.
void setFlagRayHelpers(const bool displayed)
Set whether ray helpers will be displayed.
bool getFlagLabels(void) const
Set whether asterism names are displayed.
virtual StelObjectP searchByID(const QString &id) const
Return the StelObject with the given ID if exists or the empty StelObject if not found.