Warning, /sdk/cutehmi/extensions/CuteHMI/Symbols/HVAC.1/CentrifugalFan.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 Centrifugal fan. 0007 */ 0008 Element { 0009 id: root 0010 0011 implicitWidth: units.quadrat * 1.25 0012 implicitHeight: units.quadrat 0013 0014 property bool mirror: false 0015 property real implicitRpm: 30 0016 property real rpm: active ? implicitRpm : 0 0017 0018 property Component housing: Component { 0019 SymbolCanvas { 0020 transform: Scale { origin.x: width * 0.5; xScale: root.mirror ? -1 : 1 } 0021 0022 element: root 0023 0024 onPaint: { 0025 var diameter = root.internal.diameter 0026 0027 var ctx = getContext('2d') 0028 ctx.save() 0029 ctx.reset() 0030 0031 ctx.strokeStyle = color.stroke 0032 ctx.fillStyle = color.tint 0033 ctx.lineWidth = units.strokeWidth 0034 0035 var offset = units.strokeWidth * 0.5 0036 var x = width * 0.5 0037 var y = height * 0.5 0038 var r = diameter * 0.5 0039 var housingWidth = width - offset 0040 var exhaustWidth = (width - diameter) * 0.5 0041 var exhaustHeight = diameter * 0.375 0042 0043 // Draw housing. 0044 ctx.arc(x, y, r - offset, 0.0, 1.5 * Math.PI, false) 0045 ctx.lineTo(housingWidth, offset) 0046 ctx.lineTo(housingWidth, exhaustHeight) 0047 ctx.lineTo(diameter + exhaustWidth - offset, exhaustHeight) 0048 ctx.lineTo(diameter + exhaustWidth - offset, y) 0049 ctx.fill() 0050 ctx.stroke() 0051 0052 ctx.restore(); 0053 } 0054 0055 Connections { 0056 target: root.internal 0057 0058 function onDiameterChanged() { 0059 requestPaint() 0060 } 0061 } 0062 } 0063 } 0064 0065 property Component wheel: Component { 0066 SymbolCanvas { 0067 transform: Scale { origin.x: width * 0.5; xScale: root.mirror ? -1 : 1 } 0068 0069 element: root 0070 0071 onPaint: { 0072 var wheelDiameter = root.internal.wheelDiameter 0073 0074 var ctx = getContext('2d') 0075 ctx.save() 0076 ctx.reset() 0077 0078 ctx.strokeStyle = color.stroke 0079 ctx.fillStyle = color.fill 0080 ctx.lineWidth = units.strokeWidth 0081 0082 // Draw fan wheel. 0083 var x = width * 0.5 0084 var y = height * 0.5 0085 var wheelR = wheelDiameter * 0.5 0086 0087 ctx.arc(x, y, wheelR, 0.0, 2 * Math.PI, false) 0088 ctx.fill() 0089 ctx.stroke() 0090 0091 // Draw bearings 0092 ctx.beginPath() 0093 ctx.arc(x, y, units.strokeWidth, 0.0, 2 * Math.PI, false) 0094 ctx.stroke() 0095 0096 // Draw blades. 0097 var angle = Math.PI / 6.0 0098 var sinAngle = Math.sin(angle) 0099 var cosAngle = Math.cos(angle) 0100 var x1 = 0.0 0101 var y1 = units.strokeWidth 0102 var x2 = 0.0 0103 var y2 = wheelR 0104 0105 ctx.beginPath() 0106 ctx.moveTo(x + x1, y + y1) 0107 ctx.lineTo(x + x2, y + y2) 0108 ctx.stroke() 0109 for (var curAngle = angle; curAngle < 2.0 * Math.PI; curAngle += angle) { 0110 var newX1 = x1 * cosAngle - y1 * sinAngle 0111 y1 = x1 * sinAngle + y1 * cosAngle 0112 x1 = newX1 0113 var newX2 = x2 * cosAngle - y2 * sinAngle 0114 y2 = x2 * sinAngle + y2 * cosAngle 0115 x2 = newX2 0116 ctx.beginPath() 0117 ctx.moveTo(x + x1, y + y1) 0118 ctx.lineTo(x + x2, y + y2) 0119 ctx.stroke() 0120 } 0121 0122 ctx.restore(); 0123 } 0124 0125 Connections { 0126 target: root 0127 0128 function onRpmChanged() { 0129 handleRotation() 0130 } 0131 0132 function handleRotation() { 0133 rotationAnimation.from = rotation % 360 0134 rotationAnimation.to = rotation % 360 + 360 * Math.ceil(root.rpm) 0135 if (root.rpm) 0136 rotationAnimation.restart() 0137 else 0138 rotationAnimation.stop() 0139 } 0140 0141 Component.onCompleted: handleRotation() 0142 } 0143 0144 Connections { 0145 target: root.internal 0146 0147 function onWheelDiameterChanged() { 0148 requestPaint() 0149 } 0150 } 0151 0152 RotationAnimation on rotation { 0153 id: rotationAnimation 0154 0155 duration: 60000 // 1 min = 60000 ms 0156 loops: Animation.Infinite 0157 } 0158 } 0159 } 0160 0161 property QtObject internal: QtObject { 0162 property real diameter: root.height 0163 property real wheelDiameter: diameter * 0.625 0164 } 0165 0166 Loader { 0167 width: root.width 0168 height: root.height 0169 sourceComponent: housing 0170 } 0171 0172 Loader { 0173 width: root.width 0174 height: root.height 0175 sourceComponent: wheel 0176 } 0177 } 0178 0179 //(c)C: Copyright © 2020-2021, Michał Policht <michal@policht.pl>. All rights reserved. 0180 //(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT 0181 //(c)C: This file is a part of CuteHMI. 0182 //(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. 0183 //(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. 0184 //(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/>. 0185 //(c)C: Additionally, this file is licensed under terms of MIT license as expressed below. 0186 //(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: 0187 //(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 0188 //(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.