LabelMgr.hpp   LabelMgr.hpp 
skipping to change at line 36 skipping to change at line 36
#include "StelObjectType.hpp" #include "StelObjectType.hpp"
#include "VecMath.hpp" #include "VecMath.hpp"
#include <QVector> #include <QVector>
#include <QString> #include <QString>
class StelCore; class StelCore;
class StelFont; class StelFont;
class StelPainter; class StelPainter;
// 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 st
yle=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);
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;
};
//! @class LabelMgr //! @class LabelMgr
//! Allows for creation of custom labels on objects or coordinates. //! Allows for creation of custom labels on objects or coordinates.
//! Because this class is intended for use in scripting (although //! Because this class is intended for use in scripting (although
//! other uses are also fine), all label types and so on are specified //! other uses are also fine), all label types and so on are specified
//! by QString descriptions. //! by QString descriptions.
//! TODO: when QT4.5 is out, change implementation to use QGraphicsTextItem . //! TODO: when QT4.5 is out, change implementation to use QGraphicsTextItem .
//! (QT4.5 should allow for opacity changes for fades, but it is not curren tly //! (QT4.5 should allow for opacity changes for fades, but it is not curren tly
//! implemented. //! implemented.
class LabelMgr : public StelModule class LabelMgr : public StelModule
{ {
skipping to change at line 189 skipping to change at line 92
int labelObject(const QString& text, int labelObject(const QString& text,
const QString& objectName, const QString& objectName,
bool visible=true, bool visible=true,
float fontSize=14, float fontSize=14,
const QString& fontColor="#999999", const QString& fontColor="#999999",
const QString& side="E", const QString& side="E",
double labelDistance=-1.0, double labelDistance=-1.0,
const QString& style="TextOnly"); const QString& style="TextOnly");
//! Create a label at fixed screen coordinates //! Create a label at fixed screen coordinates
//! @param text the text to display
//! @param x the horizontal position on the screen, in pixels.
//! @param y the vertical position on the screen, in pixels.
//! @param visible if true, the label starts displayed, else it star
ts hidden
//! @param fontSize size of the font to use
//! @param fontColor HTML-like color spec, e.g. "#ffff00" for yellow
int labelScreen(const QString& text, int labelScreen(const QString& text,
int x, int x,
int y, int y,
bool visible=true, bool visible=true,
float fontSize=14, float fontSize=14,
const QString& fontColor="#999999"); const QString& fontColor="#999999");
//! find out if a label identified by id is presently shown //! find out if a label identified by id is presently shown
bool getLabelShow(int id); bool getLabelShow(int id);
//! set a label identified by id to be shown or not //! set a label identified by id to be shown or not
void setLabelShow(int id, bool show); void setLabelShow(int id, bool show);
//! Delete a label by the ID which was returned from addLabel... //! Delete a label by the ID which was returned from addLabel...
//! @return true if the id existed and was deleted, else false //! @return true if the id existed and was deleted, else false
bool deleteLabel(int id); bool deleteLabel(int id);
//! Delete all labels. //! Delete all labels.
//! @return the number of labels deleted //! @return the number of labels deleted
int deleteAllLabels(void); int deleteAllLabels(void);
private: private:
SkyLabel::Style stringToStyle(const QString& s); QVector<class StelLabel*> allLabels;
QVector<StelLabel*> allLabels;
}; };
#endif // _SKYLABELMGR_HPP_ #endif // _SKYLABELMGR_HPP_
 End of changes. 3 change blocks. 
117 lines changed or deleted 8 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/