Stellarium  0.16.1
MainService.hpp
1 /*
2  * Stellarium Remote Control plugin
3  * Copyright (C) 2015 Florian Schaukowitsch
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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef MAINSERVICE_HPP_
21 #define MAINSERVICE_HPP_
22 
23 #include "AbstractAPIService.hpp"
24 
25 #include "StelObjectType.hpp"
26 #include "VecMath.hpp"
27 
28 #include <QContiguousCache>
29 #include <QJsonObject>
30 #include <QMutex>
31 
32 class StelCore;
33 class StelActionMgr;
34 class LandscapeMgr;
35 class StelLocaleMgr;
36 class StelMovementMgr;
37 class StelObjectMgr;
38 class StelPropertyMgr;
39 class StelProperty;
40 class StelScriptMgr;
41 class StelSkyCultureMgr;
42 
49 {
50  Q_OBJECT
51 
52  Q_ENUMS(SelectionMode)
53 public:
54  enum SelectionMode
55  {
56  Center,
57  Zoom,
58  Mark
59  };
60 
61  MainService(QObject* parent = Q_NULLPTR);
62 
64  virtual void update(double deltaTime) Q_DECL_OVERRIDE;
65  virtual QLatin1String getPath() const Q_DECL_OVERRIDE { return QLatin1String("main"); }
68  virtual void get(const QByteArray& operation,const APIParameters &parameters, APIServiceResponse& response) Q_DECL_OVERRIDE;
71  virtual void post(const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) Q_DECL_OVERRIDE;
72 
73 private slots:
74  StelObjectP getSelectedObject();
75 
77  QString getInfoString();
78 
80  bool focusObject(const QString& name, SelectionMode mode);
81  void focusPosition(const Vec3d& pos);
82 
83  void updateMovement(double x, double y, bool xUpdated, bool yUpdated);
84  // Allow azimut/altitude changes. Values must be in Radians.
85  void updateView(double az, double alt, bool azUpdated, bool altUpdated);
86  void setFov(double fov);
87 
88  void actionToggled(const QString& id, bool val);
89  void propertyChanged(StelProperty* prop, const QVariant &val);
90 
91 private:
92  StelCore* core;
93  StelActionMgr* actionMgr;
94  LandscapeMgr* lsMgr;
95  StelLocaleMgr* localeMgr;
96  StelMovementMgr* mvmgr;
97  StelObjectMgr* objMgr;
98  StelPropertyMgr* propMgr;
99  StelScriptMgr* scriptMgr;
100  StelSkyCultureMgr* skyCulMgr;
101 
102  double moveX,moveY;
103  qint64 lastMoveUpdateTime;
104 
105  struct ActionCacheEntry
106  {
107  ActionCacheEntry(const QString& str,bool val) : action(str),val(val) {}
108  QString action;
109  bool val;
110  };
111 
112  //lists the recently toggled actions - this is a pseudo-circular buffer
113  QContiguousCache<ActionCacheEntry> actionCache;
114  QMutex actionMutex;
115  QJsonObject getActionChangesSinceID(int changeId);
116 
117  struct PropertyCacheEntry
118  {
119  PropertyCacheEntry(const QString& str, const QVariant& val) : id(str),val(val) {}
120  QString id;
121  QVariant val;
122  };
123  QContiguousCache<PropertyCacheEntry> propCache;
124  QMutex propMutex;
125  QJsonObject getPropertyChangesSinceID(int changeId);
126 
127 };
128 
129 
130 
131 #endif
Implements the main API services, including the status operation which can be repeatedly polled to fi...
Definition: MainService.hpp:48
virtual void update(double deltaTime) Q_DECL_OVERRIDE
Used to implement move functionality.
Wrapper around a Q_PROPERTY (see the Qt property system for more information) of a specific object...
Manages all the rendering at the level of the observer&#39;s surroundings.
Manage i18n operations such as message translation and date/time localization.
Main class for Stellarium core processing.
Definition: StelCore.hpp:48
Thread-safe version of HttpResponse that can be passed around through QMetaObject::invokeMethod.
virtual void post(const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) Q_DECL_OVERRIDE
Implements the HTTP POST operations.
Manages the head movements and zoom operations.
Abstract base class for all RemoteControlServiceInterface implementations which are provided by the R...
QMultiMap< QByteArray, QByteArray > APIParameters
Defines the HTTP request parameters for the service.
Define the StelObjectP type.
Manages the registration of specific object properties with the StelProperty system.
virtual QLatin1String getPath() const Q_DECL_OVERRIDE
Returns the desired path mapping If there is a conflict, only the first object is mapped...
Definition: MainService.hpp:65
Manage the selection and queries on one or more StelObjects.
Manage scripting in Stellarium.
Manage sky cultures for stellarium.
Manager for StelAction instances. Allows registration of new actions, and finding an existing one by ...