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
e2a6e425
Commit
e2a6e425
authored
Nov 13, 2014
by
vikram
Browse files
added bubbles for navigation.
parent
ac68f26d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Density.pro.user
View file @
e2a6e425
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.1.2, 2014-11-1
0
T1
2
:4
7:27
. -->
<!-- Written by QtCreator 3.1.2, 2014-11-1
3
T1
5
:4
1:02
. -->
<qtcreator>
<data>
<variable>
ProjectExplorer.Project.ActiveTarget
</variable>
...
...
qml.qrc
View file @
e2a6e425
...
...
@@ -26,5 +26,7 @@
<file>QML/view/images/weighing_scale1.png</file>
<file>QML/view/images/wooden-block.png</file>
<file>main.cpp</file>
<file>QML/view/Note.qml</file>
<file>QML/view/images/note.png</file>
</qresource>
</RCC>
qml/view/DensityWin.qml
View file @
e2a6e425
...
...
@@ -6,6 +6,7 @@ Item {
property
ObjImage
droppedObject
property
double
beakerPointHt
:
(
densityExperimentArea
.
height
/
1.20
)
/
50
property
double
liquidLevel
:
30
*
beakerPointHt
property
Note
note
:
null
Image
{
id
:
densityExperimentArea
...
...
@@ -19,6 +20,31 @@ Item {
}
}
Item
{
id
:
noteBeaker
width
:
200
height
:
100
anchors
{
top
:
densityExperimentArea
.
bottom
left
:
densityExperimentArea
.
left
topMargin
:
-
30
leftMargin
:
40
}
function
showNote
()
{
note
=
Qt
.
createQmlObject
(
"
Note{
\n
"
+
"
rotation : 180
\n
"
+
"
textTopMargin: 10
\n
"
+
"
textLeftMargin: 40
\n
"
+
"
textWidth: 100
\n
"
+
"
textHeight: 100
\n
"
+
"
anchors.fill: parent
\n
"
+
"
text :
\"
Drop the object into beaker.
\"
}
\n
"
,
noteBeaker
,
"
note
"
)
}
}
Item
{
id
:
liquidTypeArea
width
:
(
1.1
*
densityWin
.
width
)
/
10
...
...
@@ -100,6 +126,31 @@ Item {
}
}
Item
{
id
:
noteLiquid
width
:
200
height
:
100
anchors
{
top
:
liquidTypeArea
.
bottom
left
:
liquidTypeArea
.
left
topMargin
:
-
70
leftMargin
:
-
30
}
function
showNote
()
{
note
=
Qt
.
createQmlObject
(
"
Note{
\n
"
+
"
rotation : 180
\n
"
+
"
textTopMargin: 10
\n
"
+
"
textLeftMargin: 40
\n
"
+
"
textWidth: 100
\n
"
+
"
textHeight: 100
\n
"
+
"
anchors.fill: parent
\n
"
+
"
text :
\"
Choose another liquid.
\"
}
\n
"
,
noteLiquid
,
"
note
"
)
}
}
ResultsView
{
id
:
resultsGrid
width
:
(
5
*
densityWin
.
width
)
/
10
...
...
@@ -201,4 +252,17 @@ Item {
return
liquidArea
.
height
+
objectFloatHt
}
}
function
getNote
()
{
if
(
note
!==
null
)
{
note
.
destroy
()
note
=
null
}
if
(
droppedObject
===
null
)
noteBeaker
.
showNote
()
else
noteLiquid
.
showNote
()
return
note
}
}
qml/view/FormulaWin.qml
View file @
e2a6e425
...
...
@@ -4,6 +4,7 @@ import QtQuick.Controls.Styles 1.2
Item
{
id
:
formulaArea
property
int
textHeight
:
height
/
6
property
Note
note
:
null
Rectangle
{
id
:
topEmptyArea
...
...
@@ -89,6 +90,7 @@ Item {
id
:
densityInput
width
:
densityText
.
width
-
getTextWidth
(
"
gm/c
"
)
height
:
densityText
.
height
property
int
numTrails
:
0
anchors
{
left
:
densityText
.
left
top
:
densityText
.
bottom
...
...
@@ -114,15 +116,62 @@ Item {
}
maximumLength
:
9
onTextChanged
:
{
if
(
densityMatching
())
{
showDensityExperiment
(
true
)
readOnly
=
true
// Keys.onEnterPressed: {
// }
Keys.onReturnPressed
:
{
if
(
Number
(
densityInput
.
text
)
>
0
&&
Number
(
massResultText
.
text
)
>
0
&&
Number
(
volumeResultText
.
text
)
>
0
)
{
numTrails
++
if
(
numTrails
<=
3
)
{
if
(
densityMatching
())
{
showDensityExperiment
(
true
)
readOnly
=
true
numTrails
=
0
}
else
{
var
msg
=
"
Try again
"
if
(
numTrails
===
2
)
msg
+=
"
. Last chance.
"
else
if
(
numTrails
===
3
)
{
numTrails
=
0
parentReset
()
}
noteCalulcateDensity
.
showNote
(
msg
)
}
}
}
}
}
Item
{
id
:
noteCalulcateDensity
property
string
initialComment
:
"
Calculate the density. Press Enter key.
"
width
:
170
height
:
100
anchors
{
top
:
densityInput
.
bottom
left
:
densityInput
.
left
leftMargin
:
-
30
}
function
showNote
(
text
)
{
if
(
note
!==
null
)
note
.
text
=
text
else
{
note
=
Qt
.
createQmlObject
(
"
Note{
\n
"
+
"
rotation : 180
\n
"
+
"
textTopMargin: 10
\n
"
+
"
textLeftMargin: 30
\n
"
+
"
textWidth: 100
\n
"
+
"
textHeight: 100
\n
"
+
"
anchors.fill: parent
\n
"
+
"
text :
\"
"
+
text
+
"
\"
}
\n
"
,
noteCalulcateDensity
,
"
note
"
)
}
}
}
Text
{
id
:
densityResultUnits
height
:
densityInput
.
height
...
...
@@ -243,7 +292,29 @@ Item {
return
false
}
function
getWeight
()
{
return
massResultText
.
text
}
function
getVolume
()
{
return
volumeResultText
.
text
}
function
getDensity
()
{
return
densityInput
.
text
}
function
getNote
()
{
noteCalulcateDensity
.
showNote
(
noteCalulcateDensity
.
initialComment
)
return
note
}
function
parentReset
()
{
resetAll
(
true
)
}
function
reset
()
{
densityInput
.
numTrails
=
0
densityInput
.
text
=
"
0
"
massResultText
.
text
=
"
0
"
volumeResultText
.
text
=
"
0
"
...
...
qml/view/Main.qml
View file @
e2a6e425
...
...
@@ -9,7 +9,7 @@ Item {
Rectangle
{
anchors.fill
:
parent
color
:
"
#
49B
AB
6
"
color
:
"
#
55AD
AB
"
z
:
0
}
...
...
@@ -17,6 +17,7 @@ Item {
property
int
secondRowHeight
:
height
/
5
property
int
thirdRowHeight
:
(
height
-
firstRowHeight
-
secondRowHeight
)
*
0.8
property
int
fourthRowHeight
:
height
-
firstRowHeight
-
secondRowHeight
-
thirdRowHeight
property
Note
note
property
ObjectCollectionWin
objGrid
ObjectList
{
...
...
@@ -37,7 +38,7 @@ Item {
}
if
(
dropCatched
===
false
&&
drag
.
source
!==
null
)
{
reset
(
true
)
reset
All
(
true
)
}
dropCatched
=
false
}
...
...
@@ -57,6 +58,33 @@ Item {
reCreateGridObject
(
-
1
)
}
Item
{
id
:
noteObject
width
:
200
height
:
100
anchors
{
top
:
objectArea
.
bottom
left
:
objectArea
.
left
leftMargin
:
-
10
topMargin
:
-
5
}
Component.onCompleted
:
showNote
()
function
showNote
()
{
note
=
Qt
.
createQmlObject
(
"
Note{
\n
"
+
"
rotation : 200
\n
"
+
"
textTopMargin: 5
\n
"
+
"
textLeftMargin: 50
\n
"
+
"
textWidth: 100
\n
"
+
"
textHeight: 100
\n
"
+
"
anchors.fill: parent
\n
"
+
"
text :
\"
Drag an object
\"
}
\n
"
,
noteObject
,
"
note
"
)
}
}
FormulaWin
{
id
:
formulaArea
height
:
secondRowHeight
...
...
@@ -81,6 +109,30 @@ Item {
}
}
Item
{
id
:
noteWeight
width
:
150
height
:
200
anchors
{
bottom
:
weightArea
.
bottom
left
:
weightArea
.
right
leftMargin
:
-
30
}
function
showNote
()
{
note
=
Qt
.
createQmlObject
(
"
Note{
\n
"
+
"
rotation : 100
\n
"
+
"
textTopMargin: 50
\n
"
+
"
textLeftMargin: 40
\n
"
+
"
textWidth: 100
\n
"
+
"
textHeight: 100
\n
"
+
"
anchors.fill: parent
\n
"
+
"
text :
\"
Drop the object to measure the mass
\"
}
\n
"
,
noteWeight
,
"
note
"
)
}
}
VolumeWin
{
id
:
volArea
height
:
thirdRowHeight
...
...
@@ -92,6 +144,30 @@ Item {
}
}
Item
{
id
:
noteVolume
width
:
160
height
:
160
anchors
{
bottom
:
volArea
.
bottom
left
:
volArea
.
right
leftMargin
:
-
50
}
function
showNote
()
{
note
=
Qt
.
createQmlObject
(
"
Note{
\n
"
+
"
rotation : 100
\n
"
+
"
textTopMargin: 30
\n
"
+
"
textLeftMargin: 45
\n
"
+
"
textWidth: 100
\n
"
+
"
textHeight: 100
\n
"
+
"
anchors.fill: parent
\n
"
+
"
text :
\"
Drag and drop the object to record the volume
\"
}
\n
"
,
noteVolume
,
"
note
"
)
}
}
DensityWin
{
id
:
densityArea
property
int
cellIndex
:
-
1
...
...
@@ -139,8 +215,11 @@ Item {
if
(
nextText
.
text
==
"
Next
"
)
{
nextText
.
text
=
"
Reset
"
showWeightVolumeExperiment
(
true
)
if
(
note
!==
null
)
note
.
destroy
()
noteObject
.
showNote
()
}
else
{
reset
(
true
)
reset
All
(
true
)
}
}
}
...
...
@@ -151,6 +230,7 @@ Item {
function
setImageObject
(
imageObj
)
{
dropCatched
=
true
activeImageObject
=
imageObj
showNote
()
}
function
setVolume
(
volume
)
{
...
...
@@ -180,15 +260,22 @@ Item {
"
}
\n
"
,
mainWin
,
"
objArea
"
)
}
function
reset
(
force
)
{
function
reset
All
(
force
)
{
if
(
densityArea
.
visible
==
true
)
{
showDensityExperiment
(
force
)
}
else
{
showWeightVolumeExperiment
(
force
)
}
if
(
note
!==
null
)
note
.
destroy
()
noteObject
.
showNote
()
}
function
showDensityExperiment
(
force
)
{
if
(
note
!==
null
)
note
.
destroy
()
noteObject
.
showNote
()
weightArea
.
visible
=
false
volArea
.
visible
=
false
densityArea
.
reset
(
force
)
...
...
@@ -221,5 +308,37 @@ Item {
activeImageObject
=
null
}
function
showNote
()
{
if
(
note
!==
null
)
note
.
destroy
()
note
=
null
if
(
activeImageObject
!==
null
)
{
var
state
=
activeImageObject
.
getState
()
if
(
state
==
"
inGrid
"
)
{
noteWeight
.
showNote
()
}
else
if
(
state
==
"
inWeight
"
)
{
if
(
Number
(
formulaArea
.
getVolume
())
>
0
)
{
note
=
formulaArea
.
getNote
()
}
else
{
noteVolume
.
showNote
()
}
}
else
if
(
state
==
"
inVolume
"
)
{
if
(
Number
(
formulaArea
.
getWeight
())
>
0
)
{
note
=
formulaArea
.
getNote
()
}
else
{
noteWeight
.
showNote
()
}
}
else
if
(
state
==
"
inBeaker
"
)
{
note
=
densityArea
.
getNote
()
}
}
else
{
if
(
densityArea
.
visible
===
true
)
note
=
densityArea
.
getNote
()
else
noteWeight
.
showNote
()
}
}
}
qml/view/Note.qml
0 → 100644
View file @
e2a6e425
import
QtQuick
2.2
Item
{
id
:
note
property
int
rotation
:
0
property
string
text
:
""
property
int
textTopMargin
:
0
property
int
textLeftMargin
:
0
property
int
textWidth
:
0
property
int
textHeight
:
0
Image
{
anchors.fill
:
parent
source
:
"
images/note.png
"
rotation
:
parent
.
rotation
opacity
:
0.8
}
TextEdit
{
width
:
parent
.
textWidth
height
:
parent
.
textHeight
anchors
{
left
:
note
.
left
top
:
note
.
top
topMargin
:
parent
.
textTopMargin
leftMargin
:
parent
.
textLeftMargin
}
text
:
note
.
text
wrapMode
:
TextEdit
.
WordWrap
horizontalAlignment
:
Text
.
AlignHCenter
verticalAlignment
:
Text
.
AlignVCenter
readOnly
:
true
}
}
qml/view/ObjImage.qml
View file @
e2a6e425
...
...
@@ -49,6 +49,7 @@ Item {
if
(
objImgId
.
state
==
"
inGrid
"
)
{
parentReset
(
false
)
}
objectPressed
()
}
onReleased
:
{
...
...
@@ -178,10 +179,18 @@ Item {
return
density
}
function
getState
()
{
return
state
}
function
parentReset
(
force
)
{
objImgId
.
parent
.
parentReset
(
force
)
}
function
objectPressed
()
{
parent
.
objectPressed
()
}
function
reset
()
{
}
...
...
qml/view/ObjectCollectionWin.qml
View file @
e2a6e425
...
...
@@ -55,9 +55,17 @@ Item {
"
objImgId
"
);
}
function
objectPressed
()
{
parent
.
objectPressed
()
}
}
function
parentReset
(
force
)
{
reset
(
force
)
reset
All
(
force
)
}
function
objectPressed
()
{
showNote
()
}
}
qml/view/images/note.png
0 → 100644
View file @
e2a6e425
1.26 KB
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