Revision: 55989
http://sourceforge.net/p/brlcad/code/55989
Author: starseeker
Date: 2013-07-09 20:46:38 +0000 (Tue, 09 Jul 2013)
Log Message:
-----------
Use a Tcl dict structure to pass information to rtimage, rather than a large
number of parameters. Preparing to add more rt options to rtwizard, it became
clear that the old approach wouldn't scale. This way, parameters can be added
only where needed in the core rtimage script and the specific callers that want
to invoke it, and the rest of the code can remain as-is.
Modified Paths:
--------------
brlcad/trunk/src/tclscripts/lib/Ged.tcl
brlcad/trunk/src/tclscripts/lib/RtImage.tcl
brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeA.itcl
brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeB.itcl
brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeC.itcl
brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeD.itcl
brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeE.itcl
brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeF.itcl
brlcad/trunk/src/tclscripts/rtwizard/rtwizard
Modified: brlcad/trunk/src/tclscripts/lib/Ged.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/lib/Ged.tcl 2013-07-09 20:45:49 UTC (rev
55988)
+++ brlcad/trunk/src/tclscripts/lib/Ged.tcl 2013-07-09 20:46:38 UTC (rev
55989)
@@ -2090,8 +2090,25 @@
return "make_image: no database is open"
}
- return [cadwidgets::rtimage $dbfile $_port $_w $_n $_viewsize
$_orientation $_eye_pt $_perspective \
- $_bgcolor $_ecolor $_necolor $_occmode $_gamma $_color_objects
$_ghost_objects $_edge_objects]
+ set rtimage_dict [dict create \
+ _dbfile $dbFile \
+ _port $_port \
+ _w $_w \
+ _n $_n \
+ _viewsize $_viewsize \
+ _orientation $_orientation \
+ _eye_pt $_eye_pt \
+ _perspective $_perspective \
+ _bgcolor $_bgcolor \
+ _ecolor $_ecolor \
+ _necolor $_necolor \
+ _occmode $_occmode \
+ _gamma $_gamma \
+ _color_objects $_color_objects \
+ _ghost_objects $_ghost_objects \
+ _edge_objects $_edge_objects ]
+
+ return [cadwidgets::rtimage $rtimage_dict]
}
Modified: brlcad/trunk/src/tclscripts/lib/RtImage.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/lib/RtImage.tcl 2013-07-09 20:45:49 UTC (rev
55988)
+++ brlcad/trunk/src/tclscripts/lib/RtImage.tcl 2013-07-09 20:46:38 UTC (rev
55989)
@@ -26,24 +26,29 @@
package provide cadwidgets::RtImage 1.0
namespace eval cadwidgets {
-proc rtimage {_dbfile
- _port
- _w _n
- _viewsize
- _orientation
- _eye_pt
- _perspective
- _bgcolor
- _ecolor
- _necolor
- _occmode
- _gamma
- _color_objects
- _ghost_objects
- _edge_objects} {
+proc rtimage {rtimage_dict} {
global tcl_platform
global env
+ set necessary_vars [list _dbfile _port _w _n _viewsize _orientation \
+ _eye_pt _perspective _bgcolor _ecolor _necolor _occmode _gamma]
+ set necessary_lists [list _color_objects _ghost_objects _edge_objects]
+ # It's the responsibility of the calling function
+ # to populate the dictionary with what is needed.
+ # Make the variables for local processing.
+ foreach param [dict keys $rtimage_dict] {
+ set $param [dict get $rtimage_dict $param]
+ }
+
+ # Anything we don't already have from the dictionary
+ # is assumed empty
+ foreach var ${necessary_vars} {
+ if {![info exists $var]} { set $var "" }
+ }
+ foreach var ${necessary_lists} {
+ if {![info exists $var]} { set $var {} }
+ }
+
set ar [ expr $_w.0 / $_n.0 ]
if {$tcl_platform(platform) == "windows"} {
Modified: brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeA.itcl
===================================================================
--- brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeA.itcl 2013-07-09
20:45:49 UTC (rev 55988)
+++ brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeA.itcl 2013-07-09
20:46:38 UTC (rev 55989)
@@ -155,15 +155,21 @@
#
set perspective [$viewPage getPerspective]
- ::cadwidgets::rtimage $::RtWizard::wizard_state(dbFile) $fb \
- $w $h \
- $viewsize $orientation $eye_pt $perspective\
- $bg "" ""\
- "" "" \
- $color_objects \
- "" \
- ""
+ # populate a dictionary to pass to rtimage
+ set rtimage_dict [dict create \
+ _dbfile $::RtWizard::wizard_state(dbFile) \
+ _port $fb \
+ _w $w \
+ _n $h \
+ _viewsize $viewsize \
+ _orientation $orientation \
+ _eye_pt $eye_pt \
+ _perspective $perspective \
+ _bgcolor $bg \
+ _color_objects $color_objects ]
+ ::cadwidgets::rtimage $rtimage_dict
+
# If we're outputting a file, write it out and close down
# the in-memory fbserv
if {[info exists filename]} {
Modified: brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeB.itcl
===================================================================
--- brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeB.itcl 2013-07-09
20:45:49 UTC (rev 55988)
+++ brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeB.itcl 2013-07-09
20:46:38 UTC (rev 55989)
@@ -165,15 +165,23 @@
#
set perspective [$viewPage getPerspective]
- ::cadwidgets::rtimage $::RtWizard::wizard_state(dbFile) $fb \
- $w $h \
- $viewsize $orientation $eye_pt $perspective\
- $bg $l $nl\
- 0 "" \
- ""\
- "" \
- $line_objects
+ set rtimage_dict [dict create \
+ _dbfile $::RtWizard::wizard_state(dbFile) \
+ _port $fb \
+ _w $w \
+ _n $h \
+ _viewsize $viewsize \
+ _orientation $orientation \
+ _eye_pt $eye_pt \
+ _perspective $perspective \
+ _bgcolor $bg \
+ _ecolor $l \
+ _necolor $nl\
+ _occmode 0 \
+ _edge_objects $line_objects ]
+ ::cadwidgets::rtimage $rtimage_dict
+
# If we're outputting a file, write it out and close down
# the in-memory fbserv
if {[info exists filename]} {
Modified: brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeC.itcl
===================================================================
--- brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeC.itcl 2013-07-09
20:45:49 UTC (rev 55988)
+++ brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeC.itcl 2013-07-09
20:46:38 UTC (rev 55989)
@@ -166,15 +166,24 @@
#
set perspective [$viewPage getPerspective]
- ::cadwidgets::rtimage $::RtWizard::wizard_state(dbFile) $fb \
- $w $h \
- $viewsize $orientation $eye_pt $perspective\
- $bg $l $nl\
- 1 "" \
- $color_objects \
- "" \
- $color_objects
+ set rtimage_dict [dict create \
+ _dbfile $::RtWizard::wizard_state(dbFile) \
+ _port $fb \
+ _w $w \
+ _n $h \
+ _viewsize $viewsize \
+ _orientation $orientation \
+ _eye_pt $eye_pt \
+ _perspective $perspective\
+ _bgcolor $bg \
+ _ecolor $l \
+ _necolor $nl \
+ _occmode 1 \
+ _color_objects $color_objects \
+ _edge_objects $color_objects ]
+ ::cadwidgets::rtimage $rtimage_dict
+
# If we're outputting a file, write it out and close down
# the in-memory fbserv
if {[info exists filename]} {
Modified: brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeD.itcl
===================================================================
--- brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeD.itcl 2013-07-09
20:45:49 UTC (rev 55988)
+++ brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeD.itcl 2013-07-09
20:46:38 UTC (rev 55989)
@@ -183,14 +183,23 @@
#
set perspective [$viewPage getPerspective]
- ::cadwidgets::rtimage $::RtWizard::wizard_state(dbFile) $fb \
- $w $h \
- $viewsize $orientation $eye_pt $perspective\
- $bg $l $nl\
- $occMode "" \
- $color_objects \
- "" \
- $line_objects
+ set rtimage_dict [dict create \
+ _dbfile $::RtWizard::wizard_state(dbFile) \
+ _port $fb \
+ _w $w \
+ _n $h \
+ _viewsize $viewsize \
+ _orientation $orientation \
+ _eye_pt $eye_pt \
+ _perspective $perspective \
+ _bgcolor $bg \
+ _ecolor $l \
+ _necolor $nl \
+ _occmode $occMode \
+ _color_objects $color_objects \
+ _edge_objects $line_objects ]
+
+ ::cadwidgets::rtimage $rtimage_dict
# If we're outputting a file, write it out and close down
# the in-memory fbserv
Modified: brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeE.itcl
===================================================================
--- brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeE.itcl 2013-07-09
20:45:49 UTC (rev 55988)
+++ brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeE.itcl 2013-07-09
20:46:38 UTC (rev 55989)
@@ -160,14 +160,21 @@
#
set perspective [$viewPage getPerspective]
- ::cadwidgets::rtimage $::RtWizard::wizard_state(dbFile) $fb \
- $w $h \
- $viewsize $orientation $eye_pt $perspective\
- $bg "" ""\
- "" $gamma \
- $color_objects \
- $ghost_objects \
- ""
+ set rtimage_dict [dict create \
+ _dbfile $::RtWizard::wizard_state(dbFile) \
+ _port $fb \
+ _w $w \
+ _n $h \
+ _viewsize $viewsize \
+ _orientation $orientation \
+ _eye_pt $eye_pt \
+ _perspective $perspective \
+ _bgcolor $bg \
+ _gamma $gamma \
+ _color_objects $color_objects \
+ _ghost_objects $ghost_objects ]
+
+ ::cadwidgets::rtimage $rtimage_dict
# If we're outputting a file, write it out and close down
# the in-memory fbserv
Modified: brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeF.itcl
===================================================================
--- brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeF.itcl 2013-07-09
20:45:49 UTC (rev 55988)
+++ brlcad/trunk/src/tclscripts/rtwizard/lib/PictureTypeF.itcl 2013-07-09
20:46:38 UTC (rev 55989)
@@ -187,15 +187,26 @@
#
set perspective [$viewPage getPerspective]
- ::cadwidgets::rtimage $::RtWizard::wizard_state(dbFile) $fb \
- $w $h \
- $viewsize $orientation $eye_pt $perspective\
- $bg $l $nl\
- $occMode $gamma \
- $color_objects \
- $ghost_objects \
- $line_objects
+ set rtimage_dict [dict create \
+ _dbfile $::RtWizard::wizard_state(dbFile) \
+ _port $fb \
+ _w $w \
+ _n $h \
+ _viewsize $viewsize \
+ _orientation $orientation \
+ _eye_pt $eye_pt \
+ _perspective $perspective \
+ _bgcolor $bg \
+ _ecolor $l \
+ _necolor $nl \
+ _occmode $occMode \
+ _gamma $gamma \
+ _color_objects $color_objects \
+ _ghost_objects $ghost_objects \
+ _edge_objects $line_objects ]
+ ::cadwidgets::rtimage $rtimage_dict
+
# If we're outputting a file, write it out and close down
# the in-memory fbserv
if {[info exists filename]} {
Modified: brlcad/trunk/src/tclscripts/rtwizard/rtwizard
===================================================================
--- brlcad/trunk/src/tclscripts/rtwizard/rtwizard 2013-07-09 20:45:49 UTC
(rev 55988)
+++ brlcad/trunk/src/tclscripts/rtwizard/rtwizard 2013-07-09 20:46:38 UTC
(rev 55989)
@@ -88,6 +88,8 @@
{line-color "" {::have_line_color
::RtWizard::wizard_state(e_color)}}
{non-line-color "" {::have_non_line_color
::RtWizard::wizard_state(ne_color)}}
{occlusion O {::have_occlusion_mode
::RtWizard::wizard_state(occmode)}}
+ {benchmark "" {::benchmark_mode}}
+ {cpu-count "" {::have_cpu_count
::RtWizard::wizard_state(cpu_count)}}
# Image type
{type t {::have_picture_type
::RtWizard::wizard_state(picture_type)}}
# View
@@ -463,15 +465,28 @@
set eye_pt [lrange [lindex $vdata 2] 1 end]
}
- ::cadwidgets::rtimage $::RtWizard::wizard_state(dbFile)
$::RtWizard::wizard_state(fbserv_port) \
- $::RtWizard::wizard_state(width)
$::RtWizard::wizard_state(scanlines) \
- $viewsize $orientation $eye_pt
$::RtWizard::wizard_state(perspective) \
- $::RtWizard::wizard_state(bg_color)
$::RtWizard::wizard_state(e_color) $::RtWizard::wizard_state(ne_color)\
- $::RtWizard::wizard_state(occmode)
$::RtWizard::wizard_state(ghosting_intensity) \
- $::RtWizard::wizard_state(color_objlist) \
- $::RtWizard::wizard_state(ghost_objlist) \
- $::RtWizard::wizard_state(line_objlist)
+ # populate a dictionary to pass to rtimage
+ set rtimage_dict [dict create \
+ _dbfile $::RtWizard::wizard_state(dbFile) \
+ _port $::RtWizard::wizard_state(fbserv_port) \
+ _w $::RtWizard::wizard_state(width) \
+ _n $::RtWizard::wizard_state(scanlines) \
+ _viewsize $viewsize \
+ _orientation $orientation \
+ _eye_pt $eye_pt \
+ _perspective $::RtWizard::wizard_state(perspective) \
+ _bgcolor $::RtWizard::wizard_state(bg_color) \
+ _ecolor $::RtWizard::wizard_state(e_color) \
+ _necolor $::RtWizard::wizard_state(ne_color)\
+ _occmode $::RtWizard::wizard_state(occmode) \
+ _gamma $::RtWizard::wizard_state(ghosting_intensity) \
+ _color_objects $::RtWizard::wizard_state(color_objlist) \
+ _ghost_objects $::RtWizard::wizard_state(ghost_objlist) \
+ _edge_objects $::RtWizard::wizard_state(line_objlist) ]
+
+ ::cadwidgets::rtimage $rtimage_dict
+
if {[info exists ::RtWizard::wizard_state(output_filename)]} {
set output_generated 0
if {[file extension $::RtWizard::wizard_state(output_filename)] ==
".png"} {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits