Revision: 41111
http://brlcad.svn.sourceforge.net/brlcad/?rev=41111&view=rev
Author: bob1961
Date: 2010-10-19 19:12:57 +0000 (Tue, 19 Oct 2010)
Log Message:
-----------
Added DataUtils::measureLastDataPoints for measuring the distance between the
last two data axes.
Modified Paths:
--------------
brlcad/trunk/src/tclscripts/archer/DataUtils.tcl
brlcad/trunk/src/tclscripts/archer/tclIndex
Modified: brlcad/trunk/src/tclscripts/archer/DataUtils.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/archer/DataUtils.tcl 2010-10-19 17:32:28 UTC
(rev 41110)
+++ brlcad/trunk/src/tclscripts/archer/DataUtils.tcl 2010-10-19 19:12:57 UTC
(rev 41111)
@@ -37,6 +37,7 @@
_data_axes_name _sdata_axes_name
_data_labels_name _sdata_labels_name
_data_lines_name _sdata_lines_name}
+ proc measureLastDataPoints {_ged _archer _group _attr_name _pindex
{_sindex -1}}
proc updateData {_ged _archer _group
_attr_name _data_cmd _data_subcmd}
proc updateGlobalData {_ged _archer _group _attr_name _data_cmd
_data_subcmd}
@@ -489,6 +490,68 @@
}
}
+::itcl::body DataUtils::measureLastDataPoints {_ged _archer _group _attr_name
_pindex {_sindex -1}} {
+ if {[catch {$_ged attr get _GLOBAL $_attr_name} dl]} {
+ return
+ }
+
+ # Get the data list for the specified group
+ set i [lsearch -index 0 $dl $_group]
+ if {$i != -1} {
+ set gd [lindex $dl $i]
+ } else {
+ return
+ }
+
+ # Strip off the group name
+ set data [lrange $gd 1 end]
+
+ # If a valid index is specified for indicating selection
+ # of data then collect the selected data.
+ if {[string is digit $_sindex]} {
+ set all_data $data
+ set data {}
+ foreach item $all_data {
+ if {[lindex $item $_sindex]} {
+ lappend data $item
+ }
+ }
+ }
+
+ set last_index [expr {[llength $data] - 1}]
+ if {$last_index < 1} {
+ return
+ }
+
+ set pindex_end [expr {$_pindex + 2}]
+
+ # Make sure dataA has enough values
+ set dataA [lindex $data end-1]
+ set last_index [expr {[llength $dataA] - 1}]
+ if {$last_index < $pindex_end} {
+ return
+ }
+
+ # Make sure dataB has enough values
+ set dataB [lindex $data end]
+ set last_index [expr {[llength $dataB] - 1}]
+ if {$last_index < $pindex_end} {
+ return
+ }
+
+ if {[catch {
+ set ptA [lrange $dataA $_pindex $pindex_end]
+ set ptB [lrange $dataB $_pindex $pindex_end]
+ set dist [vmagnitude [vsub2 $ptB $ptA]]
+ set dist [expr {$dist * [$_ged base2local]}]
+ } msg]} {
+ return
+ }
+
+ $_archer putString "Measured distance between data points: $dist [$_ged
units -s]."
+ $_archer setStatusString "Measured distance between data points: $dist
[$_ged units -s]."
+}
+
::itcl::body DataUtils::updateData {_ged _archer _group
_attr_name _data_cmd _data_subcmd} {
if {[catch {$_ged attr get _GLOBAL $_attr_name} dal]} {
Modified: brlcad/trunk/src/tclscripts/archer/tclIndex
===================================================================
--- brlcad/trunk/src/tclscripts/archer/tclIndex 2010-10-19 17:32:28 UTC (rev
41110)
+++ brlcad/trunk/src/tclscripts/archer/tclIndex 2010-10-19 19:12:57 UTC (rev
41111)
@@ -682,5 +682,6 @@
set auto_index(::DataUtils) [list source [file join $dir DataUtils.tcl]]
set auto_index(::DataUtils::appendGlobalData) [list source [file join $dir
DataUtils.tcl]]
set auto_index(::DataUtils::dataPick) [list source [file join $dir
DataUtils.tcl]]
+set auto_index(::DataUtils::measureLastDataPoints) [list source [file join
$dir DataUtils.tcl]]
set auto_index(::DataUtils::updateData) [list source [file join $dir
DataUtils.tcl]]
set auto_index(::DataUtils::updateGlobalData) [list source [file join $dir
DataUtils.tcl]]
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits