ConstellationMgr.cpp   ConstellationMgr.cpp 
skipping to change at line 20 skipping to change at line 20
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* 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.
*/ */
// Class used to manage group of constellation
#include <config.h>
#include <vector> #include <vector>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QSettings> #include <QSettings>
#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 "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelLoadingBar.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.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 "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) :
hipStarMgr(_hip_stars), hipStarMgr(_hip_stars),
flagNames(0), flagNames(0),
flagLines(0), flagLines(0),
flagArt(0), flagArt(0),
skipping to change at line 88 skipping to change at line 82
} }
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";
asterFont.setPixelSize(conf->value("viewing/constellation_font_size" ,16).toInt()); 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 setArtIntensity(conf->value("viewing/constellation_art_intensity", 0
.5).toDouble()); .5f).toFloat());
setArtFadeDuration(conf->value("viewing/constellation_art_fade_durat setArtFadeDuration(conf->value("viewing/constellation_art_fade_durat
ion",2.).toDouble()); ion",2.f).toFloat());
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());
GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this); GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this);
} }
/************************************************************************* /*************************************************************************
Reimplementation of the getCallOrder method Reimplementation of the getCallOrder method
*************************************************************************/ *************************************************************************/
skipping to change at line 164 skipping to change at line 158
} }
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;
} }
void ConstellationMgr::setStelStyle(const StelStyle& style) void ConstellationMgr::setStelStyle(const QString& section)
{ {
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 QString defaultColor = conf->value(section+"/default_color").toStrin
olor").toString(); g();
setLinesColor(StelUtils::strToVec3f(conf->value(style.confSectionNam setLinesColor(StelUtils::strToVec3f(conf->value(section+"/const_line
e+"/const_lines_color", defaultColor).toString())); s_color", defaultColor).toString()));
setBoundariesColor(StelUtils::strToVec3f(conf->value(style.confSecti setBoundariesColor(StelUtils::strToVec3f(conf->value(section+"/const
onName+"/const_boundary_color", "0.8,0.3,0.3").toString())); _boundary_color", "0.8,0.3,0.3").toString()));
setLabelsColor(StelUtils::strToVec3f(conf->value(style.confSectionNa setLabelsColor(StelUtils::strToVec3f(conf->value(section+"/const_nam
me+"/const_names_color", defaultColor).toString())); es_color", defaultColor).toString()));
} }
void ConstellationMgr::selectedObjectChangeCallBack(StelModuleSelectAction action) void ConstellationMgr::selectedObjectChangeCallBack(StelModuleSelectAction action)
{ {
StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr); StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr);
Q_ASSERT(omgr); Q_ASSERT(omgr);
const QList<StelObjectP> newSelected = omgr->getSelectedObject(); 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
skipping to change at line 246 skipping to change at line 240
void ConstellationMgr::setLabelsColor(const Vec3f& c) void ConstellationMgr::setLabelsColor(const Vec3f& c)
{ {
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(float newFontSize)
{ {
asterFont.setPixelSize(newFontSize); asterFont.setPixelSize(newFontSize);
} }
double ConstellationMgr::getFontSize() const float ConstellationMgr::getFontSize() const
{ {
return asterFont.pixelSize(); 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))
{ {
skipping to change at line 414 skipping to change at line 408
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";
} }
const StelNavigator* nav = StelApp::getInstance().ge tCore()->getNavigator(); const StelNavigator* nav = StelApp::getInstance().ge tCore()->getNavigator();
Vec3f s1 = hipStarMgr->searchHP(hp1)->getJ2000Equato Vec3d s1 = hipStarMgr->searchHP(hp1)->getJ2000Equato
rialPos(nav); rialPos(nav);
Vec3f s2 = hipStarMgr->searchHP(hp2)->getJ2000Equato Vec3d s2 = hipStarMgr->searchHP(hp2)->getJ2000Equato
rialPos(nav); rialPos(nav);
Vec3f s3 = hipStarMgr->searchHP(hp3)->getJ2000Equato Vec3d s3 = hipStarMgr->searchHP(hp3)->getJ2000Equato
rialPos(nav); 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)); Vec3d s4 = s1 + ((s2 - s1) ^ (s3 - s1));
Mat4f B(s1[0], s1[1], s1[2], 1, s2[0], s2[1], s2[2], 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); 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 - 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 y2, 0.f, 1.f, x3, texSizeY - y3, 0.f, 1.f, x1, texSizeY - y1, texSizeX, 1.f
); );
Mat4f X = B * A.inverse(); Mat4d X = B * A.inverse();
QVector<Vec3d> contour(4); QVector<Vec3d> contour(4);
contour[0] = X * Vec3f(0., 0., 0.); contour[0] = X * Vec3d(0., 0., 0.);
contour[1] = X * Vec3f(texSizeX, 0., 0.); contour[1] = X * Vec3d(texSizeX, 0., 0.);
contour[2] = X * Vec3f(texSizeX, texSizeY, 0.); contour[2] = X * Vec3d(texSizeX, texSizeY, 0.);
contour[3] = X * Vec3f(0, texSizeY, 0.); contour[3] = X * Vec3d(0, texSizeY, 0.);
contour[0].normalize(); contour[0].normalize();
contour[1].normalize(); contour[1].normalize();
contour[2].normalize(); contour[2].normalize();
contour[3].normalize(); contour[3].normalize();
QVector<Vec2f> texCoords(4); QVector<Vec2f> texCoords(4);
texCoords[0].set(0,0); texCoords[0].set(0,0);
texCoords[1].set(1,0); texCoords[1].set(1,0);
texCoords[2].set(1,1); texCoords[2].set(1,1);
texCoords[3].set(0,1); texCoords[3].set(0,1);
skipping to change at line 488 skipping to change at line 482
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
} }
// Draw constellations lines // Draw constellations lines
void ConstellationMgr::drawLines(StelPainter& sPainter, const StelNavigator * nav) const void ConstellationMgr::drawLines(StelPainter& sPainter, const StelNavigator * nav) const
{ {
sPainter.enableTexture2d(false); sPainter.enableTexture2d(false);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
const SphericalCap viewportHalfspace = sPainter.getProjector()->getB oundingSphericalCap(); const SphericalCap& viewportHalfspace = sPainter.getProjector()->get BoundingCap();
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, viewportHalfspace); (*iter)->drawOptim(sPainter, nav, viewportHalfspace);
} }
} }
// Draw the names of all the constellations // Draw the names of all the constellations
void ConstellationMgr::drawNames(StelPainter& sPainter) const void ConstellationMgr::drawNames(StelPainter& sPainter) const
{ {
glEnable(GL_BLEND); glEnable(GL_BLEND);
sPainter.enableTexture2d(true); sPainter.enableTexture2d(true);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
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
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(sPainter); (*iter)->drawName(sPainter);
} }
} }
Constellation *ConstellationMgr::isStarIn(const StelObject* s) const Constellation *ConstellationMgr::isStarIn(const StelObject* s) const
skipping to change at line 543 skipping to change at line 534
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)
{ {
if ((*iter)->abbreviation == tname) if ((*iter)->abbreviation == tname)
return (*iter); return (*iter);
} }
return NULL; return NULL;
} }
// Can't find constellation from a position because it's not well localized // Can't find constellation from a position because it's not well localized
QList<StelObjectP> ConstellationMgr::searchAround(const Vec3d& v, double li mitFov, const StelCore* core) const QList<StelObjectP> ConstellationMgr::searchAround(const Vec3d&, double, con st StelCore*) const
{ {
return QList<StelObjectP>(); return QList<StelObjectP>();
} }
void ConstellationMgr::loadNames(const QString& namesFile) void ConstellationMgr::loadNames(const QString& namesFile)
{ {
// Constellation not loaded yet // Constellation not loaded yet
if (asterisms.empty()) return; if (asterisms.empty()) return;
// clear previous names // clear previous names
skipping to change at line 634 skipping to change at line 625
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)
{ {
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
const int delta = (int)(deltaTime*1000);
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{ {
(*iter)->update((int)(deltaTime*1000)); (*iter)->update(delta);
} }
} }
void ConstellationMgr::setArtIntensity(double _max) void ConstellationMgr::setArtIntensity(double _max)
{ {
artMaxIntensity = _max; artMaxIntensity = _max;
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)->artFader.setMaxValue(_max); (*iter)->artFader.setMaxValue(_max);
} }
 End of changes. 17 change blocks. 
47 lines changed or deleted 38 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/