Warning, /sdk/cutehmi/extensions/CuteHMI/Symbols/HVAC.1/Pump.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 2.0
0002
0003 import CuteHMI.GUI 1.0
0004
0005 /**
0006 Pump.
0007 */
0008 Element {
0009 id: root
0010
0011 implicitWidth: units.quadrat
0012 implicitHeight: units.quadrat
0013
0014 property real implicitRpm: 30
0015
0016 property real rpm: active ? implicitRpm : 0
0017
0018 property Component housing: Component {
0019 SymbolCanvas {
0020 element: root
0021
0022 onPaint: {
0023 var diameter = root.internal.diameter
0024 var innerDiameter = root.internal.innerDiameter
0025
0026 var ctx = getContext('2d')
0027 ctx.save()
0028 ctx.reset()
0029
0030 ctx.strokeStyle = color.tint
0031 ctx.lineWidth = (diameter - innerDiameter) * 0.5
0032 ctx.arc(width * 0.5, height * 0.5, (diameter + innerDiameter) * 0.25, 0.0, 2 * Math.PI, false)
0033 ctx.stroke()
0034 ctx.closePath()
0035
0036 ctx.beginPath()
0037 ctx.strokeStyle = color.stroke
0038 ctx.lineWidth = units.strokeWidth
0039 ctx.arc(width * 0.5, height * 0.5, (diameter - units.strokeWidth) * 0.5, 0.0, 2 * Math.PI, false)
0040 ctx.stroke()
0041
0042 ctx.restore();
0043 }
0044
0045 Connections {
0046 target: root.internal
0047
0048 function onDiameterChanged() {
0049 requestPaint()
0050 }
0051
0052 function onInnerDiameterChanged() {
0053 requestPaint()
0054 }
0055 }
0056 }
0057 }
0058
0059 property Component rotor: Component {
0060 SymbolCanvas {
0061 element: root
0062
0063 onPaint: {
0064 var diameter = root.internal.diameter
0065 var innerDiameter = root.internal.innerDiameter
0066
0067 var ctx = getContext('2d')
0068 ctx.save()
0069 ctx.reset()
0070
0071 ctx.strokeStyle = color.shade
0072 ctx.lineWidth = (diameter - innerDiameter) * 0.5 - units.strokeWidth
0073
0074 // Draw vanes.
0075 var arcR = (diameter + innerDiameter) * 0.25 - units.strokeWidth * 0.5
0076 var angle = Math.PI / 6.0
0077 for (var curAngle = 0; curAngle < 2 * Math.PI; curAngle += 2 * angle) {
0078 ctx.beginPath()
0079 ctx.arc(width * 0.5, height * 0.5, arcR, curAngle, curAngle + angle)
0080 ctx.stroke()
0081 ctx.closePath()
0082 }
0083 ctx.restore();
0084 }
0085
0086 Connections {
0087 target: root
0088
0089 function onRpmChanged() {
0090 handleRotation()
0091 }
0092
0093 function handleRotation() {
0094 rotationAnimation.from = rotation % 360
0095 rotationAnimation.to = rotation % 360 + 360 * Math.ceil(root.rpm)
0096 if (root.rpm)
0097 rotationAnimation.restart()
0098 else
0099 rotationAnimation.stop()
0100 }
0101
0102 Component.onCompleted: handleRotation()
0103 }
0104
0105 Connections {
0106 target: root.internal
0107
0108 function onDiameterChanged() {
0109 requestPaint()
0110 }
0111
0112 function onInnerDiameterChanged() {
0113 requestPaint()
0114 }
0115 }
0116
0117 RotationAnimation on rotation {
0118 id: rotationAnimation
0119
0120 duration: 60000 // 1 min = 60000 ms
0121 loops: Animation.Infinite
0122 }
0123 }
0124 }
0125
0126
0127 property Component symbol: Component {
0128 SymbolCanvas {
0129 element: root
0130
0131 onPaint: {
0132 var diameter = root.internal.diameter
0133 var innerDiameter = root.internal.innerDiameter
0134
0135 var ctx = getContext('2d')
0136 ctx.save()
0137 ctx.reset()
0138
0139 ctx.strokeStyle = color.stroke
0140 ctx.lineWidth = units.strokeWidth
0141
0142 var lineOffset = units.strokeWidth * 0.5
0143 var symbolOffset = (diameter - innerDiameter) * 0.5
0144 var insetDiameter = innerDiameter - units.strokeWidth
0145
0146 ctx.translate(symbolOffset, symbolOffset)
0147
0148 // Draw circle.
0149 ctx.fillStyle = color.blank
0150 ctx.ellipse(lineOffset, lineOffset, insetDiameter, insetDiameter)
0151 ctx.fill()
0152 ctx.stroke()
0153
0154 // Draw inner triangle.
0155 ctx.fillStyle = color.fill
0156 ctx.beginPath();
0157 ctx.moveTo(innerDiameter - lineOffset, innerDiameter * 0.5)
0158 ctx.lineTo(innerDiameter * 0.25 + lineOffset, innerDiameter * ( 2.0 + Math.sqrt(3.0)) * 0.25 - lineOffset)
0159 ctx.lineTo(innerDiameter * 0.25 + lineOffset, innerDiameter * ( 2.0 - Math.sqrt(3.0)) * 0.25 + lineOffset)
0160 ctx.closePath()
0161 ctx.fill()
0162 ctx.stroke()
0163
0164 ctx.restore();
0165 }
0166
0167 Connections {
0168 target: root.internal
0169
0170 function onDiameterChanged() {
0171 requestPaint()
0172 }
0173
0174 function onInnerDiameterChanged() {
0175 requestPaint()
0176 }
0177 }
0178 }
0179 }
0180
0181 property QtObject internal: QtObject {
0182 property real diameter: Math.min(root.width, root.height)
0183 property real innerDiameter: diameter * 0.75
0184 }
0185
0186 Loader {
0187 width: root.width
0188 height: root.height
0189 sourceComponent: housing
0190 }
0191
0192 Loader {
0193 width: root.width
0194 height: root.height
0195 sourceComponent: rotor
0196 }
0197
0198 Loader {
0199 width: root.width
0200 height: root.height
0201 sourceComponent: symbol
0202 }
0203 }
0204
0205 //(c)C: Copyright © 2020-2021, Michał Policht <michal@policht.pl>. All rights reserved.
0206 //(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
0207 //(c)C: This file is a part of CuteHMI.
0208 //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
0209 //(c)C: CuteHMI 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.
0210 //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see <https://www.gnu.org/licenses/>.
0211 //(c)C: Additionally, this file is licensed under terms of MIT license as expressed below.
0212 //(c)C: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
0213 //(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
0214 //(c)C: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.