Skip to content

Commit

Permalink
Merge pull request #123 from Northeastern-Electric-Racing/#113-Update…
Browse files Browse the repository at this point in the history
…-Thermometer-Component

Update thermometer component in QML
  • Loading branch information
mattrwang authored Nov 19, 2024
2 parents 53bceb8 + 9c23f32 commit c4c553c
Show file tree
Hide file tree
Showing 6 changed files with 230 additions and 49 deletions.
11 changes: 5 additions & 6 deletions NERODesign/NERO.qmlproject.qtds
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtDesignStudio 4.3.2, 2024-04-30T10:04:04. -->
<!-- Written by QtDesignStudio 4.5.1, 2024-10-30T04:32:03. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{3cfc90f2-223d-425b-80aa-55ae979292b1}</value>
<value type="QByteArray">{8cc7a412-b525-49ef-bbee-0b31ae85f947}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
Expand Down Expand Up @@ -41,7 +41,7 @@
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">2</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
Expand All @@ -62,8 +62,8 @@
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.6.0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.6.0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.7.1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.7.1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{63f87550-2541-4163-9631-08b7fea781da}</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">-1</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
Expand All @@ -83,7 +83,6 @@
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">0</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
Expand Down
116 changes: 116 additions & 0 deletions NERODesign/NERO.qmlproject.qtds.3cfc90f
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtDesignStudio 4.3.2, 2024-04-30T10:04:04. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{3cfc90f2-223d-425b-80aa-55ae979292b1}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="qlonglong">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.6.0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.6.0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{63f87550-2541-4163-9631-08b7fea781da}</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">-1</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">0</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">QML Runtime</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QmlProjectManager.QmlRunConfiguration.Qml</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
<value type="QString" key="QmlProjectManager.QmlRunConfiguration.LastUsedLanguage">en</value>
<value type="QString" key="QmlProjectManager.QmlRunConfiguration.MainScript">CurrentFile</value>
<value type="bool" key="QmlProjectManager.QmlRunConfiguration.UseMultiLanguage">true</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="qlonglong">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">22</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>
10 changes: 5 additions & 5 deletions NERODesign/content/App.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ Window {
source: "fonts/Roboto-Black.ttf"
}

