TextUserInterface.cpp   TextUserInterface.cpp 
skipping to change at line 31 skipping to change at line 31
#include "TuiNodeActivate.hpp" #include "TuiNodeActivate.hpp"
#include "TuiNodeBool.hpp" #include "TuiNodeBool.hpp"
#include "TuiNodeInt.hpp" #include "TuiNodeInt.hpp"
#include "TuiNodeDouble.hpp" #include "TuiNodeDouble.hpp"
#include "TuiNodeFloat.hpp" #include "TuiNodeFloat.hpp"
#include "TuiNodeDateTime.hpp" #include "TuiNodeDateTime.hpp"
#include "TuiNodeColor.hpp" #include "TuiNodeColor.hpp"
#include "TuiNodeEnum.hpp" #include "TuiNodeEnum.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelPainter.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StarMgr.hpp" #include "StarMgr.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelObjectMgr.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "ConstellationMgr.hpp" #include "ConstellationMgr.hpp"
#include "NebulaMgr.hpp" #include "NebulaMgr.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "LandscapeMgr.hpp" #include "LandscapeMgr.hpp"
#include "GridLinesMgr.hpp" #include "GridLinesMgr.hpp"
#include "MilkyWay.hpp" #include "MilkyWay.hpp"
#include "StelLocation.hpp" #include "StelLocation.hpp"
#include "StelMainGraphicsView.hpp" #include "StelMainGraphicsView.hpp"
#include "StelSkyCultureMgr.hpp" #include "StelSkyCultureMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#ifndef DISABLE_SCRIPTING #ifndef DISABLE_SCRIPTING
#include "StelScriptMgr.hpp" #include "StelScriptMgr.hpp"
#endif #endif
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelGuiItems.hpp"// Funny thing to include in a TEXT user interfa ce... #include "StelGuiItems.hpp"// Funny thing to include in a TEXT user interfa ce...
#include "renderer/StelRenderer.hpp"
#include <QtOpenGL>
#include <QKeyEvent> #include <QKeyEvent>
#include <QDebug> #include <QDebug>
#include <QLabel> #include <QLabel>
#include <QTime>
#include <QProcess>
#ifdef DISABLE_SCRIPTING
#include "QSettings" // WTF?
#endif
/************************************************************************* /*************************************************************************
Utility functions Utility functions
*************************************************************************/ *************************************************************************/
QString colToConf(const Vec3f& c) QString colToConf(const Vec3f& c)
{ {
return QString("%1,%2,%3").arg(c[0],2,'f',2).arg(c[1],2,'f',2).arg(c [2],2,'f',2); return QString("%1,%2,%3").arg(c[0],2,'f',2).arg(c[1],2,'f',2).arg(c [2],2,'f',2);
} }
/************************************************************************* /*************************************************************************
skipping to change at line 389 skipping to change at line 394
m5_17->setNextNode(m5_18); m5_17->setNextNode(m5_18);
m5_18->setNextNode(m5_19); m5_18->setNextNode(m5_19);
m5_19->setNextNode(m5_20); m5_19->setNextNode(m5_20);
m5_20->setNextNode(m5_1); m5_20->setNextNode(m5_1);
m5_1->loopToTheLast(); m5_1->loopToTheLast();
m5->setChildNode(m5_1); m5->setChildNode(m5_1);
TuiNode* m6 = new TuiNode(N_("Effects"), NULL, m5); TuiNode* m6 = new TuiNode(N_("Effects"), NULL, m5);
m5->setNextNode(m6); m5->setNextNode(m6);
TuiNode* m6_1 = new TuiNodeInt(N_("Light pollution:"), TuiNode* m6_1 = new TuiNodeInt(N_("Light pollution:"),
landscapeMgr, this,
SLOT(setAtmosphereBortleLightPollutio SLOT(setBortleScale(int)),
n(int)),
3, 1, 9, 1, 3, 1, 9, 1,
m6); m6);
TuiNode* m6_2 = new TuiNodeEnum(N_("Landscape"), TuiNode* m6_2 = new TuiNodeEnum(N_("Landscape"),
landscapeMgr, landscapeMgr,
SLOT(setCurrentLandscapeName(QString )), SLOT(setCurrentLandscapeName(QString )),
landscapeMgr->getAllLandscapeNames() , landscapeMgr->getAllLandscapeNames() ,
landscapeMgr->getCurrentLandscapeNam e(), landscapeMgr->getCurrentLandscapeNam e(),
m6, m6_1); m6, m6_1);
StelMovementMgr* movementMgr = GETSTELMODULE(StelMovementMgr); StelMovementMgr* movementMgr = GETSTELMODULE(StelMovementMgr);
TuiNode* m6_3 = new TuiNodeBool(N_("Manual zoom"), TuiNode* m6_3 = new TuiNodeBool(N_("Manual zoom"),
skipping to change at line 471 skipping to change at line 476
#ifdef DISABLE_SCRIPTING #ifdef DISABLE_SCRIPTING
TuiNode* m8 = new TuiNode(N_("Administration"), NULL, m6); TuiNode* m8 = new TuiNode(N_("Administration"), NULL, m6);
m6->setNextNode(m8); m6->setNextNode(m8);
#endif #endif
m8->setNextNode(m1); m8->setNextNode(m1);
m1->loopToTheLast(); m1->loopToTheLast();
TuiNode* m8_1 = new TuiNode(N_("Load default configuration"), m8); TuiNode* m8_1 = new TuiNode(N_("Load default configuration"), m8);
TuiNode* m8_2 = new TuiNodeActivate(N_("Save current configuration") , TuiNode* m8_2 = new TuiNodeActivate(N_("Save current configuration") ,
this, SLOT(saveDefaultSettings() ), this, SLOT(saveDefaultSettings() ),
m8, m8_1); m8, m8_1);
TuiNode* m8_3 = new TuiNode(N_("Shut down"), m8, m8_2); TuiNode* m8_3 = new TuiNodeActivate(N_("Shut down"), this, SLOT(shut
Down()),
m8, m8_2);
m8_1->setNextNode(m8_2); m8_1->setNextNode(m8_2);
m8_2->setNextNode(m8_3); m8_2->setNextNode(m8_3);
m8_3->setNextNode(m8_1); m8_3->setNextNode(m8_1);
m8_1->loopToTheLast(); m8_1->loopToTheLast();
m8->setChildNode(m8_1); m8->setChildNode(m8_1);
currentNode = m1; currentNode = m1;
} }
/************************************************************************* /*************************************************************************
Load settings from configuration file. Load settings from configuration file.
*************************************************************************/ *************************************************************************/
void TextUserInterface::loadConfiguration(void) void TextUserInterface::loadConfiguration(void)
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf); Q_ASSERT(conf);
font.setPixelSize(conf->value("tui/tui_font_size", 15).toInt()); font.setPixelSize(conf->value("tui/tui_font_size", 15).toInt());
tuiDateTime = conf->value("tui/flag_show_tui_datetime", false).toBoo
l();
tuiObjInfo = conf->value("tui/flag_show_tui_short_obj_info", false).
toBool();
tuiGravityUi = conf->value("tui/flag_show_gravity_ui", false).toBool
();
} }
/************************************************************************* /*************************************************************************
Draw our module. Draw our module.
*************************************************************************/ *************************************************************************/
void TextUserInterface::draw(StelCore* core) void TextUserInterface::draw(StelCore* core, StelRenderer* renderer)
{ {
if (!tuiActive && !tuiDateTime && !tuiObjInfo)
return;
int x = 0, y = 0;
int xVc = 0, yVc = 0;
int pixOffset = 15;
int fovOffsetX = 0, fovOffsetY=0;
bool fovMaskDisk = false;
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui(
));
if (gui->getVisible())
{
QGraphicsItem* bottomBar = dynamic_cast<QGraphicsItem*>(gui-
>getButtonBar());
LeftStelBar* sideBar = gui->getWindowsButtonBar();
x = (sideBar) ? sideBar->boundingRectNoHelpLabel().right() :
50;
y = (bottomBar) ? bottomBar->boundingRect().height() : 50;
}
// Alternate x,y for Disk viewport
if (core->getProjection(StelCore::FrameJ2000)->getMaskType() == Stel
Projector::MaskDisk)
{
fovMaskDisk = true;
StelProjector::StelProjectorParams projParams = core->getCur
rentStelProjectorParams();
xVc = projParams.viewportCenter[0];
yVc = projParams.viewportCenter[1];
fovOffsetX = projParams.viewportFovDiameter*std::sin(20)/2;
fovOffsetY = projParams.viewportFovDiameter*std::cos(20)/2;
}
else
{
xVc = core->getProjection(StelCore::FrameJ2000)->getViewport
Width()/2;
}
if (tuiActive) if (tuiActive)
{ {
int x = 0, y = 0; int text_x = x + pixOffset, text_y = y + pixOffset;
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() if (fovMaskDisk) {
.getGui()); text_x = xVc - fovOffsetX + pixOffset;
if (gui->getVisible()) text_y = yVc - fovOffsetY + pixOffset;
{
QGraphicsItem* bottomBar = dynamic_cast<QGraphicsIte
m*>(gui->getButtonBar());
LeftStelBar* sideBar = gui->getWindowsButtonBar();
x = (sideBar) ? sideBar->boundingRectNoHelpLabel().r
ight() : 50;
y = (bottomBar) ? bottomBar->boundingRect().height()
: 50;
} }
// Alternate x,y for Disk viewport QString tuiText = q_("[no TUI node]");
if (core->getProjection(StelCore::FrameJ2000)->getMaskType() if (currentNode!=NULL) {
== StelProjector::MaskDisk) tuiText = currentNode->getDisplayText();
{
StelProjector::StelProjectorParams projParams = core
->getCurrentStelProjectorParams();
x = projParams.viewportCenter[0] - projParams.viewpo
rtFovDiameter/2;
y = projParams.viewportCenter[1];
} }
x += 20; renderer->setFont(font);
y += 15; renderer->setGlobalColor(0.3f, 1.0f, 0.3f);
TextParams params = TextParams(text_x, text_y, tuiText)
.projector(core->getProjection(StelCore:
:FrameJ2000));
if(tuiGravityUi){params.useGravity();}
renderer->drawText(params);
}
QString tuiText = q_("[no TUI node]"); if (tuiDateTime)
if (currentNode!=NULL) {
tuiText = currentNode->getDisplayText(); double jd = core->getJDay();
int text_x = x + xVc*2/3, text_y = y + pixOffset;
StelPainter painter(core->getProjection(StelCore::FrameAltAz QString newDate = StelApp::getInstance().getLocaleMgr().getP
)); rintableDateLocal(jd) + " "
painter.setFont(font); +StelApp::getInstance().getLocaleMgr().getPrintableT
painter.setColor(0.3,1,0.3); imeLocal(jd);
painter.drawText(x, y, tuiText, 0, 0, 0, false);
if (fovMaskDisk) {
text_x = xVc + fovOffsetY - pixOffset;
text_y = yVc - fovOffsetX + pixOffset;
}
renderer->setFont(font);
renderer->setGlobalColor(0.3f, 1.0f, 0.3f);
TextParams params = TextParams(text_x, text_y, newDate)
.projector(core->getProjection(StelCore:
:FrameAltAz));
if(tuiGravityUi){params.useGravity();}
renderer->drawText(params);
}
if (tuiObjInfo)
{
QString objInfo = "";
StelObject::InfoStringGroup tuiInfo(StelObject::Name|StelObj
ect::CatalogNumber
|StelObject::Distance|StelObject::PlainText)
;
int text_x = x + xVc*4/3, text_y = y + pixOffset;
QList<StelObjectP> selectedObj = GETSTELMODULE(StelObjectMgr
)->getSelectedObject();
if (selectedObj.isEmpty()) {
objInfo = "";
} else {
objInfo = selectedObj[0]->getInfoString(core, tuiInf
o);
objInfo.replace("\n"," ");
objInfo.replace("Distance:"," ");
objInfo.replace("Light Years","ly");
}
if (fovMaskDisk) {
text_x = xVc + fovOffsetX - pixOffset;
text_y = yVc + fovOffsetY - pixOffset;
}
renderer->setFont(font);
renderer->setGlobalColor(0.3f, 1.0f, 0.3f);
TextParams params = TextParams(text_x, text_y, objInfo)
.projector(core->getProjection(StelCore:
:FrameJ2000));
if(tuiGravityUi){params.useGravity();}
renderer->drawText(params);
} }
} }
void TextUserInterface::handleKeys(QKeyEvent* event) void TextUserInterface::handleKeys(QKeyEvent* event)
{ {
if (currentNode == NULL) if (currentNode == NULL)
{ {
qWarning() << "WARNING: no current node in TextUserInterface plugin"; qWarning() << "WARNING: no current node in TextUserInterface plugin";
event->setAccepted(false); event->setAccepted(false);
return; return;
skipping to change at line 735 skipping to change at line 816
conf->setValue("navigation/auto_zoom_out_resets_direction", mvmgr->g etFlagAutoZoomOutResetsDirection()); conf->setValue("navigation/auto_zoom_out_resets_direction", mvmgr->g etFlagAutoZoomOutResetsDirection());
conf->setValue("astro/milky_way_intensity", milk->getIntensity()); conf->setValue("astro/milky_way_intensity", milk->getIntensity());
conf->setValue("navigation/auto_move_duration", mvmgr->getAutoMoveDu ration()); conf->setValue("navigation/auto_move_duration", mvmgr->getAutoMoveDu ration());
conf->setValue("landscape/flag_landscape_sets_location", lmgr->getFl agLandscapeSetsLocation()); conf->setValue("landscape/flag_landscape_sets_location", lmgr->getFl agLandscapeSetsLocation());
// GLOBAL DISPLAY SETTINGS // GLOBAL DISPLAY SETTINGS
// TODO // TODO
qDebug() << "TextUserInterface::saveDefaultSettings done"; qDebug() << "TextUserInterface::saveDefaultSettings done";
} }
void TextUserInterface::shutDown()
{
QSettings* conf = StelApp::getInstance().getSettings();
QString shutdownCmd = conf->value("tui/admin_shutdown_cmd", "").toSt
ring();
int err;
if (!(err = QProcess::execute(shutdownCmd))) {
qDebug() << "[TextUserInterface] shutdown error, QProcess::e
xecute():" << err;
}
}
void TextUserInterface::setBortleScale(int bortle)
{
LandscapeMgr* landscapeMgr = GETSTELMODULE(LandscapeMgr);
StelSkyDrawer* skyDrawer = StelApp::getInstance().getCore()->getSkyD
rawer();
landscapeMgr->setAtmosphereBortleLightPollution(bortle);
skyDrawer->setBortleScale(bortle);
}
 End of changes. 16 change blocks. 
38 lines changed or deleted 129 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/