Constellation.cpp   Constellation.cpp 
skipping to change at line 24 skipping to change at line 24
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include <algorithm> #include <algorithm>
#include <QString> #include <QString>
#include <QTextStream> #include <QTextStream>
#include <QDebug> #include <QDebug>
#include <QFontMetrics>
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "Constellation.hpp" #include "Constellation.hpp"
#include "StarMgr.hpp" #include "StarMgr.hpp"
#include "StelNavigator.hpp" #include "StelNavigator.hpp"
#include "StelTexture.hpp" #include "StelTexture.hpp"
#include "StelFont.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
Vec3f Constellation::lineColor = Vec3f(0.4,0.4,0.8); Vec3f Constellation::lineColor = Vec3f(0.4,0.4,0.8);
Vec3f Constellation::labelColor = Vec3f(0.4,0.4,0.8); Vec3f Constellation::labelColor = Vec3f(0.4,0.4,0.8);
Vec3f Constellation::boundaryColor = Vec3f(0.8,0.3,0.3); Vec3f Constellation::boundaryColor = Vec3f(0.8,0.3,0.3);
bool Constellation::singleSelected = false; bool Constellation::singleSelected = false;
Constellation::Constellation() : asterism(NULL) Constellation::Constellation() : asterism(NULL)
skipping to change at line 92 skipping to change at line 93
// delete[] asterism; // delete[] asterism;
return false; return false;
} }
} }
XYZname.set(0.,0.,0.); XYZname.set(0.,0.,0.);
for(unsigned int ii=0;ii<numberOfSegments*2;++ii) for(unsigned int ii=0;ii<numberOfSegments*2;++ii)
{ {
XYZname+= asterism[ii]->getJ2000EquatorialPos(StelApp::getIn stance().getCore()->getNavigator()); XYZname+= asterism[ii]->getJ2000EquatorialPos(StelApp::getIn stance().getCore()->getNavigator());
} }
XYZname*=1./(numberOfSegments*2); XYZname.normalize();
return true; return true;
} }
void Constellation::drawOptim(const StelPainter& sPainter, const StelNaviga tor* nav) const void Constellation::drawOptim(StelPainter& sPainter, const StelNavigator* n av, const SphericalCap& viewportHalfspace) const
{ {
if(!lineFader.getInterstate()) return; if (lineFader.getInterstate()<=0.0001f)
return;
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transpa
rency mode
glColor4f(lineColor[0], lineColor[1], lineColor[2], lineFader.getInt erstate()); sPainter.setColor(lineColor[0], lineColor[1], lineColor[2], lineFade r.getInterstate());
Vec3d star1; Vec3d star1;
Vec3d star2; Vec3d star2;
Vec3d dummy;
Vec3d v;
const StelGeom::HalfSpace viewportHalfspace = sPainter.getProjector(
)->getBoundingHalfSpace();
for (unsigned int i=0;i<numberOfSegments;++i) for (unsigned int i=0;i<numberOfSegments;++i)
{ {
star1=asterism[2*i]->getJ2000EquatorialPos(nav); star1=asterism[2*i]->getJ2000EquatorialPos(nav);
star2=asterism[2*i+1]->getJ2000EquatorialPos(nav); star2=asterism[2*i+1]->getJ2000EquatorialPos(nav);
v = star1^star2; star1.normalize();
v.normalize(); star2.normalize();
if (viewportHalfspace.d<0. || StelGeom::planeIntersect2(view sPainter.drawGreatCircleArc(star1, star2, &viewportHalfspace
portHalfspace, StelGeom::HalfSpace(v), dummy, dummy)!=false) );
if (viewportHalfspace.contains(star1) || viewportHal
fspace.contains(star2))
sPainter.drawSmallCircleArc(star1, star2, Ve
c3d(0));
} }
} }
void Constellation::drawName(StelFont *constfont, const StelPainter& sPaint er) const void Constellation::drawName(StelPainter& sPainter) const
{ {
if(!nameFader.getInterstate()) if (!nameFader.getInterstate())
return; return;
glColor4f(labelColor[0], labelColor[1], labelColor[2], nameFader.get sPainter.setColor(labelColor[0], labelColor[1], labelColor[2], nameF
Interstate()); ader.getInterstate());
sPainter.drawText(constfont, XYname[0], XYname[1], nameI18, 0., -con sPainter.drawText(XYname[0], XYname[1], nameI18, 0., -sPainter.getFo
stfont->getStrLen(nameI18)/2, 0, false); ntMetrics().width(nameI18)/2, 0, false);
} }
void Constellation::drawArtOptim(const StelProjectorP& prj, const StelNavig ator* nav) const void Constellation::drawArtOptim(StelPainter& sPainter, const SphericalRegi on& region) const
{ {
float intensity = artFader.getInterstate(); const float intensity = artFader.getInterstate();
if (artTexture && intensity) if (artTexture && intensity && region.intersects(artPolygon))
{ {
glColor3f(intensity,intensity,intensity); sPainter.setColor(intensity,intensity,intensity);
Vec3d v0, v1, v2, v3, v4, v5, v6, v7, v8;
bool b0, b1, b2, b3, b4, b5, b6, b7, b8;
// If one of the point is in the screen // The texture is not fully loaded
b0 = prj->projectCheck(artVertex[0],v0) || (nav->getJ2000Equ if (artTexture->bind()==false)
VisionDirection().dot(artVertex[0])>0.9); return;
b1 = prj->projectCheck(artVertex[1],v1) || (nav->getJ2000Equ sPainter.drawSphericalRegion(&artPolygon, StelPainter::Spher
VisionDirection().dot(artVertex[1])>0.9); icalPolygonDrawModeTextureFill);
b2 = prj->projectCheck(artVertex[2],v2) || (nav->getJ2000Equ
VisionDirection().dot(artVertex[2])>0.9);
b3 = prj->projectCheck(artVertex[3],v3) || (nav->getJ2000Equ
VisionDirection().dot(artVertex[3])>0.9);
b4 = prj->projectCheck(artVertex[4],v4) || (nav->getJ2000Equ
VisionDirection().dot(artVertex[4])>0.9);
b5 = prj->projectCheck(artVertex[5],v5) || (nav->getJ2000Equ
VisionDirection().dot(artVertex[5])>0.9);
b6 = prj->projectCheck(artVertex[6],v6) || (nav->getJ2000Equ
VisionDirection().dot(artVertex[6])>0.9);
b7 = prj->projectCheck(artVertex[7],v7) || (nav->getJ2000Equ
VisionDirection().dot(artVertex[7])>0.9);
b8 = prj->projectCheck(artVertex[8],v8) || (nav->getJ2000Equ
VisionDirection().dot(artVertex[8])>0.9);
if (b0 || b1 || b2 || b3 || b4 || b5 || b6 || b7 || b8)
{
// The texture is not fully loaded
if (artTexture->bind()==false)
return;
if ((b0 || b1 || b2 || b3) && (v0[2]<1 && v1[2]<1 &&
v2[2]<1 && v3[2]<1))
{
glBegin(GL_QUADS);
glTexCoord2f(0,0); glVe
rtex2f(v0[0],v0[1]);
glTexCoord2f(0.5,0); glVertex2f(v
1[0],v1[1]);
glTexCoord2f(0.5,0.5); glVertex2f(v
2[0],v2[1]);
glTexCoord2f(0,0.5); glVertex2f(v
3[0],v3[1]);
glEnd();
}
if ((b1 || b4 || b5 || b2) && (v1[2]<1 && v4[2]<1 &&
v5[2]<1 && v2[2]<1))
{
glBegin(GL_QUADS);
glTexCoord2f(0.5,0); glVertex2f(v1[0
],v1[1]);
glTexCoord2f(1,0); glVertex2f(v4[0],
v4[1]);
glTexCoord2f(1,0.5); glVertex2f(v5[0
],v5[1]);
glTexCoord2f(0.5,0.5); glVertex2f(v2
[0],v2[1]);
glEnd();
}
if ((b2 || b5 || b6 || b7) && (v2[2]<1 && v5[2]<1 &&
v6[2]<1 && v7[2]<1))
{
glBegin(GL_QUADS);
glTexCoord2f(0.5,0.5); glVertex2f(v
2[0],v2[1]);
glTexCoord2f(1,0.5); glVertex2f(v
5[0],v5[1]);
glTexCoord2f(1,1); glVe
rtex2f(v6[0],v6[1]);
glTexCoord2f(0.5,1); glVertex2f(v
7[0],v7[1]);
glEnd();
}
if ((b3 || b2 || b7 || b8) && (v3[2]<1 && v2[2]<1 &&
v7[2]<1 && v8[2]<1))
{
glBegin(GL_QUADS);
glTexCoord2f(0,0.5); glVertex2f(v
3[0],v3[1]);
glTexCoord2f(0.5,0.5); glVertex2f(v
2[0],v2[1]);
glTexCoord2f(0.5,1); glVertex2f(v
7[0],v7[1]);
glTexCoord2f(0,1); glVe
rtex2f(v8[0],v8[1]);
glEnd();
}
}
} }
} }
// Draw the art texture // Draw the art texture
void Constellation::drawArt(const StelProjectorP& prj, const StelNavigator* nav) const void Constellation::drawArt(StelPainter& sPainter) const
{ {
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_TEXTURE_2D); sPainter.enableTexture2d(true);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
SphericalRegionP region = sPainter.getProjector()->getViewportConvex
drawArtOptim(prj, nav); Polygon();
drawArtOptim(sPainter, *region);
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
} }
const Constellation* Constellation::isStarIn(const StelObject* s) const const Constellation* Constellation::isStarIn(const StelObject* s) const
{ {
for(unsigned int i=0;i<numberOfSegments*2;++i) for(unsigned int i=0;i<numberOfSegments*2;++i)
{ {
// asterism[i]==s test was not working // asterism[i]==s test was not working
skipping to change at line 235 skipping to change at line 175
} }
void Constellation::update(int deltaTime) void Constellation::update(int deltaTime)
{ {
lineFader.update(deltaTime); lineFader.update(deltaTime);
nameFader.update(deltaTime); nameFader.update(deltaTime);
artFader.update(deltaTime); artFader.update(deltaTime);
boundaryFader.update(deltaTime); boundaryFader.update(deltaTime);
} }
void Constellation::drawBoundaryOptim(const StelProjectorP& prj) const void Constellation::drawBoundaryOptim(StelPainter& sPainter) const
{ {
if(!boundaryFader.getInterstate()) return; if (!boundaryFader.getInterstate())
return;
glDisable(GL_TEXTURE_2D); sPainter.enableTexture2d(false);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transpa rency mode glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transpa rency mode
glColor4f(boundaryColor[0], boundaryColor[1], boundaryColor[2], boun daryFader.getInterstate()); sPainter.setColor(boundaryColor[0], boundaryColor[1], boundaryColor[ 2], boundaryFader.getInterstate());
unsigned int i, j, size; unsigned int i, j, size;
Vec3d pt1, pt2; Vec3d pt1, pt2;
std::vector<Vec3f> *points; std::vector<Vec3f> *points;
if (singleSelected) size = isolatedBoundarySegments.size(); if (singleSelected) size = isolatedBoundarySegments.size();
else size = sharedBoundarySegments.size(); else size = sharedBoundarySegments.size();
const SphericalCap viewportHalfspace = sPainter.getProjector()->getB
oundingSphericalCap();
for (i=0;i<size;i++) for (i=0;i<size;i++)
{ {
if (singleSelected) points = isolatedBoundarySegments[i]; if (singleSelected) points = isolatedBoundarySegments[i];
else points = sharedBoundarySegments[i]; else points = sharedBoundarySegments[i];
for (j=0;j<points->size()-1;j++) for (j=0;j<points->size()-1;j++)
{ {
if(prj->projectLineCheck(points->at(j),pt1,points->a pt1 = points->at(j);
t(j+1),pt2)) pt2 = points->at(j+1);
{ if (pt1*pt2>0.9999999)
glBegin(GL_LINES); continue;
glVertex2f(pt1[0],pt1[1]); sPainter.drawGreatCircleArc(pt1, pt2, &viewportHalfs
glVertex2f(pt2[0],pt2[1]); pace);
glEnd();
}
} }
} }
} }
StelObjectP Constellation::getBrightestStarInConstellation(void) const StelObjectP Constellation::getBrightestStarInConstellation(void) const
{ {
float maxMag = 99.f; float maxMag = 99.f;
StelObjectP brightest; StelObjectP brightest;
// maybe the brightest star has always odd index, // maybe the brightest star has always odd index,
// so check all segment endpoints: // so check all segment endpoints:
 End of changes. 24 change blocks. 
134 lines changed or deleted 45 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/