diff --git a/extensions/CuteHMI/GUI.0/Element.qml b/extensions/CuteHMI/GUI.0/Element.qml index 8d49aa81..2aad9d9c 100644 --- a/extensions/CuteHMI/GUI.0/Element.qml +++ b/extensions/CuteHMI/GUI.0/Element.qml @@ -1,131 +1,131 @@ import QtQuick 2.0 import CuteHMI.GUI 0.0 /** %Element. This component should be used to implement color code aware items. */ Item { - implicitWidth: CuteApplication.theme.units.quadrat - implicitHeight: CuteApplication.theme.units.quadrat + implicitWidth: units.quadrat + implicitHeight: units.quadrat + + /** + Units used by the element. + */ + property Units units: CuteApplication.theme.units /** %Palette. %Palette to be used by an element. */ property Palette palette: CuteApplication.theme.palette /** This property defines current colors that should be used to draw element contents. By default, @a color properties are binded to the respective properties of active @ref colorSet "color set". However, current color values may differ from those of active color set, when color transitions take place. */ property ColorSet color: ColorSet { base: colorSet.base fill: colorSet.fill tint: colorSet.tint shade: colorSet.shade foreground: colorSet.foreground background: colorSet.background stroke: colorSet.stroke property color blank: palette.neutral.fill Behavior on base { ColorAnimation {} } Behavior on fill { ColorAnimation {} } Behavior on tint { ColorAnimation {} } Behavior on shade { ColorAnimation {} } Behavior on foreground { ColorAnimation {} } Behavior on background { ColorAnimation {} } Behavior on stroke { ColorAnimation {} } Behavior on blank { ColorAnimation {} } } /** Active color set. Normally this is controlled by currentStateColorSet() function, which sets appropriate color according to the state of @a active, @a warning and @a alarm properties. */ property ColorSet colorSet: currentStateColorSet() - /** - Stroke width. Width of the stoke that should be used by the item to draw its contents. - */ - property real strokeWidth: CuteApplication.theme.units.strokeWidth - /** Denotes if an item is in active state. */ property bool active: false /** Denotes if an item is in warning state. Warning state should take precedence over @a active state. */ property bool warning: false /** Denotes if an item is in alarm state. Alarm state should take precedence over @a warning and @a active states. */ property bool alarm: false /** Pick color set based on active, warning and alarm property states. Alarm takes precedence before warning and warning takes precedence over active state. For warning and alarm states this function dynamically alters the colors to carry visual information more effectively and to provide accessibility to color blind people. @return type:ColorSet appropriate color set. */ function currentStateColorSet() { return alarm ? (blinkTimer.blink ? alarmBlink : palette.alarm) : warning ? (blinkTimer.blink ? warningBlink : palette.warning) : active ? palette.active : palette.inactive } ColorSet { id: warningBlink base: Qt.lighter(palette.warning.base) fill: Qt.lighter(palette.warning.fill) tint: Qt.lighter(palette.warning.tint) shade: Qt.lighter(palette.warning.shade) foreground: Qt.lighter(palette.warning.foreground) background: Qt.lighter(palette.warning.background) stroke: Qt.lighter(palette.warning.stroke, 2.0) } ColorSet { id: alarmBlink base: Qt.lighter(palette.alarm.base) fill: palette.alarm.stroke tint: palette.alarm.shade shade: palette.alarm.tint foreground: palette.alarm.background background: palette.alarm.foreground stroke: palette.alarm.fill } Timer { id: blinkTimer interval: blink ? 250 : alarm ? 250 : 1500 running: warning || alarm repeat: true property bool blink: false onTriggered: blink = !blink } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(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. //(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. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/GUI.0/NumberDisplay.qml b/extensions/CuteHMI/GUI.0/NumberDisplay.qml index ffed5713..e695114a 100644 --- a/extensions/CuteHMI/GUI.0/NumberDisplay.qml +++ b/extensions/CuteHMI/GUI.0/NumberDisplay.qml @@ -1,120 +1,120 @@ import QtQuick 2.5 import CuteHMI.GUI 0.0 /** Number display. Number display can be used to conveniently display numerical values with corresponding units of measurement. Number display tries to keep constant width. If that's not possible it expands to fit the content. */ Element { id: root implicitWidth: background.width - valueDisplay.overfull implicitHeight: background.height active: value === value // NaN === NaN equals false, thus NaN value deactivates display. /** Font. Font that is used by the display. It may be desirable to set some monospace font. */ property alias font: valueDisplay.font /** Left padding. */ property real leftPadding: font.pixelSize * 0.25 /** Right padding. */ property real rightPadding: font.pixelSize * 0.25 /** Top padding. */ property real topPadding: font.pixelSize * 0.25 /** Bottom padding. */ property real bottomPadding: font.pixelSize * 0.25 /** Value. */ property real value: NaN /** Fractional width. */ property int fractionalWidth: 1 /** Integral width. */ property int integralWidth: 3 /** Unit of measurment. */ property string unit: "°C" /** Text formatter. */ property var textFormatter: function(value) { return value.toFixed(root.fractionalWidth) } Rectangle { id: background x: -0.5 * valueDisplay.overfull width: contentItem.width + leftPadding + rightPadding height: contentItem.height + topPadding + bottomPadding radius: height / 5 color: root.color.background border.color: root.color.stroke - border.width: strokeWidth + border.width: units.strokeWidth } Row { id: contentItem x: leftPadding - 0.5 * valueDisplay.overfull y: topPadding spacing: root.font.pixelSize * 0.25 Text { id: valueDisplay width: Math.max(contentWidth, nominaLWidth) text: textFormatter(root.value) color: root.color.foreground horizontalAlignment: Text.AlignRight - font.pixelSize: CuteApplication.theme.units.quadrat * 0.25 + font.pixelSize: units.quadrat * 0.25 font.family: CuteApplication.theme.fonts.monospace.family property real overfull: width - nominaLWidth property real nominaLWidth: contentWidth / text.length * (root.fractionalWidth + root.integralWidth + 1) } Text { id: unitDisplay text: root.unit font: root.font color: root.color.foreground } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(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. //(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. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/GUI.0/include/cutehmi/gui/Units.hpp b/extensions/CuteHMI/GUI.0/include/cutehmi/gui/Units.hpp index 5f2bfd85..4b2ffc30 100644 --- a/extensions/CuteHMI/GUI.0/include/cutehmi/gui/Units.hpp +++ b/extensions/CuteHMI/GUI.0/include/cutehmi/gui/Units.hpp @@ -1,75 +1,100 @@ #ifndef H_EXTENSIONS_CUTEHMI_GUI_0_INCLUDE_CUTEHMI_GUI_UNITS_HPP #define H_EXTENSIONS_CUTEHMI_GUI_0_INCLUDE_CUTEHMI_GUI_UNITS_HPP #include "internal/common.hpp" #include namespace cutehmi { namespace gui { +/** + * Unit. This class provides relative units of measurment. + */ class CUTEHMI_GUI_API Units: public QObject { Q_OBJECT public: static constexpr qreal INITIAL_QUADRAT = 80.0; - static constexpr bool INITIAL_ROUND_STROKE_WIDTH = true; + static constexpr qreal INITIAL_STROKE_WIDTH_RATIO = 40.0; - static constexpr qreal STANDARD_STROKE_WIDTH_QUADRAT_RATIO = 40.0; + static constexpr bool INITIAL_ROUND_STROKE_WIDTH = true; + /** + Quadrat. Role of this unit is similar to role of @p em unit used in typography. + */ Q_PROPERTY(qreal quadrat READ quadrat WRITE setQuadrat NOTIFY quadratChanged) + /** + Stroke width. By default binded to the formula @a strokeWidth = @a quadrat / @a strokeWidthRatio. + */ Q_PROPERTY(qreal strokeWidth READ strokeWidth WRITE setStrokeWidth NOTIFY strokeWidthChanged) + /** + Stroke width ratio. + */ + Q_PROPERTY(qreal strokeWidthRatio READ strokeWidthRatio WRITE setStrokeWidthRatio NOTIFY strokeWidthRatioChanged) + + /** + Whether to round stroke width to whole integer. + */ Q_PROPERTY(bool roundStrokeWidth READ roundStrokeWidth WRITE setRoundStrokeWidth NOTIFY roundStrokeWidthChanged) Units(QObject * parent = nullptr); qreal quadrat() const; void setQuadrat(qreal quadrat); qreal strokeWidth() const; void setStrokeWidth(qreal strokeWidth); + qreal strokeWidthRatio() const; + + void setStrokeWidthRatio(qreal ratio); + bool roundStrokeWidth() const; void setRoundStrokeWidth(bool roundStrokeWidth); signals: void quadratChanged(); void strokeWidthChanged(); + void strokeWidthRatioChanged(); + void roundStrokeWidthChanged(); private slots: void strokeWidthBinding(); private: void setStrokeWidth(qreal strokeWidth, bool breakBinding); struct Members { qreal quadrat; qreal strokeWidth; + qreal strokeWidthRatio; bool roundStrokeWidth; QMetaObject::Connection strokeWidthBindingConnection; + QMetaObject::Connection strokeWidthRatioBindingConnection; }; MPtr m; }; } } #endif //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(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. //(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. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/GUI.0/src/cutehmi/gui/Units.cpp b/extensions/CuteHMI/GUI.0/src/cutehmi/gui/Units.cpp index 05abb970..82b0b42c 100644 --- a/extensions/CuteHMI/GUI.0/src/cutehmi/gui/Units.cpp +++ b/extensions/CuteHMI/GUI.0/src/cutehmi/gui/Units.cpp @@ -1,83 +1,100 @@ #include #include namespace cutehmi { namespace gui { constexpr qreal Units::INITIAL_QUADRAT; +constexpr qreal Units::INITIAL_STROKE_WIDTH_RATIO; constexpr bool Units::INITIAL_ROUND_STROKE_WIDTH; -constexpr qreal Units::STANDARD_STROKE_WIDTH_QUADRAT_RATIO; Units::Units(QObject * parent): QObject(parent), m(new Members{INITIAL_QUADRAT, - INITIAL_QUADRAT / STANDARD_STROKE_WIDTH_QUADRAT_RATIO, - INITIAL_ROUND_STROKE_WIDTH, {}}) + INITIAL_QUADRAT / INITIAL_STROKE_WIDTH_RATIO, + INITIAL_STROKE_WIDTH_RATIO, + INITIAL_ROUND_STROKE_WIDTH, {}, {}}) { m->strokeWidthBindingConnection = connect(this, & Units::quadratChanged, this, & Units::strokeWidthBinding); + m->strokeWidthRatioBindingConnection = connect(this, & Units::strokeWidthRatioChanged, this, & Units::strokeWidthBinding); } qreal Units::quadrat() const { return m->quadrat; } void Units::setQuadrat(qreal quadrat) { if (m->quadrat != quadrat) { m->quadrat = quadrat; emit quadratChanged(); } } qreal Units::strokeWidth() const { return m->strokeWidth; } void Units::setStrokeWidth(qreal strokeWidth) { setStrokeWidth(strokeWidth, true); } +qreal Units::strokeWidthRatio() const +{ + return m->strokeWidthRatio; +} + +void Units::setStrokeWidthRatio(qreal ratio) +{ + if (m->strokeWidthRatio != ratio) { + m->strokeWidthRatio = ratio; + emit strokeWidthRatioChanged(); + } +} + bool Units::roundStrokeWidth() const { return m->roundStrokeWidth; } void Units::setRoundStrokeWidth(bool roundStrokeWidth) { if (m->roundStrokeWidth != roundStrokeWidth) { m->roundStrokeWidth = roundStrokeWidth; emit roundStrokeWidthChanged(); } } void Units::strokeWidthBinding() { - setStrokeWidth(quadrat() / STANDARD_STROKE_WIDTH_QUADRAT_RATIO, false); + setStrokeWidth(quadrat() / strokeWidthRatio(), false); } void Units::setStrokeWidth(qreal strokeWidth, bool breakBinding) { - if (breakBinding) + if (breakBinding) { disconnect(m->strokeWidthBindingConnection); + disconnect(m->strokeWidthRatioBindingConnection); + } if (roundStrokeWidth()) strokeWidth = std::max(std::round(strokeWidth), 1.0); if (m->strokeWidth != strokeWidth) { m->strokeWidth = strokeWidth; emit strokeWidthChanged(); } } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(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. //(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. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/HVAC.0/AirFilter.qml b/extensions/CuteHMI/Symbols/HVAC.0/AirFilter.qml index 3e271615..d13b2887 100644 --- a/extensions/CuteHMI/Symbols/HVAC.0/AirFilter.qml +++ b/extensions/CuteHMI/Symbols/HVAC.0/AirFilter.qml @@ -1,129 +1,129 @@ import QtQuick 2.5 import CuteHMI.GUI 0.0 /** Air filter. */ Element { id: root - implicitWidth: CuteApplication.theme.units.quadrat * 0.5 - implicitHeight: CuteApplication.theme.units.quadrat * 1.5 + implicitWidth: units.quadrat * 0.5 + implicitHeight: units.quadrat * 1.5 active: true warning: fill >= dirtyWarning alarm: fill >= dirtyAlarm property bool mirror: false // Number of filter pockets. property int pockets: 5 // Fill level (0.0 - 1.0). property real fill: 0.0 property real dirtyWarning: 0.75 property real dirtyAlarm: 0.9 property Component frame: Component { SymbolCanvas { transform: Scale { origin.x: width * 0.5; xScale: root.mirror ? -1 : 1 } element: root onPaint: { var ctx = getContext('2d') ctx.save() ctx.reset() ctx.strokeStyle = root.color.stroke ctx.fillStyle = root.color.fill - ctx.lineWidth = strokeWidth + ctx.lineWidth = units.strokeWidth - var offset = strokeWidth / 2.0 + var offset = units.strokeWidth / 2.0 // Draw case. - ctx.rect(offset, offset, width - strokeWidth, height - strokeWidth) + ctx.rect(offset, offset, width - units.strokeWidth, height - units.strokeWidth) ctx.fill() ctx.stroke() // Draw dirt. ctx.fillStyle = root.color.shade ctx.beginPath() - var dirtWidth = (width - 2 * strokeWidth) * fill - ctx.fillRect(width - strokeWidth - dirtWidth, strokeWidth, dirtWidth, height - 2 * strokeWidth) + var dirtWidth = (width - 2 * units.strokeWidth) * fill + ctx.fillRect(width - units.strokeWidth - dirtWidth, units.strokeWidth, dirtWidth, height - 2 * units.strokeWidth) ctx.fill() ctx.restore() } Connections { target: root onFillChanged: requestPaint() } } } property Component content: Component { SymbolCanvas { transform: Scale { origin.x: width * 0.5; xScale: root.mirror ? -1 : 1 } element: root onPaint: { var ctx = getContext('2d') ctx.save() ctx.reset() ctx.strokeStyle = root.color.stroke ctx.fillStyle = root.color.tint - ctx.lineWidth = strokeWidth + ctx.lineWidth = units.strokeWidth // Draw pockets. - var offset = strokeWidth / 2.0 - var pocketHeight = (height - strokeWidth) / pockets + var offset = units.strokeWidth / 2.0 + var pocketHeight = (height - units.strokeWidth) / pockets ctx.beginPath() var y = pocketHeight / 2.0 - ctx.moveTo(width - strokeWidth, offset) + ctx.moveTo(width - units.strokeWidth, offset) ctx.lineTo(offset, offset) - ctx.lineTo(width - strokeWidth, y) + ctx.lineTo(width - units.strokeWidth, y) for (var i = 1; i < pockets; i++) { y += pocketHeight / 2.0 ctx.lineTo(offset, y) y += pocketHeight / 2.0 - ctx.lineTo(width - strokeWidth, y) + ctx.lineTo(width - units.strokeWidth, y) } ctx.lineTo(offset, height - offset) - ctx.lineTo(width - strokeWidth, height - offset) + ctx.lineTo(width - units.strokeWidth, height - offset) ctx.fill() ctx.stroke() ctx.restore() } Connections { target: root onPocketsChanged: requestPaint() } } } Loader { width: root.width height: root.height sourceComponent: frame } Loader { width: root.width height: root.height sourceComponent: content } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(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. //(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. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/HVAC.0/BasicCooler.qml b/extensions/CuteHMI/Symbols/HVAC.0/BasicCooler.qml index afea064c..25a2fb42 100644 --- a/extensions/CuteHMI/Symbols/HVAC.0/BasicCooler.qml +++ b/extensions/CuteHMI/Symbols/HVAC.0/BasicCooler.qml @@ -1,49 +1,49 @@ import QtQuick 2.0 /** Basic cooler. */ HeatExchanger { id: root content: Component { SymbolCanvas { element: root onPaint: { var ctx = getContext("2d") ctx.save() ctx.reset() - ctx.lineWidth = root.strokeWidth + ctx.lineWidth = root.units.strokeWidth ctx.fillStyle = root.color.background ctx.strokeStyle = root.color.foreground // Draw minus symbol with radius r. var r = width * 0.25 var xCenter = width * 0.5 var yCenter = height * 0.5 // Draw circle. ctx.beginPath() ctx.arc(xCenter, yCenter, r, 0, 2 * Math.PI) ctx.fill() ctx.stroke() // Draw minus. ctx.beginPath() ctx.moveTo(xCenter - r * 0.5, yCenter) ctx.lineTo(xCenter + r * 0.5, yCenter) ctx.stroke() ctx.restore() } } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(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. //(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. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/HVAC.0/BasicDiscreteInstrument.qml b/extensions/CuteHMI/Symbols/HVAC.0/BasicDiscreteInstrument.qml index 523348b5..fbfe2ffb 100644 --- a/extensions/CuteHMI/Symbols/HVAC.0/BasicDiscreteInstrument.qml +++ b/extensions/CuteHMI/Symbols/HVAC.0/BasicDiscreteInstrument.qml @@ -1,42 +1,42 @@ import QtQuick 2.0 import CuteHMI.GUI 0.0 /** Basic discrete instrument. */ Element { id: root - implicitWidth: CuteApplication.theme.units.quadrat * 0.5 - implicitHeight: CuteApplication.theme.units.quadrat * 0.5 + implicitWidth: units.quadrat * 0.5 + implicitHeight: units.quadrat * 0.5 active: true property string symbol: "TT" property alias font: symbolText.font Rectangle { anchors.fill: parent color: root.color.background border.color: root.color.stroke - border.width: strokeWidth + border.width: units.strokeWidth radius: height * 0.5 } Text { id: symbolText anchors.centerIn: parent color: root.color.foreground font.family: CuteApplication.theme.fonts.monospace.family - font.pixelSize: CuteApplication.theme.units.quadrat * 0.2 + font.pixelSize: units.quadrat * 0.2 text: parent.symbol } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(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. //(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. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/HVAC.0/BasicHeater.qml b/extensions/CuteHMI/Symbols/HVAC.0/BasicHeater.qml index 616abef6..0a8fe00a 100644 --- a/extensions/CuteHMI/Symbols/HVAC.0/BasicHeater.qml +++ b/extensions/CuteHMI/Symbols/HVAC.0/BasicHeater.qml @@ -1,51 +1,51 @@ import QtQuick 2.0 /** Basic heater. */ HeatExchanger { id: root content: Component { SymbolCanvas { element: root onPaint: { var ctx = getContext("2d") ctx.save() ctx.reset() - ctx.lineWidth = root.strokeWidth + ctx.lineWidth = root.units.strokeWidth ctx.fillStyle = root.color.background ctx.strokeStyle = root.color.foreground // Draw plus symbol with radius r. var r = width * 0.25 var xCenter = width * 0.5 var yCenter = height * 0.5 // Draw cricle. ctx.beginPath() ctx.arc(xCenter, yCenter, r, 0, 2 * Math.PI) ctx.fill() ctx.stroke() // Draw plus. ctx.beginPath() ctx.moveTo(xCenter - r * 0.5, yCenter) ctx.lineTo(xCenter + r * 0.5, yCenter) ctx.moveTo(xCenter, yCenter - r * 0.5) ctx.lineTo(xCenter, yCenter + r * 0.5) ctx.stroke() ctx.restore() } } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(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. //(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. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/HVAC.0/BladeDamper.qml b/extensions/CuteHMI/Symbols/HVAC.0/BladeDamper.qml index 22d1e838..19a6fbd7 100644 --- a/extensions/CuteHMI/Symbols/HVAC.0/BladeDamper.qml +++ b/extensions/CuteHMI/Symbols/HVAC.0/BladeDamper.qml @@ -1,130 +1,130 @@ import QtQuick 2.5 import CuteHMI.GUI 0.0 /** Blade damper. */ Element { id: root - implicitWidth: horizontal ? CuteApplication.theme.units.quadrat : CuteApplication.theme.units.quadrat * 0.25 - implicitHeight: horizontal ? CuteApplication.theme.units.quadrat * 0.25 : CuteApplication.theme.units.quadrat + implicitWidth: horizontal ? units.quadrat : units.quadrat * 0.25 + implicitHeight: horizontal ? units.quadrat * 0.25 : units.quadrat active: true property int blades: 4 property real value: 0.5 property bool opposedBlade: true property bool mirror: false property bool horizontal property Component frame: Component { SymbolCanvas { transform: Scale { origin.x: width * 0.5; xScale: root.mirror ? -1 : 1 } element: root onPaint: { var ctx = getContext('2d') ctx.save() ctx.reset() ctx.strokeStyle = root.color.stroke ctx.fillStyle = root.color.fill - ctx.lineWidth = strokeWidth + ctx.lineWidth = units.strokeWidth - var offset = strokeWidth / 2.0 + var offset = units.strokeWidth / 2.0 // Draw case. - ctx.rect(offset, offset, width - strokeWidth, height - strokeWidth) + ctx.rect(offset, offset, width - units.strokeWidth, height - units.strokeWidth) ctx.fill() ctx.stroke() ctx.restore() } } } property Component mechanism: Component { SymbolCanvas { transform: [ Scale { origin.x: width * 0.5; xScale: root.mirror ? -1 : 1 }, Rotation { origin.x: root.height * 0.5; origin.y: root.height * 0.5; angle: horizontal ? -90 : 0 } ] element: root property real bladeSize: width * 0.75 property real bearingRadius: bladeSize * 0.125 onPaint: { var ctx = getContext('2d') ctx.save() ctx.reset() ctx.strokeStyle = root.color.stroke ctx.fillStyle = root.color.stroke - ctx.lineWidth = strokeWidth + ctx.lineWidth = units.strokeWidth var bladeMargin = 0.5 * (width - bladeSize) var totalBladesHeight = root.blades * (bladeSize + bladeMargin) - bladeMargin var margin = 0.5 * (height - totalBladesHeight) var angle = value * Math.PI * 0.5 ctx.translate(width * 0.5, margin + 0.5 * bladeSize) for (var i = 0; i < blades; i++) { // Draw bearing. ctx.beginPath() ctx.arc(0, 0, bearingRadius, 0, 2 * Math.PI, false) ctx.stroke() ctx.fill() // Draw blade. if (root.opposedBlade) angle = -angle ctx.rotate(angle) ctx.beginPath() ctx.moveTo(0, -bladeSize * 0.5) ctx.lineTo(0, bladeSize * 0.5) ctx.stroke() ctx.rotate(-angle) ctx.translate(0, bladeSize + bladeMargin) } ctx.restore() } Connections { target: root onBladesChanged: requestPaint() onValueChanged: requestPaint() onOpposedBladeChanged: requestPaint() onMirrorChanged: requestPaint() } } } Loader { width: root.width height: root.height sourceComponent: frame } Loader { width: horizontal ? root.height : root.width height: horizontal ? root.width : root.height sourceComponent: mechanism } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(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. //(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. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/HVAC.0/CentrifugalFan.qml b/extensions/CuteHMI/Symbols/HVAC.0/CentrifugalFan.qml index 42d2b2ee..43856867 100644 --- a/extensions/CuteHMI/Symbols/HVAC.0/CentrifugalFan.qml +++ b/extensions/CuteHMI/Symbols/HVAC.0/CentrifugalFan.qml @@ -1,174 +1,174 @@ import QtQuick 2.0 import CuteHMI.GUI 0.0 /** Centrifugal fan. */ Element { id: root - implicitWidth: CuteApplication.theme.units.quadrat * 1.25 - implicitHeight: CuteApplication.theme.units.quadrat + implicitWidth: units.quadrat * 1.25 + implicitHeight: units.quadrat property bool mirror: false property real implicitRpm: 30 property real rpm: active ? implicitRpm : 0 property Component housing: Component { SymbolCanvas { transform: Scale { origin.x: width * 0.5; xScale: root.mirror ? -1 : 1 } element: root onPaint: { var diameter = root.internal.diameter var ctx = getContext('2d') ctx.save() ctx.reset() ctx.strokeStyle = color.stroke ctx.fillStyle = color.tint - ctx.lineWidth = strokeWidth + ctx.lineWidth = units.strokeWidth - var offset = strokeWidth * 0.5 + var offset = units.strokeWidth * 0.5 var x = width * 0.5 var y = height * 0.5 var r = diameter * 0.5 var housingWidth = width - offset var exhaustWidth = (width - diameter) * 0.5 var exhaustHeight = diameter * 0.375 // Draw housing. ctx.arc(x, y, r - offset, 0.0, 1.5 * Math.PI, false) ctx.lineTo(housingWidth, offset) ctx.lineTo(housingWidth, exhaustHeight) ctx.lineTo(diameter + exhaustWidth - offset, exhaustHeight) ctx.lineTo(diameter + exhaustWidth - offset, y) ctx.fill() ctx.stroke() ctx.restore(); } Connections { target: root.internal onDiameterChanged: requestPaint() } } } property Component wheel: Component { SymbolCanvas { transform: Scale { origin.x: width * 0.5; xScale: root.mirror ? -1 : 1 } element: root onPaint: { var wheelDiameter = root.internal.wheelDiameter var ctx = getContext('2d') ctx.save() ctx.reset() ctx.strokeStyle = color.stroke ctx.fillStyle = color.fill - ctx.lineWidth = strokeWidth + ctx.lineWidth = units.strokeWidth // Draw fan wheel. var x = width * 0.5 var y = height * 0.5 var wheelR = wheelDiameter * 0.5 ctx.arc(x, y, wheelR, 0.0, 2 * Math.PI, false) ctx.fill() ctx.stroke() // Draw bearings ctx.beginPath() - ctx.arc(x, y, strokeWidth, 0.0, 2 * Math.PI, false) + ctx.arc(x, y, units.strokeWidth, 0.0, 2 * Math.PI, false) ctx.stroke() // Draw blades. var angle = Math.PI / 6.0 var sinAngle = Math.sin(angle) var cosAngle = Math.cos(angle) var x1 = 0.0 - var y1 = strokeWidth + var y1 = units.strokeWidth var x2 = 0.0 var y2 = wheelR ctx.beginPath() ctx.moveTo(x + x1, y + y1) ctx.lineTo(x + x2, y + y2) ctx.stroke() for (var curAngle = angle; curAngle < 2.0 * Math.PI; curAngle += angle) { var newX1 = x1 * cosAngle - y1 * sinAngle y1 = x1 * sinAngle + y1 * cosAngle x1 = newX1 var newX2 = x2 * cosAngle - y2 * sinAngle y2 = x2 * sinAngle + y2 * cosAngle x2 = newX2 ctx.beginPath() ctx.moveTo(x + x1, y + y1) ctx.lineTo(x + x2, y + y2) ctx.stroke() } ctx.restore(); } Connections { target: root onRpmChanged: handleRotation() Component.onCompleted: handleRotation() function handleRotation() { rotationAnimation.from = rotation % 360 rotationAnimation.to = rotation % 360 + 360 * Math.ceil(root.rpm) if (root.rpm) rotationAnimation.restart() else rotationAnimation.stop() } } Connections { target: root.internal onWheelDiameterChanged: requestPaint() } RotationAnimation on rotation { id: rotationAnimation duration: 60000 // 1 min = 60000 ms loops: Animation.Infinite } } } property QtObject internal: QtObject { property real diameter: root.height property real wheelDiameter: diameter * 0.625 } Loader { width: root.width height: root.height sourceComponent: housing } Loader { width: root.width height: root.height sourceComponent: wheel } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(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. //(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. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/HVAC.0/Cooler.qml b/extensions/CuteHMI/Symbols/HVAC.0/Cooler.qml index 9df7d363..d681bfc5 100644 --- a/extensions/CuteHMI/Symbols/HVAC.0/Cooler.qml +++ b/extensions/CuteHMI/Symbols/HVAC.0/Cooler.qml @@ -1,56 +1,56 @@ import QtQuick 2.0 /** Cooler. */ HeatExchanger { id: root content: Component { SymbolCanvas { property point symbolPos: root.symbolPos() element: root onPaint: { var ctx = getContext("2d") ctx.save() ctx.reset() - ctx.lineWidth = root.strokeWidth + ctx.lineWidth = root.units.strokeWidth ctx.fillStyle = root.color.background ctx.strokeStyle = root.color.foreground // Draw plus symbol with radius r. var r = width * 0.25 // Draw diagonal line. ctx.moveTo(0, height) ctx.lineTo(width, 0) ctx.stroke() // Draw cricle. ctx.beginPath() ctx.arc(symbolPos.x, symbolPos.y, r, 0, 2 * Math.PI) ctx.fill() ctx.stroke() // Draw minus. ctx.beginPath() ctx.moveTo(symbolPos.x - r * 0.5, symbolPos.y) ctx.lineTo(symbolPos.x + r * 0.5, symbolPos.y) ctx.stroke() ctx.restore() } onSymbolPosChanged: requestPaint() } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(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. //(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. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/HVAC.0/HeatExchanger.qml b/extensions/CuteHMI/Symbols/HVAC.0/HeatExchanger.qml index 7fe967ae..05493908 100644 --- a/extensions/CuteHMI/Symbols/HVAC.0/HeatExchanger.qml +++ b/extensions/CuteHMI/Symbols/HVAC.0/HeatExchanger.qml @@ -1,67 +1,67 @@ import QtQuick 2.0 import CuteHMI.GUI 0.0 /** Heat exchanger. */ Element { id: root - implicitWidth: CuteApplication.theme.units.quadrat - implicitHeight: CuteApplication.theme.units.quadrat * 1.5 + implicitWidth: units.quadrat + implicitHeight: units.quadrat * 1.5 active: true property Component housing: Component { Rectangle { color: root.color.fill border.color: root.color.stroke - border.width: root.strokeWidth + border.width: root.units.strokeWidth } } property Component content: Component { SymbolCanvas { element: root onPaint: { var ctx = getContext("2d") ctx.save() ctx.reset() - ctx.lineWidth = root.strokeWidth + ctx.lineWidth = root.units.strokeWidth ctx.strokeStyle = root.color.stroke // Draw diagonal line. ctx.moveTo(0, height) ctx.lineTo(width, 0) ctx.stroke() ctx.restore() } } } function symbolPos() { var l = 0.5 * (width + height - Math.sqrt(width * width + height * height)) return Qt.point(width - l, height - l) } Loader { width: root.width height: root.height sourceComponent: housing } Loader { width: root.width height: root.height sourceComponent: content } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(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. //(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. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/HVAC.0/HeatRecoveryWheel.qml b/extensions/CuteHMI/Symbols/HVAC.0/HeatRecoveryWheel.qml index c728bab0..356a6c94 100644 --- a/extensions/CuteHMI/Symbols/HVAC.0/HeatRecoveryWheel.qml +++ b/extensions/CuteHMI/Symbols/HVAC.0/HeatRecoveryWheel.qml @@ -1,148 +1,148 @@ import QtQuick 2.5 import CuteHMI.GUI 0.0 /** Heat recovery wheel. */ Element { id: root - implicitWidth: CuteApplication.theme.units.quadrat * 0.5 - implicitHeight: CuteApplication.theme.units.quadrat * 2.0 + implicitWidth: units.quadrat * 0.5 + implicitHeight: units.quadrat * 2.0 property int segments: 16 property bool clockwise: true property real implicitRpm: 10 property real rpm: active ? implicitRpm : 0 property Component frame: Component { SymbolCanvas { element: root onPaint: { var ctx = getContext('2d') ctx.save() ctx.reset() ctx.strokeStyle = root.color.stroke ctx.fillStyle = root.color.shade - ctx.lineWidth = strokeWidth + ctx.lineWidth = units.strokeWidth - var offset = strokeWidth / 2.0 + var offset = units.strokeWidth / 2.0 // Draw case. - ctx.rect(offset, offset, width - strokeWidth, height - strokeWidth) + ctx.rect(offset, offset, width - units.strokeWidth, height - units.strokeWidth) ctx.fill() ctx.stroke() ctx.restore() } Connections { target: root } } } property Component wheel: Component { SymbolCanvas { element: root property real rotation: 0.0 property real wheelWidth: width * 0.75 onPaint: { var ctx = getContext('2d') ctx.save() ctx.reset() ctx.strokeStyle = root.color.stroke ctx.fillStyle = root.color.fill - ctx.lineWidth = strokeWidth + ctx.lineWidth = units.strokeWidth - var offset = strokeWidth / 2.0 + var offset = units.strokeWidth / 2.0 // Draw background. - ctx.rect(offset + (width - wheelWidth) * 0.5, offset, width - strokeWidth - (width - wheelWidth), height - strokeWidth) + ctx.rect(offset + (width - wheelWidth) * 0.5, offset, width - units.strokeWidth - (width - wheelWidth), height - units.strokeWidth) ctx.stroke() ctx.fill() // Draw segments. var r = height * 0.5 var angle = 180 / segments for (var i = 0; i < segments; i++) { var currentAngle = (i * angle + rotation) % 180 currentAngle -= 90 currentAngle *= Math.PI / 180 var y = height * 0.5 + Math.sin(currentAngle) * r ctx.moveTo(offset + (width - wheelWidth) * 0.5, y) - ctx.lineTo(width - strokeWidth - (width - wheelWidth) * 0.5, y) + ctx.lineTo(width - units.strokeWidth - (width - wheelWidth) * 0.5, y) ctx.stroke() } ctx.restore() } onRotationChanged: requestPaint() Connections { target: root onRpmChanged: handleRotation() onClockwiseChanged: handleRotation() function handleRotation() { if (clockwise) { rotationAnimation.from = rotation % 360 rotationAnimation.to = rotation % 360 + 360 * Math.ceil(root.rpm) } else { rotationAnimation.to = rotation % 360 rotationAnimation.from = rotation % 360 + 360 * Math.ceil(root.rpm) } if (root.rpm) rotationAnimation.restart() else rotationAnimation.stop() } Component.onCompleted: handleRotation() } Connections { target: root onSegmentsChanged: requestPaint() } RotationAnimation on rotation { id: rotationAnimation duration: 60000 // 1 min = 60000 ms loops: Animation.Infinite direction: clockwise ? RotationAnimation.Clockwise : RotationAnimation.Counterclockwise } } } Loader { width: root.width height: root.height sourceComponent: frame } Loader { width: root.width height: root.height sourceComponent: wheel } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(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. //(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. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/HVAC.0/Heater.qml b/extensions/CuteHMI/Symbols/HVAC.0/Heater.qml index b7c4276e..c19f5b45 100644 --- a/extensions/CuteHMI/Symbols/HVAC.0/Heater.qml +++ b/extensions/CuteHMI/Symbols/HVAC.0/Heater.qml @@ -1,58 +1,58 @@ import QtQuick 2.0 /** Heater. */ HeatExchanger { id: root content: Component { SymbolCanvas { element: root property point symbolPos: root.symbolPos() onPaint: { var ctx = getContext("2d") ctx.save() ctx.reset() - ctx.lineWidth = root.strokeWidth + ctx.lineWidth = root.units.strokeWidth ctx.fillStyle = root.color.background ctx.strokeStyle = root.color.foreground // Draw plus symbol with radius r. var r = width * 0.25 // Draw diagonal line. ctx.moveTo(0, height) ctx.lineTo(width, 0) ctx.stroke() // Draw cricle. ctx.beginPath() ctx.arc(symbolPos.x, symbolPos.y, r, 0, 2 * Math.PI) ctx.fill() ctx.stroke() // Draw plus. ctx.beginPath() ctx.moveTo(symbolPos.x - r * 0.5, symbolPos.y) ctx.lineTo(symbolPos.x + r * 0.5, symbolPos.y) ctx.moveTo(symbolPos.x, symbolPos.y - r * 0.5) ctx.lineTo(symbolPos.x, symbolPos.y + r * 0.5) ctx.stroke() ctx.restore() } onSymbolPosChanged: requestPaint() } } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(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. //(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. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/HVAC.0/MotorActuator.qml b/extensions/CuteHMI/Symbols/HVAC.0/MotorActuator.qml index b8f5726c..4b3ecc13 100644 --- a/extensions/CuteHMI/Symbols/HVAC.0/MotorActuator.qml +++ b/extensions/CuteHMI/Symbols/HVAC.0/MotorActuator.qml @@ -1,82 +1,82 @@ import QtQuick 2.0 import CuteHMI.GUI 0.0 /** Motor actuator. */ Element { id: root - implicitWidth: CuteApplication.theme.units.quadrat * 0.5 - implicitHeight: CuteApplication.theme.units.quadrat * 0.5 + implicitWidth: units.quadrat * 0.5 + implicitHeight: units.quadrat * 0.5 property real start: 0.0 property real value: 0.0 property string symbol: "M" property alias font: symbolText.font SymbolCanvas { id: canvas anchors.fill: parent element: root onPaint: { var ctx = getContext("2d") ctx.save() ctx.reset() - ctx.lineWidth = root.strokeWidth - ctx.fillStyle = root.color.background - ctx.strokeStyle = root.color.stroke + ctx.lineWidth = units.strokeWidth + ctx.fillStyle = color.background + ctx.strokeStyle = color.stroke - var r = (width - strokeWidth) * 0.5 + var r = (width - units.strokeWidth) * 0.5 var xCenter = width * 0.5 var yCenter = height * 0.5 // Draw cricle. ctx.beginPath() ctx.arc(xCenter, yCenter, r, 0, 2 * Math.PI) ctx.fill() ctx.stroke() // Draw progress ctx.beginPath() - ctx.strokeStyle = root.color.background - ctx.arc(xCenter, yCenter, r - strokeWidth, 0, 2 * Math.PI) + ctx.strokeStyle = color.background + ctx.arc(xCenter, yCenter, r - units.strokeWidth, 0, 2 * Math.PI) ctx.stroke() ctx.beginPath() - ctx.strokeStyle = root.color.foreground - ctx.arc(xCenter, yCenter, r - strokeWidth, start * 2 * Math.PI - 0.5 * Math.PI, value * 2 * Math.PI - 0.5 * Math.PI) + ctx.strokeStyle = color.foreground + ctx.arc(xCenter, yCenter, r - units.strokeWidth, start * 2 * Math.PI - 0.5 * Math.PI, value * 2 * Math.PI - 0.5 * Math.PI) ctx.stroke() ctx.restore() } Connections { target: root onStartChanged: canvas.requestPaint() onValueChanged: canvas.requestPaint() } } Text { id: symbolText anchors.centerIn: parent color: root.color.foreground font.family: CuteApplication.theme.fonts.monospace.family - font.pixelSize: CuteApplication.theme.units.quadrat * 0.2 + font.pixelSize: units.quadrat * 0.2 text: parent.symbol } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(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. //(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. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/HVAC.0/Pump.qml b/extensions/CuteHMI/Symbols/HVAC.0/Pump.qml index 63a6ac33..961e1e99 100644 --- a/extensions/CuteHMI/Symbols/HVAC.0/Pump.qml +++ b/extensions/CuteHMI/Symbols/HVAC.0/Pump.qml @@ -1,188 +1,188 @@ import QtQuick 2.0 import CuteHMI.GUI 0.0 /** Pump. */ Element { id: root - implicitWidth: CuteApplication.theme.units.quadrat - implicitHeight: CuteApplication.theme.units.quadrat + implicitWidth: units.quadrat + implicitHeight: units.quadrat property real implicitRpm: 30 property real rpm: active ? implicitRpm : 0 property Component housing: Component { SymbolCanvas { element: root onPaint: { var diameter = root.internal.diameter var innerDiameter = root.internal.innerDiameter var ctx = getContext('2d') ctx.save() ctx.reset() ctx.strokeStyle = color.tint ctx.lineWidth = (diameter - innerDiameter) * 0.5 ctx.arc(width * 0.5, height * 0.5, (diameter + innerDiameter) * 0.25, 0.0, 2 * Math.PI, false) ctx.stroke() ctx.closePath() ctx.beginPath() ctx.strokeStyle = color.stroke - ctx.lineWidth = strokeWidth - ctx.arc(width * 0.5, height * 0.5, (diameter - strokeWidth) * 0.5, 0.0, 2 * Math.PI, false) + ctx.lineWidth = units.strokeWidth + ctx.arc(width * 0.5, height * 0.5, (diameter - units.strokeWidth) * 0.5, 0.0, 2 * Math.PI, false) ctx.stroke() ctx.restore(); } Connections { target: root.internal onDiameterChanged: requestPaint() onInnerDiameterChanged: requestPaint() } } } property Component rotor: Component { SymbolCanvas { element: root onPaint: { var diameter = root.internal.diameter var innerDiameter = root.internal.innerDiameter var ctx = getContext('2d') ctx.save() ctx.reset() ctx.strokeStyle = color.shade - ctx.lineWidth = (diameter - innerDiameter) * 0.5 - strokeWidth + ctx.lineWidth = (diameter - innerDiameter) * 0.5 - units.strokeWidth // Draw vanes. - var arcR = (diameter + innerDiameter) * 0.25 - strokeWidth * 0.5 + var arcR = (diameter + innerDiameter) * 0.25 - units.strokeWidth * 0.5 var angle = Math.PI / 6.0 for (var curAngle = 0; curAngle < 2 * Math.PI; curAngle += 2 * angle) { ctx.beginPath() ctx.arc(width * 0.5, height * 0.5, arcR, curAngle, curAngle + angle) ctx.stroke() ctx.closePath() } ctx.restore(); } Connections { target: root onRpmChanged: handleRotation() function handleRotation() { rotationAnimation.from = rotation % 360 rotationAnimation.to = rotation % 360 + 360 * Math.ceil(root.rpm) if (root.rpm) rotationAnimation.restart() else rotationAnimation.stop() } Component.onCompleted: handleRotation() } Connections { target: root.internal onDiameterChanged: requestPaint() onInnerDiameterChanged: requestPaint() } RotationAnimation on rotation { id: rotationAnimation duration: 60000 // 1 min = 60000 ms loops: Animation.Infinite } } } property Component symbol: Component { SymbolCanvas { element: root onPaint: { var diameter = root.internal.diameter var innerDiameter = root.internal.innerDiameter var ctx = getContext('2d') ctx.save() ctx.reset() ctx.strokeStyle = color.stroke - ctx.lineWidth = strokeWidth + ctx.lineWidth = units.strokeWidth - var lineOffset = strokeWidth * 0.5 + var lineOffset = units.strokeWidth * 0.5 var symbolOffset = (diameter - innerDiameter) * 0.5 - var insetDiameter = innerDiameter - strokeWidth + var insetDiameter = innerDiameter - units.strokeWidth ctx.translate(symbolOffset, symbolOffset) // Draw circle. ctx.fillStyle = color.blank ctx.ellipse(lineOffset, lineOffset, insetDiameter, insetDiameter) ctx.fill() ctx.stroke() // Draw inner triangle. ctx.fillStyle = color.fill ctx.beginPath(); ctx.moveTo(innerDiameter - lineOffset, innerDiameter * 0.5) ctx.lineTo(innerDiameter * 0.25 + lineOffset, innerDiameter * ( 2.0 + Math.sqrt(3.0)) * 0.25 - lineOffset) ctx.lineTo(innerDiameter * 0.25 + lineOffset, innerDiameter * ( 2.0 - Math.sqrt(3.0)) * 0.25 + lineOffset) ctx.closePath() ctx.fill() ctx.stroke() ctx.restore(); } Connections { target: root.internal onDiameterChanged: requestPaint() onInnerDiameterChanged: requestPaint() } } } property QtObject internal: QtObject { property real diameter: Math.min(root.width, root.height) property real innerDiameter: diameter * 0.75 } Loader { width: root.width height: root.height sourceComponent: housing } Loader { width: root.width height: root.height sourceComponent: rotor } Loader { width: root.width height: root.height sourceComponent: symbol } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(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. //(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. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see . diff --git a/extensions/CuteHMI/Symbols/HVAC.0/SymbolCanvas.qml b/extensions/CuteHMI/Symbols/HVAC.0/SymbolCanvas.qml index c67b7224..76287f45 100644 --- a/extensions/CuteHMI/Symbols/HVAC.0/SymbolCanvas.qml +++ b/extensions/CuteHMI/Symbols/HVAC.0/SymbolCanvas.qml @@ -1,35 +1,35 @@ import QtQuick 2.5 import CuteHMI.GUI 0.0 /** Symbol canvas. Canvas used to draw active symbols. */ Canvas { property Element element Connections { target: element.color onBaseChanged: requestPaint() onFillChanged: requestPaint() onTintChanged: requestPaint() onShadeChanged: requestPaint() onForegroundChanged: requestPaint() onBackgroundChanged: requestPaint() onStrokeChanged: requestPaint() onBlankChanged: requestPaint() } Connections { - target: element + target: element.units onStrokeWidthChanged: requestPaint() } } //(c)C: Copyright © 2020, Michał Policht . All rights reserved. //(c)C: This file is a part of CuteHMI. //(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. //(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. //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see .