Gitlab CSE Unil

Commit fab0d6d9 authored by M. Chardon's avatar M. Chardon
Browse files

enregistrement des déplacements des rectangles geomo

parent e8f21dfe
......@@ -92,11 +92,11 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
setCategory: _setCategory,
origin: origin
origin: origin,
// Mouse Event
//itemMouseDrag: itemMouseDrag,
//itemMouseUp: itemMouseUp
itemMouseDrag: itemMouseDrag,
itemMouseUp: itemMouseUp
// General attributes handlers
//setColor: _noop, //_setColor,
......@@ -110,11 +110,10 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
};
// Add event listeners
//newRecGeo.onMouseDown = itemMouseDown;
//newRecGeo.onMouseDrag = itemMouseDrag; // --> in data.itemMouseDrag
//newRecGeo.onMouseUp = itemMouseUp;
//newRecGeo.onKeyDown = itemKeyDown;
//newRecGeo.onKeyUp = itemKeyUp;
if (eventListening) {
newRecGeo.onMouseDown = itemMouseDown;
//newRecGeo.onKeyDown = itemKeyDown;
}
//newRecGeo.onPropertyChange = itemPropertyChange;
......@@ -204,7 +203,56 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
_recGeoChanged = false;
}
}
_editedSegmentIdx = _editedStriaLeftIdx = _editedStriaRightIdx = _editedStria = _editedSegmentXLimit = null;
_editedSegmentIdx = _editedStriaLeftIdx = _editedStriaRightIdx = _editedRecGeo = _editedSegmentXLimit = null;
}
function itemMouseDown(event) {
var hitItem = this;
_editedRecGeo = this;
var hitResult = hitItem.hitTest(event.point, hitOptions);
hitItem.layer.activate();
paper.project.deselectAll();
hitItem.selected = true;
_events.annotationSelected.dispatch(hitItem);
/*_editedSegmentIdx = _editedStriaLeftIdx = _editedStriaRightIdx = _editedSegmentXLimit = null;
if (hitResult.type === 'segment') {
_editedSegmentIdx = hitResult.segment.index;
_editedSegmentXLimit = _cutPosition + (
(_editedStria.segments[1-_editedSegmentIdx].point.x < _cutPosition ? 1 : -1) * _cutThreshold
);
} else {
_editedStriaLeftIdx = (_editedStria.getFirstSegment().point.x < _cutPosition) ? 0 : 1;
_editedStriaRightIdx = 1 - _editedStriaLeftIdx;
}*/
_redGeoChanged = false;
_events.annotationSelected.dispatch(hitItem);
}
function itemMouseDrag(event) {
// Handle only event forwarded by tools
if (!event.tool)
return;
_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;
}
function itemMouseUp(event) {
if (!event.tool) // catches only tool's events
return;
if (_recGeoChanged) {
_events.annotationChanged.dispatch(this);
}
_recGeoChanged = false;
}
function cancelCreate() {
......
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