Документ взят из кэша поисковой машины. Адрес оригинального документа : http://astro.uni-altai.ru/~aw/stellarium/api/TelescopeControl_8hpp_source.html
Дата изменения: Unknown
Дата индексирования: Fri Feb 28 07:53:29 2014
Кодировка:

Поисковые слова: южная атлантическая аномалия
Stellarium: /home/aw/devel/stellarium/trunk/plugins/TelescopeControl/src/TelescopeControl.hpp Source File
Stellarium 0.12.3
TelescopeControl.hpp
1 /*
2  * Stellarium Telescope Control Plug-in
3  *
4  * Copyright (C) 2006 Johannes Gajdosik
5  * Copyright (C) 2009-2010 Bogdan Marinov
6  *
7  * This module was originally written by Johannes Gajdosik in 2006
8  * as a core module of Stellarium. In 2009 it was significantly extended with
9  * GUI features and later split as an external plug-in module by Bogdan Marinov.
10  *
11  * This class used to be called TelescopeMgr before the split.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
26  */
27 
28 #ifndef _TELESCOPE_CONTROL_HPP_
29 #define _TELESCOPE_CONTROL_HPP_
30 
31 #include "StelFader.hpp"
32 #include "StelGui.hpp"
33 #include "StelJsonParser.hpp"
34 #include "StelObjectModule.hpp"
35 #include "StelProjectorType.hpp"
36 #include "TelescopeControlGlobals.hpp"
37 #include "VecMath.hpp"
38 
39 #include <QFile>
40 #include <QFont>
41 #include <QHash>
42 #include <QMap>
43 #include <QProcess>
44 #include <QSettings>
45 #include <QString>
46 #include <QStringList>
47 #include <QTextStream>
48 #include <QVariant>
49 
50 class StelObject;
51 class StelProjector;
52 class TelescopeClient;
53 class TelescopeDialog;
54 class SlewDialog;
55 
56 using namespace TelescopeControlGlobals;
57 
58 typedef QSharedPointer<TelescopeClient> TelescopeClientP;
59 
68 {
69  Q_OBJECT
70 
71 public:
73  virtual ~TelescopeControl();
74 
76  // Methods defined in the StelModule class
77  virtual void init();
78  virtual void deinit();
79  virtual void update(double deltaTime);
80  virtual void draw(StelCore * core, class StelRenderer* renderer);
81  virtual double getCallOrder(StelModuleActionName actionName) const;
82 
84  // Methods defined in the StelObjectModule class
85  virtual QList<StelObjectP> searchAround(const Vec3d& v, double limitFov, const StelCore* core) const;
86  virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
87  virtual StelObjectP searchByName(const QString& name) const;
88  virtual QStringList listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem=5) const;
89  virtual QStringList listMatchingObjects(const QString& objPrefix, int maxNbItem=5) const;
90  // empty as its not celestial objects
91  virtual QStringList listAllObjects(bool inEnglish) const { Q_UNUSED(inEnglish) return QStringList(); }
92  virtual QString getName() const { return "Telescope Control"; }
93  virtual bool configureGui(bool show = true);
94 
96  // Methods specific to TelescopeControl
100  void telescopeGoto(int telescopeNr, const Vec3d &j2000Pos);
101 
103  void deleteAllTelescopes();
104 
106  const QHash<QString, DeviceModel>& getDeviceModels();
107 
109  void loadConfiguration();
111  void saveConfiguration();
112 
114  void saveTelescopes();
116  void loadTelescopes();
117 
118  //These are public, but not slots, because they don't use sufficient validation. Scripts shouldn't be able to add/remove telescopes, only to point them.
121  bool addTelescopeAtSlot(int slot, ConnectionType connectionType, QString name, QString equinox, QString host = QString("localhost"), int portTCP = DEFAULT_TCP_PORT, int delay = DEFAULT_DELAY, bool connectAtStartup = false, QList<double> circles = QList<double>(), QString serverName = QString(), QString portSerial = QString());
123  bool getTelescopeAtSlot(int slot, ConnectionType& connectionType, QString& name, QString& equinox, QString& host, int& portTCP, int& delay, bool& connectAtStartup, QList<double>& circles, QString& serverName, QString& portSerial);
125  bool removeTelescopeAtSlot(int slot);
126 
128  bool startTelescopeAtSlot(int slot);
130  bool stopTelescopeAtSlot(int slot);
132  bool stopAllTelescopes();
133 
135  bool isExistingClientAtSlot(int slot);
137  bool isConnectedClientAtSlot(int slot);
138 
140  QHash<int, QString> getConnectedClientsNames();
141 
142  bool getFlagUseServerExecutables() {return useServerExecutables;}
144  void setFlagUseServerExecutables(bool b);
145  const QString& getServerExecutablesDirectoryPath();
147  bool setServerExecutablesDirectoryPath(const QString& newPath);
148 
149  bool getFlagUseTelescopeServerLogs () {return useTelescopeServerLogs;}
150 
151 public slots:
153  void setFlagTelescopeReticles(bool b) {reticleFader = b;}
155  bool getFlagTelescopeReticles() const {return (bool)reticleFader;}
156 
158  void setFlagTelescopeLabels(bool b) {labelFader = b;}
160  bool getFlagTelescopeLabels() const {return labelFader==true;}
161 
163  void setFlagTelescopeCircles(bool b) {circleFader = b;}
165  bool getFlagTelescopeCircles() const {return circleFader==true;}
166 
168  void setReticleColor(const Vec3f &c) {reticleColor = c;}
170  const Vec3f& getReticleColor() const {return reticleColor;}
171 
173  const Vec3f& getLabelColor() const {return labelColor;}
175  void setLabelColor(const Vec3f &c) {labelColor = c;}
176 
178  void setCircleColor(const Vec3f &c) {circleColor = c;}
180  const Vec3f& getCircleColor() const {return circleColor;}
181 
183  void setFontSize(int fontSize);
184 
188  void slewTelescopeToSelectedObject();
189 
194  void slewTelescopeToViewDirection();
195 
197  void setFlagUseTelescopeServerLogs (bool b) {useTelescopeServerLogs = b;}
198 
199 signals:
200  void clientConnected(int slot, QString name);
201  void clientDisconnected(int slot);
202 
203 private slots:
204  void setStelStyle(const QString& section);
206  void translateActionDescriptions();
207 
208 private:
210  void drawPointer(const StelProjectorP& prj, const StelCore* core, class StelRenderer* renderer);
211 
213  void communicate(void);
214 
215  LinearFader labelFader;
216  LinearFader reticleFader;
217  LinearFader circleFader;
219  Vec3f reticleColor;
221  Vec3f labelColor;
223  Vec3f circleColor;
225  Vec3f reticleNormalColor;
227  Vec3f reticleNightColor;
229  Vec3f labelNormalColor;
231  Vec3f labelNightColor;
233  Vec3f circleNormalColor;
235  Vec3f circleNightColor;
236 
238  QFont labelFont;
239 
240  //Toolbar button to toggle the Slew window
241  QPixmap* pixmapHover;
242  QPixmap* pixmapOnIcon;
243  QPixmap* pixmapOffIcon;
244  StelButton* toolbarButton;
245 
247  class StelTextureNew* reticleTexture;
249  class StelTextureNew* selectionTexture;
250 
252  QMap<int, TelescopeClientP> telescopeClients;
254  QHash<int, QProcess*> telescopeServerProcess;
255  QStringList telescopeServers;
256  QVariantMap telescopeDescriptions;
257  QHash<QString, DeviceModel> deviceModels;
258 
259  QHash<ConnectionType, QString> connectionTypeNames;
260 
261  bool useTelescopeServerLogs;
262  QHash<int, QFile*> telescopeServerLogFiles;
263  QHash<int, QTextStream*> telescopeServerLogStreams;
264 
265  bool useServerExecutables;
266  QString serverExecutablesDirectoryPath;
267 
268  //GUI
269  TelescopeDialog * telescopeDialog;
270  SlewDialog * slewDialog;
271 
273  bool isValidSlotNumber(int slot);
274  bool isValidPort(uint port);
275  bool isValidDelay(int delay);
276 
281  bool startServerAtSlot(int slot, QString serverName, int tcpPort, QString serialPort);
283  bool stopServerAtSlot(int slot);
284 
286  bool startClientAtSlot(int slot, ConnectionType connectionType, QString name, QString equinox, QString host, int portTCP, int delay, QList<double> circles, QString serverName = QString(), QString portSerial = QString());
287 
289  bool stopClientAtSlot(int slot);
290 
292  void loadTelescopeServerExecutables();
293 
295  void loadDeviceModels();
296 
299  bool restoreDeviceModelsListTo(QString deviceModelsListPath);
300 
301  void addLogAtSlot(int slot);
302  void logAtSlot(int slot);
303  void removeLogAtSlot(int slot);
304 
305  QString actionGroupId;
306  QString moveToSelectedActionId;
307  QString moveToCenterActionId;
308 };
309 
310 
311 #include "fixx11h.h"
312 #include <QObject>
313 #include "StelPluginInterface.hpp"
314 
317 {
318  Q_OBJECT
319  Q_INTERFACES(StelPluginInterface)
320 public:
321  virtual StelModule* getStelModule() const;
322  virtual StelPluginInfo getPluginInfo() const;
323 };
324 
325 #endif /*_TELESCOPE_CONTROL_HPP_*/