2009-01-18 01:52:26 +05:00
|
|
|
#
|
|
|
|
# Creates a drawing frame, and binds mouse events
|
|
|
|
#
|
|
|
|
set oldmousex 0
|
|
|
|
set oldmousey 0
|
|
|
|
#
|
2009-01-24 18:35:44 +05:00
|
|
|
|
2009-09-07 21:15:22 +06:00
|
|
|
|
2011-02-19 03:50:58 +05:00
|
|
|
# if { 1 } {
|
2012-06-08 00:52:10 +06:00
|
|
|
|
|
|
|
# use this one for Togl 2.0
|
2016-02-08 19:53:16 +05:00
|
|
|
#if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect false }] } {
|
2011-02-19 03:50:58 +05:00
|
|
|
|
2016-02-08 19:53:16 +05:00
|
|
|
# if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect false -create init -display draw -reshape reshape }] } {
|
|
|
|
# puts "no OpenGL"
|
|
|
|
# } {
|
|
|
|
|
|
|
|
set toglversion [Ng_GetToglVersion]
|
|
|
|
puts "togl-version : $toglversion"
|
|
|
|
|
|
|
|
set toglok 0
|
|
|
|
if { [Ng_GetToglVersion] == 2 } {
|
|
|
|
# Togl 2.x
|
|
|
|
if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect false -create init -display draw -reshape reshape }] } {
|
|
|
|
puts "no OpenGL"
|
|
|
|
} {
|
|
|
|
# puts "have Togl 2.1"
|
|
|
|
set toglok 1
|
|
|
|
}
|
2009-01-18 01:52:26 +05:00
|
|
|
} {
|
2016-02-08 19:53:16 +05:00
|
|
|
# Togl 1.7
|
|
|
|
if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect false }] } {
|
|
|
|
puts "no OpenGL"
|
|
|
|
} {
|
|
|
|
# puts "have Togl 1.7"
|
|
|
|
set toglok 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if { $toglok == 1} {
|
|
|
|
|
2009-01-18 01:52:26 +05:00
|
|
|
#
|
|
|
|
pack .ndraw -expand true -fill both -padx 10 -pady 10
|
2016-02-08 19:53:16 +05:00
|
|
|
catch { tkdnd::drop_target register .ndraw DND_Files }
|
2009-01-18 01:52:26 +05:00
|
|
|
#
|
|
|
|
bind .ndraw <Button-1> {
|
|
|
|
set oldmousex %x; set oldmousey %y;
|
|
|
|
}
|
|
|
|
bind .ndraw <Button-2> {
|
|
|
|
set oldmousex %x; set oldmousey %y;
|
|
|
|
}
|
|
|
|
bind .ndraw <Button-3> {
|
|
|
|
set oldmousex %x; set oldmousey %y;
|
|
|
|
}
|
|
|
|
bind .ndraw <B1-Motion> {
|
|
|
|
Ng_MouseMove $oldmousex $oldmousey %x %y $drawmode
|
|
|
|
.ndraw render
|
|
|
|
set oldmousex %x; set oldmousey %y;
|
|
|
|
}
|
|
|
|
|
|
|
|
bind .ndraw <Double-1> {
|
|
|
|
Ng_MouseDblClick %x %y
|
|
|
|
.ndraw render
|
|
|
|
if { [winfo exists .bcprop_dlg] } { bcpropdialog }
|
2009-01-31 03:22:13 +05:00
|
|
|
if { [winfo exists .surfacemeshsize_dlg] } { surfacemeshsizedialog }
|
2009-01-18 01:52:26 +05:00
|
|
|
if { [winfo exists .fieldlines_dlg] } { fieldlinesdialog }
|
|
|
|
}
|
|
|
|
|
|
|
|
bind .ndraw <B2-Motion> {
|
|
|
|
Ng_MouseMove $oldmousex $oldmousey %x %y move
|
|
|
|
.ndraw render
|
|
|
|
set oldmousex %x; set oldmousey %y;
|
|
|
|
}
|
|
|
|
|
|
|
|
bind .ndraw <B3-Motion> {
|
2015-10-10 23:37:23 +05:00
|
|
|
if { $tcl_platform(os) == "Darwin" } {
|
|
|
|
Ng_MouseMove $oldmousex $oldmousey %x %y move
|
|
|
|
} {
|
|
|
|
Ng_MouseMove $oldmousex $oldmousey %x %y zoom
|
|
|
|
}
|
2009-01-18 01:52:26 +05:00
|
|
|
.ndraw render
|
|
|
|
set oldmousex %x; set oldmousey %y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
proc popupcheckredraw { vari { x 0 } } {
|
|
|
|
upvar $vari varname
|
|
|
|
if { $varname == 1 } {
|
|
|
|
set varname 0
|
|
|
|
} {
|
|
|
|
# puts "popup-redraw $vari"
|
|
|
|
Ng_Vis_Set parameters
|
|
|
|
redraw
|
|
|
|
}
|
|
|
|
}
|
|
|
|
proc popupcheckredraw2 { vari boolvar { x 0 } } {
|
|
|
|
upvar $vari varname
|
|
|
|
if { $varname == 1 } {
|
|
|
|
set varname 0
|
|
|
|
} {
|
|
|
|
Ng_SetVisParameters
|
2011-02-15 21:22:05 +05:00
|
|
|
Ng_Vis_Set parameters
|
2009-01-18 01:52:26 +05:00
|
|
|
if { $boolvar == 1 } { redraw }
|
|
|
|
Ng_SetVisParameters
|
|
|
|
}
|
|
|
|
}
|
|
|
|
proc popupcheckredraw3 { vari { x 0 } } {
|
|
|
|
upvar $vari varname
|
|
|
|
if { $varname == 1 } {
|
|
|
|
set varname 0
|
|
|
|
} {
|
|
|
|
Ng_Vis_Set parameters
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc redraw { {x 0} } {
|
|
|
|
if {[winfo exists .ndraw]} { .ndraw render }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bind . <Left> { Ng_MouseMove 0 0 -10 0 rotate; redraw }
|
|
|
|
bind . <Right> { Ng_MouseMove 0 0 10 0 rotate; redraw }
|
|
|
|
bind . <Up> { Ng_MouseMove 0 0 0 -10 rotate; redraw }
|
|
|
|
bind . <Down> { Ng_MouseMove 0 0 0 10 rotate; redraw }
|
|
|
|
bind . <Shift-Left> { Ng_MouseMove 0 0 -10 0 move; redraw }
|
|
|
|
bind . <Shift-Right> { Ng_MouseMove 0 0 10 0 move; redraw }
|
|
|
|
bind . <Shift-Up> { Ng_MouseMove 0 0 0 -10 move; redraw }
|
|
|
|
bind . <Shift-Down> { Ng_MouseMove 0 0 0 10 move; redraw }
|
|
|
|
bind . <Control-Up> { Ng_MouseMove 0 0 0 -10 zoom; redraw }
|
|
|
|
bind . <Control-Down> { Ng_MouseMove 0 0 0 10 zoom; redraw }
|
|
|
|
|
2013-09-24 14:27:57 +06:00
|
|
|
bind . <Button-4> \
|
2009-01-18 01:52:26 +05:00
|
|
|
{event generate [focus -displayof %W] <MouseWheel> -delta 120}
|
|
|
|
|
2013-09-24 14:27:57 +06:00
|
|
|
bind . <Button-5> \
|
2009-01-18 01:52:26 +05:00
|
|
|
{event generate [focus -displayof %W] <MouseWheel> -delta -120}
|
|
|
|
|
2013-09-24 14:27:57 +06:00
|
|
|
bind . <MouseWheel> { Ng_MouseMove 0 0 0 [expr {%D/-5}] zoom; redraw }
|
2009-01-18 01:52:26 +05:00
|
|
|
|
2016-02-08 19:53:16 +05:00
|
|
|
|
|
|
|
|
|
|
|
# Drop callbacks:
|
|
|
|
bind .ndraw <<Drop:DND_Files>> {
|
|
|
|
#tk_messageBox -message "Dropped files: \"[join %D {, }]\""
|
2017-09-14 18:34:41 +05:00
|
|
|
set filename [join %D " "]
|
|
|
|
|
2016-02-08 19:53:16 +05:00
|
|
|
#%W state !active
|
2017-09-14 18:34:41 +05:00
|
|
|
set index [string last . $filename]
|
2016-02-08 19:53:16 +05:00
|
|
|
#tk_messageBox -message $index
|
2017-09-14 18:34:41 +05:00
|
|
|
set type [string range $filename $index+1 end]
|
2016-02-08 19:53:16 +05:00
|
|
|
# tk_messageBox -message $type
|
|
|
|
set ispde [string match -nocase $type "pde"]
|
|
|
|
set isgeo [expr max([string match -nocase $type "geo"],[string match -nocase $type "in2d"])]
|
|
|
|
set ismesh [expr max([string match -nocase $type "vol"],[string match -nocase $type "vol.gz"])]
|
|
|
|
set ispy [string match -nocase $type "py"]
|
|
|
|
if {$ispde == 1} {
|
2017-09-14 18:34:41 +05:00
|
|
|
AddRecentNGSFile $filename;
|
|
|
|
NGS_LoadPDE $filename;
|
2016-02-08 19:53:16 +05:00
|
|
|
SetNumProcHelpMenu
|
|
|
|
set selectvisual mesh;
|
|
|
|
Ng_SetVisParameters
|
|
|
|
}
|
|
|
|
if {$ispy == 1} {
|
2017-09-14 18:34:41 +05:00
|
|
|
AddRecentPYNGSFile $filename;
|
|
|
|
NGS_LoadPy $filename;
|
2016-02-08 19:53:16 +05:00
|
|
|
}
|
|
|
|
if {$isgeo == 1} {
|
2017-09-14 18:34:41 +05:00
|
|
|
AddRecentFile $filename;
|
|
|
|
Ng_LoadGeometry $filename;
|
2016-02-08 19:53:16 +05:00
|
|
|
Ng_ParseGeometry
|
|
|
|
set selectvisual geometry
|
|
|
|
Ng_SetVisParameters
|
|
|
|
redraw
|
2017-09-14 18:34:41 +05:00
|
|
|
wm title . [concat "$progname - " $filename]
|
|
|
|
set dirname [file dirname $filename]
|
|
|
|
set basefilename [file tail [file rootname $filename]]
|
2016-02-08 19:53:16 +05:00
|
|
|
}
|
|
|
|
if {$ismesh == 1} {
|
2017-09-14 18:34:41 +05:00
|
|
|
AddRecentMeshFile $filename;
|
|
|
|
Ng_LoadMesh $filename;
|
2016-02-08 19:53:16 +05:00
|
|
|
set selectvisual mesh
|
|
|
|
Ng_SetVisParameters
|
|
|
|
redraw
|
|
|
|
Ng_ReadStatus;
|
|
|
|
wm title . [concat "$progname - " %D]
|
|
|
|
set dirname [file dirname %D]
|
|
|
|
set basefilename [file tail [file rootname %D]]
|
|
|
|
}
|
|
|
|
return %A
|
|
|
|
}
|