Stellarium  23.4
Data Structures | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Properties | Friends
StelMainView Class Reference

Reimplement a QGraphicsView for Stellarium. More...

#include <StelMainView.hpp>

Data Structures

struct  GLInfo
 Contains some basic info about the OpenGL context used. More...
 

Public Slots

void setFullScreen (bool)
 Set whether fullscreen is activated or not.
 
void focusSky ()
 Return focus to the sky item. To be used when we close a dialog.
 
void saveScreenShot (const QString &filePrefix="stellarium-", const QString &saveDir="", const bool overwrite=false)
 Save a screen shot. More...
 
void setScreenshotFormat (const QString filetype)
 
QString getScreenshotFormat () const
 
bool getFlagInvertScreenShotColors () const
 Get whether colors are inverted when saving screenshot.
 
void setFlagInvertScreenShotColors (bool b)
 Set whether colors should be inverted when saving screenshot.
 
bool getFlagScreenshotDateFileName () const
 Get whether date and time should be used for screenshot naming.
 
void setFlagScreenshotDateFileName (bool b)
 Set whether date and time should be used for screenshot naming.
 
void setScreenshotFileMask (const QString filemask)
 
QString getScreenshotFileMask () const
 
bool getFlagOverwriteScreenShots () const
 Get whether existing files are overwritten when saving screenshot.
 
void setFlagOverwriteScreenShots (bool b)
 Set whether existing files are overwritten when saving screenshot.
 
bool getFlagUseCustomScreenshotSize () const
 Get whether custom size should be used for screenshots.
 
void setFlagUseCustomScreenshotSize (bool b)
 Set whether custom size should be used for screenshots.
 
int getCustomScreenshotWidth () const
 Get custom screenshot width.
 
void setCustomScreenshotWidth (int width)
 Set custom width for screenshots.
 
int getCustomScreenshotHeight () const
 Get custom screenshot height.
 
void setCustomScreenshotHeight (int height)
 Set custom height for screenshots.
 
int getScreenshotDpi () const
 Get screenshot DPI. This is only an entry in the screenshot image metadata. The raster content is not influenced.
 
void setScreenshotDpi (int dpi)
 Set screenshot DPI. This is only an entry in the screenshot image metadata. The raster content is not influenced.
 
float getCustomScreenshotMagnification () const
 Get screenshot magnification. More...
 
bool getFlagCursorTimeout () const
 Get the state of the mouse cursor timeout flag.
 
void setFlagCursorTimeout (bool b)
 Set the state of the mouse cursor timeout flag.
 
double getCursorTimeout () const
 Get the mouse cursor timeout in seconds.
 
void setCursorTimeout (double t)
 Set the mouse cursor timeout in seconds.
 
void setMinFps (float m)
 Set the minimum frames per second. More...
 
float getMinFps () const
 Get the current minimum frames per second.
 
void setMaxFps (float m)
 Set the maximum frames per second. More...
 
float getMaxFps () const
 Get the current maximum frames per second.
 
void setMinTimeBetweenFrames (int m)
 Set the minimum time between frames (in milliseconds). More...
 
int getMinTimeBetweenFrames () const
 Get the current minimum time between frames.
 
void thereWasAnEvent ()
 Notify that an event was handled by the program and therefore the FPS should be maximized for a couple of seconds.
 
bool needsMaxFPS () const
 Determines if we should render as fast as possible, or limit the FPS. More...
 
void setSkyBackgroundColor (Vec3f color)
 Set the sky background color. (Actually forwards to the StelRootItem.) Everything else than black creates a work of art!
 
Vec3f getSkyBackgroundColor () const
 Get the sky background color. (Actually retrieves from the StelRootItem.) Everything else than black creates a work of art!
 

Signals

void sizeChanged (const QSize &sz)
 emitted when window size has changed
 
void screenshotRequested (void)
 emitted when saveScreenShot is requested with saveScreenShot(). More...
 
void fullScreenChanged (bool b)
 
