Changeset 3637 for trunk/gui/scripts/drawing.tcl
- Timestamp:
- Apr 26, 2013, 5:25:25 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/drawing.tcl
r3330 r3637 18 18 19 19 itcl::class Rappture::Drawing { 20 constructor {xmlobj path} {21 # defined below22 }23 destructor {24 # defined below25 }26 public method limits {axis}27 public method label { elem }28 public method type { elem }29 public method style { elem }30 public method shape { elem }31 public method values { elem }32 public method data { elem }33 public method hints {{keyword ""}}34 public method components { args }35 36 20 private variable _drawing 37 21 private variable _xmlobj … … 45 29 private variable _units 46 30 private variable _limits 47 } 31 32 constructor {xmlobj path} { 33 # defined below 34 } 35 destructor { 36 # defined below 37 } 38 public method limits {axis} 39 public method label { elem } 40 public method type { elem } 41 public method style { elem } 42 public method shape { elem } 43 public method values { elem } 44 public method data { elem } 45 public method hints {{keyword ""}} 46 public method components { args } 47 private method PdbToVtk { cname contents } 48 } 49 48 50 49 51 # ---------------------------------------------------------------------- … … 97 99 } 98 100 molecule* { 99 set _data($elem) [$_xmlobj get $path.$elem.vtk] 101 set pdbdata [$_xmlobj get $path.$elem.pdb] 102 if { $pdbdata != "" } { 103 set contents [PdbToVTk $elem $pdbdata] 104 } else { 105 set contents [$_xmlobj get $path.$elem.vtk] 106 } 100 107 set _data($elem) [string trim $_data($elem)] 101 108 set _styles($elem) [$_xmlobj get $path.$elem.about.style] … … 330 337 } 331 338 339 340 itcl::body Rappture::Drawing::PdbToVtk { cname contents } { 341 package require vtk 342 343 set reader $this-datasetreader 344 vtkPDBReader $reader 345 346 # Write the contents to a file just in case it's binary. 347 set tmpfile $cname[pid].pdb 348 set f [open "$tmpfile" "w"] 349 fconfigure $f -translation binary -encoding binary 350 puts $f $contents 351 close $f 352 $reader SetFileName $tmpfile 353 $reader Update 354 file delete $tmpfile 355 356 set output [$reader GetOutput] 357 set pointData [$output GetPointData] 358 set _scalars {} 359 for { set i 0 } { $i < [$pointData GetNumberOfArrays] } { incr i } { 360 set name [$pointData GetArrayName $i] 361 lappend _scalars $name $name "???" 362 } 363 set tmpfile $cname[pid].vtk 364 set writer $this-datasetwriter 365 vtkDataSetWriter $writer 366 $writer SetInputConnection [$reader GetOutputPort] 367 $writer SetFileName $tmpfile 368 $writer Write 369 rename $reader "" 370 rename $writer "" 371 372 set f [open "$tmpfile" "r"] 373 fconfigure $f -translation binary -encoding binary 374 set vtkdata [read $f] 375 close $f 376 file delete $tmpfile 377 return $vtkdata 378 }
Note: See TracChangeset
for help on using the changeset viewer.