Warning, /sdk/cutehmi/extensions/CuteHMI/Symbols/HVAC.1/Tank.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 Tank. 0007 */ 0008 Element { 0009 id: root 0010 0011 implicitWidth: units.quadrat * 0.75 0012 implicitHeight: units.quadrat * 1.5 0013 0014 active: true 0015 0016 property real headRatio: 0.25 0017 0018 property real level: 0.0 0019 0020 property Component shell: Component { 0021 SymbolCanvas { 0022 element: root 0023 0024 onPaint: { 0025 var ctx = getContext('2d') 0026 ctx.save() 0027 ctx.reset() 0028 0029 ctx.strokeStyle = root.color.stroke 0030 ctx.fillStyle = root.color.fill 0031 ctx.lineWidth = units.strokeWidth 0032 0033 var offset = units.strokeWidth / 2.0 0034 var headRadius = height * root.headRatio 0035 var shellHeight = height - headRadius - units.strokeWidth 0036 0037 // Draw top ellipsoidal head. 0038 ctx.ellipse(offset, offset, width - units.strokeWidth, headRadius) 0039 ctx.fill() 0040 ctx.stroke() 0041 0042 // Draw bottom ellipsoidal head. 0043 ctx.ellipse(offset, offset + shellHeight, width - units.strokeWidth, headRadius) 0044 ctx.fill() 0045 ctx.stroke() 0046 0047 // Draw shell. 0048 ctx.beginPath() 0049 ctx.rect(offset, offset + headRadius * 0.5, width - units.strokeWidth, shellHeight) 0050 ctx.fill() 0051 ctx.stroke() 0052 0053 ctx.restore() 0054 } 0055 0056 Connections { 0057 target: root 0058 0059 function onHeadRatioChanged() { 0060 requestPaint() 0061 } 0062 } 0063 } 0064 } 0065 0066 property Component liquid: Component { 0067 Item { 0068 property real headRadius: height * root.headRatio 0069 property real shellHeight: height - headRadius - units.strokeWidth 0070 property real liquidY: (height - 2 * units.strokeWidth) * (1.0 - level) 0071 0072 // Liquid in heads. 0073 SymbolCanvas { 0074 id: headsLiquidCanvas 0075 0076 anchors.fill: parent 0077 0078 element: root 0079 0080 onPaint: { 0081 var ctx = getContext('2d') 0082 ctx.save() 0083 ctx.reset() 0084 0085 ctx.strokeStyle = root.color.stroke 0086 ctx.fillStyle = root.color.shade 0087 ctx.lineWidth = units.strokeWidth 0088 0089 ctx.ellipse(units.strokeWidth, units.strokeWidth, width - 2 * units.strokeWidth, headRadius - units.strokeWidth) 0090 ctx.ellipse(units.strokeWidth, units.strokeWidth + shellHeight, width - 2 * units.strokeWidth, headRadius - units.strokeWidth) 0091 ctx.clip() 0092 0093 ctx.beginPath() 0094 ctx.rect(0, liquidY + units.strokeWidth, width, height - liquidY - 2 * units.strokeWidth) 0095 ctx.fill() 0096 0097 if (level != 0 && level != 1) { 0098 ctx.beginPath() 0099 ctx.moveTo(0, liquidY + units.strokeWidth) 0100 ctx.lineTo(width, liquidY + units.strokeWidth) 0101 ctx.stroke() 0102 } 0103 0104 ctx.restore() 0105 } 0106 } 0107 0108 // Liquid in a shell. 0109 SymbolCanvas { 0110 id: shellLiquidCanvas 0111 0112 anchors.fill: parent 0113 0114 element: root 0115 0116 onPaint: { 0117 var ctx = getContext('2d') 0118 ctx.save() 0119 ctx.reset() 0120 0121 ctx.strokeStyle = root.color.stroke 0122 ctx.fillStyle = root.color.shade 0123 ctx.lineWidth = units.strokeWidth 0124 0125 ctx.rect(units.strokeWidth, units.strokeWidth + headRadius * 0.5, width - 2 * units.strokeWidth, shellHeight) 0126 ctx.clip() 0127 0128 ctx.beginPath() 0129 ctx.rect(0, liquidY + units.strokeWidth, width, height - liquidY - 2 * units.strokeWidth) 0130 ctx.fill() 0131 0132 if (level != 0 && level != 1) { 0133 ctx.beginPath() 0134 ctx.moveTo(0, liquidY + units.strokeWidth) 0135 ctx.lineTo(width, liquidY + units.strokeWidth) 0136 ctx.stroke() 0137 } 0138 } 0139 } 0140 0141 Connections { 0142 target: root 0143 0144 function onHeadRatioChanged() { 0145 shellLiquidCanvas.requestPaint() 0146 headsLiquidCanvas.requestPaint() 0147 } 0148 0149 function onLevelChanged() { 0150 shellLiquidCanvas.requestPaint() 0151 headsLiquidCanvas.requestPaint() 0152 } 0153 } 0154 } 0155 } 0156 0157 Loader { 0158 width: root.width 0159 height: root.height 0160 sourceComponent: shell 0161 } 0162 0163 Loader { 0164 width: root.width 0165 height: root.height 0166 sourceComponent: liquid 0167 } 0168 } 0169 0170 //(c)C: Copyright © 2020-2021, Michał Policht <michal@policht.pl>. All rights reserved. 0171 //(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT 0172 //(c)C: This file is a part of CuteHMI. 0173 //(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. 0174 //(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. 0175 //(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/>. 0176 //(c)C: Additionally, this file is licensed under terms of MIT license as expressed below. 0177 //(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: 0178 //(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 0179 //(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.