-
Notifications
You must be signed in to change notification settings - Fork 138
/
Copy pathngvisual.tcl
1840 lines (1387 loc) · 62.7 KB
/
ngvisual.tcl
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
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Ng_Vis_Set parameters
set viscnt 0
proc snapshottimer { } {
after 2000 { snapshottimer }
global viscnt
set viscnt [expr $viscnt+1]
set s1 0000$viscnt
# puts $s1
set cnt [string range $s1 [expr [string length $s1]-4] end]
set filename "p$cnt.jpg"
# puts "cnt = $cnt"
# puts "filename = $filename"
# .ndraw Ng_SnapShot pictures/$filename
}
snapshottimer
proc redrawtimer { } {
global visoptions.autoredraw
global visoptions.autoredrawtime
set delay [expr int(${visoptions.autoredrawtime}*1000)]
if { ${visoptions.autoredraw} == 1 } { redraw; }
after $delay { redrawtimer }
}
redrawtimer
set perstarttime [clock clicks -millisecond]
proc redrawperiodic { } {
global visoptions.redrawperiodic
global perstarttime
set curtime [clock clicks -millisecond]
# puts "redraw periodic, time = $curtime"
Ng_Vis_Set time [expr ($curtime - $perstarttime) / 5]
redraw
if { ${visoptions.redrawperiodic} == 1 } { after 30 { redrawperiodic } };
}
proc addplotline { identifier datax datay plotinfo {color black}} {
set c $identifier.c
set xstart [lindex $plotinfo 0]
set ystart [lindex $plotinfo 1]
set xmin [lindex $plotinfo 2]
set ymin [lindex $plotinfo 3]
set unitx [lindex $plotinfo 4]
set unity [lindex $plotinfo 5]
set latestx [expr ([lindex $datax 0]-$xmin)*$unitx + $xstart]
set latesty [expr ([lindex $datay 0]-$ymin)*$unity + $ystart]
for {set i 1} {$i < [llength $datax]} {incr i} {
set xpos [expr ([lindex $datax $i]-$xmin)*$unitx + $xstart]
set ypos [expr ([lindex $datay $i]-$ymin)*$unity + $ystart]
$c create line $latestx $latesty $xpos $ypos -width 1 -fill $color
set latestx $xpos
set latesty $ypos
}
}
proc createlineplot { width height identifier title xmin xmax ymin ymax plotinfo} {
set thiswidth $width
set thisheight $height
if { $thiswidth < 275 } { set thiswidth 275 }
if { $thisheight < 225 } { seth thisheight 225 }
set w $identifier
if {[winfo exists $w] == 1} {
wm withdraw $w
wm deiconify $w
focus $w
} {
toplevel $w
set c $w.c
canvas $c -relief raised -width $thiswidth -height $thisheight
pack $w.c -side top -fill x
set titleFont {Helvetica 18}
set smallFont {Helvetica 12}
set xstart 100
set xend [expr $thiswidth-75]
set ystart [expr $thisheight-75]
set yend 75
$c create line $xstart $ystart $xstart $yend -width 2
$c create line $xstart $ystart $xend $ystart -width 2
set unitx [expr double($xend-$xstart)/($xmax-$xmin)]
set unity [expr double($yend-$ystart)/($ymax-$ymin)]
for {set i 0} {$i <= 1} {set i [expr $i+0.2]} {
$c create line [expr $xstart+$i*($xend-$xstart)] [expr $ystart] [expr $xstart+$i*($xend-$xstart)] [expr $ystart+5] -width 2
$c create text [expr $xstart+$i*($xend-$xstart)] [expr $ystart+7] -anchor n -font $smallFont \
-text [format "%.3g" [expr $xmin+$i*($xmax-$xmin)]]
$c create line [expr $xstart] [expr $ystart+$i*($yend-$ystart)] [expr $xstart-7] [expr $ystart+$i*($yend-$ystart)] -width 2
$c create text [expr $xstart-9] [expr $ystart+$i*($yend-$ystart)] -anchor e -font $smallFont \
-text [format "%.3g" [expr $ymin+$i*($ymax-$ymin)]]
}
upvar $plotinfo ploti
set ploti "$xstart $ystart $xmin $ymin $unitx $unity"
button $w.close -text "Close" -command "destroy $w"
pack $w.close
wm withdraw $w
wm geom $w +100+100
wm deiconify $w
wm title $w $title
focus $w
}
}
proc getlineplotdata { datax datay xmini xmaxi ymini ymaxi} {
upvar $datax datx
upvar $datay daty
upvar $xmini xmin
upvar $xmaxi xmax
upvar $ymini ymin
upvar $ymaxi ymax
global visoptions.lineplotusingx
global visoptions.lineplotusingy
global visoptions.lineplotsource
global visoptions.lineplotfile
set datx ""
set daty ""
set xmin 1e20
set xmax -1e20
set ymin 1e20
set ymax -1e20
if {${visoptions.lineplotsource} == "file"} {
set fileId [open ${visoptions.lineplotfile} r]
set line ""
while {[gets $fileId line] >= 0} {
if { [string index [lindex $line 0] 0] != "\#" } {
if { ${visoptions.lineplotusingx} < [llength $line] } {
lappend datx [lindex $line ${visoptions.lineplotusingx}]
if { [lindex $datx end] < $xmin } {set xmin [lindex $datx end]}
if { [lindex $datx end] > $xmax } {set xmax [lindex $datx end]}
} {
lappend datx 0
}
if { ${visoptions.lineplotusingy} < [llength $line] } {
lappend daty [lindex $line ${visoptions.lineplotusingy}]
if { [lindex $daty end] < $ymin } {set ymin [lindex $daty end]}
if { [lindex $daty end] > $ymax } {set ymax [lindex $daty end]}
} {
lappend daty 0
}
}
}
close $fileId
}
}
proc lineplotdialog { } {
set w .lineplot_dlg
if {[winfo exists .lineplot_dlg] == 1} {
wm withdraw $w
wm deiconify $w
focus $w
} {
toplevel $w
ttk::frame $w.filesettings -relief groove -borderwidth 3
ttk::frame $w.filesettings.title
ttk::radiobutton $w.filesettings.title.choose -variable visoptions.lineplotsource \
-value file -text "Data from File"
pack $w.filesettings.title.choose -side left
pack $w.filesettings.title
global visoptions.lineplotselectedeval
global visoptions.lineplotfile
global visoptions.evaluatefilenames
global visoptions.evaluatefiledescriptions
set evdata [NGS_GetData evaluatefiles]
set visoptions.evaluatefilenames none
set visoptions.evaluatefiledescriptions none
for {set i 0} {[expr $i+1] < [llength $evdata]} {incr i 2} {
lappend visoptions.evaluatefilenames [lindex $evdata $i]
lappend visoptions.evaluatefiledescriptions [lindex $evdata [expr $i+1]]
}
# tixOptionMenu $w.filesettings.latestevals -label "Use Evaluate Results: " \
# -options {
# label.width 25
# label.anchor e
# menubutton.width 40
# }
# for {set i 0} {$i < [llength ${visoptions.evaluatefilenames}]} {incr i} {
# $w.filesettings.latestevals add command $i \
# -label "[lindex ${visoptions.evaluatefiledescriptions} $i] ([lindex ${visoptions.evaluatefilenames} $i])"
# }
# $w.filesettings.latestevals config -variable visoptions.lineplotselectedeval
# pack $w.filesettings.latestevals
ttk::frame $w.filesettings.latestevals
ttk::label $w.filesettings.latestevals.lab -text "Use Evaluate Results: "
ttk::menubutton $w.filesettings.latestevals.but -menu $w.filesettings.latestevals.menu -text "coarse" -width 40
menu $w.filesettings.latestevals.menu -tearoff 0
for {set i 0} {$i < [llength ${visoptions.evaluatefilenames}]} {incr i} {
$w.filesettings.latestevals.menu add command -label $i\
-command "set visoptions.lineplotselectedeval $i ; $w.filesettings.latestevals.but configure -text \"[lindex ${visoptions.evaluatefiledescriptions} $i] ([lindex ${visoptions.evaluatefilenames} $i])\""
}
$w.filesettings.latestevals.menu invoke ${visoptions.lineplotselectedeval}
grid $w.filesettings.latestevals.lab $w.filesettings.latestevals.but -sticky nw
pack $w.filesettings.latestevals
ttk::frame $w.filesettings.sfn
ttk::button $w.filesettings.sfn.bb -text "Browse" \
-command { set visoptions.lineplotfile [tk_getOpenFile] }
ttk::entry $w.filesettings.sfn.fn -width 50 \
-textvariable visoptions.lineplotfile
pack $w.filesettings.sfn.bb $w.filesettings.sfn.fn -side left
pack $w.filesettings.sfn
ttk::button $w.filesettings.refresh -text "Refresh" -command {
if { ${visoptions.lineplotselectedeval} != 0} {
set visoptions.lineplotfile [lindex ${visoptions.evaluatefilenames} ${visoptions.lineplotselectedeval}]
}
set saveusingx ${visoptions.lineplotusingx}
set saveusingy ${visoptions.lineplotusingy}
for { set i 0 } { $i < [llength ${visoptions.lineplotdatadescr}] } { incr i } {
${visoptions.lineplotxcoordselector} delete $i
}
for { set i 0 } { $i < [llength ${visoptions.lineplotdatadescr}] } { incr i } {
${visoptions.lineplotycoordselector} delete $i
}
set fileId [open ${visoptions.lineplotfile} r]
set line ""
gets $fileId line
close $fileId
if { [lindex $line 0] == "\#nglineplotinfo" } {
set visoptions.lineplotdatadescr [lrange $line 1 end]
} {
set visoptions.lineplotdatadescr ""
for { set i 0 } { $i < [llength $line] } { incr i } {
lappend visoptions.lineplotdatadescr "data[expr $i+1]"
}
}
for { set i 0 } { $i < [llength ${visoptions.lineplotdatadescr}] } { incr i } {
${visoptions.lineplotxcoordselector} add command $i -label [lindex ${visoptions.lineplotdatadescr} $i]
}
for { set i 0 } { $i < [llength ${visoptions.lineplotdatadescr}] } { incr i } {
${visoptions.lineplotycoordselector} add command $i -label [lindex ${visoptions.lineplotdatadescr} $i]
}
if { $saveusingx < [llength ${visoptions.lineplotdatadescr}] } {
set visoptions.lineplotusingx $saveusingx
} {
set visoptions.lineplotusingx 0
}
if { $saveusingy < [llength ${visoptions.lineplotdatadescr}] } {
set visoptions.lineplotusingy $saveusingy
} {
set visoptions.lineplotusingy 1
}
}
pack $w.filesettings.refresh
ttk::frame $w.filesettings.using
global visoptions.lineplotdatadescr
# tixOptionMenu $w.filesettings.using.xco -label "X-Coord:"\
# -options {
# label.width 8
# label.anchor e
# menubutton.width 15
# }
# for { set i 0 } { $i < [llength ${visoptions.lineplotdatadescr}] } { incr i } {
# $w.filesettings.using.xco add command $i -label [lindex ${visoptions.lineplotdatadescr} $i]
# }
ttk::frame $w.filesettings.using.xco
ttk::label $w.filesettings.using.xco.lab -text "X-Coord:"
ttk::menubutton $w.filesettings.using.xco.but -menu $w.filesettings.using.xco.menu -text "" -width 15
menu $w.filesettings.using.xco.menu -tearoff 0
for {set i 0} {$i < [llength ${visoptions.lineplotdatadescr}]} {incr i} {
$w.filesettings.using.xco.menu add command -label [lindex ${visoptions.lineplotdatadescr} $i]\
-command "set visoptions.lineplotusingx $i ; $w.filesettings.using.xco.but configure -text \"[lindex ${visoptions.lineplotdatadescr} $i]\""
}
$w.filesettings.using.xco.menu invoke [lindex ${visoptions.lineplotdatadescr} 0]
grid $w.filesettings.using.xco.lab $w.filesettings.using.xco.but -sticky nw
#pack $w.filesettings.using.xco
# $w.filesettings.using.xco config -variable visoptions.lineplotusingx
# tixOptionMenu $w.filesettings.using.yco -label "Y-Coord:"\
# -options {
# label.width 8
# label.anchor e
# menubutton.width 15
# }
# for { set i 0 } { $i < [llength ${visoptions.lineplotdatadescr}] } { incr i } {
# $w.filesettings.using.yco add command $i -label [lindex ${visoptions.lineplotdatadescr} $i]
# }
# $w.filesettings.using.yco config -variable visoptions.lineplotusingy
ttk::frame $w.filesettings.using.yco
ttk::label $w.filesettings.using.yco.lab -text "Y-Coord:"
ttk::menubutton $w.filesettings.using.yco.but -menu $w.filesettings.using.yco.menu -text "" -width 15
menu $w.filesettings.using.yco.menu -tearoff 0
for {set i 0} {$i < [llength ${visoptions.lineplotdatadescr}]} {incr i} {
$w.filesettings.using.yco.menu add command -label [lindex ${visoptions.lineplotdatadescr} $i]\
-command "set visoptions.lineplotusingy $i ; $w.filesettings.using.yco.but configure -text \"[lindex ${visoptions.lineplotdatadescr} $i]\""
}
$w.filesettings.using.yco.menu invoke [lindex ${visoptions.lineplotdatadescr} 0]
grid $w.filesettings.using.yco.lab $w.filesettings.using.yco.but -sticky nw
global visoptions.lineplotxcoordselector
global visoptions.lineplotycoordselector
set visoptions.lineplotxcoordselector $w.filesettings.using.xco
set visoptions.lineplotycoordselector $w.filesettings.using.yco
pack $w.filesettings.using.xco $w.filesettings.using.yco -side left
pack $w.filesettings.using
pack $w.filesettings -fill x -ipady 3
ttk::frame $w.settings -relief groove -borderwidth 3
ttk::label $w.settings.title -text "\nSettings\n"
pack $w.settings.title
ttk::frame $w.settings.minmax
ttk::checkbutton $w.settings.minmax.autoscale -text "Autoscale" -variable visoptions.lineplotautoscale
# tixControl $w.settings.minmax.xmin -label "Min. x: " \
# -integer false -variable visoptions.lineplotxmin \
# -options {
# entry.width 6
# label.width 8
# label.anchor e
# }
ttk::frame $w.settings.minmax.xmin
ttk::label $w.settings.minmax.xmin.label -text "Min. x: "
ttk::spinbox $w.settings.minmax.xmin.sp -textvariable visoptions.lineplotxmin -width 6 -increment 0.1 -validate focus -validatecommand "my_validatespinbox %W %P 3" \
-invalidcommand "my_invalidspinbox %W" -from -1e9 -to 1e9
# tixControl $w.settings.minmax.xmax -label "Max. x: " \
# -integer false -variable visoptions.lineplotxmax \
# -options {
# entry.width 6
# label.width 8
# label.anchor e
# }
ttk::frame $w.settings.minmax.xmax
ttk::label $w.settings.minmax.xmax.label -text "Max. x: "
ttk::spinbox $w.settings.minmax.xmax.sp -textvariable visoptions.lineplotxmax -width 6 -increment 0.1 -validate focus -validatecommand "my_validatespinbox %W %P 3" \
-invalidcommand "my_invalidspinbox %W" -from -1e9 -to 1e9
# tixControl $w.settings.minmax.ymin -label "Min. y: " \
# -integer false -variable visoptions.lineplotymin \
# -options {
# entry.width 6
# label.width 8
# label.anchor e
# }
ttk::frame $w.settings.minmax.ymin
ttk::label $w.settings.minmax.ymin.label -text "Min. y: "
ttk::spinbox $w.settings.minmax.ymin.sp -textvariable visoptions.lineplotymin -width 6 -increment 0.1 -validate focus -validatecommand "my_validatespinbox %W %P 3" \
-invalidcommand "my_invalidspinbox %W" -from -1e9 -to 1e9
# tixControl $w.settings.minmax.ymax -label "Max. y: " \
# -integer false -variable visoptions.lineplotymax \
# -options {
# entry.width 6
# label.width 8
# label.anchor e
# }
ttk::frame $w.settings.minmax.ymax
ttk::label $w.settings.minmax.ymax.label -text "Max. y: "
ttk::spinbox $w.settings.minmax.ymax.sp -textvariable visoptions.lineplotymax -width 6 -increment 0.1 -validate focus -validatecommand "my_validatespinbox %W %P 3" \
-invalidcommand "my_invalidspinbox %W" -from -1e9 -to 1e9
pack $w.settings.minmax.xmin.label $w.settings.minmax.xmin.sp
pack $w.settings.minmax.xmax.label $w.settings.minmax.xmax.sp
pack $w.settings.minmax.ymin.label $w.settings.minmax.ymin.sp
pack $w.settings.minmax.ymax.label $w.settings.minmax.ymax.sp
pack $w.settings.minmax.autoscale $w.settings.minmax.xmin $w.settings.minmax.xmax \
$w.settings.minmax.ymin $w.settings.minmax.ymax -side left
pack $w.settings.minmax
ttk::label $w.settings.empty1 -text ""
pack $w.settings.empty1
ttk::frame $w.settings.plotsize
# tixControl $w.settings.plotsize.xsize -label "Plotsize x: "\
# -integer true -variable visoptions.lineplotsizex \
# -options {
# entry.width 6
# label.width 13
# label.anchor e
# }
ttk::frame $w.settings.plotsize.xsize
ttk::label $w.settings.plotsize.xsize.label -text "Plotsize x: "
ttk::spinbox $w.settings.plotsize.xsize.sp -textvariable visoptions.lineplotsizex -width 6 -increment 1 -validate focus -validatecommand "my_validatespinbox %W %P 0" \
-invalidcommand "my_invalidspinbox %W" -from -1e9 -to 1e9
pack $w.settings.plotsize.xsize.label $w.settings.plotsize.xsize.sp
# tixControl $w.settings.plotsize.ysize -label "y: "\
# -integer true -variable visoptions.lineplotsizey \
# -options {
# entry.width 6
# label.width 3
# label.anchor e
# }
ttk::frame $w.settings.plotsize.ysize
ttk::label $w.settings.plotsize.ysize.label -text "Plotsize y: "
ttk::spinbox $w.settings.plotsize.ysize.sp -textvariable visoptions.lineplotsizey -width 6 -increment 1 -validate focus -validatecommand "my_validatespinbox %W %P 0" \
-invalidcommand "my_invalidspinbox %W" -from -1e9 -to 1e9
pack $w.settings.plotsize.ysize.label $w.settings.plotsize.ysize.sp
pack $w.settings.plotsize.xsize $w.settings.plotsize.ysize -side left
pack $w.settings.plotsize
ttk::label $w.settings.empty2 -text ""
pack $w.settings.empty2
# tixOptionMenu $w.settings.color -label "Linecolor: " \
# -options {
# label.width 19
# label.anchor e
# menubutton.width 15
# }
# foreach step { red black blue green yellow } {
# $w.settings.color add command $step -label $step
# }
# $w.settings.color config -variable visoptions.lineplotcolor
ttk::frame $w.settings.color
ttk::label $w.settings.color.lab -text "Linecolor: "
ttk::menubutton $w.settings.color.but -menu $w.settings.color.menu -text "" -width 15
menu $w.settings.color.menu -tearoff 0
foreach step { red black blue green yellow } {
$w.settings.color.menu add command -label $step -command "set visoptions.lineplotcolor $step; $w.settings.color.but configure -text \"$step\""
}
# for {set i 0} {$i < [llength ${visoptions.lineplotdatadescr}]} {incr i} {
# $w.filesettings.using.yco.menu add command -label [lindex ${visoptions.lineplotdatadescr} $i]\
# -command "set visoptions.lineplotusingy $i ; $w.filesettings.using.yco.but configure -text \"[lindex ${visoptions.lineplotdatadescr} $i]\""
# }
$w.settings.color.menu invoke "red"
grid $w.settings.color.lab $w.settings.color.but -sticky nw
pack $w.settings.color
pack $w.settings -fill x
set datax ""
set datay ""
set xmin 0
set xmax 0
set ymin 0
set ymax 0
ttk::frame $w.plots -relief groove -borderwidth 3
# tixOptionMenu $w.plots.selplot -label "Selected Plot: " \
# -options {
# label.width 19
# label.anchor e
# menubutton.width 15
# }
# $w.plots.selplot add command none -label "None"
# $w.plots.selplot config -variable visoptions.lineplotselected
ttk::frame $w.plots.selplot
ttk::label $w.plots.selplot.lab -text "Linecolor: "
ttk::menubutton $w.plots.selplot.but -menu $w.plots.selplot.menu -text "" -width 15
menu $w.plots.selplot.menu -tearoff 0
$w.plots.selplot.menu add command -label "None" -command "set visoptions.lineplotselected \"None\"; $w.plots.selplot.but configure -text \"None\""
grid $w.plots.selplot.lab $w.plots.selplot.but -sticky nw
$w.plots.selplot.menu invoke "None"
global visoptions.lineplotselector
set visoptions.lineplotselector $w.plots.selplot.menu
ttk::button $w.plots.new -text "Generate New Plot" -command {
if { ${visoptions.lineplotselectedeval} != 0} {
set visoptions.lineplotfile [lindex ${visoptions.evaluatefilenames} ${visoptions.lineplotselectedeval}]
}
getlineplotdata datax datay xmin xmax ymin ymax
puts stdout "xmin $xmin xmax $xmax ymin $ymin ymax $ymax"
global visoptions.lineplotautoscale
if {! ${visoptions.lineplotautoscale}} {
puts "using set min/max values"
set xmin ${visoptions.lineplotxmin}
set xmax ${visoptions.lineplotxmax}
set ymin ${visoptions.lineplotymin}
set ymax ${visoptions.lineplotymax}
}
incr visoptions.lineplotcurrentnum
set ident .newplot${visoptions.lineplotcurrentnum}
set plotinfo ""
createlineplot ${visoptions.lineplotsizex} ${visoptions.lineplotsizey} \
$ident "Lineplot ${visoptions.lineplotcurrentnum}" \
$xmin $xmax $ymin $ymax plotinfo
lappend visoptions.lineplotinfos $plotinfo
${visoptions.lineplotselector} add command ${visoptions.lineplotcurrentnum} -label "Lineplot ${visoptions.lineplotcurrentnum}"
addplotline $ident $datax $datay $plotinfo ${visoptions.lineplotcolor}
}
ttk::button $w.plots.addto -text "Add to Selected Plot" -command {
if { ${visoptions.lineplotselectedeval} != 0} {
set visoptions.lineplotfile [lindex ${visoptions.evaluatefilenames} ${visoptions.lineplotselectedeval}]
}
if { ${visoptions.lineplotselected} != "none" } {
getlineplotdata datax datay xmin xmax ymin ymax
set ident .newplot${visoptions.lineplotselected}
set plotinfo [lindex ${visoptions.lineplotinfos} ${visoptions.lineplotselected}]
addplotline $ident $datax $datay $plotinfo ${visoptions.lineplotcolor}
}
}
pack $w.plots.new $w.plots.addto $w.plots.selplot
pack $w.plots -fill x -ipady 3
ttk::button $w.close -text "Close" -command "destroy $w"
pack $w.close
wm withdraw $w
wm geom $w +200+100
wm deiconify $w
wm title $w "2D Lineplots"
focus $w
}
}
set fieldlinesdialog_pop1 0
proc fieldlinesdialog { } {
set w .fieldlines_dlg
global fieldlinesdialog_pop1
set fieldlinesdialog_pop1 1
if {[winfo exists .fieldlines_dlg] == 1} {
wm withdraw $w
wm deiconify $w
focus $w
} {
toplevel $w
#tixNoteBook $w.nb -ipadx 6 -ipady 6
pack [ttk::notebook $w.nb] -fill both -side top -ipadx 6 -ipady 6
$w.nb add [ttk::frame $w.nb.draw] -text "Draw" -underline 0
$w.nb add [ttk::frame $w.nb.settings] -text "Settings" -underline 0
#$w.nb add draw -label "Draw"
#$w.nb add settings -label "Settings"
#pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top
# Main Window
set f $w.nb.draw
ttk::labelframe $f.general -text "General settings" -relief groove -borderwidth 3
ttk::checkbutton $f.general.enable -text "Enable Fieldlines" \
-variable visoptions.drawfieldlines \
-command {
# set visoptions.redrawperiodic ${visoptions.drawfieldlines}
# redrawperiodic
# redrawperiodic # sonst
Ng_Vis_Set parameters;
redraw
}
ttk::label $f.general.numl -text "num:"
ttk::spinbox $f.general.num -from 0 -to 100 -increment 1 \
-textvariable visoptions.numfieldlines -width 4
#tixControl $f.general.num -label "Num: " -integer true \
-variable visoptions.numfieldlines \
-command { Ng_Vis_Set parameters; redraw } \
-options {
# entry.width 6
# label.width 12
# label.anchor e
# }
grid $f.general.enable -sticky nw -padx 4 -pady 2
grid x $f.general.numl $f.general.num -rowspan 3 -sticky w -padx 4 -row 0 -pady 2
grid anchor $f.general center
pack $f.general -pady 15 -fill x -ipady 3
ttk::label $f.labe0 -text " "
pack $f.labe0
#ttk::frame $f.general1
ttk::checkbutton $f.general.randomstart -text "Field dependent density " \
-variable visoptions.fieldlinesrandomstart \
-command { Ng_Vis_Set parameters; redraw}
ttk::checkbutton $f.general.redrawperiodic -text "Animate periodic" \
-variable visoptions.redrawperiodic \
-command {
redrawperiodic
Ng_Vis_Set parameters;
redraw
}
grid $f.general.randomstart -sticky nw -padx 4 -row 1
grid $f.general.redrawperiodic -sticky nw -padx 4 -row 2
#pack $f.general1
ttk::label $f.lab0 -text " "
pack $f.lab0
# tixOptionMenu $f.vecfun -label "Vector Function: " \
# -options {
# label.width 18
# label.anchor e
# menubutton.width 12
# }
# $f.vecfun add command none -label None
# for { set i 1 } { $i <= [Ng_Vis_Field getnfieldnames] } { incr i } {
# set fname [Ng_Vis_Field getfieldname $i]
# set fcomp [Ng_Vis_Field getfieldcomponents $i]
# set iscomplex [Ng_Vis_Field iscomplex $i]
# set sdim [Ng_Vis_Field getdimension]
# if { $iscomplex == 1 } { set fcomp [expr $fcomp / 2] }
# if { ($fcomp == $sdim) || ($fcomp == 3) } {
# $f.vecfun add command $fname -label $fname
# }
# }
# $f.vecfun configure -variable visoptions.fieldlinesvecfunction
# $f.vecfun configure -command { Ng_Vis_Set parameters; redraw }
ttk::frame $f.vecfun
ttk::label $f.vecfun.lab -text "Vector Function: "
ttk::menubutton $f.vecfun.but -menu $f.vecfun.menu -text "" -width 12
menu $f.vecfun.menu -tearoff 0
# for {set i 0} {$i < [llength ${visoptions.evaluatefilenames}]} {incr i} {
# $w.filesettings.latestevals.menu add command -label $i\
# -command "set visoptions.lineplotselectedeval $i ; $w.filesettings.latestevals.but configure -text \"[lindex ${visoptions.evaluatefiledescriptions} $i] ([lindex ${visoptions.evaluatefilenames} $i])\""
# }
for { set i 1 } { $i <= [Ng_Vis_Field getnfieldnames] } { incr i } {
set fname [Ng_Vis_Field getfieldname $i]
set fcomp [Ng_Vis_Field getfieldcomponents $i]
set iscomplex [Ng_Vis_Field iscomplex $i]
set sdim [Ng_Vis_Field getdimension]
if { $iscomplex == 1 } { set fcomp [expr $fcomp / 2] }
if { ($fcomp == $sdim) || ($fcomp == 3) } {
$f.vecfun.menu add command -label $fname -command "set visoptions.fieldlinesvecfunction $fname;Ng_Vis_Set parameters; redraw;$f.vecfun.but configure -text \"$fname\" " }
}
grid $f.vecfun.lab $f.vecfun.but -sticky nw
pack $f.vecfun
ttk::label $f.lab00 -text " "
pack $f.lab00
ttk::frame $f.phasesettings
ttk::checkbutton $f.phasesettings.onephase -text "Fix Phase" -variable visoptions.fieldlinesonlyonephase
# scale $f.phasesettings.phase -orient horizontal -length 300 -from 0 -to 360 \
# -label "phi" \
# -resolution 1 \
# -variable visoptions.fieldlinesphase \
# -command { popupcheckredraw3 fieldlinesdialog_pop1 }
ttk::frame $f.phasesettings.phase
ttk::label $f.phasesettings.phase.lab -text "phi"
ttk::scale $f.phasesettings.phase.sc -orient horizontal -length 100 -from 0 -to 360 -variable visoptions.fieldlinesphase \
-command "roundscale $f.phasesettings.phase.sc 0; popupcheckredraw3 fieldlinesdialog_pop1"
ttk::entry $f.phasesettings.phase.ent -width 4 -textvariable visoptions.fieldlinesphase -validate focus -takefocus 0 \
-validatecommand "popupcheckredraw3 fieldlinesdialog_pop1;my_validate %W 0 1 %P 0" \
-invalidcommand "my_invalid %W;popupcheckredraw3 fieldlinesdialog_pop1"
grid $f.phasesettings.phase.lab $f.phasesettings.phase.sc $f.phasesettings.phase.ent -sticky nw -ipadx 4
pack $f.phasesettings.onephase $f.phasesettings.phase -side left
pack $f.phasesettings
ttk::label $f.lab1 -text " "
pack $f.lab1
ttk::frame $f.boxsettings -relief groove -borderwidth 3
ttk::frame $f.boxsettings.title
ttk::radiobutton $f.boxsettings.title.choose -variable visoptions.fieldlinesstartarea \
-value box -text "Startpoints in Box"
pack $f.boxsettings.title.choose -side left
pack $f.boxsettings.title
ttk::frame $f.boxsettings.points
ttk::label $f.boxsettings.points.lab2 -text "Pmin";
ttk::entry $f.boxsettings.points.ent1x -width 8 \
-textvariable visoptions.fieldlinesstartareap1x
ttk::entry $f.boxsettings.points.ent1y -width 8 \
-textvariable visoptions.fieldlinesstartareap1y
ttk::entry $f.boxsettings.points.ent1z -width 8 \
-textvariable visoptions.fieldlinesstartareap1z
ttk::label $f.boxsettings.points.lab3 -text " Pmax";
ttk::entry $f.boxsettings.points.ent2x -width 8 \
-textvariable visoptions.fieldlinesstartareap2x
ttk::entry $f.boxsettings.points.ent2y -width 8 \
-textvariable visoptions.fieldlinesstartareap2y
ttk::entry $f.boxsettings.points.ent2z -width 8 \
-textvariable visoptions.fieldlinesstartareap2z
pack $f.boxsettings.points
pack $f.boxsettings.points.lab2 $f.boxsettings.points.ent1x $f.boxsettings.points.ent1y $f.boxsettings.points.ent1z -side left
pack $f.boxsettings.points.lab3 $f.boxsettings.points.ent2x $f.boxsettings.points.ent2y $f.boxsettings.points.ent2z -side left
ttk::button $f.boxsettings.settobb -text "Bounding Box" -command {
set bbox [Ng_MeshInfo bbox]
set visoptions.fieldlinesstartareap1x [lindex $bbox 0]
set visoptions.fieldlinesstartareap2x [lindex $bbox 1]
set visoptions.fieldlinesstartareap1y [lindex $bbox 2]
set visoptions.fieldlinesstartareap2y [lindex $bbox 3]
set visoptions.fieldlinesstartareap1z [lindex $bbox 4]
set visoptions.fieldlinesstartareap2z [lindex $bbox 5]
}
pack $f.boxsettings.settobb
pack $f.boxsettings -fill x -ipady 3
ttk::frame $f.facesettings -relief groove -borderwidth 3
ttk::frame $f.facesettings.title
ttk::radiobutton $f.facesettings.title.choose -variable visoptions.fieldlinesstartarea \
-value face -text "Startpoints on Face"
pack $f.facesettings.title.choose -side left
pack $f.facesettings.title
ttk::frame $f.facesettings.index
ttk::label $f.facesettings.index.lab -text "face index:"
ttk::label $f.facesettings.index.ent -text 1;# -padx 4
pack $f.facesettings.index.lab $f.facesettings.index.ent -side left
pack $f.facesettings.index
pack $f.facesettings -fill x -ipady 3
global visoptions.fieldlinesfilename
ttk::frame $f.filesettings -relief groove -borderwidth 3
ttk::frame $f.filesettings.title
ttk::radiobutton $f.filesettings.title.choose -variable visoptions.fieldlinesstartarea \
-value file -text "Startpoints from File"
pack $f.filesettings.title.choose -side left
pack $f.filesettings.title
ttk::frame $f.filesettings.sfn
ttk::button $f.filesettings.sfn.bb -text "Browse" \
-command {
set types {
{ "Netgen Fieldlines" {.nef} }
}
set visoptions.fieldlinesfilename [tk_getOpenFile -filetypes $types -defaultextension ".nef"]
}
ttk::entry $f.filesettings.sfn.fn -width 50 \
-textvariable visoptions.fieldlinesfilename
pack $f.filesettings.sfn.bb $f.filesettings.sfn.fn -side left
pack $f.filesettings.sfn
pack $f.filesettings -fill x -ipady 3
# Settings
set g $w.nb.settings
ttk::frame $g.linesettings -relief groove -borderwidth 3
ttk::label $g.linesettings.title -text "\nLine Settings\n"
# tixControl $g.linesettings.length -label "rel. Length: " -integer false \
# -variable visoptions.fieldlineslength -min 0.00001 -max 10000 -step 0.1 \
# -options {
# entry.width 6
# label.width 25
# label.anchor e
# }
ttk::frame $g.linesettings.length
ttk::label $g.linesettings.length.lab -text "rel. Length: "
ttk::spinbox $g.linesettings.length.sp -textvariable visoptions.fieldlineslength -width 6 -increment 0.1 -validate focus -validatecommand "my_validatespinbox %W %P 5" \
-invalidcommand "my_invalidspinbox %W" -from 0.00001 -to 10000
grid $g.linesettings.length.lab $g.linesettings.length.sp -sticky nw
# tixControl $g.linesettings.maxpoints -label "max. Points: " -integer true \
# -variable visoptions.fieldlinesmaxpoints -min 0 -max 10000 -step 1 \
# -options {
# entry.width 6
# label.width 25
# label.anchor e
# }
ttk::frame $g.linesettings.maxpoints
ttk::label $g.linesettings.maxpoints.lab -text "max. Points: "
ttk::spinbox $g.linesettings.maxpoints.sp -textvariable visoptions.fieldlinesmaxpoints -width 6 -increment 1 -validate focus -validatecommand "my_validatespinbox %W %P 0" \
-invalidcommand "my_invalidspinbox %W" -from 0 -to 10000
grid $g.linesettings.maxpoints.lab $g.linesettings.maxpoints.sp -sticky nw
# tixControl $g.linesettings.thick -label "rel. Thickness: " -integer false \
# -variable visoptions.fieldlinesthickness -min 1e-10 -max 0.5 -step 0.001 \
# -options {
# entry.width 6
# label.width 25
# label.anchor e
# }
ttk::frame $g.linesettings.thick
ttk::label $g.linesettings.thick.lab -text "rel. Thickness: "
ttk::spinbox $g.linesettings.thick.sp -textvariable visoptions.fieldlinesthickness -width 6 -increment 0.001 -validate focus -validatecommand "my_validatespinbox %W %P 6" \
-invalidcommand "my_invalidspinbox %W" -from 1e-10 -to 0.5
grid $g.linesettings.thick.lab $g.linesettings.thick.sp -stick nw
pack $g.linesettings.title $g.linesettings.length $g.linesettings.maxpoints $g.linesettings.thick
pack $g.linesettings -fill x -ipady 3
global visoptions.fieldlinestolerance
ttk::frame $g.odesettings -relief groove -borderwidth 3
ttk::label $g.odesettings.title -text "\nODE Settings\n"
# tixControl $g.odesettings.tol -label "rel. Tolerance: " -integer false \
# -variable visoptions.fieldlinestolerance -min 0.00001 -max 1 -step 0.01 \
# -options {
# entry.width 6
# label.width 25
# label.anchor e
# }
ttk::frame $g.odesettings.tol
ttk::label $g.odesettings.tol.lab -text "rel. Thickness: "
ttk::spinbox $g.odesettings.tol.sp -textvariable visoptions.fieldlinestolerance -width 6 -increment 0.01 -validate focus -validatecommand "my_validatespinbox %W %P 5" \
-invalidcommand "my_invalidspinbox %W" -from 0.00001 -to 1
grid $g.odesettings.tol.lab $g.odesettings.tol.sp -stick nw
# tixOptionMenu $g.odesettings.rktype -label "RK-Type " \
# -options {
# label.width 20
# label.anchor e
# menubutton.width 25
# }
# $g.odesettings.rktype add command euler -label "Euler, order 1"
# $g.odesettings.rktype add command eulercauchy -label "Euler-Cauchy, order 2"
# $g.odesettings.rktype add command simpson -label "Simpson, order 3"
# $g.odesettings.rktype add command crungekutta -label "classical Runge-Kutta, order 4"
# $g.odesettings.rktype configure -variable visoptions.fieldlinesrktype
# $g.odesettings.rktype configure -command { Ng_Vis_Set parameters; redraw }
ttk::frame $g.odesettings.rktype
ttk::label $g.odesettings.rktype.lab -text "RK-Type "
ttk::menubutton $g.odesettings.rktype.but -menu $g.odesettings.rktype.menu -text "" -width 25
menu $g.odesettings.rktype.menu -tearoff 0
$g.odesettings.rktype.menu add command -label "Euler, order 1" -command "set visoptions.fieldlinesrktype \"euler\" ;Ng_Vis_Set parameters; redraw;$g.odesettings.rktype.but configure -text \"Euler,order 1\" "
$g.odesettings.rktype.menu add command -label "Euler-Cauchy, order 2" -command "set visoptions.fieldlinesrktype \"eulercauchy\" ;Ng_Vis_Set parameters; redraw;$g.odesettings.rktype.but configure -text \"Euler-Cauchy,order 2\" "
$g.odesettings.rktype.menu add command -label "Simpson, order 3" -command "set visoptions.fieldlinesrktype \"simpson\" ;Ng_Vis_Set parameters; redraw;$g.odesettings.rktype.but configure -text \"Simpson,order 3\""
$g.odesettings.rktype.menu add command -label "classical Runge-Kutta, order 4" -command "set visoptions.fieldlinesrktype \"crungekutta\" ;Ng_Vis_Set parameters; redraw; $g.odesettings.rktype.but configure -text \"classical Runge-Kutta,order 4\""
$g.odesettings.rktype.menu invoke "classical Runge-Kutta, order 4"