File: ProgramOptionsDialog.cpp

package info (click to toggle)
gentle 1.9%2Bcvs20100605%2Bdfsg1-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 12,224 kB
  • sloc: cpp: 41,569; ansic: 3,978; sh: 1,420; makefile: 240
file content (666 lines) | stat: -rw-r--r-- 27,704 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
/** \file
	\brief Contains the members of the ProgramOptionsDialog class and its helper classes, TEnzymeSettingsTab (which is also used in TVectorEditor) and TEnzymeRules
*/
#include "ProgramOptionsDialog.h"

BEGIN_EVENT_TABLE(ProgramOptionsDialog, wxDialog )
    EVT_BUTTON(POD_OK,ProgramOptionsDialog::OnOK)
    EVT_BUTTON(POD_CANCEL,ProgramOptionsDialog::OnCancel)
    EVT_BUTTON(POD_AA_COL,ProgramOptionsDialog::OnAACol)
    EVT_CHAR_HOOK(ProgramOptionsDialog::OnCharHook)
END_EVENT_TABLE()
    
BEGIN_EVENT_TABLE(TEnzymeSettingsTab, wxPanel )
    EVT_CHECKBOX(GES_USE,TEnzymeSettingsTab::OnEnzymeCheckbox)
    EVT_CHECKBOX(GES_USE_MINCUTOFF,TEnzymeSettingsTab::OnEnzymeCheckbox)
    EVT_CHECKBOX(GES_USE_MAXCUTOFF,TEnzymeSettingsTab::OnEnzymeCheckbox)
    EVT_CHECKBOX(GES_USE_COLOR_CODING,TEnzymeSettingsTab::OnEnzymeCheckbox)
    EVT_BUTTON(GES_COL_1,TEnzymeSettingsTab::OnButton1)
    EVT_BUTTON(GES_COL_2,TEnzymeSettingsTab::OnButton2)
    EVT_BUTTON(GES_COL_3,TEnzymeSettingsTab::OnButton3)
END_EVENT_TABLE()


