Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
BalaSwecha
Density
Commits
ac68f26d
Commit
ac68f26d
authored
Nov 12, 2014
by
vikram
Browse files
made few more changes suggested by mehra.
parent
7a6b2acf
Changes
9
Hide whitespace changes
Inline
Side-by-side
Density.pro.user
View file @
ac68f26d
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.1.2, 2014-11-
08T13:20:0
7. -->
<!-- Written by QtCreator 3.1.2, 2014-11-
10T12:47:2
7. -->
<qtcreator>
<data>
<variable>
ProjectExplorer.Project.ActiveTarget
</variable>
...
...
qml/view/DensityWin.qml
View file @
ac68f26d
...
...
@@ -85,7 +85,7 @@ Item {
liquidArea
.
density
=
liqDensity
liquidArea
.
type
=
liquidText
.
text
if
(
liquidArea
.
color
!==
color
){
resultsGrid
.
addRow
(
droppedObject
.
imgName
,
liquidArea
.
type
,
liquidArea
.
density
,
droppedObject
.
getSinkStatus
(
liquidArea
.
density
))
resultsGrid
.
addRow
(
droppedObject
.
imgName
,
droppedObject
.
getDensity
(),
liquidArea
.
type
,
liquidArea
.
density
,
droppedObject
.
getSinkStatus
(
liquidArea
.
density
))
}
}
liquidArea
.
density
=
liqDensity
...
...
@@ -158,7 +158,7 @@ Item {
droppedObject
=
drag
.
source
droppedObject
.
changePosition
(
droppedObject
.
x
,
droppedObject
.
y
+
(
height
-
drag
.
y
-
getLiquidBottomToObjectTopHeight
(
liquidArea
.
density
)))
droppedObject
.
setState
(
"
inBeaker
"
)
resultsGrid
.
addRow
(
droppedObject
.
imgName
,
liquidArea
.
type
,
liquidArea
.
density
,
droppedObject
.
getSinkStatus
(
liquidArea
.
density
))
resultsGrid
.
addRow
(
droppedObject
.
imgName
,
droppedObject
.
getDensity
(),
liquidArea
.
type
,
liquidArea
.
density
,
droppedObject
.
getSinkStatus
(
liquidArea
.
density
))
setImageObject
(
droppedObject
)
}
onExited
:
{
...
...
@@ -182,10 +182,14 @@ Item {
liquidTypeArea
.
visible
=
false
}
function
reset
()
{
function
reset
(
force
)
{
liquidArea
.
height
=
liquidLevel
liquidArea
.
color
=
"
#006aff
"
liquidArea
.
opacity
=
0.3
if
(
force
===
true
)
{
liquidArea
.
color
=
"
#006aff
"
liquidArea
.
opacity
=
0.3
liquidArea
.
density
=
1
liquidArea
.
type
=
"
Water
"
}
droppedObject
=
null
}
...
...
qml/view/FormulaWin.qml
View file @
ac68f26d
...
...
@@ -24,8 +24,8 @@ Item {
Text
{
id
:
densityText
width
:
getTextWidth
(
"
Density
"
)
text
:
"
Density
"
width
:
getTextWidth
(
"
Density
(ρ)
"
)
text
:
"
Density
(ρ)
"
font.pixelSize
:
formulaArea
.
textHeight
font.bold
:
true
textFormat
:
TextEdit
.
AutoText
...
...
@@ -50,8 +50,8 @@ Item {
Text
{
id
:
massText
width
:
getTextWidth
(
"
Mass
"
)
text
:
"
Mass
"
width
:
getTextWidth
(
"
Mass
(m)
"
)
text
:
"
Mass
(m)
"
font.pixelSize
:
formulaArea
.
textHeight
font.bold
:
true
textFormat
:
TextEdit
.
AutoText
...
...
@@ -75,8 +75,8 @@ Item {
Text
{
id
:
volumeText
width
:
getTextWidth
(
"
Volume
"
)
text
:
"
Volume
"
width
:
getTextWidth
(
"
Volume
(v)
"
)
text
:
"
Volume
(v)
"
font.pixelSize
:
formulaArea
.
textHeight
font.bold
:
true
textFormat
:
TextEdit
.
AutoText
...
...
@@ -87,7 +87,7 @@ Item {
TextInput
{
id
:
densityInput
width
:
densityText
.
width
width
:
densityText
.
width
-
getTextWidth
(
"
gm/c
"
)
height
:
densityText
.
height
anchors
{
left
:
densityText
.
left
...
...
@@ -110,7 +110,7 @@ Item {
validator
:
DoubleValidator
{
bottom
:
0
top
:
1
e10
decimals
:
3
decimals
:
2
}
maximumLength
:
9
...
...
@@ -123,9 +123,27 @@ Item {
}
Text
{
id
:
densityResultUnits
height
:
densityInput
.
height
width
:
getTextWidth
(
"
gm/cm3
"
)
text
:
"
gm/cm3
"
color
:
"
black
"
anchors
{
left
:
densityInput
.
right
top
:
densityInput
.
top
}
font.pixelSize
:
formulaArea
.
textHeight
*
0.7
textFormat
:
TextEdit
.
AutoText
horizontalAlignment
:
Text
.
AlignLeft
verticalAlignment
:
Text
.
AlignVCenter
}
Text
{
id
:
massResultText
width
:
massText
.
width
width
:
massText
.
width
-
getTextWidth
(
"
gm
"
)
height
:
massText
.
height
text
:
"
0
"
font.pixelSize
:
formulaArea
.
textHeight
*
0.7
...
...
@@ -145,9 +163,26 @@ Item {
}
}
Text
{
id
:
massResultUnits
height
:
massResultText
.
height
width
:
getTextWidth
(
"
gm
"
)
text
:
"
gm
"
color
:
"
black
"
anchors
{
left
:
massResultText
.
right
top
:
massResultText
.
top
}
font.pixelSize
:
formulaArea
.
textHeight
*
0.7
textFormat
:
TextEdit
.
AutoText
horizontalAlignment
:
Text
.
AlignLeft
verticalAlignment
:
Text
.
AlignVCenter
}
Text
{
id
:
volumeResultText
width
:
volumeText
.
width
width
:
volumeText
.
width
-
getTextWidth
(
"
cm3
"
)
height
:
volumeText
.
height
text
:
"
0
"
font.pixelSize
:
formulaArea
.
textHeight
*
0.7
...
...
@@ -167,6 +202,24 @@ Item {
}
}
Text
{
id
:
volumeResultUnits
height
:
volumeResultText
.
height
width
:
getTextWidth
(
"
cm3
"
)
text
:
"
cm3
"
color
:
"
black
"
anchors
{
left
:
volumeResultText
.
right
top
:
volumeResultText
.
top
}
font.pixelSize
:
formulaArea
.
textHeight
*
0.7
textFormat
:
TextEdit
.
AutoText
horizontalAlignment
:
Text
.
AlignLeft
verticalAlignment
:
Text
.
AlignVCenter
}
function
getTextWidth
(
text
)
{
return
(
text
.
length
)
*
(
formulaArea
.
textHeight
*
0.8
)
}
...
...
@@ -182,10 +235,9 @@ Item {
function
densityMatching
()
{
if
(
Number
(
densityInput
.
text
)
>
0
&&
Number
(
massResultText
.
text
)
>
0
&&
Number
(
volumeResultText
.
text
)
>
0
)
{
var
calculatedDensity
=
Number
(
massResultText
.
text
)
/
Number
(
volumeResultText
.
text
)
calculatedDensity
.
toPrecision
(
5
)
calculatedDensity
=
Math
.
floor
((
calculatedDensity
*
10
*
10
))
/
100
var
inputDensity
=
Number
(
densityInput
.
text
)
inputDensity
.
toPrecision
(
5
)
if
(
Math
.
abs
(
inputDensity
-
calculatedDensity
)
<=
0.019
)
if
(
inputDensity
==
calculatedDensity
)
return
true
}
return
false
...
...
qml/view/LiquidTypeList.qml
View file @
ac68f26d
...
...
@@ -11,17 +11,17 @@ Item {
Rectangle
{
property
string
recName
:
"
Oil
"
property
string
recColor
:
"
yellow
"
property
double
recOpacity
:
1
property
double
recDensity
:
1.6
property
double
recDensity
:
0.84
},
Rectangle
{
property
string
recName
:
"
Petrol
"
Rectangle
{
property
string
recName
:
"
Honey
"
property
string
recColor
:
"
gold
"
property
double
recOpacity
:
1
property
double
recDensity
:
1
property
double
recDensity
:
1
.42
},
Rectangle
{
property
string
recName
:
"
S
e
a Water
"
Rectangle
{
property
string
recName
:
"
Sa
lt
Water
"
property
string
recColor
:
"
slateblue
"
property
double
recOpacity
:
1
property
double
recDensity
:
1.
025
property
double
recDensity
:
1.
2
},
Rectangle
{
property
string
recName
:
"
Corn Syrup
"
property
string
recColor
:
"
teal
"
...
...
qml/view/Main.qml
View file @
ac68f26d
...
...
@@ -122,7 +122,7 @@ Item {
Text
{
id
:
nextText
text
:
"
r
eset
"
text
:
"
R
eset
"
font.bold
:
true
anchors.fill
:
parent
anchors.centerIn
:
parent
...
...
@@ -136,8 +136,8 @@ Item {
id
:
buttonMouseArea
anchors.fill
:
parent
onClicked
:
{
if
(
nextText
.
text
==
"
n
ext
"
)
{
nextText
.
text
=
"
r
eset
"
if
(
nextText
.
text
==
"
N
ext
"
)
{
nextText
.
text
=
"
R
eset
"
showWeightVolumeExperiment
(
true
)
}
else
{
reset
(
true
)
...
...
@@ -191,10 +191,10 @@ Item {
function
showDensityExperiment
(
force
)
{
weightArea
.
visible
=
false
volArea
.
visible
=
false
densityArea
.
reset
()
densityArea
.
reset
(
force
)
densityArea
.
visible
=
true
densityArea
.
show
()
nextText
.
text
=
"
n
ext
"
nextText
.
text
=
"
N
ext
"
if
(
activeImageObject
!==
null
)
{
densityArea
.
cellIndex
=
activeImageObject
.
getCellNumber
()
...
...
@@ -210,6 +210,7 @@ Item {
volArea
.
reset
()
weightArea
.
visible
=
true
volArea
.
visible
=
true
densityArea
.
reset
(
true
)
densityArea
.
visible
=
false
densityArea
.
hide
()
formulaArea
.
reset
()
...
...
qml/view/ObjImage.qml
View file @
ac68f26d
...
...
@@ -116,7 +116,7 @@ Item {
}
function
getCalculatedVolume
()
{
return
(
weight
/
density
).
toFixed
(
2
);
return
(
weight
/
density
).
toFixed
();
}
function
getVolume
()
{
...
...
@@ -174,6 +174,9 @@ Item {
return
objImgId
.
parent
.
getNewObject
(
qmlStr
)
}
function
getDensity
()
{
return
density
}
function
parentReset
(
force
)
{
objImgId
.
parent
.
parentReset
(
force
)
...
...
qml/view/ObjectList.qml
View file @
ac68f26d
...
...
@@ -6,8 +6,8 @@ import QtQuick 2.0
property
list
<
Rectangle
>
objPropertiesList
:
[
Rectangle
{
property
string
imgSource
:
"
images/golf-ball.png
"
;
property
string
imgName
:
"
Golf Ball
"
;
property
double
weight
:
40
.96
property
double
density
:
1.1
5
property
double
weight
:
40
property
double
density
:
1.1
4
property
int
horizontalSpacing
:
20
property
int
verticalSpacing
:
10
...
...
@@ -15,14 +15,14 @@ import QtQuick 2.0
Rectangle
{
property
string
imgSource
:
"
images/cotton-ball.png
"
;
property
string
imgName
:
"
Cotton Ball
"
;
property
double
weight
:
70.00
property
double
density
:
1.5
4
property
double
density
:
1.5
5
property
int
horizontalSpacing
:
15
property
int
verticalSpacing
:
12
},
Rectangle
{
property
string
imgSource
:
"
images/pingpong-ball.png
"
;
property
string
imgName
:
"
Pingpong Ball
"
;
property
double
weight
:
2
.4
property
double
weight
:
2
property
double
density
:
0.1
property
int
horizontalSpacing
:
20
property
int
verticalSpacing
:
10
...
...
@@ -30,14 +30,14 @@ import QtQuick 2.0
},
Rectangle
{
property
string
imgSource
:
"
images/gold-nugget.png
"
;
property
string
imgName
:
"
Gold Nugget
"
;
property
double
weight
:
50
0.00
property
double
density
:
1
9.30
property
double
weight
:
9
0.00
property
double
density
:
1
5
property
int
horizontalSpacing
:
20
property
int
verticalSpacing
:
7
},
Rectangle
{
property
string
imgSource
:
"
images/egg.png
"
;
property
string
imgName
:
"
Egg
"
;
property
double
weight
:
5
8
property
double
weight
:
5
5
property
double
density
:
1.1
property
int
horizontalSpacing
:
40
property
int
verticalSpacing
:
5
...
...
@@ -66,8 +66,8 @@ import QtQuick 2.0
},
Rectangle
{
property
string
imgSource
:
"
images/coin.png
"
;
property
string
imgName
:
"
coin
"
;
property
double
weight
:
2.
5
property
double
density
:
7.18
property
double
weight
:
5
property
double
density
:
5
property
int
horizontalSpacing
:
10
property
int
verticalSpacing
:
5
},
...
...
qml/view/ResultsView.qml
View file @
ac68f26d
...
...
@@ -12,8 +12,9 @@ Item {
anchors.fill
:
resultsTable
TableViewColumn
{
role
:
"
objectName
"
;
title
:
"
Object Name
"
;
width
:
resultsTable
.
width
/
4
;
}
TableViewColumn
{
role
:
"
liquidType
"
;
title
:
"
Liquid Type
"
;
width
:
resultsTable
.
width
/
4
}
TableViewColumn
{
role
:
"
liquidDensity
"
;
title
:
"
Liquid Density
"
;
width
:
resultsTable
.
width
/
4
}
TableViewColumn
{
role
:
"
objectDensity
"
;
title
:
"
ρ(Object)
"
;
width
:
resultsTable
.
width
/
6
;
}
TableViewColumn
{
role
:
"
liquidType
"
;
title
:
"
Liquid Type
"
;
width
:
resultsTable
.
width
/
5
}
TableViewColumn
{
role
:
"
liquidDensity
"
;
title
:
"
ρ(Liquid)
"
;
width
:
resultsTable
.
width
/
6
}
TableViewColumn
{
role
:
"
observation
"
title
:
"
Observation
"
...
...
@@ -23,7 +24,7 @@ Item {
model
:
resultsModel
}
function
addRow
(
objectName
,
liquidType
,
liquidDensity
,
observation
)
{
function
addRow
(
objectName
,
objectDensity
,
liquidType
,
liquidDensity
,
observation
)
{
for
(
var
index
=
0
;
index
<
resultsModel
.
count
;
index
++
)
{
var
row
=
resultsModel
.
get
(
index
)
if
(
row
.
objectName
===
objectName
&&
row
.
liquidType
===
liquidType
&&
row
.
observation
===
observation
)
{
...
...
@@ -31,7 +32,7 @@ Item {
}
}
resultsModel
.
append
({
objectName
:
objectName
,
liquidType
:
liquidType
,
liquidDensity
:
liquidDensity
,
observation
:
observation
})
resultsModel
.
append
({
objectName
:
objectName
,
objectDensity
:
objectDensity
,
liquidType
:
liquidType
,
liquidDensity
:
liquidDensity
,
observation
:
observation
})
}
function
reset
()
{
...
...
qml/view/WeightWin.qml
View file @
ac68f26d
...
...
@@ -46,13 +46,6 @@ Item {
}
}
Text
{
id
:
wightUnit
text
:
"
Grams
"
anchors.bottom
:
weightText
.
top
anchors.horizontalCenter
:
parent
.
horizontalCenter
}
Text
{
id
:
weightText
width
:
weighingScaleArea
.
width
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment