Index: kstars/kstars.h =================================================================== --- kstars/kstars.h +++ kstars/kstars.h @@ -574,11 +574,28 @@ /** action slot: open Ekos panel */ void slotEkos(); + /** action slot: Track with the telescope (INDI) */ + void slotINDITelescopeTrack(); + + /** action slot: Slew with the telescope (INDI) */ + void slotINDITelescopeSlew(); + + /** action slot: Sync the telescope (INDI) */ + void slotINDITelescopeSync(); + + /** action slot: Abort any telescope motion (INDI) */ + void slotINDITelescopeAbort(); + + /** action slot: Park the telescope (INDI) */ + void slotINDITelescopePark(); + + /** action slot: Unpark the telescope (INDI) */ + void slotINDITelescopeUnpark(); + /** action slot: open dialog for setting the view options */ void slotViewOps(); - /** finish setting up after the kstarsData has finished - */ + /** finish setting up after the kstarsData has finished */ void datainitFinished(); /** Open FITS image. */ Index: kstars/kstarsactions.cpp =================================================================== --- kstars/kstarsactions.cpp +++ kstars/kstarsactions.cpp @@ -726,6 +726,132 @@ #endif } +void KStars::slotINDITelescopeTrack() +{ +#ifdef HAVE_INDI + if (m_KStarsData == nullptr || INDIListener::Instance() == nullptr) + return; + + for (auto *gd : INDIListener::Instance()->getDevices()) + { + ISD::Telescope* telescope = dynamic_cast(gd); + + if (telescope != nullptr && telescope->isConnected()) + { + ISD::GDSetCommand SlewCMD(INDI_SWITCH, "ON_COORD_SET", "TRACK", ISS_ON, this); + + gd->setProperty(&SlewCMD); + + gd->runCommand(INDI_SEND_COORDS, m_SkyMap->mousePoint()); + return; + } + } +#endif +} + +void KStars::slotINDITelescopeSlew() +{ +#ifdef HAVE_INDI + if (m_KStarsData == nullptr || INDIListener::Instance() == nullptr) + return; + + for (auto *gd : INDIListener::Instance()->getDevices()) + { + ISD::Telescope* telescope = dynamic_cast(gd); + + if (telescope != nullptr && telescope->isConnected()) + { + ISD::GDSetCommand SlewCMD(INDI_SWITCH, "ON_COORD_SET", "SLEW", ISS_ON, this); + + gd->setProperty(&SlewCMD); + + gd->runCommand(INDI_SEND_COORDS, m_SkyMap->mousePoint()); + return; + } + } +#endif +} + +void KStars::slotINDITelescopeSync() +{ +#ifdef HAVE_INDI + if (m_KStarsData == nullptr || INDIListener::Instance() == nullptr) + return; + + for (auto *gd : INDIListener::Instance()->getDevices()) + { + ISD::Telescope* telescope = dynamic_cast(gd); + + if (telescope != nullptr && telescope->isConnected() && telescope->canSync()) + { + ISD::GDSetCommand SlewCMD(INDI_SWITCH, "ON_COORD_SET", "SYNC", ISS_ON, this); + + gd->setProperty(&SlewCMD); + + gd->runCommand(INDI_SEND_COORDS, m_SkyMap->mousePoint()); + return; + } + } +#endif +} + +void KStars::slotINDITelescopeAbort() +{ +#ifdef HAVE_INDI + if (m_KStarsData == nullptr || INDIListener::Instance() == nullptr) + return; + + for (auto *gd : INDIListener::Instance()->getDevices()) + { + ISD::Telescope* telescope = dynamic_cast(gd); + + if (telescope != nullptr && telescope->isConnected()) + { + telescope->Abort(); + return; + } + } +#endif +} + +void KStars::slotINDITelescopePark() +{ +#ifdef HAVE_INDI + if (m_KStarsData == nullptr || INDIListener::Instance() == nullptr) + return; + + for (auto *gd : INDIListener::Instance()->getDevices()) + { + ISD::Telescope* telescope = dynamic_cast(gd); + + if (telescope != nullptr && telescope->isConnected() && telescope->canPark()) + { + telescope->Park(); + return; + } + } +#endif +} + +void KStars::slotINDITelescopeUnpark() +{ +#ifdef HAVE_INDI + if (m_KStarsData == nullptr || INDIListener::Instance() == nullptr) + return; + + for (auto *gd : INDIListener::Instance()->getDevices()) + { + ISD::Telescope* telescope = dynamic_cast(gd); + + if (telescope != nullptr && telescope->isConnected() && telescope->canPark()) + { + telescope->UnPark(); + return; + } + } +#endif +} + void KStars::slotGeoLocator() { QPointer locationdialog = new LocationDialog(this); Index: kstars/kstarsinit.cpp =================================================================== --- kstars/kstarsinit.cpp +++ kstars/kstarsinit.cpp @@ -565,6 +565,21 @@ << QIcon::fromTheme("center_telescope", QIcon(":/icons/center_telescope.svg")) << ToolTip(i18n("Toggle Lock Telescope Center")); ka->setEnabled(false); + + ka = actionCollection()->addAction("telescope_track", this, SLOT(slotINDITelescopeTrack())) + << i18n("Track with the telescope (INDI)") << QKeySequence(Qt::META + Qt::Key_T); + ka = actionCollection()->addAction("telescope_slew", this, SLOT(slotINDITelescopeSlew())) + << i18n("Slew with the telescope (INDI)") << QKeySequence(Qt::META + Qt::Key_S); + ka = actionCollection()->addAction("telescope_sync", this, SLOT(slotINDITelescopeSync())) + << i18n("Sync with the telescope (INDI)") << QKeySequence(Qt::META + Qt::Key_Y); + ka = actionCollection()->addAction("telescope_abort", this, SLOT(slotINDITelescopeAbort())) + << i18n("Abort any telescope motion (INDI)") << QKeySequence(Qt::META + Qt::Key_A); + ka->setShortcutContext(Qt::ApplicationShortcut); + ka = actionCollection()->addAction("telescope_park", this, SLOT(slotINDITelescopePark())) + << i18n("Park the telescope (INDI)") << QKeySequence(Qt::META + Qt::Key_P); + ka = actionCollection()->addAction("telescope_unpark", this, SLOT(slotINDITelescopeUnpark())) + << i18n("Unpark the telescope (INDI)") << QKeySequence(Qt::META + Qt::Key_U); + ka->setShortcutContext(Qt::ApplicationShortcut); #endif } Index: kstars/skymap.h =================================================================== --- kstars/skymap.h +++ kstars/skymap.h @@ -196,6 +196,13 @@ */ SkyPoint *clickedPoint() { return &ClickedPoint; } + /** + * @short Retrieve the mouse pointer position. + * + * @return The sky coordinates where the mouse pointer is over. + */ + SkyPoint *mousePoint() { return &m_MousePoint; } + /** @short Set the ClickedPoint to the skypoint given as an argument. *@param f pointer to the new ClickedPoint. */