00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _SKYLABELMGR_HPP_
00021 #define _SKYLABELMGR_HPP_
00022
00023
00024 #include "StelFader.hpp"
00025 #include "StelModule.hpp"
00026 #include "StelObject.hpp"
00027 #include "StelObjectType.hpp"
00028 #include "VecMath.hpp"
00029
00030 #include <QVector>
00031 #include <QString>
00032
00033 class StelCore;
00034 class StelFont;
00035 class StelPainter;
00036
00037
00038 class StelLabel
00039 {
00040 public:
00041 StelLabel(const QString& text, StelFont* font, const Vec3f& color);
00042 virtual ~StelLabel() {;}
00043
00046 virtual bool draw(StelCore* core, const StelPainter& sPainter) = 0;
00048 virtual void update(double deltaTime);
00050 virtual void setFadeDuration(float duration);
00052 virtual void setFontColor(const Vec3f& color);
00054 virtual void setFlagShow(bool b);
00056 virtual bool getFlagShow(void);
00057
00058 protected:
00059 QString labelText;
00060 StelFont* labelFont;
00061 Vec3f labelColor;
00062 LinearFader labelFader;
00063
00064 };
00065
00069 class SkyLabel : public StelLabel
00070 {
00071 public:
00074 enum Style {
00075 TextOnly,
00076 Line
00077 };
00078
00088 SkyLabel(const QString& text, StelObjectP bindObject, StelFont* font, Vec3f color,
00089 QString side="NE", double distance=-1.0, SkyLabel::Style style=TextOnly,
00090 double enclosureSize=0.0);
00091
00092 virtual ~SkyLabel();
00093
00094
00098 virtual bool draw(StelCore* core, const StelPainter& sPainter);
00099
00100 private:
00101 StelObjectP labelObject;
00102 QString labelSide;
00103 double labelDistance;
00104 SkyLabel::Style labelStyle;
00105 double labelEnclosureSize;
00106
00107 };
00108
00111 class ScreenLabel : public StelLabel
00112 {
00113 public:
00120 ScreenLabel(const QString& text, int x, int y, StelFont* font, Vec3f color);
00121 virtual ~ScreenLabel();
00122
00126 virtual bool draw(StelCore* core, const StelPainter& sPainter);
00127
00128 private:
00129 int screenX;
00130 int screenY;
00131
00132 };
00133
00142 class LabelMgr : public StelModule
00143 {
00144 Q_OBJECT
00145
00146 public:
00148 LabelMgr();
00149 virtual ~LabelMgr();
00150
00152
00154 virtual void init();
00155
00157 virtual void draw(StelCore* core);
00158
00160 virtual void update(double deltaTime);
00161
00163 virtual double getCallOrder(StelModuleActionName actionName) const;
00164
00165 public slots:
00180 int labelObject(const QString& text,
00181 const QString& objectName,
00182 bool visible=true,
00183 float fontSize=14,
00184 const QString& fontColor="#999999",
00185 const QString& side="E",
00186 double labelDistance=-1.0,
00187 const QString& style="TextOnly");
00188
00190 int labelScreen(const QString& text,
00191 int x,
00192 int y,
00193 bool visible=true,
00194 float fontSize=14,
00195 const QString& fontColor="#999999");
00196
00198 bool getLabelShow(int id);
00200 void setLabelShow(int id, bool show);
00203 bool deleteLabel(int id);
00206 int deleteAllLabels(void);
00207
00208 private:
00209 SkyLabel::Style stringToStyle(const QString& s);
00210 QVector<StelLabel*> allLabels;
00211 };
00212
00213 #endif // _SKYLABELMGR_HPP_