TEnzymeSettingsTab::TEnzymeSettingsTab ( wxWindow *parent , int _mode )
	: wxPanel ( parent )
	{
    myapp()->frame->push_help ( _T("GENtle:Options") ) ;
	mode = _mode ;
	int w , h ;
    GetClientSize ( &w , &h ) ;
    
    wxBoxSizer *vs = new wxBoxSizer ( wxVERTICAL ) ;
    wxFlexGridSizer *topSizer = new wxFlexGridSizer ( 2 , 15 , 5 ) ;
    optionsSizer = new wxFlexGridSizer ( 4 , 15 , 5 ) ;    
    
    // Top
    wxString t = txt("t_use_global_enzyme_settings") ; // EST_GLOBAL
    if ( mode == EST_PROJECT ) t = txt("t_use_project_enzyme_settings") ;
    if ( mode == EST_SINGLE ) t = txt("t_use_single_enzyme_settings") ;
    useSettings = new wxCheckBox ( this , GES_USE , t ) ; 
    join_enzymes = new wxCheckBox ( this , -1 , txt("t_ges_join_enzymes") ) ;    
    topSizer->Add ( new wxStaticText ( this , -1 , _T("") ) , 1 , wxALIGN_CENTER_VERTICAL ) ;
    topSizer->Add ( new wxStaticText ( this , -1 , _T("") ) , 1 , wxALIGN_CENTER_VERTICAL ) ;
    topSizer->Add ( useSettings , 1 , wxALIGN_CENTER_VERTICAL ) ;
    topSizer->Add ( join_enzymes , 1 , wxALIGN_CENTER_VERTICAL ) ;
    
    vs->Add ( topSizer , 0 , wxEXPAND , 5 ) ;
    vs->Add ( new wxStaticText ( this , -1 , _T(" ") ) , 0 , wxEXPAND , 5 ) ;
    vs->Add ( optionsSizer , 1 , wxEXPAND , 5 ) ;
    
    // Min/max cutoff
    useMinCutoff = new wxCheckBox ( this , GES_USE_MINCUTOFF , txt("t_ges_use_min_cutoff") ) ;
    minCutoff = new wxSpinCtrl ( this , -1 , _T("1")  , wxDefaultPosition , wxSize ( MYSPINBOXSIZE , 30 ) ) ;
    useMaxCutoff = new wxCheckBox ( this , GES_USE_MAXCUTOFF , txt("t_ges_use_max_cutoff") ) ;
    maxCutoff = new wxSpinCtrl ( this , -1 , _T("3")  , wxDefaultPosition , wxSize ( MYSPINBOXSIZE , 30 ) ) ;
    
    // Length of recognition sequence
    recog4 = new wxCheckBox ( this , -1 , txt("t_ges_seqlen4") ) ;
    recog5 = new wxCheckBox ( this , -1 , txt("t_ges_seqlen5") ) ;
    recog6 = new wxCheckBox ( this , -1 , txt("t_ges_seqlen6") ) ;
    recog6p = new wxCheckBox ( this , -1 , txt("t_ges_seqlen6p") ) ;

    // Overlaps
    pattern3 = new wxCheckBox ( this , -1 , txt("t_ges_overlap3") ) ;
    pattern5 = new wxCheckBox ( this , -1 , txt("t_ges_overlap5") ) ;
    pattern_blunt = new wxCheckBox ( this , -1 , txt("t_ges_overlap_blunt") ) ;
    
    // Group list
    default_group = new wxChoice ( this , -1 ) ;
    default_group->Append ( txt("All") ) ;
    wxArrayString vs2 ;
    myapp()->frame->LS->getEnzymeGroups ( vs2 ) ;
    for ( int i = 0 ; i < vs2.GetCount() ; i++ )
        default_group->Append ( vs2[i] ) ;
    default_group->SetStringSelection ( txt("All") ) ;
    
    // Colors
    use_color_coding = new wxCheckBox ( this , GES_USE_COLOR_CODING , txt("t_ges_use_color_coding") ) ;
    bcol1 = new wxButton ( this , GES_COL_1 , txt("t_ges_cut1") ) ;
    bcol2 = new wxButton ( this , GES_COL_2 , txt("t_ges_cut2") ) ;
    bcol3 = new wxButton ( this , GES_COL_3 , txt("t_ges_cut3") ) ;
    
    // Methylation
    met_dam = new wxCheckBox ( this , -1 , txt("t_ges_met_dam") ) ;
    met_dcm = new wxCheckBox ( this , -1 , txt("t_ges_met_dcm") ) ;
    
    // GC%
    showgc = new wxCheckBox ( this , -1 , txt("t_ges_showgc") ) ;
    
    // Adding elements to gridsizer
    optionsSizer->Add ( use_color_coding , 1 , wxALIGN_CENTER_VERTICAL ) ;
    optionsSizer->Add ( bcol1 , 1 , wxALIGN_CENTER_VERTICAL ) ;
    optionsSizer->Add ( bcol2 , 1 , wxALIGN_CENTER_VERTICAL ) ;
    optionsSizer->Add ( bcol3 , 1 , wxALIGN_CENTER_VERTICAL ) ;

    optionsSizer->Add ( useMinCutoff , 1 , wxALIGN_CENTER_VERTICAL ) ;
    optionsSizer->Add ( minCutoff , 1 , wxALIGN_CENTER_VERTICAL ) ;
    optionsSizer->Add ( useMaxCutoff , 1 , wxALIGN_CENTER_VERTICAL ) ;
    optionsSizer->Add ( maxCutoff , 1 , wxALIGN_CENTER_VERTICAL ) ;
    
    optionsSizer->Add ( new wxStaticText ( this , -1 , txt("t_ges_overlaps") ) , 1 , wxALIGN_CENTER_VERTICAL ) ;
    optionsSizer->Add ( pattern3 , 1 , wxALIGN_CENTER_VERTICAL ) ;
    optionsSizer->Add ( pattern5 , 1 , wxALIGN_CENTER_VERTICAL ) ;
    optionsSizer->Add ( pattern_blunt , 1 , wxALIGN_CENTER_VERTICAL ) ;
    
    optionsSizer->Add ( recog4 , 1 , wxALIGN_CENTER_VERTICAL ) ;
    optionsSizer->Add ( recog5 , 1 , wxALIGN_CENTER_VERTICAL ) ;
    optionsSizer->Add ( recog6 , 1 , wxALIGN_CENTER_VERTICAL ) ;
    optionsSizer->Add ( recog6p , 1 , wxALIGN_CENTER_VERTICAL ) ;
    
    optionsSizer->Add ( new wxStaticText ( this , -1 , txt("t_ges_enzyme_group") ) , 1 , wxALIGN_CENTER_VERTICAL ) ;
    optionsSizer->Add ( default_group , 1 , wxALIGN_CENTER_VERTICAL ) ;
    optionsSizer->Add ( new wxStaticText ( this , -1 , _T("") ) , 1 , wxALIGN_CENTER_VERTICAL ) ;
    optionsSizer->Add ( new wxStaticText ( this , -1 , _T("") ) , 1 , wxALIGN_CENTER_VERTICAL ) ;

    optionsSizer->Add ( new wxStaticText ( this , -1 , txt("t_ges_met") ) , 1 , wxALIGN_CENTER_VERTICAL ) ;
    optionsSizer->Add ( met_dam , 1 , wxALIGN_CENTER_VERTICAL ) ;
    optionsSizer->Add ( met_dcm , 1 , wxALIGN_CENTER_VERTICAL ) ;
    optionsSizer->Add ( new wxStaticText ( this , -1 , _T("") ) , 1 , wxALIGN_CENTER_VERTICAL ) ;

    optionsSizer->Add ( showgc , 1 , wxALIGN_CENTER_VERTICAL ) ;
    
    // Do it!
    this->SetSizer ( vs ) ;
    vs->Fit ( this ) ;    
    this->Show () ;
    updateGlobalEnzymes () ;
	vs->Fit ( this ) ;
	}    

