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): ...@@ -9,16 +9,7 @@ class AnObjAdmin(admin.ModelAdmin):
list_filter = ('owner',) list_filter = ('owner',)
admin.site.register(AnObj, AnObjAdmin) 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): class AnnotationAdmin(admin.ModelAdmin):
list_filter = ('annotable', ) list_filter = ('annotable', )
admin.site.register(Annotation, AnnotationAdmin) admin.site.register(Annotation, AnnotationAdmin)
# coding=utf-8 # coding=utf-8
from annotables import AOType, AOSchema, AOChoice, AOAttribute, AnObj, AnObjMembership, EnvParam from annotables import AnObj, AnObjMembership, EnvParam
from annotations import Annotation from annotations import Annotation
__all__ = ( __all__ = (
'AOType', 'AOSchema', 'AOChoice', 'AOAttribute', 'AnObj', 'AnObj', 'AnObjMembership', 'Annotation', 'EnvParam'
'AnObjMembership', 'Annotation', 'EnvParam'
) )
...@@ -20,7 +20,8 @@ from eav.models import BaseSchema, BaseAttribute, BaseChoice ...@@ -20,7 +20,8 @@ from eav.models import BaseSchema, BaseAttribute, BaseChoice
from adim_utils.decorators import cache 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() # code from from uuid._random_getnode()
RANDOM_NODE = random.randrange(0, 1 << 48L) | 0x010000000000L RANDOM_NODE = random.randrange(0, 1 << 48L) | 0x010000000000L
...@@ -32,52 +33,54 @@ AO_ENVIRON = ( ...@@ -32,52 +33,54 @@ AO_ENVIRON = (
('', 'Standard'), ('', 'Standard'),
('cimaf', 'CIMAF'), ('cimaf', 'CIMAF'),
('anodate', 'Datation'), ('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: # class AOType(models.Model):
app_label = "adim" # name = models.CharField(max_length=128)
verbose_name = "Annotable Object Type" # title = models.CharField(max_length=512, blank=True, default="")
#
def __unicode__(self): # class Meta:
if self.title: # app_label = "adim"
return u"{} ({})".format(self.title, self.name) # verbose_name = "Annotable Object Type"
else: #
return self.name # def __unicode__(self):
# if self.title:
# return u"{} ({})".format(self.title, self.name)
class AOSchema(BaseSchema): # else:
ao_types = models.ManyToManyField(AOType, blank=True) # return self.name
class Meta:
app_label = "adim" # class AOSchema(BaseSchema):
verbose_name = "Annotable Object Schema" # ao_types = models.ManyToManyField(AOType, blank=True)
verbose_name_plural = "Annotable Object Schemata" #
# class Meta:
# AOSchema._meta.get_field_by_name('datatype')[0]._choices += (('image', u'image file'), ) # app_label = "adim"
# verbose_name = "Annotable Object Schema"
# verbose_name_plural = "Annotable Object Schemata"
class AOChoice(BaseChoice): #
schema = models.ForeignKey(AOSchema, related_name='choices') # # AOSchema._meta.get_field_by_name('datatype')[0]._choices += (('image', u'image file'), )
class Meta:
app_label = "adim" # class AOChoice(BaseChoice):
verbose_name = "Annotable Object Choice" # schema = models.ForeignKey(AOSchema, related_name='choices')
#
# class Meta:
class AOAttribute(BaseAttribute): # app_label = "adim"
schema = models.ForeignKey(AOSchema, related_name='attrs') # verbose_name = "Annotable Object Choice"
choice = models.ForeignKey(AOChoice, blank=True, null=True)
#
value_image = models.ImageField(upload_to="ao", blank=True, null=True) # class AOAttribute(BaseAttribute):
# schema = models.ForeignKey(AOSchema, related_name='attrs')
class Meta: # choice = models.ForeignKey(AOChoice, blank=True, null=True)
app_label = "adim" # #
verbose_name = "Annotable Object Attribute" # value_image = models.ImageField(upload_to="ao", blank=True, null=True)
verbose_name_plural = "Annotable Object Attributes" #
# class Meta:
# app_label = "adim"
# verbose_name = "Annotable Object Attribute"
# verbose_name_plural = "Annotable Object Attributes"
def get_image_path(instance, filename): def get_image_path(instance, filename):
...@@ -274,6 +277,7 @@ class EnvParam(models.Model): ...@@ -274,6 +277,7 @@ class EnvParam(models.Model):
permissions = ( permissions = (
('set_env_cimaf', "Set CIMAF environment"), ('set_env_cimaf', "Set CIMAF environment"),
('set_env_anodate', "Set Anodate environment"), ('set_env_anodate', "Set Anodate environment"),
('set_env_geomo', "Set Geomorpho environment"),
) )
def init(self): def init(self):
......
...@@ -91,6 +91,16 @@ module.exports = function(grunt) { ...@@ -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: { cimaf_analysis: {
options: { options: {
paths: { paths: {
......
...@@ -15,22 +15,32 @@ define(["underscore", "paper", "signals"], function (_, paper, Signal) { ...@@ -15,22 +15,32 @@ define(["underscore", "paper", "signals"], function (_, paper, Signal) {
* @private * @private
*/ */
function _init(parameters){ function _init(parameters){
var env = null;
if (parameters && parameters.env){
env = parameters.env;
}
// Init category container element // Init category container element
if (_.isString(_catContainer)) _catContainer = $(_catContainer); if (_.isString(_catContainer)) _catContainer = $(_catContainer);
_(_catContainer.find("[data-category]")).each(function(el, i){ _(_catContainer.find("[data-category]")).each(function(el, i){
var $el = $(el), var $el = $(el),
colorStr = $el.data('color') || $el.css("backgroundColor"), colorStr = $el.data('color') || $el.css("backgroundColor"),
colorBgStr = $el.data('colorBg') || $el.css("backgroundColor"),
id = $el.data('category'); id = $el.data('category');
_categories[id] = { _categories[id] = {
id: id, id: id,
color: _getColorFromStr(colorStr) color: _getColorFromStr(colorStr),
colorbg: _getColorFromStr(colorBgStr)
}; };
if (i == 0) { if (i == 0) {
_categories['default'] = _categories[id]; _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 ...@@ -159,11 +159,11 @@ function ($, paper, Signal, config, view, io, tools, attributes, ui, Users, them
}); });
io.events.annotationsSavedStatusChanged.add(function(data){ io.events.annotationsSavedStatusChanged.add(function(data){
console.log("save state", data.status); //console.log("save state", data.status);
}); });
io.events.loadingError.add(function(options){ io.events.loadingError.add(function(options){
console.error("io::loadingError", options); //console.error("io::loadingError", options);
}); });
} }
......
...@@ -40,7 +40,15 @@ define([ ...@@ -40,7 +40,15 @@ define([
"tools/cmsarea", "tools/cmsarea",
// ----- ANODATE tool // ----- ANODATE tool
"tools/marker" "tools/marker",
// ----- GEOMO tool
"tools/drawinggeo",