Revision: 50197 http://brlcad.svn.sourceforge.net/brlcad/?rev=50197&view=rev Author: starseeker Date: 2012-04-20 17:59:23 +0000 (Fri, 20 Apr 2012) Log Message: ----------- Use an associative array, and populate variables in the RtWizard namespace.
Modified Paths: -------------- brlcad/trunk/src/tclscripts/rtwizard/RaytraceWizard.tcl brlcad/trunk/src/tclscripts/rtwizard/lib/DbPage.itk brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeBase.itcl brlcad/trunk/src/tclscripts/rtwizard/rtwizard.tcl Modified: brlcad/trunk/src/tclscripts/rtwizard/RaytraceWizard.tcl =================================================================== --- brlcad/trunk/src/tclscripts/rtwizard/RaytraceWizard.tcl 2012-04-20 17:26:47 UTC (rev 50196) +++ brlcad/trunk/src/tclscripts/rtwizard/RaytraceWizard.tcl 2012-04-20 17:59:23 UTC (rev 50197) @@ -78,7 +78,6 @@ package require PictureTypeE package require PictureTypeF - set dbFile "" # set helpFont {-family helvetica -size 12 \ -slant italic} @@ -177,13 +176,13 @@ # file to be specified. # if { [llength $args] > 0 } { - set ::RtWizard::dbFile [ lindex $args 0 ] - if { ! [file exists $::RtWizard::dbFile] } { - set ::RtWizard::dbFile "" + set ::RtWizard::wizard_state(dbFile) [ lindex $args 0 ] + if { ! [file exists $::RtWizard::wizard_state(dbFile)] } { + set ::RtWizard::wizard_state(dbFile) "" } } - if { [string length $::RtWizard::dbFile] == 0 } { + if { [string length $::RtWizard::wizard_state(dbFile)] == 0 } { # # select the database page # @@ -198,7 +197,7 @@ # Start up the gui, and run until the dbFile has # been specified. # - vwait ::RtWizard::dbFile + vwait ::RtWizard::wizard_state(dbFile) # # Restore the Feedback @@ -215,19 +214,19 @@ # pages. # set ::mgedObj [ArcherCore .\#auto 1 1 1 1] - $::mgedObj opendb $::RtWizard::dbFile + $::mgedObj opendb $::RtWizard::wizard_state(dbFile) $fb inform "MGED object instantiated." 40 - $w add RtWizard::FullColorPage fullColor $::RtWizard::dbFile + $w add RtWizard::FullColorPage fullColor $::RtWizard::wizard_state(dbFile) $fb inform "Support for full color images loaded." 5 - $w add RtWizard::HighlightedPage highlighted $::RtWizard::dbFile + $w add RtWizard::HighlightedPage highlighted $::RtWizard::wizard_state(dbFile) $fb inform "Support for highlighted images loaded." 5 - $w add RtWizard::GhostPage ghost $::RtWizard::dbFile + $w add RtWizard::GhostPage ghost $::RtWizard::wizard_state(dbFile) $fb inform "Support for ghost images loaded." 5 - $w add RtWizard::LinePage lines $::RtWizard::dbFile + $w add RtWizard::LinePage lines $::RtWizard::wizard_state(dbFile) $w select "exp" $fb inform "rtwizard ready!" 5 Modified: brlcad/trunk/src/tclscripts/rtwizard/lib/DbPage.itk =================================================================== --- brlcad/trunk/src/tclscripts/rtwizard/lib/DbPage.itk 2012-04-20 17:26:47 UTC (rev 50196) +++ brlcad/trunk/src/tclscripts/rtwizard/lib/DbPage.itk 2012-04-20 17:59:23 UTC (rev 50197) @@ -267,7 +267,7 @@ # onOK - called when the OK button is called # itcl::body DbPage::onOK {} { - set ::RtWizard::dbFile [getDbFile] + set ::RtWizard::wizard_state(dbFile) [getDbFile] $::wizardInstance select exp } Modified: brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeBase.itcl =================================================================== --- brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeBase.itcl 2012-04-20 17:26:47 UTC (rev 50196) +++ brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeBase.itcl 2012-04-20 17:59:23 UTC (rev 50197) @@ -271,7 +271,7 @@ set cmd [list [file join [bu_brlcad_root bin] rt] -M -R $otype $fbout -w $width \ -n $height -V $ar -A 0.9 -p $perspective \ -C [lindex $bg 0]/[lindex $bg 1]/[lindex $bg 2] \ - $::RtWizard::dbFile] + $::RtWizard::wizard_state(dbFile)] foreach obj $objects { lappend cmd $obj } @@ -351,7 +351,7 @@ -c "set bg=[lindex $nl 0],[lindex $nl 1],[lindex $nl 2]" \ -c "set om=$occMode" \ -c "set oo=\"$occObjects\"" \ - $::RtWizard::dbFile] + $::RtWizard::wizard_state(dbFile)] } else { set cmd [list rtedge -M -R -F $fb -w $width \ @@ -359,7 +359,7 @@ -c "$fgMode" \ -c "set bg=[lindex $nl 0],[lindex $nl 1],[lindex $nl 2]" \ -c "set ov=$overlay" \ - $::RtWizard::dbFile] + $::RtWizard::wizard_state(dbFile)] } # Modified: brlcad/trunk/src/tclscripts/rtwizard/rtwizard.tcl =================================================================== --- brlcad/trunk/src/tclscripts/rtwizard/rtwizard.tcl 2012-04-20 17:26:47 UTC (rev 50196) +++ brlcad/trunk/src/tclscripts/rtwizard/rtwizard.tcl 2012-04-20 17:59:23 UTC (rev 50197) @@ -57,31 +57,42 @@ # Begin Tcl here! # +# We might as well populate options directly in the namespace +# where they will eventually be used. Define that namespace +# up front. +namespace eval RtWizard {} + +# Set up the options we support with rtwizard. We will use +# an associative array named wizard_state in the RtWizard +# namespace to hold the key information - have getopt place the +# results of its parsing directly in that array source [file join [bu_brlcad_data "tclscripts"] util getopt.tcl] getopt::init { {verbose v {::verbose}} {gui gui {::use_gui}} {no-gui no-gui {::disable_gui}} - {g-file i {::have_gfile ::g_file}} - {output o {::output ::output_filename}} - {full-color-objects c {::have_full_color_objs ::color_objlist ...}} - {background-color background-color {::have_fc_bg_color ::fc_bg_color}} - {ghost-objects g {::have_ghost_objs ::ghost_objlist ...}} - {ghosting-intensity ghosting-intensity {::have_ghosting_intensity ::ghosting_intensity}} - {edge-objects e {::have_edge_objs ::edge_objlist ...}} - {line-color line-color {::have_line_color ::line_color}} - {non-line-color non-line-color {::have_non_line_color ::non_line_color}} - {occlusion occlusion {::have_occlusion_setting ::occlusion_setting}} - {type t {::have_picture_type ::picture_type}} - {matrix M {::have_matrix ::matrix}} - {azimuth a {::have_azimuth ::azimuth}} - {elevation e {::have_elevation ::elevation}} - {cpus P {::have_cpu_cnt ::cpus_use}} + {g-file i {::have_gfile RtWizard::wizard_state(dbFile)}} + {output o {::output RtWizard::wizard_state(output_filename)}} + {full-color-objects c {::have_full_color_objs RtWizard::wizard_state(color_objlist) ...}} + {background-color background-color {::have_fc_bg_color RtWizard::wizard_state(fc_bg_color)}} + {ghost-objects g {::have_ghost_objs RtWizard::wizard_state(ghost_objlist) ...}} + {ghosting-intensity ghosting-intensity {::have_ghosting_intensity RtWizard::wizard_state(ghosting_intensity)}} + {edge-objects e {::have_edge_objs RtWizard::wizard_state(edge_objlist) ...}} + {line-color line-color {::have_line_color RtWizard::wizard_state(line_color)}} + {non-line-color non-line-color {::have_non_line_color RtWizard::wizard_state(non_line_color)}} + {occlusion occlusion {::have_occlusion_setting RtWizard::wizard_state(occlusion_setting)}} + {type t {::have_picture_type RtWizard::wizard_state(picture_type)}} + {matrix M {::have_matrix RtWizard::wizard_state(matrix)}} + {azimuth a {::have_azimuth RtWizard::wizard_state(azimuth)}} + {elevation e {::have_elevation RtWizard::wizard_state(elevation)}} + {cpus P {::have_cpu_cnt RtWizard::wizard_state(cpus_use)}} } + +# Perform the actual option parsing set argv2 [getopt::getopt $argv] # During development, force default behavior (comment the following out to work on new code) -set ::use_gui 1 +#set ::use_gui 1 # If we have both gui and no-gui specified, use gui if {[info exists ::use_gui] && [info exists ::disable_gui]} { @@ -92,12 +103,12 @@ # If we have an explicit picture type, check whether we satisfy the minimum # data input for that type. if {[info exists ::have_picture_type] && ![info exists ::use_gui]} { - switch $::picture_type { + switch $RtWizard::wizard_state(picture_type) { A - 1 { - if {![info exists ::color_objlist]} { + if {![info exists RtWizard::wizard_state(color_objlist)]} { if ([info exists ::disable_gui]) { - puts "Error - picture type $::picture_type specified, but no full color objects listed" + puts "Error - picture type $RtWizard::wizard_state(picture_type) specified, but no full color objects listed" puts "Please specify full color objects using the -c option\n" exit } else { @@ -107,9 +118,9 @@ } B - 2 { - if {![info exists ::edge_objlist]} { + if {![info exists RtWizard::wizard_state(edge_objlist)]} { if ([info exists ::disable_gui]) { - puts "Error - picture type $::picture_type specified, but no edge objects listed" + puts "Error - picture type $RtWizard::wizard_state(picture_type) specified, but no edge objects listed" puts "Please specify edge objects using the -e option\n" exit } else { @@ -121,16 +132,16 @@ D - 3 - 4 { - if {![info exists ::color_objlist] || ![info exists ::edge_objlist]} { + if {![info exists RtWizard::wizard_state(color_objlist)] || ![info exists RtWizard::wizard_state(edge_objlist)]} { if (![info exists ::disable_gui]) { set ::use_gui 1 } else { - if {![info exists ::edge_objlist]} { - puts "Error - picture type $::picture_type specified, but no edge objects listed" + if {![info exists RtWizard::wizard_state(edge_objlist)]} { + puts "Error - picture type $RtWizard::wizard_state(picture_type) specified, but no edge objects listed" puts "Please specify edge objects using the -e option\n" } - if {![info exists ::color_objlist]} { - puts "Error - picture type $::picture_type specified, but no color objects listed" + if {![info exists RtWizard::wizard_state(color_objlist)]} { + puts "Error - picture type $RtWizard::wizard_state(picture_type) specified, but no color objects listed" puts "Please specify full color objects using the -c option\n" } exit @@ -139,16 +150,16 @@ } E - 5 { - if {![info exists ::color_objlist] || ![info exists ::ghost_objlist]} { + if {![info exists RtWizard::wizard_state(color_objlist)] || ![info exists RtWizard::wizard_state(ghost_objlist)]} { if (![info exists ::disable_gui]) { set ::use_gui 1 } else { - if {![info exists ::ghost_objlist]} { - puts "Error - picture type $::picture_type specified, but no ghost objects listed" + if {![info exists RtWizard::wizard_state(ghost_objlist)]} { + puts "Error - picture type $RtWizard::wizard_state(picture_type) specified, but no ghost objects listed" puts "Please specify ghost objects using the -g option\n" } - if {![info exists ::color_objlist]} { - puts "Error - picture type $::picture_type specified, but no color objects listed" + if {![info exists RtWizard::wizard_state(color_objlist)]} { + puts "Error - picture type $RtWizard::wizard_state(picture_type) specified, but no color objects listed" puts "Please specify full color objects using the -c option\n" } exit @@ -157,27 +168,27 @@ } F - 6 { - if {![info exists ::color_objlist] || ![info exists ::edge_objlist] || ![info exists ::ghost_objlist]} { + if {![info exists RtWizard::wizard_state(color_objlist)] || ![info exists RtWizard::wizard_state(edge_objlist)] || ![info exists RtWizard::wizard_state(ghost_objlist)]} { if (![info exists ::disable_gui]) { set ::use_gui 1 } else { - if {![info exists ::ghost_objlist]} { - puts "Error - picture type $::picture_type specified, but no ghost objects listed" + if {![info exists RtWizard::wizard_state(ghost_objlist)]} { + puts "Error - picture type $RtWizard::wizard_state(picture_type) specified, but no ghost objects listed" puts "Please specify ghost objects using the -g option\n" } - if {![info exists ::color_objlist]} { - puts "Error - picture type $::picture_type specified, but no color objects listed" + if {![info exists RtWizard::wizard_state(color_objlist)]} { + puts "Error - picture type $RtWizard::wizard_state(picture_type) specified, but no color objects listed" puts "Please specify full color objects using the -c option\n" } - if {![info exists ::edge_objlist]} { - puts "Error - picture type $::picture_type specified, but no edge objects listed" + if {![info exists RtWizard::wizard_state(edge_objlist)]} { + puts "Error - picture type $RtWizard::wizard_state(picture_type) specified, but no edge objects listed" puts "Please specify edge objects using the -e option\n" } exit } } } - default {puts "Error - unknown picture type $::picture_type\n"; exit} + default {puts "Error - unknown picture type $RtWizard::wizard_state(picture_type)\n"; exit} } } @@ -190,7 +201,7 @@ # graphical or command line we need to start with btclsh load [file join [bu_brlcad_root "lib"] libtclcad[info sharedlibextension]] load [file join [bu_brlcad_root "lib"] libdm[info sharedlibextension]] - # Now, load RaytraceWizard.tcl + # Now, load the actual Raytrace Wizard GUI source [file join [bu_brlcad_data "tclscripts"] rtwizard RaytraceWizard.tcl] exit } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ For Developers, A Lot Can Happen In A Second. Boundary is the first to Know...and Tell You. Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! http://p.sf.net/sfu/Boundary-d2dvs2 _______________________________________________ BRL-CAD Source Commits mailing list brlcad-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/brlcad-commits