ProgramOptionsDialog::~ProgramOptionsDialog ()
	{
	myapp()->frame->pop_help () ;
    }

void TEnzymeSettingsTab::updateGlobalEnzymes ()
	{
	bool use = useSettings->GetValue() ;
	useMinCutoff->Enable ( use ) ;
	useMaxCutoff->Enable ( use ) ;
	minCutoff->Enable ( useMinCutoff->GetValue() && use ) ;
	maxCutoff->Enable ( useMaxCutoff->GetValue() && use ) ;
	recog4->Enable ( use ) ;
	recog5->Enable ( use ) ;
	recog6->Enable ( use ) ;
	recog6p->Enable ( use ) ;
	pattern3->Enable ( use ) ;
	pattern5->Enable ( use ) ;
	pattern_blunt->Enable ( use ) ;
	default_group->Enable ( use ) ;
	if ( mode != EST_GLOBAL )
		{
		join_enzymes->Enable ( use ) ;
		use_color_coding->Enable ( use ) ;
		}    
	updateColorButton ( bcol1 , col1 ) ;
	updateColorButton ( bcol2 , col2 ) ;
	updateColorButton ( bcol3 , col3 ) ;
	}

void TEnzymeSettingsTab::updateColorButton ( wxButton *b , wxColour &c )
	{
	b->SetForegroundColour ( c ) ;
	if ( ( c.Red() + c.Green() + c.Blue() ) / 3 < 230 ) b->SetBackgroundColour ( *wxWHITE ) ;
	else b->SetBackgroundColour ( *wxBLACK ) ;
	if ( mode == EST_GLOBAL ) b->Enable ( use_color_coding->GetValue() ) ;
 	else b->Enable ( use_color_coding->GetValue() && useSettings->GetValue() ) ;
	}    
	
void TEnzymeSettingsTab::OnEnzymeCheckbox ( wxCommandEvent &event )
	{
	updateGlobalEnzymes () ;
	}    

void TEnzymeSettingsTab::OnButton1 ( wxCommandEvent &event )
	{
	updateColor ( col1 ) ;
	}    

void TEnzymeSettingsTab::OnButton2 ( wxCommandEvent &event )
	{
	updateColor ( col2 ) ;
	}    

void TEnzymeSettingsTab::OnButton3 ( wxCommandEvent &event )
	{
	updateColor ( col3 ) ;
	}    

void TEnzymeSettingsTab::updateColor ( wxColour &c )
	{
	wxColour c2 = wxGetColourFromUser ( this , c ) ;
	if ( !c2.Ok() ) return ;
	c = c2 ;
	updateGlobalEnzymes () ;
	}    
    

// ****************************************

ProgramOptionsDialog::ProgramOptionsDialog(wxWindow *parent, const wxString& title )
         : wxDialog ( parent , -1 , title , wxDefaultPosition , wxSize ( 620 , 450 ) )
    {
    wxBoxSizer *v0 = new wxBoxSizer ( wxVERTICAL ) ;
    wxBoxSizer *h0 = new wxBoxSizer ( wxHORIZONTAL ) ;
	
    globalSettingsPanel = NULL ;
    nb = new wxNotebook ( (wxWindow*) this , -1 ) ;
//	wxNotebookSizer *nbs = new wxNotebookSizer ( nb ) ;

    initGlobalSettings () ;
    initGlobalEnzymes () ;

    wxButton *OK = new wxButton ( this , POD_OK , txt("b_ok") ) ;
    wxButton *CANCEL = new wxButton ( this , POD_CANCEL , txt("b_cancel") ) ;

	h0->Add ( new wxStaticText ( this , -1 , _T("") ) , 1 , 0 ) ;
	h0->Add ( OK , 1 , 0 ) ;
	h0->Add ( new wxStaticText ( this , -1 , _T("") ) , 1 , 0 ) ;
	h0->Add ( CANCEL , 1 , 0 ) ;
	h0->Add ( new wxStaticText ( this , -1 , _T("") ) , 1 , 0 ) ;

	v0->Add ( nb , 1 , wxALL|wxEXPAND , 5 ) ;
	v0->Add ( h0 , 0 , wxALL|wxEXPAND , 5 ) ;

	SetSizer ( v0 ) ;
	v0->Fit ( this ) ;

    Center () ;
    OK->SetDefault () ;
    OK->SetFocus() ;
    }
    
void ProgramOptionsDialog::initGlobalEnzymes ()
	{
    globalEnzymesPanel = new TEnzymeSettingsTab ( nb ) ;
    nb->AddPage ( globalEnzymesPanel , txt("t_global_enzymes") ) ;    
    }    
    
