Stellarium 0.12.4
Constellation.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 _CONSTELLATION_HPP_
22 #define _CONSTELLATION_HPP_
23 
24 #include <vector>
25 #include <QString>
26 #include <QFont>
27 
28 #include "StelObject.hpp"
29 #include "StelUtils.hpp"
30 #include "StelFader.hpp"
31 #include "StelProjector.hpp"
32 #include "StelSphereGeometry.hpp"
33 
34 class StarMgr;
35 
41 class Constellation : public StelObject
42 {
43  friend class ConstellationMgr;
44 private:
45  Constellation();
46  ~Constellation();
47 
48  // StelObject method to override
55  virtual QString getInfoString(const StelCore*, const InfoStringGroup& flags) const
56  {
57  if (flags&Name) return getNameI18n() + "(" + getShortName() + ")";
58  else return "";
59  }
60 
63  virtual QString getType() const {return "Constellation";}
64 
66  virtual Vec3d getJ2000EquatorialPos(const StelCore*) const {return XYZname;}
67 
68  virtual double getAngularSize(const StelCore*) const {Q_ASSERT(0); return 0;} // TODO
69 
77  bool read(const QString& record, StarMgr *starMgr);
78 
83  void drawName(class StelRenderer* renderer, QFont& font) const;
84 
89  void drawBoundaryOptim(StelRenderer* renderer, StelProjectorP projector) const;
90 
96  const Constellation* isStarIn(const StelObject*) const;
97 
102  StelObjectP getBrightestStarInConstellation(void) const;
103 
105  QString getNameI18n() const {return nameI18;}
107  QString getEnglishName() const {return abbreviation;}
109  QString getShortName() const {return abbreviation;}
110 
115  void generateArtVertices(class StelRenderer* renderer, const int resolution);
116 
120  void drawOptim(class StelRenderer* renderer, StelProjectorP projector,
121  const StelCore* core, const SphericalCap& viewportHalfspace) const;
122 
128  void drawArtOptim(class StelRenderer* renderer, StelProjectorP projector,
129  const SphericalRegion& region) const;
130 
132  void update(int deltaTime);
135  void setFlagLines(const bool b) {lineFader=b;}
138  void setFlagBoundaries(const bool b) {boundaryFader=b;}
141  void setFlagLabels(const bool b) {nameFader=b;}
144  void setFlagArt(const bool b) {artFader=b;}
147  bool getFlagLines() const {return lineFader;}
150  bool getFlagBoundaries() const {return boundaryFader;}
153  bool getFlagLabels() const {return nameFader;}
156  bool getFlagArt() const {return artFader;}
157 
159  QString nameI18;
161  QString englishName;
163  QString nativeName;
165  QString abbreviation;
167  Vec3d XYZname;
168  Vec3d XYname;
170  unsigned int numberOfSegments;
172  StelObjectP* asterism;
173 
174  class StelTextureNew* artTexture;
175 
176  QString artTexturePath;
177 
179  struct Vertex
180  {
181  Vec3f position;
182  Vec2f texCoord;
183  Vertex(const Vec3f& position, const Vec2f texCoord)
184  : position(position), texCoord(texCoord) {}
185  VERTEX_ATTRIBUTES(Vec3f Position, Vec2f TexCoord);
186  };
187 
189  StelVertexBuffer<Vertex>* artVertices;
190 
192  class StelIndexBuffer* artIndices;
193 
194  SphericalCap boundingCap;
195 
197  LinearFader artFader, lineFader, nameFader, boundaryFader;
198  std::vector<std::vector<Vec3f> *> isolatedBoundarySegments;
199  std::vector<std::vector<Vec3f> *> sharedBoundarySegments;
200 
203  Mat4f texCoordTo3D;
204 
206  static Vec3f lineColor;
207  static Vec3f labelColor;
208  static Vec3f boundaryColor;
209 
210  static bool singleSelected;
211 };
212 
213 #endif // _CONSTELLATION_HPP_