~ubuntu-branches/ubuntu/precise/stellarium/precise

« back to all changes in this revision

Viewing changes to src/modules/Nebula.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Howard
  • Date: 2010-02-15 20:48:39 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20100215204839-u3qgbv60rho997yk
Tags: 0.10.3-0ubuntu1
* New upstream release.
  - fixes intel rendering bug (LP: #480553)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Stellarium
3
3
 * Copyright (C) 2002 Fabien Chereau
4
 
 * 
 
4
 *
5
5
 * This program is free software; you can redistribute it and/or
6
6
 * modify it under the terms of the GNU General Public License
7
7
 * as published by the Free Software Foundation; either version 2
8
8
 * of the License, or (at your option) any later version.
9
 
 * 
 
9
 *
10
10
 * This program is distributed in the hope that it will be useful,
11
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
13
 * GNU General Public License for more details.
14
 
 * 
 
14
 *
15
15
 * You should have received a copy of the GNU General Public License
16
16
 * along with this program; if not, write to the Free Software
17
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24
24
#include "Nebula.hpp"
25
25
#include "NebulaMgr.hpp"
26
26
#include "StelTexture.hpp"
27
 
#include "StelFont.hpp"
28
27
#include "StelNavigator.hpp"
29
28
#include "StelUtils.hpp"
30
29
#include "StelApp.hpp"
31
30
#include "StelTextureMgr.hpp"
32
 
#include "StelFont.hpp"
33
31
#include "StelModuleMgr.hpp"
34
32
#include "StelCore.hpp"
35
33
#include "StelPainter.hpp"
36
34
 
37
35
#include <QDebug>
 
36
#include <QBuffer>
38
37
 
39
38
StelTextureSP Nebula::texCircle;
40
 
StelFont* Nebula::nebulaFont = NULL;
41
39
float Nebula::circleScale = 1.f;
42
40
float Nebula::hintsBrightness = 0;
43
41
Vec3f Nebula::labelColor = Vec3f(0.4,0.3,0.5);
89
87
 
90
88
        if ((flags&Name) || (flags&CatalogNumber))
91
89
                oss << "</h2>";
92
 
        
 
90
 
93
91
        if (flags&Extra1)
94
92
                oss << q_("Type: <b>%1</b>").arg(getTypeString()) << "<br>";
95
93
 
96
 
        if (mag < 50 && flags&Magnitude) 
 
94
        if (mag < 50 && flags&Magnitude)
97
95
                oss << q_("Magnitude: <b>%1</b>").arg(mag, 0, 'f', 2) << "<br>";
98
96
 
99
97
        oss << getPositionInfoString(core, flags);
129
127
{
130
128
        return angularSize>0 ? angularSize * 4 : 1;
131
129
}
132
 
                                                   
133
 
void Nebula::drawHints(const StelPainter& sPainter, float maxMagHints)
 
130
 
 
131
void Nebula::drawHints(StelPainter& sPainter, float maxMagHints)
134
132
{
135
133
        if (mag>maxMagHints)
136
134
                return;
137
135
        //if (4.f/getOnScreenSize(core)<0.1) return;
138
136
        glBlendFunc(GL_ONE, GL_ONE);
139
137
        float lum = 1.;//qMin(1,4.f/getOnScreenSize(core))*0.8;
140
 
        glColor3f(circleColor[0]*lum*hintsBrightness, circleColor[1]*lum*hintsBrightness, circleColor[2]*lum*hintsBrightness);
 
138
        sPainter.setColor(circleColor[0]*lum*hintsBrightness, circleColor[1]*lum*hintsBrightness, circleColor[2]*lum*hintsBrightness, 1);
141
139
        Nebula::texCircle->bind();
142
 
        sPainter.drawSprite2dMode(XY[0], XY[1], 8);
 
140
        sPainter.drawSprite2dMode(XY[0], XY[1], 4);
143
141
}
144
142
 
145
 
void Nebula::drawLabel(const StelCore* core, const StelPainter& sPainter, float maxMagLabel)
 
143
void Nebula::drawLabel(StelPainter& sPainter, float maxMagLabel)
146
144
{
147
145
        if (mag>maxMagLabel)
148
146
                return;
149
 
        glColor4f(labelColor[0], labelColor[1], labelColor[2], hintsBrightness);
150
 
        float size = getAngularSize(core)*M_PI/180.*core->getProjection(StelCore::FrameJ2000)->getPixelPerRadAtCenter();
 
147
        sPainter.setColor(labelColor[0], labelColor[1], labelColor[2], hintsBrightness);
 
148
        float size = getAngularSize(NULL)*M_PI/180.*sPainter.getProjector()->getPixelPerRadAtCenter();
151
149
        float shift = 4.f + size/1.8f;
152
150
        QString str;
153
151
        if (nameI18!="")
161
159
                else if (IC_nb > 0)
162
160
                        str = QString("IC %1").arg(IC_nb);
163
161
        }
164
 
        
165
 
        sPainter.drawText(nebulaFont,XY[0]+shift, XY[1]+shift, str, 0, 0, 0, false);
166
 
}
167
 
 
 
162
 
 
163
        sPainter.drawText(XY[0]+shift, XY[1]+shift, str, 0, 0, 0, false);
 
164
}
 
165
 
 
166
 
 
167
void Nebula::readNGC(QDataStream& in)
 
168
{
 
169
        bool isIc;
 
170
        int nb;
 
171
        float ra, dec;
 
172
        unsigned int type;
 
173
        in >> isIc >> nb >> ra >> dec >> mag >> angularSize >> type;
 
174
        if (isIc)
 
175
        {
 
176
                IC_nb = nb;
 
177
        }
 
178
        else
 
179
        {
 
180
                NGC_nb = nb;
 
181
        }
 
182
        StelUtils::spheToRect(ra,dec,XYZ);
 
183
        Q_ASSERT(fabs(XYZ.lengthSquared()-1.)<0.000000001);
 
184
        nType = (Nebula::NebulaType)type;
 
185
        pointRegion = SphericalRegionP(new SphericalPoint(getJ2000EquatorialPos(NULL)));
 
186
}
 
187
 
 
188
#if 0
 
189
QFile filess("filess.dat");
 
190
QDataStream out;
 
191
out.setVersion(QDataStream::Qt_4_5);
168
192
bool Nebula::readNGC(char *recordstr)
169
193
{
170
194
        int rahr;
206
230
        angularSize = size/60;
207
231
        if (angularSize<0)
208
232
                angularSize=0;
209
 
        
210
 
        if (size < 0)
211
 
                size = 1;
212
233
 
213
234
        // this is a huge performance drag if called every frame, so cache here
214
235
        if (!strncmp(&recordstr[8],"Gx",2)) { nType = NebGx;}
225
246
        else if (!strncmp(&recordstr[8]," ?",2)) { nType = NebUnknown;}
226
247
        else { nType = NebUnknown;}
227
248
 
 
249
        if (!filess.isOpen())
 
250
        {
 
251
                filess.open(QIODevice::WriteOnly);
 
252
                out.setDevice(&filess);
 
253
        }
 
254
        out << ((bool)(recordstr[0] == 'I')) << nb << RaRad << DecRad << mag << angularSize << ((unsigned int)nType);
 
255
        if (nb==5369 && recordstr[0] == 'I')
 
256
                filess.close();
 
257
 
228
258
        return true;
229
259
}
 
260
#endif
230
261
 
231
262
QString Nebula::getTypeString(void) const
232
263
{