LabelMgr.cpp   LabelMgr.cpp 
skipping to change at line 42 skipping to change at line 42
#include "StelObject.hpp" #include "StelObject.hpp"
#include "StelObjectType.hpp" #include "StelObjectType.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "VecMath.hpp" #include "VecMath.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include <vector> #include <vector>
#include <QString> #include <QString>
#include <QDebug> #include <QDebug>
// Base class from which other label types inherit
class StelLabel
{
public:
StelLabel(const QString& text, StelFont* font, const Vec3f& color);
virtual ~StelLabel() {;}
//! draw the label on the sky
//! @param core the StelCore object
virtual bool draw(StelCore* core, const StelPainter& sPainter) = 0;
//! update fade for on/off action
virtual void update(double deltaTime);
//! Set the duration used for the fade in / fade out of the label.
virtual void setFadeDuration(float duration);
//! Set the font color used for the font
virtual void setFontColor(const Vec3f& color);
//! Show or hide the label. It will fade in/out.
virtual void setFlagShow(bool b);
//! Get value of flag used to turn on and off the label
virtual bool getFlagShow(void);
protected:
QString labelText;
StelFont* labelFont;
Vec3f labelColor;
LinearFader labelFader;
};
//! @class SkyLabel
//! Used to create user labels which are bound to some object on the celest
ial sphere.
//! The object in question can be any existing StelObject or celestial coor
dinates.
class SkyLabel : public StelLabel
{
public:
//! @enum Style determined the way the object to which the label is
bound
//! is indicated.
enum Style {
TextOnly, //!< Just put the label near the object
Line //!< Draw a line from the label text to the obje
ct
};
//! Constructor of a SkyLabel which is attached to an existing objec
t
//! @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 font a pointer the font to use for this 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 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 enclosureSize determines the size of the enclosure for st
yles Box and Circle
SkyLabel(const QString& text, StelObjectP bindObject, StelFont* font
, Vec3f color,
QString side="NE", double distance=-1.0, SkyLabel::
Style style=TextOnly,
double enclosureSize=0.0);
virtual ~SkyLabel();
// 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
//! @param core the StelCore object
//! @param sPainter the StelPainter to use for drawing operations
virtual bool draw(StelCore* core, const StelPainter& sPainter);
static SkyLabel::Style stringToStyle(const QString& s);
private:
StelObjectP labelObject;
QString labelSide;
double labelDistance;
SkyLabel::Style labelStyle;
double labelEnclosureSize;
};
//! @class ScreenLabel
//! Used to create user labels which are bound to a fixed point on the scre
en.
class ScreenLabel : public StelLabel
{
public:
//! Constructor of a SkyLabel which is to be displayed at a fixed po
sition on the screen.
//! @param text the text for the label
//! @param x the x-position on the screen (pixels from the left side
)
//! @param y the y-position on the screen (pixels from the bottom si
de)
//! @param font the font to use
//! @param color the color for the label
ScreenLabel(const QString& text, int x, int y, StelFont* font, Vec3f
color);
virtual ~ScreenLabel();
//! draw the label on the sky
//! @param core the StelCore object
//! @param sPainter the StelPainter to use for drawing operations
virtual bool draw(StelCore* core, const StelPainter& sPainter);
private:
int screenX;
int screenY;
};
///////////////////// /////////////////////
// StelLabel class // // StelLabel class //
///////////////////// /////////////////////
StelLabel::StelLabel(const QString& text, StelFont* font, const Vec3f& colo r) StelLabel::StelLabel(const QString& text, StelFont* font, const Vec3f& colo r)
: labelText(text), : labelText(text),
labelFont(font), labelFont(font),
labelColor(color) labelColor(color)
{ {
} }
skipping to change at line 77 skipping to change at line 173
void StelLabel::setFlagShow(bool b) void StelLabel::setFlagShow(bool b)
{ {
labelFader = b; labelFader = b;
} }
bool StelLabel::getFlagShow(void) bool StelLabel::getFlagShow(void)
{ {
return labelFader; return labelFader;
} }
SkyLabel::Style SkyLabel::stringToStyle(const QString& s)
{
if (s=="Line")
return SkyLabel::Line;
else
return SkyLabel::TextOnly;
}
//////////////////// ////////////////////
// SkyLabel class // // SkyLabel class //
//////////////////// ////////////////////
SkyLabel::SkyLabel(const QString& text, StelObjectP bindObject, StelFont* f ont, SkyLabel::SkyLabel(const QString& text, StelObjectP bindObject, StelFont* f ont,
Vec3f color, QString side, double distance, SkyLabel::St yle style, Vec3f color, QString side, double distance, SkyLabel::St yle style,
double enclosureSize) double enclosureSize)
: StelLabel(text, font, color), : StelLabel(text, font, color),
labelObject(bindObject), labelObject(bindObject),
labelSide(side), labelSide(side),
labelDistance(distance), labelDistance(distance),
skipping to change at line 255 skipping to change at line 359
const QString& objectName, const QString& objectName,
bool visible, bool visible,
float fontSize, float fontSize,
const QString& fontColor, const QString& fontColor,
const QString& side, const QString& side,
double labelDistance, double labelDistance,
const QString& style) const QString& style)
{ {
StelFont* font = &StelApp::getInstance().getFontManager().getStandar dFont(StelApp::getInstance().getLocaleMgr().getSkyLanguage(), fontSize); StelFont* font = &StelApp::getInstance().getFontManager().getStandar dFont(StelApp::getInstance().getLocaleMgr().getSkyLanguage(), fontSize);
Q_ASSERT(font); Q_ASSERT(font);
StelObjectP obj = StelApp::getInstance().getStelObjectMgr().searchBy Name(objectName); StelObjectP obj = GETSTELMODULE(StelObjectMgr)->searchByName(objectN ame);
if (!obj) if (!obj)
{ {
qWarning() << "LabelMgr::labelObject object not found: " << objectName; qWarning() << "LabelMgr::labelObject object not found: " << objectName;
return -1; return -1;
} }
StelLabel* l = new SkyLabel(text, obj, font, StelUtils::htmlColorToV ec3f(fontColor), side, labelDistance, stringToStyle(style)); StelLabel* l = new SkyLabel(text, obj, font, StelUtils::htmlColorToV ec3f(fontColor), side, labelDistance, SkyLabel::stringToStyle(style));
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;
} }
skipping to change at line 348 skipping to change at line 452
if (l!=NULL) if (l!=NULL)
{ {
delete l; delete l;
l=NULL; l=NULL;
count++; count++;
} }
} }
allLabels.clear(); allLabels.clear();
return count; return count;
} }
SkyLabel::Style LabelMgr::stringToStyle(const QString& s)
{
if (s=="Line")
return SkyLabel::Line;
else
return SkyLabel::TextOnly;
}
 End of changes. 5 change blocks. 
2 lines changed or deleted 124 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/