author | ymh <ymh.work@gmail.com> |
Mon, 19 Jan 2015 15:55:17 +0100 | |
changeset 96 | f58715468f1e |
parent 95 | 806739a26858 (current diff) |
parent 92 | a323578ea954 (diff) |
child 97 | 545803e685e0 |
client/annotviz/app/js/main.js | file | annotate | diff | comparison | revisions | |
client/annotviz/app/js/pianoroll.js | file | annotate | diff | comparison | revisions |
--- a/annot-server/settings.py.tmpl Mon Jan 19 13:31:28 2015 +0100 +++ b/annot-server/settings.py.tmpl Mon Jan 19 15:55:17 2015 +0100 @@ -11,3 +11,5 @@ LDT_PLATFORM_BASE_URL = 'http://ldt.iri.centrepompidou.fr/ldtplatform' SYNC_POST_PARAM = {} + +DEBUG = True \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/annotviz/app/js/annotsRoll.js Mon Jan 19 15:55:17 2015 +0100 @@ -0,0 +1,93 @@ +/** +* js/annotsRoll.js +* +* annotsRoll basic component +* +*/ + +'use strict'; + +var PIXI = require('pixi'); +var randomColor = require('randomColor'); + +function AnnotsRoll(parentContainer, xInit, yInit, width, height, widthRoll, pixelsPerSecond, annotColors, lineInterval){ + var _this = this; + this.container = new PIXI.DisplayObjectContainer(); + this.container.position.x = xInit; + this.container.position.y = yInit; + this.container.width = width; + parentContainer.addChild(this.container); + + this.height = height; + this.width = width; + this.widthRoll = widthRoll; + this.pixelsPerSecond = pixelsPerSecond; + this.lineInterval = lineInterval; + + this.addAnnot = function(category, user, catColor){ + var graphics = new PIXI.Graphics(); + var color = catColor; + var x = 0; + var y = -this.container.y; + graphics.beginFill(color); + graphics.drawRect(x, y, 10, 3); + graphics.endFill(); + + this.container.addChild(graphics); + + var catText = new PIXI.Text(category, { font: '16pt Arial', fill: '#65A954' }); + catText.x = x + 20; + catText.y = y - 23; + this.container.addChild(catText); + + var userText = new PIXI.Text(user, { font: '10pt Arial', fill: '#444444' }); + userText.x = x + 20; + userText.y = y + 2; + this.container.addChild(userText); + + this.addAnnotLine(color) + }; + + this.addAnnotLine = function(color){ + var x = this.widthRoll; + var y = -this.container.y; + + var graphics = new PIXI.Graphics(); + + graphics.beginFill(color); + graphics.drawRect(x, y, this.width - x, 3); + graphics.endFill(); + + this.container.addChild(graphics); + }; + + this.moveTo = function(diffTime){ + this.container.y = Math.floor(diffTime*this.pixelsPerSecond); + }; + + this.removePassedObjets = function(){ + var nbChilds = _this.container.children.length; + var i = 0, childIsNowDisplayed = false, childrenToRemove = []; + while(i<nbChilds && !childIsNowDisplayed){ + var child = _this.container.children[i++]; + + if(typeof(child) == 'undefined') { + continue; + } + if((child.y + child.height) < (Math.abs(_this.container.y) - _this.height)){ + childrenToRemove.push(child); + } + else { + childIsNowDisplayed = true; + } + } + childrenToRemove.forEach(function(child) { + _this.container.removeChild(child); + }); + }; + + window.setInterval(this.removePassedObjets, 1000 * this.height / this.pixelsPerSecond ); + +} + +module.exports = AnnotsRoll;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/annotviz/app/js/generalView.js Mon Jan 19 15:55:17 2015 +0100 @@ -0,0 +1,78 @@ +/** +* js/generalView +* +* generalView basic component +* +*/ + +'use strict'; + +var PIXI = require('pixi'); +var randomColor = require('randomColor'); + +function GeneralView(parentContainer, xInit, yInit, width, height, timeBegin, timeEnd, intervalSize){ + console.log(width); + var _this = this; + this.container = new PIXI.DisplayObjectContainer(); + this.container.position.x = xInit; + this.container.position.y = yInit; + this.container.width = width; + this.container.height = height; + parentContainer.addChild(this.container); + + this.timeBegin = timeBegin; + this.timeEnd = timeEnd; + this.duration = (timeEnd - timeBegin)/1000 + this.width = width; + this.height = height; + //define interval corresponding to the time of one step + //e.g: 60 for a step of 60 seconds + this.intervalSize = intervalSize; + // define the step depending the interval we passed and the duration + this.intervalDuration = (intervalSize*this.duration/width); + + //Initialise the list of step + //each cell will contain the list categories and the number of annotations per categories + this.cells = [] + + + // draw temp line to locate the middle of the container + var graphics = new PIXI.Graphics(); + graphics.beginFill(0x000000); + graphics.lineStyle(1, 0x000000); + graphics.moveTo(xInit, (-this.height/2) ); + graphics.lineTo(this.width, (-this.height/2)); + graphics.endFill(); + this.container.addChild(graphics); + + this.addAnnot = function(category, time){ + var x = Math.floor( (time-this.timeBegin)/(1000*this.intervalDuration)) * this.intervalSize; + var y = (-this.height/2); + + //Check if cell is already set. + //If yes get increment the numbere of annots in the category corresponding + //If not initialise the cell +// if (this.cells[x] === "undefined"){ +// cells[x].push({ +// "code" : category.code, +// "color" : category.color, +// "count" : 1 +// }); +// } else { +// if (c) +// } + + console.log("x : " + x + " | y : " + y); + + // We draw the rectangle + var graphics = new PIXI.Graphics(); + graphics.beginFill(0x536991); + graphics.drawRect(x, y, this.intervalSize, -10); + graphics.endFill(); + + this.container.addChild(graphics); + }; + +} + +module.exports = GeneralView;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utils/annotsroll-client.py Mon Jan 19 15:55:17 2015 +0100 @@ -0,0 +1,75 @@ +############################################################################### +# # +# # Copyright (C) 2011-2014 Tavendo GmbH +# # +# # Licensed under the Apache License, Version 2.0 (the "License"); +# # you may not use this file except in compliance with the License. +# # You may obtain a copy of the License at +# # +# # http://www.apache.org/licenses/LICENSE-2.0 +# # +# # Unless required by applicable law or agreed to in writing, software +# # distributed under the License is distributed on an "AS IS" BASIS, +# # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# # See the License for the specific language governing permissions and +# # limitations under the License. +# # +############################################################################### + +import sys +import csv +import time + +from twisted.python import log +from twisted.internet import reactor +import argparse + + +from autobahn.twisted.websocket import WebSocketClientProtocol, WebSocketClientFactory + +class MyClientProtocol(WebSocketClientProtocol): + + #def __init__(self, rows): + + def onConnect(self, response): + print("Server connected: {0}".format(response.peer)) + reactor.callLater(0, self.send_messages) + + def onOpen(self): + print("WebSocket connection open.") + + def send_messages(self): + with open("annotsroll_sample_formated.txt", 'rU') as datafile: + for row in list(datafile): + self.sendMessage(row, isBinary = False) + time.sleep(0.1) + + #time.sleep(0.1) + #self.sendMessage('{"user":"Julien"}'.encode('utf8')) + print("Goodbye") + self.factory.reactor.callLater(0.1, reactor.stop) + + def onClose(self, wasClean, code, reason): + print("WebSocket connection closed: {0}".format(reason)) + + + +if __name__ == '__main__': + + log.startLogging(sys.stdout) + + parser = argparse.ArgumentParser(description='Simulate an (osc) pianoroll client.') + #parser.add_argument('datafile', metavar='DATAFILE', help='The file containing the pianoroll data (CSV).') + parser.add_argument('-e', '--event', dest='event', metavar='EVENT', required=True, help='the event code.') + + args = parser.parse_args() + + #with open(args.datafile, 'rU') as datafile: + # reader = csv.reader(datafile, delimiter=' ') + + factory = WebSocketClientFactory("ws://127.0.0.1:8090/annot?event=%s" % args.event, debug=True) + factory.protocol = MyClientProtocol + + reactor.connectTCP("127.0.0.1", 8090, factory) + reactor.run() + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utils/annotsroll_sample_formated.txt Mon Jan 19 15:55:17 2015 +0100 @@ -0,0 +1,101 @@ +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"iam","label":": Clavier"},"user":"azer"} +{"category":{"code":"ntm","label":": Batterie"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"iam","label":": Clavier"},"user":"azer"} +{"category":{"code":"ntm","label":": Batterie"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"iam","label":": Clavier"},"user":"azer"} +{"category":{"code":"ntm","label":": Batterie"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"iam","label":": Clavier"},"user":"azer"} +{"category":{"code":"ntm","label":": Batterie"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"iam","label":": Clavier"},"user":"azer"} +{"category":{"code":"ntm","label":": Batterie"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"iam","label":": Clavier"},"user":"azer"} +{"category":{"code":"ntm","label":": Batterie"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"iam","label":": Clavier"},"user":"azer"} +{"category":{"code":"ntm","label":": Batterie"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"iam","label":": Clavier"},"user":"azer"} +{"category":{"code":"ntm","label":": Batterie"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"iam","label":": Clavier"},"user":"azer"} +{"category":{"code":"ntm","label":": Batterie"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"iam","label":": Clavier"},"user":"azer"} +{"category":{"code":"ntm","label":": Batterie"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"iam","label":": Clavier"},"user":"azer"} +{"category":{"code":"ntm","label":": Batterie"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"iam","label":": Clavier"},"user":"azer"} +{"category":{"code":"ntm","label":": Batterie"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"iam","label":": Clavier"},"user":"azer"} +{"category":{"code":"ntm","label":": Batterie"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"iam","label":": Clavier"},"user":"azer"} +{"category":{"code":"ntm","label":": Batterie"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"iam","label":": Clavier"},"user":"azer"} +{"category":{"code":"ntm","label":": Batterie"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"hip","label":": Guitare"},"user":"azer"} +{"category":{"code":"hop","label":": Trombone"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +{"category":{"code":"test","label":"test"},"user":"azer"} +