]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/include/marDictionary.cxx
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / include / marDictionary.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 #include <stdio.h>
27 #include <stdlib.h> 
28 #include <string.h> 
29
30 #include "marDictionary.h"
31
32
33 marDictFrase::marDictFrase(int idfrase,char*frase){
34   _idfrase       = idfrase;
35   _frase=(char*)malloc(strlen(frase));
36   memcpy( _frase , frase , strlen(frase));
37   _frase[strlen(frase)-1]='\0';
38 }
39 //-----------------------------------------------------
40
41 marDictFrase::~marDictFrase(){
42         free(_frase);
43 }
44 //-----------------------------------------------------
45
46 int marDictFrase::GetIdFrase(){
47         return _idfrase;
48 }
49 //-----------------------------------------------------
50
51 char* marDictFrase::GetFrase(){
52         return _frase;
53 }
54 //-----------------------------------------------------
55 //-----------------------------------------------------
56 //-----------------------------------------------------
57 //-----------------------------------------------------
58
59 int marDictionary::_language                                            =       0;
60 std::vector<marDictFrase*>* marDictionary::_frases      =       0;
61
62 //-----------------------------------------------------
63
64 marDictionary::marDictionary(){
65         strcpy( _emptyStr      , "(...)"         );             
66 }
67 //-----------------------------------------------------
68 marDictionary::~marDictionary(){
69
70 //-----------------------------------------------------
71 bool marDictionary::ExistFileDictionary(char *dictionaryFileName){
72
73         bool result=true;
74         FILE *ff=fopen(dictionaryFileName,"r");
75         if (ff==NULL){
76                 result=false;
77         }
78         return result;
79 }
80 //-----------------------------------------------------
81 void marDictionary::ResetDictionary(){
82         if (_frases!=NULL){
83                 FreeDictionary();
84                 delete _frases;
85         }
86         _frases=new std::vector<marDictFrase*>();
87 }
88 //-----------------------------------------------------
89 bool marDictionary::LoadDictionaryFile(char *dictionaryFileName){
90         ResetDictionary();
91
92         bool result=false;
93
94         if ((_frases->size()==0) && (ExistFileDictionary(dictionaryFileName)==true) ){
95                 long idText;
96                 long idLanguage;
97                 char idTextStr[50];
98                 char idLanguageStr[50];
99                 char text[256];
100                 char line[256];
101                 char name[50];
102                 FILE *fileIn;
103                 fileIn=fopen(dictionaryFileName,"r");
104
105                 fgets(line, 256, fileIn);
106                 sscanf(line,"%s %d" , name,&idLanguage);                
107
108                 if (strcmp(name,"MARACAS_LANGUAGE")==0){
109                         SetLanguage(idLanguage);
110                         while (!feof(fileIn)) {
111                                 fgets(line, 256, fileIn);
112                                 if (strlen(line)>5){
113                                         sscanf(line,"%s %s " , idLanguageStr,idTextStr);                
114                                         sscanf(idLanguageStr,"%d " , &idLanguage);      
115                                         if (GetLanguage()==idLanguage){
116                                                 sscanf(idTextStr,"%d " , &idText);              
117                                                 char    *start  = line + strlen(idLanguageStr)+1 + strlen(idTextStr)+1;
118                                                 int             size    = strlen(line) -  (strlen(idLanguageStr)+1 + strlen(idTextStr)+1);
119                                                 memcpy(text,start,size-1);
120                                                 text[size]='\0';
121                                                 SetString(idText,text);
122                                         }
123                                 }
124                         }
125                         result=true;
126                 } else {
127                 }
128                 fclose(fileIn);
129         }  // if _frases->size()==0
130         return result;
131
132
133 //-----------------------------------------------------
134 void marDictionary::LoadDictionary_English(){
135         ResetDictionary();
136         SetLanguage(1);
137
138         SetString(   5 , "MARACAS: MAgnetic Resonance Angiography Computer ASisted analysis ");
139         SetString(  10 , "Iso Surface values ");
140         SetString(  15 , "Iso visible ");
141         SetString(  20 , "Opacity (%) ");
142         SetString(  25 , "Isovalue ");
143         SetString(  30 , "0 ");
144         SetString(  35 , "Select ");
145         SetString(  40 , "artery ");
146         SetString(  45 , "1 ");
147         SetString(  50 , "Axis Extraction ");
148         SetString(  55 , "2 ");
149         SetString(  60 , "Quantification ");
150         SetString(  65 , "Set an initial point. ");
151         SetString(  70 , "(Double click over the interest artery.) ");
152         SetString(  73 , "OK ");
153         SetString(  75 , "Start 3D ");
154         SetString(  80 , "Plan ");
155         SetString(  85 , "Parameters ");
156         SetString(  90 , "Slice ");
157         SetString( 205 , "Healthy slice ");
158         SetString( 210 , "Perpendicular section ");
159         SetString( 215 , "Visible ring ");
160         SetString( 220 , "Show surface ");
161         SetString( 225 , "Opacity ");
162         SetString( 230 , "grayscale         ");
163         SetString( 235 , "color ");
164         SetString( 240 , "Isovalue  ");
165         SetString( 245 , "Add mark contour ");
166         SetString( 248 , "Save Contours ");
167         SetString( 250 , "Erase marks contours ");
168         SetString( 253 , "Erase all marks contours ");
169         SetString( 255 , "Stenosis (area) ");
170         SetString( 260 , "Stenosis (diameter) ");
171         SetString( 265 , "Stenosis search ");
172         SetString( 270 , "Automatic stenosis search ");
173         SetString( 273 , "0 ");
174         SetString( 275 , "Select ");
175         SetString( 280 , " slice ");
176         SetString( 283 , "1 ");
177         SetString( 285 , "    Validate ");
178         SetString( 290 , "Healthy Slice ");
179         SetString( 293 , "2 ");
180         SetString( 295 , "   Validate ");
181         SetString( 300 , "End Region ");
182         SetString( 303 , "3 ");
183         SetString( 305 , "   Find ");
184         SetString( 310 , "stenosis ");
185         SetString( 315 , "Automatic ");
186         SetString( 320 , "Manual ");
187         SetString( 325 , "Manual stenosis search ");
188         SetString( 328 , "0 ");
189         SetString( 330 , "Select ");
190         SetString( 335 , " slice ");
191         SetString( 338 , "1 ");
192         SetString( 340 , "    Select ");
193         SetString( 345 , "other slice ");
194         SetString( 348 , "2 ");
195         SetString( 350 , "    Validate ");
196         SetString( 355 , "Healthy Slice ");
197         SetString( 360 , "Healthy region size ");
198         SetString( 365 , "Healthy region size ");
199         SetString( 370 , "Size of the healthy region  ( 2xn+1 ) ");
200         SetString( 373 , "n :  ");
201         SetString( 375 , "Refresh healthy region ");
202         SetString( 380 , "Total Axis Lenght ");
203         SetString( 385 , "Seg. Length ");
204         SetString( 390 , "Area ");
205         SetString( 395 , "Ref. Area ");
206         SetString( 400 , "Perimeter ");
207         SetString( 405 , "Minimum Diameter ");
208         SetString( 410 , "Maximum Diameter ");
209         SetString( 415 , "Average Diameter ");
210         SetString( 420 , "Ref Average Diam. ");
211         SetString( 500 , "Maracas parameters... ");
212         SetString( 505 , "Contour parameters ");
213         SetString( 510 , "Contour calculation algorithm ");
214         SetString( 515 , "% Thereshold ");
215         SetString( 520 , "Debug ");
216         SetString( 525 , "Visible Diameter? ");
217         SetString( 530 , "Axis Parameters  ");
218         SetString( 535 , "Extraction parameters ");
219         SetString( 540 , "Flexion coefficient: ");
220         SetString( 545 , "Tension coefficient: ");
221         SetString( 550 , "Mask size (2*n+1), n: ");
222         SetString( 555 , "Discret step for axis (1/N): ");
223         SetString( 560 , "OK ");
224         SetString( 565 , "Cancel ");
225         SetString( 570 , "Default ");
226         SetString( 575 , "Reset ");
227         SetString( 580 , "Apply ");
228         SetString( 605 , "The mask size was modified. ");
229         SetString( 610 , "The threshold was modified. ");
230         SetString( 615 , "The flexion coeficient was modified. ");
231         SetString( 620 , "The tension coeficient was modified. ");
232         SetString( 625 , "The discret step of the axis was modified.   ");
233         SetString( 630 , " The axe will be regenereted and the contours will be eresed. ");
234         SetString( 635 , " All contours will be erase.  ");
235         SetString( 640 , " Do you want to continue?   ");
236         SetString( 645 , "Alert   ");
237         SetString( 650 , " %  Threshold  :   ");
238         SetString( 655 , "Visible diameters? ");
239         SetString( 660 , "Flexion coefficient: ");
240         SetString( 665 , "Tension coefficient: ");
241         SetString( 670 , "Mask size (2*n+1). n:  ");
242         SetString( 675 , "Discret step for axis (1/N): ");
243         SetString( 680 , "OK  ");
244         SetString( 685 , "Cancel ");
245         SetString( 690 , "Reset ");
246         SetString( 695 , "Apply ");
247         SetString( 700 , "Default ");
248         SetString( 710 , "MARACAS Parameters... ");
249         SetString( 720 , "Extraction parameters ");
250         SetString( 725 , "Debug ");
251         SetString( 730 , "Contour calculation algorithm ");
252         SetString( 735 , "Contour Parameters ");
253         SetString( 740 , "Axis Parameters ");
254         SetString( 745 , "Invert slice order ");
255         SetString( 800 , "Contour modification ");
256         SetString( 803 , "Contour modification ");
257         SetString( 805 , "1 ");
258         SetString( 810 , "2 ");
259         SetString( 815 , "3 ");
260         SetString( 820 , "New ");
261         SetString( 825 , "Contour ");
262         SetString( 830 , "Replace ");
263         SetString( 835 , "End ");
264         SetString( 840 , "Insert point ");
265         SetString( 845 , "Delete point ");
266         SetString( 850 , "Move point ");
267         SetString( 855 , "Use mouse left button to ");
268         SetString( 860 , "create the new contour. ");
269         SetString( 865 , "Alert ");
270         SetString( 870 , "This option erase all 3D contours. ");
271         SetString( 875 , "Do you want to continue? ");
272         SetString( 905 , "Set an initial point. ");
273         SetString( 910 , "(Double click over the interest artery.) ");
274         SetString( 915 , "The initial point should be far ");
275         SetString( 920 , "of the limits of the volume. ");
276         SetString( 925 , "Threshold ");
277         SetString( 930 , "Lumen Intensity % ");
278         SetString( 935 , "Calcification Intensity % ");
279         SetString( 940 , "Contour control ");
280 }
281 //-----------------------------------------------------
282 void marDictionary::LoadDictionary_French(){
283         ResetDictionary();
284         SetLanguage(2);
285
286         SetString(   5 , "MARACAS: MAgnetic Resonance Angiography Computer ASisted analysis ");
287         SetString(  10 , "Valeurs de l'Iso surface ");
288         SetString(  15 , "Iso visible");
289         SetString(  20 , "Opacit  (%) ");
290         SetString(  25 , "Isovalue ");
291         SetString(  30 , "0 ");
292         SetString(  35 , "Choisir  ");
293         SetString(  40 , "l'artre  ");
294         SetString(  45 , "1 ");
295         SetString(  50 , "Extraction de l'axe  ");
296         SetString(  55 , "2 ");
297         SetString(  60 , "Quantification ");
298         SetString(  65 , "Placez un premier point. ");
299         SetString(  70 , "(Double clique au-dessus de l'artre d'intrt.) ");
300         SetString(  73 , "OK ");
301         SetString(  75 , "Commencer 3D  ");
302         SetString(  80 , "Plan ");
303         SetString(  85 , "Paramtres ");
304         SetString(  90 , "Coupe  ");
305         SetString( 205 , "Coupe saine ");
306         SetString( 210 , "Section perpendiculaire ");
307         SetString( 215 , "Visibilit des anneaux ");
308         SetString( 220 , "Montrer la surface ");
309         SetString( 225 , "Opacit  ");
310         SetString( 230 , "Niveaux des gris         ");
311         SetString( 235 , "Couleur ");
312         SetString( 240 , "Isovaleur  ");
313         SetString( 245 , "Ajouter un marqueur de coupe ");
314         SetString( 248 , "Enregistre les contours ");
315         SetString( 250 , "Effacer un marqueur de coupe  ");
316         SetString( 253 , "Effacer les marquer des coupes ");
317         SetString( 255 , "Stnoses  (surface) ");
318         SetString( 260 , "Stnoses (diamtre ) ");
319         SetString( 265 , "Recherche des stnoses  ");
320         SetString( 270 , "Recherche automatique de la stnose ");
321         SetString( 273 , "0 ");
322         SetString( 275 , "Choisissez ");
323         SetString( 280 , " la coupe ");
324         SetString( 283 , "1 ");
325         SetString( 285 , "Valider la  ");
326         SetString( 290 , "coupe saine ");
327         SetString( 293 , "2 ");
328         SetString( 295 , "Valider la fin ");
329         SetString( 300 , "de la rgion ");
330         SetString( 303 , "3 ");
331         SetString( 305 , "   Chercher ");
332         SetString( 310 , "   stnoses ");
333         SetString( 315 , "Automatique ");
334         SetString( 320 , "Manuel ");
335         SetString( 325 , "Recherche manuel de la stnose ");
336         SetString( 328 , "0 ");
337         SetString( 330 , "Choisir ");
338         SetString( 335 , " la coupe ");
339         SetString( 338 , "1 ");
340         SetString( 340 , " Choisissez ");
341         SetString( 345 , "autre coupe ");
342         SetString( 348 , "2 ");
343         SetString( 350 , "Valider la ");
344         SetString( 355 , "coupe saine ");
345         SetString( 360 , "Taille de rgion saine  ");
346         SetString( 365 , "Taille de rgion saine  ");
347         SetString( 370 , "( 2xn+1 ) ");
348         SetString( 373 , "n :  ");
349         SetString( 375 , "Rgnrer la rgion saine ");
350         SetString( 380 , "Longeur total de l'axe  ");
351         SetString( 385 , "Longueur du segment ");
352         SetString( 390 , "Surface ");
353         SetString( 395 , "Surface de ref. ");
354         SetString( 400 , "Primtre ");
355         SetString( 405 , "Diamtre minimum ");
356         SetString( 410 , "Diamtre maximum ");
357         SetString( 415 , "Diamtre moyen ");
358         SetString( 420 , "Diamtre moyen de ref. ");
359         SetString( 500 , "Paramtres de MARACAS... ");
360         SetString( 505 , "Paramtres du contour ");
361         SetString( 510 , "Algorithme pour le calcule de contour ");
362         SetString( 515 , "% Seuillage ");
363         SetString( 520 , "Debug ");
364         SetString( 525 , "Montrer diamtre? ");
365         SetString( 530 , "Paramtres de l'axe  ");
366         SetString( 535 , "Paramtres d'extraction ");
367         SetString( 540 , "Coefficient de flexion: ");
368         SetString( 545 , "Coefficient de tension : ");
369         SetString( 550 , "Taille du masque (2*n+1), n: ");
370         SetString( 555 , "Pas de discrtisation pour l'axe (1/N): ");
371         SetString( 560 , "OK ");
372         SetString( 565 , "Annule ");
373         SetString( 570 , "Dfaut ");
374         SetString( 575 , "Remise ");
375         SetString( 580 , "Appliquer ");
376         SetString( 605 , "La taille de masque a t modifie. ");
377         SetString( 610 , "Le seuil a t modifi . ");
378         SetString( 615 , "Le coefficient de flexion a t modifi. ");
379         SetString( 620 , "Le coefficient de tension a t modifi . ");
380         SetString( 625 , "Le pas de discrtisations a t modifi.   ");
381         SetString( 630 , " L'axe sera rgnr et les coupes seront effaces. ");
382         SetString( 635 , " Tous les contours seront effacs. ");
383         SetString( 640 , " Voulez-vous continuer ?   ");
384         SetString( 645 , "Atention   ");
385         SetString( 650 , " %  Seuillage  :   ");
386         SetString( 655 , "Diamtres visible? ");
387         SetString( 660 , "Coefficient de flexion: ");
388         SetString( 665 , "Coefficient de tension: ");
389         SetString( 670 , "Taille du masque (2*n+1). n:  ");
390         SetString( 675 , "Pas de discrtisations pour l'axe (1/N): ");
391         SetString( 680 , "OK  ");
392         SetString( 685 , "Annule ");
393         SetString( 690 , "Rinitialisation ");
394         SetString( 695 , "Appliquez ");
395         SetString( 700 , "Dfaut ");
396         SetString( 710 , "Paramtres de MARACAS... ");
397         SetString( 720 , "Extraction de paramtres ");
398         SetString( 725 , "Debug ");
399         SetString( 730 , "Algorithme pour le calcul de contour  ");
400         SetString( 735 , "Paramtres du contour ");
401         SetString( 740 , "Paramtres de l'axe ");
402         SetString( 745 , "Invertir l'ordre des coupes ");
403         SetString( 800 , "Contour modification ");
404         SetString( 803 , "Modification du contour ");
405         SetString( 805 , "1 ");
406         SetString( 810 , "2 ");
407         SetString( 815 , "3 ");
408         SetString( 820 , "Nouveau  ");
409         SetString( 825 , "contour ");
410         SetString( 830 , "Remplacer ");
411         SetString( 835 , "Fin ");
412         SetString( 840 , "Insertion de point ");
413         SetString( 845 , "Effacement de point  ");
414         SetString( 850 , "Dplacement de point  ");
415         SetString( 855 , "Bouton gauche de la sourie  ");
416         SetString( 860 , "pour crer le contour. ");
417         SetString( 865 , "Atention ");
418         SetString( 870 , "Cette option efface tous les contours 3D. ");
419         SetString( 875 , "Voulez-vous continuer ? ");
420         SetString( 905 , "Dfinissez  un  point initial. ");
421         SetString( 910 , "(Double clique sur le vaisseau d'intrt.) ");
422         SetString( 915 , "Le point initial doit tre ");
423         SetString( 920 , "loin des bords du volume. ");
424         SetString( 925 , "Seuil ");
425         SetString( 930 , "Intensit du Lumen % ");
426         SetString( 935 , "Intensit des calcifications % ");
427         SetString( 940 , "Control du contour ");
428
429 }
430 //-----------------------------------------------------
431 void marDictionary::LoadDictionary_Japanese (){
432         ResetDictionary();
433         SetLanguage(3);
434 }
435 //-----------------------------------------------------
436 void marDictionary::FreeDictionary(){
437         int i,size=_frases->size();
438         for (i=0;i < size;i++){
439                 marDictFrase* tmp=(*_frases)[i];
440                 delete tmp;
441         }
442         _frases->clear();
443
444
445 //-----------------------------------------------------
446 void marDictionary::SetLanguage(int language){
447         _language=language;
448 }
449 //-----------------------------------------------------
450 char* marDictionary::GetString(int idfrase){
451         int i,size;     
452         char *result=NULL;
453         size=_frases->size();
454         for (i=0;i<size;i++){
455                 marDictFrase* tmp=(*_frases)[i];
456                 if (tmp->GetIdFrase()==idfrase){
457                         result=tmp->GetFrase();
458                 }
459         }
460         if (result==NULL){
461             sprintf(_emptyStr,"(...%d-%d...)",_language,idfrase);
462                 result=_emptyStr;
463         }
464         return result;
465 }
466 //-----------------------------------------------------
467 int     marDictionary::GetLanguage(){
468         return _language;
469 }
470 //-----------------------------------------------------
471 void marDictionary::SetString(int id,char *ss){
472         if (_frases!=NULL){
473                 marDictFrase *mf = new marDictFrase(id,ss);
474                 _frases->push_back(mf);
475         }
476 }
477
478 //-----------------------------------------------------