Warning, /education/kstars/kstars/kstarslite/qml/indi/modules/MotionControl.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
0002 // SPDX-License-Identifier: GPL-2.0-or-later
0003 
0004 import QtQuick 2.6
0005 import QtQuick.Window 2.2
0006 import QtQuick.Layouts 1.2
0007 import QtQuick.Controls 2.0
0008 import TelescopeLiteEnums 1.0
0009 import "../../constants" 1.0
0010 import "../../modules"
0011 
0012 ColumnLayout {
0013     id: motionCColumn
0014     anchors {
0015         fill: parent
0016         margins: Num.marginsKStab
0017     }
0018     spacing: 5 * Num.dp
0019 
0020     enabled: buttonsEnabled
0021 
0022     property string deviceName
0023     property var telescope: ClientManagerLite.getTelescope()
0024     property bool buttonsEnabled: ClientManagerLite.getTelescope().isConnected()
0025 
0026     Connections {
0027         target: ClientManagerLite
0028         onDeviceConnected: {
0029             buttonsEnabled = ClientManagerLite.getTelescope().isConnected()
0030         }
0031         onTelescopeAdded: {
0032             telescope = newTelescope
0033         }
0034     }
0035 
0036     //Row 1
0037     RowLayout {
0038         Layout.fillHeight: true
0039         anchors {
0040             left: parent.left
0041             right: parent.right
0042         }
0043 
0044         Button {
0045             Layout.fillHeight: true
0046             Layout.fillWidth: true
0047             activeFocusOnTab: false
0048 
0049 
0050             onPressedChanged: {
0051                 if(telescope) {
0052                     if(pressed) {
0053                         telescope.moveNS(TelescopeNS.MOTION_NORTH, TelescopeCommand.MOTION_START)
0054                         telescope.moveWE(TelescopeNS.MOTION_WEST, TelescopeCommand.MOTION_START)
0055                     } else {
0056                         telescope.moveNS(TelescopeNS.MOTION_NORTH, TelescopeCommand.MOTION_STOP)
0057                         telescope.moveWE(TelescopeNS.MOTION_WEST, TelescopeCommand.MOTION_STOP)
0058                     }
0059                 }
0060             }
0061 
0062             text: xi18n("NW")
0063         }
0064 
0065         Button {
0066             Layout.fillHeight: true
0067             Layout.fillWidth: true
0068             activeFocusOnTab: false
0069 
0070 
0071             onPressedChanged: {
0072 
0073                 if(telescope) {
0074                     if(pressed) {
0075                         telescope.moveNS(TelescopeNS.MOTION_NORTH, TelescopeCommand.MOTION_START)
0076                     } else {
0077                         telescope.moveNS(TelescopeNS.MOTION_NORTH, TelescopeCommand.MOTION_STOP)
0078                     }
0079                 }
0080             }
0081 
0082             text: xi18n("N")
0083         }
0084 
0085         Button {
0086             Layout.fillHeight: true
0087             Layout.fillWidth: true
0088             activeFocusOnTab: false
0089 
0090 
0091             onPressedChanged: {
0092 
0093                 if(telescope) {
0094                     if(pressed) {
0095                         telescope.moveNS(TelescopeNS.MOTION_NORTH, TelescopeCommand.MOTION_START)
0096                         telescope.moveWE(TelescopeNS.MOTION_EAST, TelescopeCommand.MOTION_START)
0097                     } else {
0098                         telescope.moveNS(TelescopeNS.MOTION_NORTH, TelescopeCommand.MOTION_STOP)
0099                         telescope.moveWE(TelescopeNS.MOTION_EAST, TelescopeCommand.MOTION_STOP)
0100                     }
0101                 }
0102             }
0103 
0104             text: xi18n("NE")
0105         }
0106     }
0107 
0108     //Row 2
0109     RowLayout {
0110         Layout.fillHeight: true
0111         Layout.fillWidth: true
0112 
0113         Button {
0114             Layout.fillHeight: true
0115             Layout.fillWidth: true
0116             activeFocusOnTab: false
0117 
0118 
0119             onPressedChanged: {
0120 
0121                 if(telescope) {
0122                     if(pressed) {
0123                         telescope.moveWE(TelescopeNS.MOTION_WEST, TelescopeCommand.MOTION_START)
0124                     } else {
0125                         telescope.moveWE(TelescopeNS.MOTION_WEST, TelescopeCommand.MOTION_STOP)
0126                     }
0127                 }
0128             }
0129 
0130             text: xi18n("W")
0131         }
0132 
0133         Button {
0134             Layout.fillHeight: true
0135             Layout.fillWidth: true
0136             activeFocusOnTab: false
0137 
0138 
0139             onPressedChanged: {
0140 
0141                 if(telescope) {
0142                     telescope.abort();
0143                 }
0144             }
0145 
0146             text: xi18n("Stop")
0147         }
0148 
0149         Button {
0150             Layout.fillHeight: true
0151             Layout.fillWidth: true
0152             activeFocusOnTab: false
0153 
0154 
0155             onPressedChanged: {
0156 
0157                 if(telescope) {
0158                     if(pressed) {
0159                         telescope.moveWE(TelescopeNS.MOTION_EAST, TelescopeCommand.MOTION_START)
0160                     } else {
0161                         telescope.moveWE(TelescopeNS.MOTION_EAST, TelescopeCommand.MOTION_STOP)
0162                     }
0163                 }
0164             }
0165 
0166             text: xi18n("E")
0167         }
0168     }
0169 
0170     //Row 3
0171     RowLayout {
0172         Layout.fillHeight: true
0173         Layout.fillWidth: true
0174 
0175         Button {
0176             Layout.fillHeight: true
0177             Layout.fillWidth: true
0178             activeFocusOnTab: false
0179             onPressedChanged: {
0180 
0181                 if(telescope) {
0182                     if(pressed) {
0183                         telescope.moveNS(TelescopeNS.MOTION_SOUTH, TelescopeCommand.MOTION_START)
0184                         telescope.moveWE(TelescopeNS.MOTION_WEST, TelescopeCommand.MOTION_START)
0185                     } else {
0186                         telescope.moveNS(TelescopeNS.MOTION_SOUTH, TelescopeCommand.MOTION_STOP)
0187                         telescope.moveWE(TelescopeNS.MOTION_WEST, TelescopeCommand.MOTION_STOP)
0188                     }
0189                 }
0190             }
0191 
0192             text: xi18n("SW")
0193         }
0194 
0195         Button {
0196             Layout.fillHeight: true
0197             Layout.fillWidth: true
0198             activeFocusOnTab: false
0199 
0200 
0201             text: xi18n("S")
0202 
0203             onPressedChanged: {
0204 
0205                 if(telescope) {
0206                     if(pressed) {
0207                         telescope.moveNS(TelescopeNS.MOTION_SOUTH, TelescopeCommand.MOTION_START)
0208                     } else {
0209                         telescope.moveNS(TelescopeNS.MOTION_SOUTH, TelescopeCommand.MOTION_STOP)
0210                     }
0211                 }
0212             }
0213         }
0214 
0215         Button {
0216             Layout.fillHeight: true
0217             Layout.fillWidth: true
0218             activeFocusOnTab: false
0219 
0220 
0221             onPressedChanged: {
0222 
0223                 if(telescope) {
0224                     if(pressed) {
0225                         telescope.moveNS(TelescopeNS.MOTION_SOUTH, TelescopeCommand.MOTION_START)
0226                         telescope.moveWE(TelescopeNS.MOTION_EAST, TelescopeCommand.MOTION_START)
0227                     } else {
0228                         telescope.moveNS(TelescopeNS.MOTION_SOUTH, TelescopeCommand.MOTION_STOP)
0229                         telescope.moveWE(TelescopeNS.MOTION_EAST, TelescopeCommand.MOTION_STOP)
0230                     }
0231                 }
0232             }
0233 
0234             text: xi18n("SE")
0235         }
0236     }
0237 
0238     //Slewing
0239     RowLayout {
0240         id: slewingRateRow
0241         Layout.fillHeight: true
0242         Layout.fillWidth: true
0243 
0244         Button {
0245             id: decreaseSlew
0246             height: motionCColumn.height * 0.15
0247             Layout.fillWidth: true
0248             activeFocusOnTab: false
0249             enabled: telescope.slewDecreasable
0250 
0251             Connections {
0252                 target: telescope
0253                 onSlewDecreasableChanged: {
0254                     decreaseSlew.enabled = telescope.slewDecreasable
0255                 }
0256             }
0257 
0258             onClicked: {
0259                 if(telescope) {
0260                     telescope.decreaseSlewRate()
0261                 }
0262             }
0263 
0264             text: xi18n("-")
0265         }
0266         KSText {
0267             height: parent.height * 0.15
0268             Layout.fillWidth: true
0269             horizontalAlignment: Text.AlignHCenter
0270 
0271             text: xi18n("Slew rate: " + telescope.slewRateLabel)
0272         }
0273 
0274         Button {
0275             id: increaseSlew
0276             height: motionCColumn.height * 0.15
0277             Layout.fillWidth: true
0278             activeFocusOnTab: false
0279             enabled: telescope.slewIncreasable
0280 
0281             Connections {
0282                 target: telescope
0283                 onSlewIncreasableChanged: {
0284                     increaseSlew.enabled = telescope.slewIncreasable
0285                 }
0286             }
0287 
0288             onClicked: {
0289                 if(telescope) {
0290                     telescope.increaseSlewRate()
0291                 }
0292             }
0293 
0294             text: xi18n("+")
0295         }
0296     }
0297 }