front_idill/src/search/js/curvesDetector.js
author bastiena
Tue, 31 Jul 2012 16:26:00 +0200
changeset 58 a28488078053
parent 55 afd60399a7b5
child 59 e812126f75f4
permissions -rw-r--r--
Front IDILL: search curves modified : search curves exit when event other than many curves detected.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     1
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     2
* This file is part of the TraKERS\Front IDILL package.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     3
*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     4
* (c) IRI <http://www.iri.centrepompidou.fr/>
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     5
*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     6
* For the full copyright and license information, please view the LICENSE
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     7
* file that was distributed with this source code.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     8
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     9
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    10
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    11
 * Projet : TraKERS
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    12
 * Module : Front IDILL
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    13
 * Fichier : curvesDetector.js
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    14
 * 
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    15
 * Auteur : alexandre.bastien@iri.centrepompidou.fr
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    16
 * 
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    17
 * Fonctionnalités : Détecteur de courbes de recherche, appelé par la classe de création du canvas de recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    18
 */
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    19
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    20
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    21
 * Détecteur de courbes (lignes droites, arcs de cercles et cercles).
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    22
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    23
 * searchCanvas > fonction create.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    24
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    25
function CurvesDetector(divisions, sizeTreshold, dictionary, mosaic)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    26
{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    27
    //Précision de la détection de direction en divisions (par défaut 12, selon une modélisation horaire et non mathématique).
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    28
    this.divisions = divisions;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    29
    //Taille limite pour un segment/courbe pour être considéré comme tel en px.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    30
    this.sizeTreshold = sizeTreshold;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    31
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    32
    this.dictionary = dictionary;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    33
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    34
    this.mosaic = mosaic;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    35
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    36
    //Code actuel généré. Il représente la structure de la courbe de recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    37
    this.actualCode = '';
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
    38
	//Les éléments composant le code (correspondant aux courbes.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
    39
    this.MPCode = '';
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
    40
    this.SPCode = '';
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    41
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    42
    this.joints = [];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    43
    this.jInc = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    44
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    45
    //Longueur totale de la courbe.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    46
    this.MPTotalDist = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    47
    this.SPTotalDist = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    48
    //Longueur de la partie actuelle (après début ou changement de direction).
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    49
    this.MPActualDist = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    50
    this.SPActualDist = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    51
    //Angles actuels.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    52
    this.MPActualAngle = -1;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    53
    this.SPActualAngle = -1;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    54
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    55
    //Centre du repère du pointeur principal.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    56
    this.MPrepX = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    57
    this.MPrepY = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    58
    //Centre du repère du pointeur secondaire.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    59
    this.SPrepX = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    60
    this.SPrepY = null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    61
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    62
    //Coordonnées actuelles du/des pointeur/s.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    63
    this.MPx = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    64
    this.MPy = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    65
    this.SPx = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    66
    this.SPy = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    67
    //Coordonnées précédentes du/des pointeur/s.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    68
    this.MPpx = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    69
    this.MPpy = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    70
    this.SPpx = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    71
    this.SPpy = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    72
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    73
    //Si les paramètres sont incorrects, on leur donne une valeur par défaut.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    74
    if(isNaN(divisions) || divisions < 1 || divisions > 360)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    75
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    76
        this.divisions = 12;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    77
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    78
    if(sizeTreshold < 1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    79
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    80
        sizeTreshold = 30;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    81
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    82
}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    83
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    84
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    85
 * Reinitialise les paramètres du détecteur.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    86
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    87
 * searchCanvas > fonction onPointerOut.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    88
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    89
CurvesDetector.prototype.reinit = function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    90
{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    91
    this.MPrepX = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    92
    this.MPrepY = 0;
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
    93
	this.SPrepX = 0;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
    94
	this.SPrepY = 0;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    95
    this.MPpx = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    96
    this.MPpy = 0;
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
    97
    this.SPpx = 0;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
    98
    this.SPpy = 0;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    99
    this.MPActualAngle = -1;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   100
    this.SPActualAngle = -1;
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   101
    this.MPCode = '';
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   102
    this.SPCode = '';
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   103
    this.actualCode = '';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   104
    this.MPActualDist = 0;
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   105
    this.SPActualDist = 0;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   106
    this.MPTotalDist = 0;
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   107
    this.SPTotalDist = 0;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   108
}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   109
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   110
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   111
 * Met à jour les positions des pointeurs.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   112
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   113
 * searchCanvas > fonction onPointerMove.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   114
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   115
CurvesDetector.prototype.updatePos = function(mpx, mpy, spx, spy)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   116
{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   117
    //On met à jour les coordonnées récentes.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   118
    this.MPx = mpx;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   119
    this.MPy = mpy;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   120
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   121
    //Si les coordonnées précédentes n'existent pas, alors on les met à jour.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   122
    if(!this.MPpx)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   123
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   124
        this.MPpx = mpx;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   125
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   126
    if(!this.MPpy)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   127
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   128
        this.MPpy = mpy;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   129
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   130
    if(!this.MPrepX)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   131
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   132
        this.MPrepX = mpx;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   133
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   134
    if(!this.MPrepY)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   135
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   136
        this.MPrepY = mpy;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   137
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   138
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   139
    //Si on a un second pointeur.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   140
    if(spx && spy)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   141
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   142
        //On met les coordonnées à jour.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   143
        this.SPx = spx;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   144
        this.SPy = spy;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   145
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   146
        //Si les coordonnées précédentes n'existent pas, alors on les met à jour.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   147
        if(!this.SPpx)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   148
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   149
            this.SPpx = spx;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   150
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   151
        if(!this.SPpy)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   152
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   153
            this.SPpy = spy;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   154
        }
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   155
		if(!this.SPrepX)
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   156
		{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   157
			this.SPrepX = spx;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   158
		}
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   159
		if(!this.SPrepY)
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   160
		{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   161
			this.SPrepY = spy;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   162
		}
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   163
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   164
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   165
    //On met à jour la distance des segments courants et on regarde les correspondances dans le dictionnaire.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   166
    this.updateDists();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   167
}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   168
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   169
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   170
 * Met à jour les distances parcourues.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   171
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   172
 * curvesDetector > fonction updatePos.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   173
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   174
CurvesDetector.prototype.updateDists = function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   175
{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   176
	//Si on n'est pas en recherche pas courbes, on part.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   177
	if(!this.mosaic.isSearchByCurvesOn)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   178
	{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   179
		return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   180
	}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   181
	
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   182
    var foundGestures;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   183
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   184
    //Si on a de quoi calculer les distances.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   185
    if(this.MPx && this.MPy && this.MPpx && this.MPpy && this.MPrepX && this.MPrepY)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   186
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   187
        //Distance entre les deux derniers points.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   188
        var MPDist = Math.floor(Math.sqrt((this.MPx - this.MPpx) * (this.MPx - this.MPpx) + (this.MPy - this.MPpy) * (this.MPy - this.MPpy)));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   189
        //On met à jour la distance totale de la courbe.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   190
        this.MPTotalDist += MPDist;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   191
        //Et aussi la distance du segment en cours.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   192
        this.MPActualDist += MPDist;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   193
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   194
        //Angle courant initialisé à -1.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   195
        var MPCurrentA = -1;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   196
        
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   197
		//Seuil de considération d'un segment.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   198
		var treshold = (this.mosaic.config.mouseInteractions ? this.mosaic.config.mouseUpDownDeltaTreshold : this.mosaic.config.kinectUpDownDeltaTreshold);
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   199
		
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   200
        //Si la distance actuelle du segment existe.
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   201
        if(MPDist > treshold)
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   202
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   203
            //On calcule l'angle courant entre ce segment et 
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   204
            MPCurrentA = this.currentAngle(this.MPrepX, this.MPrepY, this.MPx, this.MPy, this.divisions);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   205
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   206
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   207
        //Si la distance du segment actuel excède le seuil de la config et qu'il y a un angle.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   208
        if(this.MPActualDist > this.sizeTreshold && MPCurrentA != -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   209
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   210
            //Si l'angle affecté n'a pas encore de valeur ou si l'angle affecté est différent de l'angle calculé.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   211
            if(this.MPActualAngle == -1 || this.MPActualAngle != MPCurrentA)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   212
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   213
                //On affecte le nouvel angle.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   214
                this.MPActualAngle = MPCurrentA;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   215
                //On construit le code correspondant à ce segment.
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   216
                this.MPCode += 'D' + MPCurrentA;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   217
				
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   218
				if(this.mosaic.config.mouseInteractions)
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   219
				{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   220
					this.actualCode = this.MPCode;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   221
					//On affecte le code dans la mosaique.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   222
					this.mosaic.actualCode = this.actualCode;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   223
					//On recherche les gestures commencant par ce code.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   224
					foundGestures = this.codeToGestures(this.actualCode);
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   225
					// console.log(this.actualCode);
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   226
					this.foundGesturesManagement(foundGestures);
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   227
				}
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   228
				
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   229
                //On réinitialise la distance entre les deux derniers points.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   230
                this.MPActualDist = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   231
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   232
            //Sinon si l'angle n'a pas changé dans le segment en cours.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   233
            else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   234
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   235
                //On met à jour les dernières coordonnées du pointeur principal.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   236
                this.MPrepX = this.MPpx;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   237
                this.MPrepY = this.MPpy;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   238
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   239
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   240
            //Si l'angle affecté n'a pas encore de valeur.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   241
            if(this.MPActualAngle == -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   242
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   243
                //On le met à jour.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   244
                this.MPActualAngle = MPCurrentA;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   245
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   246
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   247
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   248
        //On met à jour les coordonnées précédentes.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   249
        if(this.MPpx != this.MPx)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   250
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   251
            this.MPpx = this.MPx;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   252
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   253
        if(this.MPpy != this.MPy)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   254
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   255
            this.MPpy = this.MPy;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   256
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   257
    }
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   258
	
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   259
    //Idem au cas où on aurait un deuxième pointeur.
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   260
    if(this.SPx && this.SPy && this.SPpx && this.SPpy && this.SPrepX && this.SPrepY)
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   261
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   262
        //Distance entre les deux derniers points.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   263
        var SPDist = Math.floor(Math.sqrt((this.SPx - this.SPpx) * (this.SPx - this.SPpx) + (this.SPy - this.SPpy) * (this.SPy - this.SPpy)));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   264
        //On met à jour la distance totale de la courbe.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   265
        this.SPTotalDist += SPDist;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   266
        //Et aussi la distance du segment en cours.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   267
        this.SPActualDist += SPDist;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   268
        
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   269
		//Angle courant initialisé à -1.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   270
        var SPCurrentA = -1;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   271
		
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   272
		//Seuil de considération d'un segment.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   273
		var treshold = (this.mosaic.config.mouseInteractions ? this.mosaic.config.mouseUpDownDeltaTreshold : this.mosaic.config.kinectUpDownDeltaTreshold);
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   274
		
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   275
        //Si la distance actuelle du segment est plus grande que le treshold.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   276
        if(SPDist > treshold)
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   277
        {
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   278
            //On calcule l'angle courant entre ce segment en divisions horaires.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   279
            SPCurrentA = this.currentAngle(this.SPrepX, this.SPrepY, this.SPx, this.SPy, this.divisions);
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   280
        }
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   281
		
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   282
		//Si la distance du segment actuel excède le seuil de la config et qu'il y a un angle.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   283
        if(this.SPActualDist > this.sizeTreshold && SPCurrentA != -1)
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   284
        {
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   285
            //Si l'angle affecté n'a pas encore de valeur ou si l'angle affecté est différent de l'angle calculé.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   286
            if(this.SPActualAngle == -1 || this.SPActualAngle != SPCurrentA)
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   287
            {
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   288
                //On affecte le nouvel angle.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   289
                this.SPActualAngle = SPCurrentA;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   290
                //On construit le code correspondant à ce segment.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   291
                this.SPCode += 'D' + SPCurrentA;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   292
				
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   293
                //On réinitialise la distance entre les deux derniers points.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   294
                this.SPActualDist = 0;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   295
            }
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   296
            //Sinon si l'angle n'a pas changé dans le segment en cours.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   297
            else
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   298
            {
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   299
                //On met à jour les dernières coordonnées du pointeur principal.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   300
                this.SPrepX = this.SPpx;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   301
                this.SPrepY = this.SPpy;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   302
            }
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   303
            
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   304
            //Si l'angle affecté n'a pas encore de valeur.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   305
            if(this.SPActualAngle == -1)
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   306
            {
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   307
                //On le met à jour.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   308
                this.SPActualAngle = SPCurrentA;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   309
            }
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   310
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   311
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   312
        //On met à jour les coordonnées précédentes.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   313
        if(this.SPpx != this.SPx)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   314
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   315
            this.SPpx = this.SPx;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   316
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   317
        if(this.SPpy != this.SPy)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   318
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   319
            this.SPpy = this.SPy;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   320
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   321
    }
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   322
	
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   323
	if(!this.mosaic.config.mouseInteractions && (this.SPCode || this.MPCode))
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   324
	{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   325
		this.actualCode = this.SPCode + ':' + this.MPCode;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   326
		// console.log(this.actualCode);
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   327
		this.mosaic.actualCode = this.actualCode;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   328
		//On recherche les gestures commencant par ce code.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   329
		foundGestures = this.codeToGestures(this.actualCode);
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   330
		this.foundGesturesManagement(foundGestures);
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   331
	}
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   332
}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   333
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   334
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   335
 * Renvoie les noms de gestures du dictionnaire qui ont un code qui commence par le code en entrée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   336
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   337
 * curvesDetector > fonction updateDists.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   338
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   339
CurvesDetector.prototype.codeToGestures = function(code)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   340
{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   341
    //Variable qui va stocker tous les noms trouvés.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   342
    var retNames = '';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   343
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   344
    //Pour tout le dictionnaire.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   345
    for(var i = 0 ; i < this.dictionary.length ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   346
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   347
        //Pour touts les codes de chaque gesture du dictionnaire.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   348
        for(var j = 0 ; j < this.dictionary[i].codes.length ; j++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   349
        {
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   350
			if(this.mosaic.config.mouseInteractions)
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   351
			{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   352
				//Si le code en entrée est une partie début d'un des codes.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   353
				if(this.dictionary[i].codes[j].indexOf(code) == 0)
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   354
				{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   355
					//On ajoute le nom de la gesture et on passe à la gesture suivante.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   356
					retNames += this.dictionary[i].name + ';';
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   357
					break;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   358
				}
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   359
			}
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   360
			else
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   361
			{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   362
				//On décompose le code dynamique et du dictionnaire en deux parties.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   363
				var partsCode = code.split(':'), partsDicoCode = this.dictionary[i].codes[j].split(':');
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   364
				//Si les débuts des deux parties correspondent aux deux parties du code dynamique.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   365
				if(partsDicoCode[0].indexOf(partsCode[0]) == 0 && partsDicoCode[1].indexOf(partsCode[1]) == 0)
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   366
				{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   367
					retNames += this.dictionary[i].name + ';';
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   368
					break;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   369
				}
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   370
			}
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   371
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   372
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   373
    //Comme on sépare chaque nom par un ;, il faut supprimer le dernier si au moins un nom a été trouvé.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   374
    if(retNames.length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   375
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   376
        retNames = retNames.substring(0, retNames.length-1);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   377
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   378
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   379
    //On renvoit les noms.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   380
    return retNames;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   381
}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   382
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   383
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   384
 * Calcule l'angle emprunté par le morceau de segment actuel. On prend A va vers B.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   385
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   386
 * curvesDetector > fonction updateDists.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   387
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   388
CurvesDetector.prototype.currentAngle = function(xa, ya, xb, yb, divisions)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   389
{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   390
    //On calcule l'angle de la droite AB et des abscisses, et on effectue une rotation de 90° vers la gauche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   391
    var angleRad = Math.atan2((ya - yb), (xa - xb)) - Math.PI / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   392
    //On traduit les radians en divisions en passant de [-PI/2 ; PI/2] à [0 ; divisions - 1].
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   393
    var angleDiv = Math.floor((angleRad > 0 ? angleRad : (2*Math.PI + angleRad)) * divisions / (2*Math.PI));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   394
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   395
    //L'angle initial est 0.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   396
    if(angleDiv == divisions)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   397
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   398
        angleDiv = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   399
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   400
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   401
    return angleDiv;
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   402
}
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   403
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   404
/*
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   405
 * Fonction de gestion des courbes trouvées.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   406
*/
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   407
CurvesDetector.prototype.foundGesturesManagement = function(foundGestures)
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   408
{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   409
	//S'il n'y a pas de gestures trouvées ou s'il y en a plus d'une.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   410
	if(foundGestures.length == 0 || foundGestures.split(';').length != 1)
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   411
	{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   412
		//On a trouvé quelque chose, même si ce qu'on a trouvé est vide ('').
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   413
		this.mosaic.curvesGesturesFound = true;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   414
		//On notifie ce qu'on a trouvé. Dans le cas où c'est '', on affiche geste inconnu.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   415
		this.mosaic.removeNotifications();
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   416
		this.mosaic.curvesGestures(foundGestures);
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   417
		
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   418
		//Si ce qu'on a trouvé est vide et si l'aide n'est pas affichée.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   419
		if(foundGestures.length == 0 && !this.mosaic.helpDisplayed && !this.mosaic.config.mouseInteractions)
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   420
		{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   421
			//Si on est en mode d'interaction Kinect, on désactive les courbes jusqu'à ce que l'utilisateur n'a plus les deux mains dans la zone (pour éviter les erreurs de manipulation).
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   422
			this.mosaic.mustTakeOutHands = true;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   423
			
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   424
			//On affiche différentes aides en fonction de si on se trouve dans une vidéo ou non.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   425
			if(this.mosaic.currentMode == 'SEARCH')
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   426
			{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   427
				this.mosaic.notifyHelp(false);
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   428
			}
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   429
			else if(this.mosaic.currentMode == 'FILTER')
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   430
			{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   431
				this.mosaic.notifyHelp(true);
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   432
			}
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   433
			foundGestures = '';
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   434
			
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   435
			//On enlève la recherche.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   436
			this.mosaic.curvesGesturesFound = false;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   437
			this.mosaic.isSearchByCurvesOn = false;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   438
			this.mosaic.leaveSearch();
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   439
			
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   440
			//Si on était en mode filtrage de la mosaïque et qu'aucune gesture de filtrage n'avait été détectée avant ca, on revient en mode mosaïque.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   441
			if(this.mosaic.currentMode == "FILTER" && this.mosaic.filterSearchedType == "")
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   442
			{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   443
				this.mosaic.currentMode = "MOSAIC";
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   444
				this.mosaic.isMosaicFiltered = false;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   445
			}
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   446
			//Sinon si on était en mode recherche dans une video et qu'aucune gesture n'avait été détectée avant ca, on revient en mode video.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   447
			if(this.mosaic.currentMode == "SEARCH" && this.mosaic.currentSearchGesture[this.centerId] == "")
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   448
			{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   449
				this.mosaic.currentMode = "VIDEO";
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   450
			}
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   451
		}
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   452
		//Si l'aide est déjà affichée, on l'enlève.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   453
		else if(foundGestures.split(';').length != 1 && this.mosaic.helpDisplayed && !this.mosaic.mustTakeOutHands)
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   454
		{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   455
			this.mosaic.removeHelp();
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   456
		}
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   457
	}
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   458
	//Si on a un seul résultat.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   459
	else
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   460
	{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   461
		//Si on est en mode d'interaction Kinect, on désactive les courbes jusqu'à ce que l'utilisateur n'a plus les deux mains dans la zone (pour éviter les erreurs de manipulation).
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   462
		this.mosaic.mustTakeOutHands = true;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   463
		
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   464
		// On affecte la recherche.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   465
		this.mosaic.currentSearchGesture[this.mosaic.centerId] = foundGestures;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   466
		this.mosaic.isUserInSearchZone = false;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   467
		
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   468
		//Si on est en mode recherche et que le player est prêt.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   469
		if(this.mosaic.currentMode == "SEARCH" && this.mosaic.playerIsReady)
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   470
		{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   471
			//On effectue la recherche.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   472
			this.mosaic.player.widgets[0].searchByGesture(foundGestures);
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   473
			this.mosaic.isCurrentlyInASearchByGesture = this.mosaic.player.widgets[0].isCurrentlyInASearchByGesture;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   474
			
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   475
			//On notifie.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   476
			this.mosaic.removeNotifications();
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   477
			this.mosaic.searchGesture(foundGestures, 'valid');
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   478
			
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   479
			//S'il y a un marqueur trouvé au moins, on place le curseur sur le premier résultat.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   480
			if(this.mosaic.player && this.mosaic.player.widgets[0] && this.mosaic.timeToGoAt[this.mosaic.centerId] === 0 && this.mosaic.player.widgets[0].atLeastOneSearchMarker(this.mosaic.currentSearchGesture[this.mosaic.centerId]))
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   481
			{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   482
				this.mosaic.player.widgets[0].goToFirstSearchedMarker(this.mosaic.currentSearchGesture[this.mosaic.centerId]);
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   483
			}
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   484
			
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   485
			//On enlève a recherche par courbes.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   486
			foundGestures = '';
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   487
			this.mosaic.curvesGesturesFound = false;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   488
			
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   489
			this.mosaic.isSearchByCurvesOn = false;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   490
			this.mosaic.leaveSearch();
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   491
		}
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   492
		//Si on est en filtrage.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   493
		else if(this.mosaic.currentMode == "FILTER")
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   494
		{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   495
			if(this.mosaic.isMosaicFiltered)
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   496
			{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   497
				//On met à jour la gesture de filtrage.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   498
				this.mosaic.filterSearchedType = foundGestures;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   499
				//On filtre la mosaique.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   500
				this.mosaic.searchFilter(foundGestures);
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   501
				this.mosaic.curvesGesturesFound = false;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   502
				//On notifie.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   503
				this.mosaic.removeNotifications();
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   504
				this.mosaic.filterGesture(foundGestures, 'valid');
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   505
				
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   506
				foundGestures = '';
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   507
				//On enlève la recherche par courbes.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   508
				this.mosaic.isSearchByCurvesOn = false;
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   509
				this.mosaic.leaveSearch();
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   510
			}
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   511
		}
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   512
	}
45
0e29ae4568a0 Front IDILL:
bastiena
parents:
diff changeset
   513
}