wrappers.tcl
上传用户:kellyonhid
上传日期:2013-10-12
资源大小:932k
文件大小:5k
源码类别:

3D图形编程

开发平台:

Visual C++

  1. proc flashCenterOfRotation {} {
  2.     global rotCenterVisible
  3.     global rotCenterOnTop
  4.     set cv $rotCenterVisible
  5.     set cot $rotCenterOnTop
  6.     set rotCenterOnTop 1
  7.     set rotCenterVisible 1
  8.     redraw 1
  9.     set rotCenterVisible 0
  10.     redraw 1
  11.     set rotCenterVisible 1
  12.     redraw 1
  13.     set rotCenterVisible $cv
  14.     set rotCenterOnTop $cot
  15. }
  16. alias bmset bmesh
  17. alias rotmesh plv_rotmesh
  18. alias rotview plv_rotview
  19. proc rotview {axis angle} {
  20.     plv_rotview $axis $angle
  21. }
  22. proc highQualityDraw { {aa -1} {shadows -1} } {
  23.     # make any menus onscreen go away before, not after, we redraw
  24.     update
  25.     if {$aa == -1} {
  26. set aa [globalset styleAntiAlias]
  27.     }
  28.     if {$shadows == -1} {
  29. set shadows [globalset styleShadows]
  30.     }
  31.     plv_drawstyle -antialias $aa -shadows $shadows
  32.     globalset highQualSingle 1
  33.     redraw 1
  34.     globalset highQualSingle 0
  35.     plv_drawstyle 
  36. -antialias [globalset styleAntiAlias] 
  37. -shadows [globalset styleShadows]
  38. }
  39. proc invertMeshNormals {mesh} {
  40.     FlipMeshNormals $mesh
  41.     global toglPane
  42.     $toglPane render
  43. }
  44. proc reloadMesh {mesh} {
  45.     set file [plv_get_scan_filename $mesh]
  46.     set answer [tk_messageBox -default yes -icon question 
  47.     -message "Save xform first?" 
  48.     -title "Scanalyze: reload $mesh" -type yesnocancel]
  49.     if {$answer == "cancel"} {
  50. return
  51.     }
  52.     if {$answer == "yes"} {
  53. plv_write_metadata $mesh xform;
  54.     }
  55.     # preserve resolution, selection as much as possible
  56.     set oldMesh [globalset theMesh]
  57.     set oldColor [plv_scan_colorcode get $mesh]
  58.     set rl [plv_getreslist $mesh short]
  59.     set ri [lsearch -exact $rl [plv_getcurrentres $mesh]]
  60.     redraw block
  61.     catch {
  62. if {[confirmDeleteMesh $mesh]} {
  63.     readfile $file
  64.     
  65.     # if it was selected, it won't be now; restore this
  66.     if {$oldMesh == $mesh} {
  67. globalset theMesh $mesh
  68.     }
  69.     
  70.     # set old resolution index
  71.     set rl [plv_getreslist $mesh short]
  72.     plv_resolution $mesh [lindex $rl $ri]
  73.     SetMeshFalseColor $mesh $oldColor
  74. }
  75.     }
  76.     redraw flush
  77. }
  78. # TODO: confirmation
  79. # if dirty, prompt save? yes/no/cancel
  80. # if clean, prompt delete? ok/cancel
  81. # or maybe this should happen automatically on the C++ side, in the
  82. # destructor, so you get that behavior at exit time too
  83. proc confirmDeleteMesh {mesh} {
  84.     
  85.     plv_meshsetdelete $mesh
  86.     removeMeshFromWindow $mesh
  87.     redraw 1    
  88.     plv_pickscan init
  89.     updateFromAndToMeshNames
  90.     return 1
  91. }
  92. proc cursor {name} {
  93.     global toglPane
  94.     global oldCursor
  95.     if {[globalset noui]} return
  96.     if {$name == "restore"} {
  97. $toglPane config -cursor $oldCursor
  98.     } else {
  99. set oldCursor [lindex [$toglPane config -cursor] 4]
  100. $toglPane config -cursor $name
  101.     }
  102.     update idletasks
  103. }
  104. proc showCameraInfo {} {
  105.     tk_messageBox -title "Camera info" -icon info 
  106. -message [plv_camerainfo graphical]
  107. }
  108. proc showMeshInfo {theMesh} {
  109.     tk_messageBox -title "Mesh info for $theMesh" -icon info 
  110. -message [plv_meshinfo $theMesh graphical]
  111. }
  112. proc setShininess {shiny} {
  113.     if {$shiny} {
  114.         plv_material -shininess 90 -specular 0.25 0.25 0.25
  115.     } else {
  116.         plv_material -specular 0 0 0 
  117.     }
  118. }
  119. proc analyze_line_depth {} {
  120.     global theMesh
  121.     plv_analyze_line_depth $theMesh
  122. }
  123. alias quit confirmQuit
  124. proc manipulateScan {scan} {
  125.     plv_selectscan $scan manipulate
  126. }
  127. proc buildCurrentMeshResList {menu} {
  128.     buildMeshResList [globalset theMesh] $menu
  129. }
  130. proc translateinplane {x y} {
  131.     set x [expr $x * 1.0 / [globalset theUnitScale]]
  132.     set y [expr $y * 1.0 / [globalset theUnitScale]]
  133.     plv_translateinplane $x $y
  134. }
  135. proc getSortedMeshList {{onlyvis 0}} {
  136.     global meshControlsSort
  137.     if {$onlyvis} {
  138. set invis "onlyvisible"
  139.     } else {
  140. set invis ""
  141.     }
  142.     return [eval plv_sort_scan_list 
  143. $meshControlsSort(1) 
  144. $meshControlsSort(2) 
  145. $meshControlsSort(3) 
  146. $meshControlsSort(4) 
  147. $meshControlsSort(5) 
  148. $meshControlsSort(mode) 
  149. $invis 
  150.    ]
  151. }
  152. proc showOnlyIcpMeshes {} {
  153.     global regICPFrom
  154.     global regICPTo
  155.     showOnlyMesh $regICPFrom $regICPTo
  156. }
  157. proc getActiveMesh {} {
  158.     if {[globalset theMover] == "mesh"} {
  159. return [globalset theMesh]
  160.     } else {
  161. return ""
  162.     }
  163. }
  164. proc alignToFitPlane {{mover camera}} {
  165.     global pfcrData
  166.     plv_clipBoxPlaneFit [globalset theMesh] align $pfcrData move$mover
  167. }
  168. proc GetMeshFalseColor {mesh} {
  169.     return [plv_scan_colorcode get $mesh]
  170. }
  171. proc SetMeshFalseColor {mesh color} {
  172.     plv_scan_colorcode set $mesh $color
  173.     global meshFrame
  174.     $meshFrame($mesh).title.color config -background $color
  175.     $meshFrame($mesh).title.curBar config -background $color
  176. }
  177. proc guiError {message {parent .}} {
  178.     tk_messageBox -title "Scanalyze error" -icon error 
  179. -parent $parent -message $message
  180. }