Stellarium 0.15.2
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 StelScriptMgr;
40 class StelSkyCultureMgr;
41 
48 {
49  Q_OBJECT
50 public:
51  MainService(const QByteArray& serviceName, QObject* parent = 0);
52 
53  virtual ~MainService() {}
54 
56  virtual void update(double deltaTime) Q_DECL_OVERRIDE;
57 
58 protected:
61  virtual void getImpl(const QByteArray& operation,const APIParameters &parameters, APIServiceResponse& response) Q_DECL_OVERRIDE;
64  virtual void postImpl(const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) Q_DECL_OVERRIDE;
65 
66 private slots:
67  StelObjectP getSelectedObject();
68 
70  QString getInfoString();
71 
73  bool focusObject(const QString& name);
74  void focusPosition(const Vec3d& pos);
75 
76  void updateMovement(float x, float y, bool xUpdated, bool yUpdated);
77  // Allow azimut/altitude changes. Values must be in Radians.
78  void updateView(double az, double alt, bool azUpdated, bool altUpdated);
79  void setFov(double fov);
80 
81  void actionToggled(const QString& id, bool val);
82  void propertyChanged(const QString& id, const QVariant& val);
83 
84 private:
85  StelCore* core;
86  StelActionMgr* actionMgr;
87  LandscapeMgr* lsMgr;
88  StelLocaleMgr* localeMgr;
89  StelMovementMgr* mvmgr;
90  StelObjectMgr* objMgr;
91  StelPropertyMgr* propMgr;
92  StelScriptMgr* scriptMgr;
93  StelSkyCultureMgr* skyCulMgr;
94 
95  float moveX,moveY;
96  qint64 lastMoveUpdateTime;
97 
98  struct ActionCacheEntry
99  {
100  ActionCacheEntry(const QString& str,bool val) : action(str),val(val) {}
101  QString action;
102  bool val;
103  };
104 
105  //lists the recently toggled actions - this is a pseudo-circular buffer
106  QContiguousCache<ActionCacheEntry> actionCache;
107  QMutex actionMutex;
108  QJsonObject getActionChangesSinceID(int changeId);
109 
110  struct PropertyCacheEntry
111  {
112  PropertyCacheEntry(const QString& str, const QVariant& val) : id(str),val(val) {}
113  QString id;
114  QVariant val;
115  };
116  QContiguousCache<PropertyCacheEntry> propCache;
117  QMutex propMutex;
118  QJsonObject getPropertyChangesSinceID(int changeId);
119 
120 };
121 
122 
123 
124 #endif
Implements the main API services, including the status operation which can be repeatedly polled to fi...
Definition: MainService.hpp:47
virtual void postImpl(const QByteArray &operation, const APIParameters &parameters, const QByteArray &data, APIServiceResponse &response) Q_DECL_OVERRIDE
Implements the HTTP POST operations.
virtual void update(double deltaTime) Q_DECL_OVERRIDE
Used to implement move functionality.
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 getImpl(const QByteArray &operation, const APIParameters &parameters, APIServiceResponse &response) Q_DECL_OVERRIDE
Implements the GET operations.
Manages the head movements and zoom operations.
Abstract base class for all Remote Control Plug-in service implementations.
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.
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 ...
QByteArray serviceName()
Returns the service name, used for request path mapping by the APIController.