void reloadShadersRequested ()
 Emitted when the "Reload shaders" action is performed Interested objects should subscribe to this signal and reload their shaders when this is emitted.
 
void updateIconsRequested ()
 
void flagInvertScreenShotColorsChanged (bool b)
 
void flagOverwriteScreenshotsChanged (bool b)
 
void flagUseCustomScreenshotSizeChanged (bool use)
 
void flagScreenshotDateFileNameChanged (bool flag)
 
void customScreenshotWidthChanged (int width)
 
void customScreenshotHeightChanged (int height)
 
void screenshotDpiChanged (int dpi)
 
void screenshotFormatChanged (QString format)
 
void screenshotFileMaskChanged (QString format)
 
void skyBackgroundColorChanged (Vec3f color)
 
void flagCursorTimeoutChanged (bool b)
 
void cursorTimeoutChanged (double t)
 
void minFpsChanged (int fps)
 
void maxFpsChanged (int fps)
 
void minTimeBetweenFramesChanged (int tbf)
 

Public Member Functions

 StelMainView (QSettings *settings)
 
void init ()
 Start the main initialization of Stellarium.
 
void deinit ()
 
void initTitleI18n ()
 Set the application title for the current language. More...
 
void deinitGL ()
 Delete openGL textures (to call before the GLContext disappears)
 
QGraphicsWidget * getGuiWidget () const
 Return the parent gui widget, this should be used as parent to all the StelDialog instances.
 
QPoint getMousePos () const
 Return mouse position coordinates.
 
QOpenGLContext * glContext () const
 Returns the main application OpenGL context, which should be used for all drawing Stellarium does. More...
 
void glContextMakeCurrent ()
 Make the main GL context (the one returned from glContext()) current on the main view surface.
 
void glContextDoneCurrent ()
 Releases the main GL context.
 
const GLInfogetGLInformation () const
 Returns the information about the GL context, this does not require the context to be active.
 
QRectF setWindowSize (int width, int height)
 Set image size in windowed mode. More...
 

Static Public Member Functions

static StelMainViewgetInstance ()
 Get the StelMainView singleton instance.
 
static QSurfaceFormat getDesiredGLFormat (QSettings *configuration)
 Returns the desired OpenGL format settings.
 

Protected Member Functions

void moveEvent (QMoveEvent *event) override
 Hack to determine current monitor pixel ratio. More...
 
void closeEvent (QCloseEvent *event) override
 Handle window closed event, calling StelApp::quit()
 
void resizeEvent (QResizeEvent *event) override
 Handle window resized events, and change the size of the underlying QGraphicsScene to be the same.
 
void mouseMoveEvent (QMouseEvent *event) override
 Wake up mouse cursor (if it was hidden)
 
bool eventFilter (QObject *obj, QEvent *event) override
 

Properties

bool fullScreen
 
bool flagInvertScreenShotColors
 
bool flagScreenshotDateFileName
 
QString screenShotFileMask
 file type like "png" or "jpg".
 
bool flagOverwriteScreenshots
 if set to true, screenshot is named by date and time format
 
bool flagUseCustomScreenshotSize
 if set to true, screenshot is named exactly screenShotPrefix.png and overwrites existing file
 
int customScreenshotWidth
 if true, the next 2 values are observed for screenshots.
 
int customScreenshotHeight
 used when flagCustomResolutionScreenshots==true
 
int screenshotDpi
 used when flagCustomResolutionScreenshots==true
 
QString screenShotFormat
 
bool flagCursorTimeout
 
double cursorTimeout
 
Vec3f skyBackgroundColor
 
int minFps
 
int maxFps
 
int minTimeBetweenFrames
 The minimum desired time between frames, in milliseconds.
 

Friends

class StelGuiItem
 
class StelRootItem
 
class StelGraphicsScene
 
class NightModeGraphicsEffect
 

Detailed Description

Reimplement a QGraphicsView for Stellarium.

It is the class creating the singleton GL Widget, the main StelApp instance as well as the main GUI.


