Gitlab CSE Unil

Commit 3e8671e9 authored by Julien Furrer's avatar Julien Furrer
Browse files

Bugfix: outils CIMAF enregistrent plusieurs fois et enregistre lors de sélection -> corrigé

parent 2c2eb513
......@@ -125,13 +125,14 @@ define(["paper"], function (paper) {
prop: o.prop,
setStrokeWidth: _noop,
// Mouse Event
itemMouseDrag: itemMouseDrag
itemMouseDrag: itemMouseDrag,
itemMouseUp: itemMouseUp
};
if (noEventListening !== true) {
newArea.onMouseDown = itemMouseDown;
//newArea.onMouseDrag = itemMouseDrag; // --> in data.itemMouseDrag
newArea.onMouseUp = itemMouseUp;
//newArea.onMouseUp = itemMouseUp;
newArea.onKeyDown = itemKeyDown;
newArea.onKeyUp = itemKeyUp;
}
......@@ -177,9 +178,9 @@ define(["paper"], function (paper) {
function itemMouseUp(event) {
if (_editedArea) {
// TODO: add a flag to indicate if a modification really occured or if it's just a click
if (_editedArea && _areaChanged) {
_events.annotationChanged.dispatch([_editedArea]);
_areaChanged = false;
}
}
......@@ -224,6 +225,7 @@ define(["paper"], function (paper) {
_drawingArea.remove();
_startPoint = null;
create = false;
_areaChanged = false;
}
function _terminateCreate() {
......@@ -237,7 +239,7 @@ define(["paper"], function (paper) {
var newArea = createNewZone({from:_startPoint.y, to:dstPoint.y});
_events.annotationAdded.dispatch(newArea);
_areaChanged = false;
_startPoint = null;
create = false;
}
......@@ -270,12 +272,14 @@ define(["paper"], function (paper) {
var i = _editedDirection === 'up' ? 0 : 2;
_editedArea.segments[i].point.y += event.delta.y;
_editedArea.segments[i+1].point.y += event.delta.y;
_areaChanged = true;
}
function dragArea(event) {
var delta = event.delta.clone();
delta.x = 0;
_editedArea.translate(delta);
_areaChanged = true;
}
......@@ -361,6 +365,8 @@ define(["paper"], function (paper) {
drawArea(event);
_terminateCreate()
}
} else if (_editedArea) {
_editedArea.data.itemMouseUp(event);
}
_editedDirection = _editedArea = null;
},
......
......@@ -131,7 +131,8 @@ define(["paper"], function (paper) {
type: TOOL_TYPE,
prop: o.prop,
// Mouse Event
itemMouseDrag: itemMouseDrag
itemMouseDrag: itemMouseDrag,
itemMouseUp: itemMouseUp
};
// Select new stria
......@@ -143,7 +144,7 @@ define(["paper"], function (paper) {
// Add event listeners
newStria.onMouseDown = itemMouseDown;
//newStria.onMouseDrag = itemMouseDrag; // --> in data.itemMouseDrag
newStria.onMouseUp = itemMouseUp;
//newStria.onMouseUp = itemMouseUp;
newStria.onKeyDown = itemKeyDown;
newStria.onKeyUp = itemKeyUp;
......@@ -173,6 +174,7 @@ define(["paper"], function (paper) {
_editedStriaLeftIdx = (_editedStria.getFirstSegment().point.x < _cutPosition) ? 0 : 1;
_editedStriaRightIdx = 1 - _editedStriaLeftIdx;
}
_striaChanged = false;
_events.annotationSelected.dispatch(hitItem);
}
......@@ -189,6 +191,7 @@ define(["paper"], function (paper) {
_editedStria.segments[_editedStriaRightIdx].point.x + event.delta.x >= _cutPosition + _cutThreshold) {
_editedStria.translate(event.delta);
_striaChanged = true;
}
}
......@@ -199,8 +202,10 @@ define(["paper"], function (paper) {
if (!event.tool) // catches only tool's events
return;
if (_editedStria) {
// TODO: add a flag to indicate if a modification really occured or if it's just a click
_events.annotationChanged.dispatch([_editedStria]);
if (_striaChanged) {
_events.annotationChanged.dispatch([_editedStria]);
_striaChanged = false;
}
}
_editedSegmentIdx = _editedStriaLeftIdx = _editedStriaRightIdx = _editedStria = _editedSegmentXLimit = null;
}
......@@ -331,6 +336,7 @@ define(["paper"], function (paper) {
_editedStria.segments[_editedSegmentIdx].point = dstPoint;
if (event.event.shiftKey)
_horizontalize(_editedStria, _editedSegmentIdx);
_striaChanged = true;
}
......@@ -398,7 +404,11 @@ define(["paper"], function (paper) {
if (_startPoint) {
if (_drawingLine && terminateOnRelease) {
drawStria(event);
_terminateCreate()
_terminateCreate();
}
} else {
if (_editedStria) {
_editedStria.data.itemMouseUp(event);
}
}
_editedSegmentIdx = _editedStria = null;
......
......@@ -114,7 +114,8 @@ define(["paper"], function (paper) {
type: TOOL_TYPE,
prop: o.prop,
// Mouse Event
itemMouseDrag: itemMouseDrag
itemMouseDrag: itemMouseDrag,
itemMouseUp: itemMouseUp
};
// Select new stria
......@@ -125,7 +126,7 @@ define(["paper"], function (paper) {
// Add event listeners
newStria.onMouseDown = itemMouseDown;
//newStria.onMouseDrag = itemMouseDrag; // --> in data.itemMouseDrag
newStria.onMouseUp = itemMouseUp;
//newStria.onMouseUp = itemMouseUp;
newStria.onKeyDown = itemKeyDown;
newStria.onKeyUp = itemKeyUp;
newStria.onPropertyChange = itemPropertyChange;
......@@ -157,6 +158,7 @@ define(["paper"], function (paper) {
if (_rightQuadrant)
_closestSegIdx = 1 - _closestSegIdx;
}
_striaChanged = false;
_events.annotationSelected.dispatch(hitItem);
}
......@@ -174,7 +176,9 @@ define(["paper"], function (paper) {
var a = _editedStria.segments[_closestSegIdx].point.x + event.delta.x - _cutPosition;
if (_rightQuadrant ? a >= 0 : a <= 0)
_editedStria.translate(event.delta);
_striaChanged = true;
}
}
......@@ -182,8 +186,10 @@ define(["paper"], function (paper) {
if (!event.tool) // catches only tool's events
return;
if (_editedStria) {
// TODO: add a flag to indicate if a modification really occured or if it's just a click
_events.annotationChanged.dispatch([_editedStria]);
if (_striaChanged) {
_events.annotationChanged.dispatch([_editedStria]);
_striaChanged = false;
}
}
_editedSegmentIdx = _editedStria = _closestSegIdx = _rightQuadrant = null;
}
......@@ -321,6 +327,7 @@ define(["paper"], function (paper) {
_editedStria.segments[_editedSegmentIdx].point = dstPoint;
if (event.event.shiftKey)
_horizontalize(_editedStria, _editedSegmentIdx);
_striaChanged = true;
}
......@@ -384,6 +391,10 @@ define(["paper"], function (paper) {
drawStria(event);
_terminateCreate();
}
} else {
if (_editedStria) {
_editedStria.data.itemMouseUp(event);
}
}
_editedSegmentIdx = _editedStria = null;
},
......
Supports Markdown
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