~ubuntu-branches/ubuntu/precise/stellarium/precise

« back to all changes in this revision

Viewing changes to src/modules/LabelMgr.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Cédric Delfosse
  • Date: 2009-03-13 20:07:22 UTC
  • mfrom: (1.1.8 upstream) (4.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090313200722-l66s4zy2s3e8up0s
Tags: 0.10.2-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Stellarium
 
3
 * This file Copyright (C) 2008 Matthew Gates
 
4
 * 
 
5
 * This program is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU General Public License
 
7
 * as published by the Free Software Foundation; either version 2
 
8
 * of the License, or (at your option) any later version.
 
9
 * 
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 * 
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
18
 */
 
19
 
 
20
#ifndef _SKYLABELMGR_HPP_
 
21
#define _SKYLABELMGR_HPP_
 
22
 
 
23
 
 
24
#include "StelFader.hpp"
 
25
#include "StelModule.hpp"
 
26
#include "StelObject.hpp"
 
27
#include "StelObjectType.hpp"
 
28
#include "VecMath.hpp"
 
29
 
 
30
#include <QVector>
 
31
#include <QString>
 
32
 
 
33
class StelCore;
 
34
class StelFont;
 
35
class StelPainter;
 
36
 
 
37
//! @class LabelMgr
 
38
//! Allows for creation of custom labels on objects or coordinates.
 
39
//! Because this class is intended for use in scripting (although
 
40
//! other uses are also fine), all label types and so on are specified 
 
41
//! by QString descriptions.
 
42
//! TODO: when QT4.5 is out, change implementation to use QGraphicsTextItem.
 
43
//! (QT4.5 should allow for opacity changes for fades, but it is not currently
 
44
//! implemented.
 
45
class LabelMgr : public StelModule
 
46
{
 
47
        Q_OBJECT
 
48
 
 
49
public:
 
50
        //! Construct a LabelMgr object.
 
51
        LabelMgr(); 
 
52
        virtual ~LabelMgr();
 
53
 
 
54
        ///////////////////////////////////////////////////////////////////////////
 
55
        // Methods defined in the StelModule class
 
56
        //! Initialize the LabelMgr object.
 
57
        virtual void init();
 
58
        
 
59
        //! Draw user labels.
 
60
        virtual void draw(StelCore* core);
 
61
        
 
62
        //! Update time-dependent parts of the module.
 
63
        virtual void update(double deltaTime);
 
64
 
 
65
        //! Defines the order in which the various modules are drawn.
 
66
        virtual double getCallOrder(StelModuleActionName actionName) const;
 
67
 
 
68
public slots:
 
69
        //! Create a label which is attached to a StelObject.
 
70
        //! @param text the text to display
 
71
        //! @param objectName the English name of the object to attach to
 
72
        //! @param visible if true, the label starts displayed, else it starts hidden
 
73
        //! @param fontSize size of the font to use
 
74
        //! @param fontColor HTML-like color spec, e.g. "#ffff00" for yellow
 
75
        //! @param side where the label appears in relation to object:
 
76
        //! - "N" = above object on screen
 
77
        //! - "S" = below object on screen
 
78
        //! - "E" = to the right of the object on screen
 
79
        //! - "W" = to the left of the object on screen
 
80
        //! - "NE", "NW", "SE", "SW" work too.
 
81
        //! @return a unique ID which can be used to refer to the label.
 
82
        //! returns -1 if the label could not be created (e.g. object not found)
 
83
        int labelObject(const QString& text, 
 
84
                        const QString& objectName,
 
85
                        bool visible=true,
 
86
                        float fontSize=14,
 
87
                        const QString& fontColor="#999999",
 
88
                        const QString& side="E",
 
89
                        double labelDistance=-1.0,
 
90
                        const QString& style="TextOnly");
 
91
 
 
92
        //! Create a label at fixed screen coordinates
 
93
        //! @param text the text to display
 
94
        //! @param x the horizontal position on the screen, in pixels.
 
95
        //! @param y the vertical position on the screen, in pixels.
 
96
        //! @param visible if true, the label starts displayed, else it starts hidden
 
97
        //! @param fontSize size of the font to use
 
98
        //! @param fontColor HTML-like color spec, e.g. "#ffff00" for yellow
 
99
        int labelScreen(const QString& text,
 
100
                        int x,
 
101
                        int y,
 
102
                        bool visible=true,
 
103
                        float fontSize=14,
 
104
                        const QString& fontColor="#999999");
 
105
 
 
106
        //! find out if a label identified by id is presently shown
 
107
        bool getLabelShow(int id); 
 
108
        //! set a label identified by id to be shown or not
 
109
        void setLabelShow(int id, bool show); 
 
110
        //! Delete a label by the ID which was returned from addLabel...
 
111
        //! @return true if the id existed and was deleted, else false
 
112
        bool deleteLabel(int id);
 
113
        //! Delete all labels.
 
114
        //! @return the number of labels deleted
 
115
        int deleteAllLabels(void);
 
116
 
 
117
private:
 
118
        QVector<class StelLabel*> allLabels;
 
119
};
 
120
 
 
121
#endif // _SKYLABELMGR_HPP_