void ProgramOptionsDialog::initGlobalSettings ()
	{
    globalSettingsPanel = new wxPanel ( nb , -1 ) ;
    nb->AddPage ( globalSettingsPanel , txt("t_global_settings") ) ;    

	wxStaticBoxSizer *display_options = new wxStaticBoxSizer ( wxVERTICAL , globalSettingsPanel , txt("program_options_display") ) ;
	wxStaticBoxSizer *general_options = new wxStaticBoxSizer ( wxVERTICAL , globalSettingsPanel , txt("program_options_general") ) ;

	// General settings
    language = new wxChoice ( globalSettingsPanel , -1 ) ;
    loadLastProject = new wxCheckBox ( globalSettingsPanel , -1 , 
                        txt("t_load_last_project") ) ;
    useMetafile = new wxCheckBox ( globalSettingsPanel , -1 , 
                        txt("t_use_metafile") ) ;
    checkUpdate = new wxCheckBox ( globalSettingsPanel , -1 , 
                        txt("t_check4update") ) ;
    useInternalHelp = new wxCheckBox ( globalSettingsPanel , -1 , 
                        txt("t_useinternalhelp") ) ; 
    useOnlineHelp = new wxCheckBox ( globalSettingsPanel , -1 , 
                        txt("t_useonlinehelp") ) ; 
    doRegisterStuff = new wxCheckBox ( globalSettingsPanel , -1 , 
                        txt("t_doregisterstuff") ) ; 
    use_nonstandard_translation_table = new wxCheckBox ( globalSettingsPanel , -1 ,
                        txt("t_use_nonstandard_translation_table") ) ;
    nonstandard_translation_table = new wxChoice ( globalSettingsPanel , -1 ) ;
    proxyName = new wxTextCtrl ( globalSettingsPanel , -1 , myapp()->frame->proxy.BeforeLast(':') ) ;
    proxyPort = new wxTextCtrl ( globalSettingsPanel , -1 , myapp()->frame->proxy.AfterLast(':') ) ;

	// ORF length
    wxBoxSizer *orf_sizer = new wxBoxSizer ( wxHORIZONTAL ) ;	
    orfLength = new wxTextCtrl ( globalSettingsPanel , -1 , wxString::Format ( _T("%d") , myapp()->frame->orfLength ) ) ;
    orf_sizer->Add ( new wxStaticText ( globalSettingsPanel , -1 , _T("ORF length") ) , 0 , wxEXPAND|wxALL , 3 ) ;
    orf_sizer->Add ( orfLength , 1 , wxEXPAND|wxALL , 3 ) ;

    
    // Display options
    enhancedDisplay = new wxCheckBox ( globalSettingsPanel , -1 , 
                        txt("t_enhanced_display") ) ; 
    vectorTitle = new wxCheckBox ( globalSettingsPanel , -1 , 
                        txt("t_vector_title") ) ;
    vectorLength = new wxCheckBox ( globalSettingsPanel , -1 , 
                        txt("t_vector_length") ) ;
    showSplashScreen = new wxCheckBox ( globalSettingsPanel , -1 , 
                        txt("t_show_splashscreen") ) ;
    showEnzymePos = new wxCheckBox ( globalSettingsPanel , -1 ,
                        txt("t_showenzymepos") ) ;
    showTips = new wxCheckBox ( globalSettingsPanel , -1 ,
                        txt("t_show_tips") ) ;
	useTwoToolbars = new wxCheckBox ( globalSettingsPanel , -1 ,
                        txt("t_use_two_toolbars") ) ;
    showToolTips = new wxCheckBox ( globalSettingsPanel , -1 ,
                        txt("t_show_tooltips") ) ;
    showLowercaseDNA = new wxCheckBox ( globalSettingsPanel , -1 ,
                        txt("t_show_lowercase_dna") ) ; // !!!!! VARIABLES!!!!
                        
                        
    wxString efm[3] ;
    efm[0] = txt("t_editfeaturemode_1") ;
    efm[1] = txt("t_editfeaturemode_2") ;
    efm[2] = txt("t_editfeaturemode_3") ;
    editFeatureMode = new wxRadioBox ( globalSettingsPanel , -1 , 
                        txt("t_editfeaturemode") , 
                        wxDefaultPosition , 
                        wxDefaultSize ,
                        3 , efm , 1 , wxRA_SPECIFY_ROWS ) ;
    editFeatureMode->SetSelection ( myapp()->frame->editFeatureMode ) ;

    wxString ssc[2] ;
    ssc[0] = _T("|") ;
    ssc[1] = _T("*") ;
    showStopCodon = new wxRadioBox ( globalSettingsPanel , -1 , 
                        txt("t_show_stop_codon") , 
                        wxDefaultPosition , 
                        wxDefaultSize ,
                        2 , ssc , 1 , wxRA_SPECIFY_ROWS ) ;
    showStopCodon->SetSelection ( myapp()->frame->showStopCodon ) ;
    wxButton *b_aacol = new wxButton ( globalSettingsPanel , POD_AA_COL , txt("t_aa_col") ) ;
                        
    enhancedDisplay->SetValue ( myapp()->frame->enhancedRefresh ) ;
    vectorTitle->SetValue ( myapp()->frame->showVectorTitle ) ;
    vectorLength->SetValue ( myapp()->frame->showVectorLength ) ;
    loadLastProject->SetValue ( myapp()->frame->loadLastProject ) ;
    useMetafile->SetValue ( myapp()->frame->useMetafile ) ;
    showSplashScreen->SetValue ( myapp()->frame->showSplashScreen ) ;
    checkUpdate->SetValue ( myapp()->frame->checkUpdate ) ;
    useInternalHelp->SetValue ( myapp()->frame->useInternalHelp ) ;
    useOnlineHelp->SetValue ( myapp()->frame->useOnlineHelp ) ;
    doRegisterStuff->SetValue ( myapp()->frame->doRegisterStuff ) ;
    showEnzymePos->SetValue ( myapp()->frame->showEnzymePos ) ;
	useTwoToolbars->SetValue ( myapp()->frame->useTwoToolbars ) ;
    showTips->SetValue ( myapp()->frame->LS->getOption ( _T("SHOWTIP") , true ) ) ;
    showToolTips->SetValue ( myapp()->frame->LS->getOption ( _T("SHOWTOOLTIPS") , true ) ) ;
    showLowercaseDNA->SetValue ( myapp()->frame->showLowercaseDNA ) ;
    use_nonstandard_translation_table->SetValue ( myapp()->frame->nonstandard_translation_table != -1 ) ;
    
    int a ;
    for ( a = 0 ; a < myapp()->frame->language_list.GetCount() ; a++ )
    	{
		if ( myapp()->frame->language_list[a].IsEmpty() ) continue ;
		language->Append ( myapp()->frame->language_list[a] ) ;
		}
    
//    language->Append ( _T("en") ) ;
//    language->Append ( _T("de") ) ;
    language->SetStringSelection ( myapp()->frame->lang_string ) ;
    aacol = myapp()->frame->aa_color ;
    
    TVector dummy ;
    int tt_mark = 0 ;
    for ( int a = 0 ; a < dummy.countCodonTables() ; a++ )
    	{
		if ( a != 1 && dummy.getCodonTableName(a) == dummy.getCodonTableName(1) ) continue ;
		translation_tables.push_back ( a ) ;
    	nonstandard_translation_table->Append ( dummy.getCodonTableName(a) ) ;
    	if ( myapp()->frame->nonstandard_translation_table == a )
    		tt_mark = translation_tables.size()-1 ;
		}
    if ( myapp()->frame->nonstandard_translation_table != -1 )
    	nonstandard_translation_table->SetSelection ( tt_mark ) ;
    else nonstandard_translation_table->SetSelection ( 0 ) ;

    wxBoxSizer *proxy_sizer = new wxBoxSizer ( wxHORIZONTAL ) ;
    proxy_sizer->Add ( new wxStaticText ( globalSettingsPanel , -1 , txt("t_proxy_name") ) , 0 , wxEXPAND|wxALL , 3 ) ;
    proxy_sizer->Add ( proxyName , 1 , wxEXPAND|wxALL , 3 ) ;
    proxy_sizer->Add ( new wxStaticText ( globalSettingsPanel , -1 , txt("t_proxy_port") ) , 0 , wxEXPAND|wxALL , 3 ) ;
    proxy_sizer->Add ( proxyPort , 0 , wxEXPAND|wxALL , 3 ) ;

    wxBoxSizer *v = new wxBoxSizer ( wxHORIZONTAL ) ;
    wxBoxSizer *h = new wxBoxSizer ( wxHORIZONTAL ) ;
    h->Add ( new wxStaticText ( globalSettingsPanel , -1 , txt("t_language") ) , 0 , wxEXPAND|wxALL , 3 ) ;
    h->Add ( language , 0 , wxEXPAND|wxALL , 3 ) ;

    v->Add ( general_options , 0 , wxEXPAND|wxALL , 3 ) ;
    v->Add ( display_options , 0 , wxEXPAND|wxALL , 3 ) ;
	
    general_options->Add ( h , 0 , wxEXPAND|wxALL , 3 ) ;
    general_options->Add ( loadLastProject , 0 , wxEXPAND|wxALL , 3 ) ;
    general_options->Add ( useMetafile , 0 , wxEXPAND|wxALL , 3 ) ;
    general_options->Add ( checkUpdate , 0 , wxEXPAND|wxALL , 3 ) ;
    general_options->Add ( useInternalHelp , 0 , wxEXPAND|wxALL , 3 ) ;
	general_options->Add ( useOnlineHelp , 0 , wxEXPAND|wxALL , 3 ) ;
    general_options->Add ( doRegisterStuff , 0 , wxEXPAND|wxALL , 3 ) ;
    general_options->Add ( new wxStaticText ( globalSettingsPanel , -1 , _T("") ) , 0 , wxEXPAND|wxALL , 3 ) ;
    general_options->Add ( use_nonstandard_translation_table , 0 , wxEXPAND|wxALL , 3 ) ; 
    general_options->Add ( nonstandard_translation_table , 0 , wxEXPAND|wxALL , 3 ) ;
    general_options->Add ( proxy_sizer , 0 , wxEXPAND|wxALL , 3 ) ;
    general_options->Add ( orf_sizer , 0 , wxEXPAND|wxALL , 3 ) ;
    
    display_options->Add ( enhancedDisplay , 0 , wxEXPAND|wxALL , 3 ) ;
    display_options->Add ( vectorTitle , 0 , wxEXPAND|wxALL , 3 ) ;
    display_options->Add ( vectorLength , 0 , wxEXPAND|wxALL , 3 ) ;
    display_options->Add ( showSplashScreen , 0 , wxEXPAND|wxALL , 3 ) ;
    display_options->Add ( showEnzymePos , 0 , wxEXPAND|wxALL , 3 ) ;
    display_options->Add ( showTips , 0 , wxEXPAND|wxALL , 3 ) ;
	display_options->Add ( useTwoToolbars , 0 , wxEXPAND|wxALL , 3 ) ;
    display_options->Add ( showToolTips , 0 , wxEXPAND|wxALL , 3 ) ;
    display_options->Add ( showLowercaseDNA , 0 , wxEXPAND|wxALL , 3 ) ;
    display_options->Add ( editFeatureMode , 0 , wxEXPAND|wxALL , 3 ) ;
    display_options->Add ( showStopCodon , 1 , wxEXPAND|wxALL , 3 ) ;
    display_options->Add ( b_aacol, 0 , wxEXPAND|wxALL , 3 ) ;

	 globalSettingsPanel->SetSizer ( v ) ;
	 v->Fit ( globalSettingsPanel ) ;
    }

void ProgramOptionsDialog::OnCharHook(wxKeyEvent& event)
    {
    int k = event.GetKeyCode () ;
    wxCommandEvent ev ;
    if ( k == WXK_ESCAPE ) OnCancel ( ev ) ;
    else if ( k == WXK_F1 ) myapp()->frame->OnHelp(ev) ;
    else event.Skip() ;
    }

void ProgramOptionsDialog::OnAACol ( wxCommandEvent &ev )
	{
	wxColour n = wxGetColourFromUser ( this , aacol ) ;
	if ( !n.Ok() ) return ; // Not OK
	aacol = n ;
	}

void ProgramOptionsDialog::OnOK ( wxCommandEvent &ev )
    {
    EndModal ( wxID_OK ) ; //wxDialog::OnOK ( ev ) ;
    }

void ProgramOptionsDialog::OnCancel ( wxCommandEvent &ev )
    {
    EndModal ( wxID_CANCEL ) ; //wxDialog::OnCancel ( ev ) ;
    }


//************************************************************************

void TEnzymeRules::init () // Default settings
	{
	useit = true ;
	min_cutoff = 1 ;
 	max_cutoff = 3 ;
	use_min_cutoff = true ;
 	use_max_cutoff = true ;
	recog4 = false ;
	recog5 = false ;
	recog6 = true ;
 	recog_longer = false ;
	pattern3 = false ;
	pattern5  = true ;
	pattern_blunt = false ;
	default_group = txt("All") ;
	col1.Set ( 200 , 0 , 0 ) ;
	col2.Set ( 0 , 200 , 0 ) ;
	col3.Set ( 0 , 0 , 200 ) ;
	join_enzymes = true ;
	use_color_coding = true ;
	methylation = 0 ;
	showgc = false ;
	}    

