Gitlab CSE Unil

Commit b00512d9 authored by Julien Furrer's avatar Julien Furrer
Browse files

Ajouté environ pour Datation et création nouvel outil "makrer"

parent 3e8671e9
...@@ -12,10 +12,6 @@ ...@@ -12,10 +12,6 @@
adim_project/apache.conf* adim_project/apache.conf*
adim_project/generate_apache_conf.py adim_project/generate_apache_conf.py
adim_app/playground.py
/templates/playground
adim_app/static/js/playground.js
adim_project/wsgi.example.py adim_project/wsgi.example.py
adim_project/wsgi-off.py adim_project/wsgi-off.py
\ No newline at end of file
...@@ -19,5 +19,6 @@ admin.site.register(AnObj, AnObjAdmin) ...@@ -19,5 +19,6 @@ admin.site.register(AnObj, AnObjAdmin)
# list_filter = ('schema', ) # list_filter = ('schema', )
# admin.site.register(AOChoice, AOChoiceAdmin) # admin.site.register(AOChoice, AOChoiceAdmin)
# admin.site.register(AOAttribute) # admin.site.register(AOAttribute)
class AnnotationAdmin(admin.ModelAdmin):
admin.site.register(Annotation) list_filter = ('annotable', )
\ No newline at end of file admin.site.register(Annotation, AnnotationAdmin)
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('adim', '0006_envparam'),
]
operations = [
migrations.AddField(
model_name='envparam',
name='categories_set',
field=models.CharField(max_length=64, blank=True),
),
migrations.AlterField(
model_name='anobj',
name='env',
field=models.CharField(blank=True, max_length=64, choices=[('', 'Standard'), ('cimaf', 'CIMAF'), ('playground', 'Pour Voir')]),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('adim', '0007_auto_20150714_0815'),
]
operations = [
migrations.RenameField(
model_name='envparam',
old_name='categories_set',
new_name='category_set_name',
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('adim', '0008_auto_20150714_0817'),
]
operations = [
migrations.AlterModelOptions(
name='envparam',
options={'verbose_name': 'Environment params', 'permissions': (('set_env_cimaf', 'Set CIMAF environment'),)},
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('adim', '0009_auto_20150715_1144'),
]
operations = [
migrations.AlterModelOptions(
name='envparam',
options={'verbose_name': 'Environment params', 'permissions': (('set_env_cimaf', 'Set CIMAF environment'), ('set_env_playground', 'Set PlayGround environment'))},
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('adim', '0010_auto_20150715_1252'),
]
operations = [
migrations.AlterField(
model_name='anobj',
name='env',
field=models.CharField(blank=True, max_length=64, choices=[('', 'Standard'), ('cimaf', 'CIMAF'), ('anodate', 'Datation')]),
),
]
...@@ -31,6 +31,7 @@ AO_IMAGES_PATH = 'ao_images' ...@@ -31,6 +31,7 @@ AO_IMAGES_PATH = 'ao_images'
AO_ENVIRON = ( AO_ENVIRON = (
('', 'Standard'), ('', 'Standard'),
('cimaf', 'CIMAF'), ('cimaf', 'CIMAF'),
('anodate', 'Datation'),
) )
class AOType(models.Model): class AOType(models.Model):
...@@ -260,6 +261,9 @@ class AnObjMembership(models.Model): ...@@ -260,6 +261,9 @@ class AnObjMembership(models.Model):
class EnvParam(models.Model): class EnvParam(models.Model):
anobj = models.OneToOneField(AnObj) anobj = models.OneToOneField(AnObj)
# ----- Categories Set
category_set_name = models.CharField(max_length=64, blank=True)
# ----- CIMAF # ----- CIMAF
cimaf_cut_pos = models.IntegerField(blank=True, null=True) cimaf_cut_pos = models.IntegerField(blank=True, null=True)
cimaf_cut_margin = models.IntegerField(blank=True, null=True) cimaf_cut_margin = models.IntegerField(blank=True, null=True)
...@@ -267,6 +271,10 @@ class EnvParam(models.Model): ...@@ -267,6 +271,10 @@ class EnvParam(models.Model):
class Meta: class Meta:
app_label = "adim" app_label = "adim"
verbose_name = "Environment params" verbose_name = "Environment params"
permissions = (
('set_env_cimaf', "Set CIMAF environment"),
('set_env_playground', "Set PlayGround environment"),
)
def init(self): def init(self):
need_to_save = False need_to_save = False
......
...@@ -81,6 +81,16 @@ module.exports = function(grunt) { ...@@ -81,6 +81,16 @@ module.exports = function(grunt) {
} }
}, },
anodate_app: {
options: {
paths: {
env: "_build/adim/env/anodate"
},
name: "../js/anodate_app",
out: "../js/anodate_app" + jsOptimizedSuffix + ".js"
}
},
cimaf_analysis: { cimaf_analysis: {
options: { options: {
paths: { paths: {
......
...@@ -134,7 +134,9 @@ function (_, paper, Signal, view) { ...@@ -134,7 +134,9 @@ function (_, paper, Signal, view) {
} }
// ----- Ordering // --------
// Ordering
// --------
function _changeOrderOfSelection(direction) { function _changeOrderOfSelection(direction) {
var selectedItems = view.getSelectedAnnotations(); var selectedItems = view.getSelectedAnnotations();
if (selectedItems.length > 0) { if (selectedItems.length > 0) {
...@@ -169,7 +171,10 @@ function (_, paper, Signal, view) { ...@@ -169,7 +171,10 @@ function (_, paper, Signal, view) {
} }
} }
// ----- Color
// -----
// Color
// -----
function setColor(color, fireAnnotationChange, silent) { function setColor(color, fireAnnotationChange, silent) {
_color = new paper.Color(color); _color = new paper.Color(color);
paper.project.currentStyle.strokeColor = _color; paper.project.currentStyle.strokeColor = _color;
...@@ -195,7 +200,9 @@ function (_, paper, Signal, view) { ...@@ -195,7 +200,9 @@ function (_, paper, Signal, view) {
} }
// ----- Filling mode ---------- // ------------
// Filling mode
// ------------
function setFill(isFill, fireAnnotationChange, silent) { function setFill(isFill, fireAnnotationChange, silent) {
_isFill = !!isFill; _isFill = !!isFill;
paper.project.currentStyle.fillColor = _isFill ? _color : null; paper.project.currentStyle.fillColor = _isFill ? _color : null;
...@@ -220,7 +227,9 @@ function (_, paper, Signal, view) { ...@@ -220,7 +227,9 @@ function (_, paper, Signal, view) {
fireAnnotationChange); fireAnnotationChange);
} }
// ----- Fonts ---------- // -----
// Fonts
// -----
function setFontSize(size, fireAnnotationChange, silent) { function setFontSize(size, fireAnnotationChange, silent) {
_fontSize = size; _fontSize = size;
paper.project.currentStyle.fontSize = size; paper.project.currentStyle.fontSize = size;
...@@ -241,7 +250,9 @@ function (_, paper, Signal, view) { ...@@ -241,7 +250,9 @@ function (_, paper, Signal, view) {
} }
// ----- StrokeWidth ---------- // -----------
// StrokeWidth
// -----------
var _maxStrokeWidth = 50; var _maxStrokeWidth = 50;
var _minStrokeWidth = 1; var _minStrokeWidth = 1;
function setStrokeWidth(width, fireAnnotationChange, silent) { function setStrokeWidth(width, fireAnnotationChange, silent) {
...@@ -253,7 +264,6 @@ function (_, paper, Signal, view) { ...@@ -253,7 +264,6 @@ function (_, paper, Signal, view) {
function getStrokeWidth() { function getStrokeWidth() {
return _strokeWidth; return _strokeWidth;
//return paper.project.currentStyle.strokeWidth;
} }
var _updateStrokeWidth = _.debounce(setStrokeWidth, 300); var _updateStrokeWidth = _.debounce(setStrokeWidth, 300);
...@@ -276,7 +286,9 @@ function (_, paper, Signal, view) { ...@@ -276,7 +286,9 @@ function (_, paper, Signal, view) {
} }
// ----- Item Opacity ----------- // ------------
// Item Opacity
// ------------
/** /**
* Set the item opacity * Set the item opacity
* @param opacity * @param opacity
...@@ -291,7 +303,6 @@ function (_, paper, Signal, view) { ...@@ -291,7 +303,6 @@ function (_, paper, Signal, view) {
function getOpacity() { function getOpacity() {
return _opacity; return _opacity;
//return paper.project.currentStyle.strokeWidth;
} }
function opacitySelectedItems(opacity, fireAnnotationChange) { function opacitySelectedItems(opacity, fireAnnotationChange) {
...@@ -305,7 +316,9 @@ function (_, paper, Signal, view) { ...@@ -305,7 +316,9 @@ function (_, paper, Signal, view) {
} }
// ----- Image Opacity ---------- // -------------
// Image Opacity
// -------------
/** /**
* Set the image opacity. opacity param is a number 1-100 * Set the image opacity. opacity param is a number 1-100
* @param {Number} opacity 1-100 the opacity value to be set * @param {Number} opacity 1-100 the opacity value to be set
...@@ -319,11 +332,12 @@ function (_, paper, Signal, view) { ...@@ -319,11 +332,12 @@ function (_, paper, Signal, view) {
function getImageOpacity() { function getImageOpacity() {
return _imgopacity; return _imgopacity;
//return paper.project.currentStyle.strokeWidth;
} }
// ----- Zoom ---------- // ----
// Zoom
// ----
var _maxZoom = 10; var _maxZoom = 10;
var _minZoom = 0.1; var _minZoom = 0.1;
/** /**
...@@ -380,6 +394,7 @@ function (_, paper, Signal, view) { ...@@ -380,6 +394,7 @@ function (_, paper, Signal, view) {
} }
// ----- Returned Module ------------------------------ // ----- Returned Module ------------------------------
return { return {
......
/**
* Item category management
*
* Created by jfurrer on 08.07.15.
*/
define(["underscore", "paper", "signals"], function (_, paper, Signal) {
var _catContainer = "#prop-annot-category"; // will be replaced by the jQuery element corresponding to the selector
var _categories = {};
/**
* Initialization, should be called when DOM is ready
* @param parameters
* @private
*/
function _init(parameters){
// Init category container element
if (_.isString(_catContainer)) _catContainer = $(_catContainer);
_(_catContainer.find("[data-category]")).each(function(el, i){
var $el = $(el),
colorStr = $el.data('color') || $el.css("backgroundColor"),
id = $el.data('category');
_categories[id] = {
id: id,
color: _getColorFromStr(colorStr)
};
if (i == 0) {
_categories['default'] = _categories[id];
}
});
}
/**
* Convert a css color property of the form 'rgb(128, 64, 32)' to hex or paperjs Color
*
* @param {string} colorStr The string of the form rgba?(\d+,\d+,\d+(,\d+)?)
* @param {boolean} [asPaperColor=false] If true, return as paper.Color object
* @returns {*}
* @private
*/
function _getColorFromStr(colorStr, asPaperColor) {
var color;
if (colorStr.indexOf('rgb') === 0) {
var colA = colorStr.split(/[(),]/)
.map(function(part){return parseFloat(part.trim())})
.filter(function(n){ return !isNaN(n)});
color = new paper.Color(colA[0] / 255, colA[1] / 255, colA[2] / 255);
} else {
color = new paper.Color(colorStr);
}
return (asPaperColor) ? color : color.toCSS(true);
}
return {
init: _init,
getCategory: function(cat) {
return _categories[cat];
}
}
});
\ No newline at end of file
/**
* anodate environment
*
* Created by jfurrer on 30.06.15.
*/
define([
"jquery",
"underscore",
"paper",
"signals",
"adim/config",
"adim/view",
"adim/attributes",
"adim/io",
"adim/tools",
"adim/ui",
"adim/category",
"env/shortcuts",
"tools/marker-ui"
],
function($, _, paper, Signal, config, view, attributes, io, tools, ui, category, shortcuts, markerUI){
/**
* Signal binding specific to anodate environment
* @private
*/
function _initSignalRouting(){
console.info("_initSignalRouting from env/anodate");
io.events.annotableLoaded.add(function(annotableData){
// p.raster is a paper.Raster
view.events.annotationRemoved.add(function(annotation){
if (annotation.data.type === 'marker') {
tools.tools['marker'].listeners.updateNumbering();
}
});
view.events.imageLoaded.add(function(p){
// Here we initilize tools that needs some image properties
});
}, 100);
// called after all other handlers
view.events.annotationsLoaded.add(function() {
tools.tools['marker'].listeners.updateNumbering();
}, -100);
ui.events.modeChanged.add(function(opts) {
var mode = opts.mode;
if (mode === 'edit') {
$("#annotation-display-panel").hide();
$("#annotation-property-panel").show();
} else if (mode === 'review') {
$("#annotation-display-panel").show();
$("#annotation-property-panel").hide();
}
});
}
/**
* UI initialization specific to anodate environment
* @param params
* @private
*/
function _initUI(params) {
category.init();
markerUI.init(params);
// hide color picker
$("#tool-colorselect").find(".color-menu").addClass("no-picker");
// Init Type Display Selector
$(".adim-display-type-selector").find("button").on('click', function(event) {
var $but = $(this);
var activate = !$but.hasClass("active");
var category = $but.data('category');
if (event.metaKey) {
//if (category !== 'image') {
// view.selectItemsByType(category);
//}
} else {
$but.toggleClass("active", activate);
if (category === 'image') {
attributes.setImageOpacity(activate ? 100 : 0, true);
//_opacitySlider.slider('setValue', activate ? 100 : 0);
} else {
view.toggleItemsByProp({prop: 'category', val: category, undef: true}, activate);
}
}
});
// Init Side Col Panel layout
var sideCol = $("#side-col"),
canvasCtnr = $(".canvas-container"),
sideColPanelGroup = $("#side-col-panel-group"),
altSideColPanelGroup = $("#alt-side-col-panel-group"),
sharedAnnotationMarkersPanel = $("#shared-annotation-markers-panel");
function displayAltCol(show) {
sideCol.toggleClass("col-sm-1", !show)
.toggleClass("col-sm-2", show);
altSideColPanelGroup.toggleClass("hidden", !show);
sideColPanelGroup.toggleClass("col-xs-12", !show)
.toggleClass("col-xs-6", show);
}
function displayAltColAndLabels(show) {
displayAltCol(show && sharedAnnotationMarkersPanel.find(".panel-collapse").hasClass("in"));
sharedAnnotationMarkersPanel.toggleClass("hidden", !show);
}
displayAltColAndLabels(params.mode === 'review');
ui.events.modeChanged.add(function(opts) {
var mode = opts.mode;
displayAltColAndLabels(mode === 'review');
ui.updateReservedSpace();
ui.adjustCanvasToImage();
});
sharedAnnotationMarkersPanel.find(".panel-collapse")
.on('hidden.bs.collapse', function () {
canvasCtnr.css("transition", 'width 0.2s cubic-bezier(0.25, 0.1, 0.25, 1) 0s');
sharedAnnotationMarkersPanel.prependTo(sideColPanelGroup);
displayAltCol(false);
ui.updateReservedSpace();
ui.adjustCanvasToImage();
canvasCtnr.css("transition", "");
})
.on('show.bs.collapse', function () {
displayAltCol(true);
sharedAnnotationMarkersPanel.appendTo(altSideColPanelGroup);
ui.updateReservedSpace();
ui.adjustCanvasToImage();
})
;
}
/**
* Define initial strokeColor from the forth color of the current color palette.
* This has to be define as a getter function as we cannot compute the color before
* the DOM is ready. The ``style`` property is accessed in the $.ready handler of main.
*
* @returns {{strokeColor: *}}
* @private
*/
function _getStyle() {
var colStr = $("#tool-colorselect").find(".color-menu .c4").css("backgroundColor");
var color;
if (colStr.indexOf('rgb') === 0) {
var colA = colStr.split(/[(),]/)
.map(function(part){return parseFloat(part.trim())})
.filter(function(n){ return !isNaN(n)});
color = new paper.Color(colA[0] / 255, colA[1] / 255, colA[2] / 255);
} else {
color = new paper.Color(colStr);
}
return {
strokeColor: color
}
}
var env = {
name: 'anodate',
shortcuts: shortcuts,