ConstellationMgr.cpp   ConstellationMgr.cpp 
skipping to change at line 41 skipping to change at line 41
#include "ConstellationMgr.hpp" #include "ConstellationMgr.hpp"
#include "Constellation.hpp" #include "Constellation.hpp"
#include "StarMgr.hpp" #include "StarMgr.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelLoadingBar.hpp" #include "StelLoadingBar.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelFontMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelSkyCultureMgr.hpp" #include "StelSkyCultureMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelFont.hpp"
#include "StelStyle.hpp" #include "StelStyle.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
using namespace std; using namespace std;
// constructor which loads all data from appropriate files // constructor which loads all data from appropriate files
ConstellationMgr::ConstellationMgr(StarMgr *_hip_stars) : ConstellationMgr::ConstellationMgr(StarMgr *_hip_stars) :
fontSize(15),
asterFont(NULL),
hipStarMgr(_hip_stars), hipStarMgr(_hip_stars),
flagNames(0), flagNames(0),
flagLines(0), flagLines(0),
flagArt(0), flagArt(0),
flagBoundaries(0) flagBoundaries(0)
{ {
setObjectName("ConstellationMgr"); setObjectName("ConstellationMgr");
Q_ASSERT(hipStarMgr); Q_ASSERT(hipStarMgr);
isolateSelected = false; isolateSelected = false;
asterFont.setPixelSize(15);
} }
ConstellationMgr::~ConstellationMgr() ConstellationMgr::~ConstellationMgr()
{ {
std::vector<Constellation *>::iterator iter; std::vector<Constellation *>::iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); iter++) for (iter = asterisms.begin(); iter != asterisms.end(); iter++)
{ {
delete(*iter); delete(*iter);
} }
skipping to change at line 91 skipping to change at line 88
} }
allBoundarySegments.clear(); allBoundarySegments.clear();
} }
void ConstellationMgr::init() void ConstellationMgr::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf); Q_ASSERT(conf);
lastLoadedSkyCulture = "dummy"; lastLoadedSkyCulture = "dummy";
fontSize = conf->value("viewing/constellation_font_size",16.).toDoub le(); asterFont.setPixelSize(conf->value("viewing/constellation_font_size" ,16).toInt());
setFlagLines(conf->value("viewing/flag_constellation_drawing").toBoo l()); setFlagLines(conf->value("viewing/flag_constellation_drawing").toBoo l());
setFlagLabels(conf->value("viewing/flag_constellation_name").toBool( )); setFlagLabels(conf->value("viewing/flag_constellation_name").toBool( ));
setFlagBoundaries(conf->value("viewing/flag_constellation_boundaries ",false).toBool()); setFlagBoundaries(conf->value("viewing/flag_constellation_boundaries ",false).toBool());
setArtIntensity(conf->value("viewing/constellation_art_intensity", 0 .5).toDouble()); setArtIntensity(conf->value("viewing/constellation_art_intensity", 0 .5).toDouble());
setArtFadeDuration(conf->value("viewing/constellation_art_fade_durat ion",2.).toDouble()); setArtFadeDuration(conf->value("viewing/constellation_art_fade_durat ion",2.).toDouble());
setFlagArt(conf->value("viewing/flag_constellation_art").toBool()); setFlagArt(conf->value("viewing/flag_constellation_art").toBool());
setFlagIsolateSelected(conf->value("viewing/flag_constellation_isola te_selected", setFlagIsolateSelected(conf->value("viewing/flag_constellation_isola te_selected",
conf->value("viewing/flag_constellation_pick conf->value("viewing/flag
", false).toBool() ).toBool()); _constellation_pick", false).toBool() ).toBool());
GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this);
} }
/************************************************************************* /*************************************************************************
Reimplementation of the getCallOrder method Reimplementation of the getCallOrder method
*************************************************************************/ *************************************************************************/
double ConstellationMgr::getCallOrder(StelModuleActionName actionName) cons t double ConstellationMgr::getCallOrder(StelModuleActionName actionName) cons t
{ {
if (actionName==StelModule::ActionDraw) if (actionName==StelModule::ActionDraw)
return StelApp::getInstance().getModuleMgr().getModule("Grid LinesMgr")->getCallOrder(actionName)+10; return StelApp::getInstance().getModuleMgr().getModule("Grid LinesMgr")->getCallOrder(actionName)+10;
return 0; return 0;
} }
void ConstellationMgr::updateSkyCulture(const QString& skyCultureDir) void ConstellationMgr::updateSkyCulture(const QString& skyCultureDir)
{ {
StelFileMgr& fileMan = StelApp::getInstance().getFileMgr();
// Check if the sky culture changed since last load, if not don't lo ad anything // Check if the sky culture changed since last load, if not don't lo ad anything
if (lastLoadedSkyCulture == skyCultureDir) if (lastLoadedSkyCulture == skyCultureDir)
return; return;
// Find constellation art. If this doesn't exist, warn, but continu e using "" // Find constellation art. If this doesn't exist, warn, but continu e using ""
// the loadLinesAndArt function knows how to handle this (just loads lines). // the loadLinesAndArt function knows how to handle this (just loads lines).
QString conArtFile; QString conArtFile;
try try
{ {
conArtFile = fileMan.findFile("skycultures/"+skyCultureDir+" /constellationsart.fab"); conArtFile = StelFileMgr::findFile("skycultures/"+skyCulture Dir+"/constellationsart.fab");
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qWarning() << "WARNING: no constellationsart.fab file found for sky culture " << skyCultureDir; qDebug() << "No constellationsart.fab file found for sky cul ture " << skyCultureDir;
} }
try try
{ {
loadLinesAndArt(fileMan.findFile("skycultures/"+skyCultureDi r+"/constellationship.fab"), conArtFile, skyCultureDir); loadLinesAndArt(StelFileMgr::findFile("skycultures/"+skyCult ureDir+"/constellationship.fab"), conArtFile, skyCultureDir);
// load constellation names // load constellation names
loadNames(fileMan.findFile("skycultures/" + skyCultureDir + "/constellation_names.eng.fab")); loadNames(StelFileMgr::findFile("skycultures/" + skyCultureD ir + "/constellation_names.eng.fab"));
// Translate constellation names for the new sky culture // Translate constellation names for the new sky culture
updateI18n(); updateI18n();
// as constellations have changed, clear out any selection a nd retest for match! // as constellations have changed, clear out any selection a nd retest for match!
selectedObjectChangeCallBack(StelModule::ReplaceSelection); selectedObjectChangeCallBack(StelModule::ReplaceSelection);
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qWarning() << "ERROR: while loading new constellation data f or sky culture " qWarning() << "ERROR: while loading new constellation data f or sky culture "
<< skyCultureDir << ", reason: " << e.what() << endl ; << skyCultureDir << ", reason: " << e.what() << endl ;
} }
// TODO: do we need to have an else { clearBoundaries(); } ? // TODO: do we need to have an else { clearBoundaries(); } ?
if (skyCultureDir=="western") if (skyCultureDir=="western")
{ {
try try
{ {
loadBoundaries(fileMan.findFile("data/constellations _boundaries.dat")); loadBoundaries(StelFileMgr::findFile("data/constella tions_boundaries.dat"));
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qWarning() << "ERROR loading constellation boundarie s file: " << e.what(); qWarning() << "ERROR loading constellation boundarie s file: " << e.what();
} }
} }
lastLoadedSkyCulture = skyCultureDir; lastLoadedSkyCulture = skyCultureDir;
} }
skipping to change at line 194 skipping to change at line 191
{ {
// Even if do not have anything selected, KEEP constellation selection intact // Even if do not have anything selected, KEEP constellation selection intact
// (allows viewing constellations without distraction from s tar pointer animation) // (allows viewing constellations without distraction from s tar pointer animation)
// setSelected(NULL); // setSelected(NULL);
return; return;
} }
const QList<StelObjectP> newSelectedConst = omgr->getSelectedObject( "Constellation"); const QList<StelObjectP> newSelectedConst = omgr->getSelectedObject( "Constellation");
if (!newSelectedConst.empty()) if (!newSelectedConst.empty())
{ {
// const boost::intrusive_ptr<Constellation> c = boost::dynamic
_pointer_cast<Constellation>(newSelectedConst[0]);
// omgr->setSelectedObject(c->getBrightestStarInConstellation()
);
// If removing this selection // If removing this selection
if(action == StelModule::RemoveFromSelection) { if(action == StelModule::RemoveFromSelection) {
unsetSelectedConst((Constellation *)newSelectedConst [0].get()); unsetSelectedConst((Constellation *)newSelectedConst [0].data());
} else { } else {
// Add constellation to selected list (do not select a star, just the constellation) // Add constellation to selected list (do not select a star, just the constellation)
setSelectedConst((Constellation *)newSelectedConst[0 ].get()); setSelectedConst((Constellation *)newSelectedConst[0 ].data());
} }
} }
else else
{ {
const QList<StelObjectP> newSelectedStar = omgr->getSelected Object("Star"); const QList<StelObjectP> newSelectedStar = omgr->getSelected Object("Star");
if (!newSelectedStar.empty()) if (!newSelectedStar.empty())
{ {
// if (!added) // if (!added)
// setSelected(NULL); // setSelected(NULL);
setSelected(newSelectedStar[0].get()); setSelected(newSelectedStar[0].data());
} }
else else
{ {
// if (!added) // if (!added)
setSelected(NULL); setSelected(NULL);
} }
} }
} }
void ConstellationMgr::setLinesColor(const Vec3f& c) void ConstellationMgr::setLinesColor(const Vec3f& c)
skipping to change at line 254 skipping to change at line 248
Constellation::labelColor = c; Constellation::labelColor = c;
} }
Vec3f ConstellationMgr::getLabelsColor() const Vec3f ConstellationMgr::getLabelsColor() const
{ {
return Constellation::labelColor; return Constellation::labelColor;
} }
void ConstellationMgr::setFontSize(double newFontSize) void ConstellationMgr::setFontSize(double newFontSize)
{ {
asterFont = &StelApp::getInstance().getFontManager().getStandardFont (StelApp::getInstance().getLocaleMgr().getSkyLanguage(), fontSize); asterFont.setPixelSize(newFontSize);
} }
double ConstellationMgr::getFontSize() const double ConstellationMgr::getFontSize() const
{ {
return asterFont->getSize(); return asterFont.pixelSize();
} }
// Load line and art data from files // Load line and art data from files
void ConstellationMgr::loadLinesAndArt(const QString &fileName, const QStri ng &artfileName, const QString& cultureName) void ConstellationMgr::loadLinesAndArt(const QString &fileName, const QStri ng &artfileName, const QString& cultureName)
{ {
QFile in(fileName); QFile in(fileName);
if (!in.open(QIODevice::ReadOnly | QIODevice::Text)) if (!in.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qWarning() << "Can't open constellation data file" << fileNa me << "for culture" << cultureName; qWarning() << "Can't open constellation data file" << fileNa me << "for culture" << cultureName;
Q_ASSERT(0); Q_ASSERT(0);
skipping to change at line 305 skipping to change at line 299
while (!in.atEnd()) while (!in.atEnd())
{ {
record = QString::fromUtf8(in.readLine()); record = QString::fromUtf8(in.readLine());
currentLineNumber++; currentLineNumber++;
if (commentRx.exactMatch(record)) if (commentRx.exactMatch(record))
continue; continue;
cons = new Constellation; cons = new Constellation;
if(cons->read(record, hipStarMgr)) if(cons->read(record, hipStarMgr))
{ {
cons->artFader.setMaxValue(artMaxIntensity);
asterisms.push_back(cons); asterisms.push_back(cons);
++readOk; ++readOk;
} }
else else
{ {
qWarning() << "ERROR reading constellation rec at li ne " << currentLineNumber << "for culture" << cultureName; qWarning() << "ERROR reading constellation rec at li ne " << currentLineNumber << "for culture" << cultureName;
delete cons; delete cons;
} }
} }
in.close(); in.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "constellat ion records successfully for culture" << cultureName; qDebug() << "Loaded" << readOk << "/" << totalRecords << "constellat ion records successfully for culture" << cultureName;
// Set current states // Set current states
setFlagArt(flagArt); setFlagArt(flagArt);
setFlagLines(flagLines); setFlagLines(flagLines);
setFlagLabels(flagNames); setFlagLabels(flagNames);
setFlagBoundaries(flagBoundaries); setFlagBoundaries(flagBoundaries);
// It's possible to have no art - just constellations
if (artfileName.isNull() || artfileName.isEmpty())
return;
QFile fic(artfileName); QFile fic(artfileName);
if (!fic.open(QIODevice::ReadOnly | QIODevice::Text)) if (!fic.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qWarning() << "Can't open constellation art file" << fileNam e << "for culture" << cultureName; qWarning() << "Can't open constellation art file" << fileNam e << "for culture" << cultureName;
return; // possible to have no art - just constellations return;
Q_ASSERT(0);
} }
totalRecords=0; totalRecords=0;
while (!fic.atEnd()) while (!fic.atEnd())
{ {
record = QString::fromUtf8(fic.readLine()); record = QString::fromUtf8(fic.readLine());
if (!commentRx.exactMatch(record)) if (!commentRx.exactMatch(record))
totalRecords++; totalRecords++;
} }
fic.seek(0); fic.seek(0);
skipping to change at line 356 skipping to change at line 353
// x2 y2 are the x and y texture coordinates in pixels of the star o f hipparcos number hp2 // x2 y2 are the x and y texture coordinates in pixels of the star o f hipparcos number hp2
// The coordinate are taken with (0,0) at the top left corner of the image file // The coordinate are taken with (0,0) at the top left corner of the image file
QString shortname; QString shortname;
QString texfile; QString texfile;
unsigned int x1, y1, x2, y2, x3, y3, hp1, hp2, hp3; unsigned int x1, y1, x2, y2, x3, y3, hp1, hp2, hp3;
QString tmpstr; QString tmpstr;
currentLineNumber = 0; // line in file currentLineNumber = 0; // line in file
readOk = 0; // count of records processed OK readOk = 0; // count of records processed OK
StelApp::getInstance().getTextureManager().setDefaultParams();
StelLoadingBar& lb = *StelApp::getInstance().getStelLoadingBar();
while (!fic.atEnd()) while (!fic.atEnd())
{ {
++currentLineNumber; ++currentLineNumber;
record = QString::fromUtf8(fic.readLine()); record = QString::fromUtf8(fic.readLine());
if (commentRx.exactMatch(record)) if (commentRx.exactMatch(record))
continue; continue;
// prevent leaving zeros on numbers from being interpretted as octal numbers // prevent leaving zeros on numbers from being interpretted as octal numbers
record.replace(" 0", " "); record.replace(" 0", " ");
QTextStream rStr(&record); QTextStream rStr(&record);
rStr >> shortname >> texfile >> x1 >> y1 >> hp1 >> x2 >> y2 >> hp2 >> x3 >> y3 >> hp3; rStr >> shortname >> texfile >> x1 >> y1 >> hp1 >> x2 >> y2 >> hp2 >> x3 >> y3 >> hp3;
if (rStr.status()!=QTextStream::Ok) if (rStr.status()!=QTextStream::Ok)
{ {
qWarning() << "ERROR parsing constellation art recor d at line" << currentLineNumber << "of art file for culture" << cultureName ; qWarning() << "ERROR parsing constellation art recor d at line" << currentLineNumber << "of art file for culture" << cultureName ;
continue; continue;
} }
// Draw loading bar // Draw loading bar
lb.SetMessage(q_("Loading Constellation Art: %1/%2").arg(cur // lb.SetMessage(q_("Loading Constellation Art: %1/%2").arg(cur
rentLineNumber).arg(totalRecords)); rentLineNumber).arg(totalRecords));
lb.Draw((float)(currentLineNumber)/totalRecords); // lb.Draw((float)(currentLineNumber)/totalRecords);
cons = NULL; cons = NULL;
cons = findFromAbbreviation(shortname); cons = findFromAbbreviation(shortname);
if (!cons) if (!cons)
{ {
qWarning() << "ERROR in constellation art file at li ne" << currentLineNumber << "for culture" << cultureName qWarning() << "ERROR in constellation art file at li ne" << currentLineNumber << "for culture" << cultureName
<< "constellation" << shortname << "unkno wn"; << "constellation" << shortname < < "unknown";
} }
else else
{ {
StelApp::getInstance().getTextureManager().setDefaul tParams();
QString texturePath(texfile); QString texturePath(texfile);
try try
{ {
texturePath = StelApp::getInstance().getFile Mgr().findFile("skycultures/"+cultureName+"/"+texfile); texturePath = StelFileMgr::findFile("skycult ures/"+cultureName+"/"+texfile);
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
// if the texture isn't found in the skycult ures/[culture] directory, // if the texture isn't found in the skycult ures/[culture] directory,
// try the central textures diectory. // try the central textures diectory.
qWarning() << "WARNING, could not locate tex ture file " << texfile qWarning() << "WARNING, could not locate tex ture file " << texfile
<< " in the skycultures/" << cultureNam << " in the skycultures/" << cultur
e eName
<< " directory... looking in general t << " directory... looking in gener
extures/ directory..."; al textures/ directory...";
try try
{ {
texturePath = StelApp::getInstance() .getFileMgr().findFile(QString("textures/")+texfile); texturePath = StelFileMgr::findFile( QString("textures/")+texfile);
} }
catch(exception& e2) catch(exception& e2)
{ {
qWarning() << "ERROR: could not find texture, " << texfile << ": " << e2.what(); qWarning() << "ERROR: could not find texture, " << texfile << ": " << e2.what();
} }
} }
cons->artTexture = StelApp::getInstance().getTexture Manager().createTextureThread(texturePath); cons->artTexture = StelApp::getInstance().getTexture Manager().createTextureThread(texturePath);
int texSizeX, texSizeY; int texSizeX, texSizeY;
skipping to change at line 433 skipping to change at line 427
// To transform from texture coordinate to 2d coordi nate we need to find X with XA = B // To transform from texture coordinate to 2d coordi nate we need to find X with XA = B
// A formed of 4 points in texture coordinate, B for med with 4 points in 3d coordinate // A formed of 4 points in texture coordinate, B for med with 4 points in 3d coordinate
// We need 3 stars and the 4th point is deduced from the other to get an normal base // We need 3 stars and the 4th point is deduced from the other to get an normal base
// X = B inv(A) // X = B inv(A)
Vec3f s4 = s1 + ((s2 - s1) ^ (s3 - s1)); Vec3f s4 = s1 + ((s2 - s1) ^ (s3 - s1));
Mat4f B(s1[0], s1[1], s1[2], 1, s2[0], s2[1], s2[2], 1, s3[0], s3[1], s3[2], 1, s4[0], s4[1], s4[2], 1); Mat4f B(s1[0], s1[1], s1[2], 1, s2[0], s2[1], s2[2], 1, s3[0], s3[1], s3[2], 1, s4[0], s4[1], s4[2], 1);
Mat4f A(x1, texSizeY - y1, 0.f, 1.f, x2, texSizeY - y2, 0.f, 1.f, x3, texSizeY - y3, 0.f, 1.f, x1, texSizeY - y1, texSizeX, 1.f ); Mat4f A(x1, texSizeY - y1, 0.f, 1.f, x2, texSizeY - y2, 0.f, 1.f, x3, texSizeY - y3, 0.f, 1.f, x1, texSizeY - y1, texSizeX, 1.f );
Mat4f X = B * A.inverse(); Mat4f X = B * A.inverse();
cons->artVertex[0] = Vec3f(X * Vec3f(0, 0, 0)); QVector<Vec3d> contour(4);
cons->artVertex[1] = Vec3f(X * Vec3f(texSizeX / 2, 0 contour[0] = X * Vec3f(0., 0., 0.);
, 0)); contour[1] = X * Vec3f(texSizeX, 0., 0.);
cons->artVertex[2] = Vec3f(X * Vec3f(texSizeX / 2, t contour[2] = X * Vec3f(texSizeX, texSizeY, 0.);
exSizeY / 2, 0)); contour[3] = X * Vec3f(0, texSizeY, 0.);
cons->artVertex[3] = Vec3f(X * Vec3f(0, texSizeY / 2 contour[0].normalize();
, 0)); contour[1].normalize();
cons->artVertex[4] = Vec3f(X * Vec3f(texSizeX / 2 + contour[2].normalize();
texSizeX / 2, 0, 0)); contour[3].normalize();
cons->artVertex[5] = Vec3f(X * Vec3f(texSizeX / 2 +
texSizeX / 2, texSizeY / 2, 0)); QVector<Vec2f> texCoords(4);
cons->artVertex[6] = Vec3f(X * Vec3f(texSizeX / 2 + texCoords[0].set(0,0);
texSizeX / 2, texSizeY / 2 + texSizeY / 2, 0)); texCoords[1].set(1,0);
cons->artVertex[7] = Vec3f(X * Vec3f(texSizeX / 2 + texCoords[2].set(1,1);
0, texSizeY / 2 + texSizeY / 2, 0)); texCoords[3].set(0,1);
cons->artVertex[8] = Vec3f(X * Vec3f(0, texSizeY / 2 cons->artPolygon.setContour(contour, texCoords);
+ texSizeY / 2, 0)); Q_ASSERT(cons->artPolygon.checkValid());
++readOk; ++readOk;
} }
} }
qDebug() << "Loaded" << readOk << "/" << totalRecords << "constellat ion art records successfully for culture" << cultureName; qDebug() << "Loaded" << readOk << "/" << totalRecords << "constellat ion art records successfully for culture" << cultureName;
fic.close(); fic.close();
} }
void ConstellationMgr::draw(StelCore* core) void ConstellationMgr::draw(StelCore* core)
{ {
StelNavigator* nav = core->getNavigator(); StelNavigator* nav = core->getNavigator();
const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ; const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ;
StelPainter sPainter(prj); StelPainter sPainter(prj);
sPainter.setFont(asterFont);
drawLines(sPainter, nav); drawLines(sPainter, nav);
drawNames(sPainter); drawNames(sPainter);
drawArt(prj, nav); drawArt(sPainter);
drawBoundaries(prj); drawBoundaries(sPainter);
} }
// Draw constellations art textures // Draw constellations art textures
void ConstellationMgr::drawArt(const StelProjectorP& prj, const StelNavigat or * nav) const void ConstellationMgr::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);
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
SphericalRegionP region = sPainter.getProjector()->getViewportConvex Polygon();
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{ {
(*iter)->drawArtOptim(prj, nav); (*iter)->drawArtOptim(sPainter, *region);
} }
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
} }
// Draw constellations lines // Draw constellations lines
void ConstellationMgr::drawLines(const StelPainter& sPainter, const StelNav igator* nav) const void ConstellationMgr::drawLines(StelPainter& sPainter, const StelNavigator * nav) const
{ {
glDisable(GL_TEXTURE_2D); sPainter.enableTexture2d(false);
glDisable(GL_BLEND); glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
const SphericalCap viewportHalfspace = sPainter.getProjector()->getB
oundingSphericalCap();
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{ {
(*iter)->drawOptim(sPainter, nav); (*iter)->drawOptim(sPainter, nav, viewportHalfspace);
} }
glDisable(GL_LINE_SMOOTH);
} }
// Draw the names of all the constellations // Draw the names of all the constellations
void ConstellationMgr::drawNames(const StelPainter& sPainter) const void ConstellationMgr::drawNames(StelPainter& sPainter) const
{ {
glEnable(GL_BLEND); glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D); sPainter.enableTexture2d(true);
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
// if (draw_mode == DM_NORMAL) glBlendFunc(GL_ONE, GL_ONE); // if (draw_mode == DM_NORMAL) glBlendFunc(GL_ONE, GL_ONE);
// else glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // charti ng // else glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // charti ng
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); iter++) for (iter = asterisms.begin(); iter != asterisms.end(); iter++)
{ {
// Check if in the field of view // Check if in the field of view
if (sPainter.getProjector()->projectCheck((*iter)->XYZname, (*iter)->XYname)) if (sPainter.getProjector()->projectCheck((*iter)->XYZname, (*iter)->XYname))
(*iter)->drawName(asterFont, sPainter); (*iter)->drawName(sPainter);
} }
} }
Constellation *ConstellationMgr::isStarIn(const StelObject* s) const Constellation *ConstellationMgr::isStarIn(const StelObject* s) const
{ {
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{ {
// Check if the star is in one of the constellation // Check if the star is in one of the constellation
if ((*iter)->isStarIn(s)) if ((*iter)->isStarIn(s))
skipping to change at line 621 skipping to change at line 622
qWarning() << "WARNING - constellation abbre viation" << shortName << "not found when loading constellation names"; qWarning() << "WARNING - constellation abbre viation" << shortName << "not found when loading constellation names";
} }
} }
} }
commonNameFile.close(); commonNameFile.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "constellat ion names"; qDebug() << "Loaded" << readOk << "/" << totalRecords << "constellat ion names";
} }
void ConstellationMgr::updateI18n() void ConstellationMgr::updateI18n()
{ {
StelTranslator trans(PACKAGE_NAME "-skycultures", StelApp::getInstan ce().getFileMgr().getLocaleDir(), StelApp::getInstance().getLocaleMgr().get SkyTranslator().getTrueLocaleName()); StelTranslator trans("stellarium-skycultures", StelFileMgr::getLocal eDir(), StelApp::getInstance().getLocaleMgr().getSkyTranslator().getTrueLoc aleName());
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{ {
(*iter)->nameI18 = trans.qtranslate((*iter)->englishName); (*iter)->nameI18 = trans.qtranslate((*iter)->englishName);
} }
asterFont = &StelApp::getInstance().getFontManager().getStandardFont (trans.getTrueLocaleName(), fontSize);
} }
// update faders // update faders
void ConstellationMgr::update(double deltaTime) void ConstellationMgr::update(double deltaTime)
{ {
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{ {
(*iter)->update((int)(deltaTime*1000)); (*iter)->update((int)(deltaTime*1000));
} }
skipping to change at line 781 skipping to change at line 781
} }
} }
if(!match) if(!match)
{ {
// Not selected constellation // Not selected constellation
(*iter)->setFlagLines(false); (*iter)->setFlagLines(false);
(*iter)->setFlagName(false); (*iter)->setFlagName(false);
(*iter)->setFlagArt(false); (*iter)->setFlagArt(false);
(*iter)->setFlagBoundaries(false); (*iter)->setFlagBoundaries(false);
} }
} }
Constellation::singleSelected = true; // For bounda ries Constellation::singleSelected = true; // For bounda ries
} }
else else
Constellation::singleSelected = false; // For bounda ries Constellation::singleSelected = false; // For bounda ries
} }
else else
{ {
if (selected.begin() == selected.end()) return; if (selected.begin() == selected.end()) return;
// Otherwise apply standard flags to all constellations // Otherwise apply standard flags to all constellations
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++it er) for (iter = asterisms.begin(); iter != asterisms.end(); ++it er)
skipping to change at line 939 skipping to change at line 939
i++; i++;
} }
dataFile.close(); dataFile.close();
qDebug() << "Loaded" << i << "constellation boundary segments"; qDebug() << "Loaded" << i << "constellation boundary segments";
delete points; delete points;
return true; return true;
} }
void ConstellationMgr::drawBoundaries(const StelProjectorP& prj) const void ConstellationMgr::drawBoundaries(StelPainter& sPainter) const
{ {
glDisable(GL_TEXTURE_2D); sPainter.enableTexture2d(false);
glDisable(GL_BLEND); glDisable(GL_BLEND);
glEnable(GL_LINE_SMOOTH); #ifndef USE_OPENGL_ES2
glLineStipple(2, 0x3333); glLineStipple(2, 0x3333);
glEnable(GL_LINE_STIPPLE); glEnable(GL_LINE_STIPPLE);
#endif
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{ {
(*iter)->drawBoundaryOptim(prj); (*iter)->drawBoundaryOptim(sPainter);
} }
#ifndef USE_OPENGL_ES2
glDisable(GL_LINE_STIPPLE); glDisable(GL_LINE_STIPPLE);
glDisable(GL_LINE_SMOOTH); #endif
} }
///unsigned int ConstellationMgr::getFirstSelectedHP(void) { ///unsigned int ConstellationMgr::getFirstSelectedHP(void) {
/// if (selected) return selected->asterism[0]->get_hp_number(); /// if (selected) return selected->asterism[0]->get_hp_number();
/// return 0; /// return 0;
///} ///}
StelObjectP ConstellationMgr::searchByNameI18n(const QString& nameI18n) con st StelObjectP ConstellationMgr::searchByNameI18n(const QString& nameI18n) con st
{ {
QString objw = nameI18n.toUpper(); QString objw = nameI18n.toUpper();
 End of changes. 54 change blocks. 
84 lines changed or deleted 76 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/