Stellarium  23.4
Public Slots | Public Member Functions
ScreenImageMgr Class Reference

Module for managing images for scripting. More...

#include <ScreenImageMgr.hpp>

Public Slots

void createScreenImage (const QString &id, const QString &filename, qreal x, qreal y, qreal scale=1., bool visible=true, qreal alpha=1., float fadeDuration=1.)
 Create an image from a file and display on the screen at x,y coordinates. More...
 
bool getShowImage (const QString &id) const
 Find out if an image is currently visible. More...
 
void showImage (const QString &id, bool show)
 Set an image's visible status. More...
 
int getImageWidth (const QString &id) const
 
int getImageHeight (const QString &id) const
 
void setImageScale (const QString &id, qreal scaleX, qreal scaleY, float duration=0.)
 Set the x and y scale for the specified image, relative to size given at load time. More...
 
qreal getImageScaleX (const QString &id) const
 
qreal getImageScaleY (const QString &id) const
 
void setImageAlpha (const QString &id, qreal alpha)
 Set an image's alpha value when visible. More...
 
void setImageXY (const QString &id, qreal x, qreal y, float duration=0.)
 Set the x and y coordinates for the specified image. More...
 
void addImageXY (const QString &id, qreal x, qreal y, float duration=0.)
 Add x and y coordinate offsets to the specified image. More...
 
void deleteImage (const QString &id)
 Delete an image. More...
 
void deleteAllImages (void)
 Delete all images currently managed by ScreenImageMgr.
 
QStringList getAllImageIDs (void) const
 Get a list of currently loaded image IDs.
 

Public Member Functions

 ScreenImageMgr ()
 Construct a ScreenImageMgr object.
 
virtual void init () Q_DECL_OVERRIDE
 Initialize itself. More...
 
virtual void draw (StelCore *core) Q_DECL_OVERRIDE
 Execute all the drawing functions for this module. More...
 
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

Module for managing images for scripting.

Images are identified by a string ID which is passed to ScreenImageMgr members when it is necessary to specify an image to work with. Member functions in this class which modify the state of the class are all mediated through the signal/slot mechanism to ensure such operations happen in the main thread where images are drawn, and not in the script thread.

Member Function Documentation

◆ addImageXY

void ScreenImageMgr::addImageXY ( const QString &  id,
qreal  x,
qreal  y,
float  duration = 0. 
)
slot

Add x and y coordinate offsets to the specified image.

Parameters
idthe ID for the desired image.
xThe x-coordinate shift for the image, pixels.
yThe y-coordinate shift for the image, pixels.
durationThe time for the change to take place, in seconds.

◆ createScreenImage

void ScreenImageMgr::createScreenImage ( const QString &  id,
const QString &  filename,
qreal  x,
qreal  y,
qreal  scale = 1.,
bool  visible = true,
qreal  alpha = 1.,
float  fadeDuration = 1. 
)
slot

Create an image from a file and display on the screen at x,y coordinates.

Parameters
idthe ID to use when referring to this image (an arbitrary string). If an image with this id exists already, it will be deleted first.
filenamethe partial path of the file to load. This will be searched for using StelFileMgr, with "scripts/" prefixed to the filename.
xThe x-coordinate for the image (0 = left of screen)
yThe y-coordinate for the image (0 = top of screen)
scalescale factor for the image. 1 = original size, 0.5 = 50% size etc.
visibleThe initial visible state of the image
alphaThe initial alpha (opacity) value for the image (range 0.0=transparent to 1.0=opaque)
fadeDurationthe time it takes for screen images to fade in/out/change alpha in seconds.

◆ deleteImage

void ScreenImageMgr::deleteImage ( const QString &  id)
slot

Delete an image.

Parameters
idthe ID for the desired image.

◆ draw()

virtual void ScreenImageMgr::draw ( StelCore core)
virtual

Execute all the drawing functions for this module.

Parameters
corethe core to use for the drawing

Reimplemented from StelModule.

◆ getImageHeight

int ScreenImageMgr::getImageHeight ( const QString &  id) const
slot
Parameters
idthe ID for the desired image.
Returns
the currently scaled height in pixels.

◆ getImageScaleX

qreal ScreenImageMgr::getImageScaleX ( const QString &  id) const
slot
Parameters
idthe ID for the desired image.
Returns
current X scaling factor, relative to loaded size.

◆ getImageScaleY

qreal ScreenImageMgr::getImageScaleY ( const QString &  id) const
slot
Parameters
idthe ID for the desired image.
Returns
current Y scaling factor, relative to loaded size.

◆ getImageWidth

int ScreenImageMgr::getImageWidth ( const QString &  id) const
slot
Parameters
idthe ID for the desired image.
Returns
the currently scaled width, in pixels.

◆ getShowImage

bool ScreenImageMgr::getShowImage ( const QString &  id) const
slot

Find out if an image is currently visible.

Parameters
idthe ID for the desired image.
Returns
true if visible, false if not visible or not loaded.

◆ init()

virtual void ScreenImageMgr::init ( )
virtual

Initialize itself.

If the initialization takes significant time, the progress should be displayed on the loading bar.

Implements StelModule.

◆ setImageAlpha

void ScreenImageMgr::setImageAlpha ( const QString &  id,
qreal  alpha 
)
slot

Set an image's alpha value when visible.

Parameters
idthe ID for the desired image.
alphathe new alpha value to set.

◆ setImageScale

void ScreenImageMgr::setImageScale ( const QString &  id,
qreal  scaleX,
qreal  scaleY,
float  duration = 0. 
)
slot

Set the x and y scale for the specified image, relative to size given at load time.

Parameters
idthe ID for the desired image.
scaleXThe new x-scale for the image.
scaleYThe new y-scale for the image.
durationThe time for the change to take place, in seconds.

◆ setImageXY

void ScreenImageMgr::setImageXY ( const QString &  id,
qreal  x,
qreal  y,
float  duration = 0. 
)
slot

Set the x and y coordinates for the specified image.

Parameters
idthe ID for the desired image.
xThe new x-coordinate for the image, pixels.
yThe new y-coordinate for the image, pixels.
durationThe time for the change to take place, in seconds.

◆ showImage

void ScreenImageMgr::showImage ( const QString &  id,
bool  show 
)
slot

Set an image's visible status.

Parameters
idthe ID for the desired image.
showthe new visible state to set.