void TEnzymeRules::load_global_settings ()
	{
	init () ;
    wxString s = myapp()->frame->LS->getOption ( _T("GLOBALENZYMESETTINGS") , _T("") ) ;
    from_string ( s ) ;
	}    

void TEnzymeRules::save_global_settings ()
	{
    myapp()->frame->LS->setOption ( _T("GLOBALENZYMESETTINGS") , to_string() ) ;
	}    

void TEnzymeRules::setup_options ( TEnzymeSettingsTab *est )
	{
	est->useSettings->SetValue ( useit ) ;
	est->minCutoff->SetValue ( min_cutoff ) ;
	est->maxCutoff->SetValue ( max_cutoff ) ;
	est->useMinCutoff->SetValue ( use_min_cutoff ) ;
	est->useMaxCutoff->SetValue ( use_max_cutoff ) ;
	est->recog4->SetValue ( recog4 ) ;
	est->recog5->SetValue ( recog5 ) ;
	est->recog6->SetValue ( recog6 ) ;
	est->recog6p->SetValue ( recog_longer ) ;
	est->pattern3->SetValue ( pattern3 ) ;
	est->pattern5->SetValue ( pattern5 ) ;
	est->pattern_blunt->SetValue ( pattern_blunt ) ;
	if ( default_group != _T("") ) est->default_group->SetStringSelection ( default_group ) ;
	est->col1 = col1 ;
	est->col2 = col2 ;
	est->col3 = col3 ;
	est->join_enzymes->SetValue ( join_enzymes ) ;
	est->use_color_coding->SetValue ( use_color_coding ) ;
	est->met_dam->SetValue ( ( methylation & DAM_METHYLATION ) > 0 ) ;
	est->met_dcm->SetValue ( ( methylation & DCM_METHYLATION ) > 0 ) ;
	est->showgc->SetValue ( showgc ) ;
	est->updateGlobalEnzymes () ;
	}    

