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