Commit 7c6782b1 authored by rahulde's avatar rahulde

Fixed Build Logic

parent 3cc152fc
......@@ -3,25 +3,22 @@
JSONReader::JSONReader(QObject *parent) : QObject(parent) {}
QString JSONReader::read() {
jsonFile = jsonFile.replace("file://", "");
if (jsonFile == "")
return QString();
if (jsonFile.isEmpty()) {
emit error("source is empty");
return QString();
}
jsonFile = jsonFile.replace("file://", "");
QFile file(jsonFile);
QString fileContent;
if (file.open(QIODevice::ReadOnly)) {
QString line;
QTextStream t(&file);
do {
line = t.readLine();
fileContent += line;
} while (!line.isNull());
fileContent = t.readAll();
file.close();
} else {
emit error("Unable to open the file");
......
......@@ -118,7 +118,7 @@ RowLayout {
x: 400
y: 630
onClicked: {
stack.push(modeSelection)
stack.push(modeSelection);
}
}
}
......@@ -128,10 +128,36 @@ RowLayout {
width: parent.width / 2
height: parent.height
anchors.right: parent.right
Drag.active: true
property string droppedOrgan
Drag.active: false
property variant droppedOrgans: ({})
property variant organs: []
property int droppedX
property int droppedY
property string wrongAnwserColor: "red"
property string correctAnwserColor: "green"
property variant labelColorSheet: {
"mouth": wrongAnwserColor,
"oesophagus": wrongAnwserColor,
"liver": wrongAnwserColor,
"stomach": wrongAnwserColor,
"small_intestine": wrongAnwserColor,
"large_intestine": wrongAnwserColor,
"anus": wrongAnwserColor,
"pancreas": wrongAnwserColor,
"gall_bladder": wrongAnwserColor
}
property variant organsLabelSheet: {
"mouth": "Mouth",
"oesophagus": "Oesophagus",
"liver": "Liver",
"stomach": "Stomach",
"small_intestine": "Small Intestine",
"large_intestine": "Large Intestine",
"anus": "Anus",
"pancreas": "Pancreas",
"gall_bladder": "Gall Bladder"
}
Text {
id: dropAreaText
......@@ -143,15 +169,9 @@ RowLayout {
}
onDropped: {
var droppedOrgan = drag.source.organ,
droppedX = drag.x,
droppedY = drag.y,
refX = referenceCoordinates[droppedOrgan].coordinates.x,
refY = referenceCoordinates[droppedOrgan].coordinates.y,
threshold = 10; // needs to be verified
if ((droppedX <= refX + threshold) || (droppedX >= refX - threshold) && (droppedY <= refY + threshold) || (droppedY >= refY - threshold))
organMatches++;
droppedOrgans[drag.source.organ] = {};
droppedOrgans[drag.source.organ].x = drag.x;
droppedOrgans[drag.source.organ].y = drag.y;
}
Image {
......@@ -174,7 +194,6 @@ RowLayout {
dragOrgans: false
displayOrganLabel: true
opacity: 0
property string clickedOrgan
}
Text {
......@@ -189,8 +208,7 @@ RowLayout {
Button {
id: feedbackButton
style: Components.ButtonStyle {
}
style: Components.ButtonStyle {}
text: "Feedback"
x: 0
y: 670
......@@ -199,20 +217,23 @@ RowLayout {
onClicked: {
if (feedbackButton.text == "Reset") {
stack.push(buildSelection)
stack.push(buildSelection);
} else {
if (root.organMatches >= numberOfOrgans) {
feedbackText.color = "green"
feedbackText.text += "Good job! You have learnt the "
+ root.organSystem + "!"
dropAreaText.color = "green"
} else {
workSpaceOrgansList.opacity = 1
buildSpaceOrgansList.opacity = 0.2
feedbackText.text += "Check what you got wrong"
dropAreaText.color = "red"
for (var organ in dropArea.droppedOrgans) {
var dX = dropArea.droppedOrgans[organ].x,
dY = dropArea.droppedOrgans[organ].y,
rX = root.referenceCoordinates[organ].coordinates.x,
rY = root.referenceCoordinates[organ].coordinates.y,
limit = 30; // Needs to be checked.
if (((dX >= rX - limit) && (dX < rX + limit)) && ((dY >= rY - limit) && (dY < rY + limit)))
dropArea.labelColorSheet[organ] = dropArea.correctAnwserColor;
}
workSpaceOrgansList.labelColorSheet = dropArea.labelColorSheet;
workSpaceOrgansList.opacity = 1
buildSpaceOrgansList.opacity = 0.2
feedbackButton.text = "Reset"
dropArea.feedbackReset()
}
......@@ -231,8 +252,9 @@ RowLayout {
Component.onCompleted: {
referenceCoordinates = JSON.parse(myFile.read());
for (var key in referenceCoordinates)
if(referenceCoordinates.hasOwnProperty(key))
numberOfOrgans++;
for (var key in referenceCoordinates) {
if (referenceCoordinates.hasOwnProperty(key))
dropArea.organs.push(key);
}
}
}
......@@ -23,8 +23,7 @@ RowLayout {
organs: root.organs
organism: root.organism
organSystem: root.organSystem
}
}
}
Component {
......@@ -50,6 +49,6 @@ RowLayout {
// }
}
}
}
}
......@@ -122,10 +122,38 @@ RowLayout {
width: parent.width / 2
height: parent.height
anchors.right: parent.right
Drag.active: true
property string droppedOrgan
Drag.active: false
property variant droppedOrgans: ({})
property variant organs: []
property int droppedX
property int droppedY
property string wrongAnwserColor: "red"
property string correctAnwserColor: "green"
property variant labelColorSheet: {
"bronchi_left": root.wrongAnwserColor,
"bronchi_right": root.wrongAnwserColor,
"bronchioles": root.wrongAnwserColor,
"diaphragm":root.wrongAnwserColor,
"epiglottis": root.wrongAnwserColor,
"lungs" :root.wrongAnwserColor,
"nose": root.wrongAnwserColor,
"oral_cavity": root.wrongAnwserColor,
"ribs" : root.wrongAnwserColor,
"trachea": root.wrongAnwserColor
}
property variant organsLabelSheet: {
"bronchi_left": "Bronchi Left" ,
"bronchi_right": "Bronchi Right" ,
"bronchioles":"Bronchioles" ,
"diaphragm": "Diaphragm",
"epiglottis": "Epiglottis" ,
"lungs" : "Lungs" ,
"nose": "Nose",
"oral_cavity": "Oral Cavity" ,
"ribs" : "Ribs" ,
"trachea": "Trachea"
}
Text {
id: dropAreaText
......@@ -137,15 +165,9 @@ RowLayout {
}
onDropped: {
var droppedOrgan = drag.source.organ,
droppedX = drag.x,
droppedY = drag.y,
refX = referenceCoordinates[droppedOrgan].coordinates.x,
refY = referenceCoordinates[droppedOrgan].coordinates.y,
threshold = 10; // needs to be verified
if ((droppedX <= refX + threshold) || (droppedX >= refX - threshold) && (droppedY <= refY + threshold) || (droppedY >= refY - threshold))
organMatches++;
droppedOrgans[drag.source.organ] = {};
droppedOrgans[drag.source.organ].x = drag.x;
droppedOrgans[drag.source.organ].y = drag.y;
}
Image {
......@@ -153,8 +175,8 @@ RowLayout {
anchors {
left: parent.left
top: parent.top
leftMargin: 0
topMargin: 28
leftMargin: -45
topMargin: -20
}
source: _organismsDataDirectory + "/" + root.organism + "/" + root.organSystem + "/background.png"
z: -2
......@@ -168,7 +190,6 @@ RowLayout {
dragOrgans: false
displayOrganLabel: true
opacity: 0
property string clickedOrgan
}
Text {
......@@ -183,8 +204,7 @@ RowLayout {
Button {
id: feedbackButton
style: Components.ButtonStyle {
}
style: Components.ButtonStyle {}
text: "Feedback"
x: 0
y: 670
......@@ -193,19 +213,23 @@ RowLayout {
onClicked: {
if (feedbackButton.text == "Reset") {
stack.push(buildSelection)
stack.push(buildSelection);
} else {
if (root.organMatches >= numberOfOrgans) {
feedbackText.color = "green"
feedbackText.text += "Good job! You have learnt the " + root.organSystem + "!"
dropAreaText.color = "green"
} else {
workSpaceOrgansList.opacity = 1
buildSpaceOrgansList.opacity = 0.2
feedbackText.text += "Check what you got wrong"
dropAreaText.color = "red"
for (var organ in dropArea.droppedOrgans) {
var dX = dropArea.droppedOrgans[organ].x,
dY = dropArea.droppedOrgans[organ].y,
rX = root.referenceCoordinates[organ].coordinates.x,
rY = root.referenceCoordinates[organ].coordinates.y,
limit = 30; // Needs to be checked.
if (((dX >= rX - limit) && (dX < rX + limit)) && ((dY >= rY - limit) && (dY < rY + limit)))
dropArea.labelColorSheet[organ] = dropArea.correctAnwserColor;
}
workSpaceOrgansList.labelColorSheet = dropArea.labelColorSheet;
workSpaceOrgansList.opacity = 1
buildSpaceOrgansList.opacity = 0.2
feedbackButton.text = "Reset"
dropArea.feedbackReset()
}
......
Markdown is supported
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