Gitlab CSE Unil

Commit 178fd0d2 authored by M. Chardon's avatar M. Chardon
Browse files

mantis 237

parent 72fccb46
......@@ -193,7 +193,6 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
}
function itemMouseDown(event) {
console.log("MouseDown");
var hitItem = this;
_editedRecGeo = this;
var hitResult = hitItem.hitTest(event.point, hitOptions);
......@@ -204,9 +203,9 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
_events.annotationSelected.dispatch(hitItem);
_editedSegmentIdx = null;
if (hitResult){
/*if (hitResult){
console.log(hitResult.type);
}
}*/
if (hitResult && hitResult.type === 'segment') {
_editedSegmentIdx = hitResult.segment.index;
}
......@@ -221,7 +220,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
}
function itemMouseDrag(event) {
console.log("itemMouseDrag");
//console.log("itemMouseDrag");
// Handle only event forwarded by tools
if (!event.tool)
return;
......@@ -271,9 +270,13 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
if (property === 'category') {
_setCategory.call(this, value);
this.style = {
fillColor: _getColorBg(value),
strokeColor: _getColor(value)
};
if (this.data.prop.fill) {
this.style = {
fillColor: _getColorBg(value)
};
}
paper.view.draw();
}
}
......
......@@ -18,7 +18,7 @@
*
*/
define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, Category) {
define(["paper", "tools/Shape.class", "adim/category"], function (paper, Shape, Category) {
// ----- Const ---------------------------------------
var TOOL_TYPE = "rectanglegeo";
var _tool; // The tool itself
......@@ -43,8 +43,8 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
var defaultProperties = {
comment: "",
category: "cat_geo_1",
fill:true,
opacity:1
fill: true,
opacity: 1
};
var hitOptions = {
......@@ -60,7 +60,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
// ----- Serialization ---------------------------------
function exportJSON(param) {
var json = this.exportJSON({asString:false});
var json = this.exportJSON({asString: false});
return (param && param.asString) ? JSON.stringify(json) : json;
}
......@@ -68,14 +68,14 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
// Sanitize data
var item = itemDef[1];
var itemData = item.data;
itemData.prop.opacity=parseFloat(item.opacity) || 1;
itemData.prop.opacity = parseFloat(item.opacity) || 1;
var curLayer = paper.project.activeLayer;
layer.activate();
// Keep copy of current category
var curCat = defaultProperties.category;
var from = new paper.Point(itemData.origin.from[1],itemData.origin.from[2]);
var from = new paper.Point(itemData.origin.from[1], itemData.origin.from[2]);
var to = new paper.Point(itemData.origin.to[1], itemData.origin.to[2]);
var recgeo = createRectangleGeo({from: from, to: to}, itemData, listening);
if (itemData.prop.category) {
......@@ -131,7 +131,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
newRecGeo.opacity = parseFloat(properties.opacity) || 1;
if (properties.fill)
newRecGeo.style = {
fillColor: _getColorBg(properties.category),
fillColor: _getColorBg(properties.category),
};
newRecGeo._boundsSelected = true;
......@@ -150,17 +150,16 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
}
var cat = Category.getCategory(category);
var color = cat && cat.color ||"grey";
var colorbg = cat && cat.colorbg ||"grey";
var color = cat && cat.color || "grey";
var colorbg = cat && cat.colorbg || "grey";
if (!_drawingLine) {
_drawingLine = new paper.Path.Rectangle(_startPoint, event.point);
if (fill == "checked") {
_drawingLine.fillColor = colorbg;
}
_drawingLine.color=color;
}
else {
_drawingLine.color = color;
} else {
_drawingLine.segments[1].point.x = event.point.x;
_drawingLine.segments[2].point = event.point;
_drawingLine.segments[3].point.y = event.point.y;
......@@ -181,7 +180,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
return newRecGeo;
}
function setSelected(selected) {
function setSelected(selected) {
if (selected) {
_events.annotationSelected.dispatch(this);
//drawMarker(this,{highlight:true});
......@@ -220,7 +219,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
var dstPoint = event.point.clone();
_editedRecGeo.segments[_editedSegmentIdx].point = dstPoint;
var deltaPoint = event.delta
switch (_editedSegmentIdx){
switch (_editedSegmentIdx) {
case 0:
_editedRecGeo.segments[1].point.x = dstPoint.x;
_editedRecGeo.segments[3].point.y = dstPoint.y;
......@@ -271,9 +270,13 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
if (property === 'category') {
_setCategory.call(this, value);
this.style = {
fillColor: _getColorBg(value),
strokeColor: _getColor(value)
};
if (this.data.prop.fill) {
this.style = {
fillColor: _getColorBg(value)
};
}
paper.view.draw();
}
}
......@@ -289,7 +292,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
var _selectedTool = null;
var toolDef = {
onMouseDown: function(event) {
onMouseDown: function (event) {
if (_startPoint) {
if (_drawingLine && !terminateOnRelease) {
_terminateCreate();
......@@ -315,28 +318,28 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
}
},
onMouseDrag: function(event) {
onMouseDrag: function (event) {
if (create && _startPoint) {
terminateOnRelease = true;
drawRecGeo(this,event);
drawRecGeo(this, event);
}
},
onMouseMove: function(event) {
onMouseMove: function (event) {
if (create && _startPoint) {
drawRecGeo(this,event);
drawRecGeo(this, event);
}
},
onMouseUp: function(event) {
onMouseUp: function (event) {
if (_startPoint) {
if (_drawingLine && terminateOnRelease) {
drawRecGeo(this,event);
drawRecGeo(this, event);
//itemMouseDown.call(marker, event);
//itemMouseDown.call(marker, event);
var newRecto = _terminateCreate(event);
newRecto.selected=true;
newRecto.selected = true;
_selectedTool = newRecto;
_events.annotationSelected.dispatch(newRecto);
} else {
......@@ -346,13 +349,13 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
_editedSegmentIdx = _editedRecGeo = null;
},
onKeyDown: function(event) {
onKeyDown: function (event) {
switch (event.key) {
case "escape":
if (create)
cancelCreate();
break;
break;
}
}
};
......@@ -375,9 +378,9 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
}
function _getColorBgD() {
if (this.prop){
if (this.prop) {
var category = Category.getCategory(this.prop.category),
color = (category && category.colorbg) || "#000000";
color = (category && category.colorbg) || "#000000";
return color;
} else {
return "#000000";
......@@ -392,6 +395,8 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
tool: _tool,
exportJSON: exportJSON,
importJSON: importJSON,
registerEvent: function(eventName, evt) { _events[eventName] = evt; }
registerEvent: function (eventName, evt) {
_events[eventName] = evt;
}
};
});
\ No newline at end of file
......@@ -22406,7 +22406,6 @@ define('tools/ellipsegeo',["paper", "tools/Shape.class","adim/category"], functi
}
function itemMouseDown(event) {
console.log("MouseDown");
var hitItem = this;
_editedRecGeo = this;
var hitResult = hitItem.hitTest(event.point, hitOptions);
......@@ -22417,9 +22416,9 @@ define('tools/ellipsegeo',["paper", "tools/Shape.class","adim/category"], functi
_events.annotationSelected.dispatch(hitItem);
_editedSegmentIdx = null;
if (hitResult){
/*if (hitResult){
console.log(hitResult.type);
}
}*/
if (hitResult && hitResult.type === 'segment') {
_editedSegmentIdx = hitResult.segment.index;
}
......@@ -22434,7 +22433,7 @@ define('tools/ellipsegeo',["paper", "tools/Shape.class","adim/category"], functi
}
function itemMouseDrag(event) {
console.log("itemMouseDrag");
//console.log("itemMouseDrag");
// Handle only event forwarded by tools
if (!event.tool)
return;
......@@ -22484,9 +22483,13 @@ define('tools/ellipsegeo',["paper", "tools/Shape.class","adim/category"], functi
if (property === 'category') {
_setCategory.call(this, value);
this.style = {
fillColor: _getColorBg(value),
strokeColor: _getColor(value)
};
if (this.data.prop.fill) {
this.style = {
fillColor: _getColorBg(value)
};
}
paper.view.draw();
}
}
......@@ -22623,7 +22626,7 @@ define('tools/ellipsegeo',["paper", "tools/Shape.class","adim/category"], functi
*
*/
define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], function (paper, Shape, Category) {
define('tools/rectanglegeo',["paper", "tools/Shape.class", "adim/category"], function (paper, Shape, Category) {
// ----- Const ---------------------------------------
var TOOL_TYPE = "rectanglegeo";
var _tool; // The tool itself
......@@ -22648,8 +22651,8 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
var defaultProperties = {
comment: "",
category: "cat_geo_1",
fill:true,
opacity:1
fill: true,
opacity: 1
};
var hitOptions = {
......@@ -22665,7 +22668,7 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
// ----- Serialization ---------------------------------
function exportJSON(param) {
var json = this.exportJSON({asString:false});
var json = this.exportJSON({asString: false});
return (param && param.asString) ? JSON.stringify(json) : json;
}
......@@ -22673,14 +22676,14 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
// Sanitize data
var item = itemDef[1];
var itemData = item.data;
itemData.prop.opacity=parseFloat(item.opacity) || 1;
itemData.prop.opacity = parseFloat(item.opacity) || 1;
var curLayer = paper.project.activeLayer;
layer.activate();
// Keep copy of current category
var curCat = defaultProperties.category;
var from = new paper.Point(itemData.origin.from[1],itemData.origin.from[2]);
var from = new paper.Point(itemData.origin.from[1], itemData.origin.from[2]);
var to = new paper.Point(itemData.origin.to[1], itemData.origin.to[2]);
var recgeo = createRectangleGeo({from: from, to: to}, itemData, listening);
if (itemData.prop.category) {
......@@ -22736,7 +22739,7 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
newRecGeo.opacity = parseFloat(properties.opacity) || 1;
if (properties.fill)
newRecGeo.style = {
fillColor: _getColorBg(properties.category),
fillColor: _getColorBg(properties.category),
};
newRecGeo._boundsSelected = true;
......@@ -22755,17 +22758,16 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
}
var cat = Category.getCategory(category);
var color = cat && cat.color ||"grey";
var colorbg = cat && cat.colorbg ||"grey";
var color = cat && cat.color || "grey";
var colorbg = cat && cat.colorbg || "grey";
if (!_drawingLine) {
_drawingLine = new paper.Path.Rectangle(_startPoint, event.point);
if (fill == "checked") {
_drawingLine.fillColor = colorbg;
}
_drawingLine.color=color;
}
else {
_drawingLine.color = color;
} else {
_drawingLine.segments[1].point.x = event.point.x;
_drawingLine.segments[2].point = event.point;
_drawingLine.segments[3].point.y = event.point.y;
......@@ -22786,7 +22788,7 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
return newRecGeo;
}
function setSelected(selected) {
function setSelected(selected) {
if (selected) {
_events.annotationSelected.dispatch(this);
//drawMarker(this,{highlight:true});
......@@ -22825,7 +22827,7 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
var dstPoint = event.point.clone();
_editedRecGeo.segments[_editedSegmentIdx].point = dstPoint;
var deltaPoint = event.delta
switch (_editedSegmentIdx){
switch (_editedSegmentIdx) {
case 0:
_editedRecGeo.segments[1].point.x = dstPoint.x;
_editedRecGeo.segments[3].point.y = dstPoint.y;
......@@ -22876,9 +22878,13 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
if (property === 'category') {
_setCategory.call(this, value);
this.style = {
fillColor: _getColorBg(value),
strokeColor: _getColor(value)
};
if (this.data.prop.fill) {
this.style = {
fillColor: _getColorBg(value)
};
}
paper.view.draw();
}
}
......@@ -22894,7 +22900,7 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
var _selectedTool = null;
var toolDef = {
onMouseDown: function(event) {
onMouseDown: function (event) {
if (_startPoint) {
if (_drawingLine && !terminateOnRelease) {
_terminateCreate();
......@@ -22920,28 +22926,28 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
}
},
onMouseDrag: function(event) {
onMouseDrag: function (event) {
if (create && _startPoint) {
terminateOnRelease = true;
drawRecGeo(this,event);
drawRecGeo(this, event);
}
},
onMouseMove: function(event) {
onMouseMove: function (event) {
if (create && _startPoint) {
drawRecGeo(this,event);
drawRecGeo(this, event);
}
},
onMouseUp: function(event) {
onMouseUp: function (event) {
if (_startPoint) {
if (_drawingLine && terminateOnRelease) {
drawRecGeo(this,event);
drawRecGeo(this, event);
//itemMouseDown.call(marker, event);
//itemMouseDown.call(marker, event);
var newRecto = _terminateCreate(event);
newRecto.selected=true;
newRecto.selected = true;
_selectedTool = newRecto;
_events.annotationSelected.dispatch(newRecto);
} else {
......@@ -22951,13 +22957,13 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
_editedSegmentIdx = _editedRecGeo = null;
},
onKeyDown: function(event) {
onKeyDown: function (event) {
switch (event.key) {
case "escape":
if (create)
cancelCreate();
break;
break;
}
}
};
......@@ -22980,9 +22986,9 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
}
function _getColorBgD() {
if (this.prop){
if (this.prop) {
var category = Category.getCategory(this.prop.category),
color = (category && category.colorbg) || "#000000";
color = (category && category.colorbg) || "#000000";
return color;
} else {
return "#000000";
......@@ -22997,7 +23003,9 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
tool: _tool,
exportJSON: exportJSON,
importJSON: importJSON,
registerEvent: function(eventName, evt) { _events[eventName] = evt; }
registerEvent: function (eventName, evt) {
_events[eventName] = evt;
}
};
});
/**
......@@ -22406,7 +22406,6 @@ define('tools/ellipsegeo',["paper", "tools/Shape.class","adim/category"], functi
}
function itemMouseDown(event) {
console.log("MouseDown");
var hitItem = this;
_editedRecGeo = this;
var hitResult = hitItem.hitTest(event.point, hitOptions);
......@@ -22417,9 +22416,9 @@ define('tools/ellipsegeo',["paper", "tools/Shape.class","adim/category"], functi
_events.annotationSelected.dispatch(hitItem);
_editedSegmentIdx = null;
if (hitResult){
/*if (hitResult){
console.log(hitResult.type);
}
}*/
if (hitResult && hitResult.type === 'segment') {
_editedSegmentIdx = hitResult.segment.index;
}
......@@ -22434,7 +22433,7 @@ define('tools/ellipsegeo',["paper", "tools/Shape.class","adim/category"], functi
}
function itemMouseDrag(event) {
console.log("itemMouseDrag");
//console.log("itemMouseDrag");
// Handle only event forwarded by tools
if (!event.tool)
return;
......@@ -22484,9 +22483,13 @@ define('tools/ellipsegeo',["paper", "tools/Shape.class","adim/category"], functi
if (property === 'category') {
_setCategory.call(this, value);
this.style = {
fillColor: _getColorBg(value),
strokeColor: _getColor(value)
};
if (this.data.prop.fill) {
this.style = {
fillColor: _getColorBg(value)
};
}
paper.view.draw();
}
}
......@@ -22623,7 +22626,7 @@ define('tools/ellipsegeo',["paper", "tools/Shape.class","adim/category"], functi
*
*/
define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], function (paper, Shape, Category) {
define('tools/rectanglegeo',["paper", "tools/Shape.class", "adim/category"], function (paper, Shape, Category) {
// ----- Const ---------------------------------------
var TOOL_TYPE = "rectanglegeo";
var _tool; // The tool itself
......@@ -22648,8 +22651,8 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
var defaultProperties = {
comment: "",
category: "cat_geo_1",
fill:true,
opacity:1
fill: true,
opacity: 1
};
var hitOptions = {
......@@ -22665,7 +22668,7 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
// ----- Serialization ---------------------------------
function exportJSON(param) {
var json = this.exportJSON({asString:false});
var json = this.exportJSON({asString: false});
return (param && param.asString) ? JSON.stringify(json) : json;
}
......@@ -22673,14 +22676,14 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
// Sanitize data
var item = itemDef[1];
var itemData = item.data;
itemData.prop.opacity=parseFloat(item.opacity) || 1;
itemData.prop.opacity = parseFloat(item.opacity) || 1;
var curLayer = paper.project.activeLayer;
layer.activate();
// Keep copy of current category
var curCat = defaultProperties.category;
var from = new paper.Point(itemData.origin.from[1],itemData.origin.from[2]);
var from = new paper.Point(itemData.origin.from[1], itemData.origin.from[2]);
var to = new paper.Point(itemData.origin.to[1], itemData.origin.to[2]);
var recgeo = createRectangleGeo({from: from, to: to}, itemData, listening);
if (itemData.prop.category) {
......@@ -22736,7 +22739,7 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
newRecGeo.opacity = parseFloat(properties.opacity) || 1;
if (properties.fill)
newRecGeo.style = {
fillColor: _getColorBg(properties.category),
fillColor: _getColorBg(properties.category),
};
newRecGeo._boundsSelected = true;
......@@ -22755,17 +22758,16 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
}
var cat = Category.getCategory(category);
var color = cat && cat.color ||"grey";
var colorbg = cat && cat.colorbg ||"grey";
var color = cat && cat.color || "grey";
var colorbg = cat && cat.colorbg || "grey";
if (!_drawingLine) {
_drawingLine = new paper.Path.Rectangle(_startPoint, event.point);
if (fill == "checked") {
_drawingLine.fillColor = colorbg;
}
_drawingLine.color=color;
}
else {
_drawingLine.color = color;
} else {
_drawingLine.segments[1].point.x = event.point.x;
_drawingLine.segments[2].point = event.point;
_drawingLine.segments[3].point.y = event.point.y;
......@@ -22786,7 +22788,7 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
return newRecGeo;
}
function setSelected(selected) {
function setSelected(selected) {
if (selected) {
_events.annotationSelected.dispatch(this);
//drawMarker(this,{highlight:true});
......@@ -22825,7 +22827,7 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
var dstPoint = event.point.clone();
_editedRecGeo.segments[_editedSegmentIdx].point = dstPoint;
var deltaPoint = event.delta
switch (_editedSegmentIdx){
switch (_editedSegmentIdx) {
case 0:
_editedRecGeo.segments[1].point.x = dstPoint.x;
_editedRecGeo.segments[3].point.y = dstPoint.y;
......@@ -22876,9 +22878,13 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
if (property === 'category') {
_setCategory.call(this, value);
this.style = {
fillColor: _getColorBg(value),
strokeColor: _getColor(value)
};
if (this.data.prop.fill) {
this.style = {
fillColor: _getColorBg(value)
};
}
paper.view.draw();
}
}
......@@ -22894,7 +22900,7 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
var _selectedTool = null;
var toolDef = {
onMouseDown: function(event) {
onMouseDown: function (event) {
if (_startPoint) {
if (_drawingLine && !terminateOnRelease) {
_terminateCreate();
......@@ -22920,28 +22926,28 @@ define('tools/rectanglegeo',["paper", "tools/Shape.class","adim/category"], func
}