Warning, /sdk/cutehmi/extensions/CuteHMI/Symbols/HVAC.1/HeatRecoveryWheel.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 2.5
0002
0003 import CuteHMI.GUI 1.0
0004
0005 /**
0006 Heat recovery wheel.
0007 */
0008 Element {
0009 id: root
0010
0011 implicitWidth: units.quadrat * 0.5
0012 implicitHeight: units.quadrat * 2.0
0013
0014 property int segments: 16
0015
0016 property bool clockwise: true
0017
0018 property real implicitRpm: 10
0019
0020 property real rpm: active ? implicitRpm : 0
0021
0022 property Component frame: Component {
0023 SymbolCanvas {
0024 element: root
0025
0026 onPaint: {
0027 var ctx = getContext('2d')
0028 ctx.save()
0029 ctx.reset()
0030
0031 ctx.strokeStyle = root.color.stroke
0032 ctx.fillStyle = root.color.shade
0033 ctx.lineWidth = units.strokeWidth
0034
0035 var offset = units.strokeWidth / 2.0
0036
0037 // Draw case.
0038 ctx.rect(offset, offset, width - units.strokeWidth, height - units.strokeWidth)
0039 ctx.fill()
0040 ctx.stroke()
0041
0042 ctx.restore()
0043 }
0044 }
0045 }
0046
0047 property Component wheel: Component {
0048 SymbolCanvas {
0049 element: root
0050
0051 property real rotation: 0.0
0052
0053 property real wheelWidth: width * 0.75
0054
0055 onPaint: {
0056 var ctx = getContext('2d')
0057 ctx.save()
0058 ctx.reset()
0059
0060 ctx.strokeStyle = root.color.stroke
0061 ctx.fillStyle = root.color.fill
0062 ctx.lineWidth = units.strokeWidth
0063
0064 var offset = units.strokeWidth / 2.0
0065
0066 // Draw background.
0067 ctx.rect(offset + (width - wheelWidth) * 0.5, offset, width - units.strokeWidth - (width - wheelWidth), height - units.strokeWidth)
0068 ctx.stroke()
0069 ctx.fill()
0070
0071 // Draw segments.
0072 var r = height * 0.5
0073 var angle = 180 / segments
0074 for (var i = 0; i < segments; i++) {
0075 var currentAngle = (i * angle + rotation) % 180
0076 currentAngle -= 90
0077 currentAngle *= Math.PI / 180
0078 var y = height * 0.5 + Math.sin(currentAngle) * r
0079 ctx.moveTo(offset + (width - wheelWidth) * 0.5, y)
0080 ctx.lineTo(width - units.strokeWidth - (width - wheelWidth) * 0.5, y)
0081 ctx.stroke()
0082 }
0083
0084 ctx.restore()
0085 }
0086
0087 onRotationChanged: requestPaint()
0088
0089 Connections {
0090 target: root
0091
0092 function onRpmChanged() {
0093 handleRotation()
0094 }
0095
0096 function onClockwiseChanged() {
0097 handleRotation()
0098 }
0099
0100 function handleRotation() {
0101 if (clockwise) {
0102 rotationAnimation.from = rotation % 360
0103 rotationAnimation.to = rotation % 360 + 360 * Math.ceil(root.rpm)
0104 } else {
0105 rotationAnimation.to = rotation % 360
0106 rotationAnimation.from = rotation % 360 + 360 * Math.ceil(root.rpm)
0107 }
0108
0109 if (root.rpm)
0110 rotationAnimation.restart()
0111 else
0112 rotationAnimation.stop()
0113 }
0114
0115 Component.onCompleted: handleRotation()
0116 }
0117
0118 Connections {
0119 target: root
0120
0121 function onSegmentsChanged() {
0122 requestPaint()
0123 }
0124 }
0125
0126 RotationAnimation on rotation {
0127 id: rotationAnimation
0128
0129 duration: 60000 // 1 min = 60000 ms
0130 loops: Animation.Infinite
0131 direction: clockwise ? RotationAnimation.Clockwise : RotationAnimation.Counterclockwise
0132 }
0133 }
0134 }
0135
0136 Loader {
0137 width: root.width
0138 height: root.height
0139 sourceComponent: frame
0140 }
0141
0142 Loader {
0143 width: root.width
0144 height: root.height
0145 sourceComponent: wheel
0146 }
0147 }
0148
0149 //(c)C: Copyright © 2020-2021, Michał Policht <michal@policht.pl>. All rights reserved.
0150 //(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
0151 //(c)C: This file is a part of CuteHMI.
0152 //(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.
0153 //(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.
0154 //(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/>.
0155 //(c)C: Additionally, this file is licensed under terms of MIT license as expressed below.
0156 //(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:
0157 //(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
0158 //(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.