summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBogdan Marinov <bogdan.marinov84@gmail.com>2012-11-21 20:24:46 +0200
committerBogdan Marinov <bogdan.marinov84@gmail.com>2012-11-21 20:24:46 +0200
commit3822602924ca066c4081db1f26c9319456282b2e (patch)
treef1e00e5d1ca7915dc6a34e795d61721c4d4844ad
parent0a5922071c6764fc1171532a652a9c58de2d4605 (diff)
separate control widget for ASCOM devicestelescope-control-0-4-0
-rw-r--r--plugins/TelescopeControl/src/CMakeLists.txt9
-rw-r--r--plugins/TelescopeControl/src/TelescopeControl.cpp8
-rw-r--r--plugins/TelescopeControl/src/TelescopeControl.hpp2
-rw-r--r--plugins/TelescopeControl/src/gui/AscomDeviceWidget.cpp93
-rw-r--r--plugins/TelescopeControl/src/gui/AscomDeviceWidget.hpp67
-rw-r--r--plugins/TelescopeControl/src/gui/CoordinatesWidget.cpp33
-rw-r--r--plugins/TelescopeControl/src/gui/CoordinatesWidget.hpp2
-rw-r--r--plugins/TelescopeControl/src/gui/DeviceControlPanel.cpp29
-rw-r--r--plugins/TelescopeControl/src/gui/DeviceControlPanel.hpp10
-rw-r--r--plugins/TelescopeControl/src/gui/StelDeviceWidget.cpp12
-rw-r--r--plugins/TelescopeControl/src/gui/StelDeviceWidget.hpp9
11 files changed, 244 insertions, 30 deletions
diff --git a/plugins/TelescopeControl/src/CMakeLists.txt b/plugins/TelescopeControl/src/CMakeLists.txt
index 16e5c0c9be..beeb701d14 100644
--- a/plugins/TelescopeControl/src/CMakeLists.txt
+++ b/plugins/TelescopeControl/src/CMakeLists.txt
@@ -91,8 +91,10 @@ SET(TelescopeControl_SRCS
IF(WIN32)
SET(TelescopeControl_SRCS
${TelescopeControl_SRCS}
- clients/TelescopeClientAscom.hpp
- clients/TelescopeClientAscom.cpp)
+ clients/TelescopeClientAscom.hpp
+ clients/TelescopeClientAscom.cpp
+ gui/AscomDeviceWidget.hpp
+ gui/AscomDeviceWidget.cpp)
ENDIF(WIN32)
# Add here all the .ui files
@@ -143,7 +145,8 @@ SET(TelescopeControl_MOC_HDRS
IF(WIN32)
SET(TelescopeControl_MOC_HDRS
${TelescopeControl_MOC_HDRS}
- clients/TelescopeClientAscom.hpp)
+ clients/TelescopeClientAscom.hpp
+ gui/AscomDeviceWidget.hpp)
ENDIF(WIN32)
# After this call, TelescopeControl_MOC_SRCS = moc_TelescopeControl.cxx
diff --git a/plugins/TelescopeControl/src/TelescopeControl.cpp b/plugins/TelescopeControl/src/TelescopeControl.cpp
index 10c1d360e1..3791c05484 100644
--- a/plugins/TelescopeControl/src/TelescopeControl.cpp
+++ b/plugins/TelescopeControl/src/TelescopeControl.cpp
@@ -183,8 +183,10 @@ void TelescopeControl::init()
controlPanelWindow, SLOT(logServerMessage(QString)));
connect(indiService, SIGNAL(clientConnected(IndiClient*)),
this, SLOT(watchIndiClient(IndiClient*)));
- connect(this, SIGNAL(clientConnected(const QString&)),
- controlPanelWindow, SLOT(addStelDevice(const QString&)));
+ connect(this,
+ SIGNAL(clientConnected(QString,TelescopeClientP)),
+ controlPanelWindow,
+ SLOT(addStelDevice(QString,TelescopeClientP)));
connect(this, SIGNAL(clientDisconnected(const QString&)),
controlPanelWindow, SLOT(removeStelDevice(const QString&)));
@@ -1590,7 +1592,7 @@ bool TelescopeControl::startClient(const QString& id,
if (interfaceType != "INDI")//Only TCP connections?
{
telescopes.insert(id, newTelescopeP);
- emit clientConnected(id);
+ emit clientConnected(id, newTelescopeP);
}
else
indiDevices.insert(id, newTelescopeP);
diff --git a/plugins/TelescopeControl/src/TelescopeControl.hpp b/plugins/TelescopeControl/src/TelescopeControl.hpp
index 904396730f..f49957415d 100644
--- a/plugins/TelescopeControl/src/TelescopeControl.hpp
+++ b/plugins/TelescopeControl/src/TelescopeControl.hpp
@@ -234,7 +234,7 @@ public slots:
signals:
//! Emitted when a connection has been established.
- void clientConnected(const QString& id);
+ void clientConnected(const QString& id, const TelescopeClientP& client);
//! Emitted when a connection has been closed.
void clientDisconnected(const QString& id);
diff --git a/plugins/TelescopeControl/src/gui/AscomDeviceWidget.cpp b/plugins/TelescopeControl/src/gui/AscomDeviceWidget.cpp
new file mode 100644
index 0000000000..60bd456f1d
--- /dev/null
+++ b/plugins/TelescopeControl/src/gui/AscomDeviceWidget.cpp
@@ -0,0 +1,93 @@
+/*
+ * Stellarium Device Control plug-in
+ * Copyright (C) 2012 Bogdan Marinov
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street,
+ * Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#include <QVBoxLayout>
+#include "AngleSpinBox.hpp"
+#include "CoordinatesWidget.hpp"
+#include "FovCirclesWidget.hpp"
+#include "TelescopeControl.hpp"
+#include "StelUtils.hpp"
+
+#include "AscomDeviceWidget.hpp"
+
+AscomDeviceWidget::AscomDeviceWidget(TelescopeControl* plugin,
+ const QString& id,
+ const TelescopeClientAscomP& telescope,
+ QWidget* parent) :
+ QWidget(parent),
+ clientId(id),
+ coordsWidget(0),
+ fcWidget(0)
+{
+ Q_ASSERT(plugin);
+ deviceManager = plugin;
+
+ Q_ASSERT(telescope);
+ client = telescope;
+ if (!client)
+ return;
+
+ QVBoxLayout* layout = new QVBoxLayout(this);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->setSpacing(0);
+
+ if (client->canSlew())
+ {
+ coordsWidget = new CoordinatesWidget(this);
+ layout->addWidget(coordsWidget);
+
+ connect(coordsWidget->slewCenterButton, SIGNAL(clicked()),
+ this, SLOT(slewToCenter()));
+ connect(coordsWidget->slewCoordsButton, SIGNAL(clicked()),
+ this, SLOT(slewToCoords()));
+ connect(coordsWidget->slewSelectedButton, SIGNAL(clicked()),
+ this, SLOT(slewToObject()));
+
+ // TODO: Stop
+ // TODO: Sync
+ }
+
+ fcWidget = new FovCirclesWidget(telescope.data(), this);
+ layout->addWidget(fcWidget);
+}
+
+void AscomDeviceWidget::slewToCoords()
+{
+ if (clientId.isEmpty())
+ return;
+
+ double radiansRA = coordsWidget->raSpinBox->valueRadians();
+ double radiansDec = coordsWidget->decSpinBox->valueRadians();
+
+ Vec3d targetPosition;
+ StelUtils::spheToRect(radiansRA, radiansDec, targetPosition);
+
+ client->telescopeGoto(targetPosition);
+}
+
+void AscomDeviceWidget::slewToCenter()
+{
+ deviceManager->slewTelescopeToViewDirection(clientId);
+}
+
+void AscomDeviceWidget::slewToObject()
+{
+ deviceManager->slewTelescopeToSelectedObject(clientId);
+}
diff --git a/plugins/TelescopeControl/src/gui/AscomDeviceWidget.hpp b/plugins/TelescopeControl/src/gui/AscomDeviceWidget.hpp
new file mode 100644
index 0000000000..01f90db0be
--- /dev/null
+++ b/plugins/TelescopeControl/src/gui/AscomDeviceWidget.hpp
@@ -0,0 +1,67 @@
+/*
+ * Stellarium Device Control plug-in
+ * Copyright (C) 2012 Bogdan Marinov
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street,
+ * Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+#ifndef ASCOMDEVICEWIDGET_HPP
+#define ASCOMDEVICEWIDGET_HPP
+
+#include <QWidget>
+
+#include "TelescopeClientAscom.hpp"
+
+class CoordinatesWidget;
+class FovCirclesWidget;
+class TelescopeControl;
+
+//! Control panel tab representing a telescope/mount ASCOM driver.
+//! @todo Support for multiple coordinate systems.
+//! @todo Direction pad.
+//! @ingroup plugin-devicecontrol
+class AscomDeviceWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ AscomDeviceWidget(TelescopeControl* plugin,
+ const QString& id,
+ const TelescopeClientAscomP& telescope,
+ QWidget *parent = 0);
+
+signals:
+
+public slots:
+ //! Slew the telescope to the manually entered coordinates.
+ void slewToCoords();
+ //! Slew the telescope to the view direction.
+ void slewToCenter();
+ //! Slew the telescope to the selected object.
+ void slewToObject();
+
+private:
+ //! Pointer to the main plug-in class.
+ TelescopeControl* deviceManager;
+
+ //! Identifier of the controlled client.
+ QString clientId;
+
+ TelescopeClientAscomP client;
+
+ CoordinatesWidget* coordsWidget;
+ FovCirclesWidget* fcWidget;
+};
+
+#endif // ASCOMDEVICEWIDGET_HPP
diff --git a/plugins/TelescopeControl/src/gui/CoordinatesWidget.cpp b/plugins/TelescopeControl/src/gui/CoordinatesWidget.cpp
index 6646a03785..a3c722af15 100644
--- a/plugins/TelescopeControl/src/gui/CoordinatesWidget.cpp
+++ b/plugins/TelescopeControl/src/gui/CoordinatesWidget.cpp
@@ -72,25 +72,26 @@ CoordinatesWidget::CoordinatesWidget(QWidget *parent) :
formatLayout->addWidget(decimalButton);
layout->addLayout(formatLayout);
- // Large "slew" button group
+ // "Slew" button group
QSize kingSize(50, 50);
slewCoordsButton = new QPushButton();
slewCoordsButton->setMinimumSize(kingSize);
- QGridLayout* bigButtonLayout = new QGridLayout();
- layout->addLayout(bigButtonLayout);
- bigButtonLayout->addWidget(slewCoordsButton, 0, 0, 1, 2);
- //QPushButton* abortButton = new QPushButton();
- //abortButton->setMinimumSize(kingSize);
- //bigButtonLayout->addWidget(abortButton, 0, 2, 1, 1);
+ QGridLayout* slewButtonLayout = new QGridLayout();
+ layout->addLayout(slewButtonLayout);
+ slewButtonLayout->addWidget(slewCoordsButton, 0, 0, 1, 2);
+ abortButton = new QPushButton();
+ abortButton->setMinimumSize(kingSize);
+ abortButton->setSizePolicy(QSizePolicy::Preferred,
+ QSizePolicy::MinimumExpanding);
+ slewButtonLayout->addWidget(abortButton, 0, 2, 2, 1);
//abortButton->setHidden(true);
-
- // Small "slew" buttons
slewCenterButton = new QPushButton();
+ slewButtonLayout->addWidget(slewCenterButton, 1, 0, 1, 1);
slewSelectedButton = new QPushButton();
- QHBoxLayout* smallButtonLayout = new QHBoxLayout();
- smallButtonLayout->addWidget(slewCenterButton);
- smallButtonLayout->addWidget(slewSelectedButton);
- layout->addLayout(smallButtonLayout);
+ slewButtonLayout->addWidget(slewSelectedButton, 1, 1, 1, 1);
+
+ syncButton = new QPushButton();
+ layout->addWidget(syncButton);
// Init control strings
retranslate();
@@ -122,6 +123,12 @@ void CoordinatesWidget::retranslate()
slewCoordsButton->setText(q_("&Slew"));
slewCenterButton->setText(q_("Slew to the center of the screen"));
slewSelectedButton->setText(q_("Slew to the selected object"));
+
+ syncButton->setText(q_("Sync"));
+ syncButton->setToolTip(q_("Set the device's internal coordinates to the given coordinates"));
+
+ abortButton->setText(q_("Stop"));
+ abortButton->setToolTip(q_("Stop the current movement"));
}
void CoordinatesWidget::setFormat(int buttonId)
diff --git a/plugins/TelescopeControl/src/gui/CoordinatesWidget.hpp b/plugins/TelescopeControl/src/gui/CoordinatesWidget.hpp
index e9711d89b7..e465c501a4 100644
--- a/plugins/TelescopeControl/src/gui/CoordinatesWidget.hpp
+++ b/plugins/TelescopeControl/src/gui/CoordinatesWidget.hpp
@@ -45,9 +45,11 @@ public:
AngleSpinBox* raSpinBox;
AngleSpinBox* decSpinBox;
QPushButton* slewCoordsButton;
+ QPushButton* abortButton;
QPushButton* currentButton;
QPushButton* slewSelectedButton;
QPushButton* slewCenterButton;
+ QPushButton* syncButton;
public slots:
void retranslate();
diff --git a/plugins/TelescopeControl/src/gui/DeviceControlPanel.cpp b/plugins/TelescopeControl/src/gui/DeviceControlPanel.cpp
index 113a298681..5ba840a852 100644
--- a/plugins/TelescopeControl/src/gui/DeviceControlPanel.cpp
+++ b/plugins/TelescopeControl/src/gui/DeviceControlPanel.cpp
@@ -34,6 +34,10 @@
#include "StelDeviceWidget.hpp"
#include "FovCirclesWidget.hpp"
#include "TelescopeClientIndi.hpp"
+#ifdef _WIN32
+#include "AscomDeviceWidget.hpp"
+#include "TelescopeClientAscom.hpp"
+#endif
DeviceControlPanel::DeviceControlPanel(TelescopeControl *plugin) :
deviceManager(0)
@@ -219,10 +223,11 @@ void DeviceControlPanel::removeIndiClient(const QString& clientName)
}
}
-void DeviceControlPanel::addStelDevice(const QString& id)
+void DeviceControlPanel::addStelDevice(const QString& id,
+ const TelescopeClientP& device)
{
qDebug() << "DeviceControlPanel::addStelDevice:" << id;
- if (id.isEmpty())
+ if (id.isEmpty() || device.isNull())
return;
Q_ASSERT(deviceTabWidget);
@@ -236,8 +241,24 @@ void DeviceControlPanel::addStelDevice(const QString& id)
emit visibleChanged(true);//StelDialog doesn't do this
}
- StelDeviceWidget* deviceWidget = new StelDeviceWidget(deviceManager,
- id, deviceTabWidget);
+ QWidget* deviceWidget;
+#ifdef _WIN32
+ TelescopeClientAscomP ascom = device.dynamicCast<TelescopeClientAscom>();
+ if (ascom)
+ {
+ deviceWidget = new AscomDeviceWidget(deviceManager,
+ id,
+ ascom,
+ deviceTabWidget);
+ }
+ else
+#endif
+ {
+ deviceWidget = new StelDeviceWidget(deviceManager,
+ id,
+ device,
+ deviceTabWidget);
+ }
// TODO: Use the proper display name instead of the ID?
deviceTabWidget->addTab(deviceWidget, id);
diff --git a/plugins/TelescopeControl/src/gui/DeviceControlPanel.hpp b/plugins/TelescopeControl/src/gui/DeviceControlPanel.hpp
index de0b6edfbc..6c3971d068 100644
--- a/plugins/TelescopeControl/src/gui/DeviceControlPanel.hpp
+++ b/plugins/TelescopeControl/src/gui/DeviceControlPanel.hpp
@@ -31,9 +31,13 @@
#include "IndiDevice.hpp"
#include "IndiProperty.hpp"
+#include "TelescopeClient.hpp"
class Ui_deviceControlPanelWidget;
class IndiClient;
+#ifdef _WIN32
+class AscomDeviceWidget;
+#endif
class IndiDeviceWidget;
class StelDeviceWidget;
class TelescopeControl;
@@ -62,7 +66,11 @@ public slots:
//! Removes the client and all associated tabs (devices and properties).
void removeIndiClient(const QString& clientName);
- void addStelDevice(const QString& id);
+ //! Add a widget for a Stellarium native or ASCOM device.
+ //! @todo It will be a lot of fun when I have to implement support for
+ //! ASCOM devices other than telescopes.
+ void addStelDevice(const QString& id, const TelescopeClientP& device);
+ //! @todo Separate device ID from display name!
void removeStelDevice(const QString& id);
//!
diff --git a/plugins/TelescopeControl/src/gui/StelDeviceWidget.cpp b/plugins/TelescopeControl/src/gui/StelDeviceWidget.cpp
index 8ef4b5e15c..885789041a 100644
--- a/plugins/TelescopeControl/src/gui/StelDeviceWidget.cpp
+++ b/plugins/TelescopeControl/src/gui/StelDeviceWidget.cpp
@@ -38,20 +38,26 @@
using namespace TelescopeControlGlobals;
StelDeviceWidget::StelDeviceWidget(TelescopeControl *plugin,
- const QString &id, QWidget *parent) :
+ const QString &id,
+ const TelescopeClientP& telescope,
+ QWidget *parent) :
QWidget(parent),
clientId(id)
{
Q_ASSERT(plugin);
deviceManager = plugin;
+ Q_ASSERT(telescope);
+ client = telescope;
+
ui = new Ui_StelDeviceWidget;
ui->setupUi(this);
coordsWidget = new CoordinatesWidget(this);
ui->verticalLayout->addWidget(coordsWidget);
+ coordsWidget->abortButton->setHidden(true);
+ coordsWidget->syncButton->setHidden(true);
- TelescopeClientP telescope = deviceManager->getTelescope(id);
fcWidget = new FovCirclesWidget(telescope.data(), this);
ui->verticalLayout->addWidget(fcWidget);
@@ -59,6 +65,8 @@ StelDeviceWidget::StelDeviceWidget(TelescopeControl *plugin,
connect(&StelApp::getInstance(), SIGNAL(languageChanged()),
this, SLOT(retranslate()));
+ // TODO: Find out if there's a way to reuse this code in
+ // CoordinatesWidget or somewhere else.
connect(coordsWidget->slewCoordsButton, SIGNAL(clicked()),
this, SLOT(slewToCoords()));
connect(coordsWidget->slewCenterButton, SIGNAL(clicked()),
diff --git a/plugins/TelescopeControl/src/gui/StelDeviceWidget.hpp b/plugins/TelescopeControl/src/gui/StelDeviceWidget.hpp
index 322cbc403d..d654c16062 100644
--- a/plugins/TelescopeControl/src/gui/StelDeviceWidget.hpp
+++ b/plugins/TelescopeControl/src/gui/StelDeviceWidget.hpp
@@ -25,16 +25,16 @@
#include <QString>
#include <QStringList>
#include <QWidget>
-#include "StelStyle.hpp"
+
+#include "TelescopeClient.hpp"
class Ui_StelDeviceWidget;
-#include "StelObjectMgr.hpp"
class CoordinatesWidget;
class FovCirclesWidget;
class TelescopeControl;
-//! Control panel tab representing a TelescopeClient object.
+//! Control panel tab representing a device controlled natively by Stellarium.
//! \ingroup plugin-devicecontrol
class StelDeviceWidget : public QWidget
{
@@ -42,6 +42,7 @@ class StelDeviceWidget : public QWidget
public:
StelDeviceWidget(TelescopeControl* plugin,
const QString& id,
+ const TelescopeClientP& telescope,
QWidget* parent = 0);
virtual ~StelDeviceWidget();
@@ -65,6 +66,8 @@ private:
//! Identifier of the controlled client.
QString clientId;
+ TelescopeClientP client;
+
Ui_StelDeviceWidget* ui;
FovCirclesWidget* fcWidget;
CoordinatesWidget* coordsWidget;