TelescopeControl.hpp   TelescopeControl.hpp 
/* /*
* Stellarium Telescope Control Plug-in * Stellarium Telescope Control Plug-in
* *
* Copyright (C) 2006 Johannes Gajdosik * Copyright (C) 2006 Johannes Gajdosik
* Copyright (C) 2009 Bogdan Marinov * Copyright (C) 2009-2010 Bogdan Marinov
* *
* This module was originally written by Johannes Gajdosik in 2006 * This module was originally written by Johannes Gajdosik in 2006
* as a core module of Stellarium. In 2009 it was significantly extended wi th * as a core module of Stellarium. In 2009 it was significantly extended wi th
* GUI features and later split as an external plug-in module by Bogdan Mar inov. * GUI features and later split as an external plug-in module by Bogdan Mar inov.
* *
* This class used to be called TelescopeMgr before the split. * This class used to be called TelescopeMgr before the split.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
skipping to change at line 38 skipping to change at line 38
#ifndef _TELESCOPE_CONTROL_HPP_ #ifndef _TELESCOPE_CONTROL_HPP_
#define _TELESCOPE_CONTROL_HPP_ #define _TELESCOPE_CONTROL_HPP_
#include "StelFader.hpp" #include "StelFader.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelJsonParser.hpp" #include "StelJsonParser.hpp"
#include "StelObjectModule.hpp" #include "StelObjectModule.hpp"
#include "StelProjectorType.hpp" #include "StelProjectorType.hpp"
#include "StelTextureTypes.hpp" #include "StelTextureTypes.hpp"
#include "TelescopeControlGlobals.hpp" #include "TelescopeControlGlobals.hpp"
#include "TelescopeDialog.hpp"
#include "VecMath.hpp" #include "VecMath.hpp"
#include <QFile> #include <QFile>
#include <QFont> #include <QFont>
#include <QHash> #include <QHash>
#include <QMap> #include <QMap>
#include <QProcess> #include <QProcess>
#include <QSettings> #include <QSettings>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QTextStream> #include <QTextStream>
#include <QVariant> #include <QVariant>
class StelNavigator; class StelNavigator;
class StelObject; class StelObject;
class StelPainter; class StelPainter;
class StelProjector; class StelProjector;
class TelescopeClient; class TelescopeClient;
class TelescopeDialog; class TelescopeDialog;
class SlewDialog;
using namespace TelescopeControlGlobals; using namespace TelescopeControlGlobals;
typedef QSharedPointer<TelescopeClient> TelescopeClientP; typedef QSharedPointer<TelescopeClient> TelescopeClientP;
//! This class manages the controlling of one or more telescopes by one //! This class manages the controlling of one or more telescopes by one
//! instance of the stellarium program. "Controlling a telescope" //! instance of the stellarium program. "Controlling a telescope"
//! means receiving position information from the telescope //! means receiving position information from the telescope
//! and sending GOTO commands to the telescope. //! and sending GOTO commands to the telescope.
//! No esoteric features like motor focus, electric heating and such. //! No esoteric features like motor focus, electric heating and such.
skipping to change at line 84 skipping to change at line 84
public: public:
TelescopeControl(); TelescopeControl();
virtual ~TelescopeControl(); virtual ~TelescopeControl();
//////////////////////////////////////////////////////////////////// /////// //////////////////////////////////////////////////////////////////// ///////
// Methods defined in the StelModule class // Methods defined in the StelModule class
virtual void init(); virtual void init();
virtual void deinit(); virtual void deinit();
virtual void update(double deltaTime); virtual void update(double deltaTime);
virtual void draw(StelCore * core); virtual void draw(StelCore * core);
virtual void setStelStyle(const StelStyle& style);//From TelescopeMg r virtual void setStelStyle(const QString& section);
virtual double getCallOrder(StelModuleActionName actionName) const; virtual double getCallOrder(StelModuleActionName actionName) const;
//////////////////////////////////////////////////////////////////// /////// //////////////////////////////////////////////////////////////////// ///////
// Methods defined in the StelObjectModule class // Methods defined in the StelObjectModule class
virtual QList<StelObjectP> searchAround(const Vec3d& v, double limit Fov, const StelCore* core) const; virtual QList<StelObjectP> searchAround(const Vec3d& v, double limit Fov, const StelCore* core) const;
virtual StelObjectP searchByNameI18n(const QString& nameI18n) const; virtual StelObjectP searchByNameI18n(const QString& nameI18n) const;
virtual StelObjectP searchByName(const QString& name) const; virtual StelObjectP searchByName(const QString& name) const;
virtual QStringList listMatchingObjectsI18n(const QString& objPrefix , int maxNbItem=5) const; virtual QStringList listMatchingObjectsI18n(const QString& objPrefix , int maxNbItem=5) const;
virtual bool configureGui(bool show = true); virtual bool configureGui(bool show = true);
skipping to change at line 121 skipping to change at line 121
void saveConfiguration(); void saveConfiguration();
//! Saves to telescopes.json a list of the parameters of the active telescope clients. //! Saves to telescopes.json a list of the parameters of the active telescope clients.
void saveTelescopes(); void saveTelescopes();
//! Loads from telescopes.json the parameters of telescope clients a nd initializes them. If there are already any initialized telescope clients , they are removed. //! Loads from telescopes.json the parameters of telescope clients a nd initializes them. If there are already any initialized telescope clients , they are removed.
void loadTelescopes(); void loadTelescopes();
//These are public, but not slots, because they don't use sufficient validation. Scripts shouldn't be able to add/remove telescopes, only to po int them. //These are public, but not slots, because they don't use sufficient validation. Scripts shouldn't be able to add/remove telescopes, only to po int them.
//! Adds a telescope description containing the given properties. DO ES NOT VALIDATE its parameters. If serverName is specified, portSerial shou ld be specified too. Call saveTelescopes() to write the modified configurat ion to disc. Call startTelescopeAtSlot() to start this telescope. //! Adds a telescope description containing the given properties. DO ES NOT VALIDATE its parameters. If serverName is specified, portSerial shou ld be specified too. Call saveTelescopes() to write the modified configurat ion to disc. Call startTelescopeAtSlot() to start this telescope.
//! @param portSerial must be a valid serial port name for the parti cular platform, e.g. "COM1" for Microsoft Windows of "/dev/ttyS0" for Linux //! @param portSerial must be a valid serial port name for the parti cular platform, e.g. "COM1" for Microsoft Windows of "/dev/ttyS0" for Linux
bool addTelescopeAtSlot(int slot, QString name, QString host, int po rtTCP, int delay, bool connectAtStartup, QList<double> circles, QString ser verName = QString(), QString portSerial = QString()); bool addTelescopeAtSlot(int slot, ConnectionType connectionType, QSt ring name, QString host = QString("localhost"), int portTCP = DEFAULT_TCP_P ORT, int delay = DEFAULT_DELAY, bool connectAtStartup = false, QList<double > circles = QList<double>(), QString serverName = QString(), QString portSe rial = QString());
//! Retrieves a telescope description. Returns false if the slot is empty. Returns empty serverName and portSerial if the description contains no server. //! Retrieves a telescope description. Returns false if the slot is empty. Returns empty serverName and portSerial if the description contains no server.
bool getTelescopeAtSlot(int slot, QString& name, QString& host, int& portTCP, int& delay, bool& connectAtStartup, QList<double>& circles, QStri ng& serverName, QString& portSerial); bool getTelescopeAtSlot(int slot, ConnectionType& connectionType, QS tring& name, QString& host, int& portTCP, int& delay, bool& connectAtStartu p, QList<double>& circles, QString& serverName, QString& portSerial);
//! Removes info from the tree. Should it include stopTelescopeAtSlo t()? //! Removes info from the tree. Should it include stopTelescopeAtSlo t()?
bool removeTelescopeAtSlot(int slot); bool removeTelescopeAtSlot(int slot);
//! Starts a telescope at the given slot, getting its description wi th getTelescopeAtSlot(). Creates a TelescopeClient object and starts a serv er process if necessary. //! Starts a telescope at the given slot, getting its description wi th getTelescopeAtSlot(). Creates a TelescopeClient object and starts a serv er process if necessary.
bool startTelescopeAtSlot(int slot); bool startTelescopeAtSlot(int slot);
//! Stops the telescope at the given slot. Destroys the TelescopeCli ent object and terminates the server process if necessary. //! Stops the telescope at the given slot. Destroys the TelescopeCli ent object and terminates the server process if necessary.
bool stopTelescopeAtSlot(int slot); bool stopTelescopeAtSlot(int slot);
//! Stops all telescopes, but without removing them like deleteAllTe lescopes(). //! Stops all telescopes, but without removing them like deleteAllTe lescopes().
bool stopAllTelescopes(); bool stopAllTelescopes();
//! Checks if there's a TelescopeClient object at a given slot, i.e. if there's an active telescope at that slot. //! Checks if there's a TelescopeClient object at a given slot, i.e. if there's an active telescope at that slot.
bool isExistingClientAtSlot(int slot); bool isExistingClientAtSlot(int slot);
//! Checks if the TelescopeClient object at a given slot is connecte d to a server. //! Checks if the TelescopeClient object at a given slot is connecte d to a server.
bool isConnectedClientAtSlot(int slot); bool isConnectedClientAtSlot(int slot);
//! Returns the module-specific style sheet for the given mode ("col //! Returns a list of the currently connected clients
or" or "night_color", as used in StelStyle). QHash<int, QString> getConnectedClientsNames();
const QString& getModuleStyleSheet(const QString& styleModeName);
//! Returns the module-specific style sheet.
//! The main StelStyle instance should be passed.
const StelStyle getModuleStyleSheet(const StelStyle& style);
bool getFlagUseServerExecutables() {return useServerExecutables;} bool getFlagUseServerExecutables() {return useServerExecutables;}
//! Forces a call of loadDeviceModels(). Stops all active telescopes . //! Forces a call of loadDeviceModels(). Stops all active telescopes .
void setFlagUseServerExecutables(bool b); void setFlagUseServerExecutables(bool b);
const QString& getServerExecutablesDirectoryPath(); const QString& getServerExecutablesDirectoryPath();
//! Forces a call of loadDeviceModels(). Stops all active telescopes . //! Forces a call of loadDeviceModels(). Stops all active telescopes .
bool setServerExecutablesDirectoryPath(const QString& newPath); bool setServerExecutablesDirectoryPath(const QString& newPath);
bool getFlagUseTelescopeServerLogs () {return useTelescopeServerLogs ;} bool getFlagUseTelescopeServerLogs () {return useTelescopeServerLogs ;}
public slots: public slots:
//! Set display flag for telescope markers and circles //! Set display flag for telescope reticles
void setFlagTelescopes(bool b) {reticleFader = b;} void setFlagTelescopeReticles(bool b) {reticleFader = b;}
//! Get display flag for telescope markers and circles //! Get display flag for telescope reticles
bool getFlagTelescopes() const {return (bool)reticleFader;} bool getFlagTelescopeReticles() const {return (bool)reticleFader;}
//! Set display flag for telescope name labels //! Set display flag for telescope name labels
void setFlagTelescopeName(bool b) {labelFader = b;} void setFlagTelescopeLabels(bool b) {labelFader = b;}
//! Get display flag for telescope name labels //! Get display flag for telescope name labels
bool getFlagTelescopeName() const {return labelFader==true;} bool getFlagTelescopeLabels() const {return labelFader==true;}
//! Set the telescope circle color //! Set display flag for telescope field of view circles
void setCircleColor(const Vec3f &c) {circleColor = c;} void setFlagTelescopeCircles(bool b) {circleFader = b;}
//! Get the telescope circle color //! Get display flag for telescope field of view circles
const Vec3f& getCircleColor() const {return circleColor;} bool getFlagTelescopeCircles() const {return circleFader==true;}
//! Set the telescope reticle color
void setReticleColor(const Vec3f &c) {reticleColor = c;}
//! Get the telescope reticle color
const Vec3f& getReticleColor() const {return reticleColor;}
//! Get the telescope labels color //! Get the telescope labels color
const Vec3f& getLabelColor() const {return labelColor;} const Vec3f& getLabelColor() const {return labelColor;}
//! Set the telescope labels color //! Set the telescope labels color
void setLabelColor(const Vec3f &c) {labelColor = c;} void setLabelColor(const Vec3f &c) {labelColor = c;}
//! Set the field of view circles color
void setCircleColor(const Vec3f &c) {circleColor = c;}
//! Get the field of view circles color
const Vec3f& getCircleColor() const {return circleColor;}
//! Define font size to use for telescope names display //! Define font size to use for telescope names display
void setFontSize(int fontSize); void setFontSize(int fontSize);
//! slews a telescope to the selected object.
//! For use from the GUI. The telescope number will be
//! deduced from the name of the QAction which triggered the slot.
void slewTelescopeToSelectedObject();
//! slews a telescope to the point of the celestial sphere currently
//! in the center of the screen.
//! For use from the GUI. The telescope number will be //! For use from the GUI. The telescope number will be
//! chosen according to the action which triggered the slot to be //! deduced from the name of the QAction which triggered the slot.
//! triggered. void slewTelescopeToViewDirection();
void moveTelescopeToSelected(void);
//! Used in the GUI //! Used in the GUI
void setFlagUseTelescopeServerLogs (bool b) {useTelescopeServerLogs = b;} void setFlagUseTelescopeServerLogs (bool b) {useTelescopeServerLogs = b;}
signals:
void clientConnected(int slot, QString name);
void clientDisconnected(int slot);
private: private:
//! Draw a nice animated pointer around the object if it's selected //! Draw a nice animated pointer around the object if it's selected
void drawPointer(const StelProjectorP& prj, const StelNavigator* nav , StelPainter& sPainter); void drawPointer(const StelProjectorP& prj, const StelNavigator* nav , StelPainter& sPainter);
//! Perform the communication with the telescope servers //! Perform the communication with the telescope servers
void communicate(void); void communicate(void);
LinearFader labelFader; LinearFader labelFader;
LinearFader reticleFader; LinearFader reticleFader;
//! Colour currently used to draw telescope circles LinearFader circleFader;
Vec3f circleColor; //! Colour currently used to draw telescope reticles
Vec3f reticleColor;
//! Colour currently used to draw telescope text labels //! Colour currently used to draw telescope text labels
Vec3f labelColor; Vec3f labelColor;
//! Colour used to draw telescope circles in normal mode, as set in //! Colour currently used to draw field of view circles
the configuration file Vec3f circleColor;
Vec3f circleNormalColor; //! Colour used to draw telescope reticles in normal mode, as set in
//! Colour used to draw telescope circles in night mode, as set in t the configuration file
he configuration file Vec3f reticleNormalColor;
Vec3f circleNightColor; //! Colour used to draw telescope reticles in night mode, as set in
the configuration file
Vec3f reticleNightColor;
//! Colour used to draw telescope labels in normal mode, as set in t he configuration file //! Colour used to draw telescope labels in normal mode, as set in t he configuration file
Vec3f labelNormalColor; Vec3f labelNormalColor;
//! Colour used to draw telescope labels in night mode, as set in th e configuration file //! Colour used to draw telescope labels in night mode, as set in th e configuration file
Vec3f labelNightColor; Vec3f labelNightColor;
//! Colour used to draw field of view circles in normal mode, as set
in the configuration file
Vec3f circleNormalColor;
//! Colour used to draw field of view circles in night mode, as set
in the configuration file
Vec3f circleNightColor;
//! Font used to draw telescope text labels //! Font used to draw telescope text labels
QFont labelFont; QFont labelFont;
#ifdef USE_TOOLBAR_BUTTON //Toolbar button to toggle the Slew window
//Toolbar button stuff
QPixmap* pixmapHover; QPixmap* pixmapHover;
QPixmap* pixmapOnIcon; QPixmap* pixmapOnIcon;
QPixmap* pixmapOffIcon; QPixmap* pixmapOffIcon;
StelButton* toolbarButton; StelButton* toolbarButton;
#endif //USE_TOOLBAR_BUTTON
//! Telescope reticle texture //! Telescope reticle texture
StelTextureSP reticleTexture; StelTextureSP reticleTexture;
//! Telescope selection marker texture //! Telescope selection marker texture
StelTextureSP selectionTexture; StelTextureSP selectionTexture;
//! Contains the initialized telescope client objects representing t he telescopes that Stellarium is connected to or attempting to connect to. //! Contains the initialized telescope client objects representing t he telescopes that Stellarium is connected to or attempting to connect to.
QMap<int, TelescopeClientP> telescopeClients; QMap<int, TelescopeClientP> telescopeClients;
//! Contains QProcess objects of the currently running telescope ser ver processes that have been launched by Stellarium. //! Contains QProcess objects of the currently running telescope ser ver processes that have been launched by Stellarium.
QHash<int, QProcess*> telescopeServerProcess; QHash<int, QProcess*> telescopeServerProcess;
QStringList telescopeServers; QStringList telescopeServers;
QVariantMap telescopeDescriptions; QVariantMap telescopeDescriptions;
QHash<QString, DeviceModel> deviceModels; QHash<QString, DeviceModel> deviceModels;
QHash<QString, QString> moduleStyleSheet;
QHash<ConnectionType, QString> connectionTypeNames;
bool useTelescopeServerLogs; bool useTelescopeServerLogs;
QHash<int, QFile*> telescopeServerLogFiles; QHash<int, QFile*> telescopeServerLogFiles;
QHash<int, QTextStream*> telescopeServerLogStreams; QHash<int, QTextStream*> telescopeServerLogStreams;
bool useServerExecutables; bool useServerExecutables;
QString serverExecutablesDirectoryPath; QString serverExecutablesDirectoryPath;
//GUI //GUI
TelescopeDialog* telescopeDialog; TelescopeDialog * telescopeDialog;
SlewDialog * slewDialog;
//Styles
QByteArray * normalStyleSheet;
QByteArray * nightStyleSheet;
//! Used internally. Checks if the argument is a valid slot number. //! Used internally. Checks if the argument is a valid slot number.
bool isValidSlotNumber(int slot); bool isValidSlotNumber(int slot);
bool isValidPort(uint port);
bool isValidDelay(int delay);
//! Start the telescope server defined for a given slot in a new QPr ocess //! Start the telescope server defined for a given slot in a new QPr ocess
//! @param slot the slot number //! @param slot the slot number
//! @param serverName the short form of the server name (e.g. "Dummy " for "TelescopeServerDummy") //! @param serverName the short form of the server name (e.g. "Dummy " for "TelescopeServerDummy")
//! @param tcpPort TCP slot the server should listen to //! @param tcpPort TCP slot the server should listen to
bool startServerAtSlot(int slot, QString serverName, int tcpPort, QS tring serialPort); bool startServerAtSlot(int slot, QString serverName, int tcpPort, QS tring serialPort);
//! Stop the telescope server at a given slot, terminating the proce ss //! Stop the telescope server at a given slot, terminating the proce ss
bool stopServerAtSlot(int slot); bool stopServerAtSlot(int slot);
//! A wrapper for TelescopeClient::create(). Used internally by load Telescopes() and startTelescopeAtSlot(). Does not perform any validation on its arguments. //! A wrapper for TelescopeClient::create(). Used internally by load Telescopes() and startTelescopeAtSlot(). Does not perform any validation on its arguments.
bool startClientAtSlot(int slot, QString name, QString host, int por tTCP, int delay, QList<double> circles, QString serverName = QString(), QSt ring portSerial = QString()); bool startClientAtSlot(int slot, ConnectionType connectionType, QStr ing name, QString host, int portTCP, int delay, QList<double> circles, QStr ing serverName = QString(), QString portSerial = QString());
//! Returns true if the TelescopeClient at this slot has been stoppe d successfully or doesn't exist //! Returns true if the TelescopeClient at this slot has been stoppe d successfully or doesn't exist
bool stopClientAtSlot(int slot); bool stopClientAtSlot(int slot);
//! Compile a list of the executables in the /servers folder //! Compile a list of the executables in the /servers folder
void loadTelescopeServerExecutables(); void loadTelescopeServerExecutables();
//! Loads the list of supported telescope models. Calls loadTelescop eServerExecutables() internally. //! Loads the list of supported telescope models. Calls loadTelescop eServerExecutables() internally.
void loadDeviceModels(); void loadDeviceModels();
 End of changes. 24 change blocks. 
35 lines changed or deleted 73 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/