|
44
|
1 |
/* |
|
|
2 |
* Lance une recherche par courbes. |
|
|
3 |
*/ |
|
|
4 |
mosaic.prototype.startSearch = function() |
|
|
5 |
{ |
|
|
6 |
var _this = this; |
|
|
7 |
|
|
|
8 |
var top, left, width, height, margin_top, inMosaic; |
|
|
9 |
//Si on est dans le cas d'un filtrage de mosaïque. |
|
|
10 |
if(this.currentMode == "FILTER") |
|
|
11 |
{ |
|
|
12 |
var mainPanel = $('#mainPanel'); |
|
|
13 |
top = mainPanel.position().top; |
|
|
14 |
left = mainPanel.position().left; |
|
|
15 |
width = mainPanel.width(); |
|
|
16 |
height = mainPanel.height(); |
|
|
17 |
margin_top = this.MPTop_margin; |
|
|
18 |
inMosaic = true; |
|
|
19 |
} |
|
|
20 |
//Sinon si c'est une recherche dans la vidéo. |
|
|
21 |
else if(this.currentMode == "SEARCH") |
|
|
22 |
{ |
|
|
23 |
top = this.snTop; |
|
|
24 |
left = this.snLeft; |
|
|
25 |
width = this.snWidth; |
|
|
26 |
height = this.snHeight; |
|
|
27 |
margin_top = '0px'; |
|
|
28 |
inMosaic = false; |
|
|
29 |
} |
|
|
30 |
|
|
45
|
31 |
this.searchCanvas = new searchCanvas(top, left, width, height, margin_top, this.timeSearchFade, inMosaic, this); |
|
|
32 |
this.searchCanvas.create(this.dictionary); |
|
|
33 |
} |
|
|
34 |
|
|
|
35 |
/* |
|
|
36 |
* Lit le dictionnaire pour reconnaître les courbes de recherche. |
|
|
37 |
*/ |
|
|
38 |
mosaic.prototype.getDictionary = function() |
|
|
39 |
{ |
|
|
40 |
var path = this.config['dico']; |
|
|
41 |
var dico = []; |
|
44
|
42 |
|
|
45
|
43 |
var _this = this; |
|
|
44 |
|
|
|
45 |
$.getJSON(path, function(data) |
|
44
|
46 |
{ |
|
45
|
47 |
for(var i = 0 ; i < data.gestures.length ; i++) |
|
44
|
48 |
{ |
|
45
|
49 |
_this.dictionary[i] = data.gestures[i]; |
|
|
50 |
} |
|
44
|
51 |
}); |
|
|
52 |
} |
|
|
53 |
|
|
46
|
54 |
/* |
|
|
55 |
* Charge le texte affichable en fonction de la langue. |
|
|
56 |
*/ |
|
|
57 |
mosaic.prototype.getLang = function(lang) |
|
|
58 |
{ |
|
|
59 |
var path = 'lang/' + this.config['lang'] + '.json'; |
|
|
60 |
|
|
|
61 |
var _this = this; |
|
|
62 |
|
|
|
63 |
$.getJSON(path, function(data) |
|
|
64 |
{ |
|
|
65 |
_this.gesturesText = data.gesturesText; |
|
|
66 |
}); |
|
|
67 |
} |
|
|
68 |
|
|
44
|
69 |
mosaic.prototype.listenToPointers = function() |
|
|
70 |
{ |
|
|
71 |
if(this.searchCanvas) |
|
|
72 |
{ |
|
|
73 |
|
|
|
74 |
} |
|
|
75 |
} |
|
|
76 |
|
|
|
77 |
/* |
|
|
78 |
* Quitte une recherche par courbes. |
|
|
79 |
*/ |
|
|
80 |
mosaic.prototype.leaveSearch = function() |
|
|
81 |
{ |
|
45
|
82 |
if(this.searchCanvas) |
|
|
83 |
{ |
|
|
84 |
this.searchCanvas.leaveSearch(); |
|
|
85 |
} |
|
44
|
86 |
this.searchCanvas = null; |
|
|
87 |
} |
|
|
88 |
|
|
|
89 |
/* |
|
|
90 |
* Affiche les types de marqueurs correspondants à ce qu'on a commencé à tracer lors d'une recherche. |
|
|
91 |
*/ |
|
|
92 |
mosaic.prototype.notifySearchMarkers = function(markersStr) |
|
|
93 |
{ |
|
|
94 |
if($('.notifications_inSearch_container').length > 0) |
|
|
95 |
{ |
|
|
96 |
return; |
|
|
97 |
} |
|
|
98 |
|
|
|
99 |
// console.log(markersStr); |
|
|
100 |
|
|
|
101 |
var markersList = markersStr.split(new RegExp(';')); |
|
|
102 |
|
|
|
103 |
var notification_search_markers = "<div class='notifications_inSearch_container'>"; |
|
|
104 |
|
|
|
105 |
//On spécifie les notifications en div. |
|
|
106 |
for(var i = 0 ; i < markersList.length ; i++) |
|
|
107 |
{ |
|
|
108 |
notification_search_markers += "<div class='notifications_inSearch' style='background-image: url(./pictos/big/normal/" + markersList[i] + ".png);'></div>"; |
|
|
109 |
} |
|
|
110 |
|
|
|
111 |
notification_search_markers += "</div>"; |
|
|
112 |
|
|
|
113 |
//On les ajoute à la mosaïque. |
|
|
114 |
$('#mainPanel').append(notification_search_markers); |
|
|
115 |
|
|
|
116 |
//On calcule leurs coordonnées et dimensions. |
|
|
117 |
var notify_width = $('.notifications_inSearch_container').width(), notify_height = $('.notifications_inSearch_container').height(); |
|
|
118 |
var notify_margin = parseInt($('.notifications_inSearch').css('margin')); |
|
|
119 |
var point_left = $(window).width() / 2 - (notify_width) / 2 - notify_margin; |
|
|
120 |
var point_top = 0; |
|
|
121 |
|
|
|
122 |
if(this.currentMode == "VIDEO" || this.currentMode == "SEARCH") |
|
|
123 |
{ |
|
|
124 |
point_top = -this.notifyTopVideo, |
|
|
125 |
point_left = -this.notifyLeftVideo + ($(window).width() - notify_width) / 2 |
|
|
126 |
} |
|
|
127 |
|
|
|
128 |
//On les positionne. |
|
|
129 |
$('.notifications_inSearch_container').css( |
|
|
130 |
{ |
|
|
131 |
left: point_left, |
|
|
132 |
top: point_top |
|
|
133 |
}); |
|
|
134 |
|
|
|
135 |
//On les fait apparaître. |
|
|
136 |
$('.notifications_inSearch').css( |
|
|
137 |
{ |
|
|
138 |
opacity: "0.9" |
|
|
139 |
}); |
|
|
140 |
} |
|
|
141 |
|
|
|
142 |
/* |
|
|
143 |
* Supprime la notification de maintient du pointage. |
|
|
144 |
*/ |
|
|
145 |
mosaic.prototype.removeSearchMarkers = function() |
|
|
146 |
{ |
|
|
147 |
$('.notifications_inSearch_container').remove(); |
|
|
148 |
} |
|
|
149 |
|
|
|
150 |
/* |
|
|
151 |
* Effectuer un filtrage de la mosaïque par rapport à un type de marqueurs. |
|
|
152 |
*/ |
|
|
153 |
mosaic.prototype.searchFilter = function(type) |
|
|
154 |
{ |
|
|
155 |
var _this = this; |
|
|
156 |
|
|
|
157 |
if(this.currentMode == "FILTER") |
|
|
158 |
{ |
|
|
159 |
this.filterSearchedType = type; |
|
|
160 |
|
|
|
161 |
// console.log('Annotations length : ' + this.annotations.length); |
|
|
162 |
if(this.annotations.length > 0) |
|
|
163 |
{ |
|
|
164 |
this.isMosaicFiltering = true; |
|
|
165 |
|
|
|
166 |
var gestureNumberByVideo = new Object(); |
|
|
167 |
var maxAnnotationNumber = 0; |
|
|
168 |
// for(var i = 0 ; i < this.config['imagesToShow'] ; i++) |
|
|
169 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
|
170 |
{ |
|
|
171 |
var current = this.annotations[i]; |
|
|
172 |
// console.log(current.annotationType.contents.title + ' == ' + type); |
|
|
173 |
if(current.annotationType.contents.title == type) |
|
|
174 |
{ |
|
|
175 |
if(gestureNumberByVideo[current.source.url] == undefined || gestureNumberByVideo[current.source.url] == '') |
|
|
176 |
{ |
|
|
177 |
gestureNumberByVideo[current.source.url] = 0; |
|
|
178 |
} |
|
|
179 |
|
|
|
180 |
gestureNumberByVideo[current.source.url]++; |
|
|
181 |
} |
|
|
182 |
} |
|
|
183 |
|
|
|
184 |
for(var i = 0 ; i < this.config['imagesToShow'] ; i++) |
|
|
185 |
{ |
|
|
186 |
if(gestureNumberByVideo[this.urls[i]] == undefined || gestureNumberByVideo[this.urls[i]] == '') |
|
|
187 |
{ |
|
|
188 |
gestureNumberByVideo[this.urls[i]] = 0; |
|
|
189 |
} |
|
|
190 |
} |
|
|
191 |
|
|
|
192 |
//On récupère la vidéo qui score le nombre d'occurences de la gesture le plus haut. |
|
|
193 |
for(i in gestureNumberByVideo) |
|
|
194 |
{ |
|
45
|
195 |
// console.log(i + " " + gestureNumberByVideo[i] + ' ' + type); |
|
44
|
196 |
if(maxAnnotationNumber < gestureNumberByVideo[i]) |
|
|
197 |
{ |
|
|
198 |
maxAnnotationNumber = gestureNumberByVideo[i]; |
|
|
199 |
} |
|
|
200 |
} |
|
|
201 |
|
|
|
202 |
var snMargin = parseInt($('.snapshotDivs').css('margin')); |
|
|
203 |
|
|
|
204 |
//On affiche l'opacité résultante pour chaque vidéo. |
|
|
205 |
for(var i = 0 ; i < this.config['imagesToShow'] ; i++)// in gestureNumberByVideo) |
|
|
206 |
{ |
|
|
207 |
//Opacité conventionelle. |
|
|
208 |
var opacity = gestureNumberByVideo[this.urls[i]] / maxAnnotationNumber; |
|
|
209 |
// console.log('opacity b : ' + opacity + ' for ' + gestureNumberByVideo[i]); |
|
|
210 |
//Ce qui est à zéro le restera (par conséquent le snapshot associé sera invisible). |
|
|
211 |
if(opacity > 0) |
|
|
212 |
{ |
|
|
213 |
//On réhausse l'opacité de 50%. |
|
|
214 |
opacity = this.scaleIntervals(0., 1., 0.5, 1., opacity); |
|
|
215 |
} |
|
|
216 |
this.opacities[i] = opacity; |
|
|
217 |
|
|
|
218 |
//var filterIndex = this.getIdxFromMetadata(i); |
|
|
219 |
var filterIndex = i; |
|
|
220 |
//if(filterIndex >= 0) |
|
|
221 |
//{ |
|
|
222 |
// console.log('#snapshotDiv-' + filterIndex + " " + _this.config['timeFilterFade'] + " " + opacity); |
|
|
223 |
$('#snapshotDiv-' + filterIndex).fadeTo(this.config['timeFilterFade'], opacity, function() |
|
|
224 |
{ |
|
|
225 |
//Pour ne notifier qu'une fois. |
|
|
226 |
if(_this.isMosaicFiltering) |
|
|
227 |
{ |
|
|
228 |
_this.isMosaicFiltering = false; |
|
|
229 |
} |
|
|
230 |
}); |
|
|
231 |
|
|
|
232 |
// console.log('filterIdx : ' + filterIndex); |
|
|
233 |
|
|
|
234 |
if(opacity == 0) |
|
|
235 |
{ |
|
|
236 |
var filteredSnapshot = $('#snapshotDiv-' + filterIndex); |
|
|
237 |
|
|
|
238 |
if(filteredSnapshot.length > 0) |
|
|
239 |
{ |
|
|
240 |
var hider = '<div id="filterHider-' + filterIndex + '" class="filterHiders"></div>'; |
|
|
241 |
$('#mainPanel').append(hider); |
|
|
242 |
|
|
|
243 |
$('#filterHider-' + filterIndex).css( |
|
|
244 |
{ |
|
|
245 |
width: +filteredSnapshot.width() + 4 * snMargin, |
|
|
246 |
height: +filteredSnapshot.height() + 4 * snMargin, |
|
|
247 |
top: filteredSnapshot.position().top - snMargin, |
|
|
248 |
left: filteredSnapshot.position().left - snMargin |
|
|
249 |
}); |
|
|
250 |
} |
|
|
251 |
} |
|
|
252 |
//} |
|
|
253 |
} |
|
|
254 |
// for(var a = 0 ; a < this.config['imagesToShow'] ; a++) |
|
|
255 |
// console.log('op : ' + ' ' + this.imgs[a] + ' \t ' + this.opacities[a]); |
|
|
256 |
|
|
|
257 |
this.isMosaicFiltered = true; |
|
|
258 |
} |
|
|
259 |
} |
|
|
260 |
} |
|
|
261 |
|
|
|
262 |
/* |
|
|
263 |
* Passe une valeur de l'intervalle [A, B] à l'intervalle [C, D]. |
|
|
264 |
*/ |
|
|
265 |
mosaic.prototype.scaleIntervals = function(A, B, C, D, val) |
|
|
266 |
{ |
|
|
267 |
return (D - C + A) * val + (C - A); |
|
|
268 |
} |
|
|
269 |
|
|
|
270 |
/* |
|
|
271 |
* Retourne l'index d'un snapshot en fonction de ses metadonnées. |
|
|
272 |
*/ |
|
|
273 |
mosaic.prototype.getIdxFromMetadata = function(metadata) |
|
|
274 |
{ |
|
|
275 |
var _this = this; |
|
|
276 |
|
|
|
277 |
for(idx in this.urls) |
|
|
278 |
{ |
|
|
279 |
if(this.urls[idx] == metadata) |
|
|
280 |
{ |
|
|
281 |
for(id in this.ids) |
|
|
282 |
{ |
|
|
283 |
if(this.ids[id] == idx) |
|
|
284 |
{ |
|
|
285 |
return id; |
|
|
286 |
} |
|
|
287 |
} |
|
|
288 |
} |
|
|
289 |
} |
|
|
290 |
|
|
|
291 |
return -1; |
|
|
292 |
} |
|
|
293 |
|
|
|
294 |
/* |
|
|
295 |
* Enlève une recherche par filtre. |
|
|
296 |
*/ |
|
|
297 |
mosaic.prototype.removeFilter = function() |
|
|
298 |
{ |
|
|
299 |
if(this.currentMode == "FILTER") |
|
|
300 |
{ |
|
|
301 |
this.currentMode = "MOSAIC"; |
|
|
302 |
|
|
|
303 |
var _this = this; |
|
|
304 |
|
|
|
305 |
this.isMosaicFiltered = false; |
|
|
306 |
this.filterSearchedType = ''; |
|
|
307 |
|
|
|
308 |
$('#notify_search').remove(); |
|
|
309 |
$('#notify_search_1gesture').remove(); |
|
|
310 |
$('.filterHiders').remove(); |
|
|
311 |
$('.snapshotDivs').fadeTo(_this.config['timeFilterFade'], 1); |
|
|
312 |
} |
|
45
|
313 |
} |
|
|
314 |
|
|
|
315 |
/* |
|
|
316 |
* Parcours le dictionnaire pour trouver la première gesture à avoir un code identique à celui en entrée. |
|
|
317 |
*/ |
|
|
318 |
mosaic.prototype.gestureWithSameCode = function(code) |
|
|
319 |
{ |
|
|
320 |
//Pour tout le dictionnaire. |
|
|
321 |
for(var i = 0 ; i < this.dictionary.length ; i++) |
|
|
322 |
{ |
|
|
323 |
//Pour touts les codes de chaque gesture du dictionnaire. |
|
|
324 |
for(var j = 0 ; j < this.dictionary[i].codes.length ; j++) |
|
|
325 |
{ |
|
|
326 |
//Si le code en entrée est une partie début d'un des codes. |
|
|
327 |
if(this.dictionary[i].codes[j] === code) |
|
|
328 |
{ |
|
|
329 |
//On retourne le nom de la gesture. |
|
|
330 |
return this.dictionary[i].name; |
|
|
331 |
} |
|
|
332 |
} |
|
|
333 |
} |
|
|
334 |
|
|
|
335 |
return ''; |
|
44
|
336 |
} |