Commit 5b4cd028 authored by Jasem Mutlaq's avatar Jasem Mutlaq

+ New mount tool box is ready for use. Probably the GUI needs some more theming to look pretty

+ N/S/W/E motion state is now recognized by the telescope class and advertised as such along with direction.
parent 04367f0b
......@@ -4785,6 +4785,7 @@ void Align::setMountStatus(ISD::Telescope::TelescopeStatus newState)
{
case ISD::Telescope::MOUNT_PARKING:
case ISD::Telescope::MOUNT_SLEWING:
case ISD::Telescope::MOUNT_MOVING:
solveB->setEnabled(false);
loadSlewB->setEnabled(false);
PAHFirstCaptureB->setEnabled(false);
......
......@@ -4257,6 +4257,7 @@ void Capture::setMountStatus(ISD::Telescope::TelescopeStatus newState)
{
case ISD::Telescope::MOUNT_PARKING:
case ISD::Telescope::MOUNT_SLEWING:
case ISD::Telescope::MOUNT_MOVING:
previewB->setEnabled(false);
liveVideoB->setEnabled(false);
// Only disable when button is "Start", and not "Stopped"
......
......@@ -2046,12 +2046,13 @@ void EkosManager::updateMountStatus(ISD::Telescope::TelescopeStatus status)
lastStatus = status;
mountStatus->setText(ISD::Telescope::getStatusString(status));
mountStatus->setText(dynamic_cast<ISD::Telescope*>(managedDevices[KSTARS_TELESCOPE])->getStatusString(status));
switch (status)
{
case ISD::Telescope::MOUNT_PARKING:
case ISD::Telescope::MOUNT_SLEWING:
case ISD::Telescope::MOUNT_MOVING:
mountPI->setColor(QColor( KStarsData::Instance()->colorScheme()->colorNamed("TargetColor" )));
if (mountPI->isAnimated() == false)
mountPI->startAnimation();
......
......@@ -2702,6 +2702,7 @@ void Focus::setMountStatus(ISD::Telescope::TelescopeStatus newState)
{
case ISD::Telescope::MOUNT_PARKING:
case ISD::Telescope::MOUNT_SLEWING:
case ISD::Telescope::MOUNT_MOVING:
captureB->setEnabled(false);
startFocusB->setEnabled(false);
startLoopB->setEnabled(false);
......
......@@ -1126,6 +1126,7 @@ void Guide::setMountStatus(ISD::Telescope::TelescopeStatus newState)
{
case ISD::Telescope::MOUNT_SLEWING:
case ISD::Telescope::MOUNT_PARKING:
case ISD::Telescope::MOUNT_MOVING:
captureB->setEnabled(false);
calibrateB->setEnabled(false);
if (newState == ISD::Telescope::MOUNT_PARKING)
......
......@@ -27,6 +27,7 @@
#include "kstars.h"
#include "kspaths.h"
#include "dialogs/finddialog.h"
#include "kstarsdata.h"
#include "ksutils.h"
......@@ -143,6 +144,12 @@ Mount::Mount()
m_altValue = m_BaseObj->findChild<QQuickItem *>("altValueObject");
m_haValue = m_BaseObj->findChild<QQuickItem *>("haValueObject");
m_zaValue = m_BaseObj->findChild<QQuickItem *>("zaValueObject");
m_targetText = m_BaseObj->findChild<QQuickItem *>("targetTextObject");
m_targetRAText = m_BaseObj->findChild<QQuickItem *>("targetRATextObject");
m_targetDEText = m_BaseObj->findChild<QQuickItem *>("targetDETextObject");
m_Park = m_BaseObj->findChild<QQuickItem *>("parkButtonObject");
m_Unpark = m_BaseObj->findChild<QQuickItem *>("unparkButtonObject");
m_statusText = m_BaseObj->findChild<QQuickItem *>("statusTextObject");
}
......@@ -240,6 +247,10 @@ void Mount::syncTelescopeInfo()
unparkB->setEnabled(currentTelescope->isParked());
connect(parkB, SIGNAL(clicked()), currentTelescope, SLOT(Park()), Qt::UniqueConnection);
connect(unparkB, SIGNAL(clicked()), currentTelescope, SLOT(UnPark()), Qt::UniqueConnection);
// QtQuick
m_Park->setEnabled(true);
m_Unpark->setEnabled(true);
}
else
{
......@@ -247,6 +258,10 @@ void Mount::syncTelescopeInfo()
unparkB->setEnabled(false);
disconnect(parkB, SIGNAL(clicked()), currentTelescope, SLOT(Park()));
disconnect(unparkB, SIGNAL(clicked()), currentTelescope, SLOT(UnPark()));
// QtQuick
m_Park->setEnabled(false);
m_Unpark->setEnabled(false);
}
}
......@@ -329,6 +344,12 @@ void Mount::updateTelescopeCoords()
lastStatus = currentStatus;
parkB->setEnabled(!currentTelescope->isParked());
unparkB->setEnabled(currentTelescope->isParked());
m_Park->setEnabled(!currentTelescope->isParked());
m_Unpark->setEnabled(currentTelescope->isParked());
m_statusText->setProperty("text", currentTelescope->getStatusString(currentStatus));
emit newStatus(lastStatus);
}
......@@ -644,6 +665,16 @@ bool Mount::isLimitsEnabled()
return enableLimitsCheck->isChecked();
}
bool Mount::slew(const QString &RA, const QString &DEC)
{
dms ra, de;
ra = dms::fromString(RA, false);
de = dms::fromString(DEC, true);
return slew(ra.Hours(), de.Degrees());
}
bool Mount::slew(double RA, double DEC)
{
if (currentTelescope == NULL || currentTelescope->isConnected() == false)
......@@ -652,6 +683,16 @@ bool Mount::slew(double RA, double DEC)
return currentTelescope->Slew(RA, DEC);
}
bool Mount::sync(const QString &RA, const QString &DEC)
{
dms ra, de;
ra = dms::fromString(RA, false);
de = dms::fromString(DEC, true);
return sync(ra.Hours(), de.Degrees());
}
bool Mount::sync(double RA, double DEC)
{
if (currentTelescope == NULL || currentTelescope->isConnected() == false)
......@@ -791,4 +832,26 @@ void Mount::showMountToolBox()
m_BaseView->show();
}
void Mount::findTarget()
{
KStarsData * data = KStarsData::Instance();
QPointer<FindDialog> fd = new FindDialog( KStars::Instance() );
if ( fd->exec() == QDialog::Accepted )
{
SkyObject * object = fd->targetObject();
if( object != 0 )
{
SkyObject * o = object->clone();
o->updateCoords( data->updateNum(), true, data->geo()->lat(), data->lst(), false );
m_targetText->setProperty("text", o->name());
m_targetRAText->setProperty("text", o->ra().toHMSString());
m_targetDEText->setProperty("text", o->dec().toDMSString());
}
}
delete fd;
}
}
......@@ -87,6 +87,11 @@ class Mount : public QWidget, public Ui::Mount
*/
Q_INVOKABLE Q_SCRIPTABLE bool slew(double RA, double DEC);
/**
@brief Like above but RA and DEC are strings HH:MM:SS and DD:MM:SS
*/
Q_INVOKABLE bool slew(const QString &RA, const QString &DEC);
/** DBUS interface function.
* Sync the mount to the RA/DEC (JNow).
* @param RA Right ascention is hours.
......@@ -95,6 +100,11 @@ class Mount : public QWidget, public Ui::Mount
*/
Q_INVOKABLE Q_SCRIPTABLE bool sync(double RA, double DEC);
/**
@brief Like above but RA and DEC are strings HH:MM:SS and DD:MM:SS
*/
Q_INVOKABLE bool sync(const QString &RA, const QString &DEC);
/** DBUS interface function.
* Get equatorial coords (JNow). An array of doubles is returned. First element is RA in hours. Second elements is DEC in degrees.
*/
......@@ -160,6 +170,8 @@ class Mount : public QWidget, public Ui::Mount
/** @}*/
Q_INVOKABLE void findTarget();
public slots:
/**
......@@ -259,8 +271,9 @@ class Mount : public QWidget, public Ui::Mount
QQuickItem * m_BaseObj=nullptr;
QQmlContext * m_Ctxt=nullptr;
QQuickItem * m_SpeedSlider=nullptr, *m_SpeedLabel=nullptr, *m_raValue=nullptr, *m_deValue=nullptr,
*m_azValue=nullptr, *m_altValue=nullptr, *m_haValue=nullptr, *m_zaValue=nullptr;
QQuickItem *m_SpeedSlider=nullptr, *m_SpeedLabel=nullptr, *m_raValue=nullptr, *m_deValue=nullptr,
*m_azValue=nullptr, *m_altValue=nullptr, *m_haValue=nullptr, *m_zaValue=nullptr, *m_targetText=nullptr,
*m_targetRAText=nullptr, *m_targetDEText=nullptr, *m_Park=nullptr, *m_Unpark=nullptr, *m_statusText=nullptr;
};
......
......@@ -9,6 +9,7 @@ Rectangle {
color: "#000000"
property color buttonColor: "gainsboro"
property color coordsColor: "gold"
ColumnLayout {
id: mainVerticalLayout
......@@ -356,12 +357,15 @@ Rectangle {
Layout.fillWidth: true
rows: 2
columns: 4
property int coordsLabelSize: 10
property int coordsValueSize: 11
Label {
id: raLabel
text: qsTr("RA:")
font.bold: true
font.pointSize: 12
font.pointSize: parent.coordsLabelSize
color: "white"
}
......@@ -369,9 +373,9 @@ Rectangle {
id: raValue
objectName: "raValueObject"
width: 50
color: "#ffffff"
color: coordsColor
text: "00:00:00"
font.pointSize: 12
font.pointSize: parent.coordsValueSize
font.bold: true
}
......@@ -379,7 +383,7 @@ Rectangle {
id: azLabel
color: "#ffffff"
text: qsTr("AZ:")
font.pointSize: 12
font.pointSize: parent.coordsLabelSize
font.bold: true
}
......@@ -387,9 +391,9 @@ Rectangle {
id: azValue
objectName: "azValueObject"
width: 50
color: "#ffffff"
color: coordsColor
text: "00:00:00"
font.pointSize: 12
font.pointSize: parent.coordsValueSize
font.bold: true
}
......@@ -397,7 +401,7 @@ Rectangle {
id: deLabel
color: "#ffffff"
text: qsTr("DE:")
font.pointSize: 12
font.pointSize: parent.coordsLabelSize
font.bold: true
}
......@@ -405,9 +409,9 @@ Rectangle {
id: deValue
objectName: "deValueObject"
width: 50
color: "#ffffff"
color: coordsColor
text: "00:00:00"
font.pointSize: 12
font.pointSize: parent.coordsValueSize
font.bold: true
}
......@@ -415,7 +419,7 @@ Rectangle {
id: altLabel
color: "#ffffff"
text: qsTr("AL:")
font.pointSize: 12
font.pointSize: parent.coordsLabelSize
font.bold: true
}
......@@ -423,9 +427,9 @@ Rectangle {
id: altValue
objectName: "altValueObject"
width: 50
color: "#ffffff"
color: coordsColor
text: "00:00:00"
font.pointSize: 12
font.pointSize: parent.coordsValueSize
font.bold: true
}
......@@ -433,7 +437,7 @@ Rectangle {
id: haLabel
color: "#ffffff"
text: qsTr("HA:")
font.pointSize: 12
font.pointSize: parent.coordsLabelSize
font.bold: true
}
......@@ -441,9 +445,9 @@ Rectangle {
id: haValue
objectName: "haValueObject"
width: 50
color: "#ffffff"
color: coordsColor
text: "00:00:00"
font.pointSize: 12
font.pointSize: parent.coordsValueSize
font.bold: true
}
......@@ -452,7 +456,7 @@ Rectangle {
id: zaLabel
color: "#ffffff"
text: qsTr("ZA:")
font.pointSize: 12
font.pointSize: parent.coordsLabelSize
font.bold: true
}
......@@ -460,9 +464,9 @@ Rectangle {
id: zaValue
objectName: "zaValueObject"
width: 50
color: "#ffffff"
color: coordsColor
text: "00:00:00"
font.pointSize: 12
font.pointSize: parent.coordsValueSize
font.bold: true
}
......@@ -491,8 +495,15 @@ Rectangle {
Label {
id: targetText
objectName: "targetTextObject"
color: "#ffffff"
text: ""
background: Rectangle
{
color: "black"
border.color : "yellow"
border.width : 1
}
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
Layout.fillHeight: true
......@@ -506,11 +517,21 @@ Rectangle {
id: findButton
width: 32
height: 32
text: qsTr("Find")
Layout.maximumHeight: 32
Layout.minimumHeight: 32
Layout.minimumWidth: 32
Layout.maximumWidth: 32
Image {
id: image
anchors.fill: parent
source: "qrc:/icons/breeze/default/view-history.svg"
}
onClicked:
{
mount.findTarget()
}
}
}
......@@ -533,6 +554,8 @@ Rectangle {
TextField {
id: targetRAText
objectName: "targetRATextObject"
placeholderText: "HH:MM:SS"
width: 150
Layout.minimumHeight: 30
Layout.maximumHeight: 30
......@@ -550,6 +573,8 @@ Rectangle {
TextField {
id: targetDEText
objectName: "targetDETextObject"
placeholderText: "DD:MM:SS"
width: 150
height: 30
Layout.maximumHeight: 30
......@@ -576,24 +601,46 @@ Rectangle {
id: gotoButton
text: qsTr("GOTO")
Layout.fillWidth: true
onClicked:
{
mount.slew(targetRAText.text, targetDEText.text)
}
}
Button {
id: syncButton
text: qsTr("SYNC")
Layout.fillWidth: true
onClicked:
{
mount.sync(targetRAText.text, targetDEText.text)
}
}
Button {
id: parkButton
objectName: "parkButtonObject"
text: qsTr("PARK")
Layout.fillWidth: true
onClicked:
{
mount.park()
}
}
Button {
id: unparkButton
objectName: "unparkButtonObject"
text: qsTr("UNPARK")
Layout.fillWidth: true
onClicked:
{
mount.unpark()
}
}
}
......@@ -613,12 +660,12 @@ Rectangle {
Label {
id: statusText
objectName: "statusTextObject"
color: "#ffffff"
text: qsTr("Idle")
font.pointSize: 12
font.bold: true
}
}
}
}
......@@ -164,7 +164,10 @@ void Telescope::processNumber(INumberVectorProperty * nvp)
}
void Telescope::processSwitch(ISwitchVectorProperty * svp)
{
{
bool manualMotionChanged=false;
if (!strcmp(svp->name, "TELESCOPE_PARK"))
{
ISwitch * sp = IUFindSwitch(svp, "PARK");
......@@ -213,6 +216,40 @@ void Telescope::processSwitch(ISwitchVectorProperty * svp)
KNotification::event( QLatin1String( "MountAborted" ) , i18n("Mount motion was aborted"));
}
}
else if (!strcmp(svp->name, "TELESCOPE_MOTION_NS"))
manualMotionChanged = true;
else if (!strcmp(svp->name, "TELESCOPE_MOTION_WE"))
manualMotionChanged = true;
if (manualMotionChanged)
{
IPState NSCurrentMotion, WECurrentMotion;
NSCurrentMotion = baseDevice->getSwitch("TELESCOPE_MOTION_NS")->s;
WECurrentMotion = baseDevice->getSwitch("TELESCOPE_MOTION_WE")->s;
if (NSCurrentMotion == IPS_BUSY || WECurrentMotion == IPS_BUSY || NSPreviousState == IPS_BUSY || WEPreviousState == IPS_BUSY)
{
if (inManualMotion == false &&
((NSCurrentMotion == IPS_BUSY && NSPreviousState != IPS_BUSY) ||
(WECurrentMotion == IPS_BUSY && WEPreviousState != IPS_BUSY)))
{
inManualMotion = true;
KNotification::event( QLatin1String( "MotionStarted" ) , i18n("Mount is manually moving"));
}
else if (inManualMotion &&
((NSCurrentMotion != IPS_BUSY && NSPreviousState == IPS_BUSY) ||
(WECurrentMotion != IPS_BUSY && WEPreviousState == IPS_BUSY)))
{
inManualMotion = false;
KNotification::event( QLatin1String( "MotionStopped" ) , i18n("Mount is manually moving"));
}
NSPreviousState = NSCurrentMotion;
WEPreviousState = WECurrentMotion;
}
}
DeviceDecorator::processSwitch(svp);
}
......@@ -268,19 +305,7 @@ bool Telescope::isSlewing()
bool Telescope::isInMotion()
{
ISwitchVectorProperty * movementSP(NULL);
bool inMotion=false;
bool inSlew=isSlewing();
movementSP = baseDevice->getSwitch("TELESCOPE_MOTION_NS");
if (movementSP)
inMotion = (movementSP->s == IPS_BUSY);
movementSP = baseDevice->getSwitch("TELESCOPE_MOTION_WE");
if (movementSP)
inMotion = ((movementSP->s == IPS_BUSY) || inMotion);
return (inSlew || inMotion);
return (isSlewing() || inManualMotion);
}
bool Telescope::doPulse(GuideDirection ra_dir, int ra_msecs, GuideDirection dec_dir, int dec_msecs )
......@@ -310,40 +335,40 @@ bool Telescope::doPulse(GuideDirection dir, int msecs )
switch(dir)
{
case RA_INC_DIR:
dirPulse = IUFindNumber(raPulse, "TIMED_GUIDE_W");
if (dirPulse == NULL)
return false;
case RA_INC_DIR:
dirPulse = IUFindNumber(raPulse, "TIMED_GUIDE_W");
if (dirPulse == NULL)
return false;
npulse = raPulse;
break;
npulse = raPulse;
break;
case RA_DEC_DIR:
dirPulse = IUFindNumber(raPulse, "TIMED_GUIDE_E");
if (dirPulse == NULL)
return false;
case RA_DEC_DIR:
dirPulse = IUFindNumber(raPulse, "TIMED_GUIDE_E");
if (dirPulse == NULL)
return false;
npulse = raPulse;
break;
npulse = raPulse;
break;
case DEC_INC_DIR:
dirPulse = IUFindNumber(decPulse, "TIMED_GUIDE_N");
if (dirPulse == NULL)
return false;
case DEC_INC_DIR:
dirPulse = IUFindNumber(decPulse, "TIMED_GUIDE_N");
if (dirPulse == NULL)
return false;
npulse = decPulse;
break;
npulse = decPulse;
break;
case DEC_DEC_DIR:
dirPulse = IUFindNumber(decPulse, "TIMED_GUIDE_S");
if (dirPulse == NULL)
return false;
case DEC_DEC_DIR:
dirPulse = IUFindNumber(decPulse, "TIMED_GUIDE_S");
if (dirPulse == NULL)
return false;
npulse = decPulse;
break;
npulse = decPulse;
break;
default:
return false;
default:
return false;
}
......@@ -367,53 +392,53 @@ bool Telescope::runCommand(int command, void * ptr)
switch (command)
{
case INDI_SEND_COORDS:
if (ptr == NULL)
sendCoords(KStars::Instance()->map()->clickedPoint());
else
sendCoords(static_cast<SkyPoint *> (ptr));
case INDI_SEND_COORDS:
if (ptr == NULL)
sendCoords(KStars::Instance()->map()->clickedPoint());
else
sendCoords(static_cast<SkyPoint *> (ptr));
break;
break;
case INDI_ENGAGE_TRACKING:
{
SkyPoint J2000Coord(currentCoord.ra(), currentCoord.dec());
J2000Coord.apparentCoord(KStars::Instance()->data()->ut().djd(), (long double) J2000);
currentCoord.setRA0(J2000Coord.ra());
currentCoord.setDec0(J2000Coord.dec());
KStars::Instance()->map()->setDestination(currentCoord);
}
break;
case INDI_ENGAGE_TRACKING:
case INDI_CENTER_LOCK:
{
//if (currentObject == NULL || KStars::Instance()->map()->focusObject() != currentObject)
if (Options::isTracking() == false || currentCoord.angularDistanceTo(KStars::Instance()->map()->focus()).Degrees() > 0.5)
{
SkyPoint J2000Coord(currentCoord.ra(), currentCoord.dec());
J2000Coord.apparentCoord(KStars::Instance()->data()->ut().djd(), (long double) J2000);
currentCoord.setRA0(J2000Coord.ra());
currentCoord.setDec0(J2000Coord.dec());
//KStars::Instance()->map()->setClickedPoint(&currentCoord);
//KStars::Instance()->map()->slotCenter();
KStars::Instance()->map()->setDestination(currentCoord);
KStars::Instance()->map()->setFocusPoint(&currentCoord);
//KStars::Instance()->map()->setFocusObject(currentObject);