// Pit {
// id: pitScreen
// }
// EfficiencyScreen {}
OffScreen {}
Pit {
id: pitScreen
}
//EfficiencyScreen {}
// OffScreen {}
Timeline {
id: appTimeline
animations: [
Expand Down
2 changes: 1 addition & 1 deletion NERODesign/content/Pit.qml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Rectangle {
anchors.top: parent.top
anchors.bottom: parent.bottom
width: parent.width / 2

thermometerColor: "#FF0000"
thermometerValue: pit.packTempValue
title: "PACK TEMP"
}
Expand Down
135 changes: 100 additions & 35 deletions NERODesign/content/Thermometer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,74 +6,139 @@ Item {
id: thermometer
property bool regen: false
property int value: 0
property int horizontalPadding: width / 20
property int maxValue: 65
property int minValue: -15
property string color: regen ? "red" : value > maxValue - ((Math.abs(maxValue) + Math.abs(
minValue)) / 5) ? "red" : value > maxValue - (((Math.abs(maxValue) + Math.abs(minValue)) / 5) * 2) ? "orange" : value > maxValue - (((Math.abs(maxValue) + Math.abs(minValue)) / 5) * 3) ? "#FFF500" : value > maxValue - (((Math.abs(maxValue) + Math.abs(minValue)) / 5) * 4) ? "blue" : "purple"
property string color
height: 500
width: 600
width: 200

property real intersectPoint: 0.2
property real totalFillPercentage: (Math.max(0, value - minValue) / (maxValue - minValue))
property real circleFillPercentage: Math.min(1, totalFillPercentage / intersectPoint)
property real tubeFillPercentage: Math.max(0, (totalFillPercentage - intersectPoint) / (1 - intersectPoint))
property bool increasing: value > previousValue
property int previousValue: value

onValueChanged: {
increasing = value > previousValue;
previousValue = value;
}

Rectangle {
visible: thermometer.regen
id: lightningBackground
width: parent.width / 3
height: parent.height / 4
color: "white"
height: parent.height / 3
color: "black"
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: -parent.height / 20
radius: 20
radius: 0
rotation: -45
anchors.centerIn: parent
}

Rectangle {
id: topSemiCircle
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenter: outerRectangle.horizontalCenter
anchors.top: parent.top
width: parent.width / 4
height: parent.width / 4
radius: parent.width / 4
color: "white"
}

Rectangle {
id: outerRectangle
anchors.top: topSemiCircle.verticalCenter
anchors.bottom: bottomOuterCircle.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width / 4
height: parent.height / 2
color: "white"
width: parent.width / 3
height: parent.width / 5
radius: parent.width / 10
color: thermometer.color
}

Rectangle {
id: bottomOuterCircle
id: bottomCircle
anchors.horizontalCenter: parent.horizontalCenter
anchors.baselineOffset: outerRectangle.bottom - 400
y: parent.height / 2
width: thermometer.width / 2
height: thermometer.width / 2
radius: thermometer.width / 2
color: "white"
radius: width / 2
color: "black"
border.width: width * 0.15
border.color: thermometer.color
clip: true

Rectangle {
id: fillBottomCircle
id: innerFillCircle
width: parent.width - parent.border.width * 2
height: parent.height - parent.border.width * 2
radius: (parent.width - parent.border.width * 2) / 2
anchors.centerIn: parent
width: parent.width * 0.8
height: parent.height * 0.8
radius: parent.radius
color: thermometer.color
color: "black"
clip: true

Rectangle {
id: gradientFill
width: parent.width
height: innerFillCircle.height * circleFillPercentage
anchors.bottom: innerFillCircle.bottom
radius: innerFillCircle.radius
gradient: Gradient {
GradientStop { position: 0.0; color: thermometer.color }
GradientStop { position: 0.5; color: Qt.darker(thermometer.color, 1.5) }
GradientStop { position: 1.0; color: Qt.darker(thermometer.color, 2.5) }
}
}
}
}

Rectangle {
id: fillRectangle
anchors.fill: outerRectangle

anchors.leftMargin: thermometer.horizontalPadding
anchors.rightMargin: thermometer.horizontalPadding
id: outerRectangle
anchors.top: topSemiCircle.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width / 3
height: parent.height * .5
color: thermometer.color

Rectangle {
id: innerRectangle
width: parent.width / 1.75
height: parent.height
anchors {
centerIn: parent
verticalCenterOffset: topSemiCircle.height / 100
}
color: "black"
clip: true
}

Rectangle {
id: thermometerFill
width: innerRectangle.width
height: innerRectangle.height
anchors {
centerIn: innerRectangle
}
clip: true
color: "black"

Rectangle {
id: fillElement
width: parent.width
height: parent.height * tubeFillPercentage
anchors.bottom: parent.bottom
color: thermometer.color

Behavior on height {
NumberAnimation {
duration: 1000
easing.type: Easing.OutQuad
running: thermometer.totalFillPercentage > thermometer.intersectPoint && increasing
}
}

Behavior on height {
NumberAnimation {
duration: 1000
easing.type: Easing.InOutQuad
running: thermometer.totalFillPercentage <= thermometer.intersectPoint && !increasing
}
}
}
}
}

Lightning {
Expand Down
5 changes: 3 additions & 2 deletions NERODesign/content/ThermometerValueComponent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Rectangle {
property int horizontalIconSpacing: width * 0.1
property int labelVerticalSpacing: height * 0.1
property bool regen: false

color: 'transparent'
color: "transparent"
property string thermometerColor: "#FF0000"
height: 100
width: 100

Expand All @@ -29,6 +29,7 @@ Rectangle {
anchors.top: parent.top
anchors.right: parent.horizontalCenter
regen: thermometerComponent.regen
color: thermometerComponent.thermometerColor
}

ValueText {
Expand Down

0 comments on commit c4c553c

Please sign in to comment.