-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathTouchOffDialog.qml
More file actions
105 lines (96 loc) · 3.6 KB
/
Copy pathTouchOffDialog.qml
File metadata and controls
105 lines (96 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/****************************************************************************
**
** Copyright (C) 2014 Alexander Rössler
** License: LGPL version 2.1
**
** This file is part of QtQuickVcp.
**
** All rights reserved. This program and the accompanying materials
** are made available under the terms of the GNU Lesser General Public License
** (LGPL) version 2.1 which accompanies this distribution, and is available at
** http://www.gnu.org/licenses/lgpl-2.1.html
**
** This library 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
** Lesser General Public License for more details.
**
** Contributors:
** Alexander Rössler @ The Cool Tool GmbH <mail DOT aroessler AT gmail DOT com>
**
****************************************************************************/
import QtQuick 2.0
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.2
import Machinekit.Application 1.0
Dialog {
property alias core: object.core
property alias status: object.status
property alias command: object.command
property alias helper: object.helper
property int axis: 0
property var axisNames: helper.ready ? helper.axisNamesUpper : ["X", "Y", "Z"]
property var _axisNames: helper.ready ? helper.axisNames : ["x", "y", "z"]
property int _index: helper.ready ? helper.axisIndices.indexOf(axis) : 0
property bool _ready: status.synced && command.connected
property bool _done: true
id: dialog
title: qsTr("Touch Off")
standardButtons: StandardButton.Ok | StandardButton.Cancel
modality: Qt.ApplicationModal
onVisibleChanged: {
if (visible) {
_done = false;
coordinateSpin.value = 0.0;
coordinateSystemCombo.currentIndex = status.motion.g5xIndex - 1;
}
}
onAccepted: {
if (_ready && !_done) {
if (status.task.taskMode !== ApplicationStatus.TaskModeMdi) {
command.setTaskMode('execute', ApplicationCommand.TaskModeMdi);
}
var axisName = _axisNames[_index];
var position = status.motion.position[axisName] - status.motion.g92Offset[axisName] - status.io.toolOffset[axisName];
var newOffset = (position - coordinateSpin.value);
var mdi = "G10 L2 P" + (coordinateSystemCombo.currentIndex + 1) + " " + axisNames[_index] + newOffset.toFixed(6);
command.executeMdi('execute', mdi);
}
_done = true;
}
ColumnLayout {
anchors.fill: parent
Label {
text: qsTr("Enter %1 coordinate relative to workpiece:").arg(dialog.axisNames[dialog._index])
}
SpinBox {
id: coordinateSpin
decimals: 4
minimumValue: -9999999
maximumValue: 9999999
}
RowLayout {
Label {
text: qsTr("Coordinate system:")
}
ComboBox {
id: coordinateSystemCombo
model: ListModel {
ListElement { text: "P1 G54" }
ListElement { text: "P2 G55" }
ListElement { text: "P3 G56" }
ListElement { text: "P4 G57" }
ListElement { text: "P5 G58" }
ListElement { text: "P6 G59" }
ListElement { text: "P7 G59.1" }
ListElement { text: "P8 G59.2" }
ListElement { text: "P9 G59.3" }
}
}
}
}
ApplicationObject {
id: object
}
}