Data Structure Documentation

◆ StelMainView::GLInfo

struct StelMainView::GLInfo

Contains some basic info about the OpenGL context used.

Data Fields
QOpenGLFunctions * functions
PFNGLMINSAMPLESHADINGPROC glMinSampleShading
bool isCoreProfile
bool isGLES
bool isHighGraphicsMode
QOpenGLContext * mainContext
GLint maxAnisotropy
GLint maxTextureSize
QString renderer
bool supportsLuminanceTextures
QSurface * surface
QString vendor

Member Function Documentation

◆ getCustomScreenshotMagnification

float StelMainView::getCustomScreenshotMagnification ( ) const
inlineslot

Get screenshot magnification.

This should be used by StarMgr, text drawing and other elements which may want to enlarge their output in screenshots to keep them visible.

◆ glContext()

QOpenGLContext* StelMainView::glContext ( ) const

Returns the main application OpenGL context, which should be used for all drawing Stellarium does.

See also
glContextMakeCurrent()
glContextDoneCurrent()

◆ initTitleI18n()

void StelMainView::initTitleI18n ( )

Set the application title for the current language.

This is useful for e.g. chinese.

◆ moveEvent()

void StelMainView::moveEvent ( QMoveEvent *  event)
overrideprotected

Hack to determine current monitor pixel ratio.

◆ needsMaxFPS

bool StelMainView::needsMaxFPS ( ) const
slot

Determines if we should render as fast as possible, or limit the FPS.

This depends on the time the last user event happened.

◆ saveScreenShot

void StelMainView::saveScreenShot ( const QString &  filePrefix = "stellarium-",
const QString &  saveDir = "",
const bool  overwrite = false 
)
slot

Save a screen shot.

The format of the file, and hence the filename extension depends on the architecture and build type.

  • filePrefix changes the beginning of the file name
  • saveDir changes the directory where the screenshot is saved If saveDir is "" then StelFileMgr::getScreenshotDir() will be used
  • overwrite if true,
  • filePrefix is used as filename, and existing file will be overwritten.
    Note
    To set file type, use setScreenshotFormat() first.

◆ screenshotRequested

void StelMainView::screenshotRequested ( void  )
signal

emitted when saveScreenShot is requested with saveScreenShot().

doScreenshot() does the actual work (it has to do it in the main thread, where as saveScreenShot() might get called from another one.

Remarks
FS: is threaded access here even a possibility anymore, or a remnant of older code?

◆ setMaxFps

void StelMainView::setMaxFps ( float  m)
inlineslot

Set the maximum frames per second.

Parameters
mthe new maximum fps setting.

◆ setMinFps

void StelMainView::setMinFps ( float  m)
inlineslot

Set the minimum frames per second.

Usually this minimum will be switched to after there are no user events for some seconds to save power. However, if can be useful to set this to a high value to improve playing smoothness in scripts.

Parameters
mthe new minimum fps setting.

◆ setMinTimeBetweenFrames

void StelMainView::setMinTimeBetweenFrames ( int  m)
inlineslot

Set the minimum time between frames (in milliseconds).

Parameters
mthe new setting.

◆ setScreenshotFormat

void StelMainView::setScreenshotFormat ( const QString  filetype)
slot
  • filetype is the preferred file type (ending) like "png", "jpg", "bmp" etc. The supported filetypes depend on the underlying Qt version. The most popular may be PNG, JPG/JPEG, BMP, TIF (LZW compressed), TIFF (uncompressed), WEBP, but as of Qt5.12, we also have ICO (for thumbnails), PBM (Portable Bitmap), PGM (Portable Graymap), PPM (Portable Pixmap), XBM (X Bitmap) and XPM (X Pixmap).

◆ setWindowSize()

QRectF StelMainView::setWindowSize ( int  width,
int  height 
)

Set image size in windowed mode.

Leaves fullScreen if necessary. This is required for externally accessing Stellarium from other programs, do not delete!