Gitlab CSE Unil

Commit 607b9f29 authored by M. Chardon's avatar M. Chardon
Browse files

Merge remote-tracking branch 'origin/dev'

Conflicts:
	adim_project/adim_app/static/css/adim.css
parents 558b16c5 de1b24d0
......@@ -9,16 +9,7 @@ class AnObjAdmin(admin.ModelAdmin):
list_filter = ('owner',)
admin.site.register(AnObj, AnObjAdmin)
# admin.site.register(AOType)
# class AOSchemaAdmin(BaseSchemaAdmin):
# filter_horizontal = ('ao_types', )
# admin.site.register(AOSchema, AOSchemaAdmin)
# class AOChoiceAdmin(admin.ModelAdmin):
# list_filter = ('schema', )
# admin.site.register(AOChoice, AOChoiceAdmin)
# admin.site.register(AOAttribute)
class AnnotationAdmin(admin.ModelAdmin):
list_filter = ('annotable', )
admin.site.register(Annotation, AnnotationAdmin)
# coding=utf-8
from annotables import AOType, AOSchema, AOChoice, AOAttribute, AnObj, AnObjMembership, EnvParam
from annotables import AnObj, AnObjMembership, EnvParam
from annotations import Annotation
__all__ = (
'AOType', 'AOSchema', 'AOChoice', 'AOAttribute', 'AnObj',
'AnObjMembership', 'Annotation', 'EnvParam'
'AnObj', 'AnObjMembership', 'Annotation', 'EnvParam'
)
......@@ -20,7 +20,8 @@ from eav.models import BaseSchema, BaseAttribute, BaseChoice
from adim_utils.decorators import cache
__all__ = ('AOType', 'AOSchema', 'AOChoice', 'AOAttribute', 'AnObj', 'AnObjMembership', 'EnvParam')
# __all__ = ('AOType', 'AOSchema', 'AOChoice', 'AOAttribute', 'AnObj', 'AnObjMembership', 'EnvParam')
__all__ = ('AnObj', 'AnObjMembership', 'EnvParam')
# code from from uuid._random_getnode()
RANDOM_NODE = random.randrange(0, 1 << 48L) | 0x010000000000L
......@@ -32,52 +33,54 @@ AO_ENVIRON = (
('', 'Standard'),
('cimaf', 'CIMAF'),
('anodate', 'Datation'),
('geomo', 'Géomorpho'),
)
class AOType(models.Model):
name = models.CharField(max_length=128)
title = models.CharField(max_length=512, blank=True, default="")
class Meta:
app_label = "adim"
verbose_name = "Annotable Object Type"
def __unicode__(self):
if self.title:
return u"{} ({})".format(self.title, self.name)
else:
return self.name
class AOSchema(BaseSchema):
ao_types = models.ManyToManyField(AOType, blank=True)
class Meta:
app_label = "adim"
verbose_name = "Annotable Object Schema"
verbose_name_plural = "Annotable Object Schemata"
# AOSchema._meta.get_field_by_name('datatype')[0]._choices += (('image', u'image file'), )
class AOChoice(BaseChoice):
schema = models.ForeignKey(AOSchema, related_name='choices')
class Meta:
app_label = "adim"
verbose_name = "Annotable Object Choice"
class AOAttribute(BaseAttribute):
schema = models.ForeignKey(AOSchema, related_name='attrs')
choice = models.ForeignKey(AOChoice, blank=True, null=True)
#
value_image = models.ImageField(upload_to="ao", blank=True, null=True)
class Meta:
app_label = "adim"
verbose_name = "Annotable Object Attribute"
verbose_name_plural = "Annotable Object Attributes"
# class AOType(models.Model):
# name = models.CharField(max_length=128)
# title = models.CharField(max_length=512, blank=True, default="")
#
# class Meta:
# app_label = "adim"
# verbose_name = "Annotable Object Type"
#
# def __unicode__(self):
# if self.title:
# return u"{} ({})".format(self.title, self.name)
# else:
# return self.name
# class AOSchema(BaseSchema):
# ao_types = models.ManyToManyField(AOType, blank=True)
#
# class Meta:
# app_label = "adim"
# verbose_name = "Annotable Object Schema"
# verbose_name_plural = "Annotable Object Schemata"
#
# # AOSchema._meta.get_field_by_name('datatype')[0]._choices += (('image', u'image file'), )
# class AOChoice(BaseChoice):
# schema = models.ForeignKey(AOSchema, related_name='choices')
#
# class Meta:
# app_label = "adim"
# verbose_name = "Annotable Object Choice"
# class AOAttribute(BaseAttribute):
# schema = models.ForeignKey(AOSchema, related_name='attrs')
# choice = models.ForeignKey(AOChoice, blank=True, null=True)
# #
# value_image = models.ImageField(upload_to="ao", blank=True, null=True)
#
# class Meta:
# app_label = "adim"
# verbose_name = "Annotable Object Attribute"
# verbose_name_plural = "Annotable Object Attributes"
def get_image_path(instance, filename):
......@@ -274,6 +277,7 @@ class EnvParam(models.Model):
permissions = (
('set_env_cimaf', "Set CIMAF environment"),
('set_env_anodate', "Set Anodate environment"),
('set_env_geomo', "Set Geomorpho environment"),
)
def init(self):
......
......@@ -91,6 +91,16 @@ module.exports = function(grunt) {
}
},
geomo_app: {
options: {
paths: {
env: "_build/adim/env/geomo"
},
name: "../js/geomo_app",
out: "../js/geomo_app" + jsOptimizedSuffix + ".js"
}
},
cimaf_analysis: {
options: {
paths: {
......
......@@ -15,22 +15,32 @@ define(["underscore", "paper", "signals"], function (_, paper, Signal) {
* @private
*/
function _init(parameters){
var env = null;
if (parameters && parameters.env){
env = parameters.env;
}
// 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"),
colorBgStr = $el.data('colorBg') || $el.css("backgroundColor"),
id = $el.data('category');
_categories[id] = {
id: id,
color: _getColorFromStr(colorStr)
color: _getColorFromStr(colorStr),
colorbg: _getColorFromStr(colorBgStr)
};
if (i == 0) {
_categories['default'] = _categories[id];
}
});
_categories['default'] = _categories['cat_2'];
if (env && env=='geomo'){
_categories['default'] = _categories['cat_geo_1'];
} else {
_categories['default'] = _categories['cat_2'];
}
}
/**
......
/**
*
* Created by mchardon on 11.01.17.
*/
define([
"jquery",
"underscore",
"paper",
"signals",
"adim/config",
"adim/view",
"adim/attributes",
"adim/io",
"adim/tools",
"adim/ui",
"adim/category",
"env/shortcuts"
],
function($, _, paper, Signal, config, view, attributes, io, tools, ui, category, shortcuts){
/**
* Signal binding specific to anodate environment
* @private
*/
function _initSignalRouting(){
console.info("_initSignalRouting from env/geomo");
io.events.annotableLoaded.add(function(annotableData){
// p.raster is a paper.Raster
view.events.annotationRemoved.add(function(annotation){
/*if (annotation.data.type === 'rectanglegeo') {
}*/
});
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() {
}, -100);
ui.events.modeChanged.add(function(opts) {
var mode = opts.mode;
if (mode === 'edit') {
$("#annotation-display-panel").hide();
$("div.property-group").show();
} else if (mode === 'review') {
$("#annotation-display-panel").show();
$("div.property-group").hide();
$("div.comment-prop").show();
}
});
}
/**
* UI initialization specific to anodate environment
* @param params
* @private
*/
function _initUI(params) {
category.init({'env':env.name});
// 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 env = {
name: 'geomo',
shortcuts: shortcuts,
initSignalRouting: _initSignalRouting,
initUI: _initUI
};
Object.defineProperty(env, 'style', {get: _getStyle});
return env;
});
\ No newline at end of file
/**
* Copyright (C) 2014 Université de Lausanne, RISET,
* < http://www.unil.ch/riset/ >
* This file is part of AdIm.
* AdIm is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* AdIm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* This copyright notice MUST APPEAR in all copies of the file.
*
* @AUTHOR: marion.chardon@unil.ch
* @CREATION-DATE: 11.01.17
*
*/
define([
"jquery",
"paper",
"signals",
// ----- app
"adim/config",
"adim/view",
"adim/tools",
"adim/ui",
// plugins
"jquery.hotkeys"
],
function ($, paper, Signal, config, view, tools, ui) {
// Two contexts corresponding to the view modes: 'edit' and 'review'
var _keyblock = function(){ return function(){return false} };
var activeTool;
return {
// DELETE -> [edit]:delete selected annot. [review]:prevent default
'backspace del': [{
event: "keydown",
ctxt: "edit",
fn: function(){
view.removeSelectedItems();
return false;
}
}, {
event: "keydown",
ctxt: "review",
fn: _keyblock()
}],
// SPACEBAR -> [*]:activate pan tool while pressed, in all context
'space': [{
event: "keydown",
//ctxt: "*",
fn: function(){
if (!activeTool) {
activeTool = tools.getActiveTool();
tools.activateTool('pan');
}
return false;
}
}, {
event: "keyup",
//ctxt: "*",
fn: function(){
if (activeTool) {
tools.activateTool(activeTool);
activeTool = null;
}
return false;
}
}],
// A -> [edit]:activate select tool
'a': [{
event: "keydown",
ctxt: "edit",
fn: function(){
tools.activateTool('select');
return false;
}
}],
// CTRL-A -> [edit]:select all annotations in edit mode. [review]:prevent default
'ctrl+a meta+a': [{
event: "keydown",
ctxt: "edit",
fn: function(){
paper.project.activeLayer.children.map(function(c){c.selected = true;});
return false;
}
}, {
event: "keydown",
ctxt: "review",
fn: _keyblock()
}],
// D -> [edit]:activate drawing tool
'd': [{
event: "keydown",
ctxt: "edit",
fn: function(){
tools.activateTool('drawinggeo');
return false;
}
}],
// F -> [edit]:activate arrow tool
'f': [{
event: "keydown",
ctxt: "edit",
fn: function(){
tools.activateTool('arrowgeo');
return false;
}
}],
// L -> [edit]:activate lines tool
'l': [{
event: "keydown",
ctxt: "edit",
fn: function(){
tools.activateTool('linesgeo');
return false;
}
}],
// C -> [edit]:activate ellipse tool
'c': [{
event: "keydown",
ctxt: "edit",
fn: function(){
tools.activateTool('ellipsegeo');
return false;
}
}],
// R -> [edit]:activate rectangle tool
'r': [{
event: "keydown",
ctxt: "edit",
fn: function(){
tools.activateTool('rectanglegeo');
return false;
}
}],
// T -> [edit]:activate text tool
't': [{
event: "keydown",
ctxt: "edit",
fn: function(){
tools.activateTool('textgeo');
return false;
}
}]
}
}
);
......@@ -159,11 +159,11 @@ function ($, paper, Signal, config, view, io, tools, attributes, ui, Users, them
});
io.events.annotationsSavedStatusChanged.add(function(data){
console.log("save state", data.status);
//console.log("save state", data.status);
});
io.events.loadingError.add(function(options){
console.error("io::loadingError", options);
//console.error("io::loadingError", options);
});
}
......
......@@ -40,7 +40,15 @@ define([
"tools/cmsarea",
// ----- ANODATE tool
"tools/marker"
"tools/marker",
// ----- GEOMO tool
"tools/drawinggeo",
"tools/linesgeo",
"tools/ellipsegeo",
"tools/rectanglegeo",
"tools/arrowgeo",
"tools/textgeo"
],
function(_, Signal){
// ----- Locale variables -----------------------------
......
define(["paper", "tools/Shape.class","adim/category"], function (paper,Shape, Category) {
// ----- Const ----------------------------------------
var TOOL_TYPE = 'arrowgeo';
var _ro = false;
// ----- Local variables ------------------------------
// Events
var _events = {
annotationAdded: null,
annotationSelected: null,
annotationChanged: null
};
// Properties
var defaultProperties = {
comment: "",
category: "cat_geo_1",
fill: true
};
var _transparent = new paper.Color([0,0,0,0]);
// ----- Serialization ---------------------------------
function exportJSON(param) {
var fromPt = this.data.from;
var toPt = this.data.to;
var json = this.exportJSON({asString:false});
try {
json[1][1].data.from = [this.data.from.x, this.data.from.y];
json[1][1].data.to = [this.data.to.x, this.data.to.y];
} catch(e) {
console.error(e);
}