|
|
@ -1,21 +1,47 @@
|
|
|
|
function createEtLogique(x, y, id, type) {
|
|
|
|
function createLogique(x, y, id, type) {
|
|
|
|
var imageObj = new Image();
|
|
|
|
|
|
|
|
imageObj.onload = function () {
|
|
|
|
switch(type){
|
|
|
|
var et = new Konva.Image({
|
|
|
|
case "et":
|
|
|
|
x: x,
|
|
|
|
var imageObj = new Image();
|
|
|
|
y: y,
|
|
|
|
imageObj.onload = function () {
|
|
|
|
image: imageObj,
|
|
|
|
var et = new Konva.Image({
|
|
|
|
width: 100,
|
|
|
|
x: x,
|
|
|
|
height: 50,
|
|
|
|
y: y,
|
|
|
|
id: id,
|
|
|
|
image: imageObj,
|
|
|
|
});
|
|
|
|
width: 100,
|
|
|
|
|
|
|
|
height: 50,
|
|
|
|
|
|
|
|
id: id,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
layer.add(et);
|
|
|
|
layer.add(et);
|
|
|
|
layer.batchDraw();
|
|
|
|
layer.batchDraw();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
imageObj.src = '../img/logiqueet.png';
|
|
|
|
imageObj.src = '../img/logiqueet.png';
|
|
|
|
imageObj.id = id;
|
|
|
|
imageObj.id = id;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "ou":
|
|
|
|
|
|
|
|
var imageObj = new Image();
|
|
|
|
|
|
|
|
imageObj.onload = function () {
|
|
|
|
|
|
|
|
var et = new Konva.Image({
|
|
|
|
|
|
|
|
x: x,
|
|
|
|
|
|
|
|
y: y,
|
|
|
|
|
|
|
|
image: imageObj,
|
|
|
|
|
|
|
|
width: 100,
|
|
|
|
|
|
|
|
height: 50,
|
|
|
|
|
|
|
|
id: id,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
layer.add(et);
|
|
|
|
|
|
|
|
layer.batchDraw();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
imageObj.src = '../img/logiqueou.png';
|
|
|
|
|
|
|
|
imageObj.id = id;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var logique = {
|
|
|
|
var logique = {
|
|
|
|
name: id,
|
|
|
|
name: id,
|
|
|
@ -120,7 +146,8 @@ function changeLineColorYellow(idLine){
|
|
|
|
|
|
|
|
|
|
|
|
function checkAllSortieLogique(){
|
|
|
|
function checkAllSortieLogique(){
|
|
|
|
logiques.forEach(function(element){
|
|
|
|
logiques.forEach(function(element){
|
|
|
|
checkSortieLogique(element.name);
|
|
|
|
if(element.id3 != null)
|
|
|
|
|
|
|
|
checkSortieLogique(element.name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -150,6 +177,14 @@ function checkSortieLogique(logiqueId){
|
|
|
|
changeLineColorBlack(element.id3);
|
|
|
|
changeLineColorBlack(element.id3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "ou" :
|
|
|
|
|
|
|
|
if(line1State == true || line2State == true){
|
|
|
|
|
|
|
|
changeLineColorYellow(element.id3);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
changeLineColorBlack(element.id3);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -178,24 +213,14 @@ function createSwitch(id, x, y) {
|
|
|
|
width: 100,
|
|
|
|
width: 100,
|
|
|
|
height: 50,
|
|
|
|
height: 50,
|
|
|
|
stroke: 'black',
|
|
|
|
stroke: 'black',
|
|
|
|
|
|
|
|
fill: 'red',
|
|
|
|
strokeWidth: 4,
|
|
|
|
strokeWidth: 4,
|
|
|
|
id: id,
|
|
|
|
id: id,
|
|
|
|
id3 : null,
|
|
|
|
id3 : null,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
layer.add(rect1);
|
|
|
|
|
|
|
|
var simpleText = new Konva.Text({
|
|
|
|
|
|
|
|
x: x,
|
|
|
|
|
|
|
|
y: y,
|
|
|
|
|
|
|
|
text: '0',
|
|
|
|
|
|
|
|
fontSize: 30,
|
|
|
|
|
|
|
|
fontFamily: 'Calibri',
|
|
|
|
|
|
|
|
fill: 'black',
|
|
|
|
|
|
|
|
id: "text" + id,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
layer.add(simpleText);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
layer.add(rect1);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -203,8 +228,10 @@ function initAllSwitch(){
|
|
|
|
switchs.forEach(function(element){
|
|
|
|
switchs.forEach(function(element){
|
|
|
|
let switche = stage.findOne("#"+element);
|
|
|
|
let switche = stage.findOne("#"+element);
|
|
|
|
switche.on('click', function () {
|
|
|
|
switche.on('click', function () {
|
|
|
|
|
|
|
|
let colorrect = switche.fill() == 'red' ? 'green' : 'red';
|
|
|
|
|
|
|
|
switche.fill(colorrect);
|
|
|
|
changeLineColor(switche.id3);
|
|
|
|
changeLineColor(switche.id3);
|
|
|
|
checkSortieLogique("logique1");
|
|
|
|
checkAllSortieLogique();
|
|
|
|
layer.draw();
|
|
|
|
layer.draw();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|