ConstellationMgr.cpp   ConstellationMgr.cpp 
skipping to change at line 91 skipping to change at line 91
} }
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";
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 te_selected", 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 );
} }
/************************************************************************* /*************************************************************************
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() void ConstellationMgr::updateSkyCulture(const QString& skyCultureDir)
{ {
QString newSkyCulture = StelApp::getInstance().getSkyCultureMgr().ge tCurrentSkyCultureID();
StelFileMgr& fileMan = StelApp::getInstance().getFileMgr(); 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 == newSkyCulture) 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/"+newSkyCulture+" /constellationsart.fab"); conArtFile = fileMan.findFile("skycultures/"+skyCultureDir+" /constellationsart.fab");
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qWarning() << "WARNING: no constellationsart.fab file found for sky culture " << newSkyCulture; qWarning() << "WARNING: no constellationsart.fab file found for sky culture " << skyCultureDir;
} }
try try
{ {
loadLinesAndArt(fileMan.findFile("skycultures/"+newSkyCultur e+"/constellationship.fab"), conArtFile, newSkyCulture); loadLinesAndArt(fileMan.findFile("skycultures/"+skyCultureDi r+"/constellationship.fab"), conArtFile, skyCultureDir);
// load constellation names // load constellation names
loadNames(fileMan.findFile("skycultures/" + newSkyCulture + "/constellation_names.eng.fab")); loadNames(fileMan.findFile("skycultures/" + skyCultureDir + "/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 "
<< newSkyCulture << ", 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 (newSkyCulture=="western") if (skyCultureDir=="western")
{ {
try try
{ {
loadBoundaries(fileMan.findFile("data/constellations _boundaries.dat")); loadBoundaries(fileMan.findFile("data/constellations _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 = newSkyCulture; lastLoadedSkyCulture = skyCultureDir;
} }
void ConstellationMgr::setStelStyle(const StelStyle& style) void ConstellationMgr::setStelStyle(const StelStyle& style)
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
// Load colors from config file // Load colors from config file
QString defaultColor = conf->value(style.confSectionName+"/default_c olor").toString(); QString defaultColor = conf->value(style.confSectionName+"/default_c olor").toString();
setLinesColor(StelUtils::strToVec3f(conf->value(style.confSectionNam e+"/const_lines_color", defaultColor).toString())); setLinesColor(StelUtils::strToVec3f(conf->value(style.confSectionNam e+"/const_lines_color", defaultColor).toString()));
setBoundariesColor(StelUtils::strToVec3f(conf->value(style.confSecti onName+"/const_boundary_color", "0.8,0.3,0.3").toString())); setBoundariesColor(StelUtils::strToVec3f(conf->value(style.confSecti onName+"/const_boundary_color", "0.8,0.3,0.3").toString()));
setLabelsColor(StelUtils::strToVec3f(conf->value(style.confSectionNa me+"/const_names_color", defaultColor).toString())); setLabelsColor(StelUtils::strToVec3f(conf->value(style.confSectionNa me+"/const_names_color", defaultColor).toString()));
} }
void ConstellationMgr::selectedObjectChangeCallBack(StelModuleSelectAction action) void ConstellationMgr::selectedObjectChangeCallBack(StelModuleSelectAction action)
{ {
const QList<StelObjectP> newSelected = StelApp::getInstance().getSte StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr);
lObjectMgr().getSelectedObject(); Q_ASSERT(omgr);
const QList<StelObjectP> newSelected = omgr->getSelectedObject();
if (newSelected.empty()) if (newSelected.empty())
{ {
// 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 = StelApp::getInstance().g etStelObjectMgr().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]); // const boost::intrusive_ptr<Constellation> c = boost::dynamic _pointer_cast<Constellation>(newSelectedConst[0]);
// StelApp::getInstance().getStelObjectMgr().setSelectedObject( c->getBrightestStarInConstellation()); // 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].get());
} 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 ].get());
} }
} }
else else
{ {
const QList<StelObjectP> newSelectedStar = StelApp::getInsta nce().getStelObjectMgr().getSelectedObject("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].get());
} }
else else
{ {
// if (!added) // if (!added)
setSelected(NULL); setSelected(NULL);
skipping to change at line 420 skipping to change at line 419
} }
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)->getJ2000Equato const StelNavigator* nav = StelApp::getInstance().ge
rialPos(0); tCore()->getNavigator();
Vec3f s2 = hipStarMgr->searchHP(hp2)->getJ2000Equato Vec3f s1 = hipStarMgr->searchHP(hp1)->getJ2000Equato
rialPos(0); rialPos(nav);
Vec3f s3 = hipStarMgr->searchHP(hp3)->getJ2000Equato Vec3f s2 = hipStarMgr->searchHP(hp2)->getJ2000Equato
rialPos(0); rialPos(nav);
Vec3f s3 = hipStarMgr->searchHP(hp3)->getJ2000Equato
rialPos(nav);
// 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();
skipping to change at line 457 skipping to change at line 457
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);
drawLines(prj); drawLines(sPainter, nav);
drawNames(sPainter); drawNames(sPainter);
drawArt(prj, nav); drawArt(prj, nav);
drawBoundaries(prj); drawBoundaries(prj);
} }
// Draw constellations art textures // Draw constellations art textures
void ConstellationMgr::drawArt(const StelProjectorP& prj, const StelNavigat or * nav) const 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);
skipping to change at line 481 skipping to change at line 481
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(const StelProjectorP& prj) const void ConstellationMgr::drawLines(const StelPainter& sPainter, const StelNav igator* nav) const
{ {
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND); glDisable(GL_BLEND);
glEnable(GL_LINE_SMOOTH); 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(sPainter, nav);
} }
glDisable(GL_LINE_SMOOTH); 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(const StelPainter& sPainter) const
{ {
glEnable(GL_BLEND); glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
 End of changes. 20 change blocks. 
26 lines changed or deleted 26 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/