1proc meshingoptionsdialog { } {
2
3    set w .options_dlg
4
5    if {[winfo exists .options_dlg] == 1} {
6	wm withdraw $w
7	wm deiconify $w
8	focus $w
9
10    } {
11
12	toplevel $w
13        #wm resizable $w 0 0
14
15#	global options.meshsize
16
17        pack [ttk::notebook $w.nb]  -fill both -side top
18        $w.nb add [ttk::frame $w.nb.general] -text "General" -underline 0
19        $w.nb add [ttk::frame $w.nb.meshsize] -text "Mesh Size" -underline 0
20        $w.nb add [ttk::frame $w.nb.chartopt] -text "STL Charts" -underline 0
21        $w.nb add [ttk::frame $w.nb.optimizer] -text "Optimizer" -underline 0
22        # $w.nb add [ttk::frame $w.nb.insider] -text "Insider" -underline 0
23        $w.nb add [ttk::frame $w.nb.debug] -text "Debug" -underline 0
24
25	# tixNoteBook $w.nbold -ipadx 6 -ipady 6
26	# $w.nbold add general -label "General" -underline 0
27	# $w.nbold add meshsize -label "Mesh Size"   -underline 0
28	# $w.nbold add chartopt -label "STL Charts" -underline 0
29	# $w.nbold add optimizer -label "Optimizer"   -underline 0
30	# $w.nbold add insider -label "Insider"   -underline 0
31	# $w.nbold add debug -label "Debug"   -underline 0
32	# pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top
33
34
35        # ############################################################
36	# General meshing options
37        # ############################################################
38
39        set f $w.nb.general
40        ttk::frame $f.background
41        pack $f.background -fill both
42        set f $f.background
43        ttk::labelframe $f.f2 -relief groove -borderwidth 3 -text "General meshing options"
44        pack $f.f2  -pady 15 -fill x
45        set f $f.f2
46
47	set finevals { 1 2 3 4 5 6 }
48	set finelabs(1) "very coarse"
49	set finelabs(2) "coarse"
50	set finelabs(3) "moderate"
51	set finelabs(4) "fine"
52	set finelabs(5) "very fine"
53	set finelabs(6) "user defined"
54
55	#tixOptionMenu $f.fine -label "Mesh granularity : " \
56	    -options {
57	#	label.width  19
58	#	label.anchor e
59	#	menubutton.width 15
60	#    }
61
62	#foreach finev $finevals {
63	#    $f.fine add command $finev -label $finelabs($finev)
64	#}
65	#$f.fine config -variable meshoptions.fineness
66	#$f.fine config -command { setgranularity }
67	#global meshoptions.fineness
68        #setgranularity ${meshoptions.fineness}
69        #pack $f.fine
70
71        global meshoptions.fineness
72        ttk::label  $f.fine2l -text "Mesh granularity: "
73        ttk::menubutton $f.fine2c -menu $f.fine2m -text "coarse" -width 16
74
75        menu $f.fine2m  -tearoff 0
76	foreach finev { 1 2 3 4 5 6 } {
77	    $f.fine2m add command -label $finelabs($finev) \
78                -command "set meshoptions.fineness $finev ; setgranularity $finev; $f.fine2c configure -text \"$finelabs($finev)\""
79	}
80        $f.fine2m invoke $finelabs(${meshoptions.fineness})
81
82
83        grid $f.fine2l $f.fine2c -sticky nw
84
85
86	set mgsteps { ag me ms os mv ov }
87	set mgsteplabel(ag) "Analyze Geometry"
88	set mgsteplabel(me) "Mesh Edges"
89	set mgsteplabel(ms) "Mesh Surface"
90	set mgsteplabel(os) "Optimize Surface"
91	set mgsteplabel(mv) "Mesh Volume"
92	set mgsteplabel(ov) "Optimize Volume"
93
94        global meshoptions.firststep
95        ttk::label  $f.first2l -text "First Step: "
96        # ttk::menubutton $f.first2.c -menu $f.first2.m -text "Analyze Geometry" -width 12
97        ttk::menubutton $f.first2c -menu $f.first2m  -width 16
98
99        menu $f.first2m  -tearoff 0
100	foreach i $mgsteps {
101	    $f.first2m add command -label $mgsteplabel($i) -command "set meshoptions.firststep $i ; $f.first2c configure -text \"$mgsteplabel($i)\""
102	}
103        $f.first2m invoke $mgsteplabel(${meshoptions.firststep})
104        grid $f.first2l $f.first2c -sticky nw
105
106        global meshoptions.laststep
107        ttk::label  $f.last2l -text "Last Step: "
108        ttk::menubutton $f.last2c -menu $f.last2m -width 16
109
110        menu $f.last2m  -tearoff 0
111
112	foreach i $mgsteps {
113	    $f.last2m add command -label $mgsteplabel($i) -command "set meshoptions.laststep $i ; $f.last2c configure -text \"$mgsteplabel($i)\""
114	}
115        $f.last2m invoke $mgsteplabel(${meshoptions.laststep})
116        grid $f.last2l $f.last2c -sticky nw
117        grid anchor $f center
118
119
120	# tixOptionMenu $f.first -label "First Step : " \
121	#     -options {
122	# 	label.width  19
123	# 	label.anchor e
124	# 	menubutton.width 15
125	#     }
126
127	# tixOptionMenu $f.last -label "Last Step : " \
128	#     -options {
129	# 	label.width  19
130	# 	label.anchor e
131	# 	menubutton.width 15
132	#     }
133
134	# foreach step $mgsteps {
135	#     $f.first add command $step -label $mgsteplabel($step)
136	#     $f.last add command $step -label $mgsteplabel($step)
137	# }
138
139	# $f.first config -variable meshoptions.firststep
140	# $f.last config  -variable meshoptions.laststep
141
142	# pack $f.first $f.last
143
144
145
146
147
148	set msg(0) "None"
149	set msg(1) "Least"
150	set msg(2) "Little"
151	set msg(3) "Moderate"
152	set msg(4) "Much"
153	set msg(5) "Most"
154
155	#tixOptionMenu $f.msg -label "Print Messages : " \
156	    -options {
157	#	label.width  19
158	#	label.anchor e
159	#	menubutton.width 15
160	#    }
161
162        #foreach step {0 1 2 3 4 5 } {
163        #    $f.msg add command $step -label $msg($step)
164	#}
165	#$f.msg config -variable options.printmsg
166	# pack $f.msg
167
168
169        global options.printmsg
170        #ttk::frame $f.msg2
171        ttk::label  $f.msg2l -text "Print Messages: "
172        menu $f.msg2m  -tearoff 0
173        ttk::menubutton $f.msg2c -menu $f.msg2m  -width 16
174	foreach step {0 1 2 3 4 5 } {
175	    $f.msg2m add command -label $msg($step) -command "set options.printmsg $step ; $f.msg2c configure -text $msg($step)"
176            #            if { ${options.printmsg} == $step } { $f.msg2.c configure -text $msg($step) }
177	}
178        $f.msg2m invoke ${options.printmsg}
179        grid $f.msg2l $f.msg2c -sticky nw
180
181        set f $w.nb.general
182
183        ttk::labelframe $f.bts -borderwidth 3 -relief groove -text "Additional meshing options"
184        pack $f.bts -fill x -pady 15
185	ttk::frame $f.bts.btnframe
186	ttk::checkbutton $f.bts.btnframe.parthread -text "Separate meshing thread" \
187	    -variable options.parthread
188	ttk::checkbutton $f.bts.btnframe.second -text "Second order elements" \
189	    -variable options.secondorder
190	ttk::checkbutton $f.bts.btnframe.quad -text "Quad dominated" \
191	    -variable options.quad -command {
192		if { ${options.quad} } {
193		    set meshoptions.laststep os
194		}
195	    }
196	ttk::checkbutton $f.bts.btnframe.invtets -text "Invert volume elements" \
197	    -variable options.inverttets
198	ttk::checkbutton $f.bts.btnframe.invtrigs -text "Invert surface elements" \
199	    -variable options.inverttrigs
200	ttk::checkbutton $f.bts.btnframe.azref -text "Automatic Z-refinement" \
201	    -variable options.autozrefine
202	pack $f.bts.btnframe -anchor center
203	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
204
205
206	# tixControl $f.elementorder -label "Element order: " -integer true \
207	#     -variable options.elementorder -min 1 -max 20 \
208	#     -options {
209	# 	entry.width 2
210	# 	label.width 20
211	# 	label.anchor e
212	#     }
213        # pack $f.elementorder
214
215        #ttk::frame $f.bts.sbox
216        #pack $f.bts.sbox -anchor w -pady 10
217        ttk::frame $f.bts.btnframe.elorder
218        ttk::label $f.bts.btnframe.elorder.l -text "Element order"
219        ttk::spinbox $f.bts.btnframe.elorder.elementorder2 -from 1 -to 20 -textvariable options.elementorder -width 2
220        pack $f.bts.btnframe.elorder -fill x
221        pack $f.bts.btnframe.elorder.elementorder2 $f.bts.btnframe.elorder.l  -anchor w -side left
222
223        ttk::frame $f.bts.btnframe.pm
224        ttk::checkbutton $f.bts.btnframe.pm.parallel_meshing -text "Parallel meshing" \
225            -variable options.parallel_meshing
226        pack $f.bts.btnframe.pm -fill x -pady 5
227        pack $f.bts.btnframe.pm.parallel_meshing  -anchor w
228
229        ttk::label $f.bts.btnframe.pm.lnthreads -text "Number of meshing threads"
230        ttk::spinbox $f.bts.btnframe.pm.nthreads -from 1 -to 128 -textvariable options.nthreads -width 2
231        pack $f.bts.btnframe.pm.nthreads $f.bts.btnframe.pm.lnthreads  -anchor w -side left
232
233
234
235        # ############################################################
236        # Mesh - Size options
237        # ############################################################
238
239        set f $w.nb.meshsize
240
241        ttk::frame $f.f2
242        pack $f.f2 -pady 10
243
244        # # ttk::style configure Tframe -background red
245        # puts "********************"
246        # puts "found these themes:"
247        # puts [ttk::themes]
248        # ttk::setTheme classic
249        # ttk::setTheme aqua
250        # puts "style Tframe foreground = "
251        # puts [ttk::style lookup Tframe -foreground]
252        # puts "f2 style:"
253        # puts [$f.f2 cget -style]
254        # puts [winfo class $f.f2]
255        # puts "style element names gives:"
256        # puts [ttk::style element names]
257
258
259        set f $f.f2
260
261        ttk::frame $f.meshsize
262        ttk::label $f.meshsize.l -text "max mesh-size"
263        ttk::spinbox $f.meshsize.s -from 1e-9 -to 1e9 -textvariable options.meshsize -width 5 -validate focus -validatecommand "my_validatespinbox %W %P 10" \
264	    -invalidcommand "my_invalidspinbox %W"
265        pack $f.meshsize -fill x
266        pack $f.meshsize.s $f.meshsize.l -side right
267
268        ttk::frame $f.minmeshsize
269        ttk::label $f.minmeshsize.l -text "min mesh-size"
270        ttk::spinbox $f.minmeshsize.s -from 0 -to 1e9 -textvariable options.minmeshsize -width 5 -validate focus -validatecommand "my_validatespinbox %W %P 10" \
271	    -invalidcommand "my_invalidspinbox %W"
272        pack $f.minmeshsize -fill x
273        pack $f.minmeshsize.s $f.minmeshsize.l -side right
274
275        ttk::frame $f.grading
276        ttk::label $f.grading.l -text "mesh-size grading"
277        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" \
278            -invalidcommand "my_invalidspinbox %W"
279        pack $f.grading -fill x
280        pack $f.grading.s $f.grading.l -side right
281
282
283	# tixControl $f.meshsize -label "max mesh-size: " -integer false \
284	#     -variable options.meshsize -min 1e-9 -max 1e6 \
285	#     -options {
286	# 	entry.width 6
287	# 	label.width 25
288	# 	label.anchor e
289	#     }
290
291	# tixControl $f.minmeshsize -label "min mesh-size: " -integer false \
292	#     -variable options.minmeshsize -min 0 -max 1e6 \
293	#     -options {
294	# 	entry.width 6
295	# 	label.width 25
296	# 	label.anchor e
297	#     }
298
299	# tixControl $f.grading -label "mesh-size grading: " -integer false \
300	#     -variable options.grading -min 0.1 -max 1 -step 0.1 \
301	#     -options {
302	# 	entry.width 6
303	# 	label.width 25
304	# 	label.anchor e
305	#     }
306
307	# pack $f.meshsize $f.minmeshsize $f.grading
308
309        set f $w.nb.meshsize
310
311	ttk::labelframe $f.msf -text "mesh-size file:" -relief groove -borderwidth 3
312	pack $f.msf
313
314 	# tixLabelEntry $f.msf.ent -label "mesh-size file: "  \
315 	#     -labelside top \
316 	#     -options {
317 	# 	entry.textVariable options.meshsizefilename
318 	# 	entry.width 35
319 	# 	label.width 25
320 	# 	label.anchor w
321 	#     }
322
323        ttk::entry $f.msf.ent -textvariable options.meshsizefilename -width 30
324 	ttk::button $f.msf.btn -text "Browse" -command {
325	    global options.meshsizefilename
326	    set types {
327		{"Meshsize file"   {.msz}	} }
328	    set options.meshsizefilename [tk_getOpenFile -filetypes $types -initialfile ${options.meshsizefilename}]
329	}
330
331 	pack $f.msf.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4
332 	pack $f.msf.btn -side left -anchor s -padx 4 -pady 4
333
334
335	ttk::label $f.lab -text "Additional mesh size restrictions:"
336
337	#csg-meshsize options
338
339	ttk::labelframe $f.csg -relief groove -borderwidth 3 -text "CSG mesh-size"
340	pack $f.csg -fill x
341        proc test {a} {puts $a}
342	#ttk::frame $f.csg.curv
343	#pack $f.csg.curv -fill x -anchor center
344        ttk::scale $f.csg.curvsc -orient horizontal -length 150 -from 0.2 -to 5 \
345            -variable options.curvaturesafety -takefocus 0 -command "roundscale $f.csg.curvsc 1"
346        #  -resolution 0.1
347        ttk::entry $f.csg.curve -textvariable options.curvaturesafety -width 3 \
348            -validatecommand "my_validate %W [$f.csg.curvsc cget -from] [$f.csg.curvsc cget -to] %P 1" \
349            -invalidcommand "my_invalid %W" -validate focus
350        ttk::label $f.csg.curvla -text "Elements per curvature radius"
351	grid $f.csg.curvsc $f.csg.curve $f.csg.curvla -sticky nw -padx 4
352
353	#ttk::frame $f.csg.elen
354	#pack $f.csg.elen  -fill x -anchor center
355	ttk::scale $f.csg.elensc -orient horizontal -length 150 -from 0.2 -to 5 \
356            -variable options.segmentsperedge -takefocus 0 -command "roundscale $f.csg.elensc 1"
357        # -resolution 0.1
358        ttk::entry $f.csg.elene -textvariable options.segmentsperedge -width 3 \
359            -validatecommand "my_validate %W [$f.csg.elensc cget -from] [$f.csg.elensc cget -to] %P 1" \
360            -invalidcommand "my_invalid %W" -validate focus
361	ttk::label $f.csg.elenla -text "Elements per edge"
362	grid $f.csg.elensc $f.csg.elene $f.csg.elenla -sticky nw -padx 4
363        grid anchor $f.csg center
364
365
366	#stl-meshsize options
367	ttk::labelframe $f.stl -relief groove -borderwidth 3 -text "STL mesh-size"
368	pack $f.stl -fill x
369
370	#ttk::frame $f.stl.r2
371	#pack $f.stl.r2 -fill x
372	ttk::scale $f.stl.r2sc -orient horizontal -length 150 -from 0.2 -to 5 \
373            -variable stloptions.resthchartdistfac -takefocus 0 -command "roundscale $f.stl.r2sc 1"
374        ttk::entry $f.stl.r2e -textvariable stloptions.resthchartdistfac -width 3 \
375            -validatecommand "my_validate %W [$f.stl.r2sc cget -from] [$f.stl.r2sc cget -to] %P 1" \
376            -invalidcommand "my_invalid %W" -validate focus
377	ttk::checkbutton $f.stl.r2bu -text "STL - chart distance" \
378	    -variable stloptions.resthchartdistenable
379	grid $f.stl.r2sc $f.stl.r2e $f.stl.r2bu -sticky nw -padx 4
380
381	#ttk::frame $f.stl.r6
382	#pack $f.stl.r6 -anchor w
383	ttk::scale $f.stl.r6sc -orient horizontal -length 150 -from 0.2 -to 5 \
384            -variable stloptions.resthlinelengthfac -takefocus 0 -command "roundscale $f.stl.r6sc 1"
385        ttk::entry $f.stl.r6e -textvariable stloptions.resthlinelengthfac -width 3 \
386            -validatecommand "my_validate %W [$f.stl.r6sc cget -from] [$f.stl.r6sc cget -to] %P 1" \
387            -invalidcommand "my_invalid %W" -validate focus
388	ttk::checkbutton $f.stl.r6bu -text "STL - line length" \
389	    -variable stloptions.resthlinelengthenable
390	grid $f.stl.r6sc $f.stl.r6e $f.stl.r6bu -sticky nw -padx 4
391
392	#ttk::frame $f.stl.r3
393	#pack $f.stl.r3 -anchor w
394	ttk::scale $f.stl.r3sc -orient horizontal -length 150 -from 0.2 -to 8 \
395            -variable stloptions.resthcloseedgefac -takefocus 0 -command "roundscale $f.stl.r3sc 1"
396        ttk::entry $f.stl.r3e -textvariable stloptions.resthcloseedgefac -width 3 \
397            -validatecommand "my_validate %W [$f.stl.r3sc cget -from] [$f.stl.r3sc cget -to] %P 1" \
398            -invalidcommand "my_invalid %W" -validate focus
399	ttk::checkbutton $f.stl.r3bu -text "STL/IGES/STEP - close edges" \
400	    -variable stloptions.resthcloseedgeenable
401
402	grid $f.stl.r3sc $f.stl.r3e $f.stl.r3bu -sticky nw -padx 4
403
404	#ttk::frame $f.stl.r1
405	#pack $f.stl.r1 -anchor w
406	ttk::scale $f.stl.r1sc -orient horizontal -length 150 -from 0.2 -to 5 \
407	    -variable stloptions.resthsurfcurvfac -takefocus 0 -command "roundscale $f.stl.r1sc 1"
408        ttk::entry $f.stl.r1e -textvariable stloptions.resthsurfcurvfac -width 3 \
409            -validatecommand "my_validate %W [$f.stl.r1sc cget -from] [$f.stl.r1sc cget -to] %P 1" \
410            -invalidcommand "my_invalid %W" -validate focus
411	ttk::checkbutton $f.stl.r1bu -text "STL - surface curvature" \
412	    -variable stloptions.resthsurfcurvenable
413	grid $f.stl.r1sc $f.stl.r1e $f.stl.r1bu -sticky nw -padx 4
414
415	#ttk::frame $f.stl.r3b
416	#pack $f.stl.r3b -anchor w
417	ttk::scale $f.stl.r3bsc -orient horizontal -length 150 -from 0.2 -to 5 \
418	    -variable stloptions.resthedgeanglefac -takefocus 0 -command "roundscale $f.stl.r3bsc 1"
419        ttk::entry $f.stl.r3be -textvariable stloptions.resthedgeanglefac -width 3 \
420            -validatecommand "my_validate %W [$f.stl.r3bsc cget -from] [$f.stl.r3bsc cget -to] %P 1" \
421            -invalidcommand "my_invalid %W" -validate focus
422        ttk::checkbutton $f.stl.r3bbu -text "STL - edge angle" \
423            -variable stloptions.resthedgeangleenable
424	grid $f.stl.r3bsc  $f.stl.r3be $f.stl.r3bbu -sticky nw -padx 4
425
426	#ttk::frame $f.stl.r5
427	#pack $f.stl.r5 -anchor w
428	ttk::scale $f.stl.r5sc -orient horizontal -length 150 -from 0.2 -to 5 \
429            -variable stloptions.resthsurfmeshcurvfac -takefocus 0 -command "roundscale $f.stl.r5sc 1"
430        ttk::entry $f.stl.r5e -textvariable stloptions.resthsurfmeshcurvfac -width 3 \
431            -validatecommand "my_validate %W [$f.stl.r5sc cget -from] [$f.stl.r5sc cget -to] %P 1" \
432            -invalidcommand "my_invalid %W" -validate focus
433	ttk::checkbutton $f.stl.r5bu -text "STL - surface mesh curv" \
434	    -variable stloptions.resthsurfmeshcurvenable
435	grid $f.stl.r5sc  $f.stl.r5e  $f.stl.r5bu -sticky nw -padx 4
436
437
438	ttk::checkbutton $f.stl.recalch -text "STL - Recalc mesh size for surface optimization" \
439	    -variable stloptions.recalchopt
440	grid $f.stl.recalch -sticky n -columnspan 3 -column 0
441
442	ttk::button $f.stl.calch -text "Calc New H" -command { redraw; Ng_STLCalcLocalH }
443	grid $f.stl.calch -columnspan 3 -column 0
444	grid anchor $f.stl center
445        # set f [$w.nb subwidget chartopt]
446
447        # round ttk::scale values to n_digits
448        proc roundscale {w n_digits args} {
449            set val [$w get]
450	    global [$w cget -variable]
451	    if {$n_digits == 0 } {
452                set [$w cget -variable] [tcl::mathfunc::round $val]
453	    } else {
454                set [$w cget -variable] [format "%.[append n_digits "f"]" $val]
455	    }
456	}
457
458        # validate ttk::entry which are linked to ttk::scales widgets
459        global last_accepted_sc
460        proc my_validate {w mini maxi val n_digits} {
461            global last_accepted_sc [$w cget -textvariable]
462            if {[string length $val] == 0} {return 0}
463            if {[string is double $val] == 1} {
464                if { $n_digits == 0 } {
465                    set val [tcl::mathfunc::max $mini [tcl::mathfunc::min $maxi [tcl::mathfunc::round $val]]]
466                } else {
467                    if { $n_digits < 9 } {
468                        set val [tcl::mathfunc::max $mini [tcl::mathfunc::min $maxi [format "%.[append n_digits "f"]" $val]]]
469                    }
470                }
471                    set last_accepted_sc $val
472                    set [$w cget -textvariable] $val
473                    return 1
474                } else {
475                    return 0
476                }
477        }
478
479        # if my_validate returns 0, this function gets called
480        proc my_invalid {w} {
481            global last_accepted_sc [$w cget -textvariable]
482            set [$w cget -textvariable] $last_accepted_sc
483        }
484
485        set f $w.nb.chartopt
486        ttk::labelframe $f.mainframe -text "STL angles" -relief groove -borderwidth 3
487
488        pack $f.mainframe -fill x -pady 15
489        set f $f.mainframe
490
491        #ttk::frame $f.f1
492        ttk::label $f.labYangles -text "Yellow Edges Angle ()"
493        ttk::scale $f.scale1 -orient horizontal -length 150 -from 0 -to 90 -variable stloptions.yangle -takefocus 0 -command "roundscale $f.scale1 1"
494        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" \
495            -invalidcommand "my_invalid %W"
496
497        #pack $f.f1 -anchor center
498        grid $f.scale1 $f.entry1 $f.labYangles -sticky nw -padx 4 -pady 6
499
500        #ttk::frame $f.f21
501        ttk::label $f.labEangles -text "Edge Corner Angle ()"
502        ttk::scale $f.scale2 -orient horizontal -length 150 -from 0 -to 180 -variable stloptions.edgecornerangle -takefocus 0 -command "roundscale $f.scale2 1"
503        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" \
504            -invalidcommand "my_invalid %W"
505
506        #pack $f.f21 -anchor center
507        grid $f.scale2 $f.entry2 $f.labEangles -sticky nw -padx 4 -pady 6
508
509        #ttk::frame $f.f31
510        ttk::label $f.lab31 -text "Chart Angle ()"
511        ttk::scale $f.scale3 -orient horizontal -length 150 -from 0 -to 180 -variable stloptions.chartangle -takefocus 0 -command "roundscale $f.scale3 1"
512        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" \
513            -invalidcommand "my_invalid %W"
514
515        #pack $f.f31 -anchor center
516        grid $f.scale3 $f.entry3 $f.lab31 -sticky nw -padx 4 -pady 6
517
518        #ttk::frame $f.f41
519        ttk::label $f.lab41 -text "Outer Chart Angle ()"
520        ttk::scale $f.scale4 -orient horizontal -length 150 -from 0 -to 180 -variable stloptions.outerchartangle -takefocus 0 -command "roundscale $f.scale4 1"
521        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" \
522            -invalidcommand "my_invalid %W"
523
524        #pack $f.f41 -anchor center
525        grid $f.scale4 $f.entry4 $f.lab41 -sticky nw -padx 4 -pady 6
526	grid anchor $f center
527	# Optimization options
528
529        global last_accepted_sp
530        # Used to validate the entries linked with a ttk::spinbox widget
531        proc my_validatespinbox {w val n_digits} {
532            global last_accepted_sp
533                if {[string length $val] == 0} {return 0}
534                if {[string is double $val] == 1} {
535                    if { $n_digits == 0 } {
536                        if { $n_digits < 9 } {
537                            set val [tcl::mathfunc::round $val] } else { set val [format "%.[append n_digits "f"]" $val]
538                        }
539                    }
540                        $w set [tcl::mathfunc::max [$w cget -from] [tcl::mathfunc::min [$w cget -to] $val]]
541                        set last_accepted_sp $val
542                        return 1
543                } else {
544                    return 0
545                }
546        }
547
548        proc my_invalidspinbox {w} {
549            global last_accepted_sp
550            $w set $last_accepted_sp
551        }
552        # set f [$w.nb subwidget optimizer]
553        set f $w.nb.optimizer
554        ttk::labelframe $f.optframe -text "Optimization settings" -relief groove -borderwidth 3
555	pack $f.optframe -fill x -pady 15
556
557        #ttk::frame $f.optframe.sos
558        ttk::label $f.optframe.sosl -text "Surface opt steps"
559        ttk::spinbox $f.optframe.soss -from 0 -to 99 -textvariable options.optsteps2d -width 5 -increment 1 -validate focus -validatecommand "my_validatespinbox %W %P 0" \
560            -invalidcommand "my_invalidspinbox %W"
561
562        #pack $f.optframe.sos -anchor center
563        grid $f.optframe.sosl $f.optframe.soss -sticky nw;# -side right -fill x -pady 2
564
565        #ttk::frame $f.optframe.vos
566        ttk::label $f.optframe.vosl -text "Volume opt steps"
567        ttk::spinbox $f.optframe.voss -from 0 -to 99 -textvariable options.optsteps3d -width 5 -increment 1 -validate focus -validatecommand "my_validatespinbox %W %P 0" \
568            -invalidcommand "my_invalidspinbox %W"
569
570        #pack $f.optframe.vos -anchor center
571        grid $f.optframe.vosl $f.optframe.voss -sticky nw;# -side right -fill x -pady 2
572
573        #ttk::frame $f.optframe.esw
574        ttk::label $f.optframe.eswl -text "Element size weight"
575        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" \
576            -invalidcommand "my_invalidspinbox %W"
577
578        #pack $f.optframe.esw -anchor center
579        grid $f.optframe.eswl $f.optframe.esws -sticky nw;# -side right -fill x -pady 2
580
581        #ttk::frame $f.optframe.wem
582        ttk::label $f.optframe.weml -text "Worst element measure"
583        ttk::spinbox $f.optframe.wems -from 1 -to 10 -textvariable options.opterrpow -width 5 -increment 1 -validate focus -validatecommand "my_validatespinbox %W %P 0" \
584            -invalidcommand "my_invalidspinbox %W"
585
586        #pack $f.optframe.wem -anchor e
587        grid $f.optframe.weml $f.optframe.wems -sticky nw;# -side right -fill x -pady 2
588        grid anchor $f.optframe center
589        # These functions are needed due to a bug within the aqua theme
590        # if a ttk::scale widget has a from value larger than 100.
591	proc roundscale_helper_osx {w val} {
592            global [$w cget -variable] options.badellimit
593            set [$w cget -variable] [tcl::mathfunc::round $val]
594            set options.badellimit [expr [tcl::mathfunc::round $val]+160]
595        }
596
597        proc my_validate_helper_osx {w val} {
598            if {[string length $val] == 0} {return 0}
599            if {[string is double $val] == 1} {
600                set scale_loc [lindex [winfo children [winfo parent $w]] [lsearch [winfo children [winfo parent $w]] *scale]]
601                global [$scale_loc cget -variable] options.badellimit
602                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]]]
603                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]]]
604                return 1
605            } else {
606                return 0
607            }
608        }
609
610        proc my_invalid_helper_osx {w} {
611            global options.badellimit
612            set scale_loc [lindex [winfo children [winfo parent $w]] [lsearch [winfo children [winfo parent $w]] *scale]]
613            global [$scale_loc cget -variable]
614            set [$scale_loc cget -variable] [tcl::mathfunc::round [$scale_loc get]]
615            set options.badellimit [expr [tcl::mathfunc::round [$scale_loc get]]+160]
616        }
617
618        global dummy_badellimit
619        set dummy_badellimit 15
620        ttk::labelframe $f.optframe2 -text "Bad elements" -relief groove -borderwidth 3
621        pack $f.optframe2 -fill x -pady 15 -ipady 5
622        ttk::frame $f.optframe2.badellimit
623        ttk::label $f.optframe2.lab -text "bad element criterion";
624        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"
625        ttk::entry $f.optframe2.entry -textvariable options.badellimit -width 3 -validate focusout -takefocus 0 -validatecommand "my_validate_helper_osx %W %P" \
626            -invalidcommand "my_invalid_helper_osx %W"
627        #pack $f.optframe2.badellimit -anchor center
628        grid $f.optframe2.scale $f.optframe2.entry $f.optframe2.lab -padx 4 -sticky nw
629        grid anchor $f.optframe2 center
630
631
632
633	# insider options
634        # set f [$w.nb subwidget insider]
635        set f $w.nb.debug
636        ttk::labelframe $f.f2 -text "Advanced options" -borderwidth 3 -relief groove
637        pack $f.f2 -fill x -pady 15
638        #ttk::frame $f.f2.frame
639        #pack $f.f2.frame
640        set f $f.f2
641	ttk::checkbutton $f.localh -text "Use Local Meshsize" \
642	    -variable options.localh
643	ttk::checkbutton $f.delauney -text "Use Delaunay" \
644	    -variable options.delaunay
645	ttk::checkbutton $f.checkoverlap -text "Check Overlapping" \
646	    -variable options.checkoverlap
647	ttk::checkbutton $f.checkcb -text "Check Chart Boundary" \
648	    -variable options.checkchartboundary
649	ttk::checkbutton $f.blockfill -text "Do Blockfilling" \
650	    -variable options.blockfill
651
652        grid $f.localh  $f.delauney -sticky nw
653        grid $f.checkoverlap $f.blockfill -sticky nw
654        grid $f.checkcb -sticky nw
655	grid anchor $f center
656        # debugging options
657        set f $w.nb.debug
658
659        # enable / disable ttk::entry widgets linked to ttk::checkbuttons
660        proc enable_cb {w1 w2 w3} {
661            Ng_SetDebugParameters
662            if {[string match *selected* [$w1 state]] == 1 } {
663                $w2 configure -state normal
664                $w3 configure -state normal
665            } else {
666                $w2 configure -state disabled
667                $w3 configure -state disabled
668            }
669        }
670
671        ttk::labelframe $f.cb1 -text "Debugging options" -borderwidth 3 -relief groove
672        pack $f.cb1 -fill x -pady 15
673
674        #frame $f.cb1.cb0
675        #pack $f.cb1.cb0 -fill x
676
677        ttk::checkbutton $f.cb1.slowchecks -text "Slow checks" \
678            -variable debug.slowchecks -command { Ng_SetDebugParameters }
679        ttk::checkbutton $f.cb1.debugoutput -text "Debugging outout" \
680            -variable debug.debugoutput -command { Ng_SetDebugParameters }
681        ttk::checkbutton $f.cb1.haltexline -text "Halt on existing line" \
682            -variable debug.haltexistingline  -command { Ng_SetDebugParameters }
683        ttk::checkbutton $f.cb1.haltoverlap -text "Halt on Overlap" \
684            -variable debug.haltoverlap  -command { Ng_SetDebugParameters }
685        ttk::checkbutton $f.cb1.haltsuc -text "Halt on success" \
686            -variable debug.haltsuccess  -command { Ng_SetDebugParameters }
687        ttk::checkbutton $f.cb1.haltnosuc -text "Halt on no success" \
688            -variable debug.haltnosuccess  -command { Ng_SetDebugParameters }
689        ttk::checkbutton $f.cb1.haltlargequal -text "Halt on large quality class" \
690            -variable debug.haltlargequalclass  -command { Ng_SetDebugParameters }
691        ttk::checkbutton $f.cb1.haltseg -text "Halt on Segment:" \
692            -variable debug.haltsegment  -command { Ng_SetDebugParameters }
693        ttk::checkbutton $f.cb1.haltnode -text "Halt on Node:" \
694            -variable debug.haltnode  -command { Ng_SetDebugParameters }
695        ttk::frame $f.cb1.fr
696        ttk::checkbutton $f.cb1.fr.cb -text "Halt on Face:" \
697            -variable debug.haltface -command { Ng_SetDebugParameters }
698        ttk::entry $f.cb1.fr.ent -textvariable debug.haltfacenr -width 3
699
700        pack $f.cb1.fr.cb $f.cb1.fr.ent -side left
701
702        ttk::frame $f.cb1.segs
703        ttk::label $f.cb1.segs.lab1 -text "P1:"
704        ttk::entry $f.cb1.segs.ent1 -width 6 \
705            -textvariable debug.haltsegmentp1
706        ttk::label $f.cb1.segs.lab2 -text "P2:"
707        ttk::entry $f.cb1.segs.ent2 -width 6 \
708            -textvariable debug.haltsegmentp2
709
710        pack $f.cb1.segs.lab1 $f.cb1.segs.ent1 $f.cb1.segs.lab2 $f.cb1.segs.ent2 -side left
711
712
713        grid $f.cb1.slowchecks $f.cb1.debugoutput -sticky nw
714        grid $f.cb1.haltexline $f.cb1.haltoverlap -sticky nw
715        grid $f.cb1.haltsuc $f.cb1.haltnosuc  -sticky nw
716        grid $f.cb1.haltlargequal  $f.cb1.fr -sticky nw
717        grid $f.cb1.haltnode -sticky nw
718        grid $f.cb1.haltseg  -stick nw
719        grid $f.cb1.segs -stick w -row 4 -rowspan 2 -column 1
720
721        grid rowconfigure $f.cb1 3 -pad 8
722        grid anchor $f.cb1 center
723        ttk::checkbutton $f.cb1.showactivechart -text "Show Active Meshing-Chart" -variable stloptions.showactivechart -command { Ng_SetVisParameters; redraw }
724
725        grid $f.cb1.showactivechart
726        grid rowconfigure $f.cb1 3 -pad 8
727        grid rowconfigure $f.cb1 5 -pad 8
728
729        set f $w.nb.debug
730        ttk::labelframe $f.cont -relief groove -borderwidth 3 -text "Debugging visualization"
731        pack $f.cont -fill x -pady 15
732        #ttk::frame $f.cont.f
733        #pack $f.cont.f
734
735        ttk::checkbutton $f.cont.multidrawing -text "Draw Meshing" -variable multithread_drawing
736        ttk::checkbutton $f.cont.multitestmode -text "Meshing Testmode" -variable multithread_testmode
737        ttk::button $f.cont.goon -text "Go On" -command { set multithread_pause 0 }
738
739        grid $f.cont.multidrawing -sticky nw
740        grid $f.cont.multitestmode -sticky nw
741        grid $f.cont.goon -row 0 -rowspan 2 -column 1 -sticky w
742        grid columnconfigure $f.cont 0 -pad 30
743        grid columnconfigure $f.cont 1 -pad 20
744        grid anchor $f.cont center
745
746	global userlevel
747	if { $userlevel < 3} {
748	    $w.nb delete insider
749	    $w.nb delete debug
750	}
751
752
753
754# 	tixButtonBox $w.bbox -orientation horizontal
755# 	$w.bbox add ok    -text Apply  -underline 0 -width 5 \
756# 	    -command {
757# 		[.options_dlg.nb subwidget meshsize].meshsize invoke
758# 		[.options_dlg.nb subwidget meshsize].grading invoke
759# 		[.options_dlg.nb subwidget optimizer].os2d invoke
760# 		[.options_dlg.nb subwidget optimizer].os3d invoke
761# 		[.options_dlg.nb subwidget optimizer].elw invoke
762# 		[.options_dlg.nb subwidget optimizer].wem invoke
763
764# 		Ng_SetMeshingParameters
765# 	    }
766
767# 	$w.bbox add close -text Done   -underline 0 -width 5 \
768# 	    -command {
769# 		[.options_dlg.nb subwidget meshsize].meshsize invoke
770# 		[.options_dlg.nb subwidget meshsize].grading invoke
771# 		[.options_dlg.nb subwidget optimizer].os2d invoke
772# 		[.options_dlg.nb subwidget optimizer].os3d invoke
773# 		[.options_dlg.nb subwidget optimizer].elw invoke
774# 		[.options_dlg.nb subwidget optimizer].wem invoke
775
776# 		Ng_SetMeshingParameters
777# 		destroy .options_dlg
778# 	    }
779
780#       pack $w.bbox -side bottom -fill x
781
782
783        ttk::frame $w.bu
784        pack $w.bu -fill x -ipady 3
785
786        ttk::button $w.bu.apl -text "Apply" -command {
787            Ng_SetMeshingParameters
788            Ng_SetDebugParameters
789        }
790
791        ttk::button $w.bu.ok -text "Done" -command {
792            Ng_SetMeshingParameters
793            Ng_SetDebugParameters
794            wm withdraw .options_dlg
795#           destroy .options_dlg
796        }
797
798        pack  $w.bu.apl $w.bu.ok -side left -expand yes
799        wm withdraw $w
800	wm geom $w +100+100
801	wm deiconify $w
802	wm title $w "Meshing Options"
803	focus .options_dlg
804    }
805}
806
807
808meshingoptionsdialog
809wm withdraw .options_dlg
810
811
812
813
814
815
816
817
818
819#
820#
821#  Viewing dialog
822#
823#
824proc viewingoptionsdialog { } {
825
826    global userlevel
827
828    set w .viewopts_dlg
829
830    if {[winfo exists .viewopts_dlg] == 1} {
831	wm withdraw $w
832	wm deiconify $w
833	focus $w
834    } {
835	toplevel $w
836        #wm resizable $w 0 0
837
838
839        pack [ttk::notebook $w.nb]  -fill both -fill both -side top
840        $w.nb add [ttk::frame $w.nb.general] -text "General" -underline 0
841        $w.nb add [ttk::frame $w.nb.stl] -text "STL" -underline 0
842        $w.nb add [ttk::frame $w.nb.occ] -text "IGES/STEP" -underline 0
843        $w.nb add [ttk::frame $w.nb.mesh] -text "Mesh" -underline 0
844        $w.nb add [ttk::frame $w.nb.light] -text "Light" -underline 0
845        $w.nb add [ttk::frame $w.nb.edges] -text "Edges" -underline 0
846        $w.nb add [ttk::frame $w.nb.misc] -text "Misc." -underline 3
847
848
849	# tixNoteBook $w.nb -ipadx 6 -ipady 6
850
851	# $w.nb add general -label "General" -underline 0
852	# $w.nb add stl -label "STL" -underline 0
853	# $w.nb add occ -label "IGES/STEP" -underline 0
854	# $w.nb add mesh -label "Mesh"   -underline 0
855	# $w.nb add light -label "Light"   -underline 0
856	# $w.nb add edges -label "Edges"   -underline 0
857	# $w.nb add misc -label "Misc."  -underline 3
858
859	# pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top
860
861
862
863
864
865	# general
866	set f $w.nb.general
867        ttk::labelframe $f.gvop -text "General viewing options" -relief groove -borderwidth 3
868        pack $f.gvop -fill x -pady 15
869        set f $f.gvop
870	ttk::checkbutton $f.backcol -text "White Background" \
871	-variable viewoptions.whitebackground \
872	-command { Ng_SetVisParameters; redraw }
873
874	ttk::checkbutton $f.cross -text "Draw Coordinate Cross" \
875	-variable viewoptions.drawcoordinatecross \
876	-command { Ng_SetVisParameters; redraw }
877
878	ttk::checkbutton $f.color -text "Draw Color-bar" \
879	-variable viewoptions.drawcolorbar \
880	-command { Ng_SetVisParameters; redraw }
881
882	ttk::checkbutton $f.netgen -text "Draw Netgen-logo" \
883	-variable viewoptions.drawnetgenlogo \
884	-command { Ng_SetVisParameters; redraw }
885
886	grid $f.backcol -sticky nw
887        grid $f.cross -stick nw
888        grid $f.color  -sticky nw
889        grid $f.netgen -sticky nw
890# 	checkbutton $f.stereo -text "Stereo View" \
891# 	-variable viewoptions.stereo \
892# 	-command { Ng_SetVisParameters; redraw }
893# 	pack $f.stereo
894
895
896        menu $f.stylemenu
897        ttk::menubutton $f.style -menu $f.stylemenu -width 10 -text [ttk::style theme use]
898        grid $f.style -sticky nw
899        grid anchor $f center
900
901        foreach theme [ttk::themes] {
902            $f.stylemenu add command -label  $theme \
903                -command " $f.style configure -text $theme; puts $theme ; ttk::setTheme $theme"
904        }
905
906	# stl geometry
907	set f $w.nb.stl
908	ttk::labelframe $f.show -relief groove -borderwidth 3 -text "STL viewing options"
909	pack $f.show -fill x -pady 15
910	ttk::checkbutton $f.show.showtrias -text "Show STL-Triangles" \
911	    -variable stloptions.showtrias -command { Ng_SetVisParameters; redraw }
912	#grid $f.show.showtrias -stick nw
913
914	ttk::checkbutton $f.show.showfilledtrias -text "Show Filled Triangles" \
915	    -variable stloptions.showfilledtrias -command { Ng_SetVisParameters; redraw }
916	grid $f.show.showtrias $f.show.showfilledtrias -sticky nw
917
918	ttk::checkbutton $f.show.showactivechart -text "Show Active Meshing-Chart" \
919	    -variable stloptions.showactivechart -command { Ng_SetVisParameters; redraw }
920	#grid $f.show.showactivechart -sticky nw
921
922	ttk::checkbutton $f.show.showedges -text "Show Edges" \
923	    -variable stloptions.showedges -command { Ng_SetVisParameters; redraw }
924	grid $f.show.showactivechart $f.show.showedges -sticky nw
925	grid anchor $f.show center
926	#frame $f.special -relief groove -borderwidth 3
927	#pack $f.special
928	ttk::checkbutton $f.show.showmarktrias -text "Show Chart Triangles" \
929	    -variable stloptions.showmarktrias \
930	    -command {set stldoctor.showfaces 0; Ng_STLDoctor; Ng_SetVisParameters; redraw }
931	#pack $f.show.showmarktrias -side left
932
933	ttk::checkbutton $f.show.showfaces -text "Show Faces" \
934	    -variable stldoctor.showfaces \
935	    -command {set stloptions.showmarktrias 0; Ng_STLDoctor; Ng_SetVisParameters; redraw}
936	#pack $f.show.showfaces -side left
937        grid $f.show.showmarktrias $f.show.showfaces -sticky nw
938
939
940        ttk::labelframe $f.fn -relief groove -borderwidth 3 -text "Chart/Face number"
941	pack $f.fn -fill x
942	ttk::label $f.fn.lab3 -text "Chart/Face number"
943	ttk::scale $f.fn.scale3 -orient horizontal -length 150 -from 0 -to 200 \
944            -variable stloptions.chartnumber -command "Ng_SetVisParameters; redraw;roundscale $f.fn.scale3 0"
945        ttk::entry $f.fn.ent3 -textvariable stloptions.chartnumber -width 3 -validate focus -takefocus 0 \
946            -validatecommand "Ng_SetVisParameters; redraw;my_validate %W [$f.fn.scale3 cget -from] [$f.fn.scale3 cget -to] %P 0" \
947            -invalidcommand "my_invalid %W;Ng_SetVisParameters; redraw;"
948
949	grid $f.fn.scale3 $f.fn.ent3 $f.fn.lab3 -sticky nw -padx 4
950
951
952	#frame $f.fo -relief groove -borderwidth 3
953	#pack $f.fo
954	tk::label $f.fn.lab -text "Chart/Face Offset:";
955	ttk::entry $f.fn.ent -width 3 \
956	    -textvariable stloptions.chartnumberoffset -validate focus -takefocus 0 \
957            -validatecommand "my_validate %W 0 1e9 %P 0" \
958            -invalidcommand "my_invalid %W"
959
960        ttk::button $f.fn.btn_write_chart -text "Write selected chart to chart.stlb" -command {
961            Ng_STLDoctor writechart
962        }
963
964	grid $f.fn.lab -sticky ne -padx 4
965        grid $f.fn.ent -sticky nw -padx 4 -row 1 -column 1
966        grid $f.fn.btn_write_chart -padx 4 -row 2 -column 1
967        grid anchor $f.fn center
968
969	ttk::labelframe $f.advstl -text "Advanced STL options" -relief groove -borderwidth 3
970        pack $f.advstl -fill x -pady 15
971        #frame $f.mt
972	#pack $f.mt -fill x
973	ttk::checkbutton $f.advstl.bu1 -text "Show Marked (Dirty) Triangles" \
974	    -variable stldoctor.showmarkedtrigs \
975	    -command {Ng_STLDoctor; redraw}
976	#pack $f.mt.bu
977
978	#frame $f.ep
979	#pack $f.ep -fill x
980	ttk::checkbutton $f.advstl.bu2 -text "show edge corner points" \
981	    -variable stldoctor.showedgecornerpoints \
982	    -command {Ng_STLDoctor; redraw}
983	#pack $f.ep.bu
984
985	#frame $f.stt
986	#pack $f.stt -fill x
987	ttk::checkbutton $f.advstl.bu3 -text "show touched triangle chart" \
988	    -variable stldoctor.showtouchedtrigchart \
989	    -command {set stldoctor.showfaces 0; set stloptions.showmarktrias 1; \
990			  Ng_STLDoctor; Ng_SetVisParameters; redraw}
991	#pack $f.stt.bu
992
993	#frame $f.sml
994	#pack $f.sml -fill x
995	ttk::checkbutton $f.advstl.bu4 -text "draw meshed edges" \
996	    -variable stldoctor.drawmeshededges \
997	    -command {Ng_STLDoctor;}
998	#pack $f.sml.bu
999
1000
1001	#frame $f.sm
1002	#pack $f.sm -fill x
1003	ttk::checkbutton $f.advstl.bu5 -text "select with mouse" \
1004	    -variable stldoctor.selectwithmouse
1005	#pack $f.sm.bu
1006	grid $f.advstl.bu1 -stick nw
1007        grid $f.advstl.bu2 -sticky nw
1008        grid $f.advstl.bu3 -stick nw
1009        grid $f.advstl.bu4 -stick nw
1010        grid $f.advstl.bu5 -stick nw
1011        grid anchor $f.advstl center
1012	ttk::frame $f.advstl.tbn
1013	ttk::label $f.advstl.tbn.lab -text "Select triangle by number";
1014	ttk::entry $f.advstl.tbn.ent -width 5 \
1015	    -textvariable stldoctor.selecttrig
1016        pack $f.advstl.tbn.lab $f.advstl.tbn.ent -padx 4 -side left
1017	grid $f.advstl.tbn -sticky nw
1018	grid anchor $f.advstl center
1019        grid rowconfigure $f.advstl 4 -pad 8
1020
1021        ttk::labelframe $f.vc -relief groove -borderwidth 3 -text "Vicinity options"
1022	pack $f.vc -fill x -pady 15
1023	ttk::checkbutton $f.vc.bu -text "show vicinity" \
1024	    -variable stldoctor.showvicinity \
1025	    -command {Ng_STLDoctor vicinity; redraw}
1026	ttk::label $f.vc.lab -text "vicinity size";
1027	ttk::scale $f.vc.scale -orient horizontal -length 150 -from 0 -to 200 \
1028	    -variable stldoctor.vicinity \
1029             -takefocus 0 \
1030             -command "roundscale $f.vc.scale 0; Ng_STLDoctor vicinity; redraw"
1031	    #-command { Ng_STLDoctor vicinity; redraw }
1032        ttk::entry $f.vc.ent -width 4 -textvariable stldoctor.vicinity -validate focus \
1033        -takefocus 0 -validatecommand "Ng_STLDoctor vicinity; redraw;my_validate %W [$f.vc.scale cget -from] [$f.vc.scale cget -to] %P 0" \
1034            -invalidcommand "my_invalid %W;Ng_STLDoctor vicinity; redraw"
1035	#pack $f.vc.bu $f.vc.lab $f.vc.sc -expand yes
1036	grid $f.vc.bu -stick nw -columnspan 3 -column 0
1037        grid $f.vc.scale $f.vc.ent $f.vc.lab -sticky nw -padx 4
1038        grid anchor $f.vc center
1039
1040
1041	# IGES/STEP
1042	set f $w.nb.occ
1043	ttk::labelframe $f.occframe -text "IGES/STEP options" -relief groove -borderwidth 3
1044        pack $f.occframe -fill x -pady 15 -ipady 8
1045        #set f $f.occframe
1046	ttk::checkbutton $f.occframe.occshowsurfaces -text "Show surfaces " \
1047	    -variable occoptions.showsurfaces \
1048	    -command { Ng_SetOCCVisParameters; redraw }
1049
1050	ttk::checkbutton $f.occframe.occshowedges -text "Show edges " \
1051	    -variable occoptions.showedges \
1052	    -command { Ng_SetOCCVisParameters; redraw }
1053        grid $f.occframe.occshowsurfaces $f.occframe.occshowedges -sticky nw -padx 4
1054        grid anchor $f.occframe center
1055	#ttk::frame $f.deflection -relief groove -borderwidth 3
1056	#pack $f.occframe.deflection -fill x
1057	ttk::button $f.occframe.btn -text "Rebuild visualization data" \
1058	    -command {
1059		Ng_SetOCCVisParameters
1060		Ng_OCCCommand buildvisualizationmesh
1061		redraw
1062	    }
1063
1064	#tixControl $f.occframe.ent -label "Visualization smoothness" -integer false \
1065	    -variable occoptions.deflection -min 0.1 -max 3 -step 0.1 \
1066	    -options { entry.width 3 } \
1067	    -command { Ng_SetOCCVisParameters }
1068        ttk::frame $f.occframe.vssm
1069        ttk::label $f.occframe.vssm.lab -text "Visulization smoothness"
1070        ttk::spinbox $f.occframe.vssm.sp -textvariable occoptions.deflection \
1071            -from 0.1 -to 3 -increment 0.1 -width 4 -command { catch Ng_SetOCCVisParameters } \
1072            -validate focus -validatecommand "my_validatespinbox %W %P 0" \
1073            -invalidcommand "my_invalidspinbox %W"
1074        pack $f.occframe.vssm.lab $f.occframe.vssm.sp -side left -padx 4
1075        grid $f.occframe.vssm -sticky nw -columnspan 2 -column 0 -pady 8
1076        grid $f.occframe.btn -columnspan 2 -column 0 -sticky n
1077
1078
1079
1080	#grid $f.occframe.ent $f.occframe.lab -sticky nw
1081
1082
1083	# ACIS visualization / construction
1084
1085        ttk::labelframe $f.occframe1 -relief groove -borderwidth 3 -text "ACIS visulization / construction"
1086        pack $f.occframe1 -fill x -pady 15 -ipady 8
1087        #ttk::frame $f.occframe1.shso
1088        ttk::label $f.occframe1.lab1 -text "Show solid (0 for all)"
1089        ttk::spinbox $f.occframe1.sp1 -textvariable occoptions.showsolidnr \
1090            -from 0 -to 999 -increment 1 -width 4 -command { catch Ng_SetOCCVisParameters;redraw } \
1091            -validate focus -validatecommand "my_validatespinbox %W %P 0" \
1092            -invalidcommand "my_invalidspinbox %W"
1093        #pack $f.occframe1.shso.lab $f.occframe1.shso.sp -side left -padx 4
1094
1095        #ttk::frame $f.occframe1.shso2
1096        ttk::label $f.occframe1.lab2 -text "Show solid 2"
1097        ttk::spinbox $f.occframe1.sp2 -textvariable occoptions.showsolidnr2 \
1098            -from 0 -to 999 -increment 1 -width 4 -command { catch Ng_SetOCCVisParameters;redraw } \
1099            -validate focus -validatecommand "my_validatespinbox %W %P 0" \
1100            -invalidcommand "my_invalidspinbox %W"
1101        #pack $f.occframe1.shso2.lab $f.occframe1.shso2.sp -side left -padx 4
1102
1103	#tixControl $f.showsolid -label "Show solid (0 for all)" -integer true \
1104            -variable occoptions.showsolidnr -min 0 -max 999 \
1105	    -options { entry.width 3 } \
1106	    -command { Ng_SetOCCVisParameters; redraw }
1107
1108	#tixControl $f.showsolid2 -label "Show solid 2" -integer true \
1109            -variable occoptions.showsolidnr2 -min 0 -max 999 \
1110	    -options { entry.width 3 } \
1111	    -command { Ng_SetOCCVisParameters; redraw }
1112
1113	ttk::button $f.occframe1.subtract -text "Subtract (2 minus 1)" \
1114	    -command {
1115		Ng_ACISCommand subtract ${occoptions.showsolidnr} ${occoptions.showsolidnr2}
1116		redraw
1117	    }
1118
1119
1120
1121	ttk::button $f.occframe1.combine -text "Combine all" \
1122	    -command {
1123		Ng_ACISCommand combineall
1124		redraw
1125	    }
1126
1127	#pack $f.showsolid $f.showsolid2 $f.subtract $f.combine;# -sticky nw
1128        grid $f.occframe1.lab1 -row 0 -column 0 -sticky ne
1129        grid $f.occframe1.sp1 -row 0 -column 1 -sticky nw
1130        grid $f.occframe1.lab2 -row 1 -column 0 -sticky ne
1131        grid $f.occframe1.sp2 -row 1 -column 1 -sticky nw
1132        grid $f.occframe1.combine -columnspan 2 -column 0 -sticky n
1133        grid anchor $f.occframe1 center
1134
1135
1136
1137
1138	# mesh options
1139	set f $w.nb.mesh
1140
1141	ttk::labelframe $f.center -relief groove -borderwidth 3 -text "how shall i name you?"
1142	pack $f.center -fill x -pady 15
1143	ttk::button $f.center.lab1 -text "Set Center Point" \
1144	    -command { Ng_SetVisParameters; Ng_Center; redraw }
1145	ttk::entry $f.center.ent1 -width 5 \
1146	    -textvariable viewoptions.centerpoint -validate focus \
1147            -validatecommand "my_validate %W 0 1e9 %P 0" \
1148            -invalidcommand "my_invalid %W"
1149	grid $f.center.ent1 $f.center.lab1 -padx 4 -pady 4 -sticky nw
1150
1151	#ttk::frame $f.drawel -relief groove -borderwidth 3
1152	#pack $f.drawel -fill x
1153	ttk::button $f.center.lab2 -text "Draw Element" \
1154	    -command { Ng_SetVisParameters; Ng_ZoomAll; redraw }
1155	ttk::entry $f.center.ent2 -width 5 \
1156	    -textvariable viewoptions.drawelement -validate focus \
1157            -validatecommand "my_validate %W 0 1e9 %P 0" \
1158            -invalidcommand "my_invalid %W"
1159	grid $f.center.ent2 $f.center.lab2 -padx 4 -pady 4 -sticky nw
1160        grid anchor $f.center center
1161
1162        ttk::labelframe $f.meshframe -text "Mesh visualization options" -relief groove -borderwidth 3
1163        pack $f.meshframe -fill x -pady 15
1164        set f $f.meshframe
1165	ttk::checkbutton $f.showcolor -text "Meshsize Visualization" \
1166	    -variable viewoptions.colormeshsize \
1167	    -command { Ng_SetVisParameters;redraw; }
1168
1169	ttk::checkbutton $f.showfilledtrigs -text "Show filled triangles" \
1170	    -variable viewoptions.drawfilledtrigs \
1171	    -command { Ng_SetVisParameters; redraw }
1172
1173	ttk::checkbutton $f.showedges -text "Show edges" \
1174	    -variable viewoptions.drawedges \
1175	    -command { Ng_SetVisParameters; redraw }
1176
1177	ttk::checkbutton $f.showoutline -text "Show Triangle Outline" \
1178	    -variable viewoptions.drawoutline \
1179	    -command { Ng_SetVisParameters; redraw }
1180
1181	ttk::checkbutton $f.showbadels -text "Show bad elements" \
1182	    -variable viewoptions.drawbadels \
1183	    -command { Ng_SetVisParameters; redraw }
1184
1185	ttk::checkbutton $f.showprisms -text "Show prisms" \
1186	    -variable viewoptions.drawprisms \
1187	    -command { Ng_SetVisParameters; redraw }
1188
1189	ttk::checkbutton $f.showpyramids -text "Show pyramids" \
1190	    -variable viewoptions.drawpyramids \
1191	    -command { Ng_SetVisParameters; redraw }
1192
1193	ttk::checkbutton $f.showhexes -text "Show hexes" \
1194	    -variable viewoptions.drawhexes \
1195	    -command { Ng_SetVisParameters; redraw }
1196
1197	ttk::checkbutton $f.showidentified -text "Show identified points" \
1198	    -variable viewoptions.drawidentified \
1199	    -command { Ng_SetVisParameters; redraw }
1200
1201	ttk::checkbutton $f.showmetispartition -text "Show METIS Partition" \
1202	    -variable viewoptions.drawmetispartition \
1203	    -command { Ng_SetVisParameters; redraw }
1204
1205	ttk::checkbutton $f.showpointnumbers -text "Show Point-numbers" \
1206	    -variable viewoptions.drawpointnumbers \
1207	    -command { Ng_SetVisParameters; redraw }
1208	ttk::checkbutton $f.showedgenumbers -text "Show Edge-numbers" \
1209	    -variable viewoptions.drawedgenumbers \
1210	    -command { Ng_SetVisParameters; redraw }
1211	ttk::checkbutton $f.showfacenumbers -text "Show Face-numbers" \
1212	    -variable viewoptions.drawfacenumbers \
1213	    -command { Ng_SetVisParameters; redraw }
1214	ttk::checkbutton $f.showelementnumbers -text "Show Element-numbers" \
1215	    -variable viewoptions.drawelementnumbers \
1216	    -command { Ng_SetVisParameters; redraw }
1217
1218	# label $f.showdomainlab -text "Domain Surface"
1219#	scale $f.showdomain -orient horizontal -length 100 -from 0 -to 50 \
1220	    -resolution 1 -variable  viewoptions.drawdomainsurf    \
1221	    -command { Ng_SetVisParameters; redraw } \
1222	    -label "Domain Surface"
1223
1224        #pack $f.showfilledtrigs
1225	#pack $f.showoutline $f.subdiv $f.showedges  $f.showbadels
1226	## pack $f.showdomainlab
1227	#pack $f.showdomain
1228	#pack $f.showpointnumbers
1229	#pack $f.showedgenumbers $f.showfacenumbers $f.showelementnumbers
1230	#pack $f.showmetispartition
1231
1232
1233
1234
1235	ttk::frame $f.frametets
1236	ttk::checkbutton $f.frametets.showtets -text "" \
1237	    -variable viewoptions.drawtets \
1238	    -command { Ng_SetVisParameters; redraw }
1239        ttk::label $f.frametets.label -text "\Show Tets\rin domain"
1240        ttk::spinbox $f.frametets.showtetsdomain -from 0 -to 500 -increment 1 -width 3 \
1241            -textvariable viewoptions.drawtetsdomain -validate focus \
1242            -command "Ng_SetVisParameters; redraw;" \
1243            -validatecommand "my_validatespinbox %W %P 0" \
1244            -invalidcommand "my_invalidspinbox %W"
1245
1246        #ttk::frame $f.frametets
1247        ttk::label $f.frametets.label1 -text "Subdivision"
1248        ttk::spinbox $f.frametets.subdiv -from 0 -to 8 -increment 1 -width 3 \
1249            -textvariable visoptions.subdivisions -validate focus \
1250            -command { Ng_SetVisParameters; Ng_Vis_Set parameters; Ng_SetNextTimeStamp; redraw } \
1251            -validatecommand "my_validatespinbox %W %P 0" \
1252            -invalidcommand "my_invalidspinbox %W"
1253
1254        ttk::label $f.frametets.label2 -text "Show surface\rof domain"
1255        ttk::spinbox $f.frametets.showdomain -from 0 -to 50 -increment 1 -width 3 \
1256            -textvariable viewoptions.drawdomainsurf -validate focus \
1257            -command { Ng_SetVisParameters; Ng_Vis_Set parameters; redraw } \
1258            -validatecommand "my_validatespinbox %W %P 0" \
1259            -invalidcommand "my_invalidspinbox %W"
1260
1261	#tixControl $f.showdomain -label "Show surface\rof domain" -integer true \
1262            -variable viewoptions.drawdomainsurf -min 0 -max 50 \
1263	    -options { entry.width 2 } \
1264	    -command { Ng_SetVisParameters; Ng_Vis_Set parameters; redraw }
1265
1266
1267        #tixControl $f.subdiv -label "Subdivision" -integer true \
1268        #    -variable visoptions.subdivisions -min 0 -max 8 \
1269	    -options { entry.width 2 } \
1270	    -command { Ng_SetVisParameters; Ng_Vis_Set parameters; Ng_SetNextTimeStamp; redraw }
1271
1272	#tixControl $f.frametets.showtetsdomain -label "" -integer true \
1273	    -variable viewoptions.drawtetsdomain -min 0 -max 500 \
1274	    -options { entry.width 2 } \
1275	    -command { Ng_SetVisParameters; redraw }
1276
1277	#pack $f.frametets
1278        grid $f.frametets.showtets $f.frametets.label $f.frametets.showtetsdomain -sticky w
1279        grid x $f.frametets.label2 $f.frametets.showdomain -stick w
1280        grid x $f.frametets.label1 $f.frametets.subdiv -sticky w
1281        grid $f.showfilledtrigs $f.showoutline -sticky nw
1282        grid $f.showedges $f.showbadels -sticky nw
1283        grid $f.showpointnumbers $f.showedgenumbers -sticky nw
1284        grid $f.showfacenumbers $f.showelementnumbers -sticky nw
1285        grid $f.showmetispartition $f.showidentified -sticky nw
1286	grid $f.showcolor $f.showpyramids -sticky nw
1287        grid $f.showprisms $f.showhexes -sticky nw
1288
1289
1290        grid  $f.frametets -sticky n -columnspan 2 -column 0 -pady 8
1291        #grid  $f.showdomain -stick ne;# -columnspan 3 -column 0 -pady 6
1292        #grid  $f.framesubdiv -sticky nw;# -columnspan 3 -column 0 -pady 6
1293        grid anchor $f center
1294
1295        set f $w.nb.mesh
1296	ttk::labelframe $f.fshrink -text "Element visualization" -relief groove -borderwidth 3
1297	ttk::label $f.fshrink.lab -text "Shrink elements"
1298	#scale $f.fshrink.scale -orient horizontal -length 200 -from 0 -to 1.0001 \
1299	    -resolution 0.01  -tickinterval 0.25 \
1300	    -command { Ng_SetVisParameters; after idle redraw } \
1301            -variable  viewoptions.shrink
1302	ttk::scale $f.fshrink.scale -orient horizontal -length 200 -from 0 -to 1.0001 \
1303            -command "roundscale $f.fshrink.scale 2;Ng_SetVisParameters; after idle redraw" \
1304            -variable  viewoptions.shrink
1305        ttk::entry $f.fshrink.entry -textvariable viewoptions.shrink -width 4 -validate focus \
1306            -takefocus 0 -validatecommand "Ng_SetVisParameters; after idle redraw;my_validate %W [$f.fshrink.scale cget -from] [$f.fshrink.scale cget -to] %P 2" \
1307            -invalidcommand "my_invalid %W;Ng_SetVisParameters; after idle redraw;"
1308	pack $f.fshrink -fill x -ipady 8
1309	grid $f.fshrink.scale $f.fshrink.entry $f.fshrink.lab -padx 4
1310        grid anchor $f.fshrink center
1311
1312#	if {$userlevel == 3} {
1313#	    frame $f.framecurveproj
1314#	    checkbutton $f.framecurveproj.showcurveproj -text "Show curved edge projection " \
1315		-variable viewoptions.drawcurveproj \
1316		-command { Ng_SetVisParameters; redraw }
1317	#    tixControl $f.framecurveproj.showcurveprojedge -label "" -integer true \
1318		-variable viewoptions.drawcurveprojedge -min 1 -max 99999 \
1319		-options { entry.width 5 } \
1320		-command { Ng_SetVisParameters; redraw }
1321
1322#	    pack $f.framecurveproj
1323#	    pack $f.framecurveproj.showcurveproj $f.framecurveproj.showcurveprojedge -side left
1324#	}
1325
1326
1327
1328
1329
1330
1331	# light options
1332	set f $w.nb.light
1333	ttk::labelframe $f.main -text "Lighting options" -relief groove -borderwidth 3
1334        pack $f.main -fill x -pady 15
1335        set f $f.main
1336	ttk::label $f.lab1 -text "Ambient Light"
1337	ttk::scale $f.scale1 -orient horizontal -length 200 -from 0 -to 1 \
1338	    -command "roundscale $f.scale1 2; Ng_SetVisParameters; redraw" \
1339            -variable viewoptions.light.amb
1340        ttk::entry $f.ent1 -textvariable viewoptions.light.amb -validate focus -width 4 \
1341            -validatecommand " Ng_SetVisParameters; redraw;my_validate %W [$f.scale1 cget -from] [$f.scale1 cget -to] %P 2" \
1342            -invalidcommand "my_invalid %W;Ng_SetVisParameters; redraw;"
1343
1344        ttk::label $f.lab2 -text "Diffuse Light"
1345        ttk::scale $f.scale2 -orient horizontal -length 200 -from 0 -to 1 \
1346	    -command "roundscale $f.scale2 2; Ng_SetVisParameters; redraw " \
1347            -variable  viewoptions.light.diff
1348        ttk::entry $f.ent2 -textvariable viewoptions.light.diff -validate focus -width 4 \
1349            -validatecommand " Ng_SetVisParameters; redraw;my_validate %W [$f.scale2 cget -from] [$f.scale2 cget -to] %P 2" \
1350            -invalidcommand "my_invalid %W;Ng_SetVisParameters; redraw;"
1351
1352	ttk::label $f.lab3 -text "Specular Light"
1353	ttk::scale $f.scale3 -orient horizontal -length 200 -from 0 -to 1 \
1354	    -command "roundscale $f.scale3 2; Ng_SetVisParameters; redraw " \
1355            -variable  viewoptions.light.spec
1356        ttk::entry $f.ent3 -textvariable viewoptions.light.spec -validate focus -width 4 \
1357            -validatecommand " Ng_SetVisParameters; redraw;my_validate %W [$f.scale3 cget -from] [$f.scale3 cget -to] %P 2" \
1358            -invalidcommand "my_invalid %W;Ng_SetVisParameters; redraw;"
1359
1360        grid $f.scale1 $f.ent1 $f.lab1 -sticky nw -padx 4 -pady 8
1361        grid $f.scale2 $f.ent2 $f.lab2 -sticky nw -padx 4 -pady 8
1362        grid $f.scale3 $f.ent3 $f.lab3 -sticky nw -padx 4 -pady 8
1363        grid anchor $f center
1364        set f $w.nb.light
1365        ttk::labelframe $f.main1 -text "Material options" -relief groove -borderwidth 3
1366        pack $f.main1 -fill x -pady 15
1367        set f $f.main1
1368        ttk::label $f.lab4 -text "Material Shininess"
1369	ttk::scale $f.scale4 -orient horizontal -length 200 -from 0 -to 128 \
1370	    -command "roundscale $f.scale4 0; Ng_SetVisParameters; redraw " \
1371            -variable  viewoptions.mat.shininess
1372        ttk::entry $f.ent4 -textvariable viewoptions.mat.shininess -validate focus -width 4 \
1373            -validatecommand " Ng_SetVisParameters; redraw;my_validate %W [$f.scale4 cget -from] [$f.scale4 cget -to] %P 0" \
1374            -invalidcommand "my_invalid %W;Ng_SetVisParameters; redraw;"
1375
1376
1377	ttk::label $f.lab5 -text "Material Transparency"
1378	ttk::scale $f.scale5 -orient horizontal -length 200 -from 0 -to 1 \
1379	-command "roundscale $f.scale5 2; Ng_SetVisParameters; redraw " \
1380        -variable  viewoptions.mat.transp
1381        ttk::entry $f.ent5 -textvariable viewoptions.mat.transp -validate focus -width 4 \
1382            -validatecommand " Ng_SetVisParameters; redraw;my_validate %W [$f.scale5 cget -from] [$f.scale5 cget -to] %P 2" \
1383            -invalidcommand "my_invalid %W;Ng_SetVisParameters; redraw;"
1384
1385
1386        grid $f.scale4 $f.ent4 $f.lab4 -sticky nw -padx 4 -pady 8
1387        grid $f.scale5 $f.ent5 $f.lab5 -sticky nw -padx 4 -pady 8
1388        grid anchor $f center
1389        #$f.lab2 $f.scale2 $f.lab3 $f.scale3 $f.lab4 $f.scale4 $f.lab5 $f.scale5
1390
1391
1392
1393
1394
1395	# edges options
1396	set f $w.nb.edges
1397        ttk::labelframe $f.main -text "Edge viewing options" -relief groove -borderwidth 3
1398        pack $f.main -fill x -pady 15
1399        set f $f.main
1400        ttk::frame $f.helper
1401        pack $f.helper -anchor center
1402        set f $f.helper
1403	ttk::checkbutton $f.showedges -text "Show Edges" \
1404	    -variable viewoptions.drawededges \
1405	    -command { Ng_SetVisParameters; redraw }
1406	ttk::checkbutton $f.showpoints -text "Show Points" \
1407	    -variable viewoptions.drawedpoints \
1408	    -command { Ng_SetVisParameters; redraw }
1409	ttk::checkbutton $f.showpointnrs -text "Show Points Nrs" \
1410	    -variable viewoptions.drawedpointnrs \
1411	    -command { Ng_SetVisParameters; redraw }
1412	ttk::checkbutton $f.showtang -text "Show CP Tangents" \
1413	    -variable viewoptions.drawedtangents \
1414	    -command { Ng_SetVisParameters; redraw }
1415	ttk::checkbutton $f.drawedgenrs -text "Show Edge Nrs" \
1416	    -variable viewoptions.drawededgenrs \
1417	    -command { Ng_SetVisParameters; redraw }
1418
1419	pack $f.showedges $f.showpoints $f.showpointnrs $f.showtang $f.drawedgenrs -anchor w
1420        set f $w.nb.edges
1421        ttk::labelframe $f.main1 -text "Center point" -relief groove -borderwidth 3
1422        pack $f.main1 -fill x -pady 15
1423        set f $f.main1
1424	ttk::frame $f.center
1425	pack $f.center -anchor center
1426	ttk::button $f.center.btn -text "Set Center Point" \
1427	    -command { Ng_SetVisParameters; Ng_Center; redraw }
1428	ttk::entry $f.center.ent -width 5 -textvariable viewoptions.centerpoint -validate focus \
1429            -validatecommand "my_validate %W 0 1e9 %P 0" \
1430            -invalidcommand "my_invalid %W"
1431	grid $f.center.ent $f.center.btn -sticky nw -padx 4
1432
1433
1434
1435	#ttk::frame $f.f1
1436	#pack $f.f1 -pady 5 -anchor center
1437	ttk::label $f.center.lab1 -text "SpecPoint Veclen"
1438	ttk::entry $f.center.ent1 -width 5 -textvariable viewoptions.specpointvlen -validate focus \
1439            -validatecommand "my_validate %W 0 1e9 %P 4" \
1440            -invalidcommand "my_invalid %W"
1441	grid $f.center.ent1 $f.center.lab1 -sticky nw -padx 4
1442
1443
1444
1445
1446	# misc options
1447	set f $w.nb.misc
1448
1449	ttk::labelframe $f.point -relief groove -borderwidth 3 -text "Special point"
1450
1451	ttk::frame $f.point.dp
1452
1453	ttk::checkbutton $f.point.dp.drawpoint -text "Draw Point" \
1454	    -variable viewoptions.drawspecpoint \
1455	    -command { Ng_SetVisParameters; redraw }
1456
1457	ttk::entry $f.point.dp.px -width 8 -textvariable viewoptions.specpointx -validate focus \
1458            -validatecommand "my_validate %W -1e9 1e9 %P 10" \
1459            -invalidcommand "my_invalid %W"
1460	ttk::entry $f.point.dp.py -width 8 -textvariable viewoptions.specpointy -validate focus \
1461            -validatecommand "my_validate %W -1e9 1e9 %P 10" \
1462            -invalidcommand "my_invalid %W"
1463	ttk::entry $f.point.dp.pz -width 8 -textvariable viewoptions.specpointz -validate focus \
1464            -validatecommand "my_validate %W -1e9 1e9 %P 10" \
1465            -invalidcommand "my_invalid %W"
1466
1467	grid $f.point.dp.drawpoint $f.point.dp.px $f.point.dp.py $f.point.dp.pz -sticky nw -padx 4;# -side left
1468
1469
1470
1471	ttk::checkbutton $f.point.dp.center -text "Use as Center" \
1472	    -variable viewoptions.usecentercoords \
1473	    -command {
1474		if { ${viewoptions.usecentercoords} } {
1475		    set viewoptions.centerx ${viewoptions.specpointx}
1476		    set viewoptions.centery ${viewoptions.specpointy}
1477		    set viewoptions.centerz ${viewoptions.specpointz}
1478		    Ng_SetVisParameters; Ng_Center
1479		    redraw
1480		} {
1481		    Ng_SetVisParameters
1482		}
1483
1484
1485	    }
1486
1487	grid $f.point.dp.center -sticky nw -padx 4
1488	pack $f.point.dp
1489	pack $f.point -fill x -ipady 3 -pady 15
1490
1491
1492
1493	ttk::frame $w.bu
1494	pack $w.bu -fill x -ipady 3
1495
1496
1497	ttk::button $w.bu.done -text "Done" -command {
1498	    Ng_SetVisParameters;
1499	    redraw
1500	    destroy .viewopts_dlg
1501	}
1502	ttk::button $w.bu.apply -text "Apply" -command {
1503	    Ng_SetVisParameters;
1504	    redraw
1505	}
1506	pack $w.bu.apply $w.bu.done -expand yes -side left
1507
1508	wm withdraw $w
1509	wm geom $w +100+100
1510	wm deiconify $w
1511	wm title $w "Viewing options"
1512	focus $w
1513    }
1514}
1515
1516
1517
1518proc clipplanecommand { { optionalvar 0 } } {
1519    Ng_SetVisParameters
1520    after idle redraw
1521}
1522
1523
1524set clippingdialog_pop1 0
1525set clippingdialog_pop2 0
1526set clippingdialog_pop3 0
1527set clippingdialog_pop4 0
1528
1529
1530#
1531#
1532#  clipping dialog
1533#
1534#
1535proc clippingdialog { } {
1536
1537    global clippingdialog_pop1
1538    global clippingdialog_pop2
1539    global clippingdialog_pop3
1540    global clippingdialog_pop4
1541    set clippingdialog_pop1 1
1542    set clippingdialog_pop2 1
1543    set clippingdialog_pop3 1
1544    set clippingdialog_pop4 1
1545
1546    set w .clipping_dlg
1547
1548    if {[winfo exists .clipping_dlg] == 1} {
1549
1550	wm withdraw $w
1551	wm deiconify $w
1552	focus $w
1553
1554    } {
1555	toplevel $w
1556        ttk::frame $w.background
1557        pack $w.background -fill x -fill y
1558        set w $w.background
1559        ttk::labelframe $w.main -text "Visual clipping" -relief groove -borderwidth 3
1560        pack $w.main -fill x -pady 15
1561        set w $w.main
1562	ttk::label $w.lab1 -text "Normal x"
1563	ttk::scale $w.scale1 -orient horizontal -length 300 -from -1 -to 1 \
1564            -variable  viewoptions.clipping.nx \
1565            -command "roundscale $w.scale1 2; clipplanecommand "
1566        ttk::entry $w.entry1 -width 5 -textvariable  viewoptions.clipping.nx \
1567            -validate focus -validatecommand " clipplanecommand;my_validate %W [$w.scale1 cget -from] [$w.scale1 cget -to] %P 2" \
1568            -invalidcommand "my_invalid %W; clipplanecommand"
1569
1570	ttk::label $w.lab2 -text "Normal y"
1571	ttk::scale $w.scale2 -orient horizontal -length 300 -from -1 -to 1 \
1572            -variable  viewoptions.clipping.ny \
1573            -command "roundscale $w.scale2 2; clipplanecommand "
1574        ttk::entry $w.entry2 -width 5 -textvariable  viewoptions.clipping.ny \
1575            -validate focus -validatecommand " clipplanecommand;my_validate %W [$w.scale2 cget -from] [$w.scale2 cget -to] %P 2" \
1576            -invalidcommand "my_invalid $w.entry2;clipplanecommand"
1577
1578	ttk::label $w.lab3 -text "Normal z"
1579	ttk::scale $w.scale3 -orient horizontal -length 300 -from -1 -to 1 \
1580            -variable  viewoptions.clipping.nz \
1581            -command "roundscale $w.scale3 2; clipplanecommand "
1582        ttk::entry $w.entry3 -width 5 -textvariable  viewoptions.clipping.nz \
1583            -validate focus -validatecommand " clipplanecommand;my_validate %W [$w.scale3 cget -from] [$w.scale3 cget -to] %P 2" \
1584            -invalidcommand "my_invalid %W;clipplanecommand"
1585
1586        ttk::label $w.lab4 -text "Distance"
1587	ttk::scale $w.scale4 -orient horizontal -length 300 -from -1 -to 1.001 \
1588            -variable  viewoptions.clipping.dist \
1589            -command "roundscale $w.scale4 3; clipplanecommand "
1590        ttk::entry $w.entry4 -width 5 -textvariable  viewoptions.clipping.dist \
1591            -validate focus -validatecommand " clipplanecommand;my_validate %W [$w.scale4 cget -from] [$w.scale4 cget -to] %P 3" \
1592            -invalidcommand "my_invalid %W;clipplanecommand"
1593
1594
1595        proc my_Press {w x y} {
1596            set inc [expr {([$w get $x $y] <= [$w get]) ? -1 : 1}]
1597            ttk::Repeatedly ttk::scale::Increment $w [expr 0.001*$inc]
1598
1599        }
1600        bind $w.scale4 <ButtonPress-1> { if { [string match *slider [%W identify %x %y]] == 0 } { my_Press %W %x %y;break } }
1601        bind $w.scale4 <ButtonRelease-1> {ttk::scale::Release %W %x %y}
1602
1603	ttk::label $w.lab5 -text "Additional\rDistance"
1604	ttk::scale $w.scale5 -orient horizontal -length 300 -from -1 -to 1.001 \
1605            -variable  viewoptions.clipping.dist2 \
1606            -command "roundscale $w.scale5 3; clipplanecommand "
1607        ttk::entry $w.entry5 -width 5 -textvariable  viewoptions.clipping.dist2 \
1608            -validate focus -validatecommand " clipplanecommand;my_validate %W [$w.scale5 cget -from] [$w.scale5 cget -to] %P 3" \
1609            -invalidcommand "my_invalid %W;clipplanecommand"
1610
1611        bind $w.scale5 <ButtonPress-1> { if { [string match *slider [%W identify %x %y]] == 0 } { my_Press %W %x %y;break } }
1612        bind $w.scale5 <ButtonRelease-1> {ttk::scale::Release %W %x %y}
1613
1614        ttk::label $w.clipdomainlabel -text "Clip only domain"
1615        ttk::spinbox $w.clipdomainspinb -from 0 -to 500 -increment 1 -width 3 \
1616            -textvariable viewoptions.clipping.onlydomain -validate focus \
1617            -command {clipplanecommand;} \
1618            -validatecommand "my_validatespinbox %W %P 0" \
1619            -invalidcommand "my_invalidspinbox %W"
1620
1621        ttk::label $w.donotclipdomainlabel -text "Do not clip domain"
1622        ttk::spinbox $w.donotclipdomainspinb -from 0 -to 500 -increment 1 -width 3 \
1623            -textvariable viewoptions.clipping.notdomain -validate focus \
1624            -command "clipplanecommand" \
1625            -validatecommand "my_validatespinbox %W %P 0" \
1626            -invalidcommand "my_invalidspinbox %W"
1627
1628
1629	#tixControl $w.clipdomain -label "Clip only domain" -integer true \
1630	    -variable viewoptions.clipping.onlydomain -min 0 -max 50 \
1631	    -options { entry.width 2 } \
1632	    -command { clipplanecommand; }
1633#	    -command { Ng_SetVisParameters; redraw }
1634	#tixControl $w.donotclipdomain -label "Do not clip domain" -integer true \
1635	    -variable viewoptions.clipping.notdomain -min 0 -max 50 \
1636	    -options { entry.width 2 } \
1637	    -command { clipplanecommand; }
1638#	    -command { Ng_SetVisParameters; redraw }
1639
1640	grid $w.scale1 $w.entry1 $w.lab1 -sticky nw -padx 4 -pady 14
1641        grid $w.scale2 $w.entry2 $w.lab2 -sticky nw -padx 4 -pady 14
1642        grid $w.scale3 $w.entry3 $w.lab3 -sticky nw -padx 4 -pady 14
1643        grid $w.scale4 $w.entry4 $w.lab4 -sticky nw -padx 4 -pady 14
1644        grid $w.scale5 $w.entry5 $w.lab5 -sticky w -padx 4 -pady 14
1645        grid $w.clipdomainlabel -sticky ne -padx 4 -pady 14
1646        grid $w.clipdomainspinb -sticky nw -padx 4 -pady 14 -column 1 -row 5
1647        grid $w.donotclipdomainlabel -sticky ne -padx 4 -pady 14
1648        grid $w.donotclipdomainspinb -sticky nw -padx 4 -pady 14 -column 1 -row 6
1649        grid anchor $w center
1650        #pack $w.lab2 $w.scale2 $w.lab3 $w.scale3 $w.lab4 $w.scale4 $w.lab5 $w.scale5 $w.clipdomain $w.donotclipdomain
1651
1652	set w .clipping_dlg.background.main
1653	ttk::checkbutton $w.cb1 -text "Enable clipping" \
1654	    -variable viewoptions.clipping.enable \
1655	    -command { Ng_SetVisParameters; redraw }
1656
1657	grid  $w.cb1 -columnspan 2 -sticky ne
1658
1659
1660
1661	ttk::frame $w.bu
1662#	pack $w.bu -fill x
1663	grid $w.bu;# -fill x -ipady 3
1664
1665	ttk::button $w.cancle -text "Done" -command "destroy .clipping_dlg"
1666	grid $w.cancle -columnspan 3 -pady 16
1667
1668	set w .clipping_dlg
1669	wm withdraw $w
1670	wm geom $w +100+100
1671	wm deiconify $w
1672	wm title $w "Clipping Plane"
1673	#    grab $w
1674	focus $w
1675
1676#	$w.scale1 configure -command { puts "call1b"; Ng_SetVisParameters; redraw }
1677#	puts "after"
1678
1679	clipplanecommand
1680    }
1681}
1682
1683
1684
1685
1686
1687#
1688#  refinement dialog
1689#
1690#
1691proc refinementdialog { } {
1692
1693    set w .refinement_dlg
1694
1695    if {[winfo exists .refinement_dlg] == 1} {
1696	wm withdraw $w
1697	wm deiconify $w
1698	focus $w
1699    } {
1700
1701	toplevel $w
1702
1703	#ttk::labelframe $w.main -text "Refinement options" -relief groove -borderwidth 3
1704        #pack $w.main -fill x -pady 15
1705        #set w $w.main
1706	# tixControl $w.meshsize -label "max mesh-size: " -integer false \
1707	    # -variable options.meshize -min 1e-6 -max 1e6 \
1708	    # -options {
1709		# entry.width 6
1710		# label.width 25
1711		# label.anchor e
1712	    # }
1713
1714	# pack $w.meshsize -anchor e
1715
1716	global localh
1717	set localh 1
1718	# tixControl $w.loch -label "local mesh-size: " -integer false \
1719	    # -variable localh -min 1e-6 -max 1e6 \
1720	    # -options {
1721		# entry.width 6
1722		# label.width 25
1723		# label.anchor e
1724	    # }
1725
1726	# pack $w.loch -anchor e
1727
1728	ttk::frame $w.meshsize
1729
1730    ttk::label $w.meshsize.l1 -text "max mesh-size: "
1731    ttk::spinbox $w.meshsize.sp1 -from 1e-6 -to 1e6 -textvariable options.meshsize -validate focus -validatecommand "my_validatespinbox %W %P 4" \
1732	    -invalidcommand "my_invalidspinbox %W" -width 6 -increment 0.1
1733    #pack $w.meshsize.l1 $w.meshsize.sp1  -fill x -side left
1734
1735	ttk::frame $w.meshsizeloc
1736    #pack $w.meshsize -anchor e
1737    #pack $w.meshsizeloc -anchor e
1738    ttk::label $w.meshsizeloc.l1 -text "local mesh-size: "
1739    ttk::spinbox $w.meshsizeloc.sp1 -from 1e-6 -to 1e6 -textvariable localh -validate focus -validatecommand "my_validatespinbox %W %P 4" \
1740	    -invalidcommand "my_invalidspinbox %W" -width 6 -increment 0.1
1741    #pack $w.meshsizeloc.l1 $w.meshsizeloc.sp1  -expand yes -fill x
1742    pack $w.meshsize
1743    pack $w.meshsizeloc
1744    grid $w.meshsize.l1 $w.meshsize.sp1
1745    grid $w.meshsizeloc.l1 $w.meshsizeloc.sp1
1746
1747
1748	ttk::button $w.restface -text "Restrict H at face"  \
1749	    -command {
1750		.refinement_dlg.meshsize invoke
1751		.refinement_dlg.loch invoke
1752		Ng_RestrictH face $localh
1753	    }
1754	ttk::button $w.restedge -text "Restrict H at edge"  \
1755	    -command {
1756		.refinement_dlg.meshsize invoke
1757		.refinement_dlg.loch invoke
1758		Ng_RestrictH edge $localh
1759	    }
1760	ttk::button $w.restelement -text "Restrict H at element"  \
1761	    -command {
1762		.refinement_dlg.meshsize invoke
1763		.refinement_dlg.loch invoke
1764		Ng_RestrictH element $localh
1765	    }
1766	ttk::button $w.restpoint -text "Restrict H at point"  \
1767	    -command {
1768		.refinement_dlg.meshsize invoke
1769		.refinement_dlg.loch invoke
1770		Ng_RestrictH point $localh
1771	    }
1772
1773
1774	pack $w.restface $w.restedge $w.restelement $w.restpoint
1775
1776
1777
1778	ttk::button $w.anisoedge -text "Declare Anisotropic edge"  \
1779	    -command {
1780		Ng_Anisotropy edge
1781	    }
1782	pack $w.anisoedge
1783
1784
1785	frame $w.bu
1786	pack $w.bu -fill x -ipady 3
1787
1788
1789	ttk::button $w.bu.cancle -text "Done" -command "destroy .refinement_dlg"
1790	ttk::button $w.bu.refine -text "Refine"  \
1791	    -command {
1792#		Ng_BisectCopyMesh;
1793		set oldnp 0; set newnp $status_np;
1794		while { $oldnp < $newnp } {
1795		    set level [expr $level+1]
1796		    Ng_Bisect;
1797		    Ng_HighOrder ${options.elementorder}
1798		    Ng_ReadStatus;
1799		redraw;
1800		    set oldnp $newnp
1801		    set newnp $status_np
1802		    puts "oldnp $oldnp newnp $newnp"
1803		}
1804	    }
1805	ttk::button $w.bu.zrefine -text "Z-Refine"  \
1806	    -command { Ng_ZRefinement; Ng_ReadStatus; redraw; }
1807
1808	pack $w.bu.zrefine $w.bu.refine $w.bu.cancle  -expand yes -side left
1809
1810	wm withdraw $w
1811	wm geom $w +100+100
1812	wm deiconify $w
1813	wm title $w "Select Refinement"
1814	focus $w
1815    }
1816}
1817
1818
1819
1820
1821#
1822#  boundcondessing dialog
1823#
1824#
1825proc bcpropdialog { } {
1826
1827    set w .bcprop_dlg
1828
1829    if {[winfo exists .bcprop_dlg] == 1} {
1830	wm withdraw $w
1831	wm deiconify $w
1832    } {
1833	toplevel $w
1834
1835	ttk::frame $w.face  -borderwidth 3
1836	pack $w.face -fill x
1837	ttk::label $w.face.lab -text "face index:"
1838	ttk::label $w.face.ent -text 1
1839	ttk::button $w.face.next -text "next" -command {
1840	    set w .bcprop_dlg;
1841	    set facenr [$w.face.ent cget -text]
1842	    if {$facenr == [Ng_BCProp getnfd]} {
1843		set facenr 1
1844	    } {
1845		set facenr [expr $facenr + 1]
1846	    }
1847	    $w.face.ent configure -text $facenr
1848	    Ng_BCProp setactive $facenr
1849	    set bcnr [Ng_BCProp getbc $facenr]
1850	    $w.bc.ent delete 0 end
1851	    $w.bc.ent insert 0 $bcnr
1852
1853	    redraw
1854	}
1855	ttk::button $w.face.prev -text "prev" -command {
1856	    set w .bcprop_dlg;
1857	    set facenr [$w.face.ent cget -text]
1858	    if {$facenr == 1} {
1859		set facenr [Ng_BCProp getnfd]
1860	    } {
1861		set facenr [expr $facenr - 1]
1862	    }
1863	    $w.face.ent configure -text $facenr
1864	    Ng_BCProp setactive $facenr
1865	    set bcnr [Ng_BCProp getbc $facenr]
1866	    $w.bc.ent delete 0 end
1867	    $w.bc.ent insert 0 $bcnr
1868
1869	    redraw
1870	}
1871
1872
1873	pack $w.face.lab $w.face.ent $w.face.prev $w.face.next  -side left
1874
1875	ttk::frame $w.bc  -borderwidth 3
1876	pack $w.bc -fill x
1877	ttk::label $w.bc.lab -text "bc property:"
1878	entry $w.bc.ent -width 5 -relief sunken
1879	ttk::button $w.bc.but -text "change" -command {
1880	    set w .bcprop_dlg;
1881	    Ng_BCProp setbc [$w.face.ent cget -text] [$w.bc.ent get];
1882	}
1883	ttk::button $w.bc.but2 -text "all" -command {
1884	    set w .bcprop_dlg;
1885	    Ng_BCProp setall [$w.bc.ent get];
1886	}
1887	pack $w.bc.lab $w.bc.ent $w.bc.but $w.bc.but2 -side left  -expand yes
1888
1889	ttk::frame $w.bcname  -borderwidth 3
1890	pack $w.bcname -fill x
1891	ttk::label $w.bcname.lab -text "bc name:"
1892	ttk::label $w.bcname.ent -text "-"
1893	pack $w.bcname.lab $w.bcname.ent -side left  -expand yes
1894
1895
1896	ttk::frame $w.bu
1897	pack $w.bu -fill x -ipady 3
1898
1899	ttk::button $w.bu.close -text "Close" -command { destroy .bcprop_dlg }
1900
1901	pack $w.bu.close  -expand yes -side left
1902
1903	wm withdraw $w
1904	wm geom $w +100+100
1905	wm deiconify $w
1906	wm title $w "Boundary Conditions"
1907    }
1908
1909    focus $w
1910
1911    set facenr [Ng_BCProp getactive]
1912    $w.face.ent configure -text $facenr
1913
1914    set bcnr [Ng_BCProp getbc $facenr]
1915    $w.bc.ent delete 0 end
1916    $w.bc.ent insert 0 $bcnr
1917
1918    set bcname [Ng_BCProp getbcname $facenr]
1919    $w.bcname.ent configure -text $bcname
1920
1921}
1922
1923
1924
1925
1926#
1927# Philippose - 25/07/2010
1928# Display the face colours currently
1929# available in the mesh
1930#
1931proc currmeshcoloursdialog { } {
1932
1933    set w .currmeshcolours_dlg
1934
1935    if {[winfo exists .currmeshcolours_dlg] == 1} {
1936	wm withdraw $w
1937	wm deiconify $w
1938	focus $w
1939    } {
1940	toplevel $w
1941
1942	global facecolslist
1943
1944	frame $w.facecols -borderwidth 3
1945
1946	listbox $w.facecols.list -yscroll "$w.facecols.scroll set" -selectmode single -setgrid 1 -width 32 -height 12
1947	scrollbar $w.facecols.scroll -command "$w.facecols.list yview"
1948	pack $w.facecols.scroll -side right -fill y
1949	pack $w.facecols.list -side left -expand yes -fill both
1950
1951	Ng_CurrentFaceColours getcolours facecolslist
1952	set i 1
1953	foreach el $facecolslist {
1954	    set hel [format "%d: (%.4f %.4f %.4f)" $i [ lindex $el 0 ] [ lindex $el 1 ] [ lindex $el 2 ]]
1955	    incr i
1956	    $w.facecols.list insert end $hel }
1957
1958	frame $w.bu1 -borderwidth 3
1959    ttk::button $w.bu1.showonly -text "show only" -command {
1960        Ng_CurrentFaceColours showonly [.currmeshcolours_dlg.facecols.list curselection]
1961        redraw
1962    }
1963    ttk::button $w.bu1.hideonly -text "hide only" -command {
1964        Ng_CurrentFaceColours hideonly [.currmeshcolours_dlg.facecols.list curselection]
1965        redraw
1966    }
1967    ttk::button $w.bu1.showalso -text "show" -command {
1968        Ng_CurrentFaceColours showalso [.currmeshcolours_dlg.facecols.list curselection]
1969        redraw
1970    }
1971    ttk::button $w.bu1.hidealso -text "hide" -command {
1972        Ng_CurrentFaceColours hidealso [.currmeshcolours_dlg.facecols.list curselection]
1973        redraw
1974    }
1975    pack $w.bu1.showonly $w.bu1.hideonly $w.bu1.showalso $w.bu1.hidealso -expand yes -fill x -padx 2 -pady 2 -side left
1976
1977    frame $w.bu2
1978    ttk::button $w.bu2.showall -text "show all" -command {
1979        Ng_CurrentFaceColours showall
1980        redraw
1981    }
1982    ttk::button $w.bu2.hideall -text "hide all" -command {
1983        Ng_CurrentFaceColours hideall
1984        redraw
1985    }
1986    pack $w.bu2.showall $w.bu2.hideall -expand yes -fill x -padx 2 -pady 2 -side left
1987
1988    frame $w.bu3
1989	ttk::button $w.bu3.close -text "close" -command {
1990	    destroy .currmeshcolours_dlg
1991	}
1992    pack $w.bu3.close -expand yes -fill x -pady 3 -side right
1993
1994
1995	pack $w.facecols -side top -expand yes -fill x -fill y
1996    pack $w.bu3 -side bottom
1997    pack $w.bu2 -side bottom
1998    pack $w.bu1 -expand yes -fill x -side left
1999
2000	wm withdraw $w
2001	wm geom $w +100+100
2002	wm deiconify $w
2003	wm title $w "Inspect Mesh Colours"
2004	focus $w
2005    }
2006}
2007
2008
2009
2010
2011#
2012#  Philippose - 30/01/2009
2013#  Local Surface Mesh Size Selection
2014#  (Currently only supports OCC Geometry)
2015#
2016#
2017proc surfacemeshsizedialog { } {
2018
2019    set w .surfacemeshsize_dlg
2020
2021    if {[winfo exists .surfacemeshsize_dlg] == 1} {
2022	wm withdraw $w
2023	wm deiconify $w
2024    } {
2025	toplevel $w
2026
2027	frame $w.face  -borderwidth 3
2028	pack $w.face -fill x -padx 5
2029	ttk::label $w.face.lab -text "face index:"
2030	ttk::label $w.face.ent -text 1
2031	ttk::button $w.face.next -text "next" -command {
2032	    set w .surfacemeshsize_dlg;
2033	    set facenr [$w.face.ent cget -text]
2034	    if {$facenr == [Ng_SurfaceMeshSize getnfd]} {
2035		set facenr 1
2036	    } {
2037		set facenr [expr $facenr + 1]
2038	    }
2039	    $w.face.ent configure -text $facenr
2040	    Ng_SurfaceMeshSize setactive $facenr
2041	    set surfms [Ng_SurfaceMeshSize getsurfms $facenr]
2042	    $w.sms.ent delete 0 end
2043	    $w.sms.ent insert 0 $surfms
2044
2045	    redraw
2046	}
2047	ttk::button $w.face.prev -text "prev" -command {
2048	    set w .surfacemeshsize_dlg;
2049	    set facenr [$w.face.ent cget -text]
2050	    if {$facenr == 1} {
2051		set facenr [Ng_SurfaceMeshSize getnfd]
2052	    } {
2053		set facenr [expr $facenr - 1]
2054	    }
2055	    $w.face.ent configure -text $facenr
2056	    Ng_SurfaceMeshSize setactive $facenr
2057	    set surfms [Ng_SurfaceMeshSize getsurfms $facenr]
2058	    $w.sms.ent delete 0 end
2059	    $w.sms.ent insert 0 $surfms
2060
2061	    redraw
2062	}
2063
2064
2065	pack $w.face.lab $w.face.ent $w.face.prev $w.face.next  -side left
2066
2067	frame $w.sms  -borderwidth 3
2068	pack $w.sms -fill x
2069	ttk::label $w.sms.lab -text "max mesh size:"
2070	entry $w.sms.ent -width 8 -relief sunken
2071	ttk::button $w.sms.but -text "change" -command {
2072	    set w .surfacemeshsize_dlg;
2073	    Ng_SurfaceMeshSize setsurfms [$w.face.ent cget -text] [$w.sms.ent get];
2074	}
2075	ttk::button $w.sms.but2 -text "all" -command {
2076	    set w .surfacemeshsize_dlg;
2077	    Ng_SurfaceMeshSize setall [$w.sms.ent get];
2078	}
2079	pack $w.sms.lab $w.sms.ent $w.sms.but $w.sms.but2 -side left -padx 5 -expand yes
2080
2081	frame $w.bu
2082	pack $w.bu -fill x -ipady 3
2083
2084	ttk::button $w.bu.close -text "Close" -command { destroy .surfacemeshsize_dlg }
2085
2086	pack $w.bu.close  -expand yes -side left
2087
2088	wm withdraw $w
2089	wm geom $w +100+100
2090	wm deiconify $w
2091	wm title $w "Edit Surface Mesh Size"
2092    }
2093
2094    focus $w
2095
2096    set facenr [Ng_SurfaceMeshSize getactive]
2097    $w.face.ent configure -text $facenr
2098
2099    set surfms [Ng_SurfaceMeshSize getsurfms $facenr]
2100    $w.sms.ent delete 0 end
2101    $w.sms.ent insert 0 $surfms
2102
2103}
2104
2105
2106
2107
2108#
2109#  METIS dialog
2110#
2111#
2112proc METISdialog { } {
2113
2114    set w .metis_dlg
2115    set w.parts 64
2116
2117    if {[winfo exists .metis_dlg] == 1} {
2118	wm withdraw $w
2119	wm deiconify $w
2120    } {
2121	toplevel $w
2122
2123	frame $w.a -borderwidth 0
2124	frame $w.b -borderwidth 0
2125	pack $w.a $w.b
2126
2127	ttk::label $w.a.lab -text "Number of partitions:"
2128	entry $w.a.ent -textvariable w.parts -width 4 -relief sunken
2129
2130	ttk::button $w.b.start -text "Start METIS" -command {
2131	    Ng_Metis ${w.parts}
2132	    redraw
2133	}
2134	ttk::button $w.b.cancel -text "Cancel" -command { destroy .metis_dlg }
2135	pack $w.a.lab $w.a.ent -side left  -expand yes
2136	pack $w.b.start $w.b.cancel -side left
2137
2138
2139	wm withdraw $w
2140	wm geom $w +100+100
2141	wm deiconify $w
2142	wm title $w "METIS Partitioning"
2143	focus $w
2144
2145    }
2146}
2147
2148
2149
2150#
2151#  STL dialog
2152#
2153proc stloptionsdialog { } {
2154
2155    set w .stlopts_dlg
2156
2157    if {[winfo exists .stlopts_dlg] == 1} {
2158	wm withdraw $w
2159	wm deiconify $w
2160	focus $w
2161    } {
2162	toplevel $w
2163
2164        pack [ttk::notebook $w.nb]  -fill both -fill both -side top
2165	# tixNoteBook $w.nb -ipadx 6 -ipady 6
2166	#	$w config -bg gray
2167	#	$w.nb subwidget nbframe config -backpagecolor gray
2168
2169	# Create the two tabs on the notebook. The -underline option
2170	# puts a underline on the first character of the labels of the tabs.
2171	# Keyboard accelerators will be defined automatically according
2172	# to the underlined character.
2173	#
2174
2175# 	$w.nb add chartopt -label "Chart Options" -underline 0
2176# 	#$w.nb add meshsize   -label "Mesh Size"   -underline 0
2177# 	pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top
2178
2179
2180# 	set f [$w.nb subwidget chartopt]
2181
2182
2183# 	label $f.lab1 -text "Yellow Edges Angle ()"
2184# 	scale $f.scale1 -orient horizontal -length 300 \
2185# 	    -from 0 -to 90 -resolution 1  -tickinterval 10 \
2186# 	    -variable  stloptions.yangle
2187
2188# 	pack $f.lab1 $f.scale1
2189
2190# 	label $f.lab2e -text "Edge Corner Angle ()"
2191# 	scale $f.scale2e -orient horizontal -length 360 -from 0 -to 180 \
2192# 	    -resolution 1  -tickinterval 20 \
2193# 	    -variable  stloptions.edgecornerangle
2194# 	pack $f.lab2e $f.scale2e
2195
2196# 	label $f.lab2 -text "Chart Angle ()"
2197# 	scale $f.scale2 -orient horizontal -length 360 -from 0 -to 180 \
2198# 	    -resolution 1  -tickinterval 20 \
2199# 	    -variable  stloptions.chartangle
2200# 	pack $f.lab2 $f.scale2
2201
2202# 	label $f.lab2b -text "Outer Chart Angle ()"
2203# 	scale $f.scale2b -orient horizontal -length 360 -from 0 -to 180 \
2204# 	    -resolution 1  -tickinterval 20 \
2205# 	    -variable  stloptions.outerchartangle
2206# 	pack $f.lab2b $f.scale2b
2207
2208#	frame $f.r4
2209#	pack $f.r4 -anchor w
2210#	scale $f.r4.sc -orient horizontal -length 200 -from 0.1 -to 10 \
2211#	    -resolution 0.1 -variable stloptions.resthatlasfac
2212#	checkbutton $f.r4.bu -text "Restrict h for Calc Atlas (Faster)" \
2213#	    -variable stloptions.resthatlasenable
2214#	pack $f.r4.sc $f.r4.bu -side left
2215
2216
2217	#set f [$w.nb subwidget meshsize]
2218
2219
2220
2221#    checkbutton $w.seat -text "Use Searchtrees" \
2222#	-variable stloptions.usesearchtree
2223#   pack $w.seat
2224
2225
2226
2227
2228	frame $w.bu
2229#    pack $w.bu
2230	pack $w.bu -fill x -ipady 3
2231
2232# -fill x
2233
2234    ttk::button $w.bu.apply -text "Apply" -command { redraw; Ng_GenerateMesh 1 2}
2235	ttk::button $w.bu.cancle -text "Done" -command { destroy .stlopts_dlg }
2236    pack $w.bu.cancle  $w.bu.apply  -side left -expand yes
2237
2238
2239    wm withdraw $w
2240    wm geom $w +100+100
2241    wm deiconify $w
2242	wm title $w "STL Options"
2243#    grab $w
2244	focus $w
2245    }
2246}
2247
2248proc stldoctordialog { } {
2249    Ng_STLDoctor
2250    set wd .stldoctor_dlg
2251
2252    if {[winfo exists .stldoctor_dlg] == 1} {
2253
2254	wm withdraw $wd
2255	wm deiconify $wd
2256	focus $wd
2257    } {
2258
2259    toplevel $wd
2260    pack [ttk::notebook $wd.nb] -fill both -fill both -side top
2261    $wd.nb add [ttk::frame $wd.nb.general] -text "General" -underline 0
2262    $wd.nb add [ttk::frame $wd.nb.topology] -text "Edit Topology" -underline 5
2263    $wd.nb add [ttk::frame $wd.nb.edges] -text "Edit Edges" -underline 5
2264    $wd.nb add [ttk::frame $wd.nb.normals] -text "Edit Normals" -underline 5
2265    $wd.nb add [ttk::frame $wd.nb.advanced] -text "Advanced" -underline 0
2266
2267    # tixNoteBook $wd.nb -ipadx 6 -ipady 6
2268    # $wd.nb add general -label "General" -underline 0
2269    # $wd.nb add topology -label "Edit Topology"  -underline 5
2270    # $wd.nb add edges -label "Edit Edges"   -underline 5
2271    # $wd.nb add normals -label "Edit Normals"   -underline 5
2272    # $wd.nb add advanced -label "Advanced"   -underline 0
2273    # pack $wd.nb -expand yes -fill both -padx 5 -pady 5 -side top
2274
2275
2276    # GENERAL *****************************
2277
2278    set f $wd.nb.general
2279    ttk::frame $f.selectframe -borderwidth 0
2280    #ttk::frame $f.show
2281    #pack $f.show -fill x
2282    ttk::checkbutton $f.selectframe.showtrias -text "Show STL-Triangles" \
2283	-variable stloptions.showtrias -command { Ng_SetVisParameters; redraw }
2284    #pack $f.selectframe.showtrias -anchor w
2285
2286    ttk::checkbutton $f.selectframe.showfilledtrias -text "Show Filled Triangles" \
2287	-variable stloptions.showfilledtrias -command { Ng_SetVisParameters; redraw }
2288    #pack $f.show.showfilledtrias -anchor w
2289
2290    set selmodevals { 0 1 2 3 4 }
2291    set selmodelabs(0) "triangle"
2292    set selmodelabs(1) "edge"
2293    set selmodelabs(2) "point"
2294    set selmodelabs(3) "line"
2295    set selmodelabs(4) "line cluster"
2296
2297    # tixOptionMenu $f.selmode -label "Double Click selects :" \
2298	# -options {
2299	    # label.width  19
2300	    # label.anchor e
2301	    # menubutton.width 15
2302	# }
2303
2304    # foreach selmodev $selmodevals {
2305	# $f.selmode add command $selmodev -label $selmodelabs($selmodev)
2306    # }
2307    # $f.selmode config -variable stldoctor.selectmode
2308    # $f.selmode config -command { Ng_STLDoctor }
2309    global stldoctor.selectmode
2310    # pack $f.selmode
2311
2312    ttk::label  $f.selectframe.dblcsellab -text "Double Click selects : "
2313    ttk::menubutton $f.selectframe.dblcselbut -menu $f.selectframe.dblcselmen -text "triangle" -width 16
2314    menu $f.selectframe.dblcselmen  -tearoff 0
2315	foreach selmode { 0 1 2 3 4 } {
2316	    $f.selectframe.dblcselmen add command -label $selmodelabs($selmode) \
2317                -command "set stldoctor.selectmode $selmode ; Ng_STLDoctor ; $f.selectframe.dblcselbut configure -text \"$selmodelabs($selmode)\""
2318	}
2319    $f.selectframe.dblcselmen invoke $selmodelabs(${stldoctor.selectmode})
2320    pack $f.selectframe
2321    grid $f.selectframe.showtrias -sticky nw
2322    grid $f.selectframe.showfilledtrias -sticky nw
2323    grid $f.selectframe.dblcsellab $f.selectframe.dblcselbut -sticky nw
2324
2325
2326
2327
2328    ttk::frame $f.sm
2329    pack $f.sm -fill x
2330    ttk::checkbutton $f.sm.bu -text "select with mouse" \
2331	-variable stldoctor.selectwithmouse
2332    pack $f.sm.bu
2333
2334    ttk::frame $f.st -relief groove -borderwidth 3
2335    pack $f.st -fill x
2336    ttk::label $f.st.lab -text "Select triangle by number";
2337    ttk::entry $f.st.ent -width 5 \
2338	-textvariable stldoctor.selecttrig
2339    pack $f.st.ent $f.st.lab -side left -expand yes
2340
2341    ttk::frame $f.vc -relief groove -borderwidth 3
2342    pack $f.vc -fill x
2343    ttk::checkbutton $f.vc.bu -text "show vicinity" \
2344	-variable stldoctor.showvicinity \
2345	-command {Ng_STLDoctor vicinity; redraw}
2346    ttk::label $f.vc.lab -text "vicinity size";
2347
2348    #scale $f.vc.sc -orient horizontal -length 200 -from 0 -to 200 \
2349	-resolution 1 -variable stldoctor.vicinity \
2350	-command { Ng_STLDoctor vicinity; redraw }
2351    ttk::frame $f.vc.sc
2352    ttk::scale $f.vc.sc.scale -orient horizontal -length 200 -from 0 -to 200 \
2353    -variable stldoctor.vicinity -takefocus 0 -command "Ng_STLDoctor vicinity; redraw; roundscale $f.vc.sc.scale 0"
2354    ttk::entry $f.vc.sc.entry -textvariable stldoctor.vicinity -width 3 \
2355    -validatecommand "Ng_STLDoctor vicinity; redraw; my_validate %W [$f.vc.sc.scale cget -from] [$f.vc.sc.scale cget -to] %P 0" \
2356    -invalidcommand "my_invalid %W;Ng_STLDoctor vicinity; redraw;" -validate focus
2357    ttk::label $f.vc.sc.lab -text "vicinity size"
2358	grid $f.vc.sc.scale $f.vc.sc.entry $f.vc.sc.lab -sticky nw -padx 4
2359    pack $f.vc.bu $f.vc.lab $f.vc.sc -expand yes
2360
2361    ttk::frame $f.ge -relief groove -borderwidth 0
2362    pack $f.ge -expand yes
2363    ttk::button $f.ge.neighbourangles -text "calc neighbourangles" -command {Ng_STLDoctor neighbourangles}
2364    ttk::button $f.ge.showcoords -text "show coords of touched triangle" -command {Ng_STLDoctor showcoords}
2365    ttk::button $f.ge.moveptm -text "move point to middle of trianglepoints" -command {Ng_STLDoctor movepointtomiddle; redraw}
2366    ttk::button $f.ge.destroy0trigs -text "destroy 0-volume triangles" -command {Ng_STLDoctor destroy0trigs}
2367    grid $f.ge.neighbourangles -sticky nw -padx 4 -pady 4
2368    grid $f.ge.showcoords -sticky nw -padx 4 -pady 4
2369    grid $f.ge.moveptm -sticky nw -padx 4 -pady 4
2370    grid $f.ge.destroy0trigs -sticky nw -padx 4 -pady 4
2371
2372
2373    ttk::button $f.ge.cancle -text "Done" -command {destroy .stldoctor_dlg }
2374    grid $f.ge.cancle  -sticky nw
2375
2376    # TOPOLOGY ********************
2377    set f $wd.nb.topology
2378
2379    ttk::frame $f.oc -relief groove -borderwidth 3
2380    pack $f.oc -pady 3 -ipady 3 -fill y -fill x
2381    ttk::frame $f.oc.oc1 -borderwidth 0
2382    pack $f.oc.oc1
2383    ttk::button $f.oc.oc1.bu -text "invert orientation \n of selected trig" -command {Ng_STLDoctor invertselectedtrig; redraw }
2384    ttk::button $f.oc.oc1.bu2 -text "orient after \n selected trig" -command {Ng_STLDoctor orientafterselectedtrig; redraw }
2385
2386
2387    ttk::button $f.oc.oc1.toperr -text "mark inconsistent triangles" -command {Ng_STLDoctor marktoperrortrigs; redraw }
2388    ttk::button $f.oc.oc1.deltrig -text "delete selected triangle" -command {Ng_STLDoctor deleteselectedtrig; redraw }
2389    ttk::button $f.oc.oc1.geosmooth -text "geometric smoothing" -command {Ng_STLDoctor smoothgeometry; redraw }
2390
2391    grid $f.oc.oc1.bu x $f.oc.oc1.bu2 -sticky nw -padx 4 -pady 4
2392    grid $f.oc.oc1.toperr - x -sticky nw -padx 4 -pady 4
2393    grid $f.oc.oc1.deltrig - x -sticky nw -padx 4 -pady 4
2394    grid $f.oc.oc1.geosmooth - x -sticky nw -padx 4 -pady 4
2395
2396
2397
2398
2399
2400    # EDGES ***********************
2401    set f $wd.nb.edges
2402
2403
2404    ttk::frame $f.be -relief groove -borderwidth 3
2405    pack $f.be -fill x
2406
2407    #scale $f.be.sc -orient horizontal -length 200 -from 0 -to 100 \
2408	#-resolution 0.5
2409    ttk::frame $f.be.frame
2410    pack $f.be.frame -ipady 4 -pady 4
2411    ttk::label $f.be.frame.lab -text "build edges with yellow angle:";
2412    ttk::scale $f.be.frame.scale -orient horizontal -length 200 -from 0 -to 200 \
2413    -variable stloptions.yangle -takefocus 0 -command "roundscale $f.be.frame.scale 1; Ng_SetSTLParameters; Ng_STLDoctor buildedges; redraw"
2414    ttk::entry $f.be.frame.entry -textvariable stloptions.yangle -width 5 \
2415    -validatecommand "Ng_SetSTLParameters; Ng_STLDoctor buildedges; redraw;my_validate %W [$f.be.frame.scale cget -from] [$f.be.frame.scale cget -to] %P 1" \
2416    -invalidcommand "my_invalid %W;Ng_SetSTLParameters; Ng_STLDoctor buildedges; redraw" -validate focus
2417	grid $f.be.frame.lab - -sticky nw -padx 4
2418    grid $f.be.frame.scale $f.be.frame.entry -sticky nw -padx 4
2419
2420
2421
2422    #$f.be.sc config -variable stloptions.yangle
2423    #$f.be.sc config -command { Ng_SetSTLParameters; Ng_STLDoctor buildedges; redraw }
2424    ttk::label $f.be.frame.lab2 -text "continue edges with yellow angle:";
2425#    scale $f.be.sc2 -orient horizontal -length 200 -from 0 -to 100 \
2426	-resolution 0.5
2427    ttk::scale $f.be.frame.scale2 -orient horizontal -length 200 -from 0 -to 100 \
2428    -variable stloptions.contyangle -takefocus 0 -command "roundscale $f.be.frame.scale2 1; Ng_SetSTLParameters; Ng_STLDoctor buildedges; redraw"
2429    ttk::entry $f.be.frame.entry2 -textvariable stloptions.contyangle -width 5 \
2430    -validatecommand "Ng_SetSTLParameters; Ng_STLDoctor buildedges; redraw;my_validate %W [$f.be.frame.scale2 cget -from] [$f.be.frame.scale2 cget -to] %P 1" \
2431    -invalidcommand "my_invalid %W;Ng_SetSTLParameters; Ng_STLDoctor buildedges; redraw" -validate focus
2432
2433	grid $f.be.frame.lab2 - -sticky nw -padx 4
2434    grid $f.be.frame.scale2 $f.be.frame.entry2 -sticky nw -padx 4
2435
2436    #$f.be.sc2 config -variable stloptions.contyangle
2437    #$f.be.sc2 config -command { Ng_SetSTLParameters; Ng_STLDoctor buildedges; redraw }
2438
2439
2440
2441    ttk::button $f.be.frame.buildedges -text "Build Edges" -command {Ng_STLDoctor buildedges; redraw}
2442    grid $f.be.frame.buildedges - -sticky n -padx 4 -pady 4
2443    #pack $f.be.lab $f.be.sc $f.be.lab2 $f.be.sc2 $f.be.buildedges -expand yes
2444
2445    ttk::frame $f.se -relief groove -borderwidth 3
2446    pack $f.se -fill x
2447    ttk::checkbutton $f.se.bu -text "show excluded" \
2448	-variable stldoctor.showexcluded \
2449	-command {Ng_STLDoctor; redraw}
2450    pack $f.se.bu
2451
2452    # edgeselectmode ******
2453
2454    set edgeselmodevals { 0 1 2 3 4 }
2455    set edgeselmodelabs(0) "no change"
2456    set edgeselmodelabs(1) "undefined"
2457    set edgeselmodelabs(2) "confirmed"
2458    set edgeselmodelabs(3) "candidate"
2459    set edgeselmodelabs(4) "excluded"
2460
2461    # tixOptionMenu $f.edgeselmode -label "Double Click sets edge :" \
2462	# -options {
2463	    # label.width  19
2464	    # label.anchor e
2465	    # menubutton.width 15
2466	# }
2467
2468    # foreach edgeselmodev $edgeselmodevals {
2469	# $f.edgeselmode add command $edgeselmodev -label $edgeselmodelabs($edgeselmodev)
2470    # }
2471    # $f.edgeselmode config -variable stldoctor.edgeselectmode
2472    # $f.edgeselmode config -command { Ng_STLDoctor }
2473    global stldoctor.edgeselectmode
2474    # pack $f.edgeselmode
2475
2476    ttk::frame $f.scaleframe -relief groove -borderwidth 0
2477    pack $f.scaleframe -ipadx 4 -pady 4 -expand yes
2478    ttk::label  $f.scaleframe.dblcedgelab -text "Double Click sets edge :"
2479    ttk::menubutton $f.scaleframe.dblcledgebut -menu $f.scaleframe.dblcledgem -text "coarse" -width 16
2480
2481    menu $f.scaleframe.dblcledgem  -tearoff 0
2482	foreach selectmode { 0 1 2 3 4 } {
2483	$f.scaleframe.dblcledgem add command -label $edgeselmodelabs($selectmode) \
2484    -command "set stldoctor.edgeselectmode $selectmode ; $f.scaleframe.dblcledgebut configure -text \"$edgeselmodelabs($selectmode)\""
2485	}
2486    $f.scaleframe.dblcledgem invoke $edgeselmodelabs(${stldoctor.edgeselectmode})
2487    grid $f.scaleframe.dblcedgelab $f.scaleframe.dblcledgebut -sticky n -ipadx 4
2488
2489
2490
2491
2492    # edge buttons
2493
2494    ttk::frame $f.edg -relief groove -borderwidth 3
2495    pack $f.edg -fill x -ipadx 4 -ipady 4
2496
2497#    checkbutton $f.edg.bu -text "use external edges" \
2498#	-variable stldoctor.useexternaledges \
2499#	-command {Ng_STLDoctor; redraw}
2500#   pack $f.edg.bu -expand yes
2501
2502
2503    ttk::frame $f.edg.f0
2504    pack $f.edg.f0
2505    ttk::button $f.edg.f0.confirmedge -text "confirm" -command {Ng_STLDoctor confirmedge; redraw}
2506    ttk::button $f.edg.f0.candidateedge -text "candidate" -command {Ng_STLDoctor candidateedge; redraw}
2507    ttk::button $f.edg.f0.excludeedge -text "exclude" -command {Ng_STLDoctor excludeedge; redraw}
2508    ttk::button $f.edg.f0.undefinededge -text "undefined" -command {Ng_STLDoctor undefinededge; redraw}
2509    pack $f.edg.f0.confirmedge $f.edg.f0.candidateedge $f.edg.f0.excludeedge $f.edg.f0.undefinededge  -side left
2510
2511    ttk::frame $f.edg.fa
2512    pack $f.edg.fa
2513    ttk::button $f.edg.fa.setallundefined -text "all undefined" -command {Ng_STLDoctor setallundefinededges; redraw}
2514    ttk::button $f.edg.fa.erasecandidates -text "candidates to undefined" -command {Ng_STLDoctor erasecandidateedges; redraw}
2515    pack $f.edg.fa.setallundefined $f.edg.fa.erasecandidates -side left
2516
2517
2518    ttk::frame $f.edg.fb
2519    pack $f.edg.fb
2520    ttk::button $f.edg.fb.confirmcandidates -text "candidates to confirmed" -command {Ng_STLDoctor confirmcandidateedges; redraw}
2521    ttk::button $f.edg.fb.confirmedtocandidates -text "confirmed to candidates" -command {Ng_STLDoctor confirmedtocandidateedges; redraw}
2522    pack $f.edg.fb.confirmcandidates $f.edg.fb.confirmedtocandidates -side left
2523
2524    ttk::frame $f.edg.f1
2525    ttk::frame $f.edg.f2
2526    ttk::frame $f.edg.f3
2527    ttk::frame $f.edg.f4
2528    pack $f.edg.f1 $f.edg.f2 $f.edg.f3 $f.edg.f4
2529
2530    ttk::button $f.edg.f1.exportedges -text "export edges" -command {Ng_STLDoctor exportedges}
2531    ttk::button $f.edg.f1.importedges -text "import edges" -command {Ng_STLDoctor importedges; redraw}
2532    ttk::button $f.edg.f1.saveedgedata -text "save edgedata" \
2533	-command {
2534	    set types {
2535		{"Netgen Edgedata"   {.ned} }
2536	    }
2537	    set file [tk_getSaveFile -filetypes $types -defaultextension ".ned"]
2538	    if {$file != ""} {
2539		Ng_STLDoctor saveedgedata $file
2540	}
2541    }
2542
2543    ttk::button $f.edg.f1.loadedgedata -text "load edgedata" \
2544	-command {
2545	    set types {
2546		{"Netgen Edgedata"  {.ned} }
2547	    }
2548	    set file [tk_getOpenFile -filetypes $types -defaultextension ".ned"]
2549	    if {$file != ""} {
2550		Ng_STLDoctor loadedgedata $file
2551		puts "loading done"
2552
2553		redraw
2554
2555#		wm title . [concat "NETGEN - " $file]
2556	    }
2557	}
2558
2559    ttk::button $f.edg.f1.importAVLedges -text "import AVL edges" \
2560	-command {
2561	    set types {{"Edge file"  {.edg }}}
2562
2563	    set file [tk_getOpenFile -filetypes $types -defaultextension ".edg"]
2564	    if {$file != ""} {
2565		Ng_STLDoctor importexternaledges $file;
2566	    }
2567	}
2568
2569    pack $f.edg.f1.importAVLedges $f.edg.f1.loadedgedata $f.edg.f1.saveedgedata -side left
2570
2571#    button $f.edg.f1.buildedges -text "build external edges" -command {Ng_STLDoctor buildexternaledges; redraw}
2572    ttk::frame $f.edg2 -relief groove -borderwidth 3
2573    pack $f.edg2 -fill x
2574
2575
2576#    button $f.edg2.addlonglines -text "make long lines candidates (% of diam)" -command {Ng_STLDoctor addlonglines; redraw}
2577    ttk::label $f.edg2.lab -text "length (%):"
2578    scale $f.edg2.sc -orient horizontal -length 200 -from 0 -to 100 \
2579	-resolution 0.5 \
2580        -variable stldoctor.longlinefact
2581
2582 #   button $f.edg2.deletedirtyedges -text "make dirty edges candidates" -command {Ng_STLDoctor deletedirtyedges; redraw}
2583    ttk::button $f.edg2.undoedge -text "undo last edge change" -command {Ng_STLDoctor undoedgechange; redraw}
2584
2585 #   pack $f.edg2.addlonglines $f.edg2.deletedirtyedges -expand yes
2586 #   pack $f.edg2.lab $f.edg2.sc -side left
2587    pack $f.edg2.undoedge -expand yes
2588
2589
2590
2591    # NORMALS ***********************
2592    set f $wd.nb.normals
2593
2594    ttk::frame $f.dt -relief groove -borderwidth 3
2595    pack $f.dt -fill x
2596    ttk::label $f.dt.lab -text "dirty triangle factor";
2597    ttk::entry $f.dt.ent -width 5 \
2598	-textvariable stldoctor.dirtytrigfact -validatecommand "Ng_SetSTLParameters;my_validate %W -1e9 1e9 %P 3" \
2599    -invalidcommand "my_invalid %W;Ng_SetSTLParameters" -validate focus
2600    pack $f.dt.ent $f.dt.lab -side left -expand yes -pady 8
2601
2602    ttk::frame $f.srt -relief groove -borderwidth 3
2603    pack $f.srt -fill x
2604    ttk::button $f.srt.bu -text "smooth reverted triangles geometric" -command {Ng_STLDoctor smoothrevertedtrigs; redraw }
2605    ttk::entry $f.srt.ent -width 5 \
2606	-textvariable stldoctor.smoothangle -validatecommand "Ng_SetSTLParameters;my_validate %W -1e9 1e9 %P 2" \
2607    -invalidcommand "my_invalid %W;Ng_SetSTLParameters" -validate focus
2608    pack $f.srt.ent $f.srt.bu -side left  -expand yes -pady 8
2609
2610    ttk::frame $f.bdt -relief groove -borderwidth 3
2611    pack $f.bdt -fill x
2612    ttk::button $f.bdt.bu -text "mark dirty triangles" -command {Ng_STLDoctor markdirtytrigs; redraw }
2613    ttk::button $f.bdt.bu2 -text "smooth dirty triangles normal" -command {Ng_STLDoctor smoothdirtytrigs; redraw }
2614    pack $f.bdt.bu $f.bdt.bu2 -side left  -expand yes -pady 8
2615
2616
2617    ttk::frame $f.sno -relief groove -borderwidth 3
2618    pack $f.sno -fill x
2619    ttk::frame $f.sno.snoframe -borderwidth 0
2620    #ttk::label $f.sno.labrough -text "rough"
2621    #scale $f.sno.scsmooth -orient horizontal -length 100 -from 0 -to 0.8 \
2622	-resolution 0.01 -variable stldoctor.smoothnormalsweight \
2623	-command { Ng_SetSTLParameters }
2624    #ttk::label $f.sno.labsmooth -text "smooth"
2625    ttk::button $f.sno.smoothnormals -text "smooth normals" -command { Ng_STLDoctor smoothnormals; redraw}
2626
2627    ttk::scale $f.sno.snoframe.scale -orient horizontal -length 100 -from 0.0 -to 0.8 \
2628    -variable stldoctor.smoothnormalsweight -takefocus 0 -command "roundscale $f.sno.snoframe.scale 2;Ng_SetSTLParameters"
2629    ttk::entry $f.sno.snoframe.entry -textvariable stldoctor.smoothnormalsweight -width 4 \
2630    -validatecommand "Ng_SetSTLParameters;my_validate %W [$f.sno.snoframe.scale cget -from] [$f.sno.snoframe.scale cget -to] %P 2" \
2631    -invalidcommand "my_invalid %W;Ng_SetSTLParameters" -validate focus
2632    ttk::label $f.sno.snoframe.labrough -text "rough"
2633    ttk::label $f.sno.snoframe.labsmooth -text "smooth"
2634	grid $f.sno.snoframe.labrough $f.sno.snoframe.scale $f.sno.snoframe.labsmooth $f.sno.snoframe.entry -sticky nw -padx 4
2635
2636    #pack $f.sno.labrough $f.sno.scsmooth $f.sno.labsmooth $f.sno.smoothnormals -side left -padx 5
2637    pack $f.sno.snoframe $f.sno.smoothnormals -side left -padx 5 -pady 8
2638    ttk::frame $f.no -relief groove -borderwidth 3
2639    pack $f.no -fill x
2640
2641    ttk::button $f.no.marknonsmoothnormals -text "mark non-smooth triangles" -command {Ng_STLDoctor marknonsmoothnormals; redraw}
2642    ttk::button $f.no.calcnormals -text "calculate normals from geometry" -command {Ng_STLDoctor calcnormals; redraw}
2643
2644    pack $f.no.marknonsmoothnormals $f.no.calcnormals -expand yes -pady 8
2645
2646
2647    # ADVANCED **************************
2648    set f $wd.nb.advanced
2649
2650
2651    ttk::frame $f.sc
2652    pack $f.sc -fill x
2653    ttk::checkbutton $f.sc.bu -text "spiral check" \
2654	-variable stldoctor.spiralcheck \
2655	-command {Ng_STLDoctor;}
2656    ttk::checkbutton $f.sc.bu2 -text "cone check" \
2657	-variable stldoctor.conecheck \
2658	-command {Ng_STLDoctor;}
2659    pack $f.sc.bu $f.sc.bu2
2660
2661
2662    #tixControl $f.gtol -label "load-geometry tolerance factor" -integer false \
2663	# -variable stldoctor.geom_tol_fact \
2664	# -options {
2665	#    entry.width 8
2666	#    label.width 30
2667	#    label.anchor e
2668	#}
2669    ttk::label $f.gtol_lbl -text "LoadSTL tolerance factor"
2670    ttk::spinbox $f.gtol -from 1e-15 -to 0.001 -textvariable stldoctor.geom_tol_fact -width 8
2671    pack $f.gtol_lbl $f.gtol
2672
2673    ttk::button $f.adap -text "Apply" -command {
2674	Ng_STLDoctor;
2675    }
2676    pack $f.adap -expand yes
2677
2678#    frame $f.gtol -relief groove -borderwidth 3
2679#    pack $f.gtol -fill x
2680#    label $f.gtol.lab -text "Geometry-Load-Tolerance-Factor";
2681#    entry $f.gtol.ent -width 5 -relief sunken \
2682#	-textvariable stldoctor.geom_tol_fact
2683#   pack $f.gtol.lab $f.gtol.ent -side left -expand yes
2684
2685    #*******************************
2686    wm withdraw $wd
2687    wm geom $wd +100+100
2688    wm deiconify $wd
2689    wm title $wd "STL Doctor"
2690
2691    focus $wd
2692}
2693}
2694
2695
2696
2697
2698
2699proc meshdoctordialog { } {
2700
2701    set w .meshdoc_dlg
2702    global meshdoctor.active
2703
2704    if {[winfo exists .meshdoc_dlg] == 1} {
2705	wm withdraw $w
2706	wm deiconify $w
2707	focus $w
2708    } {
2709	toplevel $w
2710
2711	set meshdoctor.active 1
2712	Ng_MeshDoctor;
2713
2714
2715	ttk::frame $w.vis -relief groove -borderwidth 3
2716	pack $w.vis
2717
2718	ttk::checkbutton $w.vis.showfilledtrigs -text "Show filled triangles" \
2719	-variable viewoptions.drawfilledtrigs \
2720	-command { Ng_SetVisParameters; redraw }
2721
2722	ttk::checkbutton $w.vis.showedges -text "Show edges" \
2723	-variable viewoptions.drawedges \
2724	-command { Ng_SetVisParameters; redraw }
2725
2726
2727	ttk::checkbutton $w.vis.showoutline -text "Show Triangle Outline" \
2728	-variable viewoptions.drawoutline \
2729	-command { Ng_SetVisParameters; redraw }
2730
2731	pack $w.vis.showfilledtrigs  $w.vis.showoutline $w.vis.showedges
2732
2733    ttk::frame $w.markedgedist
2734    ttk::label $w.markedgedist.l -text "Mark edge dist: "
2735    ttk::spinbox $w.markedgedist.s -from 0 -to 999 -width 5 -increment 1 -validate focus -validatecommand "my_validatespinbox %W %P 0" \
2736    -invalidcommand "my_invalidspinbox %W" -command {Ng_MeshDoctor markedgedist ${meshdoc.markedgedist};redraw} -textvariable meshdoc.markedgedist
2737    #pack $f.grading -fill x
2738    pack $w.markedgedist.l $w.markedgedist.s -side left
2739
2740	# tixControl $w.markedgedist -label "Mark edge dist: " -integer true \
2741	    # -min 0 -max 999  \
2742	    # -variable meshdoc.markedgedist \
2743	    # -options {
2744		# entry.width 3
2745		# label.width 20
2746		# label.anchor e
2747	    # } \
2748	    # -command {
2749		# Ng_MeshDoctor markedgedist ${meshdoc.markedgedist}
2750		# redraw
2751	    # }
2752	pack $w.markedgedist
2753
2754	ttk::button $w.deledge -text "Delete marked segments" -command {
2755	    Ng_MeshDoctor deletemarkedsegments
2756	    redraw
2757	}
2758	pack $w.deledge
2759
2760	ttk::button $w.close -text "Close" -command {
2761	    set meshdoctor.active 0;
2762	    Ng_MeshDoctor;
2763	    destroy .meshdoc_dlg
2764	}
2765	pack $w.close -expand yes
2766
2767	wm withdraw $w
2768	wm geom $w +100+100
2769	wm deiconify $w
2770	wm title $w "Mesh Doctor"
2771    }
2772}
2773
2774
2775
2776#
2777#  Quality viewer
2778#
2779
2780proc qualityviewdialog { show } {
2781
2782    set w .qualityview_dlg
2783
2784    if {[winfo exists .qualityview_dlg] == 1} {
2785
2786	if { $show == 1 } {
2787	    wm withdraw .qualityview_dlg
2788	    wm deiconify $w
2789	    focus $w
2790	} {
2791	    wm withdraw $w
2792	}
2793    } {
2794	toplevel $w
2795
2796	set c $w.c
2797
2798	canvas $c -relief raised -width 450 -height 300
2799	pack $w.c -side top -fill x
2800
2801	set plotFont {Helvetica 12}
2802	set smallFont {Helvetica 12}
2803
2804	$c create line 100 250 400 250 -width 2
2805	$c create line 100 250 100 50 -width 2
2806
2807	for {set i 0} {$i <= 10} {incr i} {
2808	    set x [expr {100 + ($i*30)}]
2809	    $c create line $x 250 $x 245 -width 2
2810	    if { [expr {$i % 2}] == 0 } {
2811		$c create text $x 254 -text [format %1.1f [expr 0.1*$i]] -anchor n -font $plotFont
2812	    }
2813	}
2814
2815	global qualbar
2816	global qualbarnull
2817	global qualbaraxis
2818
2819	for {set i 0} {$i <= 5} {incr i} {
2820	    set y [expr {250 - ($i*40)}]
2821	    $c create line 100 $y 105 $y -width 2
2822
2823#            global qualbaraxis($i)
2824	    set qualbaraxis($i) \
2825		[$c create text 96 $y -text [expr $i*50].0 -anchor e -font $plotFont]
2826	}
2827
2828	for {set i 0} {$i < 20} {incr i} {
2829	    set x1 [expr {100 + ($i*15) + 2}]
2830	    set x2 [expr {$x1+10}]
2831	    set y [expr {250 - 10 * $i}]
2832#	    global qualbar($i)
2833	    set qualbar($i) [$c create rectangle $x1 250 $x2 245 -fill blue]
2834	    set qualbarnull($i) [$c create text [expr {($x1+$x2)/2}] 245 -text 0 -anchor s -font $smallFont -fill blue]
2835	}
2836
2837	frame $w.bu
2838	pack $w.bu
2839	# -fill x
2840
2841	ttk::button $w.close -text "Close" \
2842	    -command {
2843		wm withdraw .qualityview_dlg
2844		set viewqualityplot 0
2845	    }
2846	pack $w.close
2847
2848
2849	if { $show == 1 } {
2850	    wm withdraw $w
2851	    wm geom $w +100+100
2852	    wm deiconify $w
2853	    wm title $w "Mesh Quality"
2854	    focus $w
2855	}
2856    }
2857}
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868#
2869#  Quality viewer
2870#
2871proc memusedialog { show } {
2872
2873    set w .memuse_dlg
2874
2875    if {[winfo exists .memuse_dlg] == 1} {
2876
2877	if { $show == 1 } {
2878	    wm withdraw .memuse_dlg
2879	    wm deiconify $w
2880	    focus $w
2881	} {
2882	    wm withdraw $w
2883	}
2884    } {
2885	toplevel $w
2886
2887	set c $w.c
2888
2889	canvas $c -relief raised -width 600 -height 300
2890	pack $w.c -side top -fill x
2891
2892	set plotFont {Helvetica 18}
2893	set smallFont {Helvetica 12}
2894
2895
2896	global memmark
2897	for {set i 0} {$i < 512} { incr i } {
2898	    set memmark($i) [$c create line [expr 50+$i] 50 [expr 50+$i] 70 -fill blue]
2899	}
2900
2901
2902	set plotFont {Helvetica 18}
2903	set smallFont {Helvetica 12}
2904
2905	$c create text 50 90 -text "0 GB" -anchor n -font $plotFont
2906	$c create text 178 90 -text "1 GB" -anchor n -font $plotFont
2907	$c create text 306 90 -text "2 GB" -anchor n -font $plotFont
2908	$c create text 434 90 -text "3 GB" -anchor n -font $plotFont
2909	$c create text 562 90 -text "4 GB" -anchor n -font $plotFont
2910
2911
2912	ttk::frame $w.bu
2913	pack $w.bu
2914	# -fill x
2915
2916	ttk::button $w.close -text "Close" \
2917	    -command {
2918		wm withdraw .memuse_dlg
2919		set memuseplot 0
2920	    }
2921	pack $w.close
2922
2923	if { $show == 1 } {
2924	    wm withdraw $w
2925	    wm geom $w +100+100
2926	    wm deiconify $w
2927	    wm title $w "Memory Usage"
2928	    focus $w
2929	}
2930    }
2931}
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947#
2948#  STL INFO dialog
2949#
2950proc STLinfodialog { show } {
2951
2952    set w .STLinfo_dlg
2953
2954    if {[winfo exists .STLinfo_dlg] == 1} {
2955
2956	if { $show == 1 } {
2957	    wm withdraw .STLinfo_dlg
2958	    wm deiconify $w
2959	    focus $w
2960	} {
2961	    wm withdraw $w
2962	}
2963    } {
2964	toplevel $w
2965
2966	set c $w.c
2967
2968	canvas $c -relief raised -width 450 -height 300
2969	pack $w.c -side top -fill x
2970
2971	set plotFont {Helvetica 18}
2972	set smallFont {Helvetica 12}
2973
2974	$c create line 100 250 400 250 -width 2
2975	$c create line 100 250 100 50 -width 2
2976
2977	ttk::frame $w.bu
2978	pack $w.bu
2979	# -fill x
2980
2981	ttk::button $w.close -text "Close" \
2982	    -command {
2983		wm withdraw .STLinfo_dlg
2984		#set STLinfoopen 0
2985	    }
2986	pack $w.close
2987
2988
2989	if { $show == 1 } {
2990	    wm withdraw $w
2991	    wm geom $w +100+100
2992	    wm deiconify $w
2993	    wm title $w "STL Geometry Info"
2994	    focus $w
2995	}
2996    }
2997}
2998
2999
3000
3001
3002
3003
3004
3005
3006proc logwindow { } {
3007    set w .logwindow
3008
3009    if {[winfo exists .logwindow] == 1} {
3010	wm withdraw $w
3011	wm deiconify $w
3012	focus $w
3013    } {
3014	toplevel $w
3015
3016	text $w.edit -yscroll "$w.scrolly set" -setgrid 1 -height 12
3017	scrollbar $w.scrolly -command "$w.edit yview"
3018	pack $w.edit -side left -fill both -expand 1
3019	pack $w.scrolly -side left -fill both -expand 0
3020
3021	.logwindow.edit insert end "Netgen Log Window\n"
3022
3023	wm withdraw $w
3024	wm geom $w +100+100
3025	wm deiconify $w
3026	wm title $w "Netgen Log"
3027	focus $w
3028    }
3029}
3030# logwindow
3031
3032
3033
3034# Opens a window with a table. tablevar is a list, the first entry is the title, the second the number of rows, the third the number of columns,
3035# then the entries follow.
3036
3037proc printtable { tablevar } {
3038    set w newtcltable
3039    while {[winfo exists .$w] == 1} {set w 1$w}
3040    set w .$w
3041    toplevel $w
3042    for {set i 0} {$i < [lindex $tablevar 2]} { incr i } {
3043	frame $w.col$i
3044	for {set j 0} {$j < [lindex $tablevar 1]} { incr j } {
3045	    frame $w.col$i.row$j
3046	    message $w.col$i.row$j.txt -aspect 10000000 -text [lindex $tablevar [expr 3+[lindex $tablevar 2]*$j+$i]]
3047	    pack $w.col$i.row$j.txt
3048	    pack $w.col$i.row$j -side top
3049	}
3050	pack $w.col$i -side left
3051    }
3052    wm withdraw $w
3053    wm geom $w +200+100; wm deiconify $w
3054    wm title $w [lindex $tablevar 0]
3055    focus $w
3056}
3057
3058
3059set latestwarning 0
3060
3061
3062proc printwarning { textvar } {
3063    global latestwarning
3064    set latestwarning $textvar
3065    set w warning
3066    while {[winfo exists .$w] == 1} {set w 1$w}
3067    set w .$w
3068    toplevel $w
3069    message $w.mes -aspect 2000 -text "WARNING:\n$textvar"
3070    ttk::button $w.done -text "Done" -command "destroy $w"
3071    pack $w.mes
3072    pack $w.done
3073    wm withdraw $w
3074    wm deiconify $w
3075    wm title $w "Warning"
3076    focus $w
3077}
3078
3079
3080proc printlatestwarning { } {
3081    global latestwarning
3082    if {$latestwarning != 0} {printwarning $latestwarning}
3083}
3084
3085
3086
3087# proc runtestdialog { } {
3088    # source $::ngdir/ngshell.tcl
3089    # set w .runtest_dlg
3090
3091    # if {[winfo exists .runtest_dlg] == 1} {
3092	# wm withdraw $w
3093	# wm deiconify $w
3094
3095	# focus $w
3096    # } {
3097	# toplevel $w
3098
3099# # in2d testing #
3100	# frame $w.in2dframe
3101	# pack $w.in2dframe
3102
3103        # set in2dlogfile ""
3104 	# tixLabelEntry $w.in2dframe.ent -label "in2d log-file: console if empty"  \
3105 	    # -labelside top \
3106 	    # -options {
3107 		# entry.textVariable in2dlogfile
3108 		# entry.width 35
3109 		# label.width 25
3110 		# label.anchor w
3111 	    # }
3112 	# button $w.in2dframe.btn -text "Browse" -command {
3113	    # set types { { "Log file"   {.log}	} }
3114	    # set in2dlogfile [tk_getOpenFile -filetypes $types -initialfile $in2dlogfile]
3115	# }
3116 	# button $w.in2dframe.test -text "Test in2d meshing" -command { ngtest in2d $in2dlogfile }
3117
3118
3119 	# pack $w.in2dframe.test -side left -anchor s -padx 4 -pady 4
3120 	# pack $w.in2dframe.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4
3121 	# pack $w.in2dframe.btn -side left -anchor s -padx 4 -pady 4
3122
3123
3124# # geo testing #
3125	# frame $w.geoframe
3126	# pack $w.geoframe
3127
3128        # set geologfile ""
3129 	# tixLabelEntry $w.geoframe.ent -label "geo log-file: console if empty"  \
3130 	    # -labelside top \
3131 	    # -options {
3132 		# entry.textVariable geologfile
3133 		# entry.width 35
3134 		# label.width 25
3135 		# label.anchor w
3136 	    # }
3137 	# button $w.geoframe.btn -text "Browse" -command {
3138	    # set types { { "Log file"   {.log}	} }
3139	    # set geologfile [tk_getOpenFile -filetypes $types -initialfile $geologfile]
3140	# }
3141 	# button $w.geoframe.test -text "Test geo meshing" -command { ngtest geo $geologfile }
3142
3143
3144 	# pack $w.geoframe.test -side left -anchor s -padx 4 -pady 4
3145 	# pack $w.geoframe.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4
3146 	# pack $w.geoframe.btn -side left -anchor s -padx 4 -pady 4
3147
3148# # stl testing #
3149	# frame $w.stlframe
3150	# pack $w.stlframe
3151
3152        # set stllogfile ""
3153 	# tixLabelEntry $w.stlframe.ent -label "stl log-file: console if empty"  \
3154 	    # -labelside top \
3155 	    # -options {
3156 		# entry.textVariable stllogfile
3157 		# entry.width 35
3158 		# label.width 25
3159 		# label.anchor w
3160 	    # }
3161 	# button $w.stlframe.btn -text "Browse" -command {
3162	    # set types { { "Log file"   {.log}	} }
3163	    # set stllogfile [tk_getOpenFile -filetypes $types -initialfile $stllogfile]
3164	# }
3165 	# button $w.stlframe.test -text "Test stl meshing" -command { ngtest stl $stllogfile }
3166
3167
3168 	# pack $w.stlframe.test -side left -anchor s -padx 4 -pady 4
3169 	# pack $w.stlframe.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4
3170 	# pack $w.stlframe.btn -side left -anchor s -padx 4 -pady 4
3171
3172# # pde testing #
3173	# frame $w.pdeframe
3174	# pack $w.pdeframe
3175
3176        # set pdelogfile ""
3177 	# tixLabelEntry $w.pdeframe.ent -label "pde log-file: console if empty"  \
3178 	    # -labelside top \
3179 	    # -options {
3180 		# entry.textVariable pdelogfile
3181 		# entry.width 35
3182 		# label.width 25
3183 		# label.anchor w
3184 	    # }
3185 	# button $w.pdeframe.btn -text "Browse" -command {
3186	    # set types { { "Log file"   {.log}	} }
3187	    # set pdelogfile [tk_getOpenFile -filetypes $types -initialfile $pdelogfile]
3188	# }
3189 	# button $w.pdeframe.test -text "Test ngsolve pde's" -command { ngtest pde $pdelogfile }
3190
3191
3192 	# pack $w.pdeframe.test -side left -anchor s -padx 4 -pady 4
3193 	# pack $w.pdeframe.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4
3194 	# pack $w.pdeframe.btn -side left -anchor s -padx 4 -pady 4
3195
3196	# wm title $w "Testing"
3197	# focus .runtest_dlg
3198    # }
3199# }
3200
3201