void TEnzymeRules::lookup_options ( TEnzymeSettingsTab *est )
	{
	useit = est->useSettings->GetValue() ;
	min_cutoff = est->minCutoff->GetValue() ;
	max_cutoff = est->maxCutoff->GetValue() ;
	use_min_cutoff = est->useMinCutoff->GetValue() ;
	use_max_cutoff = est->useMaxCutoff->GetValue() ;
	recog4 = est->recog4->GetValue() ;
	recog5 = est->recog5->GetValue() ;
	recog6 = est->recog6->GetValue() ;
	recog_longer = est->recog6p->GetValue() ;
	pattern3 = est->pattern3->GetValue() ;
	pattern5 = est->pattern5->GetValue() ;
	pattern_blunt = est->pattern_blunt->GetValue() ;
	default_group = est->default_group->GetStringSelection() ;
	col1 = est->col1 ;
	col2 = est->col2 ;
	col3 = est->col3 ;
	join_enzymes = est->join_enzymes->GetValue() ;
	use_color_coding = est->use_color_coding->GetValue() ;
	showgc = est->showgc->GetValue() ;
	
	methylation = 0 ;
	if ( est->met_dam->GetValue() ) methylation += DAM_METHYLATION ;
	if ( est->met_dcm->GetValue() ) methylation += DCM_METHYLATION ;
	}
	
bool TEnzymeRules::isEqual ( TEnzymeRules &r )
	{
 	return to_string() == r.to_string() ;
	}    
     
wxString TEnzymeRules::to_string ()
	{
	wxString ret ;
	ret += wxString::Format ( _T("useit=%d\r") , useit ) ;
	ret += wxString::Format ( _T("min_cutoff=%d\r") , min_cutoff ) ;
	ret += wxString::Format ( _T("max_cutoff=%d\r") , max_cutoff ) ;
	ret += wxString::Format ( _T("use_min_cutoff=%d\r") , use_min_cutoff ) ;
	ret += wxString::Format ( _T("use_max_cutoff=%d\r") , use_max_cutoff ) ;
	ret += wxString::Format ( _T("recog4=%d\r") , recog4 ) ;
	ret += wxString::Format ( _T("recog5=%d\r") , recog5 ) ;
	ret += wxString::Format ( _T("recog6=%d\r") , recog6 ) ;
	ret += wxString::Format ( _T("recog_longer=%d\r") , recog_longer ) ;
	ret += wxString::Format ( _T("pattern3=%d\r") , pattern3 ) ;
	ret += wxString::Format ( _T("pattern5=%d\r") , pattern5 ) ;
	ret += wxString::Format ( _T("pattern_blunt=%d\r") , pattern_blunt ) ;
	ret += wxString::Format ( _T("default_group=%s\r") , default_group.c_str() ) ;
	ret += wxString::Format ( _T("col1=%d,%d,%d\r") , col1.Red() , col1.Green() , col1.Blue() ) ;
	ret += wxString::Format ( _T("col2=%d,%d,%d\r") , col2.Red() , col2.Green() , col2.Blue() ) ;
	ret += wxString::Format ( _T("col3=%d,%d,%d\r") , col3.Red() , col3.Green() , col3.Blue() ) ;
	ret += wxString::Format ( _T("join_enzymes=%d\r") , join_enzymes ) ;
	ret += wxString::Format ( _T("use_color_coding=%d\r") , use_color_coding ) ;
	ret += wxString::Format ( _T("methylation=%d\r") , methylation ) ;
	ret += wxString::Format ( _T("showgc=%d\r") , showgc ) ;
	return ret ;
	}    

