LabelMgr.cpp   LabelMgr.cpp 
/* /*
* Stellarium * Stellarium
* This file Copyright (C) 2008 Matthew Gates * This file Copyright (C) 2008 Matthew Gates
* Horizon system labels (c) 2015 Georg Zotti
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* 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.
skipping to change at line 86 skipping to change at line 87
//! @enum Style determined the way the object to which the label is bound //! @enum Style determined the way the object to which the label is bound
//! is indicated. //! is indicated.
enum Style { enum Style {
TextOnly, //!< Just put the label near the object TextOnly, //!< Just put the label near the object
Line //!< Draw a line from the label text to the obje ct Line //!< Draw a line from the label text to the obje ct
}; };
//! Constructor of a SkyLabel which is attached to an existing objec t //! Constructor of a SkyLabel which is attached to an existing objec t
//! @param text the text which will be displayed //! @param text the text which will be displayed
//! @param bindObject a pointer to an existing object to which the l abel will be attached //! @param bindObject a pointer to an existing object to which the l abel will be attached
//! @param font a pointer the font to use for this label //! @param font a pointer to the font to use for this label
//! @param color choose a color for the label //! @param color choose a color for the label
//! @param side which side of the object to draw the label, values N , S, E, W, NE, NW, SE, SW, C (C is centred on the object) //! @param side which side of the object to draw the label, values N , S, E, W, NE, NW, SE, SW, C (C is centred on the object)
//! @param distance the distance from the object to draw the label. If < 0.0, placement is automatic. //! @param distance the distance from the object to draw the label. If < 0.0, placement is automatic.
//! @param style determines how the label is drawn //! @param style determines how the label is drawn
//! @param enclosureSize determines the size of the enclosure for st yles Box and Circle //! @param enclosureSize determines the size of the enclosure for st yles Box and Circle
// TBD: Apparently styles Box and Circle have been removed?
SkyLabel(const QString& text, StelObjectP bindObject, const QFont& f ont, Vec3f color, SkyLabel(const QString& text, StelObjectP bindObject, const QFont& f ont, Vec3f color,
QString side="NE", double distance=-1.0, SkyLabel:: Style style=TextOnly, QString side="NE", double distance=-1.0, SkyLabel:: Style style=TextOnly,
double enclosureSize=0.0); double enclosureSize=0.0);
virtual ~SkyLabel(); virtual ~SkyLabel();
// SkyLabel(const QString& text, Vec3d coords, QString side="NE", do uble distance=-1.0, SkyLabel::Style style=TextOnly, double enclosureSize=-1 .0); // SkyLabel(const QString& text, Vec3d coords, QString side="NE", do uble distance=-1.0, SkyLabel::Style style=TextOnly, double enclosureSize=-1 .0);
//! Draw the label on the sky //! Draw the label on the sky
//! @param core the StelCore object //! @param core the StelCore object
//! @param sPainter the StelPainter to use for drawing operations //! @param sPainter the StelPainter to use for drawing operations
skipping to change at line 114 skipping to change at line 116
static SkyLabel::Style stringToStyle(const QString& s); static SkyLabel::Style stringToStyle(const QString& s);
private: private:
StelObjectP labelObject; StelObjectP labelObject;
QString labelSide; QString labelSide;
double labelDistance; double labelDistance;
SkyLabel::Style labelStyle; SkyLabel::Style labelStyle;
double labelEnclosureSize; double labelEnclosureSize;
}; };
//! @class HorizonLabel
//! Used to create user labels which are bound to azimuthal coordinates.
class HorizonLabel : public StelLabel
{
public:
//! Constructor of a HorizonLabel which is to be displayed on an alt
-azimuthal position.
//! @param text the text for the label
//! @param az the azimuth, degrees
//! @param alt the altitude, degrees
//! @param font the font to use
//! @param color the color for the label
HorizonLabel(const QString& text, const float az, const float alt, c
onst QFont& font, const Vec3f& color);
virtual ~HorizonLabel();
//! draw the label on the screen
//! @param core the StelCore object
//! @param sPainter the StelPainter to use for drawing operations
virtual bool draw(StelCore* core, StelPainter& sPainter);
private:
Vec3d altaz; // the vector to the coordinates
};
//! @class ScreenLabel //! @class ScreenLabel
//! Used to create user labels which are bound to a fixed point on the scre en. //! Used to create user labels which are bound to a fixed point on the scre en.
class ScreenLabel : public StelLabel class ScreenLabel : public StelLabel
{ {
public: public:
//! Constructor of a SkyLabel which is to be displayed at a fixed po sition on the screen. //! Constructor of a ScreenLabel which is to be displayed at a fixed position on the screen.
//! @param text the text for the label //! @param text the text for the label
//! @param x the x-position on the screen (pixels from the left side ) //! @param x the x-position on the screen (pixels from the left side )
//! @param y the y-position on the screen (pixels from the top side) //! @param y the y-position on the screen (pixels from the top side)
//! @param font the font to use //! @param font the font to use
//! @param color the color for the label //! @param color the color for the label
ScreenLabel(const QString& text, int x, int y, const QFont& font, co nst Vec3f& color); ScreenLabel(const QString& text, int x, int y, const QFont& font, co nst Vec3f& color);
virtual ~ScreenLabel(); virtual ~ScreenLabel();
//! draw the label on the sky //! draw the label on the screen
//! @param core the StelCore object //! @param core the StelCore object
//! @param sPainter the StelPainter to use for drawing operations //! @param sPainter the StelPainter to use for drawing operations
virtual bool draw(StelCore* core, StelPainter& sPainter); virtual bool draw(StelCore* core, StelPainter& sPainter);
private: private:
int screenX; int screenX;
int screenY; int screenY;
}; };
///////////////////// /////////////////////
skipping to change at line 303 skipping to change at line 327
sPainter.setColor(labelColor[0], labelColor[1], labelColor[2 ], labelFader.getInterstate()); sPainter.setColor(labelColor[0], labelColor[1], labelColor[2 ], labelFader.getInterstate());
sPainter.drawLine2d(lineEndX,lineEndY,objXY[0], objXY[1]); sPainter.drawLine2d(lineEndX,lineEndY,objXY[0], objXY[1]);
} }
return true; return true;
} }
/////////////////////// ///////////////////////
// HorizonLabel class //
///////////////////////
HorizonLabel::HorizonLabel(const QString& text, const float az, const float
alt, const QFont& font, const Vec3f& color)
: StelLabel(text, font, color)
{
StelUtils::spheToRect((180.0f-az)*M_PI/180.0, alt*M_PI/180.0, altaz)
;
}
HorizonLabel::~HorizonLabel()
{
}
bool HorizonLabel::draw(StelCore *core, StelPainter& sPainter)
{
if (labelFader.getInterstate() <= 0.0)
return false;
sPainter.setColor(labelColor[0], labelColor[1], labelColor[2], label
Fader.getInterstate());
sPainter.setFont(labelFont);
StelProjectorP keepProj=sPainter.getProjector(); // we must reset af
ter painting!
StelProjectorP altazProjector=core->getProjection(StelCore::FrameAlt
Az, StelCore::RefractionOff);
sPainter.setProjector(altazProjector);
sPainter.drawText(altaz, labelText, 0, 0, 0, false);
sPainter.setProjector(keepProj);
return true;
}
///////////////////////
// ScreenLabel class // // ScreenLabel class //
/////////////////////// ///////////////////////
ScreenLabel::ScreenLabel(const QString& text, int x, int y, const QFont& fo nt, const Vec3f& color) ScreenLabel::ScreenLabel(const QString& text, int x, int y, const QFont& fo nt, const Vec3f& color)
: StelLabel(text, font, color), : StelLabel(text, font, color),
screenX(x) screenX(x)
{ {
QFontMetrics metrics(font); QFontMetrics metrics(font);
screenY = StelApp::getInstance().getCore()->getProjection2d()->getVi ewportHeight() - y - metrics.height(); screenY = StelApp::getInstance().getCore()->getProjection2d()->getVi ewportHeight() - y - metrics.height();
} }
skipping to change at line 381 skipping to change at line 433
if (l==NULL) if (l==NULL)
return -1; return -1;
if (visible) if (visible)
l->setFlagShow(true); l->setFlagShow(true);
allLabels.append(l); allLabels.append(l);
return allLabels.size()-1; return allLabels.size()-1;
} }
int LabelMgr::labelHorizon(const QString& text,
float az,
float alt,
bool visible,
float fontSize,
const QString& fontColor)
{
QFont font;
font.setPixelSize(fontSize);
HorizonLabel* l = new HorizonLabel(text, az, alt, font, StelUtils::h
tmlColorToVec3f(fontColor));
if (l==NULL)
return -1;
if (visible)
l->setFlagShow(true);
allLabels.append(l);
return allLabels.size()-1;
}
int LabelMgr::labelScreen(const QString& text, int LabelMgr::labelScreen(const QString& text,
int x, int x,
int y, int y,
bool visible, bool visible,
float fontSize, float fontSize,
const QString& fontColor) const QString& fontColor)
{ {
QFont font; QFont font;
font.setPixelSize(fontSize); font.setPixelSize(fontSize);
ScreenLabel* l = new ScreenLabel(text, x, y, font, StelUtils::htmlCo lorToVec3f(fontColor)); ScreenLabel* l = new ScreenLabel(text, x, y, font, StelUtils::htmlCo lorToVec3f(fontColor));
 End of changes. 8 change blocks. 
3 lines changed or deleted 83 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/