56 this.mainPointerIdleStartX; |
59 this.mainPointerIdleStartX; |
57 this.mainPointerIdleStartY; |
60 this.mainPointerIdleStartY; |
58 this.secondPointerIdleStartX; |
61 this.secondPointerIdleStartX; |
59 this.secondPointerIdleStartY; |
62 this.secondPointerIdleStartY; |
60 |
63 |
|
64 //Coordonnées de la souris dans le mode d'interaction souris. |
|
65 this.mousePosX; |
|
66 this.mousePosY; |
|
67 //Coordonnées précédentes de la souris dans le mode d'interaction souris. |
|
68 this.mousePosLastX; |
|
69 this.mousePosLastY; |
|
70 //Valeur du déplacement entre un mouse up et un mouse down. |
|
71 this.mouseUpDownDelta = 0; |
|
72 |
61 //Dimensions de la mosaïque en pixels. |
73 //Dimensions de la mosaïque en pixels. |
62 this.width; |
74 this.width; |
63 this.height; |
75 this.height; |
64 //Dimensions d'un snapshot en pixels. |
76 //Dimensions d'un snapshot en pixels. |
65 this.snapshotWidth; |
77 this.snapshotWidth; |
66 this.snapshotHeight; |
78 this.snapshotHeight; |
67 //Espacement entre les snapshots en pixels. |
79 //Espacement entre les snapshots en pixels. |
68 this.marginWidth; |
80 this.marginWidth; |
69 |
81 |
70 //Booléens permettant ou non certaines intéractions selon le contexte. |
82 //Booléens permettant ou non certaines intéractions selon le contexte. |
71 this.zoomed; |
83 this.zoomed = false; |
72 this.fullscreen; |
84 this.fullscreen = false; |
73 this.canMoveToNeighbour; |
85 this.canMoveToNeighbour = false; |
74 this.mainPointerExitBorder; |
86 this.mainPointerExitBorder = false; |
75 this.secondPointerExitBorder; |
87 this.secondPointerExitBorder = false; |
76 this.isMainPointerDisplayed; |
88 this.isMainPointerDisplayed = false; |
77 this.isSecondPointerDisplayed; |
89 this.isSecondPointerDisplayed = false; |
78 this.helpDisplayed; |
90 this.helpDisplayed = false; |
79 //Indique si l'utilisateur a manuellement pausé la vidéo. |
91 //Indique si l'utilisateur a manuellement pausé la vidéo. |
80 this.userPaused; |
92 this.userPaused = false; |
81 //Indique si on est en train de se déplacer vers un voisin. |
93 //Indique si on est en train de se déplacer vers un voisin. |
82 this.currentlyMoving; |
94 this.currentlyMoving = false; |
83 //Indique si on est en train de dézoomer vers la mosaïque. |
95 //Indique si on est en train de dézoomer vers la mosaïque. |
84 this.currentlyUnzooming; |
96 this.currentlyUnzooming = false; |
85 //Indique si on peut s'approcher de kinect. |
97 //Indique si on peut s'approcher de kinect. |
86 this.canStart; |
98 this.canStart = false; |
87 //Indique si on est actuellement sur un snapshot. |
99 //Indique si on est actuellement sur un snapshot. |
88 this.isOnASnapshot; |
100 this.isOnASnapshot = false; |
89 //Indique si l'idle des pointeurs est disponible (deux mains détectées). |
101 //Indique si l'idle des pointeurs est disponible (deux mains détectées). |
90 this.pointersIdleAvailable; |
102 this.pointersIdleAvailable = false; |
91 //Indique si le timeout pour l'idle des pointeurs à besoin d'être lancé. |
103 //Indique si le timeout pour l'idle des pointeurs à besoin d'être lancé. |
92 this.pointersIdleNeedLaunch; |
104 this.pointersIdleNeedLaunch = false; |
93 //Indique si les deux mains sont là. |
105 //Indique si les deux mains sont là. |
94 this.areBothPointersHere; |
106 this.areBothPointersHere = false; |
95 //Indique si le timeout pour la détection de deux pointeurs a été lancé. |
107 //Indique si le timeout pour la détection de deux pointeurs a été lancé. |
96 this.areBothPointersTimeoutLaunched; |
108 this.areBothPointersTimeoutLaunched = false; |
97 //Indique si la mosaïque a été filtrée. |
109 //Indique si la mosaïque a été filtrée. |
98 this.isMosaicFiltered; |
110 this.isMosaicFiltered = false; |
99 //Indique si on est actuellement dans une recherche par gesture. |
111 //Indique si on est actuellement dans une recherche par gesture. |
100 this.isCurrentlyInASearchByGesture; |
112 this.isCurrentlyInASearchByGesture = false; |
101 //Indique si un pointeur est déjà sur une notification de recherche par gesture. |
113 //Indique si un pointeur est déjà sur une notification de recherche par gesture. |
102 this.alreadyOnNotification; |
114 this.alreadyOnNotification = false; |
103 //Si on a fait un swipe. |
115 //Si on a fait un swipe. |
104 this.isSwipe; |
116 this.isSwipe = false; |
105 //On peut swiper. |
117 //On peut swiper. |
106 this.canSwipe; |
118 this.canSwipe = false; |
107 //On passe vers une autre video automatiquement à la fin d'une lecture. |
119 //On passe vers une autre video automatiquement à la fin d'une lecture. |
108 this.autoMove; |
120 this.autoMove = false; |
109 //Si l'utilisateur a demandé à sélectionner la TL. |
121 //Si l'utilisateur a demandé à sélectionner la TL. |
110 this.isTLRequested; |
122 this.isTLRequested = false; |
111 //Le pointeur gauche a sélectionné la TL. |
123 //Le pointeur gauche a sélectionné la TL. |
112 this.isTLSelectedBySecondPointer; |
124 this.isTLSelectedBySecondPointer = false; |
113 //Le pointeur droit a sélectionné la TL. |
125 //Le pointeur droit a sélectionné la TL. |
114 this.isTLSelectedByMainPointer; |
126 this.isTLSelectedByMainPointer = false; |
115 //On peut afficher l'aide. |
127 //On peut afficher l'aide. |
116 this.canNotifyHelp; |
128 this.canNotifyHelp = false; |
117 //Indique si la mosaique est en train d'être filtrée. |
129 //Indique si la mosaique est en train d'être filtrée. |
118 this.isMosaicFiltering; |
130 this.isMosaicFiltering = false; |
119 this.arrowLeftLoading = false; |
131 this.arrowLeftLoading = false; |
120 this.arrowRightLoading = false; |
132 this.arrowRightLoading = false; |
121 this.arrowUpLoading = false; |
133 this.arrowUpLoading = false; |
122 this.arrowDownLoading = false; |
134 this.arrowDownLoading = false; |
123 //On est dans une recherche par courbes. |
135 //On est dans une recherche par courbes. |
124 this.isSearchByCurvesOn; |
136 this.isSearchByCurvesOn = false; |
125 this.canDrawNextCurve = false; |
137 this.canDrawNextCurve = false; |
|
138 //Dans le mode d'interaction souris, indique si on se situe actuellement sur un snapshot entièrement prézoomé. |
|
139 this.isOnAPrezoomSN = false; |
|
140 //Indique si une courbe de recherche donne au moins un résultat. |
|
141 this.curvesGesturesFound = false; |
|
142 //Indique si on souhaite supprimer la recherche en cours. |
|
143 this.gestureDelRequested = false; |
|
144 //Code de gesture actuellement calculé par les détecteurs de courbes. |
|
145 this.actualCode = ''; |
126 |
146 |
127 //Timeout (attente) pour le zoom après un préZoom. |
147 //Timeout (attente) pour le zoom après un préZoom. |
128 this.zoomTimeout; |
148 this.zoomTimeout = null; |
129 //Timeout (attente) pour le passage vers un voisin. |
149 //Timeout (attente) pour le passage vers un voisin. |
130 this.moveToNeighbourTimeout; |
150 this.moveToNeighbourTimeout = null; |
131 this.mainPointerExitBorderTimeout; |
151 this.mainPointerExitBorderTimeout = null; |
132 this.secondPointerExitBorderTimeout; |
152 this.secondPointerExitBorderTimeout = null; |
133 //Idle time pour les pointeurs afin d'informer le front qu'on souhaite faire une recherche. |
153 //Idle time pour les pointeurs afin d'informer le front qu'on souhaite faire une recherche. |
134 this.pointersSearchIdleTimeout; |
154 this.pointersSearchIdleTimeout = null; |
135 //Vérifie toutes les N ms que les deux pointeurs sont détectés. |
155 //Vérifie toutes les N ms que les deux pointeurs sont détectés. |
136 this.areBothPointersHereTimeout; |
156 this.areBothPointersHereTimeout = null; |
137 //Délai de suppression d'une notification de recherche par gesture. |
157 //Délai de suppression d'une notification de recherche par gesture. |
138 this.removeNotificationByGestureTimeout; |
158 this.removeNotificationByGestureTimeout = null; |
139 //Délai de suppression d'une notification de recherche par gesture infructueuse. |
159 //Délai de suppression d'une notification de recherche par gesture infructueuse. |
140 this.removeFailedNotificationByGestureTimeout; |
160 this.removeFailedNotificationByGestureTimeout = null; |
141 //Délai avant la suppression de notification swipe. |
161 //Délai avant la suppression de notification swipe. |
142 this.notifySwipeTimeout; |
162 this.notifySwipeTimeout = null; |
143 //Délai pour la sélection de la TL. |
163 //Délai pour la sélection de la TL. |
144 this.selectTLTimeout; |
164 this.selectTLTimeout = null; |
145 //Délai pour slider sur la TL. |
165 //Délai pour slider sur la TL. |
146 this.canSlideInTLTimeout; |
166 this.canSlideInTLTimeout = null; |
147 //Délai pour afficher l'aide. |
167 //Délai pour afficher l'aide. |
148 this.canNotifyHelpTimeout; |
168 this.canNotifyHelpTimeout = null; |
149 this.arrowLeftTimeout; |
169 this.arrowLeftTimeout = null; |
150 this.arrowRightTimeout; |
170 this.arrowRightTimeout = null; |
151 this.arrowUpTimeout; |
171 this.arrowUpTimeout = null; |
152 this.arrowDownTimeout; |
172 this.arrowDownTimeout = null; |
153 |
173 |
154 this.arrowSpinnerTimeout; |
174 this.arrowSpinnerTimeout = null; |
155 this.nouserTimeout; |
175 this.nouserTimeout = null; |
156 this.nextDrawCurveTimeout; |
176 this.nextDrawCurveTimeout = null; |
157 |
177 |
158 //Dernier message INCOMING (pour éviter d'effectuer n fois la même action. |
178 //Dernier message INCOMING (pour éviter d'effectuer n fois la même action. |
159 this.lastIncomingMessage; |
179 this.lastIncomingMessage = ''; |
160 |
180 |
161 //Type de marqueur recherché dans la mosaïque (en mode filter). |
181 //Type de marqueur recherché dans la mosaïque (en mode filter). |
162 this.filterSearchedType = ""; |
182 this.filterSearchedType = ""; |
163 |
183 |
164 //Mode actuel. |
184 //Mode actuel. |
165 this.currentMode = "NO-USER"; |
185 this.currentMode = "NO-USER"; |
166 //Snapshot sur lequel on a zoomé. |
186 //Snapshot sur lequel on a zoomé. |
167 this.previousZoomedSN = null; |
187 this.previousZoomedSN = null; |
|
188 //Snapshot sur lequel on a prezoomé. |
|
189 this.previousPrezoomDiv = null; |
168 //Son ID. |
190 //Son ID. |
169 this.previousId; |
191 this.previousId = null; |
170 //Dernier snapshot prézoomé non null. |
192 //Dernier snapshot prézoomé non null. |
171 this.lastNonNullSN = null; |
193 this.lastNonNullSN = null; |
172 //Largeur de la marge pour le centrage vertical de la mosaïque. |
194 //Largeur de la marge pour le centrage vertical de la mosaïque. |
173 this.MPTop_margin; |
195 this.MPTop_margin; |
174 this.top_margin; |
196 this.top_margin; |
175 |
197 |
176 //Gesture actuellement cherchée. |
198 //Gesture actuellement cherchée. |
177 this.currentSearchGesture; |
199 this.currentSearchGesture = ''; |
178 |
200 |
179 //Mosaïque locale. |
201 //Mosaïque locale. |
180 this.localMos; |
202 this.localMos; |
181 //Position des voisins lors d'un zoom. |
203 //Position des voisins lors d'un zoom. |
182 this.neighboursIds = []; |
204 this.neighboursIds = []; |
183 //ID du snapshot du milieu lors d'un zoom. |
205 //ID du snapshot du milieu lors d'un zoom. |
406 |
402 |
407 _this.previousZoomedSN = $('#snapshotDiv-' + _this.fillingIds[0]); |
403 _this.previousZoomedSN = $('#snapshotDiv-' + _this.fillingIds[0]); |
408 } |
404 } |
409 }); |
405 }); |
410 } |
406 } |
|
407 |
|
408 if(this.mouseInteractions) |
|
409 { |
|
410 //On bind le clic pour supprimer une recherche. |
|
411 $('body').click(function(e) |
|
412 { |
|
413 _this.removeSearchNotificationIfOnIt(e.pageX, e.pageY); |
|
414 }); |
|
415 |
|
416 //Si on fait un mouse down sur le body, on vérifie enregistre le déplacement de la souris jusqu'au prochain mouse up. |
|
417 $(window).mousedown(function () |
|
418 { |
|
419 if(_this.isSearchByCurvesOn) |
|
420 { |
|
421 _this.searchCanvas.onPointerIn(_this.mousePosX, _this.mousePosY, null, null); |
|
422 } |
|
423 |
|
424 console.log('mdown'); |
|
425 //On écoute le déplacement de la souris. |
|
426 $(window).mousemove(function(e) |
|
427 { |
|
428 if(_this.isSearchByCurvesOn) |
|
429 { |
|
430 _this.searchCanvas.onPointerMove(_this.mousePosX, _this.mousePosY - _this.MPTop_margin, null, null); |
|
431 } |
|
432 |
|
433 //On met à jour l'ancienne position de la souris si elle est nulle. |
|
434 if(!_this.mousePosLastX && _this.mousePosLastX != 0) |
|
435 { |
|
436 _this.mousePosLastX = _this.mousePosX; |
|
437 } |
|
438 if(!_this.mousePosLastY && _this.mousePosLastY != 0) |
|
439 { |
|
440 _this.mousePosLastY = _this.mousePosY; |
|
441 } |
|
442 |
|
443 //Le delta s'accroît si la souris bouge. |
|
444 _this.mouseUpDownDelta += Math.floor(Math.sqrt((_this.mousePosLastX - e.pageX) * (_this.mousePosLastX - e.pageX) + (_this.mousePosLastY - e.pageY) * (_this.mousePosLastY - e.pageY))); |
|
445 |
|
446 // console.log(_this.mouseUpDownDelta, _this.mousePosLastX, e.pageX); |
|
447 |
|
448 if(_this.mousePosLastX != _this.mousePosX) |
|
449 { |
|
450 _this.mousePosLastX = _this.mousePosX; |
|
451 } |
|
452 if(_this.mousePosLastY != _this.mousePosY) |
|
453 { |
|
454 _this.mousePosLastY = _this.mousePosY; |
|
455 } |
|
456 |
|
457 //Si la souris a parcouru une trop grande distance, on entre en recherche. |
|
458 if(_this.mouseUpDownDelta > _this.config['mouseUpDownDeltaTreshold']) |
|
459 { |
|
460 //Si on est en mosaique, on entre en filtrage. |
|
461 if(_this.currentMode == "MOSAIC") |
|
462 { |
|
463 _this.preUnzoom(); |
|
464 _this.currentMode = "FILTER"; |
|
465 _this.isMosaicFiltered = true; |
|
466 |
|
467 console.log(_this.date() + ' - ENTRE EN MODE FILTRAGE'); |
|
468 |
|
469 _this.isSearchByCurvesOn = true; |
|
470 _this.startSearch(); |
|
471 |
|
472 if(!_this.curvesGesturesFound) |
|
473 { |
|
474 $('.notifications').remove(); |
|
475 _this.filterSearch(); |
|
476 } |
|
477 |
|
478 _this.searchCanvas.onPointerIn(_this.mousePosX, _this.mousePosY - _this.MPTop_margin, null, null); |
|
479 } |
|
480 else if(_this.currentMode == "FILTER" && !_this.isSearchByCurvesOn) |
|
481 { |
|
482 console.log('after search'); |
|
483 _this.preUnzoom(); |
|
484 _this.isSearchByCurvesOn = true; |
|
485 _this.startSearch(); |
|
486 _this.searchCanvas.onPointerIn(_this.mousePosX, _this.mousePosY - _this.MPTop_margin, null, null); |
|
487 } |
|
488 //Si on est dans une vidéo, on entre en recherche. |
|
489 else if(_this.currentMode == "VIDEO" || _this.currentMode == "TIMELINE") |
|
490 { |
|
491 _this.currentMode = "SEARCH"; |
|
492 |
|
493 console.log(_this.date() + ' - ENTRE EN MODE RECHERCHE'); |
|
494 |
|
495 _this.isSearchByCurvesOn = true; |
|
496 _this.startSearch(); |
|
497 |
|
498 if(!_this.curvesGesturesFound) |
|
499 { |
|
500 $('.notifications').remove(); |
|
501 _this.searchSearch(); |
|
502 } |
|
503 |
|
504 _this.searchCanvas.onPointerIn(_this.mousePosX, _this.mousePosY - _this.MPTop_margin, null, null); |
|
505 } |
|
506 else if(_this.currentMode == "SEARCH" && !_this.isSearchByCurvesOn) |
|
507 { |
|
508 _this.isSearchByCurvesOn = true; |
|
509 _this.startSearch(); |
|
510 _this.searchCanvas.onPointerIn(_this.mousePosX, _this.mousePosY - _this.MPTop_margin, null, null); |
|
511 } |
|
512 |
|
513 //Il est possible d'afficher l'aide. |
|
514 if(!_this.canNotifyHelp) |
|
515 { |
|
516 _this.canNotifyHelpTimeout = setTimeout(function() |
|
517 { |
|
518 _this.canNotifyHelp = true; |
|
519 }, _this.config['timeoutCanNotifyHelp']); |
|
520 } |
|
521 } |
|
522 }); |
|
523 |
|
524 //Si on fait un mouse up après ce mouse down. |
|
525 $(window).mouseup(function() |
|
526 { |
|
527 console.log('mup'); |
|
528 |
|
529 if(_this.isSearchByCurvesOn) |
|
530 { |
|
531 var gesture_match = _this.gestureWithSameCode(_this.actualCode); |
|
532 _this.actualCode = ''; |
|
533 |
|
534 if(gesture_match.length > 0) |
|
535 { |
|
536 if(_this.currentMode == "SEARCH" && _this.playerIsReady) |
|
537 { |
|
538 _this.player.widgets[0].searchByGesture(gesture_match); |
|
539 _this.isCurrentlyInASearchByGesture = _this.player.widgets[0].isCurrentlyInASearchByGesture; |
|
540 |
|
541 $('.notifications').remove(); |
|
542 _this.searchGesture(gesture_match, 'valid'); |
|
543 _this.curvesGesturesFound = false; |
|
544 } |
|
545 else if(_this.currentMode == "FILTER") |
|
546 { |
|
547 if(_this.isMosaicFiltered) |
|
548 { |
|
549 $('.notifications').remove(); |
|
550 _this.filterSearchedType = gesture_match; |
|
551 _this.filterGesture(gesture_match, 'valid'); |
|
552 _this.searchFilter(gesture_match); |
|
553 _this.curvesGesturesFound = false; |
|
554 } |
|
555 } |
|
556 } |
|
557 |
|
558 _this.searchCanvas.onPointerOut(); |
|
559 } |
|
560 |
|
561 //On unbind ce qui a été bindé après le mouse up. |
|
562 $(window).unbind('mousemove'); |
|
563 $(window).unbind('mouseup'); |
|
564 //On rebind le mousemove principal du body, car ils ont tous été unbindés. |
|
565 $('body').mousemove(function(e) |
|
566 { |
|
567 _this.refreshMainPointer(e.pageX, e.pageY, _this); |
|
568 _this.mousePosX = e.pageX; |
|
569 _this.mousePosY = e.pageY; |
|
570 }); |
|
571 |
|
572 _this.mousePosLastX = null; |
|
573 _this.mousePosLastY = null; |
|
574 |
|
575 //Si la distance parcourue par la souris entre le mouse down et le mouse up est inférieure ou égale au seuil. |
|
576 if(_this.mouseUpDownDelta <= _this.config['mouseUpDownDeltaTreshold']) |
|
577 { |
|
578 //Si on est sur un snapshot prézoomé. |
|
579 if(_this.isOnAPrezoomSN && _this.previousZoomedSN != '' && (_this.currentMode == 'MOSAIC' || _this.currentMode == 'FILTER')) |
|
580 { |
|
581 _this.zoom(); |
|
582 } |
|
583 } |
|
584 |
|
585 _this.mouseUpDownDelta = 0; |
|
586 _this.isSearchByCurvesOn = false; |
|
587 _this.leaveSearch(); |
|
588 |
|
589 if(_this.currentMode == 'FILTER' && _this.filterSearchedType != '')//if(_this.currentSearchGesture != '') |
|
590 { |
|
591 $('.notifications').remove(); |
|
592 _this.filterGesture(_this.currentSearchGesture, 'valid'); |
|
593 } |
|
594 |
|
595 }); |
|
596 }); |
|
597 } |
411 } |
598 } |
412 |
599 |
413 /* |
600 /* |
414 * Charge les paramètres du Front. Local (true/false) est le mode de chargement des données. |
601 * Charge les paramètres du Front. Local (true/false) est le mode de chargement des données. |
415 */ |
602 */ |
416 mosaic.prototype.loadParameters = function(file_path) |
603 mosaic.prototype.loadParameters = function(file_path) |
417 { |
604 { |
418 var _this = this; |
605 var _this = this; |
419 |
606 |
420 var supposedToBeInt = ['length', 'imagesToShow', 'totalImages', 'timePrezoom', 'timePreUnzoom', 'timeZoom', 'zoomTime', 'timeUnzoom', 'timeNeighbourGlowing', 'timeNeighbourUnglowing', 'timeMovingToNeighbour', 'timeSearchFade', 'timeNotifyFade', 'timeFilterFade', 'timeANFade', 'timeFilling', 'zoomedMargin', 'timeoutZoom', 'timeoutUnzoom', 'timeoutMoveToNeighbour', 'timeoutPointersIdle', 'timeoutAreBothPointersHere', 'timeoutRemoveNotificationByGesture', 'timeoutRemoveFailedNotificationByGesture', 'timeoutNotifySwipe', 'timeoutSelectTL', 'timeoutSlideTL', 'timeoutCanNotifyHelp', 'timeoutRemoveSpinner', 'timeoutNouser', 'timeoutNextDrawCurve']; |
607 var supposedToBeInt = ['length', 'imagesToShow', 'totalImages', 'timePrezoom', 'timePreUnzoom', 'timeZoom', 'zoomTime', 'timeUnzoom', 'timeNeighbourGlowing', 'timeNeighbourUnglowing', 'timeMovingToNeighbour', 'timeSearchFade', 'timeNotifyFade', 'timeFilterFade', 'timeANFade', 'timeFilling', 'zoomedMargin', 'timeoutZoom', 'timeoutUnzoom', 'timeoutMoveToNeighbour', 'timeoutPointersIdle', 'timeoutAreBothPointersHere', 'timeoutRemoveNotificationByGesture', 'timeoutRemoveFailedNotificationByGesture', 'timeoutNotifySwipe', 'timeoutSelectTL', 'timeoutSlideTL', 'timeoutCanNotifyHelp', 'timeoutRemoveSpinner', 'timeoutNouser', 'timeoutNextDrawCurve', 'mouseUpDownDeltaTreshold']; |
421 var supposedToBeFloat = ['zoomPercentage', 'prezoomPercentage']; |
608 var supposedToBeFloat = ['zoomPercentage', 'prezoomPercentage']; |
422 |
609 |
423 $.getJSON(file_path, function(data) |
610 $.getJSON(file_path, function(data) |
424 { |
611 { |
425 for(key in data) |
612 for(key in data) |