ConstellationMgr.cpp   ConstellationMgr.cpp 
skipping to change at line 32 skipping to change at line 32
#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 "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelSkyCultureMgr.hpp" #include "StelSkyCultureMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelMovementMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include <vector> #include <vector>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QSettings> #include <QSettings>
skipping to change at line 55 skipping to change at line 56
#include <QDir> #include <QDir>
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),
constellationDisplayStyle(ConstellationMgr::constellationsTranslat ed), constellationDisplayStyle(ConstellationMgr::constellationsTranslat ed),
artFadeDuration(1.), artFadeDuration(1.),
artIntensity(0), artIntensity(0),
artIntensityMinimumFov(1.0),
artIntensityMaximumFov(2.0),
artDisplayed(0), artDisplayed(0),
boundariesDisplayed(0), boundariesDisplayed(0),
linesDisplayed(0), linesDisplayed(0),
namesDisplayed(0), namesDisplayed(0),
constellationLineThickness(1.f) constellationLineThickness(1.)
{ {
setObjectName("ConstellationMgr"); setObjectName("ConstellationMgr");
Q_ASSERT(hipStarMgr); Q_ASSERT(hipStarMgr);
isolateSelected = false; isolateSelected = false;
constellationPickEnabled = false; constellationPickEnabled = false;
} }
ConstellationMgr::~ConstellationMgr() ConstellationMgr::~ConstellationMgr()
{ {
std::vector<Constellation *>::iterator iter; std::vector<Constellation *>::iterator iter;
skipping to change at line 125 skipping to change at line 128
{ {
setConstellationDisplayStyle(constellationsEnglish); setConstellationDisplayStyle(constellationsEnglish);
} }
else else
{ {
qDebug() << "Warning: viewing/constellation_name_style (" << starloreDisplayStyle << ") invalid. Using translated style."; qDebug() << "Warning: viewing/constellation_name_style (" << starloreDisplayStyle << ") invalid. Using translated style.";
conf->setValue("viewing/constellation_name_style", "translat ed"); conf->setValue("viewing/constellation_name_style", "translat ed");
setConstellationDisplayStyle(constellationsTranslated); setConstellationDisplayStyle(constellationsTranslated);
} }
// Load colors from config file
QString defaultColor = conf->value("color/default_color").toString()
;
setLinesColor(StelUtils::strToVec3f(conf->value("color/const_lines_c
olor", defaultColor).toString()));
setBoundariesColor(StelUtils::strToVec3f(conf->value("color/const_bo
undary_color", "0.8,0.3,0.3").toString()));
setLabelsColor(StelUtils::strToVec3f(conf->value("color/const_names_
color", defaultColor).toString()));
StelObjectMgr *objectManager = GETSTELMODULE(StelObjectMgr); StelObjectMgr *objectManager = GETSTELMODULE(StelObjectMgr);
objectManager->registerStelObjectMgr(this); objectManager->registerStelObjectMgr(this);
connect(objectManager, SIGNAL(selectedObjectChanged(StelModule::Stel ModuleSelectAction)), connect(objectManager, SIGNAL(selectedObjectChanged(StelModule::Stel ModuleSelectAction)),
this, SLOT(selectedObjectChange(StelModule::StelModu leSelectAction))); this, SLOT(selectedObjectChange(StelModule::StelModu leSelectAction)));
StelApp *app = &StelApp::getInstance(); StelApp *app = &StelApp::getInstance();
connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n())); connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n()));
connect(app, SIGNAL(skyCultureChanged(const QString&)), this, SLOT(u connect(&app->getSkyCultureMgr(), SIGNAL(currentSkyCultureChanged(QS
pdateSkyCulture(const QString&))); tring)), this, SLOT(updateSkyCulture(const QString&)));
connect(app, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT(
setStelStyle(const QString&)));
QString displayGroup = N_("Display Options"); QString displayGroup = N_("Display Options");
addAction("actionShow_Constellation_Lines", displayGroup, N_("Conste llation lines"), "linesDisplayed", "C"); addAction("actionShow_Constellation_Lines", displayGroup, N_("Conste llation lines"), "linesDisplayed", "C");
addAction("actionShow_Constellation_Art", displayGroup, N_("Constell ation art"), "artDisplayed", "R"); addAction("actionShow_Constellation_Art", displayGroup, N_("Constell ation art"), "artDisplayed", "R");
addAction("actionShow_Constellation_Labels", displayGroup, N_("Const ellation labels"), "namesDisplayed", "V"); addAction("actionShow_Constellation_Labels", displayGroup, N_("Const ellation labels"), "namesDisplayed", "V");
addAction("actionShow_Constellation_Boundaries", displayGroup, N_("C onstellation boundaries"), "boundariesDisplayed", "B"); addAction("actionShow_Constellation_Boundaries", displayGroup, N_("C onstellation boundaries"), "boundariesDisplayed", "B");
addAction("actionShow_Constellation_Isolated", displayGroup, N_("Sel ect single constellation"), "isolateSelected"); // no shortcut, sync with G UI
} }
/************************************************************************* /*************************************************************************
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;
skipping to change at line 210 skipping to change at line 219
} }
else else
existBoundaries = true; existBoundaries = true;
if (existBoundaries) if (existBoundaries)
loadBoundaries(fic); loadBoundaries(fic);
lastLoadedSkyCulture = skyCultureDir; lastLoadedSkyCulture = skyCultureDir;
} }
void ConstellationMgr::setStelStyle(const QString& section)
{
QSettings* conf = StelApp::getInstance().getSettings();
// Load colors from config file
QString defaultColor = conf->value(section+"/default_color").toStrin
g();
setLinesColor(StelUtils::strToVec3f(conf->value(section+"/const_line
s_color", defaultColor).toString()));
setBoundariesColor(StelUtils::strToVec3f(conf->value(section+"/const
_boundary_color", "0.8,0.3,0.3").toString()));
setLabelsColor(StelUtils::strToVec3f(conf->value(section+"/const_nam
es_color", defaultColor).toString()));
}
void ConstellationMgr::selectedObjectChange(StelModule::StelModuleSelectAct ion action) void ConstellationMgr::selectedObjectChange(StelModule::StelModuleSelectAct ion 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
// (allows viewing constellations without distraction from s tar pointer animation) // (allows viewing constellations without distraction from s tar pointer animation)
// setSelected(NULL); // setSelected(NULL);
skipping to change at line 343 skipping to change at line 341
asterFont.setPixelSize(newFontSize); asterFont.setPixelSize(newFontSize);
emit fontSizeChanged(newFontSize); emit fontSizeChanged(newFontSize);
} }
} }
float ConstellationMgr::getFontSize() const float ConstellationMgr::getFontSize() const
{ {
return asterFont.pixelSize(); return asterFont.pixelSize();
} }
void ConstellationMgr::setConstellationDisplayStyle(int style) void ConstellationMgr::setConstellationDisplayStyle(ConstellationDisplaySty le style)
{ {
constellationDisplayStyle=(ConstellationMgr::ConstellationDisplaySty if(style!=constellationDisplayStyle)
le) style; {
if (constellationDisplayStyle==constellationsTranslated) constellationDisplayStyle=style;
GETSTELMODULE(SolarSystem)->setFlagTranslatedNames(true); if (constellationDisplayStyle==constellationsTranslated)
else GETSTELMODULE(SolarSystem)->setFlagTranslatedNames(t
GETSTELMODULE(SolarSystem)->setFlagTranslatedNames(false); rue);
else
GETSTELMODULE(SolarSystem)->setFlagTranslatedNames(f
alse);
emit constellationsDisplayStyleChanged(constellationDisplayStyle); emit constellationsDisplayStyleChanged(constellationDisplayS
tyle);
}
} }
QString ConstellationMgr::getConstellationDisplayStyleString() QString ConstellationMgr::getConstellationDisplayStyleString(ConstellationD isplayStyle style)
{ {
ConstellationDisplayStyle displayStyle = getConstellationDisplayStyl return (style == constellationsAbbreviated ? "abbreviated" : (style
e(); == constellationsNative ? "native" : "translated"));
return (displayStyle == constellationsAbbreviated ? "abbreviated" :
(displayStyle == constellationsNative ? "native" : "translated"));
} }
ConstellationMgr::ConstellationDisplayStyle ConstellationMgr::getConstellat ionDisplayStyle() ConstellationMgr::ConstellationDisplayStyle ConstellationMgr::getConstellat ionDisplayStyle()
{ {
return constellationDisplayStyle; return constellationDisplayStyle;
} }
void ConstellationMgr::setConstellationLineThickness(const double thickness ) void ConstellationMgr::setConstellationLineThickness(const float thickness)
{ {
constellationLineThickness = thickness; if(thickness!=constellationLineThickness)
if (constellationLineThickness<=0.f) // The line can not be negative {
or zero thickness constellationLineThickness = thickness;
constellationLineThickness = 1.f; if (constellationLineThickness<=0.f) // The line can not be
negative or zero thickness
constellationLineThickness = 1.f;
emit constellationLineThicknessChanged(thickness);
}
} }
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" << QDir:: toNativeSeparators(fileName) << "for culture" << cultureName; qWarning() << "Can't open constellation data file" << QDir:: toNativeSeparators(fileName) << "for culture" << cultureName;
Q_ASSERT(0); Q_ASSERT(0);
} }
skipping to change at line 852 skipping to change at line 857
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)
{ {
//calculate FOV fade value, linear fade between artIntensityMaximumF
ov and artIntensityMinimumFov
double fov = StelApp::getInstance().getCore()->getMovementMgr()->get
CurrentFov();
Constellation::artIntensityFovScale = qBound(0.0,(fov - artIntensity
MinimumFov) / (artIntensityMaximumFov - artIntensityMinimumFov),1.0);
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
const int delta = (int)(deltaTime*1000); const int delta = (int)(deltaTime*1000);
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{ {
(*iter)->update(delta); (*iter)->update(delta);
} }
} }
void ConstellationMgr::setArtIntensity(const double intensity) void ConstellationMgr::setArtIntensity(const float intensity)
{ {
if (artIntensity != intensity) if (artIntensity != intensity)
{
artIntensity = intensity; artIntensity = intensity;
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(); ++it
{ er)
(*iter)->artFader.setMaxValue(artIntensity); {
(*iter)->artFader.setMaxValue(artIntensity);
}
emit artIntensityChanged(intensity);
} }
emit artIntensityChanged(intensity);
} }
double ConstellationMgr::getArtIntensity() const float ConstellationMgr::getArtIntensity() const
{ {
return artIntensity; return artIntensity;
} }
void ConstellationMgr::setArtIntensityMinimumFov(const double fov)
{
artIntensityMinimumFov = fov;
}
double ConstellationMgr::getArtIntensityMinimumFov() const
{
return artIntensityMinimumFov;
}
void ConstellationMgr::setArtIntensityMaximumFov(const double fov)
{
artIntensityMaximumFov = fov;
}
double ConstellationMgr::getArtIntensityMaximumFov() const
{
return artIntensityMaximumFov;
}
void ConstellationMgr::setArtFadeDuration(const float duration) void ConstellationMgr::setArtFadeDuration(const float duration)
{ {
if (artFadeDuration != duration) if (artFadeDuration != duration)
{
artFadeDuration = duration; artFadeDuration = duration;
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(); ++it
{ er)
(*iter)->artFader.setDuration((int) (duration * 1000.f)); {
(*iter)->artFader.setDuration((int) (duration * 1000
.f));
}
emit artFadeDurationChanged(duration);
} }
emit artFadeDurationChanged(duration);
} }
float ConstellationMgr::getArtFadeDuration() const float ConstellationMgr::getArtFadeDuration() const
{ {
return artFadeDuration; return artFadeDuration;
} }
void ConstellationMgr::setFlagLines(const bool displayed) void ConstellationMgr::setFlagLines(const bool displayed)
{ {
if(linesDisplayed != displayed) if(linesDisplayed != displayed)
skipping to change at line 1240 skipping to change at line 1274
unsigned num, numc; unsigned num, numc;
vector<Vec3f> *points = NULL; vector<Vec3f> *points = NULL;
QString consname; QString consname;
i = 0; i = 0;
while (!istr.atEnd()) while (!istr.atEnd())
{ {
points = new vector<Vec3f>; points = new vector<Vec3f>;
num = 0; num = 0;
istr >> num; istr >> num;
if(num == 0) continue; // empty line if(num == 0) continue; // empty line
for (j=0;j<num;j++) for (j=0;j<num;j++)
{ {
istr >> RA >> DE; istr >> RA >> DE;
RA*=M_PI/12.; // Convert from hours to rad RA*=M_PI/12.; // Convert from hours to rad
DE*=M_PI/180.; // Convert from deg to rad DE*=M_PI/180.; // Convert from deg to rad
// Calc the Cartesian coord with RA and DE // Calc the Cartesian coord with RA and DE
StelUtils::spheToRect(RA,DE,XYZ); StelUtils::spheToRect(RA,DE,XYZ);
skipping to change at line 1323 skipping to change at line 1357
{ {
QString objwcap = (*iter)->englishName.toUpper(); QString objwcap = (*iter)->englishName.toUpper();
if (objwcap==objw) return *iter; if (objwcap==objw) return *iter;
objwcap = (*iter)->abbreviation.toUpper(); objwcap = (*iter)->abbreviation.toUpper();
if (objwcap==objw) return *iter; if (objwcap==objw) return *iter;
} }
return NULL; return NULL;
} }
QStringList ConstellationMgr::listMatchingObjectsI18n(const QString& objPre fix, int maxNbItem, bool useStartOfWords) const QStringList ConstellationMgr::listMatchingObjects(const QString& objPrefix, int maxNbItem, bool useStartOfWords, bool inEnglish) const
{ {
QStringList result; QStringList result;
if (maxNbItem==0) return result; if (maxNbItem <= 0)
QString cn;
bool find;
vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{ {
cn = (*iter)->getNameI18n(); return result;
find = false;
if (useStartOfWords)
{
//if (objPrefix.toUpper()==cn.mid(0, objPrefix.size(
)).toUpper()) // WHY SO LONG?
if (cn.startsWith(objPrefix, Qt::CaseInsensitive))
find = true;
}
else
{
if (cn.contains(objPrefix,Qt::CaseInsensitive))
find = true;
}
if (find)
{
result << cn;
if (result.size()==maxNbItem)
return result;
}
} }
return result;
}
QStringList ConstellationMgr::listMatchingObjects(const QString& objPrefix,
int maxNbItem, bool useStartOfWords) const
{
QStringList result;
if (maxNbItem==0) return result;
QString cn; vector<Constellation*>::const_iterator iter;
bool find;
vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{ {
cn = (*iter)->getEnglishName(); QString name = inEnglish ? (*iter)->getEnglishName() : (*ite
find = false; r)->getNameI18n();
if (useStartOfWords) if (!matchObjectName(name, objPrefix, useStartOfWords))
{
//if (objPrefix.toUpper()==cn.mid(0, objPrefix.size(
)).toUpper()) // WHY SO LONG?
if (cn.startsWith(objPrefix, Qt::CaseInsensitive))
find = true;
}
else
{ {
if (cn.contains(objPrefix,Qt::CaseInsensitive)) continue;
find = true;
} }
if (find)
result.append(name);
if (result.size() >= maxNbItem)
{ {
result << cn; break;
if (result.size()==maxNbItem)
return result;
} }
} }
result.sort();
return result; return result;
} }
QStringList ConstellationMgr::listAllObjects(bool inEnglish) const QStringList ConstellationMgr::listAllObjects(bool inEnglish) const
{ {
QStringList result; QStringList result;
if (inEnglish) if (inEnglish)
{ {
foreach(Constellation* constellation, asterisms) foreach(Constellation* constellation, asterisms)
{ {
 End of changes. 35 change blocks. 
105 lines changed or deleted 105 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/