Stellarium  1.0
Public Slots | Signals | Public Member Functions | Static Public Member Functions
StelObjectMgr Class Reference

#include <StelObjectMgr.hpp>

Public Slots

virtual void setExtraInfoString (const StelObject::InfoStringGroup &flags, const QString &str)
 
virtual void addToExtraInfoString (const StelObject::InfoStringGroup &flags, const QString &str)
 Add str to the extra string. More...
 
void removeExtraInfoStrings (const StelObject::InfoStringGroup &flags)
 Remove the extraInfoStrings with the given flags. More...
 

Signals

void selectedObjectChanged (StelModule::StelModuleSelectAction)
 Indicate that the selected StelObjects has changed. More...
 

Public Member Functions

virtual void init () Q_DECL_OVERRIDE
 Initialize itself. More...
 
void registerStelObjectMgr (StelObjectModule *m)
 Add a new StelObject manager into the list of supported modules. More...
 
bool findAndSelect (const StelCore *core, const Vec3d &pos, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection)
 Find and select an object near given equatorial J2000 position. More...
 
bool findAndSelect (const StelCore *core, int x, int y, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection)
 Find and select an object near given screen position. More...
 
bool findAndSelectI18n (const QString &nameI18n, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection)
 Find and select an object from its translated name. More...
 
bool findAndSelectI18n (const QString &name, const QString &objtype, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection)
 Find and select an object from its translated name and object type name. More...
 
bool findAndSelect (const QString &name, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection)
 Find and select an object from its standard program name. More...
 
bool findAndSelect (const QString &name, const QString &objtype, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection)
 Find and select an object from its standard program name and object type name. More...
 
QStringList listMatchingObjects (const QString &objPrefix, int maxNbItem=5, bool useStartOfWords=false) const
 Find and return the list of at most maxNbItem objects auto-completing the passed object name. More...
 
QStringList listAllModuleObjects (const QString &moduleId, bool inEnglish) const
 
QMap< QString, QString > objectModulesMap () const
 
bool getWasSelected (void) const
 Return whether an object was selected during last selection related event.
 
void unSelect (void)
 Notify that we want to unselect any object.
 
bool setSelectedObject (const StelObjectP obj, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection)
 Notify that we want to select the given object. More...
 
bool setSelectedObject (const QList< StelObjectP > &objs, StelModule::StelModuleSelectAction action=StelModule::ReplaceSelection)
 Notify that we want to select the given objects. More...
 
const QList< StelObjectP > & getSelectedObject () const
 Get the list of objects which was recently selected by the user.
 
QList< StelObjectPgetSelectedObject (const QString &type) const
 Return the list objects of type "withType" which was recently selected by the user. More...
 
void setFlagSelectedObjectPointer (bool b)
 Set whether a pointer is to be drawn over selected object.
 
bool getFlagSelectedObjectPointer (void) const
 Get whether a pointer is to be drawn over selected object.
 
StelObjectP searchByNameI18n (const QString &name) const
 Find any kind of object by its translated name.
 
StelObjectP searchByNameI18n (const QString &name, const QString &objType) const
 Find any kind of object by its translated name and its object type name.
 
StelObjectP searchByName (const QString &name) const
 Find any kind of object by its standard program name.
 
StelObjectP searchByName (const QString &name, const QString &objType) const
 Find any kind of object by its standard program name and its object type name.
 
StelObjectP searchByID (const QString &type, const QString &id) const
 Find an object of the given type and ID. More...
 
void setObjectSearchRadius (double radius)
 Set the radius in pixel in which objects will be searched when clicking on a point in sky.
 
void setDistanceWeight (float newDistanceWeight)
 Set the weight of the distance factor when choosing the best object to select. More...
 
StelObject::InfoStringGroup getCustomInfoStrings ()
 Return a list of enabled fields (custom info strings)
 
QStringList getExtraInfoStrings (const StelObject::InfoStringGroup &flags) const
 Retrieve an (unsorted) QStringList of all extra info strings that match flags. More...
 
- 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 void draw (StelCore *core)
 Execute all the drawing functions for this module. More...
 
virtual void update (double deltaTime)
 Update the module with respect to the time. 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 adress 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 double getCallOrder (StelModuleActionName actionName) const
 Return the value defining the order of call for the given action For example if stars.callOrder[ActionDraw] == 10 and constellation.callOrder[ActionDraw] == 11, the stars module will be drawn before the constellations. More...
 
virtual bool configureGui (bool show=true)
 Detect or show the configuration GUI elements for the module. More...
 

Static Public Member Functions

static QVariantMap getObjectInfo (const StelObjectP obj)
 Return a QMap of data about the object (calls obj->getInfoMap()). 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

Manage the selection and queries on one or more StelObjects. Each module is then free to manage object selection as it wants.

Member Function Documentation

◆ addToExtraInfoString

virtual void StelObjectMgr::addToExtraInfoString ( const StelObject::InfoStringGroup &  flags,
const QString &  str 
)
virtualslot

This should be preferrable over hard setting. Can be used by plugins to show extra info for the selected object, or for debugging. The strings will be shown in the InfoString for the selected object, below the default fields per-flag. Additional coordinates not fitting into one of the predefined coordinate sets should be flagged with OtherCoords, and must be adapted to table or non-table layout as required. The line ending must be given explicitly, usually just end a line with "<br/>", except when it may end up in a Table or appended to a line. See getCommonInfoString() or the respective getInfoString() in the subclasses for details of use.

◆ findAndSelect() [1/4]

bool StelObjectMgr::findAndSelect ( const QString &  name,
const QString &  objtype,
StelModule::StelModuleSelectAction  action = StelModule::ReplaceSelection 
)
Parameters
actiondefine whether to add to, replace, or remove from the existing selection
namethe case sensitive object translated name
objtypethe type of the object
Returns
true if a object with the passed name was found

◆ findAndSelect() [2/4]

bool StelObjectMgr::findAndSelect ( const QString &  name,
StelModule::StelModuleSelectAction  action = StelModule::ReplaceSelection 
)
Parameters
actiondefine whether to add to, replace, or remove from the existing selection
namethe case sensitive object translated name
Returns
true if a object with the passed name was found

◆ findAndSelect() [3/4]

bool StelObjectMgr::findAndSelect ( const StelCore core,
const Vec3d pos,
StelModule::StelModuleSelectAction  action = StelModule::ReplaceSelection 
)
Parameters
corethe StelCore instance to use for computations
posthe direction vector around which to search in equatorial J2000
actiondefine whether to add to, replace, or remove from the existing selection
Returns
true if a object was found at position (this does not necessarily means it is selected)

◆ findAndSelect() [4/4]

bool StelObjectMgr::findAndSelect ( const StelCore core,
int  x,
int  y,
StelModule::StelModuleSelectAction  action = StelModule::ReplaceSelection 
)
Parameters
corethe StelCore instance to use for computations
xthe x screen position in pixel
ythe y screen position in pixel
actiondefine whether to add to, replace, or remove from the existing selection
Returns
true if a object was found at position (this does not necessarily means it is selected)
Note
If aberration is computed, this first applies aberration backwards and then searches for an object.

◆ findAndSelectI18n() [1/2]

bool StelObjectMgr::findAndSelectI18n ( const QString &  name,
const QString &  objtype,
StelModule::StelModuleSelectAction  action = StelModule::ReplaceSelection 
)
Parameters
actiondefine whether to add to, replace, or remove from the existing selection
nameI18nthe case sensitive object translated name
objtypethe type of the object
Returns
true if a object with the passed name was found

◆ findAndSelectI18n() [2/2]

bool StelObjectMgr::findAndSelectI18n ( const QString &  nameI18n,
StelModule::StelModuleSelectAction  action = StelModule::ReplaceSelection 
)
Parameters
actiondefine whether to add to, replace, or remove from the existing selection
nameI18nthe case sensitive object translated name
Returns
true if a object with the passed name was found

