Commit ac68f26d authored by vikram's avatar vikram
Browse files

made few more changes suggested by mehra.

parent 7a6b2acf
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.1.2, 2014-11-08T13:20:07. -->
<!-- Written by QtCreator 3.1.2, 2014-11-10T12:47:27. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
......
......@@ -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
}
......
......@@ -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: 1e10
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
......
......@@ -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: "Sea Water"
Rectangle { property string recName: "Salt 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"
......
......@@ -122,7 +122,7 @@ Item {
Text {
id : nextText
text : "reset"
text : "Reset"
font.bold: true
anchors.fill : parent
anchors.centerIn: parent
......@@ -136,8 +136,8 @@ Item {
id : buttonMouseArea
anchors.fill: parent
onClicked : {
if(nextText.text == "next") {
nextText.text = "reset"
if(nextText.text == "Next") {
nextText.text = "Reset"
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 = "next"
nextText.text = "Next"
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()
......
......@@ -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)
......
......@@ -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.15
property double weight: 40
property double density: 1.14
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.54
property double density: 1.55
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: 500.00
property double density: 19.30
property double weight: 90.00
property double density: 15
property int horizontalSpacing: 20
property int verticalSpacing: 7
},
Rectangle { property string imgSource: "images/egg.png";
property string imgName: "Egg";
property double weight: 58
property double weight: 55
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
},
......
......@@ -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() {
......
......@@ -46,13 +46,6 @@ Item {
}
}
Text {
id : wightUnit
text: "Grams"
anchors.bottom: weightText.top
anchors.horizontalCenter: parent.horizontalCenter
}
Text {
id : weightText
width: weighingScaleArea.width
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment