AsterismMgr.cpp   AsterismMgr.cpp 
skipping to change at line 50 skipping to change at line 50
#include <QSettings> #include <QSettings>
#include <QRegExp> #include <QRegExp>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#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
AsterismMgr::AsterismMgr(StarMgr *_hip_stars) AsterismMgr::AsterismMgr(StarMgr *_hip_stars)
: hipStarMgr(_hip_stars), : hipStarMgr(_hip_stars)
linesDisplayed(0), , linesDisplayed(false)
namesDisplayed(0), , rayHelpersDisplayed(false)
hasAsterism(0), , namesDisplayed(false)
asterismLineThickness(1.) , hasAsterism(false)
, asterismLineThickness(1)
, rayHelperThickness(1)
{ {
setObjectName("AsterismMgr"); setObjectName("AsterismMgr");
Q_ASSERT(hipStarMgr); Q_ASSERT(hipStarMgr);
} }
AsterismMgr::~AsterismMgr() AsterismMgr::~AsterismMgr()
{ {
std::vector<Asterism *>::iterator iter; std::vector<Asterism *>::iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); iter++) for (iter = asterisms.begin(); iter != asterisms.end(); iter++)
skipping to change at line 78 skipping to change at line 80
} }
void AsterismMgr::init() void AsterismMgr::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/asterism_font_size", 14) .toInt()); asterFont.setPixelSize(conf->value("viewing/asterism_font_size", 14) .toInt());
setFlagLines(conf->value("viewing/flag_asterism_drawing").toBool()); setFlagLines(conf->value("viewing/flag_asterism_drawing").toBool());
setFlagRayHelpers(conf->value("viewing/flag_rayhelper_drawing").toBo ol());
setFlagLabels(conf->value("viewing/flag_asterism_name").toBool()); setFlagLabels(conf->value("viewing/flag_asterism_name").toBool());
setAsterismLineThickness(conf->value("viewing/asterism_line_thicknes setAsterismLineThickness(conf->value("viewing/asterism_line_thicknes
s", 1.f).toFloat()); s", 1).toInt());
setRayHelperThickness(conf->value("viewing/rayhelper_line_thickness"
, 1).toInt());
// Load colors from config file // Load colors from config file
QString defaultColor = conf->value("color/default_color").toString() ; QString defaultColor = conf->value("color/default_color").toString() ;
setLinesColor(StelUtils::strToVec3f(conf->value("color/asterism_line s_color", defaultColor).toString())); setLinesColor(StelUtils::strToVec3f(conf->value("color/asterism_line s_color", defaultColor).toString()));
setLabelsColor(StelUtils::strToVec3f(conf->value("color/asterism_nam es_color", defaultColor).toString())); setLabelsColor(StelUtils::strToVec3f(conf->value("color/asterism_nam es_color", defaultColor).toString()));
setRayHelpersColor(StelUtils::strToVec3f(conf->value("color/rayhelpe r_lines_color", defaultColor).toString()));
StelObjectMgr *objectManager = GETSTELMODULE(StelObjectMgr); StelObjectMgr *objectManager = GETSTELMODULE(StelObjectMgr);
objectManager->registerStelObjectMgr(this); objectManager->registerStelObjectMgr(this);
StelApp *app = &StelApp::getInstance(); StelApp *app = &StelApp::getInstance();
connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n())); connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n()));
connect(&app->getSkyCultureMgr(), SIGNAL(currentSkyCultureChanged(QS tring)), this, SLOT(updateSkyCulture(const QString&))); connect(&app->getSkyCultureMgr(), SIGNAL(currentSkyCultureChanged(QS tring)), this, SLOT(updateSkyCulture(const QString&)));
QString displayGroup = N_("Display Options"); QString displayGroup = N_("Display Options");
addAction("actionShow_Asterism_Lines", displayGroup, N_("Asterism li nes"), "linesDisplayed", "Alt+A"); addAction("actionShow_Asterism_Lines", displayGroup, N_("Asterism li nes"), "linesDisplayed", "Alt+A");
addAction("actionShow_Asterism_Labels", displayGroup, N_("Asterism l abels"), "namesDisplayed", "Alt+V"); addAction("actionShow_Asterism_Labels", displayGroup, N_("Asterism l abels"), "namesDisplayed", "Alt+V");
addAction("actionShow_Ray_Helpers", displayGroup, N_("Ray helpers"), "rayHelpersDisplayed", "Alt+R");
} }
/************************************************************************* /*************************************************************************
Reimplementation of the getCallOrder method Reimplementation of the getCallOrder method
*************************************************************************/ *************************************************************************/
double AsterismMgr::getCallOrder(StelModuleActionName actionName) const double AsterismMgr::getCallOrder(StelModuleActionName actionName) const
{ {
if (actionName==StelModule::ActionDraw) if (actionName==StelModule::ActionDraw)
return StelApp::getInstance().getModuleMgr().getModule("Grid LinesMgr")->getCallOrder(actionName)+11; return StelApp::getInstance().getModuleMgr().getModule("Grid LinesMgr")->getCallOrder(actionName)+11;
return 0; return 0;
} }
void AsterismMgr::updateSkyCulture(const QString& skyCultureDir) void AsterismMgr::updateSkyCulture(const QString& skyCultureDir)
{ {
currentSkyCultureID = skyCultureDir; currentSkyCultureID = skyCultureDir;
// 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 == skyCultureDir) if (lastLoadedSkyCulture == skyCultureDir)
return; return;
QString fic = StelFileMgr::findFile("skycultures/"+skyCultureDir+"/a sterismship.fab"); QString fic = StelFileMgr::findFile("skycultures/"+skyCultureDir+"/a sterism_lines.fab");
if (fic.isEmpty()) if (fic.isEmpty())
{ {
hasAsterism = false; hasAsterism = false;
qWarning() << "No asterisms for skyculture" << currentSkyCul tureID; qWarning() << "No asterisms for skyculture" << currentSkyCul tureID;
} }
else else
{ {
hasAsterism = true; hasAsterism = true;
loadLines(fic); loadLines(fic);
} }
skipping to change at line 152 skipping to change at line 158
Asterism::lineColor = color; Asterism::lineColor = color;
emit linesColorChanged(color); emit linesColorChanged(color);
} }
} }
Vec3f AsterismMgr::getLinesColor() const Vec3f AsterismMgr::getLinesColor() const
{ {
return Asterism::lineColor; return Asterism::lineColor;
} }
void AsterismMgr::setRayHelpersColor(const Vec3f& color)
{
if (color != Asterism::rayHelperColor)
{
Asterism::rayHelperColor = color;
emit rayHelpersColorChanged(color);
}
}
Vec3f AsterismMgr::getRayHelpersColor() const
{
return Asterism::rayHelperColor;
}
void AsterismMgr::setLabelsColor(const Vec3f& color) void AsterismMgr::setLabelsColor(const Vec3f& color)
{ {
if (Asterism::labelColor != color) if (Asterism::labelColor != color)
{ {
Asterism::labelColor = color; Asterism::labelColor = color;
emit namesColorChanged(color); emit namesColorChanged(color);
} }
} }
Vec3f AsterismMgr::getLabelsColor() const Vec3f AsterismMgr::getLabelsColor() const
skipping to change at line 180 skipping to change at line 200
asterFont.setPixelSize(newFontSize); asterFont.setPixelSize(newFontSize);
emit fontSizeChanged(newFontSize); emit fontSizeChanged(newFontSize);
} }
} }
float AsterismMgr::getFontSize() const float AsterismMgr::getFontSize() const
{ {
return asterFont.pixelSize(); return asterFont.pixelSize();
} }
void AsterismMgr::setAsterismLineThickness(const float thickness) void AsterismMgr::setAsterismLineThickness(const int thickness)
{ {
if(thickness!=asterismLineThickness) if(thickness!=asterismLineThickness)
{ {
asterismLineThickness = thickness; asterismLineThickness = thickness;
if (asterismLineThickness<=0.f) // The line can not be negat if (asterismLineThickness<=0) // The line can not be negativ
ive or zero thickness e or zero thickness
asterismLineThickness = 1.f; asterismLineThickness = 1;
emit asterismLineThicknessChanged(thickness); emit asterismLineThicknessChanged(thickness);
} }
} }
void AsterismMgr::setRayHelperThickness(const int thickness)
{
if(thickness!=rayHelperThickness)
{
rayHelperThickness = thickness;
if (rayHelperThickness<=0) // The line can not be negative o
r zero thickness
rayHelperThickness = 1;
emit rayHelperThicknessChanged(thickness);
}
}
void AsterismMgr::loadLines(const QString &fileName) void AsterismMgr::loadLines(const QString &fileName)
{ {
QFile in(fileName); QFile in(fileName);
if (!in.open(QIODevice::ReadOnly | QIODevice::Text)) if (!in.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qWarning() << "Can't open asterism data file" << QDir::toNat iveSeparators(fileName) << "for culture" << currentSkyCultureID; qWarning() << "Can't open asterism data file" << QDir::toNat iveSeparators(fileName) << "for culture" << currentSkyCultureID;
Q_ASSERT(0); Q_ASSERT(0);
} }
int totalRecords=0; int totalRecords=0;
skipping to change at line 235 skipping to change at line 267
record = QString::fromUtf8(in.readLine()); record = QString::fromUtf8(in.readLine());
currentLineNumber++; currentLineNumber++;
if (commentRx.exactMatch(record)) if (commentRx.exactMatch(record))
continue; continue;
aster = new Asterism; aster = new Asterism;
if(aster->read(record, hipStarMgr)) if(aster->read(record, hipStarMgr))
{ {
aster->setFlagLines(linesDisplayed); aster->setFlagLines(linesDisplayed);
aster->setFlagLabels(namesDisplayed); aster->setFlagLabels(namesDisplayed);
aster->setFlagRayHelpers(rayHelpersDisplayed);
asterisms.push_back(aster); asterisms.push_back(aster);
++readOk; ++readOk;
} }
else else
{ {
qWarning() << "ERROR reading asterism lines record a t line " << currentLineNumber << "for culture" << currentSkyCultureID; qWarning() << "ERROR reading asterism lines record a t line " << currentLineNumber << "for culture" << currentSkyCultureID;
delete aster; delete aster;
} }
} }
in.close(); in.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "asterism r ecords successfully for culture" << currentSkyCultureID; qDebug() << "Loaded" << readOk << "/" << totalRecords << "asterism r ecords successfully for culture" << currentSkyCultureID;
// Set current states // Set current states
setFlagLines(linesDisplayed); setFlagLines(linesDisplayed);
setFlagLabels(namesDisplayed); setFlagLabels(namesDisplayed);
setFlagRayHelpers(rayHelpersDisplayed);
} }
void AsterismMgr::draw(StelCore* core) void AsterismMgr::draw(StelCore* core)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ; const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ;
StelPainter sPainter(prj); StelPainter sPainter(prj);
sPainter.setFont(asterFont); sPainter.setFont(asterFont);
drawLines(sPainter, core); drawLines(sPainter, core);
drawRayHelpers(sPainter, core);
drawNames(sPainter); drawNames(sPainter);
} }
// Draw asterisms lines // Draw asterisms lines
void AsterismMgr::drawLines(StelPainter& sPainter, const StelCore* core) co nst void AsterismMgr::drawLines(StelPainter& sPainter, const StelCore* core) co nst
{ {
if (!hasAsterism) if (!hasAsterism)
return; return;
sPainter.setBlending(true); sPainter.setBlending(true);
if (asterismLineThickness>1.f) if (asterismLineThickness>1)
sPainter.setLineWidth(asterismLineThickness); // set line th ickness sPainter.setLineWidth(asterismLineThickness); // set line th ickness
sPainter.setLineSmooth(true); sPainter.setLineSmooth(true);
const SphericalCap& viewportHalfspace = sPainter.getProjector()->get BoundingCap(); const SphericalCap& viewportHalfspace = sPainter.getProjector()->get BoundingCap();
vector < Asterism * >::const_iterator iter; vector < Asterism * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{ {
(*iter)->drawOptim(sPainter, core, viewportHalfspace); if ((*iter)->isAsterism())
(*iter)->drawOptim(sPainter, core, viewportHalfspace
);
}
if (asterismLineThickness>1)
sPainter.setLineWidth(1); // restore line thickness
sPainter.setLineSmooth(false);
}
// Draw asterisms lines
void AsterismMgr::drawRayHelpers(StelPainter& sPainter, const StelCore* cor
e) const
{
if (!hasAsterism)
return;
sPainter.setBlending(true);
if (rayHelperThickness>1)
sPainter.setLineWidth(rayHelperThickness); // set line thick
ness
sPainter.setLineSmooth(true);
const SphericalCap& viewportHalfspace = sPainter.getProjector()->get
BoundingCap();
vector < Asterism * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{
if (!(*iter)->isAsterism())
(*iter)->drawOptim(sPainter, core, viewportHalfspace
);
} }
if (asterismLineThickness>1.f) if (rayHelperThickness>1)
sPainter.setLineWidth(1.f); // restore line thickness sPainter.setLineWidth(1); // restore line thickness
sPainter.setLineSmooth(false); sPainter.setLineSmooth(false);
} }
// Draw the names of all the asterisms // Draw the names of all the asterisms
void AsterismMgr::drawNames(StelPainter& sPainter) const void AsterismMgr::drawNames(StelPainter& sPainter) const
{ {
if (!hasAsterism) if (!hasAsterism)
return; return;
sPainter.setBlending(true); sPainter.setBlending(true);
skipping to change at line 448 skipping to change at line 507
} }
emit linesDisplayedChanged(displayed); emit linesDisplayedChanged(displayed);
} }
} }
bool AsterismMgr::getFlagLines(void) const bool AsterismMgr::getFlagLines(void) const
{ {
return linesDisplayed; return linesDisplayed;
} }
void AsterismMgr::setFlagRayHelpers(const bool displayed)
{
if(rayHelpersDisplayed != displayed)
{
rayHelpersDisplayed = displayed;
vector < Asterism * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++it
er)
{
(*iter)->setFlagRayHelpers(rayHelpersDisplayed);
}
emit rayHelpersDisplayedChanged(displayed);
}
}
bool AsterismMgr::getFlagRayHelpers(void) const
{
return rayHelpersDisplayed;
}
void AsterismMgr::setFlagLabels(const bool displayed) void AsterismMgr::setFlagLabels(const bool displayed)
{ {
if (namesDisplayed != displayed) if (namesDisplayed != displayed)
{ {
namesDisplayed = displayed; namesDisplayed = displayed;
vector < Asterism * >::const_iterator iter; vector < Asterism * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++it er) for (iter = asterisms.begin(); iter != asterisms.end(); ++it er)
(*iter)->setFlagLabels(namesDisplayed); (*iter)->setFlagLabels(namesDisplayed);
emit namesDisplayedChanged(displayed); emit namesDisplayedChanged(displayed);
 End of changes. 17 change blocks. 
16 lines changed or deleted 102 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/