-
Notifications
You must be signed in to change notification settings - Fork 135
/
Copy pathdialog.tcl
3207 lines (2522 loc) · 112 KB
/
dialog.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
proc meshingoptionsdialog { } {
set w .options_dlg
if {[winfo exists .options_dlg] == 1} {
wm withdraw $w
wm deiconify $w
focus $w
} {
toplevel $w
#wm resizable $w 0 0
# global options.meshsize
pack [ttk::notebook $w.nb] -fill both -side top
$w.nb add [ttk::frame $w.nb.general] -text "General" -underline 0
$w.nb add [ttk::frame $w.nb.meshsize] -text "Mesh Size" -underline 0
$w.nb add [ttk::frame $w.nb.chartopt] -text "STL Charts" -underline 0
$w.nb add [ttk::frame $w.nb.optimizer] -text "Optimizer" -underline 0
# $w.nb add [ttk::frame $w.nb.insider] -text "Insider" -underline 0
$w.nb add [ttk::frame $w.nb.debug] -text "Debug" -underline 0
# tixNoteBook $w.nbold -ipadx 6 -ipady 6
# $w.nbold add general -label "General" -underline 0
# $w.nbold add meshsize -label "Mesh Size" -underline 0
# $w.nbold add chartopt -label "STL Charts" -underline 0
# $w.nbold add optimizer -label "Optimizer" -underline 0
# $w.nbold add insider -label "Insider" -underline 0
# $w.nbold add debug -label "Debug" -underline 0
# pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top
# ############################################################
# General meshing options
# ############################################################
set f $w.nb.general
ttk::frame $f.background
pack $f.background -fill both
set f $f.background
ttk::labelframe $f.f2 -relief groove -borderwidth 3 -text "General meshing options"
pack $f.f2 -pady 15 -fill x
set f $f.f2
set finevals { 1 2 3 4 5 6 }
set finelabs(1) "very coarse"
set finelabs(2) "coarse"
set finelabs(3) "moderate"
set finelabs(4) "fine"
set finelabs(5) "very fine"
set finelabs(6) "user defined"
#tixOptionMenu $f.fine -label "Mesh granularity : " \
-options {
# label.width 19
# label.anchor e
# menubutton.width 15
# }
#foreach finev $finevals {
# $f.fine add command $finev -label $finelabs($finev)
#}
#$f.fine config -variable meshoptions.fineness
#$f.fine config -command { setgranularity }
#global meshoptions.fineness
#setgranularity ${meshoptions.fineness}
#pack $f.fine
global meshoptions.fineness
ttk::label $f.fine2l -text "Mesh granularity: "
ttk::menubutton $f.fine2c -menu $f.fine2m -text "coarse" -width 16
menu $f.fine2m -tearoff 0
foreach finev { 1 2 3 4 5 6 } {
$f.fine2m add command -label $finelabs($finev) \
-command "set meshoptions.fineness $finev ; setgranularity $finev; $f.fine2c configure -text \"$finelabs($finev)\""
}
$f.fine2m invoke $finelabs(${meshoptions.fineness})
grid $f.fine2l $f.fine2c -sticky nw
set mgsteps { ag me ms os mv ov }
set mgsteplabel(ag) "Analyze Geometry"
set mgsteplabel(me) "Mesh Edges"
set mgsteplabel(ms) "Mesh Surface"
set mgsteplabel(os) "Optimize Surface"
set mgsteplabel(mv) "Mesh Volume"
set mgsteplabel(ov) "Optimize Volume"
global meshoptions.firststep
ttk::label $f.first2l -text "First Step: "
# ttk::menubutton $f.first2.c -menu $f.first2.m -text "Analyze Geometry" -width 12
ttk::menubutton $f.first2c -menu $f.first2m -width 16
menu $f.first2m -tearoff 0
foreach i $mgsteps {
$f.first2m add command -label $mgsteplabel($i) -command "set meshoptions.firststep $i ; $f.first2c configure -text \"$mgsteplabel($i)\""
}
$f.first2m invoke $mgsteplabel(${meshoptions.firststep})
grid $f.first2l $f.first2c -sticky nw
global meshoptions.laststep
ttk::label $f.last2l -text "Last Step: "
ttk::menubutton $f.last2c -menu $f.last2m -width 16
menu $f.last2m -tearoff 0
foreach i $mgsteps {
$f.last2m add command -label $mgsteplabel($i) -command "set meshoptions.laststep $i ; $f.last2c configure -text \"$mgsteplabel($i)\""
}
$f.last2m invoke $mgsteplabel(${meshoptions.laststep})
grid $f.last2l $f.last2c -sticky nw
grid anchor $f center
# tixOptionMenu $f.first -label "First Step : " \
# -options {
# label.width 19
# label.anchor e
# menubutton.width 15
# }
# tixOptionMenu $f.last -label "Last Step : " \
# -options {
# label.width 19
# label.anchor e
# menubutton.width 15
# }
# foreach step $mgsteps {
# $f.first add command $step -label $mgsteplabel($step)
# $f.last add command $step -label $mgsteplabel($step)
# }
# $f.first config -variable meshoptions.firststep
# $f.last config -variable meshoptions.laststep
# pack $f.first $f.last
set msg(0) "None"
set msg(1) "Least"
set msg(2) "Little"
set msg(3) "Moderate"
set msg(4) "Much"
set msg(5) "Most"
#tixOptionMenu $f.msg -label "Print Messages : " \
-options {
# label.width 19
# label.anchor e
# menubutton.width 15
# }
#foreach step {0 1 2 3 4 5 } {
# $f.msg add command $step -label $msg($step)
#}
#$f.msg config -variable options.printmsg
# pack $f.msg
global options.printmsg
#ttk::frame $f.msg2
ttk::label $f.msg2l -text "Print Messages: "
menu $f.msg2m -tearoff 0
ttk::menubutton $f.msg2c -menu $f.msg2m -width 16
foreach step {0 1 2 3 4 5 } {
$f.msg2m add command -label $msg($step) -command "set options.printmsg $step ; $f.msg2c configure -text $msg($step)"
# if { ${options.printmsg} == $step } { $f.msg2.c configure -text $msg($step) }
}
$f.msg2m invoke ${options.printmsg}
grid $f.msg2l $f.msg2c -sticky nw
set f $w.nb.general
ttk::labelframe $f.bts -borderwidth 3 -relief groove -text "Additional meshing options"
pack $f.bts -fill x -pady 15
ttk::frame $f.bts.btnframe
ttk::checkbutton $f.bts.btnframe.parthread -text "Separate meshing thread" \
-variable options.parthread
ttk::checkbutton $f.bts.btnframe.second -text "Second order elements" \
-variable options.secondorder
ttk::checkbutton $f.bts.btnframe.quad -text "Quad dominated" \
-variable options.quad -command {
if { ${options.quad} } {
set meshoptions.laststep os
}
}
ttk::checkbutton $f.bts.btnframe.invtets -text "Invert volume elements" \
-variable options.inverttets
ttk::checkbutton $f.bts.btnframe.invtrigs -text "Invert surface elements" \
-variable options.inverttrigs
ttk::checkbutton $f.bts.btnframe.azref -text "Automatic Z-refinement" \
-variable options.autozrefine
pack $f.bts.btnframe -anchor center
pack $f.bts.btnframe.parthread $f.bts.btnframe.second $f.bts.btnframe.quad $f.bts.btnframe.invtets $f.bts.btnframe.invtrigs $f.bts.btnframe.azref -anchor w
# tixControl $f.elementorder -label "Element order: " -integer true \
# -variable options.elementorder -min 1 -max 20 \
# -options {
# entry.width 2
# label.width 20
# label.anchor e
# }
# pack $f.elementorder
#ttk::frame $f.bts.sbox
#pack $f.bts.sbox -anchor w -pady 10
ttk::frame $f.bts.btnframe.elorder
ttk::label $f.bts.btnframe.elorder.l -text "Element order"
ttk::spinbox $f.bts.btnframe.elorder.elementorder2 -from 1 -to 20 -textvariable options.elementorder -width 2
pack $f.bts.btnframe.elorder -fill x
pack $f.bts.btnframe.elorder.elementorder2 $f.bts.btnframe.elorder.l -anchor w -side left
ttk::frame $f.bts.btnframe.pm
ttk::checkbutton $f.bts.btnframe.pm.parallel_meshing -text "Parallel meshing" \
-variable options.parallel_meshing
pack $f.bts.btnframe.pm -fill x -pady 5
pack $f.bts.btnframe.pm.parallel_meshing -anchor w
ttk::label $f.bts.btnframe.pm.lnthreads -text "Number of meshing threads"
ttk::spinbox $f.bts.btnframe.pm.nthreads -from 1 -to 128 -textvariable options.nthreads -width 2
pack $f.bts.btnframe.pm.nthreads $f.bts.btnframe.pm.lnthreads -anchor w -side left
# ############################################################
# Mesh - Size options
# ############################################################
set f $w.nb.meshsize
ttk::frame $f.f2
pack $f.f2 -pady 10
# # ttk::style configure Tframe -background red
# puts "********************"
# puts "found these themes:"
# puts [ttk::themes]
# ttk::setTheme classic
# ttk::setTheme aqua
# puts "style Tframe foreground = "
# puts [ttk::style lookup Tframe -foreground]
# puts "f2 style:"
# puts [$f.f2 cget -style]
# puts [winfo class $f.f2]
# puts "style element names gives:"
# puts [ttk::style element names]
set f $f.f2
ttk::frame $f.meshsize
ttk::label $f.meshsize.l -text "max mesh-size"
ttk::spinbox $f.meshsize.s -from 1e-9 -to 1e9 -textvariable options.meshsize -width 5 -validate focus -validatecommand "my_validatespinbox %W %P 10" \
-invalidcommand "my_invalidspinbox %W"
pack $f.meshsize -fill x
pack $f.meshsize.s $f.meshsize.l -side right
ttk::frame $f.minmeshsize
ttk::label $f.minmeshsize.l -text "min mesh-size"
ttk::spinbox $f.minmeshsize.s -from 0 -to 1e9 -textvariable options.minmeshsize -width 5 -validate focus -validatecommand "my_validatespinbox %W %P 10" \
-invalidcommand "my_invalidspinbox %W"
pack $f.minmeshsize -fill x
pack $f.minmeshsize.s $f.minmeshsize.l -side right
ttk::frame $f.grading
ttk::label $f.grading.l -text "mesh-size grading"
ttk::spinbox $f.grading.s -from 0.1 -to 1.0 -textvariable options.grading -width 5 -increment 0.1 -validate focus -validatecommand "my_validatespinbox %W %P 3" \
-invalidcommand "my_invalidspinbox %W"
pack $f.grading -fill x
pack $f.grading.s $f.grading.l -side right
# tixControl $f.meshsize -label "max mesh-size: " -integer false \
# -variable options.meshsize -min 1e-9 -max 1e6 \
# -options {
# entry.width 6
# label.width 25
# label.anchor e
# }
# tixControl $f.minmeshsize -label "min mesh-size: " -integer false \
# -variable options.minmeshsize -min 0 -max 1e6 \
# -options {
# entry.width 6
# label.width 25
# label.anchor e
# }
# tixControl $f.grading -label "mesh-size grading: " -integer false \
# -variable options.grading -min 0.1 -max 1 -step 0.1 \
# -options {
# entry.width 6
# label.width 25
# label.anchor e
# }
# pack $f.meshsize $f.minmeshsize $f.grading
set f $w.nb.meshsize
ttk::labelframe $f.msf -text "mesh-size file:" -relief groove -borderwidth 3
pack $f.msf
# tixLabelEntry $f.msf.ent -label "mesh-size file: " \
# -labelside top \
# -options {
# entry.textVariable options.meshsizefilename
# entry.width 35
# label.width 25
# label.anchor w
# }
ttk::entry $f.msf.ent -textvariable options.meshsizefilename -width 30
ttk::button $f.msf.btn -text "Browse" -command {
global options.meshsizefilename
set types {
{"Meshsize file" {.msz} } }
set options.meshsizefilename [tk_getOpenFile -filetypes $types -initialfile ${options.meshsizefilename}]
}
pack $f.msf.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4
pack $f.msf.btn -side left -anchor s -padx 4 -pady 4
ttk::label $f.lab -text "Additional mesh size restrictions:"
#csg-meshsize options
ttk::labelframe $f.csg -relief groove -borderwidth 3 -text "CSG mesh-size"
pack $f.csg -fill x
proc test {a} {puts $a}
#ttk::frame $f.csg.curv
#pack $f.csg.curv -fill x -anchor center
ttk::scale $f.csg.curvsc -orient horizontal -length 150 -from 0.2 -to 5 \
-variable options.curvaturesafety -takefocus 0 -command "roundscale $f.csg.curvsc 1"
# -resolution 0.1
ttk::entry $f.csg.curve -textvariable options.curvaturesafety -width 3 \
-validatecommand "my_validate %W [$f.csg.curvsc cget -from] [$f.csg.curvsc cget -to] %P 1" \
-invalidcommand "my_invalid %W" -validate focus
ttk::label $f.csg.curvla -text "Elements per curvature radius"
grid $f.csg.curvsc $f.csg.curve $f.csg.curvla -sticky nw -padx 4
#ttk::frame $f.csg.elen
#pack $f.csg.elen -fill x -anchor center
ttk::scale $f.csg.elensc -orient horizontal -length 150 -from 0.2 -to 5 \
-variable options.segmentsperedge -takefocus 0 -command "roundscale $f.csg.elensc 1"
# -resolution 0.1
ttk::entry $f.csg.elene -textvariable options.segmentsperedge -width 3 \
-validatecommand "my_validate %W [$f.csg.elensc cget -from] [$f.csg.elensc cget -to] %P 1" \
-invalidcommand "my_invalid %W" -validate focus
ttk::label $f.csg.elenla -text "Elements per edge"
grid $f.csg.elensc $f.csg.elene $f.csg.elenla -sticky nw -padx 4
grid anchor $f.csg center
#stl-meshsize options
ttk::labelframe $f.stl -relief groove -borderwidth 3 -text "STL mesh-size"
pack $f.stl -fill x
#ttk::frame $f.stl.r2
#pack $f.stl.r2 -fill x
ttk::scale $f.stl.r2sc -orient horizontal -length 150 -from 0.2 -to 5 \
-variable stloptions.resthchartdistfac -takefocus 0 -command "roundscale $f.stl.r2sc 1"
ttk::entry $f.stl.r2e -textvariable stloptions.resthchartdistfac -width 3 \
-validatecommand "my_validate %W [$f.stl.r2sc cget -from] [$f.stl.r2sc cget -to] %P 1" \
-invalidcommand "my_invalid %W" -validate focus
ttk::checkbutton $f.stl.r2bu -text "STL - chart distance" \
-variable stloptions.resthchartdistenable
grid $f.stl.r2sc $f.stl.r2e $f.stl.r2bu -sticky nw -padx 4
#ttk::frame $f.stl.r6
#pack $f.stl.r6 -anchor w
ttk::scale $f.stl.r6sc -orient horizontal -length 150 -from 0.2 -to 5 \
-variable stloptions.resthlinelengthfac -takefocus 0 -command "roundscale $f.stl.r6sc 1"
ttk::entry $f.stl.r6e -textvariable stloptions.resthlinelengthfac -width 3 \
-validatecommand "my_validate %W [$f.stl.r6sc cget -from] [$f.stl.r6sc cget -to] %P 1" \
-invalidcommand "my_invalid %W" -validate focus
ttk::checkbutton $f.stl.r6bu -text "STL - line length" \
-variable stloptions.resthlinelengthenable
grid $f.stl.r6sc $f.stl.r6e $f.stl.r6bu -sticky nw -padx 4
#ttk::frame $f.stl.r3
#pack $f.stl.r3 -anchor w
ttk::scale $f.stl.r3sc -orient horizontal -length 150 -from 0.2 -to 8 \
-variable stloptions.resthcloseedgefac -takefocus 0 -command "roundscale $f.stl.r3sc 1"
ttk::entry $f.stl.r3e -textvariable stloptions.resthcloseedgefac -width 3 \
-validatecommand "my_validate %W [$f.stl.r3sc cget -from] [$f.stl.r3sc cget -to] %P 1" \
-invalidcommand "my_invalid %W" -validate focus
ttk::checkbutton $f.stl.r3bu -text "STL/IGES/STEP - close edges" \
-variable stloptions.resthcloseedgeenable
grid $f.stl.r3sc $f.stl.r3e $f.stl.r3bu -sticky nw -padx 4
#ttk::frame $f.stl.r1
#pack $f.stl.r1 -anchor w
ttk::scale $f.stl.r1sc -orient horizontal -length 150 -from 0.2 -to 5 \
-variable stloptions.resthsurfcurvfac -takefocus 0 -command "roundscale $f.stl.r1sc 1"
ttk::entry $f.stl.r1e -textvariable stloptions.resthsurfcurvfac -width 3 \
-validatecommand "my_validate %W [$f.stl.r1sc cget -from] [$f.stl.r1sc cget -to] %P 1" \
-invalidcommand "my_invalid %W" -validate focus
ttk::checkbutton $f.stl.r1bu -text "STL - surface curvature" \
-variable stloptions.resthsurfcurvenable
grid $f.stl.r1sc $f.stl.r1e $f.stl.r1bu -sticky nw -padx 4
#ttk::frame $f.stl.r3b
#pack $f.stl.r3b -anchor w
ttk::scale $f.stl.r3bsc -orient horizontal -length 150 -from 0.2 -to 5 \
-variable stloptions.resthedgeanglefac -takefocus 0 -command "roundscale $f.stl.r3bsc 1"
ttk::entry $f.stl.r3be -textvariable stloptions.resthedgeanglefac -width 3 \
-validatecommand "my_validate %W [$f.stl.r3bsc cget -from] [$f.stl.r3bsc cget -to] %P 1" \
-invalidcommand "my_invalid %W" -validate focus
ttk::checkbutton $f.stl.r3bbu -text "STL - edge angle" \
-variable stloptions.resthedgeangleenable
grid $f.stl.r3bsc $f.stl.r3be $f.stl.r3bbu -sticky nw -padx 4
#ttk::frame $f.stl.r5
#pack $f.stl.r5 -anchor w
ttk::scale $f.stl.r5sc -orient horizontal -length 150 -from 0.2 -to 5 \
-variable stloptions.resthsurfmeshcurvfac -takefocus 0 -command "roundscale $f.stl.r5sc 1"
ttk::entry $f.stl.r5e -textvariable stloptions.resthsurfmeshcurvfac -width 3 \
-validatecommand "my_validate %W [$f.stl.r5sc cget -from] [$f.stl.r5sc cget -to] %P 1" \
-invalidcommand "my_invalid %W" -validate focus
ttk::checkbutton $f.stl.r5bu -text "STL - surface mesh curv" \
-variable stloptions.resthsurfmeshcurvenable
grid $f.stl.r5sc $f.stl.r5e $f.stl.r5bu -sticky nw -padx 4
ttk::checkbutton $f.stl.recalch -text "STL - Recalc mesh size for surface optimization" \
-variable stloptions.recalchopt
grid $f.stl.recalch -sticky n -columnspan 3 -column 0
ttk::button $f.stl.calch -text "Calc New H" -command { redraw; Ng_STLCalcLocalH }
grid $f.stl.calch -columnspan 3 -column 0
grid anchor $f.stl center
# set f [$w.nb subwidget chartopt]
# round ttk::scale values to n_digits
proc roundscale {w n_digits args} {
set val [$w get]
global [$w cget -variable]
if {$n_digits == 0 } {
set [$w cget -variable] [tcl::mathfunc::round $val]
} else {
set [$w cget -variable] [format "%.[append n_digits "f"]" $val]
}
}
# validate ttk::entry which are linked to ttk::scales widgets
global last_accepted_sc
proc my_validate {w mini maxi val n_digits} {
global last_accepted_sc [$w cget -textvariable]
if {[string length $val] == 0} {return 0}
if {[string is double $val] == 1} {
if { $n_digits == 0 } {
set val [tcl::mathfunc::max $mini [tcl::mathfunc::min $maxi [tcl::mathfunc::round $val]]]
} else {
if { $n_digits < 9 } {
set val [tcl::mathfunc::max $mini [tcl::mathfunc::min $maxi [format "%.[append n_digits "f"]" $val]]]
}
}
set last_accepted_sc $val
set [$w cget -textvariable] $val
return 1
} else {
return 0
}
}
# if my_validate returns 0, this function gets called
proc my_invalid {w} {
global last_accepted_sc [$w cget -textvariable]
set [$w cget -textvariable] $last_accepted_sc
}
set f $w.nb.chartopt
ttk::labelframe $f.mainframe -text "STL angles" -relief groove -borderwidth 3
pack $f.mainframe -fill x -pady 15
set f $f.mainframe
#ttk::frame $f.f1
ttk::label $f.labYangles -text "Yellow Edges Angle ()"
ttk::scale $f.scale1 -orient horizontal -length 150 -from 0 -to 90 -variable stloptions.yangle -takefocus 0 -command "roundscale $f.scale1 1"
ttk::entry $f.entry1 -textvariable stloptions.yangle -width 5 -validate focus -takefocus 0 -validatecommand "my_validate %W [$f.scale1 cget -from] [$f.scale1 cget -to] %P 1" \
-invalidcommand "my_invalid %W"
#pack $f.f1 -anchor center
grid $f.scale1 $f.entry1 $f.labYangles -sticky nw -padx 4 -pady 6
#ttk::frame $f.f21
ttk::label $f.labEangles -text "Edge Corner Angle ()"
ttk::scale $f.scale2 -orient horizontal -length 150 -from 0 -to 180 -variable stloptions.edgecornerangle -takefocus 0 -command "roundscale $f.scale2 1"
ttk::entry $f.entry2 -textvariable stloptions.edgecornerangle -width 5 -validate focus -takefocus 0 -validatecommand "my_validate %W [$f.scale2 cget -from] [$f.scale2 cget -to] %P 1" \
-invalidcommand "my_invalid %W"
#pack $f.f21 -anchor center
grid $f.scale2 $f.entry2 $f.labEangles -sticky nw -padx 4 -pady 6
#ttk::frame $f.f31
ttk::label $f.lab31 -text "Chart Angle ()"
ttk::scale $f.scale3 -orient horizontal -length 150 -from 0 -to 180 -variable stloptions.chartangle -takefocus 0 -command "roundscale $f.scale3 1"
ttk::entry $f.entry3 -textvariable stloptions.chartangle -width 5 -validate focus -takefocus 0 -validatecommand "my_validate %W [$f.scale3 cget -from] [$f.scale3 cget -to] %P 1" \
-invalidcommand "my_invalid %W"
#pack $f.f31 -anchor center
grid $f.scale3 $f.entry3 $f.lab31 -sticky nw -padx 4 -pady 6
#ttk::frame $f.f41
ttk::label $f.lab41 -text "Outer Chart Angle ()"
ttk::scale $f.scale4 -orient horizontal -length 150 -from 0 -to 180 -variable stloptions.outerchartangle -takefocus 0 -command "roundscale $f.scale4 1"
ttk::entry $f.entry4 -textvariable stloptions.outerchartangle -width 5 -validate focus -takefocus 0 -validatecommand "my_validate %W [$f.scale4 cget -from] [$f.scale4 cget -to] %P 1" \
-invalidcommand "my_invalid %W"
#pack $f.f41 -anchor center
grid $f.scale4 $f.entry4 $f.lab41 -sticky nw -padx 4 -pady 6
grid anchor $f center
# Optimization options
global last_accepted_sp
# Used to validate the entries linked with a ttk::spinbox widget
proc my_validatespinbox {w val n_digits} {
global last_accepted_sp
if {[string length $val] == 0} {return 0}
if {[string is double $val] == 1} {
if { $n_digits == 0 } {
if { $n_digits < 9 } {
set val [tcl::mathfunc::round $val] } else { set val [format "%.[append n_digits "f"]" $val]
}
}
$w set [tcl::mathfunc::max [$w cget -from] [tcl::mathfunc::min [$w cget -to] $val]]
set last_accepted_sp $val
return 1
} else {
return 0
}
}
proc my_invalidspinbox {w} {
global last_accepted_sp
$w set $last_accepted_sp
}
# set f [$w.nb subwidget optimizer]
set f $w.nb.optimizer
ttk::labelframe $f.optframe -text "Optimization settings" -relief groove -borderwidth 3
pack $f.optframe -fill x -pady 15
#ttk::frame $f.optframe.sos
ttk::label $f.optframe.sosl -text "Surface opt steps"
ttk::spinbox $f.optframe.soss -from 0 -to 99 -textvariable options.optsteps2d -width 5 -increment 1 -validate focus -validatecommand "my_validatespinbox %W %P 0" \
-invalidcommand "my_invalidspinbox %W"
#pack $f.optframe.sos -anchor center
grid $f.optframe.sosl $f.optframe.soss -sticky nw;# -side right -fill x -pady 2
#ttk::frame $f.optframe.vos
ttk::label $f.optframe.vosl -text "Volume opt steps"
ttk::spinbox $f.optframe.voss -from 0 -to 99 -textvariable options.optsteps3d -width 5 -increment 1 -validate focus -validatecommand "my_validatespinbox %W %P 0" \
-invalidcommand "my_invalidspinbox %W"
#pack $f.optframe.vos -anchor center
grid $f.optframe.vosl $f.optframe.voss -sticky nw;# -side right -fill x -pady 2
#ttk::frame $f.optframe.esw
ttk::label $f.optframe.eswl -text "Element size weight"
ttk::spinbox $f.optframe.esws -from 0 -to 1 -textvariable options.elsizeweight -width 5 -increment 0.1 -validate focus -validatecommand "my_validatespinbox %W %P 1" \
-invalidcommand "my_invalidspinbox %W"
#pack $f.optframe.esw -anchor center
grid $f.optframe.eswl $f.optframe.esws -sticky nw;# -side right -fill x -pady 2
#ttk::frame $f.optframe.wem
ttk::label $f.optframe.weml -text "Worst element measure"
ttk::spinbox $f.optframe.wems -from 1 -to 10 -textvariable options.opterrpow -width 5 -increment 1 -validate focus -validatecommand "my_validatespinbox %W %P 0" \
-invalidcommand "my_invalidspinbox %W"
#pack $f.optframe.wem -anchor e
grid $f.optframe.weml $f.optframe.wems -sticky nw;# -side right -fill x -pady 2
grid anchor $f.optframe center
# These functions are needed due to a bug within the aqua theme
# if a ttk::scale widget has a from value larger than 100.
proc roundscale_helper_osx {w val} {
global [$w cget -variable] options.badellimit
set [$w cget -variable] [tcl::mathfunc::round $val]
set options.badellimit [expr [tcl::mathfunc::round $val]+160]
}
proc my_validate_helper_osx {w val} {
if {[string length $val] == 0} {return 0}
if {[string is double $val] == 1} {
set scale_loc [lindex [winfo children [winfo parent $w]] [lsearch [winfo children [winfo parent $w]] *scale]]
global [$scale_loc cget -variable] options.badellimit
set [$scale_loc cget -variable] [tcl::mathfunc::max [$scale_loc cget -from] [tcl::mathfunc::min [$scale_loc cget -to] [expr [tcl::mathfunc::round $val]-160]]]
set options.badellimit [tcl::mathfunc::max [expr [$scale_loc cget -from]+160] [tcl::mathfunc::min [expr [$scale_loc cget -to]+160] [tcl::mathfunc::round $val]]]
return 1
} else {
return 0
}
}
proc my_invalid_helper_osx {w} {
global options.badellimit
set scale_loc [lindex [winfo children [winfo parent $w]] [lsearch [winfo children [winfo parent $w]] *scale]]
global [$scale_loc cget -variable]
set [$scale_loc cget -variable] [tcl::mathfunc::round [$scale_loc get]]
set options.badellimit [expr [tcl::mathfunc::round [$scale_loc get]]+160]
}
global dummy_badellimit
set dummy_badellimit 15
ttk::labelframe $f.optframe2 -text "Bad elements" -relief groove -borderwidth 3
pack $f.optframe2 -fill x -pady 15 -ipady 5
ttk::frame $f.optframe2.badellimit
ttk::label $f.optframe2.lab -text "bad element criterion";
ttk::scale $f.optframe2.scale -orient horizontal -length 100 -from 00 -to 20 -variable dummy_badellimit -takefocus 0 -command "roundscale_helper_osx $f.optframe2.scale"
ttk::entry $f.optframe2.entry -textvariable options.badellimit -width 3 -validate focusout -takefocus 0 -validatecommand "my_validate_helper_osx %W %P" \
-invalidcommand "my_invalid_helper_osx %W"
#pack $f.optframe2.badellimit -anchor center
grid $f.optframe2.scale $f.optframe2.entry $f.optframe2.lab -padx 4 -sticky nw
grid anchor $f.optframe2 center
# insider options
# set f [$w.nb subwidget insider]
set f $w.nb.debug
ttk::labelframe $f.f2 -text "Advanced options" -borderwidth 3 -relief groove
pack $f.f2 -fill x -pady 15
#ttk::frame $f.f2.frame
#pack $f.f2.frame
set f $f.f2
ttk::checkbutton $f.localh -text "Use Local Meshsize" \
-variable options.localh
ttk::checkbutton $f.delauney -text "Use Delaunay" \
-variable options.delaunay
ttk::checkbutton $f.checkoverlap -text "Check Overlapping" \
-variable options.checkoverlap
ttk::checkbutton $f.checkcb -text "Check Chart Boundary" \
-variable options.checkchartboundary
ttk::checkbutton $f.blockfill -text "Do Blockfilling" \
-variable options.blockfill
grid $f.localh $f.delauney -sticky nw
grid $f.checkoverlap $f.blockfill -sticky nw
grid $f.checkcb -sticky nw
grid anchor $f center
# debugging options
set f $w.nb.debug
# enable / disable ttk::entry widgets linked to ttk::checkbuttons
proc enable_cb {w1 w2 w3} {
Ng_SetDebugParameters
if {[string match *selected* [$w1 state]] == 1 } {
$w2 configure -state normal
$w3 configure -state normal
} else {
$w2 configure -state disabled
$w3 configure -state disabled
}
}
ttk::labelframe $f.cb1 -text "Debugging options" -borderwidth 3 -relief groove
pack $f.cb1 -fill x -pady 15
#frame $f.cb1.cb0
#pack $f.cb1.cb0 -fill x
ttk::checkbutton $f.cb1.slowchecks -text "Slow checks" \
-variable debug.slowchecks -command { Ng_SetDebugParameters }
ttk::checkbutton $f.cb1.debugoutput -text "Debugging output" \
-variable debug.debugoutput -command { Ng_SetDebugParameters }
ttk::checkbutton $f.cb1.haltexline -text "Halt on existing line" \
-variable debug.haltexistingline -command { Ng_SetDebugParameters }
ttk::checkbutton $f.cb1.haltoverlap -text "Halt on Overlap" \
-variable debug.haltoverlap -command { Ng_SetDebugParameters }
ttk::checkbutton $f.cb1.haltsuc -text "Halt on success" \
-variable debug.haltsuccess -command { Ng_SetDebugParameters }
ttk::checkbutton $f.cb1.haltnosuc -text "Halt on no success" \
-variable debug.haltnosuccess -command { Ng_SetDebugParameters }
ttk::checkbutton $f.cb1.haltlargequal -text "Halt on large quality class" \
-variable debug.haltlargequalclass -command { Ng_SetDebugParameters }
ttk::checkbutton $f.cb1.haltseg -text "Halt on Segment:" \
-variable debug.haltsegment -command { Ng_SetDebugParameters }
ttk::checkbutton $f.cb1.haltnode -text "Halt on Node:" \
-variable debug.haltnode -command { Ng_SetDebugParameters }
ttk::frame $f.cb1.fr
ttk::checkbutton $f.cb1.fr.cb -text "Halt on Face:" \
-variable debug.haltface -command { Ng_SetDebugParameters }
ttk::entry $f.cb1.fr.ent -textvariable debug.haltfacenr -width 3
pack $f.cb1.fr.cb $f.cb1.fr.ent -side left
ttk::frame $f.cb1.segs
ttk::label $f.cb1.segs.lab1 -text "P1:"
ttk::entry $f.cb1.segs.ent1 -width 6 \
-textvariable debug.haltsegmentp1
ttk::label $f.cb1.segs.lab2 -text "P2:"
ttk::entry $f.cb1.segs.ent2 -width 6 \
-textvariable debug.haltsegmentp2
pack $f.cb1.segs.lab1 $f.cb1.segs.ent1 $f.cb1.segs.lab2 $f.cb1.segs.ent2 -side left
grid $f.cb1.slowchecks $f.cb1.debugoutput -sticky nw
grid $f.cb1.haltexline $f.cb1.haltoverlap -sticky nw
grid $f.cb1.haltsuc $f.cb1.haltnosuc -sticky nw
grid $f.cb1.haltlargequal $f.cb1.fr -sticky nw
grid $f.cb1.haltnode -sticky nw
grid $f.cb1.haltseg -stick nw
grid $f.cb1.segs -stick w -row 4 -rowspan 2 -column 1
grid rowconfigure $f.cb1 3 -pad 8
grid anchor $f.cb1 center
ttk::checkbutton $f.cb1.showactivechart -text "Show Active Meshing-Chart" -variable stloptions.showactivechart -command { Ng_SetVisParameters; redraw }
grid $f.cb1.showactivechart
grid rowconfigure $f.cb1 3 -pad 8
grid rowconfigure $f.cb1 5 -pad 8
set f $w.nb.debug
ttk::labelframe $f.cont -relief groove -borderwidth 3 -text "Debugging visualization"
pack $f.cont -fill x -pady 15
#ttk::frame $f.cont.f
#pack $f.cont.f
ttk::checkbutton $f.cont.multidrawing -text "Draw Meshing" -variable multithread_drawing
ttk::checkbutton $f.cont.multitestmode -text "Meshing Testmode" -variable multithread_testmode
ttk::button $f.cont.goon -text "Go On" -command { set multithread_pause 0 }
grid $f.cont.multidrawing -sticky nw
grid $f.cont.multitestmode -sticky nw
grid $f.cont.goon -row 0 -rowspan 2 -column 1 -sticky w
grid columnconfigure $f.cont 0 -pad 30
grid columnconfigure $f.cont 1 -pad 20
grid anchor $f.cont center
global userlevel
if { $userlevel < 3} {
$w.nb delete insider
$w.nb delete debug
}
# tixButtonBox $w.bbox -orientation horizontal
# $w.bbox add ok -text Apply -underline 0 -width 5 \
# -command {
# [.options_dlg.nb subwidget meshsize].meshsize invoke
# [.options_dlg.nb subwidget meshsize].grading invoke
# [.options_dlg.nb subwidget optimizer].os2d invoke
# [.options_dlg.nb subwidget optimizer].os3d invoke
# [.options_dlg.nb subwidget optimizer].elw invoke
# [.options_dlg.nb subwidget optimizer].wem invoke
# Ng_SetMeshingParameters
# }
# $w.bbox add close -text Done -underline 0 -width 5 \
# -command {
# [.options_dlg.nb subwidget meshsize].meshsize invoke
# [.options_dlg.nb subwidget meshsize].grading invoke
# [.options_dlg.nb subwidget optimizer].os2d invoke
# [.options_dlg.nb subwidget optimizer].os3d invoke
# [.options_dlg.nb subwidget optimizer].elw invoke
# [.options_dlg.nb subwidget optimizer].wem invoke
# Ng_SetMeshingParameters
# destroy .options_dlg
# }
# pack $w.bbox -side bottom -fill x
ttk::frame $w.bu
pack $w.bu -fill x -ipady 3
ttk::button $w.bu.apl -text "Apply" -command {
Ng_SetMeshingParameters
Ng_SetDebugParameters
}
ttk::button $w.bu.ok -text "Done" -command {
Ng_SetMeshingParameters
Ng_SetDebugParameters
wm withdraw .options_dlg
# destroy .options_dlg
}
pack $w.bu.apl $w.bu.ok -side left -expand yes
wm withdraw $w
wm geom $w +100+100
wm deiconify $w
wm title $w "Meshing Options"
focus .options_dlg
}
}
meshingoptionsdialog
wm withdraw .options_dlg
#
#
# Viewing dialog
#
#
proc viewingoptionsdialog { } {
global userlevel
set w .viewopts_dlg
if {[winfo exists .viewopts_dlg] == 1} {
wm withdraw $w
wm deiconify $w
focus $w
} {
toplevel $w
#wm resizable $w 0 0
pack [ttk::notebook $w.nb] -fill both -fill both -side top
$w.nb add [ttk::frame $w.nb.general] -text "General" -underline 0
$w.nb add [ttk::frame $w.nb.stl] -text "STL" -underline 0
$w.nb add [ttk::frame $w.nb.occ] -text "IGES/STEP" -underline 0
$w.nb add [ttk::frame $w.nb.mesh] -text "Mesh" -underline 0
$w.nb add [ttk::frame $w.nb.light] -text "Light" -underline 0
$w.nb add [ttk::frame $w.nb.edges] -text "Edges" -underline 0
$w.nb add [ttk::frame $w.nb.misc] -text "Misc." -underline 3
# tixNoteBook $w.nb -ipadx 6 -ipady 6
# $w.nb add general -label "General" -underline 0
# $w.nb add stl -label "STL" -underline 0
# $w.nb add occ -label "IGES/STEP" -underline 0
# $w.nb add mesh -label "Mesh" -underline 0
# $w.nb add light -label "Light" -underline 0
# $w.nb add edges -label "Edges" -underline 0
# $w.nb add misc -label "Misc." -underline 3
# pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top
# general
set f $w.nb.general
ttk::labelframe $f.gvop -text "General viewing options" -relief groove -borderwidth 3
pack $f.gvop -fill x -pady 15
set f $f.gvop
ttk::checkbutton $f.backcol -text "White Background" \
-variable viewoptions.whitebackground \
-command { Ng_SetVisParameters; redraw }
ttk::checkbutton $f.cross -text "Draw Coordinate Cross" \
-variable viewoptions.drawcoordinatecross \
-command { Ng_SetVisParameters; redraw }
ttk::checkbutton $f.color -text "Draw Color-bar" \
-variable viewoptions.drawcolorbar \
-command { Ng_SetVisParameters; redraw }
ttk::checkbutton $f.netgen -text "Draw Netgen-logo" \
-variable viewoptions.drawnetgenlogo \
-command { Ng_SetVisParameters; redraw }
grid $f.backcol -sticky nw
grid $f.cross -stick nw
grid $f.color -sticky nw
grid $f.netgen -sticky nw
# checkbutton $f.stereo -text "Stereo View" \
# -variable viewoptions.stereo \
# -command { Ng_SetVisParameters; redraw }
# pack $f.stereo
menu $f.stylemenu
ttk::menubutton $f.style -menu $f.stylemenu -width 10 -text [ttk::style theme use]
grid $f.style -sticky nw
grid anchor $f center
foreach theme [ttk::themes] {
$f.stylemenu add command -label $theme \
-command " $f.style configure -text $theme; puts $theme ; ttk::setTheme $theme"
}
# stl geometry
set f $w.nb.stl
ttk::labelframe $f.show -relief groove -borderwidth 3 -text "STL viewing options"
pack $f.show -fill x -pady 15
ttk::checkbutton $f.show.showtrias -text "Show STL-Triangles" \
-variable stloptions.showtrias -command { Ng_SetVisParameters; redraw }
#grid $f.show.showtrias -stick nw
ttk::checkbutton $f.show.showfilledtrias -text "Show Filled Triangles" \
-variable stloptions.showfilledtrias -command { Ng_SetVisParameters; redraw }
grid $f.show.showtrias $f.show.showfilledtrias -sticky nw
ttk::checkbutton $f.show.showactivechart -text "Show Active Meshing-Chart" \
-variable stloptions.showactivechart -command { Ng_SetVisParameters; redraw }
#grid $f.show.showactivechart -sticky nw
ttk::checkbutton $f.show.showedges -text "Show Edges" \
-variable stloptions.showedges -command { Ng_SetVisParameters; redraw }
grid $f.show.showactivechart $f.show.showedges -sticky nw
grid anchor $f.show center
#frame $f.special -relief groove -borderwidth 3
#pack $f.special
ttk::checkbutton $f.show.showmarktrias -text "Show Chart Triangles" \
-variable stloptions.showmarktrias \
-command {set stldoctor.showfaces 0; Ng_STLDoctor; Ng_SetVisParameters; redraw }
#pack $f.show.showmarktrias -side left
ttk::checkbutton $f.show.showfaces -text "Show Faces" \
-variable stldoctor.showfaces \
-command {set stloptions.showmarktrias 0; Ng_STLDoctor; Ng_SetVisParameters; redraw}
#pack $f.show.showfaces -side left
grid $f.show.showmarktrias $f.show.showfaces -sticky nw
ttk::labelframe $f.fn -relief groove -borderwidth 3 -text "Chart/Face number"
pack $f.fn -fill x
ttk::label $f.fn.lab3 -text "Chart/Face number"
ttk::scale $f.fn.scale3 -orient horizontal -length 150 -from 0 -to 200 \
-variable stloptions.chartnumber -command "Ng_SetVisParameters; redraw;roundscale $f.fn.scale3 0"
ttk::entry $f.fn.ent3 -textvariable stloptions.chartnumber -width 3 -validate focus -takefocus 0 \
-validatecommand "Ng_SetVisParameters; redraw;my_validate %W [$f.fn.scale3 cget -from] [$f.fn.scale3 cget -to] %P 0" \
-invalidcommand "my_invalid %W;Ng_SetVisParameters; redraw;"
grid $f.fn.scale3 $f.fn.ent3 $f.fn.lab3 -sticky nw -padx 4
#frame $f.fo -relief groove -borderwidth 3
#pack $f.fo
tk::label $f.fn.lab -text "Chart/Face Offset:";
ttk::entry $f.fn.ent -width 3 \
-textvariable stloptions.chartnumberoffset -validate focus -takefocus 0 \
-validatecommand "my_validate %W 0 1e9 %P 0" \
-invalidcommand "my_invalid %W"
ttk::button $f.fn.btn_write_chart -text "Write selected chart to chart.stlb" -command {
Ng_STLDoctor writechart
}
grid $f.fn.lab -sticky ne -padx 4
grid $f.fn.ent -sticky nw -padx 4 -row 1 -column 1
grid $f.fn.btn_write_chart -padx 4 -row 2 -column 1
grid anchor $f.fn center
ttk::labelframe $f.advstl -text "Advanced STL options" -relief groove -borderwidth 3
pack $f.advstl -fill x -pady 15
#frame $f.mt
#pack $f.mt -fill x
ttk::checkbutton $f.advstl.bu1 -text "Show Marked (Dirty) Triangles" \
-variable stldoctor.showmarkedtrigs \
-command {Ng_STLDoctor; redraw}
#pack $f.mt.bu
#frame $f.ep
#pack $f.ep -fill x
ttk::checkbutton $f.advstl.bu2 -text "show edge corner points" \
-variable stldoctor.showedgecornerpoints \
-command {Ng_STLDoctor; redraw}
#pack $f.ep.bu
#frame $f.stt
#pack $f.stt -fill x
ttk::checkbutton $f.advstl.bu3 -text "show touched triangle chart" \
-variable stldoctor.showtouchedtrigchart \
-command {set stldoctor.showfaces 0; set stloptions.showmarktrias 1; \
Ng_STLDoctor; Ng_SetVisParameters; redraw}
#pack $f.stt.bu
#frame $f.sml
#pack $f.sml -fill x
ttk::checkbutton $f.advstl.bu4 -text "draw meshed edges" \
-variable stldoctor.drawmeshededges \
-command {Ng_STLDoctor;}
#pack $f.sml.bu