ConstellationMgr.cpp   ConstellationMgr.cpp 
skipping to change at line 125 skipping to change at line 125
{ {
conArtFile = StelFileMgr::findFile("skycultures/"+skyCulture Dir+"/constellationsart.fab"); conArtFile = StelFileMgr::findFile("skycultures/"+skyCulture Dir+"/constellationsart.fab");
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qDebug() << "No constellationsart.fab file found for sky cul ture " << skyCultureDir; qDebug() << "No constellationsart.fab file found for sky cul ture " << skyCultureDir;
} }
try try
{ {
// first of all, remove constellations from the list of sele
cted objects in StelObjectMgr, since we are going to delete them
deselectConstellations();
loadLinesAndArt(StelFileMgr::findFile("skycultures/"+skyCult ureDir+"/constellationship.fab"), conArtFile, skyCultureDir); loadLinesAndArt(StelFileMgr::findFile("skycultures/"+skyCult ureDir+"/constellationship.fab"), conArtFile, skyCultureDir);
// load constellation names // load constellation names
loadNames(StelFileMgr::findFile("skycultures/" + skyCultureD ir + "/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!
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")
{ {
skipping to change at line 210 skipping to change at line 210
setSelected(newSelectedStar[0].data()); setSelected(newSelectedStar[0].data());
} }
else else
{ {
// if (!added) // if (!added)
setSelected(NULL); setSelected(NULL);
} }
} }
} }
void ConstellationMgr::deselectConstellations(void)
{
selected.clear();
StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr);
Q_ASSERT(omgr);
const QList<StelObjectP> currSelection = omgr->getSelectedObject();
if (currSelection.empty())
{
return;
}
QList<StelObjectP> newSelection;
foreach(const StelObjectP& obj, currSelection)
{
if (obj->getType() != "Constellation")
{
newSelection.push_back(obj);
}
}
omgr->setSelectedObject(newSelection, StelModule::ReplaceSelection);
}
void ConstellationMgr::setLinesColor(const Vec3f& c) void ConstellationMgr::setLinesColor(const Vec3f& c)
{ {
Constellation::lineColor = c; Constellation::lineColor = c;
} }
Vec3f ConstellationMgr::getLinesColor() const Vec3f ConstellationMgr::getLinesColor() const
{ {
return Constellation::lineColor; return Constellation::lineColor;
} }
skipping to change at line 277 skipping to change at line 299
totalRecords++; totalRecords++;
} }
in.seek(0); in.seek(0);
// delete existing data, if any // delete existing data, if any
vector < Constellation * >::iterator iter; vector < Constellation * >::iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
delete(*iter); delete(*iter);
asterisms.clear(); asterisms.clear();
selected.clear();
Constellation *cons = NULL; Constellation *cons = NULL;
// read the file, adding a record per non-comment line // read the file, adding a record per non-comment line
int currentLineNumber = 0; // line in file int currentLineNumber = 0; // line in file
int readOk = 0; // count of records processed OK int readOk = 0; // count of records processed OK
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))
skipping to change at line 421 skipping to change at line 442
// 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)
Vec3d s4 = s1 + ((s2 - s1) ^ (s3 - s1)); Vec3d s4 = s1 + ((s2 - s1) ^ (s3 - s1));
Mat4d 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); Mat4d 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);
Mat4d 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 ); Mat4d 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 );
Mat4d X = B * A.inverse(); Mat4d X = B * A.inverse();
QVector<Vec3d> contour(4); // Tesselate on the plan assuming a tangential proje
contour[0] = X * Vec3d(0., 0., 0.); ction for the image
contour[1] = X * Vec3d(texSizeX, 0., 0.); static const int nbPoints=5;
contour[2] = X * Vec3d(texSizeX, texSizeY, 0.); QVector<Vec2f> texCoords;
contour[3] = X * Vec3d(0, texSizeY, 0.); texCoords.reserve(nbPoints*nbPoints*6);
contour[0].normalize(); for (int j=0;j<nbPoints;++j)
contour[1].normalize(); {
contour[2].normalize(); for (int i=0;i<nbPoints;++i)
contour[3].normalize(); {
texCoords << Vec2f(((float)i)/nbPoin
QVector<Vec2f> texCoords(4); ts, ((float)j)/nbPoints);
texCoords[0].set(0,0); texCoords << Vec2f(((float)i+1.f)/nb
texCoords[1].set(1,0); Points, ((float)j)/nbPoints);
texCoords[2].set(1,1); texCoords << Vec2f(((float)i)/nbPoin
texCoords[3].set(0,1); ts, ((float)j+1.f)/nbPoints);
cons->artPolygon.setContour(contour, texCoords); texCoords << Vec2f(((float)i+1.f)/nb
Q_ASSERT(cons->artPolygon.checkValid()); Points, ((float)j)/nbPoints);
texCoords << Vec2f(((float)i+1.f)/nb
Points, ((float)j+1.f)/nbPoints);
texCoords << Vec2f(((float)i)/nbPoin
ts, ((float)j+1.f)/nbPoints);
}
}
QVector<Vec3d> contour;
contour.reserve(texCoords.size());
foreach (const Vec2f& v, texCoords)
contour << X * Vec3d(v[0]*texSizeX, v[1]*tex
SizeY, 0.);
cons->artPolygon.vertex=contour;
cons->artPolygon.texCoords=texCoords;
cons->artPolygon.primitiveType=StelVertexArray::Tria
ngles;
Vec3d tmp(X * Vec3d(0.5*texSizeX, 0.5*texSizeY, 0.))
;
tmp.normalize();
Vec3d tmp2(X * Vec3d(0., 0., 0.));
tmp2.normalize();
cons->boundingCap.n=tmp;
cons->boundingCap.d=tmp*tmp2;
++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)
{ {
skipping to change at line 613 skipping to change at line 649
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("stellarium-skycultures", StelFileMgr::getLocal eDir(), StelApp::getInstance().getLocaleMgr().getSkyTranslator().getTrueLoc aleName()); StelTranslator trans = StelApp::getInstance().getLocaleMgr().getSkyT ranslator();
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);
} }
} }
// update faders // update faders
void ConstellationMgr::update(double deltaTime) void ConstellationMgr::update(double deltaTime)
{ {
skipping to change at line 716 skipping to change at line 752
(*iter)->setFlagName(b); (*iter)->setFlagName(b);
} }
else else
{ {
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)
(*iter)->setFlagName(b); (*iter)->setFlagName(b);
} }
} }
void ConstellationMgr::setFlagIsolateSelected(bool s)
{
isolateSelected = s;
// when turning off isolated selection mode, clear exisiting isolate
d selections.
if (!s)
{
vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++it
er)
{
(*iter)->setFlagLines(getFlagLines());
(*iter)->setFlagName(getFlagLabels());
(*iter)->setFlagArt(getFlagArt());
(*iter)->setFlagBoundaries(getFlagBoundaries());
}
}
}
StelObject* ConstellationMgr::getSelected(void) const { StelObject* ConstellationMgr::getSelected(void) const {
return *selected.begin(); // TODO return all or just remove this me thod return *selected.begin(); // TODO return all or just remove this me thod
} }
void ConstellationMgr::setSelected(const QString& abbreviation) void ConstellationMgr::setSelected(const QString& abbreviation)
{ {
Constellation * c = findFromAbbreviation(abbreviation); Constellation * c = findFromAbbreviation(abbreviation);
if(c != NULL) setSelectedConst(c); if(c != NULL) setSelectedConst(c);
} }
 End of changes. 7 change blocks. 
23 lines changed or deleted 89 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/