Stellarium  23.4
Public Slots | Public Member Functions
LabelMgr Class Reference

Allows for creation of custom labels on objects or coordinates. More...

#include <LabelMgr.hpp>

Public Slots

int labelObject (const QString &text, const QString &objectName, bool visible=true, float fontSize=14, const QString &fontColor="#999999", const QString &side="E", double labelDistance=-1.0, const QString &style="TextOnly", bool autoDelete=false, int autoDeleteTimeoutMs=0)
 Create a label which is attached to a StelObject. More...
 
int labelObject (const QString &text, const QString &objectName, bool visible, float fontSize, const Vec3f &fontColor, const QString &side="E", double labelDistance=-1.0, const QString &style="TextOnly", bool autoDelete=false, int autoDeleteTimeoutMs=0)
 
int labelHorizon (const QString &text, float az, float alt, bool visible=true, float fontSize=14, const QString &fontColor="#999999", bool autoDelete=false, int autoDeleteTimeoutMs=0)
 Create a label in azimuthal coordinate system. More...
 
int labelHorizon (const QString &text, float az, float alt, bool visible, float fontSize, const Vec3f &fontColor, bool autoDelete=false, int autoDeleteTimeoutMs=0)
 
int labelEquatorial (const QString &text, const QString &ra, const QString &dec, bool visible=true, float fontSize=14, const QString &fontColor="#999999", const QString &side="", double labelDistance=-1.0, bool autoDelete=false, int autoDeleteTimeoutMs=0, bool j2000epoch=true)
 Create a label in equatorial coordinate system. More...
 
int labelEquatorial (const QString &text, const QString &ra, const QString &dec, bool visible, float fontSize, const Vec3f &fontColor, const QString &side="", double labelDistance=-1.0, bool autoDelete=false, int autoDeleteTimeoutMs=0, bool j2000epoch=true)
 
int labelScreen (const QString &text, int x, int y, bool visible=true, float fontSize=14, const QString &fontColor="#999999", bool autoDelete=false, int autoDeleteTimeoutMs=0)
 Create a label at fixed screen coordinates. More...
 
int labelScreen (const QString &text, int x, int y, bool visible, float fontSize, const Vec3f &fontColor, bool autoDelete=false, int autoDeleteTimeoutMs=0)
 
bool getLabelShow (int id) const
 find out if a label identified by id is presently shown
 
void setLabelShow (int id, bool show)
 set a label identified by id to be shown or not
 
void setLabelText (int id, const QString &newText)
 set text of label identified by id to be newText
 
void deleteLabel (int id)
 Delete a label by the ID which was returned from addLabel... More...
 
int deleteAllLabels (void)
 Delete all labels. More...
 

Public Member Functions

 LabelMgr ()
 Construct a LabelMgr object.
 
virtual void init () Q_DECL_OVERRIDE
 Initialize the LabelMgr object.
 
virtual void draw (StelCore *core) Q_DECL_OVERRIDE
 Draw user labels.
 
virtual void update (double deltaTime) Q_DECL_OVERRIDE
 Update time-dependent parts of the module.
 
virtual double getCallOrder (StelModuleActionName actionName) const Q_DECL_OVERRIDE
 Defines the order in which the various modules are drawn.
 
- Public Member Functions inherited from StelModule
 StelModule ()
 Constructor. Every derived class MUST call setObjectName(className) in its constructor.
 
virtual void deinit ()
 Called before the module will be deleted, and before the OpenGL context is suppressed. More...
 
virtual QSettings * getSettings ()
 Return module-specific settings. More...
 
virtual QString getModuleVersion () const
 Get the version of the module, default is stellarium main version.
 
virtual QString getAuthorName () const
 Get the name of the module author.
 
virtual QString getAuthorEmail () const
 Get the email address of the module author.
 
virtual void handleMouseClicks (class QMouseEvent *)
 Handle mouse clicks. More...
 
virtual void handleMouseWheel (class QWheelEvent *)
 Handle mouse wheel. More...
 
virtual bool handleMouseMoves (int x, int y, Qt::MouseButtons b)
 Handle mouse moves. More...
 
virtual void handleKeys (class QKeyEvent *e)
 Handle key events. More...
 
virtual bool handlePinch (qreal scale, bool started)
 Handle pinch gesture events. More...
 
virtual bool configureGui (bool show=true)
 Detect or show the configuration GUI elements for the module. More...
 

Additional Inherited Members

- Public Types inherited from StelModule
enum  StelModuleSelectAction { AddToSelection , ReplaceSelection , RemoveFromSelection }
 Enum used when selecting objects to define whether to add to, replace, or remove from the existing selection list. More...
 
enum  StelModuleActionName {
  ActionDraw , ActionUpdate , ActionHandleMouseClicks , ActionHandleMouseMoves ,
  ActionHandleKeys
}
 Define the possible action for which an order is defined. More...
 
- Protected Member Functions inherited from StelModule
class StelActionaddAction (const QString &id, const QString &groupId, const QString &text, QObject *target, const char *slot, const QString &shortcut="", const QString &altShortcut="")
 convenience methods to add an action (call to slot) to the StelActionMgr object. More...
 
class StelActionaddAction (const QString &id, const QString &groupId, const QString &text, const char *slot, const QString &shortcut="", const QString &altShortcut="")
 convenience methods to add an action (call to own slot) to the StelActionMgr object. More...
 
