Commit 72489ad8 authored by rahulde's avatar rahulde

Build implemented for Digestive System

parent 12f9e29c
#include "imagemousearea.h"
#include <QImage>
ImageMouseArea::ImageMouseArea(QQuickItem *parent) : QQuickItem(parent)
{
ImageMouseArea::ImageMouseArea(QQuickItem *parent) : QQuickItem(parent) {
setAcceptedMouseButtons(Qt::LeftButton);
setClip(true);
}
bool ImageMouseArea::contains(const QPointF &point) const
{
bool ImageMouseArea::contains(const QPointF &point) const {
auto newString = m_imageName;
QImage image(newString.replace("file://", ""));
return image.rect().contains(point.toPoint()) && qAlpha(image.pixel(point.toPoint())) > 0;
}
void ImageMouseArea::mousePressEvent(QMouseEvent *event)
{
void ImageMouseArea::mousePressEvent(QMouseEvent *event) {
emit clicked();
event->accept();
}
......@@ -3,8 +3,7 @@
#include <QQuickItem>
class ImageMouseArea : public QQuickItem
{
class ImageMouseArea : public QQuickItem {
Q_OBJECT
Q_PROPERTY(QString imageName READ imageName WRITE setImageName)
......
......@@ -5,8 +5,7 @@
#include <QFile>
#include <QTextStream>
class JSONReader : public QObject
{
class JSONReader : public QObject {
Q_OBJECT
public:
explicit JSONReader(QObject *parent = 0);
......
......@@ -5,8 +5,7 @@
#include <QtQml>
#include <jsonreader.h>
int main(int argc, char *argv[])
{
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
qmlRegisterType<ImageMouseArea>("org.swecha.humanatlas", 1, 0, "ImageMouseArea");
......
......@@ -2,7 +2,7 @@ import QtQuick 2.0
import QtQuick.Layouts 1.1
import QtWebKit 3.0
import QtQuick.Controls 1.2
import QtQuick.LocalStorage 2.0
import JSONReader 1.0
import components 1.0 as Components
......@@ -12,41 +12,107 @@ RowLayout {
property string organSystem
property string currentOrgan
property int organMatches: 0
property variant coordinatesSheet: {"liver": {"x": 50, "y": 50, "z": 1},
"intestine": {"x": 50, "y": 300},
"stomach": {"x": 50, "y": 200}
}
property int numberOfOrgans: 0
property variant referenceCoordinates
property variant coordinatesSheet: {
"mouth": {
"coordinates": {
"x": 0,
"y": 0,
"z": 1
}
},
"oesophagus": {
"coordinates": {
"x": 0,
"y": 0,
"z": 1
}
},
"liver": {
"coordinates": {
"x": 0,
"y": 0,
"z": -1
}
},
"stomach": {
"coordinates": {
"x": 0,
"y": 0
}
},
"small_intestine": {
"coordinates": {
"x": 0,
"y": 0,
"z": 2
}
},
"large_intestine": {
"coordinates": {
"x": 0,
"y": 0,
"z": 1
}
},
"anus": {
"coordinates": {
"x": 0,
"y": 0,
"z": 1
}
},
"pancreas": {
"coordinates": {
"x": 0,
"y": 0,
"z": -1
}
},
"gall_bladder": {
"coordinates": {
"x": 0,
"y": 0,
"z": 1
}
}
}
anchors.fill: parent
JSONReader {
id: myFile
source: _organismsDataDirectory + "/" + root.organism + "/" + root.organSystem + "/" + "data.json"
onError: console.log(msg)
}
Rectangle {
width: parent.width/2
width: parent.width / 2
height: parent.height
anchors.left: parent.left
TableView {
id: organsTable
headerVisible: true
Text {
anchors.fill: parent
text: qsTr("Organs")
font.bold: true
font.pixelSize: 14
horizontalAlignment: Text.AlignHCenter
}
TableViewColumn {
role: "title" ;
title: "List of organs";
horizontalAlignment: Text.AlignHCenter;
}
Organs {
id:buildSpaceOrgansList
organism: root.organism
organSystem: root.organSystem
currentOrgan: root.currentOrgan
dragOrgans: true
coordinatesSheet: root.coordinatesSheet
}
}
Organs {
id: buildSpaceOrgansList
organism: root.organism
organSystem: root.organSystem
currentOrgan: root.currentOrgan
dragOrgans: true
coordinatesSheet: root.coordinatesSheet
}
Button {
text: "Back"
style: Components.ButtonStyle {}
style: Components.ButtonStyle {
}
width: 50
height: 50
x: 400
......@@ -58,28 +124,50 @@ RowLayout {
}
DropArea {
id:dropArea
width: parent.width/2
id: dropArea
width: parent.width / 2
height: parent.height
anchors.right: parent.right
property string droppedOrgan
Drag.active: true
Drag.active: false
property int droppedX
property int droppedY
Text {
id: dropAreaText
anchors.fill: parent
text: qsTr("Work" + " space")
text: qsTr("Work space")
font.bold: true
font.pixelSize: 14
horizontalAlignment: Text.AlignHCenter
}
onDropped: {
droppedOrgan = drag.source.organ
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) && (droppedY <= refY + threshold) || (droppedX <= refX - threshold) && (droppedY <= refY - threshold))
organMatches++;
}
Image {
id: background
anchors {
left: parent.left
top: parent.top
leftMargin: -45
topMargin: -20
}
source: _organismsDataDirectory + "/" + root.organism + "/" + root.organSystem + "/background.png"
z: -2
}
Organs {
id:workSpaceOrgansList
id: workSpaceOrgansList
organism: root.organism
organSystem: root.organSystem
currentOrgan: root.currentOrgan
......@@ -87,37 +175,6 @@ RowLayout {
displayOrganLabel: true
opacity: 0
property string clickedOrgan
onClicked: {
clickedOrgan = organ
//TODO: Implement a better functionality to check whether the 2 organs matche
// Here we're just checking if the names of the two organs matche
if (dropArea.droppedOrgan == workSpaceOrgansList.clickedOrgan) {
root.organMatches +=1
}
}
}
Text {
text: " 1"
x: workSpaceOrgansList.coordinatesSheet["stomach"].x
y: workSpaceOrgansList.coordinatesSheet["stomach"].y
}
Text {
text: " 2"
x: workSpaceOrgansList.coordinatesSheet["liver"].x
y: workSpaceOrgansList.coordinatesSheet["liver"].y
z: workSpaceOrgansList.coordinatesSheet["liver"].z
}
Text {
text: " 3"
x: workSpaceOrgansList.coordinatesSheet["intestine"].x + 200
y:workSpaceOrgansList.coordinatesSheet["intestine"].y
z:1
}
Text {
......@@ -132,37 +189,32 @@ RowLayout {
Button {
id: feedbackButton
style: Components.ButtonStyle {}
style: Components.ButtonStyle {
}
text: "Feedback"
x: 130
y: 630
x: 0
y: 670
width: 100
height: 50
onClicked: {
if (feedbackButton.text == "Reset") {
stack.push(buildSelection)
}
else {
// 3 here represents the total number of organs
// We should be able to make this more generic
if (root.organMatches >= 3) {
stack.push(buildSelection)
} else {
if (root.organMatches >= numberOfOrgans) {
feedbackText.color = "green"
feedbackText.text += "Good job! You have learnt the "
+ root.organSystem + "!\n"
+ root.organSystem + "!"
dropAreaText.color = "green"
}
else {
} else {
workSpaceOrgansList.opacity = 1
buildSpaceOrgansList.opacity = 0.2
feedbackText.text += "Check what you got wrong" + "\n"
feedbackText.text += "Check what you got wrong"
dropAreaText.color = "red"
}
feedbackButton.text = "Reset"
dropArea.feedbackReset()
feedbackButton.text = "Reset"
dropArea.feedbackReset()
}
}
}
......@@ -170,10 +222,17 @@ RowLayout {
function feedbackReset() {
if (feedbackButton.text == "Reset") {
feedbackButton.enabled = true
}
else {
} else {
feedbackButton.enabled = false
}
}
}
}
Component.onCompleted: {
referenceCoordinates = JSON.parse(myFile.read());
for (var key in referenceCoordinates)
if(referenceCoordinates.hasOwnProperty(key))
numberOfOrgans++;
}
}
......@@ -15,6 +15,7 @@ Item {
//property variant organsList: [ "mouth","oesophagus"]
Image {
id: background
anchors {
left: parent.left
top: parent.top
......@@ -84,8 +85,6 @@ Item {
y: 0
onClicked: root.clicked(organ)
}
Components.OrganImage {
......@@ -216,35 +215,27 @@ Item {
Repeater{
model:getModel()
Image {
source: root.coordinatesSheet.lines[modelData + "Line"].source
x:root.coordinatesSheet.lines[modelData + "Line"].coordinates.x;
y:root.coordinatesSheet.lines[modelData + "Line"].coordinates.y
z:root.coordinatesSheet.lines[modelData + "Line"].coordinates.z
width:root.coordinatesSheet.lines[modelData + "Line"].width
visible: root.displayOrganLabel
Image {
Image {
source: root.coordinatesSheet.lines[modelData + "Line"].sourceArrow
x:root.coordinatesSheet.lines[modelData + "Line"].coordinatesArrow.x;
y:root.coordinatesSheet.lines[modelData + "Line"].coordinatesArrow.y
z:root.coordinatesSheet.lines[modelData + "Line"].coordinatesArrow.z
width:root.coordinatesSheet.lines[modelData + "Line"].widthArrow
visible: root.displayOrganLabel
}
}
function getModel(){
root.coordinatesSheet = JSON.parse(myFile.read());
return organsList
}
}
......@@ -259,7 +250,10 @@ Item {
}
Component.onCompleted: {
root.coordinatesSheet = JSON.parse(myFile.read());
if (dragOrgans) {
background.visible = false;
return;
}
mouthImage.x = root.coordinatesSheet.mouth.coordinates.x;
mouthImage.y = root.coordinatesSheet.mouth.coordinates.y;
......
......@@ -7,12 +7,12 @@
},
"description": "In human anatomy, the mouth is the first portion of the alimentary canal that receives food and saliva. In addition to its primary role as the beginning of the digestive system, in humans the mouth also plays a significant role in communication. The mouth, normally moist, is lined with a mucous membrane, and contains the teeth.",
"label": "Mouth",
"labelcoordinates":{
"x":15,
"y":130,
"z":0
"labelcoordinates": {
"x": 15,
"y": 130,
"z": 0
},
"fontsize":20
"fontsize": 20
},
"oesophagus": {
"coordinates": {
......@@ -21,13 +21,13 @@
"z": 1
},
"description": "commonly known as the foodpipe or gullet, is an organ in vertebrates which consists of a fibromuscular tube through which food passes, aided by peristaltic contractions, from the pharynx to the stomach. In humans, the esophagus is usually 18–25 centimeters (cm) long.",
"label": "Oesophagus",
"labelcoordinates":{
"x":400,
"y":200,
"z":0
"label": "Oesophagus",
"labelcoordinates": {
"x": 400,
"y": 200,
"z": 0
},
"fontsize":20
"fontsize": 20
},
"liver": {
"coordinates": {
......@@ -36,13 +36,13 @@
"z": -1
},
"description": "The liver is a vital organ of the digestive system present in vertebrates and some other animals. It has a wide range of functions, including detoxification, protein synthesis, and production of biochemicals necessary for digestion. The liver is necessary for survival; there is currently no way to compensate for the absence of liver function in the long term, although new liver dialysis techniques can be used in the short term. This gland plays a major role in metabolism and has a number of functions in the body, including glycogen storage, decomposition of red blood cells, plasma protein synthesis, hormone production, and detoxification. It lies below the diaphragm in the abdominal-pelvic region of the abdomen. It produces bile, an alkaline compound which aids in digestion via the emulsification of lipids. The liver's highly specialized tissues regulate a wide variety of high-volume biochemical reactions, including the synthesis and breakdown of small and complex molecules, many of which are necessary for normal vital functions. Estimates regarding the organ's total number of functions vary, but textbooks generally cite it at around 500 or so. Terminology related to the liver often starts in hepar- or hepat- from the Greek word for liver.",
"label": "Liver",
"labelcoordinates":{
"x":15,
"y":340,
"z":0
"label": "Liver",
"labelcoordinates": {
"x": 15,
"y": 340,
"z": 0
},
"fontsize":20
"fontsize": 20
},
"stomach": {
"coordinates": {
......@@ -50,13 +50,13 @@
"y": 345
},
"description": "The stomach is a muscular, hollow, dilated part of the digestive system which functions as an important organ of the digestive tract in some animals, including vertebrates, echinoderms, insects (mid-gut), and molluscs. It is involved in the second phase of digestion, following mastication (chewing). The stomach is located between the esophagus and the small intestine. It secretes protein-digesting enzymes called proteases and strong acids to aid in food digestion, (sent to it via esophageal peristalsis) through smooth muscular contortions (called segmentation) before sending partially digested food (chyme) to the small intestines.",
"label": "Stomach",
"labelcoordinates":{
"x":400,
"y":380,
"z":0
"label": "Stomach",
"labelcoordinates": {
"x": 400,
"y": 380,
"z": 0
},
"fontsize":20
"fontsize": 20
},
"small_intestine": {
"coordinates": {
......@@ -65,14 +65,13 @@
"z": 2
},
"description": "The small intestine (or small bowel) is the part of the gastrointestinal tract following the stomach and followed by the large intestine, and is where much of the digestion and absorption of food takes place. The small intestine is composed of a duodenum, jejunum, and ileum. It receives bile juice and pancreatic juice from the liver.",
"label": "Small Intestine",
"labelcoordinates":{
"x":400,
"y":550,
"z":0
"label": "Small Intestine",
"labelcoordinates": {
"x": 400,
"y": 550,
"z": 0
},
"fontsize":20
"fontsize": 20
},
"large_intestine": {
"coordinates": {
......@@ -81,13 +80,13 @@
"z": 1
},
"description": "The large intestine is the combination of the cecum, colon, rectum, and anal canal. Its function is to absorb water from fecal matter, and then rid the body of remaining waste material.",
"label": "Large Intestine",
"labelcoordinates":{
"x":400,
"y":500,
"z":0
"label": "Large Intestine",
"labelcoordinates": {
"x": 400,
"y": 500,
"z": 0
},
"fontsize":20
"fontsize": 20
},
"anus": {
"coordinates": {
......@@ -96,13 +95,13 @@
"z": 1
},
"description": "The anus is the opening where the gastrointestinal tract ends and exits the body. The anus starts at the bottom of the rectum, the last portion of the colon (large intestine). The anorectal line separates the anus from the rectum.",
"label": "Anus",
"labelcoordinates":{
"x":15,
"y":690,
"z":0
"label": "Anus",
"labelcoordinates": {
"x": 15,
"y": 690,
"z": 0
},
"fontsize":20
"fontsize": 20
},
"pancreas": {
"coordinates": {
......@@ -111,13 +110,13 @@
"z": -1
},
"description": "The pancreas is a glandular organ in the digestive system and endocrine system of vertebrates. In humans, it is located in the abdominal cavity behind the stomach. It is an endocrine gland producing several important hormones, including insulin, glucagon, somatostatin, and pancreatic polypeptide which circulate in the blood. The pancreas is also a digestive organ, secreting pancreatic juice containing digestive enzymes that assist digestion and absorption of nutrients in the small intestine. These enzymes help to further break down the carbohydrates, proteins, and lipids in the chyme.",
"label": "Pancreas",
"labelcoordinates":{
"x":400,
"y":450,
"z":0
"label": "Pancreas",
"labelcoordinates": {
"x": 400,
"y": 450,
"z": 0
},
"fontsize":20
"fontsize": 20
},
"gall_bladder": {
"coordinates": {
......@@ -126,189 +125,158 @@
"z": 10
},
"description": "The gallbladder is a small pouch that sits just under the liver. The gallbladder stores bile produced by the liver. After meals, the gallbladder is empty and flat, like a deflated balloon. Before a meal, the gallbladder may be full of bile and about the size of a small pear.",
"label": "Gall Bladder",
"labelcoordinates":{
"x":15,
"y":420,
"z":0
"label": "Gall Bladder",
"labelcoordinates": {
"x": 15,
"y": 420,
"z": 0
},
"fontsize":20
"fontsize": 20
},
"lines":{
"mouthLine":{
"source":"../line.png",
"sourceArrow":"../left.png",
"coordinates": {
"x": 85,
"y": 142,
"z": 10
},
"coordinatesArrow": {
"x": -7,
"y": -9,
"z": 10
},
"width": 100,
"widthArrow": 21
},
"oesophagusLine":{
"source":"../line.png",
"sourceArrow":"../right.png",
"coordinates": {
"x": 245,
"y": 213,
"z": 10
},
"coordinatesArrow": {
"x": 133,
"y": -9,
"z": 10
},
"width": 145,
"widthArrow": 20
},
"liverLine":{
"source":"../line.png",
"sourceArrow":"../left.png",
"coordinates": {
"x": 70,
"y": 355,
"z": 10
},
"coordinatesArrow": {
"x": -7,
"y": -9,
"z": 10
},
"width": 120,
"widthArrow": 20
},
"stomachLine":{
"source":"../line.png",
"sourceArrow":"../right.png",
"coordinates": {
"x": 300,
"y": 395,
"z": 10
},
"coordinatesArrow": {