Gitlab CSE Unil

Commit 977e011e authored by M. Chardon's avatar M. Chardon
Browse files

nettoyage divers

parent 6ac3fb35
...@@ -22,9 +22,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C ...@@ -22,9 +22,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
// Properties // Properties
var defaultProperties = { var defaultProperties = {
comment: "", comment: "",
//labelComment: "",
category: "cat_geo_1", category: "cat_geo_1",
remplissage: 1,
fill:true fill:true
}; };
...@@ -42,15 +40,13 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C ...@@ -42,15 +40,13 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
function exportJSON(param) { function exportJSON(param) {
var json = this.exportJSON({asString:false}); var json = this.exportJSON({asString:false});
// Apply some cleanup
//json[1].data.origin.splice(0,1);
return (param && param.asString) ? JSON.stringify(json) : json; return (param && param.asString) ? JSON.stringify(json) : json;
} }
function importJSON(itemDef, layer, listening) { function importJSON(itemDef, layer, listening) {
// Sanitize data // Sanitize data
var item = itemDef[1]; var item = itemDef[1];
var itemData = itemDef[1].data; var itemData = item.data;
var curLayer = paper.project.activeLayer; var curLayer = paper.project.activeLayer;
layer.activate(); layer.activate();
...@@ -75,7 +71,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C ...@@ -75,7 +71,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
// ----- Item ----------------------------------------- // ----- Item -----------------------------------------
function createRectangleGeo(origin, config, eventListening) { function createRectangleGeo(origin, config, eventListening) {
var newRecGeo = new paper.Path.Rectangle(origin); //Shape("rectangle", _events); var newRecGeo = new paper.Path.Rectangle(origin);
// Extend tool's item properties with default values // Extend tool's item properties with default values
var properties = (config && typeof config.prop === 'object') ? config.prop : {}; var properties = (config && typeof config.prop === 'object') ? config.prop : {};
...@@ -83,7 +79,6 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C ...@@ -83,7 +79,6 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
if (!properties.hasOwnProperty(p)) if (!properties.hasOwnProperty(p))
properties[p] = defaultProperties[p]; properties[p] = defaultProperties[p];
} }
//newRecGeo.style = confidenceStyle[o.prop.confidence];
newRecGeo.data = { newRecGeo.data = {
tId: "a" + newRecGeo._id, tId: "a" + newRecGeo._id,
...@@ -93,6 +88,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C ...@@ -93,6 +88,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
prop: properties, prop: properties,
setCategory: _setCategory, setCategory: _setCategory,
getColorBgD: _getColorBgD,
origin: origin, origin: origin,
...@@ -100,26 +96,10 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C ...@@ -100,26 +96,10 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
itemMouseDrag: itemMouseDrag, itemMouseDrag: itemMouseDrag,
itemMouseUp: itemMouseUp, itemMouseUp: itemMouseUp,
itemMouseDown: itemMouseDown, itemMouseDown: itemMouseDown,
// General attributes handlers
//setColor: _noop, //_setColor,
//getColor: _noop, //_getColor,
//setFill: _noop,
//setStrokeWidth: _setStrokeWidth,
//getStrokeWidth: _getStrokeWidth,
getColorBgD: _getColorBgD
}; };
// Add event listeners newRecGeo.onMouseDown = itemMouseDown;
//if (eventListening) { newRecGeo.itemMouseDrag = itemMouseDrag;
// newRecGeo.onMouseDown = itemMouseDown;
// newRecGeo.itemMouseDrag = itemMouseDrag;
//newRecGeo.onKeyDown = itemKeyDown;
//}
newRecGeo.onMouseDown = itemMouseDown;
newRecGeo.itemMouseDrag = itemMouseDrag;
newRecGeo.onPropertyChange = itemPropertyChange; newRecGeo.onPropertyChange = itemPropertyChange;
newRecGeo.style = { newRecGeo.style = {
...@@ -133,43 +113,16 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C ...@@ -133,43 +113,16 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
newRecGeo._boundsSelected = true; newRecGeo._boundsSelected = true;
return newRecGeo; return newRecGeo;
//marker._boundsSelected = true;
//marker._selectChildren = false;
/*if (eventListening) {
marker.onPropertyChange = itemPropertyChange;
marker.onMouseDown = itemMouseDown;
}*/
//drawMarker(marker);
// Add the marker to the list of markers. Only if in editing mode.
/*if (eventListening) {
_.some(_markers, function (m, idx) {
if (label < m.data.label) {
_markers.splice(idx, 0, marker);
return true;
}
return false;
}) || _markers.push(marker);
}*/
//return marker;
} }
function drawRecGeo(rectgeo, event) { function drawRecGeo(rectgeo, event) {
// data passed in prop obj // data passed in prop obj
prop = /*prop ||*/ {};
if (rectgeo.data) { if (rectgeo.data) {
var category = rectgeo.data.prop.category || 'default'; var category = rectgeo.data.prop.category || 'default';
var remplissage = rectgeo.data.prop.remplissage || 1;
var fill = rectgeo.data.prop.fill || "checked"; var fill = rectgeo.data.prop.fill || "checked";
} else { } else {
var category = 'default'; var category = 'default';
var remplissage = 1;
var fill = "checked"; var fill = "checked";
} }
...@@ -178,9 +131,9 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C ...@@ -178,9 +131,9 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
var colorbg = cat && cat.colorbg ||"grey"; var colorbg = cat && cat.colorbg ||"grey";
if (!_drawingLine) { if (!_drawingLine) {
_drawingLine = new paper.Path.Rectangle(_startPoint, event.point); //Shape("rectangle", _events); //new paper.Path.Line({from: _startPoint, to: event.point}); _drawingLine = new paper.Path.Rectangle(_startPoint, event.point);
if (fill == "checked") { if (fill == "checked") {
drawingLine.fillColor = colorbg; _drawingLine.fillColor = colorbg;
} }
_drawingLine.color=color; _drawingLine.color=color;
} }
...@@ -192,10 +145,6 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C ...@@ -192,10 +145,6 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
} }
function _terminateCreate(event) { function _terminateCreate(event) {
//var dstPoint = _drawingLine ? _drawingLine.segments[1].point.clone() : null;
/*if (!validatePosition(_startPoint, dstPoint))
return;
*/
if (_drawingLine) { if (_drawingLine) {
_drawingLine.remove(); _drawingLine.remove();
_drawingLine = null; _drawingLine = null;
...@@ -207,20 +156,6 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C ...@@ -207,20 +156,6 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
create = false; create = false;
} }
/* function itemMouseUp(event) {
if (!event.tool) // catches only tool's events
return;
if (_editedRecGeo) {
if (_recGeoChanged) {
_events.annotationChanged.dispatch([_editedRecGeo]);
_recGeoChanged = false;
}
}
_editedSegmentIdx = _editedStriaLeftIdx = _editedStriaRightIdx = _editedRecGeo = _editedSegmentXLimit = null;
}*/
function itemMouseDown(event) { function itemMouseDown(event) {
var hitItem = this; var hitItem = this;
_editedRecGeo = this; _editedRecGeo = this;
...@@ -231,40 +166,22 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C ...@@ -231,40 +166,22 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
hitItem.selected = true; hitItem.selected = true;
_events.annotationSelected.dispatch(hitItem); _events.annotationSelected.dispatch(hitItem);
console.log("tutu");
_editedSegmentIdx = null; _editedSegmentIdx = null;
console.log(hitResult);
if (hitResult) {
console.log(hitResult.type);
}
if (hitResult && hitResult.type === 'segment') { if (hitResult && hitResult.type === 'segment') {
_editedSegmentIdx = hitResult.segment.index; _editedSegmentIdx = hitResult.segment.index;
} else {
} }
/*_editedSegmentIdx = _editedStriaLeftIdx = _editedStriaRightIdx = _editedSegmentXLimit = null;
if (hitResult.type === 'segment') { _recGeoChanged = false;
_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); _events.annotationSelected.dispatch(hitItem);
} }
function itemMouseDrag(event) { function itemMouseDrag(event) {
console.log("itemmousedrag");
// Handle only event forwarded by tools // Handle only event forwarded by tools
if (!event.tool) if (!event.tool)
return; return;
if (_editedSegmentIdx !== null) { if (_editedSegmentIdx !== null) {
console.log(_editedSegmentIdx);
var dstPoint = event.point.clone(); var dstPoint = event.point.clone();
_editedRecGeo.segments[_editedSegmentIdx].point = dstPoint; _editedRecGeo.segments[_editedSegmentIdx].point = dstPoint;
var deltaPoint = event.delta var deltaPoint = event.delta
...@@ -294,8 +211,6 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C ...@@ -294,8 +211,6 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
this.data.origin.to.y += deltaPoint.y; this.data.origin.to.y += deltaPoint.y;
break; break;
} }
//if (event.event.shiftKey)
// _horizontalize(_editedRecGeo, _editedSegmentIdx);
} else { } else {
this.translate(event.delta); this.translate(event.delta);
this.data.origin.from.x += event.delta.x; this.data.origin.from.x += event.delta.x;
...@@ -321,7 +236,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C ...@@ -321,7 +236,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
if (property === 'category') { if (property === 'category') {
_setCategory.call(this, value); _setCategory.call(this, value);
this.style = { this.style = {
fillColor: _getColorBg(value), fillColor: _getColorBg(value),
strokeColor: _getColor(value) strokeColor: _getColor(value)
}; };
paper.view.draw(); paper.view.draw();
...@@ -335,15 +250,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C ...@@ -335,15 +250,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
create = false; create = false;
} }
/*function validatePosition(from, to){
// A concordant stria should cross the cut
return (from.x <= _cutPosition && to.x >= (_cutPosition + _cutThreshold) ) ||
(from.x >= _cutPosition && to.x <= (_cutPosition - _cutThreshold) );
}*/
// ----- Tool Def ------------------------------------- // ----- Tool Def -------------------------------------
//var toolDef = new Shape("rectangle", _events);
var toolDef = { var toolDef = {
onMouseDown: function(event) { onMouseDown: function(event) {
...@@ -352,7 +259,6 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C ...@@ -352,7 +259,6 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
_terminateCreate(); _terminateCreate();
} }
} else { } else {
var hitResult = paper.project.activeLayer.hitTest(event.point, hitOptions); var hitResult = paper.project.activeLayer.hitTest(event.point, hitOptions);
if (!hitResult) { if (!hitResult) {
paper.project.deselectAll(); paper.project.deselectAll();
...@@ -370,25 +276,17 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C ...@@ -370,25 +276,17 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
} else { } else {
hitResult.item.onMouseDown(event); hitResult.item.onMouseDown(event);
} }
} }
}, },
onMouseDrag: function(event) { onMouseDrag: function(event) {
console.info("onMouseDrag");
if (create && _startPoint) { if (create && _startPoint) {
terminateOnRelease = true; terminateOnRelease = true;
drawRecGeo(this,event); drawRecGeo(this,event);
_//editedRecGeo = _drawingLine;
} }
/*if (_editedRecGeo) {
itemMouseDrag(event);
}*/
}, },
onMouseMove: function(event) { onMouseMove: function(event) {
console.info("onMouseMove");
if (create && _startPoint) { if (create && _startPoint) {
drawRecGeo(this,event); drawRecGeo(this,event);
} }
...@@ -400,92 +298,24 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C ...@@ -400,92 +298,24 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
drawRecGeo(this,event); drawRecGeo(this,event);
_terminateCreate(event); _terminateCreate(event);
} }
}/* else { }
if (_editedRecGeo) {
_editedRecGeo.data.itemMouseUp(event);
}
}*/
_editedSegmentIdx = _editedRecGeo = null; _editedSegmentIdx = _editedRecGeo = null;
}, },
onKeyDown: function(event) { onKeyDown: function(event) {
//console.log( event.key );
switch (event.key) { switch (event.key) {
/*case "enter":
if (create)
_terminateCreate(event);
break;*/
case "escape": case "escape":
if (create) if (create)
cancelCreate(); cancelCreate();
break; break;
/*case "shift":
if (_drawingLine) {
_horizontalize(_drawingLine, 1);
} else if (_editedRecGeo && _editedSegmentIdx !== null) {
_horizontalize(_editedRecGeo, _editedSegmentIdx);
}
break;*/
/*case "up":
case"down":
var items = paper.project.getSelectedItems();
for (var i=0,item;item=items[i];i++){
if (item.data.type && typeof item.onKeyDown === 'function') {
item.onKeyDown(event);
break;
}
}
break;*/
}
},
/*onKeyUp: function (event) {
//console.log( event.key );
switch (event.key) {
case "shift":
if (_drawingLine) {
_horizontalize(_drawingLine, 1, true);
} else if (_editedRecGeo && _editedSegmentIdx) {
_horizontalize(_editedRecGeo, _editedSegmentIdx, true);
}
break;
case "up":
case"down":
var items = paper.project.getSelectedItems();
for (var i=0,item;item=items[i];i++){
if (item.data.type && typeof item.onKeyUp === 'function') {
item.onKeyUp(event);
break;
}
}
break;
} }
}*/ }
}; };
//var exportJSON = toolDef.exportJSON;
//delete(toolDef.exportJSON);
//var importJSON = toolDef.importJSON;
//delete(toolDef.importJSON);
// ----- Initialisations ------------------------------
// ----- Functions ------------------------------------ // ----- Functions ------------------------------------
function _setCategory(catId) { function _setCategory(catId) {
var category = Category.getCategory(catId),
color = (category && category.color) || "#000000";
//_setColor.call(this, color);
defaultProperties.category = catId; defaultProperties.category = catId;
} }
...@@ -502,9 +332,13 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C ...@@ -502,9 +332,13 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper, Shape, C
} }
function _getColorBgD() { function _getColorBgD() {
var category = Category.getCategory(this.prop.category), if (this.prop){
color = (category && category.colorbg) || "#000000"; var category = Category.getCategory(this.prop.category),
return color; color = (category && category.colorbg) || "#000000";
return color;
} else {
return "#000000";
}
} }
......
...@@ -1525,41 +1525,7 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export ...@@ -1525,41 +1525,7 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export
var catBut = this.el.find(".btn-cat.active"); var catBut = this.el.find(".btn-cat.active");
return catBut.length === 1 ? catBut.data('category') : ""; return catBut.length === 1 ? catBut.data('category') : "";
} }
}, }
'remplissage': {
el: "#prop-annot-remplissage",
enable: function(status) {
status = (status !== void(0)) ? !!status : true;
//if (config.mode !== config.MODE_EDIT)
if ((config.mode === 'review') ||
(config.annotable && config.annotable.locked))
status = false;
if (status) {
this.el.removeAttr("disabled");
} else {
this.el.attr("disabled","disabled");
}
this.el.closest(".property-group").toggleClass("disabled", !status);
return this;
},
setValue: function(value) { this.el.val(value); return this; },
getValue: function() { return this.el.val(); },
init: function() {
var me = this;
var intervalId = null;
me.el.on('keyup', function(event) {
if (intervalId)
clearTimeout(intervalId);
intervalId = setTimeout(function(){
updateSelectedItemProp('remplissage');
intervalId = null;
}, 500);
});
}
},
}; };
......
...@@ -11,7 +11,8 @@ import os ...@@ -11,7 +11,8 @@ import os
import sys import sys
__all__ = ('application', ) __all__ = ('application', )
_virtualenv_path = "//anaconda/envs/adim" #_virtualenv_path = "//anaconda/envs/adim"
_virtualenv_path = "/home/kury/PycharmProjects/adim/workspace/adim.env"
_settings_module = "adim_project.settings.local" _settings_module = "adim_project.settings.local"
_project_settings = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) _project_settings = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
......
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