Gitlab CSE Unil

Commit 8bc0d6d8 authored by M. Chardon's avatar M. Chardon
Browse files

modification de la taille des rect geo

parent fab0d6d9
......@@ -96,7 +96,8 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
// Mouse Event
itemMouseDrag: itemMouseDrag,
itemMouseUp: itemMouseUp
itemMouseUp: itemMouseUp,
itemMouseDown: itemMouseDown,
// General attributes handlers
//setColor: _noop, //_setColor,
......@@ -110,10 +111,13 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
};
// Add event listeners
if (eventListening) {
newRecGeo.onMouseDown = itemMouseDown;
//if (eventListening) {
// newRecGeo.onMouseDown = itemMouseDown;
// newRecGeo.itemMouseDrag = itemMouseDrag;
//newRecGeo.onKeyDown = itemKeyDown;
}
//}
newRecGeo.onMouseDown = itemMouseDown;
newRecGeo.itemMouseDrag = itemMouseDrag;
//newRecGeo.onPropertyChange = itemPropertyChange;
......@@ -194,7 +198,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
}
function itemMouseUp(event) {
/* function itemMouseUp(event) {
if (!event.tool) // catches only tool's events
return;
if (_editedRecGeo) {
......@@ -204,7 +208,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
}
}
_editedSegmentIdx = _editedStriaLeftIdx = _editedStriaRightIdx = _editedRecGeo = _editedSegmentXLimit = null;
}
}*/
function itemMouseDown(event) {
......@@ -217,6 +221,17 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
hitItem.selected = true;
_events.annotationSelected.dispatch(hitItem);
console.log("tutu");
_editedSegmentIdx = null;
console.log(hitResult);
if (hitResult) {
console.log(hitResult.type);
}
if (hitResult && hitResult.type === 'segment') {
_editedSegmentIdx = hitResult.segment.index;
} else {
}
/*_editedSegmentIdx = _editedStriaLeftIdx = _editedStriaRightIdx = _editedSegmentXLimit = null;
if (hitResult.type === 'segment') {
_editedSegmentIdx = hitResult.segment.index;
......@@ -233,16 +248,52 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
function itemMouseDrag(event) {
console.log("itemmousedrag");
// Handle only event forwarded by tools
if (!event.tool)
return;
if (_editedSegmentIdx !== null) {
console.log(_editedSegmentIdx);
var dstPoint = event.point.clone();
_editedRecGeo.segments[_editedSegmentIdx].point = dstPoint;
var deltaPoint = event.delta
switch (_editedSegmentIdx){
case 0:
_editedRecGeo.segments[1].point.x = dstPoint.x;
_editedRecGeo.segments[3].point.y = dstPoint.y;
this.data.origin.from.x += deltaPoint.x;
this.data.origin.to.y += deltaPoint.y;
break;
case 1:
_editedRecGeo.segments[0].point.x = dstPoint.x;
_editedRecGeo.segments[2].point.y = dstPoint.y;
this.data.origin.from.x += deltaPoint.x;
this.data.origin.from.y += deltaPoint.y;
break;
case 2:
_editedRecGeo.segments[3].point.x = dstPoint.x;
_editedRecGeo.segments[1].point.y = dstPoint.y;
this.data.origin.from.y += deltaPoint.y;
this.data.origin.to.x += deltaPoint.x;
break;
case 3:
_editedRecGeo.segments[2].point.x = dstPoint.x;
_editedRecGeo.segments[0].point.y = dstPoint.y;
this.data.origin.to.x += deltaPoint.x;
this.data.origin.to.y += deltaPoint.y;
break;
}
//if (event.event.shiftKey)
// _horizontalize(_editedRecGeo, _editedSegmentIdx);
} else {
this.translate(event.delta);
this.data.origin.from.x += event.delta.x;
this.data.origin.from.y += event.delta.y;
this.data.origin.to.x += event.delta.x;
this.data.origin.to.y += event.delta.y;
}
_recGeoChanged = true;
this.translate(event.delta);
this.data.origin.from.x += event.delta.x;
this.data.origin.from.y += event.delta.y;
this.data.origin.to.x += event.delta.x;
this.data.origin.to.y += event.delta.y;
}
......@@ -253,6 +304,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
_events.annotationChanged.dispatch(this);
}
_recGeoChanged = false;
_editedSegmentIdx = null;
}
function cancelCreate() {
......@@ -307,10 +359,11 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
if (create && _startPoint) {
terminateOnRelease = true;
drawRecGeo(this,event);
_//editedRecGeo = _drawingLine;
}
if (_editedRecGeo) {
_editedRecGeo.data.itemMouseDrag(event);
}
/*if (_editedRecGeo) {
itemMouseDrag(event);
}*/
},
onMouseMove: function(event) {
......@@ -326,11 +379,11 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
drawRecGeo(this,event);
_terminateCreate(event);
}
} else {
}/* else {
if (_editedRecGeo) {
_editedRecGeo.data.itemMouseUp(event);
}
}
}*/
_editedSegmentIdx = _editedRecGeo = null;
},
......
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