ConstellationMgr.cpp   ConstellationMgr.cpp 
skipping to change at line 38 skipping to change at line 38
#include <QRegExp> #include <QRegExp>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#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 "Projector.hpp" #include "StelProjector.hpp"
#include "LoadingBar.hpp" #include "StelLoadingBar.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelFontMgr.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 "SFont.hpp" #include "StelFont.hpp"
#include "StelStyle.hpp" #include "StelStyle.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), fontSize(15),
asterFont(NULL), 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");
assert(hipStarMgr); Q_ASSERT(hipStarMgr);
isolateSelected = false; isolateSelected = false;
} }
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 87 skipping to change at line 88
for (iter1 = allBoundarySegments.begin(); iter1 != allBoundarySegmen ts.end(); ++iter1) for (iter1 = allBoundarySegments.begin(); iter1 != allBoundarySegmen ts.end(); ++iter1)
{ {
delete (*iter1); delete (*iter1);
} }
allBoundarySegments.clear(); allBoundarySegments.clear();
} }
void ConstellationMgr::init() void ConstellationMgr::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
assert(conf); Q_ASSERT(conf);
lastLoadedSkyCulture = "dummy"; lastLoadedSkyCulture = "dummy";
updateSkyCulture(); updateSkyCulture();
fontSize = conf->value("viewing/constellation_font_size",16.).toDoub le(); fontSize = conf->value("viewing/constellation_font_size",16.).toDoub le();
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 teSelected", setFlagIsolateSelected(conf->value("viewing/flag_constellation_isola te_selected",
conf->value("viewing/flag_constellation_pick ", false).toBool() ).toBool()); conf->value("viewing/flag_constellation_pick ", false).toBool() ).toBool());
StelApp::getInstance().getStelObjectMgr().registerStelObjectMgr(this ); StelApp::getInstance().getStelObjectMgr().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)
skipping to change at line 269 skipping to change at line 270
return asterFont->getSize(); return asterFont->getSize();
} }
// 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;
assert(0); Q_ASSERT(0);
} }
int totalRecords=0; int totalRecords=0;
QString record; QString record;
QRegExp commentRx("^(\\s*#.*|\\s*)$"); QRegExp commentRx("^(\\s*#.*|\\s*)$");
while (!in.atEnd()) while (!in.atEnd())
{ {
record = QString::fromUtf8(in.readLine()); record = QString::fromUtf8(in.readLine());
if (!commentRx.exactMatch(record)) if (!commentRx.exactMatch(record))
totalRecords++; totalRecords++;
skipping to change at line 328 skipping to change at line 329
setFlagArt(flagArt); setFlagArt(flagArt);
setFlagLines(flagLines); setFlagLines(flagLines);
setFlagLabels(flagNames); setFlagLabels(flagNames);
setFlagBoundaries(flagBoundaries); setFlagBoundaries(flagBoundaries);
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; // possible to have no art - just constellations
assert(0); 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 357 skipping to change at line 358
// 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(); StelApp::getInstance().getTextureManager().setDefaultParams();
LoadingBar& lb = *StelApp::getInstance().getLoadingBar(); 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);
skipping to change at line 419 skipping to change at line 420
} }
cons->artTexture = StelApp::getInstance().getTexture Manager().createTextureThread(texturePath); cons->artTexture = StelApp::getInstance().getTexture Manager().createTextureThread(texturePath);
int texSizeX, texSizeY; int texSizeX, texSizeY;
if (cons->artTexture==NULL || !cons->artTexture->get Dimensions(texSizeX, texSizeY)) if (cons->artTexture==NULL || !cons->artTexture->get Dimensions(texSizeX, texSizeY))
{ {
qWarning() << "Texture dimension not availab le"; qWarning() << "Texture dimension not availab le";
} }
Vec3f s1 = hipStarMgr->searchHP(hp1)->getObsJ2000Pos Vec3f s1 = hipStarMgr->searchHP(hp1)->getJ2000Equato
(0); rialPos(0);
Vec3f s2 = hipStarMgr->searchHP(hp2)->getObsJ2000Pos Vec3f s2 = hipStarMgr->searchHP(hp2)->getJ2000Equato
(0); rialPos(0);
Vec3f s3 = hipStarMgr->searchHP(hp3)->getObsJ2000Pos Vec3f s3 = hipStarMgr->searchHP(hp3)->getJ2000Equato
(0); rialPos(0);
// 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)); cons->artVertex[0] = Vec3f(X * Vec3f(0, 0, 0));
cons->artVertex[1] = Vec3f(X * Vec3f(texSizeX / 2, 0 , 0)); cons->artVertex[1] = Vec3f(X * Vec3f(texSizeX / 2, 0 , 0));
cons->artVertex[2] = Vec3f(X * Vec3f(texSizeX / 2, t exSizeY / 2, 0)); cons->artVertex[2] = Vec3f(X * Vec3f(texSizeX / 2, t exSizeY / 2, 0));
cons->artVertex[3] = Vec3f(X * Vec3f(0, texSizeY / 2 , 0)); cons->artVertex[3] = Vec3f(X * Vec3f(0, texSizeY / 2 , 0));
cons->artVertex[4] = Vec3f(X * Vec3f(texSizeX / 2 + texSizeX / 2, 0, 0)); cons->artVertex[4] = Vec3f(X * Vec3f(texSizeX / 2 + texSizeX / 2, 0, 0));
cons->artVertex[5] = Vec3f(X * Vec3f(texSizeX / 2 + texSizeX / 2, texSizeY / 2, 0)); cons->artVertex[5] = Vec3f(X * Vec3f(texSizeX / 2 + texSizeX / 2, texSizeY / 2, 0));
skipping to change at line 452 skipping to change at line 453
++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)
{ {
Navigator* nav = core->getNavigation(); StelNavigator* nav = core->getNavigator();
Projector* prj = core->getProjection(); const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000)
;
StelPainter sPainter(prj);
prj->setCurrentFrame(Projector::FrameJ2000);
drawLines(prj); drawLines(prj);
drawNames(prj); drawNames(sPainter);
drawArt(prj, nav); drawArt(prj, nav);
drawBoundaries(prj); drawBoundaries(prj);
} }
// Draw constellations art textures // Draw constellations art textures
void ConstellationMgr::drawArt(Projector * prj, const Navigator * nav) cons t void ConstellationMgr::drawArt(const StelProjectorP& prj, const StelNavigat or * nav) const
{ {
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
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)->drawArtOptim(prj, nav); (*iter)->drawArtOptim(prj, nav);
} }
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
} }
// Draw constellations lines // Draw constellations lines
void ConstellationMgr::drawLines(Projector * prj) const void ConstellationMgr::drawLines(const StelProjectorP& prj) const
{ {
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND); glDisable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
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(prj); (*iter)->drawOptim(prj);
} }
glDisable(GL_LINE_SMOOTH);
} }
// Draw the names of all the constellations // Draw the names of all the constellations
void ConstellationMgr::drawNames(Projector * prj) const void ConstellationMgr::drawNames(const StelPainter& sPainter) const
{ {
glEnable(GL_BLEND); glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
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 (prj->projectCheck((*iter)->XYZname, (*iter)->XYname)) if (sPainter.getProjector()->projectCheck((*iter)->XYZname,
(*iter)->drawName(asterFont, prj); (*iter)->XYname))
(*iter)->drawName(asterFont, 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 619 skipping to change at line 621
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()
{ {
Translator trans(PACKAGE_NAME "-skycultures", StelApp::getInstance() .getFileMgr().getLocaleDir(), StelApp::getInstance().getLocaleMgr().getSkyT ranslator().getTrueLocaleName()); StelTranslator trans(PACKAGE_NAME "-skycultures", StelApp::getInstan ce().getFileMgr().getLocaleDir(), StelApp::getInstance().getLocaleMgr().get SkyTranslator().getTrueLocaleName());
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); asterFont = &StelApp::getInstance().getFontManager().getStandardFont (trans.getTrueLocaleName(), fontSize);
} }
// update faders // update faders
void ConstellationMgr::update(double deltaTime) void ConstellationMgr::update(double deltaTime)
skipping to change at line 937 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(Projector * prj) const void ConstellationMgr::drawBoundaries(const StelProjectorP& prj) const
{ {
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND); glDisable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
glLineStipple(2, 0x3333); glLineStipple(2, 0x3333);
glEnable(GL_LINE_STIPPLE); glEnable(GL_LINE_STIPPLE);
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(prj);
} }
glDisable(GL_LINE_STIPPLE); glDisable(GL_LINE_STIPPLE);
glDisable(GL_LINE_SMOOTH);
} }
///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. 24 change blocks. 
29 lines changed or deleted 34 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/