StelGuiItems.cpp   StelGuiItems.cpp 
skipping to change at line 26 skipping to change at line 26
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "StelGui.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelLocation.hpp" #include "StelLocation.hpp"
#include "StelMainView.hpp" #include "StelMainView.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelActionMgr.hpp" #include "StelActionMgr.hpp"
#include "StelProgressController.hpp" #include "StelProgressController.hpp"
#include "StelObserver.hpp"
#include <QPainter> #include <QPainter>
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QGraphicsView> #include <QGraphicsView>
#include <QGraphicsLineItem> #include <QGraphicsLineItem>
#include <QRectF> #include <QRectF>
#include <QDebug> #include <QDebug>
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
#include <QGraphicsTextItem> #include <QGraphicsTextItem>
#include <QTimeLine> #include <QTimeLine>
skipping to change at line 190 skipping to change at line 192
void StelButton::updateIcon() void StelButton::updateIcon()
{ {
if (opacity < 0.) if (opacity < 0.)
opacity = 0; opacity = 0;
QPixmap pix(pixOn.size()); QPixmap pix(pixOn.size());
pix.fill(QColor(0,0,0,0)); pix.fill(QColor(0,0,0,0));
QPainter painter(&pix); QPainter painter(&pix);
painter.setOpacity(opacity); painter.setOpacity(opacity);
if (!pixBackground.isNull() && noBckground==false) if (!pixBackground.isNull() && noBckground==false)
painter.drawPixmap(0, 0, pixBackground); painter.drawPixmap(0, 0, pixBackground);
painter.drawPixmap(0, 0, painter.drawPixmap(0, 0,
(isTristate_ && checked == ButtonStateNoChange) ? (pixNoChan ge) : (isTristate_ && checked == ButtonStateNoChange) ? (pixNoChan ge) :
(checked == ButtonStateOn) ? (pixOn) : (checked == ButtonStateOn) ? (pixOn) :
/* (checked == ButtonStateOff) ? */ (pixOff)); /* (checked == ButtonStateOff) ? */ (pixOff));
if (hoverOpacity > 0) if (hoverOpacity > 0)
{ {
painter.setOpacity(hoverOpacity * opacity); painter.setOpacity(hoverOpacity * opacity);
painter.drawPixmap(0, 0, pixHover); painter.drawPixmap(0, 0, pixHover);
} }
setPixmap(pix); setPixmap(pix);
} }
void StelButton::animValueChanged(qreal value) void StelButton::animValueChanged(qreal value)
{ {
skipping to change at line 243 skipping to change at line 247
void LeftStelBar::addButton(StelButton* button) void LeftStelBar::addButton(StelButton* button)
{ {
double posY = 0; double posY = 0;
if (QGraphicsItem::childItems().size()!=0) if (QGraphicsItem::childItems().size()!=0)
{ {
const QRectF& r = childrenBoundingRect(); const QRectF& r = childrenBoundingRect();
posY += r.bottom()-1; posY += r.bottom()-1;
} }
button->setParentItem(this); button->setParentItem(this);
button->prepareGeometryChange(); // could possibly be removed when q t 4.6 become stable button->prepareGeometryChange(); // could possibly be removed when q t 4.6 become stable
button->setPos(0., qRound(posY+10.5)); button->setPos(0., qRound(posY+10.5));
connect(button, SIGNAL(hoverChanged(bool)), this, SLOT(buttonHoverCh anged(bool))); connect(button, SIGNAL(hoverChanged(bool)), this, SLOT(buttonHoverCh anged(bool)));
} }
void LeftStelBar::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget *) void LeftStelBar::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget *)
{ {
} }
QRectF LeftStelBar::boundingRect() const QRectF LeftStelBar::boundingRect() const
{ {
skipping to change at line 291 skipping to change at line 295
QString tip(button->action->getText()); QString tip(button->action->getText());
QString shortcut(button->action->getShortcut().toStr ing(QKeySequence::NativeText)); QString shortcut(button->action->getShortcut().toStr ing(QKeySequence::NativeText));
if (!shortcut.isEmpty()) if (!shortcut.isEmpty())
{ {
//XXX: this should be unnecessary since we u sed NativeText. //XXX: this should be unnecessary since we u sed NativeText.
if (shortcut == "Space") if (shortcut == "Space")
shortcut = q_("Space"); shortcut = q_("Space");
tip += " [" + shortcut + "]"; tip += " [" + shortcut + "]";
} }
helpLabel->setText(tip); helpLabel->setText(tip);
helpLabel->setPos(qRound(boundingRectNoHelpLabel().width()+15.5 ),qRound(button->pos().y()+button->pixmap().size().height()/2-8)); helpLabel->setPos(qRound(boundingRectNoHelpLabel().w idth()+15.5),qRound(button->pos().y()+button->pixmap().size().height()/2-8) );
} }
} }
else else
{ {
helpLabel->setText(""); helpLabel->setText("");
} }
// Update the screen as soon as possible. // Update the screen as soon as possible.
StelMainView::getInstance().thereWasAnEvent(); StelMainView::getInstance().thereWasAnEvent();
} }
skipping to change at line 537 skipping to change at line 541
b->animValueChanged(0.); b->animValueChanged(0.);
b->setPos(x, y); b->setPos(x, y);
x += b->getButtonPixmapWidth(); x += b->getButtonPixmapWidth();
++n; ++n;
} }
x+=group.rightMargin; x+=group.rightMargin;
} }
updateText(true); updateText(true);
} }
// create text elements and tooltips in bottom toolbar.
// Make sure to avoid any change if not necessary to avoid triggering usele ss redraw // Make sure to avoid any change if not necessary to avoid triggering usele ss redraw
void BottomStelBar::updateText(bool updatePos) void BottomStelBar::updateText(bool updatePos)
{ {
StelCore* core = StelApp::getInstance().getCore(); StelCore* core = StelApp::getInstance().getCore();
double jd = core->getJDay(); double jd = core->getJD();
double deltaT = 0.; double deltaT = core->getDeltaT();
double sigma = -1.; double sigma = StelUtils::getDeltaTStandardError(jd);
QString sigmaInfo = ""; QString sigmaInfo = "";
QString validRangeInfo = ""; QString validRangeMarker = "";
bool displayDeltaT = false; core->getCurrentDeltaTAlgorithmValidRangeDescription(jd, &validRange
if (core->getCurrentLocation().planetName.contains("Earth")) Marker);
{
deltaT = core->getDeltaT(jd);
displayDeltaT = true;
sigma = StelUtils::getDeltaTStandardError(jd);
core->getCurrentDeltaTAlgorithmValidRange(jd, &validRangeInf
o);
}
const StelLocaleMgr& locmgr = StelApp::getInstance().getLocaleMgr(); const StelLocaleMgr& locmgr = StelApp::getInstance().getLocaleMgr();
double dt = deltaT/86400.; // A DeltaT correction. Divide DeltaT by QString tz = locmgr.getPrintableTimeZoneLocal(jd);
86400 to convert from seconds to days.
QString tz = locmgr.getPrintableTimeZoneLocal(jd-dt);
QString newDateInfo = " "; QString newDateInfo = " ";
if (getFlagShowTime()) if (getFlagShowTime())
{ {
if (getFlagShowTz()) if (getFlagShowTz())
newDateInfo = QString("%1 %2 %3").arg(locmgr.getPr intableDateLocal(jd-dt)).arg(locmgr.getPrintableTimeLocal(jd-dt)).arg(tz); newDateInfo = QString("%1 %2 %3").arg(locmgr.getPr intableDateLocal(jd)).arg(locmgr.getPrintableTimeLocal(jd)).arg(tz);
else else
newDateInfo = QString("%1 %2").arg(locmgr.getPrint ableDateLocal(jd-dt)).arg(locmgr.getPrintableTimeLocal(jd-dt)); newDateInfo = QString("%1 %2").arg(locmgr.getPrint ableDateLocal(jd)).arg(locmgr.getPrintableTimeLocal(jd));
} }
QString newDateAppx = QString("JD %1").arg(jd-dt, 0, 'f', 5); QString newDateAppx = QString("JD %1").arg(jd, 0, 'f', 5);
if (getFlagTimeJd()) if (getFlagTimeJd())
{ {
newDateAppx = newDateInfo; newDateAppx = newDateInfo;
newDateInfo = QString("JD %1").arg(jd-dt, 0, 'f', 5); newDateInfo = QString("JD %1").arg(jd, 0, 'f', 5);
} }
if (datetime->text()!=newDateInfo) if (datetime->text()!=newDateInfo)
{ {
updatePos = true; updatePos = true;
datetime->setText(newDateInfo); datetime->setText(newDateInfo);
if (displayDeltaT && core->getCurrentDeltaTAlgorithm()!=Stel Core::WithoutCorrection) if (core->getCurrentDeltaTAlgorithm()!=StelCore::WithoutCorr ection)
{ {
if (sigma>0) if (sigma>0)
sigmaInfo = QString("; %1(%2T) = %3s").arg(Q Char(0x03c3)).arg(QChar(0x0394)).arg(sigma, 3, 'f', 1); sigmaInfo = QString("; %1(%2T) = %3s").arg(Q Char(0x03c3)).arg(QChar(0x0394)).arg(sigma, 3, 'f', 1);
QString deltaTInfo = ""; QString deltaTInfo = "";
if (qAbs(deltaT)>60.) if (qAbs(deltaT)>60.)
deltaTInfo = QString("%1 (%2s)%3").arg(StelU tils::hoursToHmsStr(deltaT/3600.)).arg(deltaT, 5, 'f', 2).arg(validRangeInf o); deltaTInfo = QString("%1 (%2s)%3").arg(StelU tils::hoursToHmsStr(deltaT/3600.)).arg(deltaT, 5, 'f', 2).arg(validRangeMar ker);
else else
deltaTInfo = QString("%1s%2").arg(deltaT, 3, 'f', 3).arg(validRangeInfo); deltaTInfo = QString("%1s%2").arg(deltaT, 3, 'f', 3).arg(validRangeMarker);
datetime->setToolTip(QString("<p style='white-space: pre'>%1T = %2 [n-dot @ -23.8946\"/cy%3%4]<br>%5</p>").arg(QChar(0x0394)).ar g(deltaTInfo).arg(QChar(0x00B2)).arg(sigmaInfo).arg(newDateAppx)); datetime->setToolTip(QString("<p style='white-space: pre'>%1T = %2 [n-dot @ -23.8946\"/cy%3%4]<br>%5</p>").arg(QChar(0x0394)).ar g(deltaTInfo).arg(QChar(0x00B2)).arg(sigmaInfo).arg(newDateAppx));
} }
else else
datetime->setToolTip(QString("%1").arg(newDateAppx)) ; datetime->setToolTip(QString("%1").arg(newDateAppx)) ;
} }
// build location tooltip
QString newLocation = ""; QString newLocation = "";
const StelLocation* loc = &core->getCurrentLocation(); const StelLocation* loc = &core->getCurrentLocation();
const StelTranslator& trans = locmgr.getSkyTranslator(); const StelTranslator& trans = locmgr.getSkyTranslator();
if (getFlagShowLocation() && !loc->name.isEmpty()) if (getFlagShowLocation() && !loc->name.isEmpty())
{ {
newLocation = trans.qtranslate(loc->planetName) +", "+loc->n ame + ", "+q_("%1m").arg(loc->altitude); newLocation = trans.qtranslate(loc->planetName) +", "+loc->n ame + ", "+q_("%1m").arg(loc->altitude);
} }
if (getFlagShowLocation() && loc->name.isEmpty()) if (getFlagShowLocation() && loc->name.isEmpty())
{ {
newLocation = trans.qtranslate(loc->planetName)+", "+StelUti ls::decDegToDmsStr(loc->latitude)+", "+StelUtils::decDegToDmsStr(loc->longi tude); newLocation = trans.qtranslate(loc->planetName)+", "+StelUti ls::decDegToDmsStr(loc->latitude)+", "+StelUtils::decDegToDmsStr(loc->longi tude);
} }
if (location->text()!=newLocation) // TODO: When topocentric switch is toggled, this must be redrawn!
if (location->text()!=newLocation || updatePos)
{ {
updatePos = true; updatePos = true;
location->setText(newLocation); location->setText(newLocation);
float lat = core->getCurrentLocation().latitude; float lat = core->getCurrentLocation().latitude;
float lon = core->getCurrentLocation().longitude; float lon = core->getCurrentLocation().longitude;
QString latStr, lonStr, pm; QString latStr, lonStr, pm;
if (lat >= 0) if (lat >= 0)
pm = "N"; pm = "N";
else else
{ {
skipping to change at line 628 skipping to change at line 627
} }
latStr = QString("%1%2%3").arg(pm).arg(lat).arg(QChar(0x00B0 )); latStr = QString("%1%2%3").arg(pm).arg(lat).arg(QChar(0x00B0 ));
if (lon >= 0) if (lon >= 0)
pm = "E"; pm = "E";
else else
{ {
pm = "W"; pm = "W";
lon *= -1; lon *= -1;
} }
lonStr = QString("%1%2%3").arg(pm).arg(lon).arg(QChar(0x00B0 )); lonStr = QString("%1%2%3").arg(pm).arg(lon).arg(QChar(0x00B0 ));
location->setToolTip(QString("%1 %2").arg(latStr).arg(lonStr QString rho;
)); if (core->getUseTopocentricCoordinates())
rho = q_("planetocentric distance %1 km").arg(core->
getCurrentObserver()->getDistanceFromCenter() * AU);
else
rho = q_("planetocentric observer");
location->setToolTip(QString("%1 %2; %3").arg(latStr).arg(lo
nStr).arg(rho));
} }
QString str; QString str;
// build fov tooltip
QTextStream wos(&str); QTextStream wos(&str);
if (getFlagFovDms()) if (getFlagFovDms())
{ {
wos << "FOV " << StelUtils::decDegToDmsStr(core->getMovement Mgr()->getCurrentFov()); wos << "FOV " << StelUtils::decDegToDmsStr(core->getMovement Mgr()->getCurrentFov());
} }
else else
{ {
wos << "FOV " << qSetRealNumberPrecision(3) << core->getMove mentMgr()->getCurrentFov() << QChar(0x00B0); wos << "FOV " << qSetRealNumberPrecision(3) << core->getMove mentMgr()->getCurrentFov() << QChar(0x00B0);
} }
skipping to change at line 658 skipping to change at line 665
fov->setToolTip(q_("Field of view")); fov->setToolTip(q_("Field of view"));
} }
else else
{ {
fov->setText(""); fov->setText("");
fov->setToolTip(""); fov->setToolTip("");
} }
} }
str=""; str="";
// build fps tooltip
QTextStream wos2(&str); QTextStream wos2(&str);
wos2 << qSetRealNumberPrecision(3) << StelApp::getInstance().getFps( ) << " FPS"; wos2 << qSetRealNumberPrecision(3) << StelApp::getInstance().getFps( ) << " FPS";
if (fps->text()!=str) if (fps->text()!=str)
{ {
updatePos = true; updatePos = true;
if (getFlagShowFps()) if (getFlagShowFps())
{ {
fps->setText(str); fps->setText(str);
fps->setToolTip(q_("Frames per second")); fps->setToolTip(q_("Frames per second"));
} }
skipping to change at line 805 skipping to change at line 814
QRectF StelProgressBarMgr::boundingRect() const QRectF StelProgressBarMgr::boundingRect() const
{ {
if (QGraphicsItem::children().size()==0) if (QGraphicsItem::children().size()==0)
return QRectF(); return QRectF();
const QRectF& r = childrenBoundingRect(); const QRectF& r = childrenBoundingRect();
return QRectF(0, 0, r.width()-1, r.height()-1); return QRectF(0, 0, r.width()-1, r.height()-1);
}*/ }*/
void StelProgressBarMgr::addProgressBar(const StelProgressController* p) void StelProgressBarMgr::addProgressBar(const StelProgressController* p)
{ {
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( ));
QProgressBar* pb = new QProgressBar(); QProgressBar* pb = new QProgressBar();
pb->setFixedHeight(25); pb->setFixedHeight(25);
pb->setFixedWidth(200); pb->setFixedWidth(200);
pb->setTextVisible(true); pb->setTextVisible(true);
pb->setValue(p->getValue()); pb->setValue(p->getValue());
pb->setMinimum(p->getMin()); pb->setMinimum(p->getMin());
pb->setMaximum(p->getMax()); pb->setMaximum(p->getMax());
pb->setFormat(p->getFormat()); pb->setFormat(p->getFormat());
if (gui!=NULL)
pb->setStyleSheet(gui->getStelStyle().qtStyleSheet);
QGraphicsProxyWidget* pbProxy = new QGraphicsProxyWidget(); QGraphicsProxyWidget* pbProxy = new QGraphicsProxyWidget();
pbProxy->setWidget(pb); pbProxy->setWidget(pb);
pbProxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache); pbProxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
pbProxy->setZValue(150); pbProxy->setZValue(150);
static_cast<QGraphicsLinearLayout*>(layout())->addItem(pbProxy); static_cast<QGraphicsLinearLayout*>(layout())->addItem(pbProxy);
allBars.insert(p, pb); allBars.insert(p, pb);
pb->setVisible(true); pb->setVisible(true);
connect(p, SIGNAL(changed()), this, SLOT(oneBarChanged())); connect(p, SIGNAL(changed()), this, SLOT(oneBarChanged()));
} }
 End of changes. 24 change blocks. 
28 lines changed or deleted 40 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/