StelActionaddAction (const QString &id, const QString &groupId, const QString &text, QObject *contextObject, std::function< void()> lambda, const QString &shortcut="", const QString &altShortcut="")
 convenience methods to add an action (call to Lambda functor) to the StelActionMgr object. More...
 

Detailed Description

Allows for creation of custom labels on objects or coordinates.

Because this class is intended for use in scripting (although other uses are also fine), all label types and so on are specified by QString descriptions. The labels are painted very late, i.e. also sky object labels will be written over the landscape.

Member Function Documentation

◆ deleteAllLabels

int LabelMgr::deleteAllLabels ( void  )
slot

Delete all labels.

Returns
the number of labels deleted

◆ deleteLabel

void LabelMgr::deleteLabel ( int  id)
slot

Delete a label by the ID which was returned from addLabel...

Returns
true if the id existed and was deleted, else false

◆ labelEquatorial

int LabelMgr::labelEquatorial ( const QString &  text,
const QString &  ra,
const QString &  dec,
bool  visible = true,
float  fontSize = 14,
const QString &  fontColor = "#999999",
const QString &  side = "",
double  labelDistance = -1.0,
bool  autoDelete = false,
int  autoDeleteTimeoutMs = 0,
bool  j2000epoch = true 
)
slot

Create a label in equatorial coordinate system.

Parameters
textthe text to display
RAright ascension (e.g. 5h10m31s)
Decdeclination (e.g. 25d30m30s)
visibleif true, the label starts displayed, else it starts hidden
fontSizesize of the font to use
fontColoreither HTML-like color spec, e.g. "#ffff00", or 3-part float vector like Vec3f(1.0f,1.0f,0.0f) for yellow
sidewhere the label appears in relation to coordinates:
  • "N" = above object on screen
  • "S" = below object on screen
  • "E" = to the right of the object on screen
  • "W" = to the left of the object on screen
  • "NE", "NW", "SE", "SW" work too.
autoDeletethe label will be automatically deleted after it is displayed once
autoDeleteTimeoutMsif not zero, the label will be automatically deleted after autoDeleteTimeoutMs ms
j2000epochif true, the label starts displayed in equatorial coordinates for epoch J2000.0

◆ labelHorizon

int LabelMgr::labelHorizon ( const QString &  text,
float  az,
float  alt,
bool  visible = true,
float  fontSize = 14,
const QString &  fontColor = "#999999",
bool  autoDelete = false,
int  autoDeleteTimeoutMs = 0 
)
slot

Create a label in azimuthal coordinate system.

Can be used e.g. to show landscape features

Parameters
textthe text to display
azazimuth, degrees
altaltitude, degrees
visibleif true, the label starts displayed, else it starts hidden
fontSizesize of the font to use
fontColoreither HTML-like color spec, e.g. "#ffff00", or 3-part float vector like Vec3f(1.0f,1.0f,0.0f) for yellow
autoDeletethe label will be automatically deleted after it is displayed once
autoDeleteTimeoutMsif not zero, the label will be automatically deleted after autoDeleteTimeoutMs ms

◆ labelObject

int LabelMgr::labelObject ( const QString &  text,
const QString &  objectName,
bool  visible = true,
float  fontSize = 14,
const QString &  fontColor = "#999999",
const QString &  side = "E",
double  labelDistance = -1.0,
const QString &  style = "TextOnly",
bool  autoDelete = false,
int  autoDeleteTimeoutMs = 0 
)
slot

Create a label which is attached to a StelObject.

Parameters
textthe text to display
objectNamethe English name of the object to attach to
visibleif true, the label starts displayed, else it starts hidden
fontSizesize of the font to use
fontColoreither HTML-like color spec, e.g. "#ffff00", or 3-part float vector like Vec3f(1.0f,1.0f,0.0f) for yellow
sidewhere the label appears in relation to object:
  • "N" = above object on screen
  • "S" = below object on screen
  • "E" = to the right of the object on screen
  • "W" = to the left of the object on screen
  • "NE", "NW", "SE", "SW" work too.
style"TextOnly" | "Line"
autoDeletethe label will be automatically deleted after it is displayed once
autoDeleteTimeoutMsif not zero, the label will be automatically deleted after autoDeleteTimeoutMs ms
Returns
a unique ID which can be used to refer to the label. returns -1 if the label could not be created (e.g. object not found)

◆ labelScreen

int LabelMgr::labelScreen ( const QString &  text,
int  x,
int  y,
bool  visible = true,
float  fontSize = 14,
const QString &  fontColor = "#999999",
bool  autoDelete = false,
int  autoDeleteTimeoutMs = 0 
)
slot

Create a label at fixed screen coordinates.

Parameters
textthe text to display
xthe horizontal position on the screen, in pixels, from the left of the screen
ythe vertical position on the screen, in pixels, from the top of the screen
visibleif true, the label starts displayed, else it starts hidden
fontSizesize of the font to use
fontColoreither HTML-like color spec, e.g. "#ffff00", or 3-part float vector like Vec3f(1.0f,1.0f,0.0f) for yellow
autoDeletethe label will be automatically deleted after it is displayed once
autoDeleteTimeoutMsif not zero, the label will be automatically deleted after autoDeleteTimeoutMs ms