◆ getExtraInfoStrings()

QStringList StelObjectMgr::getExtraInfoStrings ( const StelObject::InfoStringGroup &  flags) const

Normally the order matches the order of addition, but this cannot be guaranteed.

◆ getObjectInfo()

static QVariantMap StelObjectMgr::getObjectInfo ( const StelObjectP  obj)
static

If obj is valid, add an element ["found", true]. If obj is Q_NULLPTR, returns a 1-element map [["found", false]]

◆ getSelectedObject()

QList<StelObjectP> StelObjectMgr::getSelectedObject ( const QString &  type) const
Parameters
typereturn only objects of the given type

◆ init()

virtual void StelObjectMgr::init ( )
virtual

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

Implements StelModule.

◆ listMatchingObjects()

QStringList StelObjectMgr::listMatchingObjects ( const QString &  objPrefix,
int  maxNbItem = 5,
bool  useStartOfWords = false 
) const
Parameters
objPrefixthe case insensitive first letters of the searched object
maxNbItemthe maximum number of returned object names.
useStartOfWordsthe autofill mode for returned objects names
Returns
a list of matching object names by order of relevance, or an empty list if nothing match

◆ registerStelObjectMgr()

void StelObjectMgr::registerStelObjectMgr ( StelObjectModule m)

Registered modules can have selected objects

◆ removeExtraInfoStrings

void StelObjectMgr::removeExtraInfoStrings ( const StelObject::InfoStringGroup &  flags)
slot

This is a finer-grained removal than just extraInfoStrings.remove(flags), as it allows a combination of flags. After display, InfoPanel::setTextFromObjects() auto-clears the strings of the selected object using the AllInfo constant. extraInfoStrings having been set with the DebugAid and Script flags have to be removed by separate calls of this method. Those which have been set by scripts have to persist at least as long as the selection remains active. The behaviour of DebugAid texts depends on the use case.

◆ searchByID()

StelObjectP StelObjectMgr::searchByID ( const QString &  type,
const QString &  id 
) const
Parameters
typethe type of the object as given by StelObject::getType()
idthe ID of the object as given by StelObject::getID()
Returns
an null/invalid pointer when nothing is found, the given object otherwise.
Note
a StelObject may be found by multiple IDs (different catalog numbers, etc), so StelObject::getID() of the returned object may not be the same as the query parameter id.

◆ selectedObjectChanged

void StelObjectMgr::selectedObjectChanged ( StelModule::StelModuleSelectAction  )
signal
Parameters
actiondefine if the user requested that the objects are added to the selection or just replace it

◆ setDistanceWeight()

void StelObjectMgr::setDistanceWeight ( float  newDistanceWeight)
inline

Default to 1.

◆ setExtraInfoString

virtual void StelObjectMgr::setExtraInfoString ( const StelObject::InfoStringGroup &  flags,
const QString &  str 
)
virtualslot
Note
These functions were copied over from StelObject. Given that setExtraInfoString is non-const and some functions where these methods are useful are const, we can use the StelObjectMgr as "carrier object". Allow additions to the Info String. Can be used by plugins to show extra info for the selected object, or for debugging. Hard-set this string group to a single str, or delete all messages when str==""
This should be used with caution. Usually you want to use addToExtraInfoString().

◆ setSelectedObject() [1/2]

bool StelObjectMgr::setSelectedObject ( const QList< StelObjectP > &  objs,
StelModule::StelModuleSelectAction  action = StelModule::ReplaceSelection 
)
Parameters
objsa vector of objects to select
actiondefine whether to add to, replace, or remove from the existing selection
Returns
true if at least 1 object was sucessfully selected

◆ setSelectedObject() [2/2]

bool StelObjectMgr::setSelectedObject ( const StelObjectP  obj,
StelModule::StelModuleSelectAction  action = StelModule::ReplaceSelection 
)
Parameters
objthe StelObject to select
actionaction define whether to add to, replace, or remove from the existing selection
Returns
true if at least 1 object was sucessfully selected