front_idill/src/search/js/searchCanvas.js
author bastiena
Mon, 24 Sep 2012 15:20:10 +0200
changeset 124 d2b4682dc9cc
parent 79 9eff85166868
permissions -rw-r--r--
Étiquette V00.17 ajoutée à la révision 57a65edde708
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
     1
/*
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
     2
* This file is part of the TraKERS\Front IDILL package.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
     3
*
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
     4
* (c) IRI <http://www.iri.centrepompidou.fr/>
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
     5
*
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
     6
* For the full copyright and license information, please view the LICENSE
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
     7
* file that was distributed with this source code.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
     8
*/
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
     9
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    10
/*
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    11
 * Projet : TraKERS
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    12
 * Module : Front IDILL
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    13
 * Fichier : searchCanvas.js
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    14
 * 
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    15
 * Auteur : alexandre.bastien@iri.centrepompidou.fr
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    16
 * 
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    17
 * Fonctionnalités : Définit les fonctions de recherche par courbe de haut niveau (instantiation et manipulation de la classe de recherche par courbe mais pas les courbes en elles-mêmes ni le détecteur).
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    18
 */
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    19
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    20
/*
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    21
 * Déclaration du canvas de recherche par courbes.
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    22
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    23
 * search > fonction startSearch.
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    24
*/
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    25
function SearchCanvas(_canvasTop, _canvasLeft, _canvasWidth, _canvasHeight, _margin_top, _fadeTime, _inMosaic, _mosaic)
35
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    26
{
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    27
    //Coordonnées, dimensions et autres paramètres du canvas.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    28
    this.canvasTop = _canvasTop;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    29
    this.canvasLeft = _canvasLeft;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    30
    this.canvasWidth = _canvasWidth;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    31
    this.canvasHeight = _canvasHeight;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    32
    this.fadeTime = _fadeTime;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    33
    this.margin_top = _margin_top;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    34
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    35
    this.mosaic = _mosaic;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    36
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    37
    //Courbe du pointeur principal.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    38
    this.mainPath;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    39
    this.mainPathStroke;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    40
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    41
    //Courbe du pointeur secondaire.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    42
    this.secondPath;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    43
    this.secondPathStroke;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    44
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    45
    //Courbe indicatrice de la direction actuelle.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    46
    this.direction;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    47
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    48
    //Point précédent des pointeurs.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    49
    this.mainLastPoint;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    50
    this.secondLastPoint;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    51
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    52
    //Coordonnées précédentes des pointeurs.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    53
    this.mainPointerLastX;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    54
    this.mainPointerLastY;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    55
    this.secondPointerLastX;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    56
    this.secondPointerLastY;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    57
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    58
    this.inMosaic = _inMosaic;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    59
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    60
    this.detector;
35
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    61
}
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    62
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    63
/*
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    64
 * Fonction d'initialisation du canvas de recherche par courbes.
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    65
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    66
 * search > fonction startSearch.
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    67
*/
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    68
SearchCanvas.prototype.create = function(dictionary)
35
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    69
{
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    70
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    71
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    72
    //On crée le canvas.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    73
    var canvas = '<canvas id="paperCanvas" width="' + this.canvasWidth + 'px" height="' + this.canvasHeight + 'px" class="canvas"></canvas>';
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    74
    //On l'ajoute à la page.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    75
    $('body').append(canvas);
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    76
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    77
    $('.canvas').css(
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    78
    {
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    79
        top: this.canvasTop,
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    80
        left: this.canvasLeft
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    81
    });
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    82
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    83
    //S'il est dans la mosaique, on le réhausse en fonction de la taille de la marge verticale.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    84
    if(this.inMosaic)
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    85
    {
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    86
        $('.canvas').css(
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    87
        {
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    88
            "margin-top": this.margin_top
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    89
        });
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    90
    }
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    91
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    92
    //On instancie le détecteur de courbes de recherche.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    93
    this.detector = new CurvesDetector(6, 100, dictionary, this.mosaic);
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    94
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    95
    //On active le canvas.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
    96
    paper.setup('paperCanvas');
35
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    97
};
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
    98
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    99
/*
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   100
 * Fonction appelée pour quitter le mode de recherche par courbes.
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   101
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   102
 * search > fonction leaveSearch.
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   103
*/
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   104
SearchCanvas.prototype.leaveSearch = function()
35
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
   105
{
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   106
    $('.canvas').fadeTo(this.fadeTime, 0, function()
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   107
    {
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   108
        $('.canvas').remove();
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   109
    });
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   110
    
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   111
    if(this.mosaic.isTablet)
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   112
    {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   113
        this.mosaic.isTouchStart = false;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   114
    }
35
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
   115
};
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
   116
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   117
/*
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   118
 * Fonction de déclaration des courbes.
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   119
 * Est appelé dans les fichiers :
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   120
 * mosaic > fonctions onMouseDown et onMouseMove.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   121
 * client > fonction processMsg.
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   122
*/
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   123
SearchCanvas.prototype.onPointerIn = function(mainPointerX, mainPointerY, secondPointerX, secondPointerY)
35
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
   124
{
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   125
    // console.log('IN');
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   126
    
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   127
    if(this.mosaic.currentMode != 'MOSAIC' && this.mosaic.currentMode != 'FILTER')
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   128
    {
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   129
        mainPointerX -= 130;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   130
        mainPointerY -= 60;
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   131
        
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   132
        if(secondPointerX && secondPointerY)
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   133
        {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   134
            secondPointerX -= 130;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   135
            secondPointerY -= 60;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   136
        }
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   137
    }
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   138
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   139
    //On obtient les coordonnées du pointeur principal en px.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   140
    mainPointerX = Math.floor(mainPointerX);
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   141
    mainPointerY = Math.floor(mainPointerY);
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   142
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   143
    //On forme le contour la courbe principale.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   144
    this.mainPathStroke = new paper.Path();
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   145
    this.mainPathStroke.strokeColor = '#366F7A';
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   146
    this.mainPathStroke.strokeWidth = 18;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   147
    this.mainPathStroke.strokeCap = 'round';
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   148
    this.mainPathStroke.strokeJoin = 'round';
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   149
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   150
    //On forme la courbe principale.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   151
    this.mainPath = new paper.Path();
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   152
    this.mainPath.strokeColor = '#02FEFF';
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   153
    this.mainPath.strokeWidth = 10;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   154
    this.mainPath.strokeCap = 'round';
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   155
    this.mainPath.strokeJoin = 'round';
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   156
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   157
    //Si on a un pointeur secondaire
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   158
    if(secondPointerX && secondPointerY)
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   159
    {
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   160
        //On obtient les coordonnées du pointeur secondaire en px.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   161
        secondPointerX = Math.floor(secondPointerX);
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   162
        secondPointerY = Math.floor(secondPointerY);
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   163
        
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   164
        //On forme le contour de la courbe secondaire.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   165
        this.secondPathStroke = new paper.Path();
58
a28488078053 Front IDILL:
bastiena
parents: 52
diff changeset
   166
        this.secondPathStroke.strokeColor = '#366F7A';
a28488078053 Front IDILL:
bastiena
parents: 52
diff changeset
   167
        this.secondPathStroke.strokeWidth = 18;
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   168
        this.secondPathStroke.strokeCap = 'round';
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   169
        this.secondPathStroke.strokeJoin = 'round';
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   170
        
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   171
        //On forme la courbe secondaire.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   172
        this.secondPath = new paper.Path();
58
a28488078053 Front IDILL:
bastiena
parents: 52
diff changeset
   173
        this.secondPath.strokeColor = '#02FEFF';
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   174
        this.secondPath.strokeWidth = 10;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   175
        this.secondPath.strokeCap = 'round';
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   176
        this.secondPath.strokeJoin = 'round';
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   177
    }
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   178
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   179
    //On raffraichit l'affichage.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   180
    paper.view.draw();
35
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
   181
};
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
   182
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   183
/*
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   184
 * Fonction appelée lorsque les pointeurs bougent pour construire la courbe.
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   185
 * Est appelé dans les fichiers :
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   186
 * mosaic > fonction onMouseMove.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   187
 * client > fonction processMsg.
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   188
*/
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   189
SearchCanvas.prototype.onPointerMove = function(mainPointerX, mainPointerY, secondPointerX, secondPointerY)
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   190
{
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   191
    // console.log('MOVE');
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   192
    
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   193
    //Si on est dans une video, on réhausse
59
e812126f75f4 Front IDILL : curves more accurate
bastiena
parents: 58
diff changeset
   194
    if(this.mosaic.currentMode != 'MOSAIC' && this.mosaic.currentMode != 'FILTER' && this.mosaic.config.mouseInteractions)
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   195
    {
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   196
        // mainPointerX -= 130;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   197
        // mainPointerY -= 60;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   198
        
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   199
        if(secondPointerX && secondPointerY)
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   200
        {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   201
            secondPointerX -= 130;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   202
            secondPointerY -= 60;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   203
        }
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   204
    }
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   205
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   206
    //On obtient les coordonnées du pointeur principal en px.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   207
    mainPointerX = Math.floor(mainPointerX);
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   208
    mainPointerY = Math.floor(mainPointerY);
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   209
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   210
    //Si les coordonnées du pointeur principal n'ont pas été affectées, on les affecte.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   211
    if(!this.mainPointerLastX || !this.mainPointerLastY)
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   212
    {
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   213
        this.mainPointerLastX = mainPointerX;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   214
        this.mainPointerLastY = mainPointerY;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   215
    }
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   216
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   217
    //On crée les points de la courbe principale.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   218
    var mainPoint = new paper.Point(mainPointerX, mainPointerY);
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   219
    var mainPointStroke = new paper.Point(mainPointerX, mainPointerY);
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   220
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   221
    //On les ajoute à la courbe.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   222
    this.mainPathStroke.add(mainPointStroke);
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   223
    this.mainPathStroke.smooth();
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   224
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   225
    //On place le premier point de la courbe, qu'on lisse.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   226
    this.mainPath.add(mainPoint);
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   227
    this.mainPath.smooth();
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   228
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   229
    //Si on a un pointeur secondaire.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   230
    if(secondPointerX && secondPointerY)
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   231
    {
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   232
        //On obtient les coordonnées du pointeur secondaire en px.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   233
        secondPointerX = Math.floor(secondPointerX);
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   234
        secondPointerY = Math.floor(secondPointerY);
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   235
        
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   236
        //Si les coordonnées du pointeur principal n'ont pas été affectées, on les affecte.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   237
        if(!this.secondPointerLastX || !this.secondPointerLastY)
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   238
        {
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   239
            this.secondPointerLastX = secondPointerX;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   240
            this.secondPointerLastY = secondPointerY;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   241
        }
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   242
        
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   243
        //On crée les points de la courbe secondaire.
58
a28488078053 Front IDILL:
bastiena
parents: 52
diff changeset
   244
        var secondPoint = new paper.Point(secondPointerX, secondPointerY);
a28488078053 Front IDILL:
bastiena
parents: 52
diff changeset
   245
        var secondPointStroke = new paper.Point(secondPointerX, secondPointerY);
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   246
        
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   247
        //On les ajoute à la courbe.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   248
        this.secondPathStroke.add(secondPointStroke);
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   249
        this.secondPathStroke.smooth();
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   250
        
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   251
        //On place le premier point de la seconde courbe, qu'on lisse.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   252
        this.secondPath.add(secondPoint);
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   253
        this.secondPath.smooth();
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   254
        
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   255
        //On met l'avant dernière position du pointeur secondaire à jour.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   256
        if(this.secondPointerLastX != secondPointerX)
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   257
        {
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   258
            this.secondPointerLastX = secondPointerX;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   259
        }
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   260
        if(this.secondPointerLastY != secondPointerY)
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   261
        {
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   262
            this.secondPointerLastY = secondPointerY;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   263
        }
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   264
    }
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   265
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   266
    //On met l'avant dernière position du pointeur principal à jour.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   267
    if(this.mainPointerLastX != mainPointerX)
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   268
    {
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   269
        this.mainPointerLastX = mainPointerX;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   270
    }
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   271
    if(this.mainPointerLastY != mainPointerY)
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   272
    {
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   273
        this.mainPointerLastY = mainPointerY;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   274
    }
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   275
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   276
    //On met à jour les points dans le détecteur de courbes.
58
a28488078053 Front IDILL:
bastiena
parents: 52
diff changeset
   277
    this.detector.updatePos(mainPointerX, mainPointerY, secondPointerX, secondPointerY);
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   278
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   279
    //On met à jour l'affichage.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   280
    paper.view.draw();
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   281
};
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   282
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   283
/*
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   284
 * Fonction appelée lorsqu'on cesse de dessiner une courbe.
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   285
 * Est appelé dans les fichiers :
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   286
 * mosaic > fonction onMouseUp.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   287
 * client > fonction processMsg.
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   288
*/
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   289
SearchCanvas.prototype.onPointerOut = function()
35
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
   290
{
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   291
    // console.log('OUT');
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   292
    // console.trace();
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   293
    
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   294
    //On quitte la zone de recherche.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   295
    this.isUserInSearchZone = false;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   296
        
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   297
    //On regarde si ce qu'on a tracé correspond à une courbe en particulier.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   298
    var gesture_match = this.mosaic.gestureWithSameCode(this.mosaic.actualCode);
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   299
    this.mosaic.actualCode = '';
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   300
    
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   301
    //Si oui.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   302
    if(gesture_match.length > 0)
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   303
    {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   304
        //Si on est en mode recherche dans une vidéo et que le player est prêt.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   305
        if(this.mosaic.currentMode == "SEARCH" && this.mosaic.playerIsReady)
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   306
        {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   307
            //On effectue une recherche dans cette vidéo.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   308
            this.mosaic.player.widgets[0].searchByGesture(gesture_match);
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   309
            this.mosaic.isCurrentlyInASearchByGesture = this.mosaic.player.widgets[0].isCurrentlyInASearchByGesture;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   310
            
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   311
            //On va au premier marqueur trouvé.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   312
            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]))
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   313
            {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   314
                this.mosaic.player.widgets[0].goToFirstSearchedMarker(this.mosaic.currentSearchGesture[this.mosaic.centerId]);
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   315
            }
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   316
            
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   317
            //On affiche la notification de gesture de recherche.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   318
            this.mosaic.removeNotifications();
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   319
            this.mosaic.currentSearchGesture[this.mosaic.centerId] = gesture_match;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   320
            this.mosaic.searchGesture(gesture_match, 'valid');
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   321
            this.mosaic.curvesGesturesFound = false;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   322
        }
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   323
        //Si on est en mode de filtrage de mosaique.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   324
        else if(this.mosaic.currentMode == "FILTER")
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   325
        {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   326
            if(this.mosaic.isMosaicFiltered)
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   327
            {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   328
                //On notifie la recherche par filtrage.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   329
                this.mosaic.removeNotifications();
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   330
                this.mosaic.filterSearchedType = gesture_match;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   331
                this.mosaic.filterGesture(gesture_match, 'valid');
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   332
                //On filtre la mosaique.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   333
                this.mosaic.searchFilter(gesture_match);
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   334
                this.mosaic.curvesGesturesFound = false;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   335
            }
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   336
        }
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   337
    }
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   338
    //Si aucune gesture ne matche dans le dictionnaire.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   339
    else if(!this.mosaic.mustTakeOutHands && this.mosaic.mouseInteractions)
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   340
    {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   341
        //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.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   342
        if(this.mosaic.currentMode == "FILTER" && this.mosaic.filterSearchedType == "")
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   343
        {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   344
            this.mosaic.currentMode = "MOSAIC";
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   345
            this.mosaic.isMosaicFiltered = false;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   346
        }
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   347
        //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.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   348
        if(this.mosaic.currentMode == "SEARCH" && this.mosaic.currentSearchGesture[this.mosaic.centerId] == "")
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   349
        {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   350
            this.mosaic.currentMode = "VIDEO";
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   351
        }
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   352
    }
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   353
    
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   354
    //On réinitialise la courbe principale.
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   355
    if(this.mainPathStroke)
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   356
    {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   357
        this.mainPathStroke.remove();
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   358
    }
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   359
    if(this.mainPath)
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   360
    {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   361
        this.mainPath.remove();
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   362
    }
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   363
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   364
    this.mainPointerLastX = 0;
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   365
    this.mainPointerLastY = 0;
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   366
    this.mainPointerX = 0;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   367
    this.mainPointerY = 0;
52
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   368
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   369
    //On réinitialise le détecteur.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   370
    this.detector.reinit();
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   371
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   372
    //Si on a un second pointeur, on réinitialise la courbe secondaire.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   373
    if(this.secondPathStroke)
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   374
    {
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   375
        this.secondPathStroke.remove();
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   376
    }
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   377
    if(this.secondPath)
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   378
    {
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   379
        this.secondPath.remove();
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   380
    }
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   381
    
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   382
    //On met à jour l'affichage.
277c94533395 Front IDILL :
bastiena
parents: 46
diff changeset
   383
    paper.view.draw();
35
4267d6d27a7d Front IDILL :
bastiena
parents:
diff changeset
   384
};