Warning, /sdk/cutehmi/extensions/CuteHMI/Symbols/HVAC.1/BladeDamper.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 Blade damper. 0007 */ 0008 Element { 0009 id: root 0010 0011 implicitWidth: horizontal ? units.quadrat * 1.5 : units.quadrat * 0.25 0012 implicitHeight: horizontal ? units.quadrat * 0.25 : units.quadrat * 1.5 0013 active: true 0014 0015 property int blades: 6 0016 0017 property real value: 0.5 0018 0019 property bool opposedBlade: true 0020 0021 property bool mirror: false 0022 0023 property bool horizontal: false 0024 0025 property Component frame: Component { 0026 SymbolCanvas { 0027 transform: Scale { origin.x: width * 0.5; xScale: root.mirror ? -1 : 1 } 0028 0029 element: root 0030 0031 onPaint: { 0032 var ctx = getContext('2d') 0033 ctx.save() 0034 ctx.reset() 0035 0036 ctx.strokeStyle = root.color.stroke 0037 ctx.fillStyle = root.color.fill 0038 ctx.lineWidth = units.strokeWidth 0039 0040 var offset = units.strokeWidth / 2.0 0041 0042 // Draw case. 0043 ctx.rect(offset, offset, width - units.strokeWidth, height - units.strokeWidth) 0044 ctx.fill() 0045 ctx.stroke() 0046 0047 ctx.restore() 0048 } 0049 } 0050 } 0051 0052 property Component mechanism: Component { 0053 SymbolCanvas { 0054 transform: [ 0055 Scale { origin.x: width * 0.5; xScale: root.mirror ? -1 : 1 }, 0056 Rotation { origin.x: root.height * 0.5; origin.y: root.height * 0.5; angle: horizontal ? -90 : 0 } 0057 ] 0058 0059 element: root 0060 0061 property real bladeSize: width * 0.75 0062 0063 property real bearingRadius: bladeSize * 0.125 0064 0065 onPaint: { 0066 var ctx = getContext('2d') 0067 ctx.save() 0068 ctx.reset() 0069 0070 ctx.strokeStyle = root.color.stroke 0071 ctx.fillStyle = root.color.stroke 0072 ctx.lineWidth = units.strokeWidth 0073 0074 var bladeMargin = 0.5 * (width - bladeSize) 0075 var totalBladesHeight = root.blades * (bladeSize + bladeMargin) - bladeMargin 0076 var margin = 0.5 * (height - totalBladesHeight) 0077 0078 var angle = value * Math.PI * 0.5 0079 ctx.translate(width * 0.5, margin + 0.5 * bladeSize) 0080 for (var i = 0; i < blades; i++) { 0081 // Draw bearing. 0082 ctx.beginPath() 0083 ctx.arc(0, 0, bearingRadius, 0, 2 * Math.PI, false) 0084 ctx.stroke() 0085 ctx.fill() 0086 0087 // Draw blade. 0088 if (root.opposedBlade) 0089 angle = -angle 0090 ctx.rotate(angle) 0091 ctx.beginPath() 0092 ctx.moveTo(0, -bladeSize * 0.5) 0093 ctx.lineTo(0, bladeSize * 0.5) 0094 ctx.stroke() 0095 ctx.rotate(-angle) 0096 0097 ctx.translate(0, bladeSize + bladeMargin) 0098 } 0099 0100 ctx.restore() 0101 } 0102 0103 Connections { 0104 target: root 0105 0106 function onBladesChanged() { 0107 requestPaint() 0108 } 0109 0110 function onValueChanged() { 0111 requestPaint() 0112 } 0113 0114 function onOpposedBladeChanged() { 0115 requestPaint() 0116 } 0117 0118 function onMirrorChanged() { 0119 requestPaint() 0120 } 0121 } 0122 } 0123 } 0124 0125 Loader { 0126 width: root.width 0127 height: root.height 0128 sourceComponent: frame 0129 } 0130 0131 Loader { 0132 width: horizontal ? root.height : root.width 0133 height: horizontal ? root.width : root.height 0134 sourceComponent: mechanism 0135 } 0136 } 0137 0138 //(c)C: Copyright © 2020-2021, Michał Policht <michal@policht.pl>. All rights reserved. 0139 //(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT 0140 //(c)C: This file is a part of CuteHMI. 0141 //(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. 0142 //(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. 0143 //(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/>. 0144 //(c)C: Additionally, this file is licensed under terms of MIT license as expressed below. 0145 //(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: 0146 //(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 0147 //(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.