void TEnzymeRules::from_string ( wxString &s )
	{
	init () ;
	wxArrayString as ;
	explode ( _T("\r") , s , as ) ;
	for ( int a = 0 ; a < as.GetCount() ; a++ )
		{
		if ( as[a] == _T("") ) continue ;
		wxString key = as[a].BeforeFirst ( '=' ) ;
		wxString val = as[a].AfterFirst ( '=' ) ;
		long l ;
		val.ToLong ( &l ) ;
		if ( key == _T("useit") ) useit = l ;
		else if ( key == _T("min_cutoff") ) min_cutoff = l ;
		else if ( key == _T("max_cutoff") ) max_cutoff = l ;
		else if ( key == _T("use_min_cutoff") ) use_min_cutoff = l ;
		else if ( key == _T("use_max_cutoff") ) use_max_cutoff = l ;
		else if ( key == _T("recog4") ) recog4 = l ;
		else if ( key == _T("recog5") ) recog5 = l ;
		else if ( key == _T("recog6") ) recog6 = l ;
		else if ( key == _T("recog_longer") ) recog_longer = l ;
		else if ( key == _T("pattern3") ) pattern3 = l ;
		else if ( key == _T("pattern5") ) pattern5 = l ;
		else if ( key == _T("pattern_blunt") ) pattern_blunt = l ;
		else if ( key == _T("default_group") ) default_group = val ;
		else if ( key == _T("col1") ) col1 = scan_color ( val ) ;
		else if ( key == _T("col2") ) col2 = scan_color ( val ) ;
		else if ( key == _T("col3") ) col3 = scan_color ( val ) ;
		else if ( key == _T("join_enzymes") ) join_enzymes = l ;
		else if ( key == _T("use_color_coding") ) use_color_coding = l ;
		else if ( key == _T("methylation") ) methylation = l ;
		else if ( key == _T("showgc") ) showgc = l ;
		}    
	}    

wxColour TEnzymeRules::scan_color ( wxString s )
	{
	wxString c1 = s.BeforeFirst ( ',' ) ;
	s = s.AfterFirst ( ',' ) ;
	wxString c2 = s.BeforeFirst ( ',' ) ;
	wxString c3 = s.AfterFirst ( ',' ) ;
	return wxColour ( atoi(c1.mb_str()) , atoi(c2.mb_str()) , atoi(c3.mb_str()) ) ;
	}

// Here we go...

wxColour *TEnzymeRules::getColor ( int cuts )
	{
	if ( !use_color_coding || cuts == 0 || cuts > 3 ) return (wxColour*) wxBLACK ;
	if ( cuts == 1 ) return &col1 ;
	if ( cuts == 2 ) return &col2 ;
	if ( cuts == 3 ) return &col3 ;
	return &col1 ; // Dummy
	}    

void TEnzymeRules::getVectorCuts ( TVector *v )
{
    int a , b ;
    for ( a = 0 ; a < v->re.GetCount() ; a++ )
	v->getCuts ( v->re[a] , v->rc , false ) ;
    if ( !useit ) return ;

    // Getting the default list of enzymes
    wxArrayTRestrictionEnzyme ve ;
    wxArrayString vs ;
    myapp()->frame->LS->getEnzymesInGroup ( default_group , vs ) ;
    ve.Alloc ( vs.GetCount() ) ;
    
    // Removing the ones we already did because they were manually selected
    for ( a = 0 ; a < v->re.GetCount() ; a++ )
    {
	if ( v->re[a]->getName().IsEmpty() ) continue ; // Avoid endless loop
	int i = vs.Index ( v->re[a]->getName() ) ;
	while ( i != wxNOT_FOUND )
	{
	    vs[i] = _T("") ;
	    i = vs.Index ( v->re[a]->getName() ) ;
	}    
    }    

    // Eliminating from properties
    for ( a = 0 ; a < vs.GetCount() ; a++ )
    {
	if ( vs[a].IsEmpty() ) continue ; // Was removed earlier
	TRestrictionEnzyme *e = myapp()->frame->LS->getRestrictionEnzyme ( vs[a] ) ;
	bool keep = true ;
	if ( keep && !pattern3 && e->getOverlap() < 0 ) keep = false ;
	if ( keep && !pattern5 && e->getOverlap() > 0 ) keep = false ;
	if ( keep && !pattern_blunt && e->getOverlap() == 0 ) keep = false ;
	if ( keep && !recog4 && e->getSequence().length() == 4 ) keep = false ;
	if ( keep && !recog5 && e->getSequence().length() == 5 ) keep = false ;
	if ( keep && !recog6 && e->getSequence().length() == 6 ) keep = false ;
	if ( keep && !recog_longer && e->getSequence().length() > 6 ) keep = false ;
	if ( keep ) ve.Add ( e ) ;
    }    
    
    // Add what has the correct number of cuts
    v->re2.Clear () ; // The list of used enzymes that were *not* added manually
    int max = 10000000 ; // Ridiculously high number
    if ( use_max_cutoff ) max = max_cutoff ;
    for ( a = 0 ; a < ve.GetCount() ; a++ )
    {
	vector <TRestrictionCut> vc ;
	v->getCuts ( ve[a] , vc , false , max ) ;
	if ( ( !use_min_cutoff || min_cutoff <= vc.size() ) &&
	     ( !use_max_cutoff || max_cutoff >= vc.size() ) )
	{
	    v->re2.Add ( ve[a] ) ;
	    for ( b = 0 ; b < vc.size() ; b++ ) v->rc.push_back ( vc[b] ) ;
	}    
    }    
}