PageRenderTime 141ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 1ms

/binaries/theo/data

https://bitbucket.org/titiller/atgc
#! | 11949 lines | 11578 code | 371 blank | 0 comment | 0 complexity | a46072b61571bbf554c0a511964b7832 MD5 | raw file
Possible License(s): 0BSD
  1. ####################
  2. # SCRIPTREE
  3. # Copyright Š 2000-2008 Chevenet F. chevenet@ird.fr
  4. # IRD SPIRALES
  5. #
  6. # This program is under the terms of the GNU General Public License
  7. ####################
  8. ####################
  9. # INTERFACE
  10. ####################
  11. namespace eval Interface {
  12. proc TreeDynInitialisation {} {
  13. global tcl_platform S T db IMGshn IMGil1 B asedCon find
  14. #des preferences
  15. set S(ltoolboxusername) {}
  16. set S(toolboxType) all
  17. set S(Preference_display_eu) 1
  18. set S(Preference_fgc) black
  19. set S(Preference_mainXY) +297+129
  20. set S(Preference_display_eu) 1
  21. set S(Preference_fgc) black
  22. set S(version) "TreeDyn (196.3)"
  23. set S(treedynpack) Marianne
  24. set S(patchnumber) 196
  25. set S(manual) 1.0
  26. set S(TreeDynUpdate) {Marianne 196 1.0}
  27. set S(loc) 1
  28. set S(history) ""
  29. set S(AutoReset) 0
  30. set S(illustration-tabulation) 0
  31. set S(TabulationAnnot) 5
  32. set S(-family) Arial
  33. set S(-weight) normal
  34. set S(-size) 10
  35. set S(-slant) roman
  36. set S(-underline) 0
  37. set S(-overstrike) 0
  38. set S(gfo) [list -family $S(-family) \
  39. -weight $S(-weight) \
  40. -size $S(-size) \
  41. -slant $S(-slant) \
  42. -underline $S(-underline) \
  43. -overstrike $S(-overstrike)]
  44. set S(fontbase) [list -family Arial -weight normal -size 10 -slant roman -underline 0 -overstrike 0]
  45. # Database
  46. set S(lastid) 0
  47. set S(nbobj) 0
  48. set S(database) ""
  49. set S(ldatabase) {}
  50. set asedCon [interp create treedyn]
  51. $asedCon alias db "Database::db"
  52. set S(topmessage) $S(version)
  53. set S(ghi) grey ;# couleur de hightlight
  54. set S(ilt) 0 ;# liste des identificateurs tree
  55. set S(ilw) 0 ;# liste des identificateurs windows
  56. set S(col) red
  57. set S(display_eu) normal
  58. set S(nodefilter) 0
  59. set S(tool) move
  60. set S(cp) "" ; # variable contenant les arguemnts pour les copy/paste
  61. set S(und) "?" ; # variable undo
  62. set S(Xfactor) 1.0
  63. set S(Yfactor) 1.0
  64. set S(collection) "" ;# liste des ID de collection (processus de copy / paste)
  65. set S(browserCP_width) 150
  66. set S(browserCP_height) 150
  67. ### variable package supertree
  68. set S(supertreeConsDisplayNewWindow) 1
  69. set S(supertreeConsDisplaySameWindow) 1
  70. set S(supertreeConsFile) 0
  71. ##### variable de reset graphique
  72. set S(OpResetLFgC) 0
  73. set S(OpResetLBgC) 0
  74. set S(OpResetLF) 0
  75. set S(OpResetNFgC) 0
  76. set S(OpResetNBgC) 0
  77. set S(OpResetNLW) 0
  78. set S(OpResetNLD) 0
  79. set S(OpResetNUS) 0
  80. set S(OpResetNUC) 0
  81. set S(OpResetAL) 0
  82. set S(OpResetAN) 0
  83. set S(OpResetAC) 0
  84. set S(AutoReset) 0 ;# variable de reset automatic du panel "Interface::Find"
  85. ##### variable/ valeur par defaut pour exportation HTML
  86. set S(url-prefix) "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=Nucleotide&cmd=search&val="
  87. set S(stipple) z.xbm
  88. # variable clavier virtuel (illustration)
  89. set S(ill-family) Wingdings
  90. set S(ill-size) 6
  91. set S(ill-weight) normal
  92. set S(ill-overstrike) 0
  93. set S(ill-underline) 0
  94. set S(ill-slant) roman
  95. # operation l'identification
  96. set S(operation) leaffgcolor
  97. set S(operationName) "Leaf Foreground Color"
  98. set S(operationlabelisation) menu
  99. set S(operationdatabase) localisation
  100. set S(AnnotateNote) <text>
  101. set S(illustration-tabulation) 0
  102. set S(TabulationAnnot) 5
  103. set S(loc) 1
  104. set S(history) {}
  105. set find(case) 1
  106. set S(newW) 350 ;# Width et Height par defaut
  107. set S(newH) 350 ;# Width et Height par defaut
  108. set S(defaultshape) 1 ;# la forme par defaut des backgrounds
  109. set S(DisplayVOV) 1 ;# variable pour qLannC et qLannC360 pour differencie affichage variableValeur
  110. # variable MULTI IMPORT
  111. set S(MultiImportTDY) 0
  112. set S(MultiImportSFN) "0 File(s)"
  113. set S(MultiImportAFN) "0 File(s)"
  114. set S(MultiImportTRE) "0 Tree(s)"
  115. set S(MultiImportDII) {} ;# conservation des directories deja visitees
  116. set S(MultiImportTAR) new
  117. set S(MultiImportNBC) 3
  118. # fonte d'illustration par defaut
  119. set S(ill-fon) +
  120. set S(ill-car) +
  121. #variable SIMPLE IMPORT
  122. set S(SimpleImportTDY) 0
  123. set S(SimpleImportAFN) "0 File(s)"
  124. set S(SimpleImportTRE) "0 Tree(s)"
  125. set S(SimpleImportDII) {} ;# conservation des directories deja visitees
  126. # parametre par defaut Legend (identification query variable)
  127. set S(LegendLabels) 0
  128. set S(LegendVariable) 0
  129. set S(LegendOperator) 0
  130. set S(LegendOperation) 0
  131. set S(LegendBox) 1
  132. set S(LegendCadre) 0
  133. # variable BigImport
  134. set S(BIseuil) 5
  135. set S(ImportAUTOTAR) 1 ;# autotarget
  136. set S(alterTool) move
  137. set S(toolswitch) ""
  138. }
  139. }
  140. ####################
  141. ####################
  142. # REFLECTION
  143. ####################
  144. namespace eval Reflection {
  145. ### Transition I / Transition Empirique Simple
  146. proc Transition-I {w} {
  147. global S T
  148. set tags [$w gettags [$w find withtag current]]
  149. set n [string trimright \
  150. [lindex $tags [lsearch -glob $tags *C]] C]
  151. set t [string range \
  152. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  153. if {$n != ""} {
  154. foreach key [array names S *,tar] {
  155. if {$S($key) == 1} {
  156. set ti [string range $key 0 [expr [string first , $key] - 1]]
  157. if {$ti != 0} {
  158. set wi $S($ti,w)
  159. #liste des codes
  160. set SouCodLea [Tools::NodeNoToLe $t $n]
  161. #liste de noms
  162. set SouRefLea [Tools::NodeLeCoToRe $t $SouCodLea]
  163. Operation::Operation $wi $ti $SouRefLea
  164. }
  165. }
  166. }
  167. }
  168. }
  169. #
  170. proc ConnectionAction {w t n key} {
  171. global S T
  172. #liste des codes
  173. set SouCodLea [Tools::NodeNoToLe $t $n]
  174. #liste de noms
  175. set SouRefLea [Tools::NodeLeCoToRe $t $SouCodLea]
  176. if {$key != "nodenetwork"} {
  177. foreach ti $S($w,t) {
  178. switch $key {
  179. nodefgcolor {
  180. set peres [FindFatherNode $ti $SouRefLea]
  181. foreach ni $peres {
  182. Figuration::NodeColorFgTree $ti $ni $S(col)
  183. }
  184. }
  185. leaffgcolor {
  186. set peres [FindFatherNode $ti $SouRefLea]
  187. foreach ni $peres {
  188. Figuration::NodeColorFgLeaf $ti $ni $S(col)
  189. }
  190. }
  191. shrink {
  192. set peres [FindFatherNode $ti $SouRefLea]
  193. foreach ni $peres {
  194. Abstraction::Shrink $w $ti $ni
  195. }
  196. }
  197. unshrink {
  198. set peres [FindFatherNode $ti $SouRefLea]
  199. foreach ni $peres {
  200. Abstraction::ShrinkUn $w $ti $ni
  201. }
  202. }
  203. nodebgcolor {
  204. set peres [FindFatherNode $ti $SouRefLea]
  205. foreach ni $peres {
  206. Figuration::NodeColorBgSubTree $ti $ni
  207. }
  208. }
  209. leafbgcolor {
  210. set peres [FindFatherNode $ti $SouRefLea]
  211. foreach ni $peres {
  212. Figuration::NodeColorBgLeaf $ti $ni
  213. }
  214. }
  215. leaffontglob {
  216. set peres [FindFatherNode $ti $SouRefLea]
  217. foreach ni $peres {
  218. Figuration::FontSetGlobal $ti $ni $S(gfo)
  219. }
  220. }
  221. widthline+ {
  222. set peres [FindFatherNode $ti $SouRefLea]
  223. foreach ni $peres {
  224. Figuration::NodeLineWidth $ti $ni +
  225. }
  226. }
  227. widthline- {
  228. set peres [FindFatherNode $ti $SouRefLea]
  229. foreach ni $peres {
  230. Figuration::NodeLineWidth $ti $ni -
  231. }
  232. }
  233. nodedashOn {
  234. set peres [FindFatherNode $ti $SouRefLea]
  235. foreach ni $peres {
  236. Figuration::NodeLineDash $ti $ni 1
  237. }
  238. }
  239. nodedashOff {
  240. set peres [FindFatherNode $ti $SouRefLea]
  241. foreach ni $peres {
  242. Figuration::NodeLineDash $ti $ni 0
  243. }
  244. }
  245. leafhide {
  246. }
  247. leafdisplay {
  248. }
  249. collapse {
  250. }
  251. uncollapse {
  252. }
  253. anotationmatrix {
  254. Annotation::LabelMatrix $w $ti $SouRefLea User
  255. }
  256. }
  257. }
  258. } else {
  259. set lkv {}
  260. lappend lkv $t $n
  261. foreach ti $S($w,t) {
  262. set peres [FindFatherNode $ti $SouRefLea]
  263. foreach ni $peres {
  264. lappend lkv $ti $ni
  265. }
  266. }
  267. Reflection::NodeNetworkBuild $w $lkv ""
  268. }
  269. }
  270. # des feuilles vers des feuilles
  271. proc Transition-IIIAction {w t n database variable} {
  272. global S T
  273. # liste feuilles sources
  274. set SouRefLea [Tools::NodeLeCoToRe $t [Tools::NodeNoToLe $t $n]]
  275. # liste records dont la valeur de la variable contient au moins une feuille de liste source
  276. set MatchingRecords {}
  277. foreach f $SouRefLea {
  278. # ceci ok si la variable a pour valeurs des feuilles
  279. set recordsOK [Database::dbQueryRecordsFromVarPatVal $database $variable $f]
  280. foreach r $recordsOK {
  281. if {[lsearch -exact $MatchingRecords $r] == -1} {lappend MatchingRecords $r}
  282. }
  283. }
  284. # traduction records vers leafs
  285. set leaves [Database::dbQueryEusFromRecords $database $MatchingRecords]
  286. # localisation multi-arbres
  287. # allumage
  288. foreach key [array names S *,tar] {
  289. if {$S($key) == 1} {
  290. set ti [string range $key 0 [expr [string first , $key] - 1]]
  291. if {$ti != 0} {
  292. set wi $S($ti,w)
  293. # allumer les resultats
  294. Operation::Operation $w $ti $leaves
  295. # allumer la source et ses copies
  296. Operation::Operation $w $ti $SouRefLea
  297. }
  298. }
  299. }
  300. }
  301. ###
  302. proc Transition-IIAction {w t n database variable} {
  303. global S T
  304. # liste feuilles sources
  305. set SouRefLea [Tools::NodeLeCoToRe $t [Tools::NodeNoToLe $t $n]]
  306. # liste records correspondant aux feuilles sources
  307. set MatchingRecords {}
  308. foreach f $SouRefLea {
  309. set recordsOK [Database::dbQueryRecordsFromVarPatVal $database EU $f]
  310. foreach r $recordsOK {
  311. lappend MatchingRecords $r
  312. }
  313. }
  314. # liste valeurs pour $variable sur les matching records
  315. upvar #0 $database X
  316. set MatchingValues {}
  317. foreach r $MatchingRecords {
  318. set t $X($r)
  319. if {!([set pos [lsearch $t $variable]]%2)} {
  320. set val [lindex $t [incr pos]]
  321. if {[lsearch -exact $MatchingValues $val] == -1} {lappend MatchingValues $val}
  322. }
  323. }
  324. # Records matchant les MatchingValues sur la $database
  325. set MatchingRecordsFinal {}
  326. foreach v $MatchingValues {
  327. set recordsOK [Database::dbQueryRecordsFromVarPatVal $database $variable $v]
  328. foreach r $recordsOK {
  329. if {[lsearch -exact $MatchingRecordsFinal $r] == -1} {lappend MatchingRecordsFinal $r}
  330. }
  331. }
  332. # traduction records vers leafs
  333. set leaves [Database::dbQueryEusFromRecords $database $MatchingRecordsFinal]
  334. # localisation multi-arbres
  335. foreach key [array names S *,tar] {
  336. if {$S($key) == 1} {
  337. set ti [string range $key 0 [expr [string first , $key] - 1]]
  338. if {$ti != 0} {
  339. set wi $S($ti,w)
  340. Operation::Operation $w $ti $leaves
  341. }
  342. }
  343. }
  344. }
  345. ### OPTIMISATION : si un node est ok : ne pas tester ses nodes fils
  346. proc FindFatherNode {t SouRefLea} {
  347. global S T
  348. set L {}
  349. if {[llength $SouRefLea] != 1} {
  350. foreach TarCodNod [lsort -dictionary $T($t,all_cod)] {
  351. # selection des codes leaf issus de node
  352. set TarCodLea [Tools::NodeNoToLe $t $TarCodNod]
  353. # passage codes leaf -> references leaf
  354. set TarRefLea [Tools::NodeLeCoToRe $t $TarCodLea]
  355. # test inclusion des references leaf de TARGET avec SOURCE
  356. if {$S(nodefilter) == 0} {
  357. set r [Tools::ListInclu $TarRefLea $SouRefLea]
  358. if {$r == 1} {lappend L $TarCodNod}
  359. } else {
  360. set r [Tools::ListIncluSauf $TarRefLea $SouRefLea $S(nodefilter)]
  361. if {$r == 1} {lappend L $TarCodNod}
  362. }
  363. }
  364. # meme node pere possibles
  365. # differents nodes peres possibles
  366. # -> identification des nodes peres de plus haut niveau
  367. set l [Tools::NodeFaNoId {} $L]
  368. if {$L == {}} {return {}} {return $l}
  369. } {
  370. if {[lsearch -exact $T($t,ue_lab) $SouRefLea] != -1} {return $T($t,ltc,$SouRefLea)} else {return {}}
  371. }
  372. }
  373. ### allume fg leafs et nodes a partir d'un node select par user
  374. ### et compare les topologies, transmission aux tree de la meme fenetre
  375. ### selon resultats comparaison
  376. proc Congruence {w} {
  377. global S T
  378. set tags [$w gettags [$w find withtag current]]
  379. set n [string trimright \
  380. [lindex $tags [lsearch -glob $tags *C]] C]
  381. set t [string range \
  382. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  383. if {$n != ""} {
  384. foreach ti $S($w,t) {
  385. congruenceTNs $t $n $ti
  386. }
  387. }
  388. }
  389. # cette proc applique la procedure congruenceTN a tous les nodes
  390. # issus de nsource issue de tsource
  391. proc congruenceTNs {tsource nsource ttarget} {
  392. global T S
  393. #
  394. set lresult {}
  395. # Figuration::NodeColorFgTree $tsource $nsource $S(col)
  396. set nodesfromsource [Tools::NodeNoCoFaToNoCoCh $tsource $nsource]
  397. # on ne prend pas en compte les codes des feuilles
  398. set latest [Tools::SousL $nodesfromsource $T($tsource,ue_cod)]
  399. foreach node $latest {
  400. lappend lresult [congruenceTN $tsource $node $ttarget]
  401. }
  402. #puts LRESULT$lresult
  403. if {[lsearch $lresult 0] == -1} {
  404. Figuration::NodeColorFgTree $ttarget [lindex $lresult 0] $S(col)
  405. }
  406. }
  407. # si il existe un et un seul node pere de ttarget commun
  408. # aux leafs names de tsource pour nsource, cette fonction
  409. # retourne ce node, sinon retourne 0
  410. proc congruenceTN {tsource nsource ttarget} {
  411. # liste des noms leafs de tsource pour nsource
  412. set SouCodLea [Tools::NodeNoToLe $tsource $nsource]
  413. set SouRefLea [Tools::NodeLeCoToRe $tsource $SouCodLea]
  414. # recherche d'un node pere a ces leafs sur ttarget
  415. set result [Tools::FatherSearch2 $ttarget $SouRefLea]
  416. #puts ===================
  417. #puts $SouRefLea
  418. #puts $result
  419. if {$result != "" && [llength $result] == 1} {
  420. return $result
  421. } else {
  422. return 0
  423. }
  424. }
  425. # compl?Šter un reseau, cad ajouter des nodes
  426. # sachant l'id d'un node network, on reactive la descrition du reseau
  427. # avec en argument le dernier element de B($id,CONnod)
  428. proc ReStartNodeNetwork {w id} {
  429. global S B
  430. set lasttree [lindex $B(CONtre,$id) end]
  431. set S(tool) connect
  432. bindtags $w [list $S(tool) $w Canvas . all]
  433. bind connect <Button-1> "Reflection::Connection %W $id"
  434. bind connect <Double-Button-1> "Reflection::UpdateLinkStop %W $lasttree $id"
  435. bind connect <Motion> "Reflection::UpdateLink %W $lasttree $id %x %y"
  436. }
  437. # delete
  438. proc ConnectorDelete {w id} {
  439. global B S
  440. # nettoyage canvas
  441. $w delete [format "%s%s%s" Connect ? $id]
  442. $w delete [format "%s%s%s" ConIconTag ? $id]
  443. # nettoyage array B
  444. unset B(CONtre,$id)
  445. unset B(CONnod,$id)
  446. unset B(CONnot,$id)
  447. # retrait
  448. set index [lsearch -exact $S($w,con) $id]
  449. set S($w,con) [concat [lrange $S($w,con) 0 [expr $index - 1]] \
  450. [lrange $S($w,con) [expr $index + 1] end]]
  451. }
  452. ### voir modifications pour network en etoile
  453. proc UpdateLink {w t id xmouse ymouse} {
  454. global B S
  455. set lcoords {}
  456. foreach n $B(CONnod,$id) {
  457. set co [$w coords $n]
  458. lappend lcoords [lindex $co 0] [lindex $co 1]
  459. }
  460. lappend lcoords [expr $xmouse - 5] [expr $ymouse - 5]
  461. # prise en compte figuration preexistante
  462. set j [format "%s%s%s" Connect ? $id ]
  463. if {[$w find withtag $j] != ""} {
  464. set width_line [lindex [$w itemconfigure $j -width] end]
  465. set dash_line [lindex [$w itemconfigure $j -dash] end]
  466. set color_line [lindex [$w itemconfigure $j -fill] end]
  467. } else {
  468. set width_line 1
  469. set dash_line {2 2}
  470. set color_line $S(col)
  471. }
  472. $w delete $j
  473. if {$lcoords != {} } {
  474. $w create line $lcoords -width $width_line -fill $color_line -dash $dash_line \
  475. -tags "Connect [format "%s%s%s" Connect ? $id ] "
  476. }
  477. $w lower Connect
  478. }
  479. #
  480. proc UpdateLinkStop {w t id} {
  481. global B
  482. set lcoords {}
  483. foreach n $B(CONnod,$id) {
  484. set co [$w coords $n]
  485. lappend lcoords [lindex $co 0] [lindex $co 1]
  486. }
  487. set j [format "%s%s%s" Connect ? $id ]
  488. set width_line [lindex [$w itemconfigure $j -width] end]
  489. set dash_line [lindex [$w itemconfigure $j -dash] end]
  490. set color_line [lindex [$w itemconfigure $j -fill] end]
  491. $w delete $j
  492. if {[llength $lcoords] != 2 } {
  493. $w create line $lcoords -fill $color_line -dash $dash_line -width $width_line \
  494. -tags "Connect $j"
  495. }
  496. bind connect <Button-1> "Reflection::Connection %W"
  497. # mise a nil pour le reste
  498. bind connect <Motion> ""
  499. bind connect <Double-Button-1> ""
  500. }
  501. #
  502. proc UpdateAll {w} {
  503. global B S
  504. foreach id $S($w,con) {
  505. set lcoords {}
  506. foreach n $B(CONnod,$id) {
  507. set co [$w coords $n]
  508. lappend lcoords [lindex $co 0] [lindex $co 1]
  509. }
  510. set j [format "%s%s%s" Connect ? $id ]
  511. set width_line [lindex [$w itemconfigure $j -width] end]
  512. set dash_line [lindex [$w itemconfigure $j -dash] end]
  513. set color_line [lindex [$w itemconfigure $j -fill] end]
  514. set state [lindex [$w itemconfigure $j -state] end]
  515. $w delete $j
  516. if {[llength $lcoords] != 2 } {
  517. $w create line $lcoords -fill $color_line -dash $dash_line -width $width_line \
  518. -tags "Connect $j" -state $state
  519. }
  520. }
  521. $w lower Connect
  522. }
  523. proc ConnectNoteOk {w id} {
  524. global B
  525. set B(CONnot,$id) [.connectnote.st get 1.0 end]
  526. destroy .connectnote
  527. Reflection::ConnectorIconifyUpdate $w $id
  528. }
  529. # network ON/OFF
  530. proc ConnectorIconifyONOFF {w id} {
  531. set connector [format "%s%s%s" Connect ? $id ]
  532. set etat [$w itemcget $connector -state]
  533. if {$etat == "normal"} {
  534. $w itemconfigure $connector -state hidden
  535. } else {
  536. $w itemconfigure $connector -state normal
  537. }
  538. }
  539. #
  540. proc ConnectorIconify {w id x y } {
  541. global B S
  542. set connector [format "%s%s%s" Connect ? $id ]
  543. set ConIconTag [format "%s%s%s" ConIconTag ? $id]
  544. # destruction de l'ancien si existe, mais on conserve x y
  545. set idtext [$w find withtag [list $ConIconTag && text]]
  546. set idline [$w find withtag [list $ConIconTag && line]]
  547. if {$idline != ""} {
  548. set coords [$w coords $idline]
  549. set x [lindex $coords 0]
  550. set y [lindex $coords 1]
  551. $w delete $idtext
  552. $w delete $idline
  553. }
  554. # $w delete $idtext
  555. # on masque le reseau
  556. $w itemconfigure $connector -state hidden
  557. # on cree l'icon
  558. #set color [lindex [$w itemconfigure $connector -fill] end]
  559. set width_line [lindex [$w itemconfigure $connector -width] end]
  560. set dash_line [lindex [$w itemconfigure $connector -dash] end]
  561. set color_line [lindex [$w itemconfigure $connector -fill] end]
  562. $w create line $x $y [expr $x + 20] $y -width $width_line -dash $dash_line -fill $color_line \
  563. -tag "ConnectIcon $id $ConIconTag line"
  564. if {$B(CONnot,$id) != "" } {
  565. $w create text $x [expr $y + 3] -text "$B(CONnot,$id)" -anchor nw \
  566. -tag "ConnectIcon $id $ConIconTag text" -fill $color_line -font $S(gfo)
  567. } else {
  568. $w create text $x [expr $y + 3] -text "" -anchor nw \
  569. -tag "ConnectIcon $id $ConIconTag text" -fill $color_line -font $S(gfo)
  570. }
  571. }
  572. # mise a jour icone node network apres annotation network (display ON)
  573. proc ConnectorIconifyUpdate {w id} {
  574. global B
  575. set ConIconTag [format "%s%s%s" ConIconTag ? $id]
  576. set idtext [$w find withtag [list $ConIconTag && text]]
  577. $w itemconfigure $idtext -text $B(CONnot,$id) -anchor nw
  578. }
  579. #
  580. proc ConnectorIconRemove {w id} {
  581. set ConIconTag [format "%s%s%s" ConIconTag ? $id]
  582. $w delete $ConIconTag
  583. ConnectorIconifyONOFF $w $id
  584. }
  585. proc ConnectorMerge {w idsource lid} {
  586. global B
  587. # fusion de node network
  588. # lid est soit un id de node network soit une liste d'id node network (selection de all)
  589. # mise a jour array
  590. foreach id $lid {
  591. #tre
  592. foreach tid $B(CONtre,$id) {
  593. if {[lsearch $B(CONtre,$idsource) $tid] == -1} {
  594. lappend B(CONtre,$idsource) $tid
  595. }
  596. }
  597. #nod
  598. foreach nid $B(CONnod,$id) {
  599. if {[lsearch $B(CONnod,$idsource) $nid] == -1} {
  600. lappend B(CONnod,$idsource) $nid
  601. }
  602. }
  603. # mise en ordre
  604. set B(CONnod,$idsource) [lsort -dictionary $B(CONnod,$idsource)]
  605. # not
  606. foreach notid $B(CONnot,$id) {
  607. # on ne garde les note que si elle sont differente de id et pas deja referencees
  608. if {$notid != $id} {
  609. if {[lsearch $B(CONnot,$idsource) $notid] == -1} {
  610. lappend B(CONnot,$idsource) $notid
  611. }
  612. }
  613. }
  614. #deletion graphique
  615. Reflection::ConnectorDelete $w $id
  616. }
  617. # mise a jour graphic de idsource
  618. UpdateAll $w
  619. }
  620. proc NodeNetworkBuild {w lkv note} {
  621. global B S
  622. set id [Tools::GenId]
  623. if {$note == ""} {set note $id}
  624. # liste tree
  625. set B(CONtre,$id) {}
  626. # liste node
  627. set B(CONnod,$id) {}
  628. # note
  629. set B(CONnot,$id) [list $note]
  630. # liste id network / window
  631. lappend S($w,con) $id
  632. foreach {tree node} $lkv {
  633. lappend B(CONtre,$id) $tree
  634. lappend B(CONnod,$id) $node
  635. }
  636. # graphic
  637. set lcoords {}
  638. foreach n $B(CONnod,$id) {
  639. set co [$w coords $n]
  640. lappend lcoords [lindex $co 0] [lindex $co 1]
  641. }
  642. set j [format "%s%s%s" Connect ? $id ]
  643. set width_line 1
  644. set dash_line {2 2}
  645. set color_line $S(col)
  646. $w delete $j
  647. if {[llength $lcoords] != 2 } {
  648. $w create line $lcoords -fill $color_line -dash $dash_line -width $width_line \
  649. -tags "Connect $j"
  650. }
  651. }
  652. }
  653. ####################
  654. ####################
  655. # FIGURATION
  656. ####################
  657. namespace eval Figuration {
  658. ###
  659. proc FontSet {t w n variable value} {
  660. global T
  661. set f [lindex [$w itemconfigure [format "%s%s" $n EUL] -font] end]
  662. set fnew {}
  663. foreach {var val} $f {
  664. if {$var == $variable} {lappend fnew $var $value} {lappend fnew $var $val}
  665. }
  666. set T($t,gfo,$n) $fnew
  667. $w itemconfigure [format "%s%s" $n EUL] -font $fnew
  668. }
  669. ###
  670. proc LineSize {mode} {
  671. global T S
  672. RecLineSize $S(ict) $mode
  673. if {$S(com) != {}} {
  674. foreach t $S(com) {
  675. set current [string range $t 2 [expr [string first .c $t] -1]]
  676. if {$current != $S(ict)} {
  677. RecLineSize $current $mode
  678. }
  679. }
  680. }
  681. }
  682. ###
  683. proc RecLineSize {t mode} {
  684. global T S
  685. set w [format "%s%s%s" .t $t .c]
  686. if {$mode == "+" || $mode == "-"} {
  687. if {$T($t,sel) == "*"} {
  688. foreach c $T($t,all_cod) {
  689. set code [format "%s%s" $c L]
  690. set width_line [lindex [$w itemconfigure $code -width] end]
  691. set new_wl [expr abs($width_line $mode 1)]
  692. $w itemconfigure $code -width $new_wl
  693. $w itemconfigure [format "%s%s" $code C] -width $new_wl
  694. set T($t,gls,$code) $new_wl
  695. }
  696. }
  697. if {$T($t,sel) != "*"} {
  698. foreach c $T($t,sel) {
  699. set code [format "%s%s" $c L]
  700. set width_line [lindex [$w itemconfigure $code -width] end]
  701. set new_wl [expr abs($width_line $mode 1)]
  702. $w itemconfigure $code -width $new_wl
  703. set T($t,gls,$code) $new_wl
  704. }
  705. }
  706. } else {
  707. if {$T($t,sel) == "*"} {
  708. foreach c $T($t,all_cod) {
  709. set code [format "%s%s" $c L]
  710. set new_wl 1
  711. $w itemconfigure $code -width $new_wl
  712. $w itemconfigure [format "%s%s" $code C] -width $new_wl
  713. set T($t,gls,$code) $new_wl
  714. }
  715. }
  716. if {$T($t,sel) != "*"} {
  717. foreach c $T($t,sel) {
  718. set code [format "%s%s" $c L]
  719. set new_wl 1
  720. $w itemconfigure $code -width $new_wl
  721. set T($t,gls,$code) $new_wl
  722. }
  723. }
  724. }
  725. if {$S(desel) == 1} {TBA::UnSelect $w}
  726. }
  727. ###
  728. proc PreLineStipple {mode} {
  729. global T S
  730. set t $S(ict)
  731. set w [format "%s%s%s" .t $t .c ]
  732. LineStipple $t $w $mode
  733. if {$S(com) != {}} {
  734. foreach w $S(com) {
  735. set t [string range $w 2 [expr [string first .c $w] -1]]
  736. if {$t != $S(ict)} {
  737. LineStipple $t $w $mode
  738. }
  739. }
  740. }
  741. }
  742. ###
  743. proc LineStipple {t w mode} {
  744. global T S
  745. foreach c $T($t,sel) {
  746. set code [format "%s%s" $c L]
  747. set dash_line [lindex [$w itemconfigure $code -dash] end]
  748. if {$mode == "+" || $mode == "-"} {
  749. switch -exact $dash_line {
  750. 1 { if {$mode == "+"} {
  751. set new_dl 2
  752. } else {
  753. set new_dl {}
  754. }
  755. }
  756. 15 { if {$mode == "+"} {
  757. set new_dl {}
  758. } else {
  759. set new_dl 14
  760. }
  761. }
  762. {} { if {$mode == "+"} {
  763. set new_dl 1
  764. } else {
  765. set new_dl 15
  766. }
  767. }
  768. default {
  769. set new_dl [expr abs($dash_line $mode 1)]
  770. }
  771. }
  772. } else {set new_dl {}}
  773. set T($t,gld,$c) $new_dl
  774. $w itemconfigure $code -dash $new_dl
  775. }
  776. if {$S(desel) == 1} {TBA::UnSelect $w}
  777. }
  778. #
  779. proc RedrawT {w t} {
  780. $w delete T$t
  781. TDcom::PhyNJ $t $w
  782. }
  783. # restauration sur un arbre entier
  784. proc RestaureT {w t} {
  785. #restauration des variables graphiques
  786. # gfg lbg lfg bbg gfo gls gld
  787. NodeGraVarRest $t
  788. # 2 variables graphiques particulieres (items suplementaires)
  789. # les bg tree et leaf
  790. Figuration::RestaureBGSall $w $t
  791. Figuration::RestaureBGLall $w $t
  792. ### restauration des variables de dessin
  793. # DANS L'ORDRE decomposition, bll , querynode, shrink
  794. #RestaureOVAall $w $t
  795. RestaureBLLall $w $t
  796. RestaureQYNall $w $t
  797. RestaureShrinkAll $w $t
  798. }
  799. #
  800. proc RestaureShrinkAll {w t} {
  801. global T S B IMGshn
  802. # il faut reconstruire la structure hierarchique des shrink
  803. # les plus anciens shrink d'abord, ajout incr?Šmental du tag
  804. # si le tag est deja present on tag pas
  805. foreach id [lsort -increasing $B($t,shi)] {
  806. set TAG [format "%s%s%s" SHI ? $id]
  807. # dessin
  808. set c0 [$w coords $B(SHInod,$id)]
  809. set x0 [lindex $c0 2]
  810. set y0 [lindex $c0 3]
  811. # passer au bitmap set $S(col)
  812. $w create text [expr $x0 +5] $y0 -text + \
  813. -tags "SHRINK [format "%s%s%s" SHN ? $id] T$t" -font $B(SHIfon,$id) -fill $B(SHIcol,$id)
  814. # bll associees a n et ses derives
  815. set pattern [format "%s%s" $B(SHInod,$id) *]
  816. foreach idbll $B($t,bll) {
  817. if {[string match $pattern $B(BLLnod,$idbll)] == 1 } {
  818. if {[$w itemcget $B(BLLidt,$idbll) -state] != "hidden"} {
  819. $w addtag $TAG withtag $B(BLLidt,$idbll)
  820. $w addtag $TAG withtag $B(BLLidl,$idbll)
  821. $w itemconfigure $B(BLLidt,$idbll) -state hidden
  822. $w itemconfigure $B(BLLidl,$idbll) -state hidden
  823. }
  824. }
  825. }
  826. # leaves
  827. set leafs [Tools::NodeNoToLe $t $B(SHInod,$id)]
  828. foreach i $leafs {
  829. set tagi [list [format "%s%s" EUL $T($t,ctl,$i)] && T$t]
  830. if {[$w itemcget $tagi -state] != "hidden"} {
  831. $w addtag $TAG withtag $tagi
  832. $w itemconfigure $tagi -state hidden
  833. }
  834. }
  835. # background leaves
  836. set pattern [format "%s%s" $B(SHInod,$id) *]
  837. foreach idi $B($t,bgl) {
  838. if {[string match $pattern $B(BGLnod,$idi)] == 1} {
  839. if {[$w itemcget [format "%s%s%s" BGL ? $idi] -state] != "hidden"} {
  840. $w addtag $TAG withtag [format "%s%s%s" BGL ? $idi]
  841. $w itemconfigure [format "%s%s%s" BGL ? $idi] -state hidden
  842. }
  843. }
  844. }
  845. # arretes terminales
  846. set Le [Tools::NodeNoToLe $t $B(SHInod,$id)]
  847. foreach e $Le {
  848. if {[$w itemcget $e -state] != "hidden"} {
  849. $w addtag $TAG withtag $e
  850. $w itemconfigure $e -state hidden
  851. }
  852. }
  853. # tree
  854. set lchild [Tools::NodeNoCoFaToNoCoCh $t $B(SHInod,$id)]
  855. foreach i $lchild {
  856. if {[$w itemcget $i -state] != "hidden"} {
  857. $w addtag $TAG withtag [format "%s%s" $i C]
  858. $w itemconfigure [format "%s%s" $i C] -state hidden
  859. }
  860. }
  861. # background tree
  862. set pattern [format "%s%s" $B(SHInod,$id) *]
  863. foreach idi $B($t,bgs) {
  864. if {[string match $pattern $B(BGSnod,$idi)] == 1} {
  865. if {[$w itemcget [format "%s%s%s" BGS ? $idi] -state] != "hidden"} {
  866. $w addtag $TAG withtag [format "%s%s%s" BGS ? $idi]
  867. $w itemconfigure [format "%s%s%s" BGS ? $idi] -state hidden
  868. }
  869. }
  870. }
  871. # sous shrink
  872. set pattern [format "%s%s" $B(SHInod,$id) *]
  873. foreach idi $B($t,shi) {
  874. if {[string match $pattern $B(SHInod,$idi)] == 1 && $id != $idi} {
  875. if {[$w itemcget [format "%s%s%s" SHN ? $idi] -state] != "hidden"} {
  876. $w addtag $TAG withtag [format "%s%s%s" SHN ? $idi]
  877. $w itemconfigure [format "%s%s%s" SHN ? $idi] -state hidden
  878. set B(SHIsta,$idi) hidden
  879. }
  880. }
  881. }
  882. }
  883. }
  884. #
  885. proc RestaureBLLall {w t} {
  886. global B
  887. set l {}
  888. foreach id $B($t,bll) {
  889. $w create text $B(BLLxxx,$id) $B(BLLyyy,$id) \
  890. -text $B(BLLtxt,$id) -font $B(BLLgfo,$id) -fill $B(BLLcol,$id) -anchor nw \
  891. -tags "bullab T$B(BLLtre,$id) $B(BLLidt,$id)"
  892. set co_sou [$w coords $B(BLLnod,$id)]
  893. set x1 [lindex $co_sou 0]
  894. set y1 [lindex $co_sou 1]
  895. $w create line $x1 $y1 $B(BLLxxx,$id) $B(BLLyyy,$id) \
  896. -width 1 -fill $B(BLLcol,$id) -tags "Link T$B(BLLtre,$id) $B(BLLidl,$id)"
  897. }
  898. }
  899. #
  900. proc RestaureQYNall {w t} {
  901. global B
  902. foreach id $B($t,qyn) {
  903. set idtext [format "%s%s%s" QYN ? $id]
  904. $w create text $B(QYNxxx,$id) $B(QYNyyy,$id) \
  905. -text [lrange $B(QYNqry,$id) [expr [lsearch $B(QYNqry,$id) where] + 1] end] \
  906. -font $B(QYNgfo,$id) -fill $B(QYNcol,$id) -anchor nw \
  907. -tags "querynode T$t $B(QYNidt,$id)"
  908. $w raise Q$t
  909. }
  910. }
  911. #
  912. proc RestaureOVAall {w t} {
  913. global B
  914. set lnodlid {}
  915. foreach id $B($t,ova) {
  916. lappend lnodlid $B(OVAnod2,$id)
  917. set decomp($B(OVAnod2,$id)) $id
  918. }
  919. foreach n [lsort -increasing $lnodlid] {
  920. set id $decomp($n)
  921. set TAG [format "%s%s%s" TD ? $id]
  922. Decomposition::SubTreeDescendant $w $t $n $id $TAG
  923. $w move $TAG $B(OVAtrx,$id) $B(OVAtry,$id)
  924. }
  925. Decomposition::UpdateLink $w $t
  926. if [array exists decomp] {unset decomp}
  927. }
  928. #
  929. proc RestaureBGSall {w t} {
  930. global T S B
  931. set lnodes {}
  932. foreach idi $B($t,bgs) {
  933. $w delete [format "%s%s%s" BGS ? $idi]
  934. lappend lnodes $B(BGSnod,$idi)
  935. set transit($B(BGSnod,$idi)) $idi
  936. }
  937. foreach ni [lsort -increasing $lnodes] {
  938. # compatibilit?Š sauvegarde precedent la creation variable du type des contours et stipple
  939. if {[catch {set v $B(BGStyp,$transit($ni))} err]} then {set B(BGStyp,$transit($ni)) 1}
  940. if {[catch {set v $B(BGSsti,$transit($ni))} err]} then {set B(BGSsti,$transit($ni)) z.xbm}
  941. set lxy [Figuration::NodeColorBgSubTreeContourSwitch $w $t $ni $B(BGStyp,$transit($ni))]
  942. set idi $transit($ni)
  943. set tag [format "%s%s%s" BGS ? $idi]
  944. if {$B(BGSsti,$idi) == "z.xbm"} {
  945. $w create polygon $lxy -outline $B(BGScol,$idi) -fill $B(BGScol,$idi) -tags "bgtree T$t $tag"
  946. } else {
  947. #$w create polygon $lxy -outline $B(BGScol,$idi) -fill $B(BGScol,$idi) -tags "bgtree T$t $tag" \
  948. # -stipple @[file join [file dirname [info script]] +/stipple/ $B(BGSsti,$idi)]
  949. #
  950. # ATTENTION a rester sur un path relatif
  951. #$w create polygon $lxy -outline $B(BGScol,$idi) -fill $B(BGScol,$idi) -tags "bgtree T$t $tag" \
  952. # -stipple @[file join $S(stidir) $B(BGSsti,$idi)]
  953. # @[file join + stipple $S(stipple)]
  954. $w create polygon $lxy -outline $B(BGScol,$idi) -fill $B(BGScol,$idi) -tags "bgtree T$t $tag" \
  955. -stipple @[file join $S(TheoPATH) + stipple $B(BGSsti,$idi)]
  956. }
  957. }
  958. $w lower bgtree
  959. if {[array exists transit] == 1} {unset transit}
  960. }
  961. #
  962. proc RestaureBGLall {w t} {
  963. global T S B
  964. set lnodes {}
  965. foreach idi $B($t,bgl) {
  966. $w delete [format "%s%s%s" BGL ? $idi]
  967. lappend lnodes $B(BGLnod,$idi)
  968. set transit($B(BGLnod,$idi)) $idi
  969. }
  970. foreach ni $lnodes {
  971. set lab $T($t,ctl,$ni)
  972. set coords [$w bbox [list [format "%s%s" EUL $lab ] && T$t]]
  973. if {$coords != ""} {
  974. set x1 [lindex $coords 0]
  975. set y1 [expr [lindex $coords 1] -1]
  976. set x2 [lindex $coords 2]
  977. set y2 [lindex $coords 3]
  978. set idi $transit($ni)
  979. set tag [format "%s%s%s" BGL ? $idi]
  980. # dessin
  981. $w create rectangle $x1 $y1 $x2 $y2 \
  982. -fill $B(BGLcol,$idi) -outline $B(BGLcol,$idi) \
  983. -tags "bgleaf T$t $tag"
  984. }
  985. }
  986. $w lower bgleaf
  987. if {[array exists transit] == 1} {unset transit}
  988. }
  989. #
  990. proc RedrawBGLall {w t} {
  991. global T B
  992. foreach idi $B($t,bgl) {
  993. set lab $T($t,ctl,$B(BGLnod,$idi))
  994. set coords [$w bbox [list [format "%s%s" EUL $lab ] && T$t]]
  995. if {$coords != ""} {
  996. $w coords [format "%s%s%s" BGL ? $idi] $coords
  997. }
  998. }
  999. }
  1000. ### Procedure de restauration des variables graphiques sur tout l'arbre
  1001. proc NodeGraVarRest {t} {
  1002. global S T
  1003. set w $S($t,w)
  1004. ###
  1005. # T($t,gfg,$n) restauration des foreground color tree
  1006. # on classe les codes pour fg les subtree de la racine vers les feuilles
  1007. set li [lsort -dictionary [array names T $t,gfg,*]]
  1008. foreach key $li {
  1009. set n [string range $key [expr [string last , $key] + 1] end]
  1010. set Le [Tools::NodeNoCoFaToNoCoCh $t $n]
  1011. foreach e $Le {
  1012. foreach j [$w find withtag [list [format "%s%s" $e C] && T$t]] {
  1013. Figuration::NodeColorFgItem $w $j $T($key)
  1014. }
  1015. }
  1016. }
  1017. ###
  1018. # T($t,lfg,$n) restauration des foreground color leaf
  1019. foreach key [array names T $t,lfg,*] {
  1020. set n [string range $key [expr [string last , $key] + 1] end]
  1021. set lab $T($t,ctl,$n)
  1022. $w itemconfigure [list [format "%s%s" EUL $lab ] && T$t] -fill $T($key)
  1023. }
  1024. ###
  1025. # T($t,gld,$n) restauration des line dash
  1026. set li [lsort -dictionary [array names T $t,gld,*]]
  1027. foreach key $li {
  1028. set n [string range $key [expr [string last , $key] + 1] end]
  1029. set Le [Tools::NodeNoCoFaToNoCoCh $t $n]
  1030. foreach e $Le {
  1031. foreach j [$w find withtag [list [format "%s%s" $e C] && T$t]] {
  1032. $w itemconfigure $j -dash $T($key)
  1033. }
  1034. }
  1035. }
  1036. ###
  1037. # set T($t,gls,$i) restauration des line width
  1038. set li [lsort -dictionary [array names T $t,gls,*]]
  1039. foreach key $li {
  1040. set n [string range $key [expr [string last , $key] + 1] end]
  1041. set Le [Tools::NodeNoCoFaToNoCoCh $t $n]
  1042. foreach e $Le {
  1043. foreach j [$w find withtag [list [format "%s%s" $e C] && T$t]] {
  1044. $w itemconfigure $j -width $T($key)
  1045. }
  1046. }
  1047. }
  1048. ###
  1049. # set T($t,gfo,$i) restauration des font
  1050. foreach key [array names T $t,gfo,*] {
  1051. set n [string range $key [expr [string last , $key] + 1] end]
  1052. set lab $T($t,ctl,$n)
  1053. set i [$w find withtag [list [format "%s%s" EUL $lab ] && T$t]]
  1054. $w itemconfigure $i -font $T($key)
  1055. }
  1056. }
  1057. #Procedure de restauration des variables graphiques a partir de N
  1058. #independance de l'existence de variable
  1059. proc NodeGraVarRestLOCAL {t n} {
  1060. global S T
  1061. set w $S($t,w)
  1062. set p [format "%s%s" $n *]
  1063. ###
  1064. # T($t,gfg,$n) restauration des foreground color tree
  1065. # on classe les codes pour fg les subtree de la racine vers les feuilles
  1066. set li [lsort -dictionary [array names T $t,gfg,$p]]
  1067. foreach key $li {
  1068. set n [string range $key [expr [string last , $key] + 1] end]
  1069. set Le [Tools::NodeNoCoFaToNoCoCh $t $n]
  1070. foreach e $Le {
  1071. foreach j [$w find withtag [list [format "%s%s" $e C] && T$t]] {
  1072. Figuration::NodeColorFgItem $w $j $T($key)
  1073. }
  1074. }
  1075. }
  1076. ###
  1077. # T($t,lfg,$n) restauration des foreground color leaf
  1078. foreach key [array names T $t,lfg,$p] {
  1079. set n [string range $key [expr [string last , $key] + 1] end]
  1080. set lab $T($t,ctl,$n)
  1081. $w itemconfigure [list [format "%s%s" EUL $lab ] && T$t] -fill $T($key)
  1082. }
  1083. ###
  1084. # T($t,gld,$n) restauration des line dash
  1085. set li [lsort -dictionary [array names T $t,gld,$p]]
  1086. foreach key $li {
  1087. set n [string range $key [expr [string last , $key] + 1] end]
  1088. set Le [Tools::NodeNoCoFaToNoCoCh $t $n]
  1089. foreach e $Le {
  1090. foreach j [$w find withtag [list [format "%s%s" $e C] && T$t]] {
  1091. $w itemconfigure $j -dash $T($key)
  1092. }
  1093. }
  1094. }
  1095. ###
  1096. # set T($t,gls,$i) restauration des line width
  1097. set li [lsort -dictionary [array names T $t,gls,$p]]
  1098. foreach key $li {
  1099. set n [string range $key [expr [string last , $key] + 1] end]
  1100. set Le [Tools::NodeNoCoFaToNoCoCh $t $n]
  1101. foreach e $Le {
  1102. foreach j [$w find withtag [list [format "%s%s" $e C] && T$t]] {
  1103. $w itemconfigure $j -width $T($key)
  1104. }
  1105. }
  1106. }
  1107. ###
  1108. # set T($t,gfo,$i) restauration des font
  1109. foreach key [array names T $t,gfo,$p] {
  1110. set n [string range $key [expr [string last , $key] + 1] end]
  1111. set lab $T($t,ctl,$n)
  1112. set i [$w find withtag [list [format "%s%s" EUL $lab ] && T$t]]
  1113. $w itemconfigure $i -font $T($key)
  1114. }
  1115. }
  1116. # T($t,gfg,$n) init des foreground color tree
  1117. # a l'appel n* = les desceandants aussi
  1118. # par defaut l'arbre entier
  1119. proc GraVarInitFgTree {w t {n *}} {
  1120. global T S
  1121. # liste key soit une si n soit peut etre liste si n*, fonction de l'appel
  1122. set li [lsort -dictionary [array names T $t,gfg,$n]]
  1123. foreach key $li {
  1124. # destruction variable
  1125. unset T($key)
  1126. # coloration back to default
  1127. # set node [string range $key [expr [string last , $key] + 1] end]
  1128. set p [format "%s%s" $n *]
  1129. foreach e $T($t,all_cod) {
  1130. if {[string match $p $e] == 1} {
  1131. foreach j [$w find withtag [list [format "%s%s" $e C] && T$t]] {
  1132. Figuration::NodeColorFgItem $w $j $S(Preference_fgc)
  1133. }
  1134. }
  1135. }
  1136. }
  1137. # si que n restauration locale sur d'eventuelle variable
  1138. # si n* on a tout detruit donc pas besoin de restauration
  1139. if {[string range $n end end] != "*"} {
  1140. #restauration locale et specifique variable
  1141. set p [format "%s%s" $n *]
  1142. set li [lsort -dictionary [array names T $t,gfg,$p]]
  1143. foreach key $li {
  1144. set n [string range $key [expr [string last , $key] + 1] end]
  1145. set Le [Tools::NodeNoCoFaToNoCoCh $t $n]
  1146. foreach e $Le {
  1147. foreach j [$w find withtag [list [format "%s%s" $e C] && T$t]] {
  1148. Figuration::NodeColorFgItem $w $j $T($key)
  1149. }
  1150. }
  1151. }
  1152. }
  1153. }
  1154. # init des background color tree
  1155. proc GraVarInitBgSubTree {w t {n *}} {
  1156. if {[string range $n end end] == "*"} {
  1157. NodeColorBgSubTreeRemoveAll $t $n
  1158. } else {
  1159. NodeColorBgSubTreeRemove $t $n
  1160. }
  1161. }
  1162. # init des background color tree
  1163. #proc GraVarInitBgSubTree {w t} {
  1164. # foreach j [$w find withtag [list bgtree && T$t]] {
  1165. # Figuration::NodeColorBgSubTreeDelete $w $j
  1166. # }
  1167. #}
  1168. # T($t,lfg,$n) init des foreground color leaf
  1169. proc GraVarInitFgLeaf {w t {n *}} {
  1170. global T S
  1171. if {$n != "*"} {set pattern [format "%s%s" $n *]} {set pattern *}
  1172. foreach key [array names T $t,lfg,$pattern] {
  1173. set n [string range $key [expr [string last , $key] + 1] end]
  1174. set lab $T($t,ctl,$n)
  1175. $w itemconfigure [list [format "%s%s" EUL $lab ] && T$t] -fill $S(Preference_fgc)
  1176. unset T($key)
  1177. }
  1178. }
  1179. # init des background color leaf
  1180. proc GraVarInitBgLeaf {w t {n *}} {
  1181. global T S B
  1182. set listid {}
  1183. if {$n != "*"} {set p [format "%s%s" $n *]} {set p *}
  1184. foreach {k v} [array get B BGLnod,*] {
  1185. if {[string match $p $v] == 1} {
  1186. lappend listid [string trimleft $k "BGLnod," ]
  1187. }
  1188. }
  1189. foreach id $listid {
  1190. $w delete [format "%s%s%s" BGL ? $id]
  1191. set w $S($t,w)
  1192. set t $B(BGLtre,$id)
  1193. foreach key [array names B *,$id] {
  1194. unset B($key)
  1195. }
  1196. set index [lsearch -exact $B($t,bgl) $id]
  1197. set B($t,bgl) [concat [lrange $B($t,bgl) 0 [expr $index - 1]] \
  1198. [lrange $B($t,bgl) [expr $index + 1] end]]
  1199. }
  1200. }
  1201. # set T($t,gfo,$i) init des font
  1202. proc GraVarInitFont {w t {n *}} {
  1203. global T S
  1204. foreach key [array names T $t,gfo,$n] {
  1205. set n [string range $key [expr [string last , $key] + 1] end]
  1206. set lab $T($t,ctl,$n)
  1207. $w itemconfigure [list [format "%s%s" EUL $lab] && T$t] -font $S(fontbase)
  1208. unset T($key)
  1209. }
  1210. }
  1211. # T($t,gls,$c) la taille du trait
  1212. proc GraVarInitLineWidth {w t {n *}} {
  1213. global T
  1214. set li [lsort -dictionary [array names T $t,gls,$n]]
  1215. foreach key $li {
  1216. set n [string range $key [expr [string last , $key] + 1] end]
  1217. set p [format "%s%s" $n *]
  1218. set listeitems {}
  1219. foreach e $T($t,all_cod) {
  1220. if {[string match $p $e] == 1} {
  1221. foreach j [$w find withtag [list [format "%s%s" $e C] && T$t]] {
  1222. lappend listeitems $j
  1223. }
  1224. }
  1225. }
  1226. foreach i $listeitems {
  1227. $w itemconfigure $i -width 1
  1228. }
  1229. unset T($key)
  1230. }
  1231. }
  1232. # T($t,gld,$c) le pointille du trait
  1233. proc GraVarInitLineDash {w t {n *}} {
  1234. global T
  1235. set li [lsort -dictionary [array names T $t,gld,$n]]
  1236. foreach key $li {
  1237. set n [string range $key [expr [string last , $key] + 1] end]
  1238. set p [format "%s%s" $n *]
  1239. set listeitems {}
  1240. foreach e $T($t,all_cod) {
  1241. if {[string match $p $e] == 1} {
  1242. foreach j [$w find withtag [list [format "%s%s" $e C] && T$t]] {
  1243. lappend listeitems $j
  1244. }
  1245. }
  1246. }
  1247. foreach i $listeitems {
  1248. $w itemconfigure $i -dash {}
  1249. }
  1250. unset T($key)
  1251. }
  1252. }
  1253. # reset general de tous les arbres de toutes les fenetres
  1254. proc ResetGlob {} {
  1255. global S
  1256. set l {}
  1257. foreach key [array names S *,w] {
  1258. foreach t $S($S($key),t) {
  1259. if {[lsearch -exact $l $t] == -1} {lappend l $t}
  1260. }
  1261. }
  1262. foreach t $l {
  1263. Figuration::NodeGraVarInit $t
  1264. }
  1265. }
  1266. # procedure de suppression de toutes les variables graphiques
  1267. proc NodeGraVarInit {t} {
  1268. global S T
  1269. set w $S($t,w)
  1270. # init des foreground color tree
  1271. GraVarInitFgTree $w $t
  1272. # init des background color tree
  1273. GraVarInitBgSubTree $w $t
  1274. # init des background color leaf
  1275. GraVarInitBgLeaf $w $t
  1276. # T($t,lfg,$n) init des foreground color leaf
  1277. GraVarInitFgLeaf $w $t
  1278. # set T($t,gfo,$i) init des font
  1279. GraVarInitFont $w $t
  1280. # T($t,gls,$c) la taille du trait
  1281. GraVarInitLineWidth $w $t
  1282. # T($t,gld,$c) le pointille du trait
  1283. GraVarInitLineDash $w $t
  1284. }
  1285. proc GraVarInitAllN {w t n} {
  1286. GraVarInitFgTree $w $t $n
  1287. GraVarInitBgSubTree $w $t $n
  1288. GraVarInitBgLeaf $w $t $n
  1289. GraVarInitFgLeaf $w $t $n
  1290. GraVarInitFont $w $t $n
  1291. GraVarInitLineWidth $w $t $n
  1292. GraVarInitLineDash $w $t $n
  1293. }
  1294. # fonction de copy des variables graphiques d'un arbre vers un autre
  1295. ## c un peu magique mais ca marche, il y a corespondance
  1296. ## exacte entre les codes tsource/ttarget, cela vient de la procedure NodeNoCoFaToNoCoCh
  1297. proc TransitionVG {w tsource npere ttarget} {
  1298. global T S B
  1299. set lnodesFrom [Tools::NodeNoCoFaToNoCoCh $tsource $npere]
  1300. set lnodesTo [Tools::NodeNoCoFaToNoCoCh $ttarget $ttarget]
  1301. foreach nf $lnodesFrom nt $lnodesTo {
  1302. set transition($nf) $nt
  1303. }
  1304. set lnodesFrom2 [lsort -dictionary [Tools::NodeFathers $tsource $npere]]
  1305. foreach nf $lnodesFrom2 {
  1306. set transition2($nf) $ttarget
  1307. }
  1308. # GROUPE 1, on prend en compte les nodes ascendants
  1309. # variables T
  1310. set lvar {gfg lfg gld gls gfo}
  1311. foreach nf $lnodesFrom2 {
  1312. foreach var $lvar {
  1313. if {[catch {set v $T($tsource,$var,$nf)} err]} then {
  1314. #rien
  1315. } else {
  1316. set T($ttarget,$var,$transition2($nf)) $v
  1317. }
  1318. }
  1319. }
  1320. # BGL bg leaves
  1321. foreach idbgl $B($tsource,bgl) {
  1322. if {[lsearch -exact $lnodesFrom2 $B(BGLnod,$idbgl)] != -1} {
  1323. Figuration::NodeColorBgLeaf2 $ttarget $transition2($B(BGLnod,$idbgl)) $B(BGLcol,$idbgl)
  1324. }
  1325. }
  1326. # BGS bg subtree
  1327. foreach idbgs $B($tsource,bgs) {
  1328. if {[lsearch -exact $lnodesFrom2 $B(BGSnod,$idbgs)] != -1} {
  1329. Figuration::NodeColorBgSubTree2 $ttarget $transition2($B(BGSnod,$idbgs)) $B(BGScol,$idbgs) $B(BGSsti,$idbgs)
  1330. }
  1331. }
  1332. # GROUPE 2 on ne prend pas en compte les ascendants
  1333. # variables graphiques
  1334. set lvar {gfg lfg gld gls gfo}
  1335. foreach nf $lnodesFrom {
  1336. foreach var $lvar {
  1337. if {[catch {set v $T($tsource,$var,$nf)} err]} then {
  1338. #rien
  1339. } else {
  1340. set T($ttarget,$var,$transition($nf)) $v
  1341. }
  1342. }
  1343. }
  1344. # BGL bg leaves
  1345. foreach idbgl $B($tsource,bgl) {
  1346. if {[lsearch -exact $lnodesFrom $B(BGLnod,$idbgl)] != -1} {
  1347. Figuration::NodeColorBgLeaf2 $ttarget $transition($B(BGLnod,$idbgl)) $B(BGLcol,$idbgl)
  1348. }
  1349. }
  1350. # BGS bg subtree
  1351. foreach idbgs $B($tsource,bgs) {
  1352. if {[lsearch -exact $lnodesFrom $B(BGSnod,$idbgs)] != -1} {
  1353. Figuration::NodeColorBgSubTree2 $ttarget $transition($B(BGSnod,$idbgs)) $B(BGScol,$idbgs) $B(BGSsti,$idbgs)
  1354. }
  1355. }
  1356. # variables B : shi bll ova
  1357. # construction des items (mais array seuleument, pas graphique)
  1358. # BLL
  1359. # on prend les nodes des bll on regarde si ils sont dans la liste des nodes copies
  1360. foreach bi $B($tsource,bll) {
  1361. if {[lsearch -exact $lnodesFrom $B(BLLnod,$bi)] != -1} {
  1362. set co [$w coords $transition($B(BLLnod,$bi))]
  1363. set x [lindex $co 0]
  1364. set y [lindex $co 1]
  1365. set titx [string first "\n" $B(BLLtxt,$bi)]
  1366. set titre [string range $B(BLLtxt,$bi) 0 [expr $titx - 1]]
  1367. set text [string range $B(BLLtxt,$bi) [expr $titx + 1] end]
  1368. # BLLmake2 ne construit que les array
  1369. Annotation::BLLmake2 $w $ttarget $x $y $titre $text $transition($B(BLLnod,$bi)) $B(BLLcol,$bi) $B(BLLgfo,$bi)
  1370. }
  1371. }
  1372. ### OVA
  1373. # on prend les nodes sous decomposition et on regarde si ils sont dans la liste des nodes copies
  1374. foreach idc $B($tsource,ova) {
  1375. if {[lsearch -exact $lnodesFrom $B(OVAnod2,$idc)] != -1} {
  1376. Decomposition::SubTree2 $ttarget $B(OVAtrx,$idc) $B(OVAtry,$idc) $transition($B(OVAnod2,$idc))
  1377. }
  1378. }
  1379. # SHI en dernier
  1380. # il suffit de reconstruire les shrink en partant des plus bas
  1381. # afin d'appliquer le state/tag de visiblite au fur et a mesure
  1382. set lni {}
  1383. # on prend les nodes qui sont shrink et on regarde si ils sont dans la liste des nodes copies
  1384. foreach si $B($tsource,shi) {
  1385. if {[lsearch -exact $lnodesFrom $B(SHInod,$si)] != -1} {lappend lni $B(SHInod,$si)}
  1386. }
  1387. # on ordonne ensuite les codes nodes, les plus profons d'abord, la fct shrink
  1388. # reconstruit la strucutre imbriqu?Še des shrink
  1389. foreach ni [lsort -decreasing $lni] {
  1390. Abstraction::Shrink2 $w $ttarget $transition($ni) $S(col)
  1391. }
  1392. unset transition
  1393. }
  1394. ###set S(contour2mode) c ; set S(contour2mode) d ;
  1395. proc NodeColorBgSubTreeToolbox {w command} {
  1396. global S
  1397. set tags [$w gettags [$w find withtag current]]
  1398. set n [string trimright \
  1399. [lindex $tags [lsearch -glob $tags *C]] C]
  1400. set t [string range \
  1401. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  1402. if {$n != ""} {
  1403. switch -exact $command {
  1404. add1 {NodeColorBgSubTree $t $n}
  1405. remove {NodeColorBgSubTreeRemove $t $n}
  1406. removeall {NodeColorBgSubTreeRemoveAll $t $n}
  1407. menushape {SetDefaultShape $w}
  1408. }
  1409. Figuration::RestaureBGSall $w $t
  1410. }
  1411. }
  1412. ### Background color of Subtree
  1413. # on calcule le pourtour du sous-arbre
  1414. # pour etre independant des orientations des arbres et des items
  1415. # on compare les normes des vecteurs entre chaque extremites et
  1416. #une des coordonn?Šes du node pere
  1417. proc NodeColorBgSubTree {t n} {
  1418. global T S B
  1419. set w $S($t,w)
  1420. set id [format "%s%s" $t [Tools::GenId]]
  1421. # MEM
  1422. set B(BGStre,$id) $t
  1423. set B(BGSnod,$id) $n
  1424. set B(BGScol,$id) $S(col)
  1425. set B(BGSsti,$id) $S(stipple)
  1426. set B(BGStyp,$id) $S(defaultshape)
  1427. # Liste des BGS par tree
  1428. lappend B($t,bgs) $id
  1429. # RestaureBGSall est place ailleurs car trop long en identification
  1430. #Figuration::RestaureBGSall $w $t
  1431. }
  1432. proc NodeColorBgSubTreeSwitch {w i type} {
  1433. global S B
  1434. set tags [$w gettags $i]
  1435. set id [lindex [split [lindex $tags [lsearch -glob $tags BGS*]] ?] end]
  1436. set B(BGStyp,$id) $type
  1437. Figuration::RestaureBGSall $w $B(BGStre,$id)
  1438. }
  1439. proc NodeColorBgSubTreeUpdateStipple {w i} {
  1440. global S B
  1441. set tags [$w gettags $i]
  1442. set id [lindex [split [lindex $tags [lsearch -glob $tags BGS*]] ?] end]
  1443. set B(BGSsti,$id) $S(stipple)
  1444. Figuration::RestaureBGSall $w $B(BGStre,$id)
  1445. }
  1446. #
  1447. proc NodeColorBgSubTreeRemove {t n } {
  1448. global T S B
  1449. set w $S($t,w)
  1450. set listid {}
  1451. foreach {k v} [array get B BGSnod,*] {
  1452. if {$n == $v} {
  1453. lappend listid [string trimleft $k "BGSnod," ]
  1454. }
  1455. }
  1456. foreach id $listid {
  1457. $w delete [format "%s%s%s" BGS ? $id]
  1458. set w $S($t,w)
  1459. set t $B(BGStre,$id)
  1460. foreach key [array names B *,$id] {
  1461. unset B($key)
  1462. }
  1463. #retirer
  1464. set index [lsearch -exact $B($t,bgs) $id]
  1465. set B($t,bgs) [concat [lrange $B($t,bgs) 0 [expr $index - 1]] \
  1466. [lrange $B($t,bgs) [expr $index + 1] end]]
  1467. }
  1468. }
  1469. #
  1470. proc NodeColorBgSubTreeRemoveAll {t n } {
  1471. global T S B
  1472. set w $S($t,w)
  1473. set p [format "%s%s" $n *]
  1474. set listid {}
  1475. foreach {k v} [array get B BGSnod,*] {
  1476. if {[string match $p $v] == 1} {
  1477. lappend listid [string trimleft $k "BGSnod," ]
  1478. }
  1479. }
  1480. foreach id $listid {
  1481. $w delete [format "%s%s%s" BGS ? $id]
  1482. set w $S($t,w)
  1483. set t $B(BGStre,$id)
  1484. foreach key [array names B *,$id] {
  1485. unset B($key)
  1486. }
  1487. #retirer
  1488. set index [lsearch -exact $B($t,bgs) $id]
  1489. set B($t,bgs) [concat [lrange $B($t,bgs) 0 [expr $index - 1]] \
  1490. [lrange $B($t,bgs) [expr $index + 1] end]]
  1491. }
  1492. }
  1493. #
  1494. proc NodeColorBgSubTree2 {t n c s} {
  1495. global T S B
  1496. set id [format "%s%s" $t [Tools::GenId]]
  1497. # MEM
  1498. set B(BGStre,$id) $t
  1499. set B(BGSnod,$id) $n
  1500. set B(BGScol,$id) $c
  1501. set B(BGSsti,$id) $s
  1502. # Liste des BGS par tree
  1503. lappend B($t,bgs) $id
  1504. }
  1505. #
  1506. proc NodeColorBgSubTreeDelete {w i} {
  1507. global B S
  1508. set tags [$w gettags $i]
  1509. set id [lindex [split [lindex $tags [lsearch -glob $tags BGS*]] ?] end]
  1510. $w delete [format "%s%s%s" BGS ? $id]
  1511. set t $B(BGStre,$id)
  1512. set w $S($t,w)
  1513. foreach key [array names B *,$id] {
  1514. unset B($key)
  1515. }
  1516. #retirer
  1517. set index [lsearch -exact $B($t,bgs) $id]
  1518. set B($t,bgs) [concat [lrange $B($t,bgs) 0 [expr $index - 1]] \
  1519. [lrange $B($t,bgs) [expr $index + 1] end]]
  1520. }
  1521. #
  1522. proc NodeColorBgSubTreeUpateColor {w i c} {
  1523. global B S
  1524. set tags [$w gettags $i]
  1525. set id [lindex [split [lindex $tags [lsearch -glob $tags BGS*]] ?] end]
  1526. $w itemconfigure [format "%s%s%s" BGS ? $id] -fill $c -outline $c
  1527. set B(BGScol,$id) $c
  1528. }
  1529. proc NodeColorBgSubTreeContourSwitch {w t n mode} {
  1530. switch $mode {
  1531. 1 {set lxy [NodeColorBgSubTreeContour $w $t $n]}
  1532. 2 {set lxy [NodeColorBgSubTreeContour2 $w $t $n 2]}
  1533. 3 {set lxy [NodeColorBgSubTreeContour2 $w $t $n 3]}
  1534. 4 {set lxy [NodeColorBgSubTreeContour2 $w $t $n 4]}
  1535. 5 {set lxy [NodeColorBgSubTreeContour2 $w $t $n 5]}
  1536. }
  1537. return $lxy
  1538. }
  1539. ###
  1540. proc NodeColorBgSubTreeContour {w t n} {
  1541. #on trace le polygon du contour du sous-arbre
  1542. # depart
  1543. set lxy {}
  1544. set leafs [Tools::NodeNoToLe $t $n]
  1545. set nodes [Tools::SousL [Tools::NodeNoCoFaToNoCoCh $t $n] $n]
  1546. set sbase [string length $n]
  1547. if {[llength $leafs] != 1 } {
  1548. # descandants gauche y compris feuilles
  1549. set ldesgauche {}
  1550. foreach ni [lsort -increasing $nodes] {
  1551. set suffixe [string range $ni $sbase end]
  1552. if {[string match *d* $suffixe] == 0} {
  1553. lappend ldesgauche $ni
  1554. }
  1555. }
  1556. # ascendants droits y compris feuilles
  1557. set lascdroit {}
  1558. foreach ni [lsort -decreasing $nodes] {
  1559. set suffixe [string range $ni $sbase end]
  1560. if {[string match *g* $suffixe] == 0} {
  1561. lappend lascdroit $ni
  1562. }
  1563. }
  1564. # feuilles intermediaires (sans les descandants feuilles g et d)
  1565. set leafsinter [Tools::SousL $leafs [concat $ldesgauche $lascdroit]]
  1566. # coordonnees
  1567. set lxy {}
  1568. # la base
  1569. set npap [Tools::NodeParentNode $t $n]
  1570. if {$npap == $t || $npap == ""} {
  1571. set npap [format "%s%s" $t C]
  1572. }
  1573. set conp [$w coords $npap]
  1574. set xp [lindex $conp 0]
  1575. set yp [lindex $conp 1]
  1576. if {$n == $t || $n == ""} {
  1577. set n2 [format "%s%s" $t C]
  1578. } else {
  1579. set n2 $n
  1580. }
  1581. # NB pb avec les copy paste
  1582. set coni [$w coords $n2]
  1583. set x1 [lindex $coni 0]
  1584. set y1 [lindex $coni 1]
  1585. set x2 [lindex $coni 2]
  1586. set y2 [lindex $coni 3]
  1587. set norm1 [expr sqrt((($xp - $x1) * ($xp - $x1)) + (($yp - $y1) * ($yp - $y1)))]
  1588. set norm2 [expr sqrt((($xp - $x2) * ($xp - $x2)) + (($yp - $y2) * ($yp - $y2)))]
  1589. if {$norm1 <= $norm2} {
  1590. lappend lxy [list $x2 $y2]
  1591. } else {
  1592. lappend lxy [list $x1 $y1]
  1593. }
  1594. # descandants gauche
  1595. foreach i $ldesgauche {
  1596. set npap [Tools::NodeParentNode $t $i]
  1597. if {$npap == $t} {
  1598. set npap [format "%s%s" $t C]
  1599. }
  1600. set conp [$w coords $npap]
  1601. set xp [lindex $conp 0]
  1602. set yp [lindex $conp 1]
  1603. set coni [$w coords $i]
  1604. set x1 [lindex $coni 0]
  1605. set y1 [lindex $coni 1]
  1606. set x2 [lindex $coni 2]
  1607. set y2 [lindex $coni 3]
  1608. set norm1 [expr sqrt((($xp - $x1) * ($xp - $x1)) + (($yp - $y1) * ($yp - $y1)))]
  1609. set norm2 [expr sqrt((($xp - $x2) * ($xp - $x2)) + (($yp - $y2) * ($yp - $y2)))]
  1610. if {$norm1 <= $norm2} {
  1611. lappend lxy [list $x1 $y1 $x2 $y2]
  1612. } else {
  1613. lappend lxy [list $x2 $y2 $x1 $y1]
  1614. }
  1615. }
  1616. # feuilles
  1617. foreach i $leafsinter {
  1618. set npap [Tools::NodeParentNode $t $i]
  1619. if {$npap == $t} {
  1620. set npap [format "%s%s" $t C]
  1621. }
  1622. set conp [$w coords $npap]
  1623. set xp [lindex $conp 0]
  1624. set yp [lindex $conp 1]
  1625. set coni [$w coords $i]
  1626. set x1 [lindex $coni 0]
  1627. set y1 [lindex $coni 1]
  1628. set x2 [lindex $coni 2]
  1629. set y2 [lindex $coni 3]
  1630. set norm1 [expr sqrt((($xp - $x1) * ($xp - $x1)) + (($yp - $y1) * ($yp - $y1)))]
  1631. set norm2 [expr sqrt((($xp - $x2) * ($xp - $x2)) + (($yp - $y2) * ($yp - $y2)))]
  1632. if {$norm1 <= $norm2} {
  1633. lappend lxy [list $x2 $y2]
  1634. } else {
  1635. lappend lxy [list $x1 $y1]
  1636. }
  1637. }
  1638. # ascendants droits
  1639. foreach i $lascdroit {
  1640. set npap [Tools::NodeParentNode $t $i]
  1641. if {$npap == $t} {
  1642. set npap [format "%s%s" $t C]
  1643. }
  1644. set conp [$w coords $npap]
  1645. set xp [lindex $conp 0]
  1646. set yp [lindex $conp 1]
  1647. set coni [$w coords $i]
  1648. set x1 [lindex $coni 0]
  1649. set y1 [lindex $coni 1]
  1650. set x2 [lindex $coni 2]
  1651. set y2 [lindex $coni 3]
  1652. set norm1 [expr sqrt((($xp - $x1) * ($xp - $x1)) + (($yp - $y1) * ($yp - $y1)))]
  1653. set norm2 [expr sqrt((($xp - $x2) * ($xp - $x2)) + (($yp - $y2) * ($yp - $y2)))]
  1654. if {$norm1 <= $norm2} {
  1655. lappend lxy [list $x2 $y2 $x1 $y1]
  1656. } else {
  1657. lappend lxy [list $x1 $y1 $x2 $y2]
  1658. }
  1659. }
  1660. regsub -all "\{" $lxy "" lxy
  1661. regsub -all "\}" $lxy "" lxy
  1662. } else {
  1663. set lxy [$w coords $n]
  1664. }
  1665. return $lxy
  1666. }
  1667. #
  1668. ### NodeColorBgSubTreeContour2 un background tree en rectangle
  1669. proc NodeColorBgSubTreeContour2 {w t n mode} {
  1670. global S T
  1671. # x1 (partie commune)
  1672. if {$n == $t || $n == ""} {
  1673. set n [format "%s%s" $t C]
  1674. }
  1675. set cop [$w coords $n]
  1676. set xp1 [lindex $cop 0]
  1677. set xp2 [lindex $cop 2]
  1678. if {$xp1 < $xp2} {
  1679. set x1 $xp1
  1680. } else {
  1681. set x1 $xp2
  1682. }
  1683. # x2 (xmax) y1 (ymin) y2 (ymax)
  1684. set leafs [Tools::NodeNoToLe $t $n]
  1685. set x2 0 ; set y1 100000 ; set y2 0
  1686. # NB pas de switch sur 1 qui correpond au contour 1
  1687. switch -exact $mode {
  1688. 2 {
  1689. foreach i $leafs {
  1690. # le texte des feuilles n'est pas pris en compte
  1691. set coi [$w coords $i]
  1692. set xi1 [lindex $coi 0]
  1693. set yi1 [lindex $coi 1]
  1694. set xi2 [lindex $coi 2]
  1695. set yi2 [lindex $coi 3]
  1696. # x2
  1697. if {$xi1 > $xi2} {
  1698. if {$xi1 > $x2} {set x2 $xi1}
  1699. } else {
  1700. if {$xi2 > $x2} {set x2 $xi2}
  1701. }
  1702. # y1 et y2
  1703. if {$yi1 > $yi2} {
  1704. # y1: on regarde yi2
  1705. if {$yi2 < $y1} {set y1 $yi2}
  1706. # y2: on regarde yi1
  1707. if {$yi1 > $y2} {set y2 $yi1}
  1708. } else {
  1709. # y1: on regarde yi1
  1710. if {$yi1 < $y1} {set y1 $yi1}
  1711. # y2: on regarde yi2
  1712. if {$yi2 > $y2} {set y2 $yi2}
  1713. }
  1714. }
  1715. }
  1716. 3 {
  1717. # prise en compte des texte feuilles
  1718. foreach i $leafs {
  1719. set ii [$w find withtag [list [format "%s%s" EUL $T($t,ctl,$i)] && T$t]]
  1720. set coi [$w bbox $ii]
  1721. # le texte des feuilles n'est pas pris en compte
  1722. #set coi [$w coords $i]
  1723. set xi1 [lindex $coi 0]
  1724. set yi1 [lindex $coi 1]
  1725. set xi2 [lindex $coi 2]
  1726. set yi2 [lindex $coi 3]
  1727. # x2
  1728. if {$xi1 > $xi2} {
  1729. if {$xi1 > $x2} {set x2 $xi1}
  1730. } else {
  1731. if {$xi2 > $x2} {set x2 $xi2}
  1732. }
  1733. # y1 et y2
  1734. if {$yi1 > $yi2} {
  1735. # y1: on regarde yi2
  1736. if {$yi2 < $y1} {set y1 $yi2}
  1737. # y2: on regarde yi1
  1738. if {$yi1 > $y2} {set y2 $yi1}
  1739. } else {
  1740. # y1: on regarde yi1
  1741. if {$yi1 < $y1} {set y1 $yi1}
  1742. # y2: on regarde yi2
  1743. if {$yi2 > $y2} {set y2 $yi2}
  1744. }
  1745. }
  1746. }
  1747. 4 {
  1748. # cas d'un xmax commun a tous les backgrounds, non prise en compte des annotations
  1749. set coi [$w bbox [list T$t && L]]
  1750. set x2 [lindex $coi 2]
  1751. foreach i $leafs {
  1752. set tagi [format "%s%s" EUL $T($t,ctl,$i)]
  1753. #set coi [$w coords $tagi]
  1754. set coi [$w bbox [list $tagi && T$t]]
  1755. set xi1 [lindex $coi 0]
  1756. set yi1 [lindex $coi 1]
  1757. set xi2 [lindex $coi 2]
  1758. set yi2 [lindex $coi 3]
  1759. # y1 et y2
  1760. if {$yi1 > $yi2} {
  1761. # y1: on regarde yi2
  1762. if {$yi2 < $y1} {set y1 $yi2}
  1763. # y2: on regarde yi1
  1764. if {$yi1 > $y2} {set y2 $yi1}
  1765. } else {
  1766. # y1: on regarde yi1
  1767. if {$yi1 < $y1} {set y1 $yi1}
  1768. # y2: on regarde yi2
  1769. if {$yi2 > $y2} {set y2 $yi2}
  1770. }
  1771. }
  1772. }
  1773. 5 {
  1774. # cas d'un xmax commun a tous les backgrounds, prise en compte des annotations
  1775. set coi [$w bbox T$t]
  1776. set x2 [lindex $coi 2]
  1777. foreach i $leafs {
  1778. set tagi [format "%s%s" EUL $T($t,ctl,$i)]
  1779. #set coi [$w coords $tagi]
  1780. set coi [$w bbox [list $tagi && T$t]]
  1781. set xi1 [lindex $coi 0]
  1782. set yi1 [lindex $coi 1]
  1783. set xi2 [lindex $coi 2]
  1784. set yi2 [lindex $coi 3]
  1785. # y1 et y2
  1786. if {$yi1 > $yi2} {
  1787. # y1: on regarde yi2
  1788. if {$yi2 < $y1} {set y1 $yi2}
  1789. # y2: on regarde yi1
  1790. if {$yi1 > $y2} {set y2 $yi1}
  1791. } else {
  1792. # y1: on regarde yi1
  1793. if {$yi1 < $y1} {set y1 $yi1}
  1794. # y2: on regarde yi2
  1795. if {$yi2 > $y2} {set y2 $yi2}
  1796. }
  1797. }
  1798. }
  1799. }
  1800. # redim x2 (du au bounding box du bbox)
  1801. # original return [list $x1 $y1 [expr $x2 -2] $y1 [expr $x2 -2] $y2 $x1 $y2]
  1802. return [list $x1 [expr $y1 + 3] [expr $x2 -2] [expr $y1 + 3] [expr $x2 -2] [expr $y2 - 3] $x1 [expr $y2 - 3]]
  1803. }
  1804. ###
  1805. proc NodeColorBgLeafToolbox {w command} {
  1806. global S
  1807. set tags [$w gettags [$w find withtag current]]
  1808. set n [string trimright \
  1809. [lindex $tags [lsearch -glob $tags *C]] C]
  1810. set t [string range \
  1811. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  1812. if {$n != ""} {
  1813. switch -exact $command {
  1814. add {NodeColorBgLeaf $t $n}
  1815. remove {NodeColorBgLeafRemove $t $n}
  1816. }
  1817. }
  1818. }
  1819. ### foreground color leaf via node pere
  1820. proc NodeColorFgLeaf {t n c} {
  1821. global T S
  1822. set w $S($t,w)
  1823. set leafs [Tools::NodeNoToLe $t $n]
  1824. foreach code $leafs {
  1825. $w itemconfigure [list [format "%s%s" EUL $T($t,ctl,$code)] && T$t] -fill $c
  1826. set T($t,lfg,$code) $c
  1827. }
  1828. }
  1829. ###
  1830. proc NodeColorFgLeafToolbox {w} {
  1831. global S
  1832. set tags [$w gettags [$w find withtag current]]
  1833. set n [string trimright \
  1834. [lindex $tags [lsearch -glob $tags *C]] C]
  1835. set t [string range \
  1836. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  1837. if {$n != ""} {
  1838. NodeColorFgLeaf $t $n $S(col)
  1839. }
  1840. }
  1841. ###
  1842. proc NodeColorFgLeafToolboxRemove {w} {
  1843. global S
  1844. set tags [$w gettags [$w find withtag current]]
  1845. set n [string trimright \
  1846. [lindex $tags [lsearch -glob $tags *C]] C]
  1847. set t [string range \
  1848. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  1849. if {$n != ""} {
  1850. GraVarInitFgLeaf $w $t $n
  1851. }
  1852. }
  1853. ###
  1854. proc NodeLineDashToolbox {w o} {
  1855. global S
  1856. set tags [$w gettags [$w find withtag current]]
  1857. set n [string trimright \
  1858. [lindex $tags [lsearch -glob $tags *C]] C]
  1859. set t [string range \
  1860. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  1861. if {$n != ""} {
  1862. NodeLineDash $t $n $o
  1863. }
  1864. }
  1865. # NodeLineDash
  1866. # variable binaire
  1867. # donc on ne creer une variable graphique que pour l'etat dash
  1868. # et une variable globale pour le noeud a l'origine du sous-arbre
  1869. proc NodeLineDash {t n o} {
  1870. global T S
  1871. set w $S($t,w)
  1872. set p [format "%s%s" $n *]
  1873. set listeitems {}
  1874. foreach e $T($t,all_cod) {
  1875. if {[string match $p $e] == 1} {
  1876. lappend listeitems $e
  1877. }
  1878. }
  1879. # creation d'une variable pour chaque node
  1880. if {$o == "1"} {
  1881. foreach i $listeitems {
  1882. $w itemconfigure $i -dash {2 2}
  1883. $w itemconfigure [format "%s%s" $i C] -dash {2 2}
  1884. set T($t,gld,$i) {2 2}
  1885. }
  1886. } else {
  1887. # il faut supprimer les variables des nodes issues de $code
  1888. # set pattern [format "%s%s" $n *]
  1889. # foreach key [array names T $t,gld,$pattern] {
  1890. # unset T($key)
  1891. # }
  1892. foreach i $listeitems {
  1893. $w itemconfigure $i -dash {}
  1894. $w itemconfigure [format "%s%s" $i C] -dash {}
  1895. set T($t,gld,$i) {}
  1896. }
  1897. }
  1898. }
  1899. ###
  1900. proc NodeLineWidthToolbox {w o} {
  1901. global S
  1902. set tags [$w gettags [$w find withtag current]]
  1903. set n [string trimright \
  1904. [lindex $tags [lsearch -glob $tags *C]] C]
  1905. set t [string range \
  1906. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  1907. if {$n != ""} {
  1908. if {[string length $o] == "1"} {
  1909. NodeLineWidth $t $n $o
  1910. } {NodeLineWidthSet $t $n $o}
  1911. }
  1912. }
  1913. # NodeLineWidth augmente (si o = +) ou diminue ( o = -)
  1914. # la valeur des epaisseurs de traits issus de node
  1915. # donc creation d'une variable graphique propre a chaque element
  1916. # (possiblilite d'avoir des epaisseur differentes pour les arretes de n)
  1917. proc NodeLineWidth {t n o} {
  1918. global T S
  1919. set w $S($t,w)
  1920. set p [format "%s%s" $n *]
  1921. set listeitems {}
  1922. foreach e $T($t,all_cod) {
  1923. if {[string match $p $e] == 1} {
  1924. foreach j [$w find withtag [format "%s%s" $e C]] {
  1925. set width_line [lindex [$w itemconfigure $j -width] end]
  1926. set new_wl [expr abs($width_line $o 1)]
  1927. $w itemconfigure $j -width $new_wl
  1928. set T($t,gls,$e) $new_wl
  1929. }
  1930. }
  1931. }
  1932. }
  1933. # NodeLineWidth augmente (si o = +) ou diminue ( o = -)
  1934. # la valeur des epaisseurs de traits issus de node
  1935. # donc creation d'une variable graphique propre a chaque element
  1936. # (possiblilite d'avoir des epaisseur differentes pour les arretes de n)
  1937. proc NodeLineWidth2 {t n o} {
  1938. global T S
  1939. set w $S($t,w)
  1940. set item [$w find withtag $n]
  1941. set width_line [lindex [$w itemconfigure $item -width] end]
  1942. set new_wl [expr abs($width_line $o 1)]
  1943. $w itemconfigure $item -width $new_wl
  1944. }
  1945. # NodeLineDash2
  1946. # variable binaire
  1947. # donc on ne creer une variable graphique que pour l'etat dash
  1948. # et une variable globale pour le noeud a l'origine du sous-arbre
  1949. proc NodeLineDash2 {t n o} {
  1950. global T S
  1951. set w $S($t,w)
  1952. set item [$w find withtag $n]
  1953. $w itemconfigure $item -dash {2 2}
  1954. }
  1955. # cette fonction met l'epaisseur de trait des arretes issues de n
  1956. # a la valeur de l'epaisseur de trait de n augmente/diminue de 1 (toutes
  1957. # les arretes auront la meme epaisseur)
  1958. proc NodeLineWidthSet {t n o} {
  1959. global T S
  1960. if {$o == "++"} {set o +} else {set o -}
  1961. set w $S($t,w)
  1962. set p [format "%s%s" $n *]
  1963. set listeitems {}
  1964. foreach e $T($t,all_cod) {
  1965. if {[string match $p $e] == 1} {
  1966. lappend listeitems $e
  1967. }
  1968. }
  1969. set width_line [lindex [$w itemconfigure $n -width] end]
  1970. set new_wl [expr abs($width_line $o 1)]
  1971. foreach i $listeitems {
  1972. $w itemconfigure $i -width $new_wl
  1973. $w itemconfigure [format "%s%s" $i C] -width $new_wl
  1974. #set T($t,gls,$i) $new_wl
  1975. }
  1976. # on detruit les variables sous-jacentes
  1977. set pattern [format "%s%s" $n *]
  1978. foreach key [array names T $t,gls,$pattern] {
  1979. unset T($key)
  1980. }
  1981. # on stocke la variable pour le noeud pere
  1982. set T($t,gls,$n) $new_wl
  1983. }
  1984. # le probleme de la presence de multiple arbres ds la meme w et
  1985. # ayant des eu names en commun est resolu via le bbox &&
  1986. proc NodeColorBgLeaf {t n } {
  1987. global T S B
  1988. set w $S($t,w)
  1989. set p [format "%s%s" $n *]
  1990. set listneu {}
  1991. foreach e $T($t,ue_cod) {
  1992. if {[string match $p $e] == 1} {
  1993. lappend listneu $e
  1994. }
  1995. }
  1996. foreach i $listneu {
  1997. set id [format "%s%s" $t [Tools::GenId]]
  1998. # MEM
  1999. set B(BGLtre,$id) $t
  2000. set B(BGLnod,$id) $i
  2001. set B(BGLcol,$id) $S(col)
  2002. # Liste des BGL par tree
  2003. lappend B($t,bgl) $id
  2004. }
  2005. Figuration::RestaureBGLall $w $t
  2006. }
  2007. #
  2008. proc NodeColorBgLeafRemove {t n } {
  2009. global T S B
  2010. set w $S($t,w)
  2011. set p [format "%s%s" $n *]
  2012. set listid {}
  2013. foreach {k v} [array get B BGLnod,*] {
  2014. if {[string match $p $v] == 1} {
  2015. #lappend listid [string range $k [expr [string first , $k] - 1]] end ]
  2016. lappend listid [string trimleft $k "BGLnod," ]
  2017. }
  2018. }
  2019. foreach id $listid {
  2020. $w delete [format "%s%s%s" BGL ? $id]
  2021. set w $S($t,w)
  2022. set t $B(BGLtre,$id)
  2023. foreach key [array names B *,$id] {
  2024. unset B($key)
  2025. }
  2026. #retirer
  2027. set index [lsearch -exact $B($t,bgl) $id]
  2028. set B($t,bgl) [concat [lrange $B($t,bgl) 0 [expr $index - 1]] \
  2029. [lrange $B($t,bgl) [expr $index + 1] end]]
  2030. }
  2031. Figuration::RestaureBGLall $w $t
  2032. }
  2033. #
  2034. proc NodeColorBgLeafDelete {w i} {
  2035. global B S
  2036. set tags [$w gettags $i]
  2037. set id [lindex [split [lindex $tags [lsearch -glob $tags BGL*]] ?] end]
  2038. $w delete [format "%s%s%s" BGL ? $id]
  2039. set t $B(BGLtre,$id)
  2040. foreach key [array names B *,$id] {
  2041. unset B($key)
  2042. }
  2043. #retirer
  2044. set index [lsearch -exact $B($t,bgl) $id]
  2045. set B($t,bgl) [concat [lrange $B($t,bgl) 0 [expr $index - 1]] \
  2046. [lrange $B($t,bgl) [expr $index + 1] end]]
  2047. }
  2048. #
  2049. proc NodeColorBgLeaf2 {t n c} {
  2050. global T S B
  2051. set p [format "%s%s" $n *]
  2052. foreach e $T($t,ue_cod) {
  2053. if {[string match $p $e] == 1} {
  2054. set id [format "%s%s" $t [Tools::GenId]]
  2055. # MEM
  2056. set B(BGLtre,$id) $t
  2057. set B(BGLnod,$id) $e
  2058. set B(BGLcol,$id) $c
  2059. # Liste des BGL par tree
  2060. lappend B($t,bgl) $id
  2061. }
  2062. }
  2063. }
  2064. ### idem NodeColorBgLeaf mais l'argument est une liste de leafs et non un code node pere
  2065. proc EUColorBgLeaf {t eus c} {
  2066. global T S B
  2067. set w $S($t,w)
  2068. foreach i $eus {
  2069. set id [format "%s%s" $t [Tools::GenId]]
  2070. # MEM
  2071. set B(BGLtre,$id) $t
  2072. set B(BGLnod,$id) $T($t,ltc,$i)
  2073. #set B(BGLcol,$id) $S(col)
  2074. set B(BGLcol,$id) $c
  2075. # Liste des BGL par tree
  2076. lappend B($t,bgl) $id
  2077. }
  2078. Figuration::RestaureBGLall $w $t
  2079. }
  2080. ### couleur d'ecriture des text leaf, arg = liste eu
  2081. proc EUColorFgLeaf {t eus c} {
  2082. global T S
  2083. set w $S($t,w)
  2084. foreach i $eus {
  2085. set tag [list [format "%s%s" EUL $i ] && T$t]
  2086. # creation des variables graphiques
  2087. #set T($t,lfg,$T($t,ltc,$i)) $S(col)
  2088. set T($t,lfg,$T($t,ltc,$i)) $c
  2089. # dessin
  2090. $w itemconfigure $tag -fill $c
  2091. }
  2092. }
  2093. ###
  2094. proc NodeColorFgTag {w tag color} {
  2095. set listeitems [$w find withtag $tag]
  2096. foreach i $listeitems {
  2097. switch [$w type $i] {
  2098. line - text {
  2099. $w itemconfigure $i -fill $color
  2100. }
  2101. rectangle - polygon - oval - arc {
  2102. $w itemconfigure $i -outline $color
  2103. }
  2104. }
  2105. }
  2106. }
  2107. ###
  2108. proc NodeColorFgItem {w item color} {
  2109. switch [$w type $item] {
  2110. line {
  2111. $w itemconfigure $item -fill $color
  2112. }
  2113. rectangle - polygon - oval - arc {
  2114. $w itemconfigure $item -outline $color
  2115. }
  2116. }
  2117. }
  2118. ###
  2119. proc NodeColorFgTreeToolbox {w} {
  2120. global S
  2121. set tags [$w gettags [$w find withtag current]]
  2122. set n [string trimright \
  2123. [lindex $tags [lsearch -glob $tags *C]] C]
  2124. set t [string range \
  2125. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  2126. if {$n != ""} {
  2127. NodeColorFgTree $t $n $S(col)
  2128. }
  2129. }
  2130. ###
  2131. proc NodeColorFgTreeToolboxRemove {w} {
  2132. global S
  2133. set tags [$w gettags [$w find withtag current]]
  2134. set n [string trimright \
  2135. [lindex $tags [lsearch -glob $tags *C]] C]
  2136. set t [string range \
  2137. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  2138. if {$n != ""} {
  2139. GraVarInitFgTree $w $t $n
  2140. }
  2141. }
  2142. ### cette fonction modifie la valeur $T($ti,gfg,$node) (affecte $color)
  2143. ### elle est utilisee par la localisation et NodeColorFgTreeToolbox
  2144. proc NodeColorFgTree {t code color} {
  2145. global T S
  2146. set w $S($t,w)
  2147. set p [format "%s%s" $code *]
  2148. set listeitems {}
  2149. foreach e $T($t,all_cod) {
  2150. if {[string match $p $e] == 1} {
  2151. foreach j [$w find withtag [format "%s%s" $e C]] {
  2152. NodeColorFgItem $w $j $color
  2153. }
  2154. }
  2155. }
  2156. # il faut supprimer les variables des nodes issues de $code
  2157. set pattern [format "%s%s" $code *]
  2158. foreach key [array names T $t,gfg,$pattern] {
  2159. unset T($key)
  2160. }
  2161. # on cree la variable graphique pour le node pere seuleument
  2162. set T($t,gfg,$code) $color
  2163. }
  2164. ### cette fonction modifie la valeur $T($ti,gfg,$node) (affecte $color)
  2165. ### elle est utilisee par la localisation et NodeColorFgTreeToolbox
  2166. proc NodeColorFgTree2 {t code color} {
  2167. global T S
  2168. set w $S($t,w)
  2169. #set p [format "%s%s" $code *]
  2170. set item [$w find withtag $code]
  2171. # set item [$w find withtag [format "%s%s" $code C]]
  2172. NodeColorFgItem $w $item $color
  2173. }
  2174. ### cette fonction modifie la valeur $T($ti,gfg,$node) (affecte $color)
  2175. ### elle est utilisee par la localisation et NodeColorFgTreeToolbox
  2176. proc NodeColorFgTreeNoMem {t code color} {
  2177. global T S
  2178. set w $S($t,w)
  2179. set p [format "%s%s" $code *]
  2180. set listeitems {}
  2181. foreach e $T($t,all_cod) {
  2182. if {[string match $p $e] == 1} {
  2183. foreach j [$w find withtag [list [format "%s%s" $e C] && T$t]] {
  2184. lappend listeitems $j
  2185. }
  2186. }
  2187. }
  2188. foreach i $listeitems {
  2189. NodeColorFgItem $w $i $color
  2190. }
  2191. }
  2192. ###
  2193. proc CatchColor {w} {
  2194. global S
  2195. set i [$w find withtag current]
  2196. set color ""
  2197. switch [$w type $i] {
  2198. rectangle - polygon - oval - line - text {
  2199. set color [lindex [$w itemconfigure $i -fill] end]
  2200. }
  2201. arc {
  2202. set color [lindex [$w itemconfigure $i -outline] end]
  2203. }
  2204. }
  2205. if {$color != ""} {
  2206. set S(col) $color
  2207. if {[winfo exists .colorpanel.sample] == 1} {.colorpanel.sample configure -background $S(col)}
  2208. set winwin [format "%s%s%s" .colorpanel.dic. $S(col) .b]
  2209. if {[winfo exists $winwin] == 1} {$winwin select}
  2210. }
  2211. }
  2212. ###
  2213. proc CatchFont {w} {
  2214. global S
  2215. set i [$w find withtag current]
  2216. set font ""
  2217. switch [$w type $i] {
  2218. text {
  2219. set font [lindex [$w itemconfigure $i -font] end]
  2220. }
  2221. }
  2222. if {$font != ""} {
  2223. set S(gfo) $font
  2224. foreach {var val} $font {
  2225. set S($var) $val
  2226. }
  2227. if {[winfo exists .fontpanel.msg] == 1} {.fontpanel.msg configure -font $S(gfo)}
  2228. }
  2229. }
  2230. ###
  2231. proc FontWeight {w} {
  2232. global T S
  2233. set tags [$w gettags [$w find withtag current]]
  2234. set t [string range \
  2235. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  2236. set n [string trimright \
  2237. [lindex $tags [lsearch -glob $tags *C]] C]
  2238. if {$n != ""} {
  2239. set leafs [Tools::NodeNoToLe $t $n]
  2240. foreach code $leafs {
  2241. set i [$w find withtag [list [format "%s%s" EUL $T($t,ctl,$code)] && T$t]]
  2242. set f [lindex [$w itemconfigure $i -font] end]
  2243. set fnew {}
  2244. foreach {var val} $f {
  2245. if {$var == "-weight"} {
  2246. if {$val == "bold"} {set val normal} {set val bold}
  2247. }
  2248. lappend fnew $var $val
  2249. }
  2250. set T($t,gfo,$code) $fnew
  2251. $w itemconfigure $i -font $fnew
  2252. }
  2253. }
  2254. }
  2255. ###
  2256. proc FontSlant {w} {
  2257. global T S
  2258. set tags [$w gettags [$w find withtag current]]
  2259. set t [string range \
  2260. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  2261. set n [string trimright \
  2262. [lindex $tags [lsearch -glob $tags *C]] C]
  2263. if {$n != ""} {
  2264. set leafs [Tools::NodeNoToLe $t $n]
  2265. foreach code $leafs {
  2266. set i [$w find withtag [list [format "%s%s" EUL $T($t,ctl,$code)] && T$t]]
  2267. set f [lindex [$w itemconfigure $i -font] end]
  2268. set fnew {}
  2269. foreach {var val} $f {
  2270. if {$var == "-slant"} {
  2271. if {$val == "roman"} {set val italic} {set val roman}
  2272. }
  2273. lappend fnew $var $val
  2274. }
  2275. set T($t,gfo,$code) $fnew
  2276. $w itemconfigure $i -font $fnew
  2277. }
  2278. }
  2279. }
  2280. ###
  2281. proc FontOverstrike {w} {
  2282. global T S
  2283. set tags [$w gettags [$w find withtag current]]
  2284. set t [string range \
  2285. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  2286. set n [string trimright \
  2287. [lindex $tags [lsearch -glob $tags *C]] C]
  2288. if {$n != ""} {
  2289. set leafs [Tools::NodeNoToLe $t $n]
  2290. foreach code $leafs {
  2291. set i [$w find withtag [list [format "%s%s" EUL $T($t,ctl,$code)] && T$t]]
  2292. set f [lindex [$w itemconfigure $i -font] end]
  2293. set fnew {}
  2294. foreach {var val} $f {
  2295. if {$var == "-overstrike"} {
  2296. if {$val == "true"} {set val false} {set val true}
  2297. }
  2298. lappend fnew $var $val
  2299. }
  2300. set T($t,gfo,$code) $fnew
  2301. $w itemconfigure $i -font $fnew
  2302. }
  2303. }
  2304. }
  2305. ###
  2306. proc FontUnderline {w} {
  2307. global T S
  2308. set tags [$w gettags [$w find withtag current]]
  2309. set t [string range \
  2310. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  2311. set n [string trimright \
  2312. [lindex $tags [lsearch -glob $tags *C]] C]
  2313. if {$n != ""} {
  2314. set leafs [Tools::NodeNoToLe $t $n]
  2315. foreach code $leafs {
  2316. set i [$w find withtag [list [format "%s%s" EUL $T($t,ctl,$code)] && T$t]]
  2317. set f [lindex [$w itemconfigure $i -font] end]
  2318. set fnew {}
  2319. foreach {var val} $f {
  2320. if {$var == "-underline"} {
  2321. if {$val == "true"} {set val false} {set val true}
  2322. }
  2323. lappend fnew $var $val
  2324. }
  2325. set T($t,gfo,$code) $fnew
  2326. $w itemconfigure $i -font $fnew
  2327. }
  2328. }
  2329. }
  2330. ### OK
  2331. proc FontSize {w mode} {
  2332. global T S
  2333. set tags [$w gettags [$w find withtag current]]
  2334. set t [string range \
  2335. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  2336. set n [string trimright \
  2337. [lindex $tags [lsearch -glob $tags *C]] C]
  2338. if {$n != ""} {
  2339. set leafs [Tools::NodeNoToLe $t $n]
  2340. foreach code $leafs {
  2341. set i [$w find withtag [list [format "%s%s" EUL $T($t,ctl,$code)] && T$t]]
  2342. set f [lindex [$w itemconfigure $i -font] end]
  2343. set fnew {}
  2344. foreach {var val} $f {
  2345. if {$var == "-size"} {
  2346. if {$mode == "+"} {set val [incr val]} {set val [incr val -1]}
  2347. }
  2348. lappend fnew $var $val
  2349. }
  2350. set T($t,gfo,$code) $fnew
  2351. $w itemconfigure $i -font $fnew
  2352. }
  2353. }
  2354. }
  2355. ### OK
  2356. proc FontSetGlobalToolbox {w} {
  2357. global T S
  2358. set tags [$w gettags [$w find withtag current]]
  2359. set n [string trimright \
  2360. [lindex $tags [lsearch -glob $tags *C]] C]
  2361. set t [string range \
  2362. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  2363. if {$n != ""} {
  2364. FontSetGlobal $t $n $S(gfo)
  2365. }
  2366. }
  2367. ### Font du panel Font, via un node pere
  2368. proc FontSetGlobal {t n font} {
  2369. global T S
  2370. set w $S($t,w)
  2371. set leafs [Tools::NodeNoToLe $t $n]
  2372. foreach code $leafs {
  2373. $w itemconfigure [list [format "%s%s" EUL $T($t,ctl,$code)] && T$t] -font $font
  2374. set T($t,gfo,$code) $font
  2375. }
  2376. }
  2377. ### Font du panel Font, via une liste d'eu
  2378. proc FontSetGlobalEU {t eus font} {
  2379. global T S
  2380. set w $S($t,w)
  2381. foreach eu $eus {
  2382. $w itemconfigure [list [format "%s%s" EUL $eu] && T$t] -font $font
  2383. set T($t,gfo,$T($t,ltc,$eu)) $font
  2384. }
  2385. }
  2386. ###
  2387. proc FontSet {t w n variable value} {
  2388. global T
  2389. set f [lindex [$w itemconfigure [format "%s%s" $n EUL] -font] end]
  2390. set fnew {}
  2391. foreach {var val} $f {
  2392. if {$var == $variable} {lappend fnew $var $value} {lappend fnew $var $val}
  2393. }
  2394. set T($t,gfo,$n) $fnew
  2395. $w itemconfigure [format "%s%s" $n EUL] -font $fnew
  2396. }
  2397. ###
  2398. proc RecFoSw {t variable value} {
  2399. global T S
  2400. set w [format "%s%s%s" .t $t .c]
  2401. foreach code $T($t,sel) {
  2402. if {[lsearch -exact $T($t,ue_cod) $code] != -1} {
  2403. FontSet $t $w $code $variable $value
  2404. }
  2405. }
  2406. }
  2407. }
  2408. ####################
  2409. ####################
  2410. # INTEGRATION
  2411. ####################
  2412. namespace eval Integration {
  2413. ### renvoie une chaine newick a partir d'un fichier nexus
  2414. proc NexusToNewick {} {
  2415. global S
  2416. set fSource $S(NexusFileIN)
  2417. set fTarget $S(NexusFileOUT)
  2418. if {$fSource != "" && $fTarget != ""} {
  2419. if [catch {open $fSource r} fidS] {
  2420. puts stderr "Error Opening File"
  2421. } else {
  2422. set s [read $fidS]
  2423. regsub -all "\n" $s "" s
  2424. regsub -all {\[} $s "" s
  2425. # suppression des signes - sur les longueurs de branches
  2426. #regsub -all {:-} $s ":" s
  2427. regsub -all {\]} $s "" s
  2428. #OK puts $s
  2429. set fidT [open $fTarget w]
  2430. # un petit regexp pour recuperer dans blaa la liste des feuilles 1 BLSK, 2 SHSFH, 3 SGGSS
  2431. regexp {Translate(.+?);} $s bla blaa
  2432. #OK puts $blaa
  2433. # un petit foreach pour ranger dans une liste $l les nom des feuilles {BLSK SHSFH SGGSS}
  2434. foreach e $blaa {
  2435. if {[regexp {^[0-9]+$} $e ] ==0} {
  2436. regexp {[^,]+} $e e1
  2437. lappend l $e1
  2438. }
  2439. }
  2440. # un petit regexp de nouveau pour recuperer dans blaa1 l'arbre en format ((1:346.34,2:56.6):876.9,3:1.9)
  2441. # original regexp {;[^(]+([^;]+);(E|e)nd;} $s bla1 blaa1
  2442. regexp {;[^(]+([^;]+);(E|e)nd;} $s bla1 blaa1
  2443. # initialisation de la variable qui va contenir le resultat final
  2444. set Nick {}
  2445. set i 0
  2446. # un petit regsub pour spliter $blaa1 de la forme ((1,2),3) pour la forme ( ( 1 , 2 ) , 3 )
  2447. # pour traiter blaa1 comme une liste avec un foreach
  2448. # Tout d'abord l'arbre a t'il des longueur de feuilles ou faut-il en mettre?
  2449. if [regexp : $blaa1] {
  2450. regsub -all {(\(|,|\)|:)} $blaa1 { & } blaa1
  2451. # un petit foreach pour remplacer dans l'expression $blaa1 les chiffres par le nom
  2452. # des feuilles stocke dans $l
  2453. foreach e $blaa1 {
  2454. if {[regexp {^[0-9]+$} $e] & [lindex $blaa1 [expr $i+1]] == ":"} {
  2455. set Nick $Nick[lindex $l [expr $e -1]]
  2456. } elseif [string equal $e ")"] {
  2457. set Nick $Nick)
  2458. } {
  2459. set Nick $Nick$e
  2460. }
  2461. incr i
  2462. }
  2463. } {
  2464. regsub -all {(\(|,|\))} $blaa1 { & } blaa1
  2465. # un petit foreach pour remplacer dans l'expression $blaa1 les chiffres par le nom
  2466. # des feuilles stocke dans $l
  2467. foreach e $blaa1 {
  2468. if [regexp {^[0-9]+$} $e] {
  2469. set Nick $Nick[lindex $l [expr $e -1]]:1.0
  2470. } elseif [string equal $e ")"] {
  2471. set Nick $Nick):1.0
  2472. } {
  2473. set Nick $Nick$e
  2474. }
  2475. }
  2476. }
  2477. # et c'est fini
  2478. #return $Nick
  2479. puts $fidT "$Nick ;"
  2480. close $fidT
  2481. close $fidS
  2482. }
  2483. }
  2484. }
  2485. # traductoin fichier matrice leaves*variables vers fichier records label file fo treedyn
  2486. proc MakeLabelFile {} {
  2487. global S
  2488. set fSource $S(MakeLabelFileIN)
  2489. set fTarget $S(MakeLabelFileOUT)
  2490. if {$fSource != "" && $fTarget != ""} {
  2491. set fidS [open $fSource r]
  2492. set fidT [open $fTarget w]
  2493. # premiere ligne = liste de variable
  2494. set nbrows 1
  2495. set lrowsBad ""
  2496. gets $fidS variables
  2497. while {[eof $fidS] != 1} {
  2498. incr nbrows
  2499. gets $fidS row
  2500. # verification a faire sur le nombre de valeurs correspondant nombre de variables
  2501. set data ""
  2502. if {[llength $variables] == [llength $row]} {
  2503. # le premier couple var val doit etre EU / $eu on ecrit que $eu sans {}
  2504. set data [lindex $row 0 0]
  2505. #ok
  2506. foreach var [lrange $variables 1 end] val [lrange $row 1 end] {
  2507. set data [concat $data $var [format "%s%s%s" "{" $val "}"]]
  2508. }
  2509. puts $fidT $data
  2510. } else {
  2511. # attention si retour charriot sur la derniere ligne du fichier
  2512. if {$row != ""} {
  2513. set lrowsBad [concat $lrowsBad "Row: $nbrows ([lindex $row 0]) \n"]
  2514. }
  2515. }
  2516. }
  2517. if {$lrowsBad != ""} {
  2518. tk_messageBox -type ok -default ok -icon warning \
  2519. -message "Missing non-paired item/value list ($fSource):\n $lrowsBad"
  2520. }
  2521. close $fidS
  2522. close $fidT
  2523. }
  2524. }
  2525. #
  2526. proc MIbackfile {} {
  2527. set files [.fsp.lfb.l get 0 end]
  2528. destroy .fsp
  2529. .int.n.canvas.notebook.cs.page1.cs.ld.l delete 0 end
  2530. foreach f $files {
  2531. .int.n.canvas.notebook.cs.page1.cs.ld.l insert 0 $f
  2532. }
  2533. }
  2534. #
  2535. proc MIupdateAvailableFile {} {
  2536. global S
  2537. .fsp.lfa.l delete 0 end
  2538. set filter [.fsp.fi get]
  2539. if {$filter == "ALL"} { set pattern *
  2540. } else {
  2541. set pattern [format "%s%s" * $filter]
  2542. }
  2543. #[format "%s%s" $S(userDIR) /?.nwk]
  2544. set AFN [lsort [glob -nocomplain -type f -dir $S(userDIR) $pattern]]
  2545. set S(MultiImportAFN) "[llength $AFN] File(s)"
  2546. foreach f $AFN {
  2547. .fsp.lfa.l insert end [file tail $f]
  2548. }
  2549. MIConfigBg
  2550. }
  2551. #
  2552. proc MIConfigBg {} {
  2553. global S
  2554. # config bg si deja en selection
  2555. set lfselectavecDir {}
  2556. set lfselectsansDir {}
  2557. foreach e [.fsp.lfb.l get 0 end] {
  2558. lappend lfselectsansDir [file tail $e]
  2559. lappend lfselectavecDir $e
  2560. }
  2561. set index 0
  2562. foreach f [.fsp.lfa.l get 0 end] {
  2563. if {[lsearch $lfselectavecDir [format "%s%s%s" $S(userDIR) / $f]] != -1} {
  2564. .fsp.lfa.l itemconfigure $index -background NavajoWhite2
  2565. } elseif {[lsearch $lfselectsansDir $f] != -1} {
  2566. .fsp.lfa.l itemconfigure $index -background NavajoWhite3
  2567. } else {
  2568. .fsp.lfa.l itemconfigure $index -background LightGoldenrodYellow
  2569. }
  2570. incr index
  2571. }
  2572. }
  2573. #
  2574. proc MIupdateDirectories {} {
  2575. global S
  2576. .fsp.ld.l delete 0 end
  2577. foreach d [lsort [glob -nocomplain -type d -dir $S(userDIR) *]] {
  2578. .fsp.ld.l insert end [file tail $d]
  2579. }
  2580. .fsp.ld.l insert 0 ..
  2581. }
  2582. #
  2583. proc MIupdateFol {f} {
  2584. global S
  2585. set S(userDIR) $f
  2586. MIupdateDirectories
  2587. MIupdateAvailableFile
  2588. MIupdateFilter
  2589. }
  2590. #
  2591. proc MIaddFile {} {
  2592. global S
  2593. set li [.fsp.lfa.l curselection] ;# des index
  2594. set lsel {}
  2595. foreach i $li {
  2596. lappend lsel [.fsp.lfa.l get $i]
  2597. .fsp.lfa.l itemconfigure $i -background NavajoWhite2
  2598. }
  2599. set lall2 [.fsp.lfb.l get 0 end]
  2600. .fsp.lfb.l delete 0 end
  2601. foreach e $lsel {
  2602. lappend lall2 [format "%s%s%s" $S(userDIR) / $e]
  2603. }
  2604. foreach e $lall2 {
  2605. .fsp.lfb.l insert 0 $e
  2606. }
  2607. # deselection des fichiers liste available
  2608. .fsp.lfa.l selection clear 0 end
  2609. # conservation dir deja visitees
  2610. if {[lsearch $S(MultiImportDII) $S(userDIR)] == -1} {
  2611. MIupdateFolRebuild
  2612. }
  2613. }
  2614. #
  2615. proc MIaddFileMouse {listbox x y} {
  2616. global S
  2617. set newfile [format "%s%s%s" $S(userDIR) / [.fsp.lfa.l get @$x,$y]]
  2618. .fsp.lfa.l selection clear @$x,$y
  2619. .fsp.lfb.l insert 0 $newfile
  2620. # conservation dir deja visitees
  2621. if {[lsearch $S(MultiImportDII) $S(userDIR)] == -1} {
  2622. MIupdateFolRebuild
  2623. }
  2624. }
  2625. #
  2626. proc MIupdateFolRebuild {} {
  2627. global S
  2628. .fsp.dir.m delete 0 end
  2629. lappend S(MultiImportDII) $S(userDIR)
  2630. foreach e [file volume] {
  2631. .fsp.dir.m add command -label $e -command "Integration::MIupdateFol $e"
  2632. }
  2633. .fsp.dir.m add separator
  2634. foreach e $S(MultiImportDII) {
  2635. .fsp.dir.m add command -label $e -command "Integration::MIupdateFol $e"
  2636. }
  2637. }
  2638. #
  2639. proc MIremFile {} {
  2640. # attention retrait a partir de l'index le plus bat
  2641. # le delete remet a jour les index
  2642. set li [lsort -decreasing [.fsp.lfb.l curselection]] ;# des index
  2643. foreach i $li {
  2644. .fsp.lfb.l delete $i
  2645. }
  2646. # deselection des fichiers liste available
  2647. .fsp.lfa.l selection clear 0 end
  2648. }
  2649. # retrait d'un elt par double-1 sans toucher la selection
  2650. proc MIremFileMouse {listbox x y} {
  2651. $listbox delete @$x,$y
  2652. }
  2653. #
  2654. proc MIupdateDirectoriesMouse {listbox x y} {
  2655. global S
  2656. set repertoire [$listbox get @$x,$y]
  2657. if {$repertoire != ".."} {
  2658. if {[string length $S(ImportDIR)] == 3} {
  2659. set S(ImportDIR) [format "%s%s" $S(userDIR) $repertoire]
  2660. } else {
  2661. set S(ImportDIR) [format "%s%s%s" $S(userDIR) / $repertoire]
  2662. }
  2663. } else {
  2664. set S(ImportDIR) [file dirname $S(userDIR)]
  2665. }
  2666. MIupdateDirectories
  2667. MIupdateAvailableFile
  2668. }
  2669. #
  2670. proc MIupdateFilter {} {
  2671. global S
  2672. .fsp.fi select ALL
  2673. }
  2674. #
  2675. proc RobinsonFoulds {} {
  2676. }
  2677. #
  2678. proc TranslationSelectFile {txt var} {
  2679. global S
  2680. set typelist {
  2681. {"All Files" {*}}
  2682. }
  2683. set file [tk_getOpenFile -initialdir $S(userDIR) \
  2684. -filetypes $typelist -defaultextension "*" \
  2685. -title $txt]
  2686. if {$file != ""} {set S(userDIR) [file dirname $file] ; set S($var) $file}
  2687. }
  2688. # procedure de changement des noms des feuilles si les noms des feuilles
  2689. # attention ne pas melanger entre des longueurs de branche et des nombres pour des noms de feuilles
  2690. # feuilles : (f: soit ,f: attention bien cadrer a gauche et a droite, ne pas prendre que $f:)
  2691. # impossible de melanger avec longueurs de branche
  2692. # qui sont soit ":v," soit ":v)"
  2693. proc NewickTranslation {} {
  2694. global S
  2695. set filename $S(FSPtransTrF)
  2696. if [catch {open $filename r} fid] {
  2697. puts stderr "Error Opening File"
  2698. } else {
  2699. set filename2 $S(FSPtransFF)
  2700. if [catch {open $filename2 r} fid2] {
  2701. puts stderr "Error Opening File"
  2702. } else {
  2703. set translation [read $fid]
  2704. set source [read $fid2]
  2705. regsub -all {\n} $source "" source
  2706. set fidTARGET [open $S(FSPtransTF) a]
  2707. foreach {val var trans} $translation {
  2708. set feuilleFrom [format "%s%s%s" "\\(" $val ":" ]
  2709. set feuilleVers [format "%s%s%s" "\(" $trans ":" ]
  2710. #set feuilleVers [format "%s%s%s" "\(" [string toupper $trans] ":" ]
  2711. set trouve [regsub $feuilleFrom $source $feuilleVers source]
  2712. if {$trouve == 0} {
  2713. set feuilleFrom [format "%s%s%s" , $val : ]
  2714. set feuilleVers [format "%s%s%s" , $trans : ]
  2715. #set feuilleVers [format "%s%s%s" , [string toupper $trans] : ]
  2716. regsub $feuilleFrom $source $feuilleVers source
  2717. }
  2718. }
  2719. puts $fidTARGET $source
  2720. close $fid
  2721. close $fid2
  2722. close $fidTARGET
  2723. }
  2724. }
  2725. }
  2726. proc FileConcatenation {} {
  2727. global S
  2728. set fSource [.int.p.cs.page0.cs.ld.l get 0 end]
  2729. set fTarget $S(FSPtargetfile)
  2730. if {$fSource != "" && $fTarget != ""} {
  2731. set fidT [open $fTarget a]
  2732. foreach f $fSource {
  2733. set fid [open $f r]
  2734. set data [read $fid]
  2735. puts $fidT $data
  2736. close $fid
  2737. }
  2738. close $fidT
  2739. }
  2740. }
  2741. }
  2742. ####################
  2743. ####################
  2744. # ILLUSTRATION
  2745. ####################
  2746. namespace eval Illustration {
  2747. proc BracketDrawLeafs {w t leafs text colortext fo tab dx color stipple} {
  2748. global S
  2749. set ltag {}
  2750. foreach l $leafs {
  2751. set tag [format "%s%s" EUL $l]
  2752. lappend ltag $tag
  2753. }
  2754. set co [eval $w bbox $ltag]
  2755. if {$tab == 0} {
  2756. set x [lindex $co 2]
  2757. } else {
  2758. # on tabul relativement a l'arbre
  2759. set tag [format "%s%s" T$t &&!DRAW]
  2760. set cotree [eval $w bbox $tag]
  2761. set xt [lindex $cotree 2]
  2762. set x [expr $xt + $tab]
  2763. }
  2764. set y1 [expr [lindex $co 1] + 3]
  2765. set y2 [expr [lindex $co 3] - 3]
  2766. set id [format "%s%s" NBKT [Tools::GenId]]
  2767. $w create rectangle $x $y1 [expr $x + $dx] $y2 \
  2768. -fill $color -outline $color -width 1 -tags "nbracket nbracketrec $id DRAW T$t" \
  2769. -stipple @[file join $S(TheoPATH) + stipple $stipple]
  2770. set ym [expr ($y1 + $y2) / 2.0]
  2771. $w create text [expr $x + $dx + 5] $ym -text $text \
  2772. -anchor w -font $fo -fill $colortext -tags "nbracket nbracketext $id DRAW T$t"
  2773. }
  2774. proc BracketDrawCreateNode {w shape x y} {
  2775. global S
  2776. set tags [$w gettags [$w find withtag current]]
  2777. set n [string trimright \
  2778. [lindex $tags [lsearch -glob $tags *C]] C]
  2779. set t [string range \
  2780. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  2781. if {$n != ""} {
  2782. set leafs [Tools::NodeNoToLe $t $n]
  2783. set l1 [lindex $leafs 0]
  2784. set l2 [lindex $leafs end]
  2785. set co1 [$w coords $l1]; set co2 [$w coords $l2]
  2786. set x1 [lindex $co1 0] ; set y1 [lindex $co1 1]
  2787. set x2 [lindex $co2 0] ; set y2 [lindex $co2 1]
  2788. set id [format "%s%s" NBKT [Tools::GenId]]
  2789. switch -exact $shape {
  2790. bracket {
  2791. $w create rectangle $x1 $y1 [expr $x1 +5] $y2 \
  2792. -fill $S(col) -width 1 -tags "nbracket nbracketrec $id DRAW T$t" \
  2793. -stipple @[file join $S(TheoPATH) + stipple $S(stipple)]
  2794. set ym [expr ($y1 + $y2) / 2.0]
  2795. $w create text [expr $x1 + 10] $ym -text $S(AnnotateNote) \
  2796. -anchor w -font $S(gfo) -fill $S(col) -tags "nbracket nbracketext $id DRAW T$t"
  2797. }
  2798. }
  2799. # passage mode move
  2800. set S(tool) move
  2801. bindtags $w [list $S(tool) $w Canvas . all]
  2802. }
  2803. }
  2804. ### Draw bracket, forcer la ligne verticalite
  2805. # possibilit?Š de grande taille, dessin vectoriel
  2806. # shape sera soit bracket soit accolade
  2807. #
  2808. proc BracketDrawCreate {w shape x y} {
  2809. global S
  2810. set id [$w find closest $x $y]
  2811. set tags [$w gettags $id]
  2812. set t [string range [lindex $tags [lsearch -glob $tags T*]] 1 end]
  2813. if {$t != ""} {
  2814. set x [$w canvasx $x] ; set y [$w canvasy $y]
  2815. set id [format "%s%s" BKT [Tools::GenId]]
  2816. set S(bracketdrawOri) $x
  2817. set S(bracketdrawId) $id
  2818. set S(bracketdrawIdT) T$t
  2819. switch -exact $shape {
  2820. bracket {
  2821. $w create line [expr $x -5] $y $x $y \
  2822. -fill black -width 1 -tags "bracket $id DRAW T$t"
  2823. $w create line $x $y $x $y \
  2824. -fill black -width 1 -tags "bracket $id rubbershape DRAW T$t"
  2825. }
  2826. accolade {
  2827. #A FAIRE
  2828. }
  2829. }
  2830. }
  2831. }
  2832. #
  2833. proc BracketDrawDrag {w x y} {
  2834. global S
  2835. set x [$w canvasx $x] ; set y [$w canvasy $y]
  2836. set coords [$w coords "rubbershape"]
  2837. set coords [lreplace $coords 2 3 $S(bracketdrawOri) $y]
  2838. eval $w coords "rubbershape" $coords
  2839. }
  2840. #
  2841. proc BracketDrawEnd {w x y} {
  2842. global S
  2843. BracketDrawDrag $w $S(bracketdrawOri) $y
  2844. set x [$w canvasx $x] ; set y [$w canvasy $y]
  2845. $w create line [expr $S(bracketdrawOri) - 5] $y [expr $S(bracketdrawOri) + 1] $y \
  2846. -fill black -width 1 -tags "bracket $S(bracketdrawId) DRAW $S(bracketdrawIdT)"
  2847. $w dtag "rubbershape"
  2848. }
  2849. proc BracketNproperties {w i what} {
  2850. global S
  2851. switch -- $what {
  2852. text {
  2853. set id [$w find withtag [list $i && nbracketext]]
  2854. set co [$w coords $id]
  2855. set xi [lindex $co 0] ; set yi [lindex $co 1]
  2856. set col [lindex [$w itemconfigure $id -fill] end]
  2857. set fo [lindex [$w itemconfigure $id -font] end]
  2858. set tags [$w gettags $id]
  2859. $w delete $id
  2860. $w create text $xi $yi -text $S(AnnotateNote) \
  2861. -anchor w -font $fo -fill $col -tags $tags
  2862. }
  2863. color {
  2864. set id [$w find withtag [list $i && nbracketrec]]
  2865. $w itemconfigure $id -fill $S(col)
  2866. set id [$w find withtag [list $i && nbracketext]]
  2867. $w itemconfigure $id -fill $S(col)
  2868. }
  2869. stipple {
  2870. set id [$w find withtag [list $i && nbracketrec]]
  2871. $w itemconfigure $id -stipple @[file join $S(TheoPATH) + stipple $S(stipple)]
  2872. }
  2873. font {
  2874. set id [$w find withtag [list $i && nbracketext]]
  2875. $w itemconfigure $id -font $S(gfo)}
  2876. }
  2877. }
  2878. #
  2879. proc BracketAddLabel {w i} {
  2880. global S
  2881. set tags [$w gettags $i]
  2882. set id [lindex $tags [lsearch -glob $tags BKT*]]
  2883. $w delete LAB$id
  2884. set cod [$w bbox $id]
  2885. set x [lindex $cod 2]
  2886. set y1 [lindex $cod 1]
  2887. set y2 [lindex $cod 3]
  2888. set y [expr ($y1 + $y2) / 2.0]
  2889. $w create text $x $y -text $S(AnnotateNote) \
  2890. -anchor w \
  2891. -font $S(gfo) -tags "bracket LAB$id $id DRAW"
  2892. }
  2893. #
  2894. proc BracketAlign {w i} {
  2895. global S
  2896. set tags [$w gettags $i]
  2897. set id [lindex $tags [lsearch -glob $tags BKT*]]
  2898. set cod [$w bbox $id]
  2899. set x [lindex $cod 2]
  2900. set bkt [$w find withtag bracket]
  2901. foreach i $bkt {
  2902. set coi [$w bbox $i]
  2903. set newc [list $x [lrange $cod 1 end]]
  2904. $w coords $i $newc
  2905. }
  2906. }
  2907. ###
  2908. proc NodeBgContour {w x y} {
  2909. global S B
  2910. set tags [$w gettags [$w find withtag current]]
  2911. set n [string trimright \
  2912. [lindex $tags [lsearch -glob $tags *C]] C]
  2913. set t [string range \
  2914. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  2915. set lxy [Figuration::NodeColorBgSubTreeContour $w $t $n]
  2916. set c0 [$w bbox $n]
  2917. set x0 [lindex $c0 0]
  2918. set y0 [lindex $c0 1]
  2919. set id [format "%s%s" $t [Tools::GenId]]
  2920. set tag [format "%s%s%s" BGS ? $id]
  2921. $w create polygon "$x0 $y0 $lxy $x0 $y0" -smooth 1 -splinesteps 100 \
  2922. -fill $S(col) -outline $S(col) -tags "bgtree T$t $tag"
  2923. $w lower bgtree
  2924. # MEM
  2925. set B(BGStre,$id) $t
  2926. set B(BGSnod,$id) $n
  2927. set B(BGScol,$id) $S(col)
  2928. # Liste des BGS par tree
  2929. lappend B($t,bgs) $id
  2930. }
  2931. #
  2932. #
  2933. proc NodeIllustration {w x y} {
  2934. global S
  2935. set tags [$w gettags [$w find withtag current]]
  2936. set n [string trimright \
  2937. [lindex $tags [lsearch -glob $tags *C]] C]
  2938. set t [string range \
  2939. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  2940. if {$n != ""} {
  2941. set co [$w coords $n]
  2942. set x [lindex $co 0]
  2943. set y [lindex $co 1]
  2944. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  2945. #set S(symbolcolorfill) $S(col)
  2946. #set S(symbolcoloroutline) $S(col)
  2947. #set S(symbolstipple) $S(stipple)
  2948. Illustration::drawsymbol $w $x $y [list T$t AnnotMatrix AM$t $tagC AMatrixCo]
  2949. update
  2950. }
  2951. }
  2952. #
  2953. proc NodeIllustration2 {w x y} {
  2954. global S
  2955. set tags [$w gettags [$w find withtag current]]
  2956. set n [string trimright \
  2957. [lindex $tags [lsearch -glob $tags *C]] C]
  2958. set t [string range \
  2959. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  2960. if {$n != ""} {
  2961. set co [$w coords $n]
  2962. set y [lindex $co 1]
  2963. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  2964. #set S(symbolcolorfill) $S(col)
  2965. #set S(symbolcoloroutline) $S(col)
  2966. #set S(symbolstipple) $S(stipple)
  2967. Illustration::drawsymbol $w $x $y [list T$t AnnotMatrix AM$t $tagC AMatrixCo]
  2968. update
  2969. }
  2970. }
  2971. #
  2972. proc SymbolInsert {w x y} {
  2973. global S
  2974. #set S(symbolcolorfill) $S(col)
  2975. #set S(symbolcoloroutline) $S(col)
  2976. #set S(symbolstipple) $S(stipple)
  2977. Illustration::drawsymbol $w [$w canvasx $x] [$w canvasy $y] [list DRAW symbol]
  2978. }
  2979. proc LillLtoolbox {w x y} {
  2980. global T S
  2981. set tags [$w gettags [$w find withtag current]]
  2982. set t [string range \
  2983. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  2984. set n [string trimright \
  2985. [lindex $tags [lsearch -glob $tags *C]] C]
  2986. if {$n != ""} {
  2987. set p [format "%s%s" $n *]
  2988. set leu {}
  2989. foreach e $T($t,ue_cod) {
  2990. if {[string match $p $e] == 1} {
  2991. lappend leu $T($t,ctl,$e)
  2992. }
  2993. }
  2994. LillL $w $t $leu
  2995. }
  2996. }
  2997. # Leaves Illustration mode Leave
  2998. proc LillL {w t leu} {
  2999. global T S
  3000. # tag serie
  3001. switch -exact $S($t,type) {
  3002. PhyNJ - ClaSla - ClaRec {
  3003. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  3004. foreach l $leu {
  3005. #set l $T($t,ctl,$code)
  3006. set i [$w find withtag [list ILLL?$l && T$t]]
  3007. if {$i == ""} {
  3008. set i [$w find withtag [list [format "%s%s" EUL $l] && T$t]]
  3009. set co [$w coords $i]
  3010. set y [lindex $co 1]
  3011. set x [lindex [$w bbox $i] 2]
  3012. } else {
  3013. # cas si plusieurs ajout on recup le i de plus gran x
  3014. set co [$w coords [lindex $i 0]]
  3015. set y [lindex $co 1]
  3016. set x 0
  3017. foreach ii $i {
  3018. set xii [lindex [$w bbox $ii] 2]
  3019. if {$xii >= $x} {
  3020. set x $xii
  3021. }
  3022. }
  3023. }
  3024. if {$x != "" && $y != ""} {
  3025. #set S(symbolcolorfill) $S(col)
  3026. #set S(symbolcoloroutline) $S(col)
  3027. #set S(symbolstipple) $S(stipple)
  3028. Illustration::drawsymbol $w $x $y [list ILLCo?$l T$t AnnotMatrix AM$t MA?$l $tagC AMatrixCo]
  3029. }
  3030. }
  3031. }
  3032. PhyRad - PhyCir1 - PhyCir2 - ClaRad {
  3033. LillL360bis $w $t $leu
  3034. }
  3035. ClaCir1 - ClaCir2 - ClaCir3 {
  3036. LillL360 $w $t $leu
  3037. }
  3038. }
  3039. }
  3040. #
  3041. proc LillL360 {} {
  3042. }
  3043. #
  3044. proc LillL360bis {} {
  3045. }
  3046. #
  3047. proc LillCtoolbox {w x y } {
  3048. global T S
  3049. set tags [$w gettags [$w find withtag current]]
  3050. set t [string range \
  3051. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  3052. set n [string trimright \
  3053. [lindex $tags [lsearch -glob $tags *C]] C]
  3054. if {$n != ""} {
  3055. set p [format "%s%s" $n *]
  3056. set leu {}
  3057. foreach e $T($t,ue_cod) {
  3058. if {[string match $p $e] == 1} {
  3059. lappend leu $T($t,ctl,$e)
  3060. }
  3061. }
  3062. LillC $w $t $leu
  3063. }
  3064. }
  3065. # Leaves Illustration mode Columns
  3066. # tab la variable de tabulation entre differentes colonnes
  3067. proc LillC {w t leu } {
  3068. global S ann T
  3069. if {$S(illustration-tabulation) == 1} {
  3070. set S($t,LabelMatrixBase) [expr $S($t,LabelMatrixBase) + $S(TabulationAnnot)]
  3071. }
  3072. #set S($t,LabelMatrixBase) [expr $S($t,LabelMatrixBase) + $S(TabulationAnnot)]
  3073. #
  3074. switch -exact $S($t,type) {
  3075. PhyNJ - ClaSla - ClaRec {
  3076. set XMAX1 [lindex [$w bbox [list T$t && Z]] 2]
  3077. set XMAX2 [lindex [$w bbox [list T$t && L]] 2]
  3078. if {$XMAX1 < $XMAX2} {set XMAX $XMAX2 } {set XMAX $XMAX1}
  3079. set x [expr $XMAX + $S($t,LabelMatrixBase)]
  3080. # tag de colonne
  3081. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  3082. foreach l $leu {
  3083. # recherche y (code arrete terminale)
  3084. set item [$w find withtag [list [format "%s%s" EU $l ] && T$t]]
  3085. if {$item != ""} {
  3086. set co [$w coords $item]
  3087. set y [lindex $co 1]
  3088. #set S(symbolcolorfill) $S(col)
  3089. #set S(symbolcoloroutline) $S(col)
  3090. #set S(symbolstipple) $S(stipple)
  3091. drawsymbol $w $x $y [list ILLCo?$l T$t AnnotMatrix AM$t MA?$l $tagC AMatrixCo]
  3092. }
  3093. }
  3094. }
  3095. PhyRad - PhyCir1 - PhyCir2 - ClaRad {
  3096. # ENCORE DU TRAVAIL A FAIRE
  3097. # PB du rectangle / oval, des zones de dessin arbre en dehors de l'oval
  3098. # LillC360bis $w $t $leu
  3099. LillC360bis2 $w $t $leu
  3100. }
  3101. ClaCir1 - ClaCir2 - ClaCir3 {
  3102. LillC360 $w $t $leu
  3103. }
  3104. }
  3105. #Navigation::FitToContents $w
  3106. }
  3107. proc drawsymbol {w x y tags} {
  3108. global S
  3109. switch $S(symboltype) {
  3110. 01 {
  3111. # carre rectangle ok
  3112. $w create rectangle [expr $x-$S(symboldx)] [expr $y-$S(symboldy)] [expr $x+$S(symboldx)] [expr $y+$S(symboldy)] \
  3113. -fill $S(symbolcolorfill) -outline $S(symbolcoloroutline) \
  3114. -tags $tags -stipple @[file join $S(TheoPATH) + stipple $S(symbolstipple)]
  3115. }
  3116. 02 {
  3117. # cercle/ocal ok
  3118. $w create oval [expr $x-$S(symboldx)] [expr $y-$S(symboldy)] [expr $x+$S(symboldx)] [expr $y+$S(symboldy)] \
  3119. -fill $S(symbolcolorfill) -outline $S(symbolcoloroutline) \
  3120. -tags $tags -stipple @[file join $S(TheoPATH) + stipple $S(symbolstipple)]
  3121. }
  3122. 03 {
  3123. # losange ok
  3124. $w create polygon [expr $x-$S(symboldx)] $y $x [expr $y-$S(symboldy)] [expr $x+$S(symboldx)] $y $x [expr $y+$S(symboldy)] \
  3125. -fill $S(symbolcolorfill) -outline $S(symbolcoloroutline) \
  3126. -tags $tags -stipple @[file join $S(TheoPATH) + stipple $S(symbolstipple)]
  3127. }
  3128. 04 {
  3129. # triangle right ok
  3130. $w create polygon [expr $x-$S(symboldx)] [expr $y-$S(symboldy)] [expr $x+$S(symboldx)] $y [expr $x-$S(symboldx)] [expr $y+$S(symboldy)] \
  3131. -fill $S(symbolcolorfill) -outline $S(symbolcoloroutline) \
  3132. -tags $tags -stipple @[file join $S(TheoPATH) + stipple $S(symbolstipple)]
  3133. }
  3134. 05 {
  3135. # triangle left ok
  3136. $w create polygon [expr $x+$S(symboldx)] [expr $y-$S(symboldy)] [expr $x+$S(symboldx)] [expr $y+$S(symboldy)] [expr $x-$S(symboldx)] $y \
  3137. -fill $S(symbolcolorfill) -outline $S(symbolcoloroutline) \
  3138. -tags $tags -stipple @[file join $S(TheoPATH) + stipple $S(symbolstipple)]
  3139. }
  3140. 06 {
  3141. # triangle bottom ok
  3142. $w create polygon [expr $x-$S(symboldx)] [expr $y-$S(symboldy)] [expr $x+$S(symboldx)] [expr $y-$S(symboldy)] $x [expr $y+$S(symboldy)] \
  3143. -fill $S(symbolcolorfill) -outline $S(symbolcoloroutline) \
  3144. -tags $tags -stipple @[file join $S(TheoPATH) + stipple $S(symbolstipple)]
  3145. }
  3146. 07 {
  3147. # triangle top
  3148. $w create polygon [expr $x-$S(symboldx)] [expr $y+$S(symboldy)] [expr $x+$S(symboldx)] [expr $y+$S(symboldy)] $x [expr $y-$S(symboldy)] \
  3149. -fill $S(symbolcolorfill) -outline $S(symbolcoloroutline) \
  3150. -tags $tags -stipple @[file join $S(TheoPATH) + stipple $S(symbolstipple)]
  3151. }
  3152. 08 {
  3153. #case a cocher 0 OK
  3154. $w create rectangle [expr $x-$S(symboldx)] [expr $y-$S(symboldy)] [expr $x+$S(symboldx)] [expr $y+$S(symboldy)] \
  3155. -outline $S(symbolcoloroutline) \
  3156. -tags $tags -stipple @[file join $S(TheoPATH) + stipple $S(symbolstipple)]
  3157. }
  3158. 09 {
  3159. #case a cocher 1 OK
  3160. $w create rectangle [expr $x-$S(symboldx)] [expr $y-$S(symboldy)] [expr $x+$S(symboldx)] [expr $y+$S(symboldy)] \
  3161. -outline $S(symbolcoloroutline) \
  3162. -tags $tags -stipple @[file join $S(TheoPATH) + stipple $S(stipple)]
  3163. $w create line [expr $x-$S(symboldx)] [expr $y-$S(symboldy)] [expr $x+$S(symboldx)] [expr $y+$S(symboldy)] \
  3164. -fill $S(symbolcolorfill) \
  3165. -tags $tags
  3166. $w create line [expr $x-$S(symboldx)] [expr $y+$S(symboldy)] [expr $x+$S(symboldx)] [expr $y-$S(symboldy)] \
  3167. -fill $S(symbolcolorfill) \
  3168. -tags $tags
  3169. }
  3170. }
  3171. }
  3172. proc LillCpolygon {w t leu } {
  3173. global S ann T
  3174. #
  3175. if [catch {expr $S($t,LabelMatrixBase) + $S(TabulationAnnot)} result] {
  3176. set S($t,LabelMatrixBase) $S(TabulationAnnot)
  3177. } else {
  3178. # tabulation entre colonnes
  3179. # possiblit?Š de rester sur la meme colonne
  3180. if {$S(illustration-tabulation) == 1} {
  3181. set S($t,LabelMatrixBase) $result
  3182. }
  3183. }
  3184. #
  3185. switch -exact $S($t,type) {
  3186. PhyNJ - ClaSla - ClaRec {
  3187. # recherche x
  3188. if {$S(illustration-tabulation) == 1} {
  3189. set XMAX1 [lindex [$w bbox [list T$t && Z]] 2]
  3190. set XMAX2 [lindex [$w bbox [list T$t && L]] 2]
  3191. set XMAX3 [lindex [$w bbox [list T$t && AnnotMatrix]] 2]
  3192. if {$XMAX1 < $XMAX2} {set XMAX $XMAX2 } {set XMAX $XMAX1}
  3193. if {$XMAX < $XMAX3} {set XMAX $XMAX3 }
  3194. set x [expr $XMAX + $S($t,LabelMatrixBase)]
  3195. } else {
  3196. set XMAX1 [lindex [$w bbox [list T$t && Z]] 2]
  3197. set XMAX2 [lindex [$w bbox [list T$t && L]] 2]
  3198. if {$XMAX1 < $XMAX2} {set XMAX $XMAX2 } {set XMAX $XMAX1}
  3199. set x [expr $XMAX + $S($t,LabelMatrixBase)]
  3200. }
  3201. # tag de colonne
  3202. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  3203. foreach l $leu {
  3204. # recherche y (code arrete terminale)
  3205. set item [$w find withtag [list [format "%s%s" EU $l ] && T$t]]
  3206. if {$item != ""} {
  3207. set co [$w coords $item]
  3208. set y [lindex $co 1]
  3209. # avoir 2 caracteres pour bon centrage
  3210. #set illtxt [concat " " [lindex $S(ill-car-fon) 0 ]]
  3211. #set illfon [lrange $S(ill-car-fon) 1 end]
  3212. set illtxt [concat " " $S(ill-car) ]
  3213. set illfon $S(ill-fon)
  3214. # On va chercher pour la variable en selection la liste des coords du polygon a trace
  3215. # f est un facteur d'amplification ?  appliquer sur les coord du polygon
  3216. # x et y sont utiliser pour appliquer une translation en x et y respectivement
  3217. set item [$w create text $x $y \
  3218. -text $illtxt \
  3219. -anchor center -justify center \
  3220. -fill $S(col) \
  3221. -font $illfon \
  3222. -tags "ILLCo?$l T$t AnnotMatrix AM$t MA?$l $tagC AMatrixCo"]
  3223. $w raise $item
  3224. update
  3225. }
  3226. }
  3227. }
  3228. PhyRad - PhyCir1 - PhyCir2 - ClaRad {
  3229. }
  3230. ClaCir1 - ClaCir2 - ClaCir3 {
  3231. }
  3232. }
  3233. }
  3234. ###
  3235. proc LillC360 {w t leu} {
  3236. global S ann T
  3237. set d $S($t,LabelMatrixBase)
  3238. set co [$w bbox [list Z && T$t]]
  3239. set x1 [lindex $co 0]
  3240. set y1 [lindex $co 1]
  3241. set x2 [lindex $co 2]
  3242. set y2 [lindex $co 3]
  3243. set C(dx) [expr abs(($x2 - $x1)) /2.0]
  3244. set C(dy) [expr abs(($y2 - $y1)) /2.0]
  3245. set a_ref [expr 360.0/ [llength $T($t,ue_cod)]] ;# unit?Š d'angle
  3246. set n 0
  3247. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  3248. if { $S($t,type) == "ClaCir2"} {
  3249. # inversion de la liste des eus
  3250. set LLE {}
  3251. foreach e $T($t,ue_cod) {
  3252. set LLE [concat $e $LLE]
  3253. }
  3254. set n 1
  3255. } else {
  3256. set LLE $T($t,ue_cod)
  3257. }
  3258. foreach e $LLE {
  3259. set C(angle,$e) [expr $n*$a_ref]
  3260. if { [lsearch $leu $T($t,ctl,$e)] != -1} {
  3261. # degres -> radians
  3262. set angrad [expr (2 * acos(-1) * $C(angle,$e)) / 360.0]
  3263. # d est l'augmentation du rayon du cercle
  3264. set x [expr ($C(dx) + $d ) * cos($angrad)]
  3265. set y [expr ($C(dy) + $d ) * sin($angrad)]
  3266. set l $T($t,ctl,$e)
  3267. #set illtxt [concat " " [lindex $S(ill-car-fon) 0 ]]
  3268. #set illfon [lrange $S(ill-car-fon) 1 end]
  3269. set illtxt [concat " " $S(ill-car) ]
  3270. set illfon $S(ill-fon)
  3271. set item [$w create text [expr $x + $x1 + $C(dx)] [expr $y + $y1 + $C(dy)] \
  3272. -text $illtxt \
  3273. -anchor center -justify center \
  3274. -fill $S(col) \
  3275. -font $illfon \
  3276. -tags "ILLCo?$l T$t AnnotMatrix AM$t MA?$l $tagC AMatrixCo"]
  3277. $w raise $item
  3278. update
  3279. }
  3280. incr n
  3281. }
  3282. unset C
  3283. }
  3284. ###
  3285. # s est soit tab- soit tab+
  3286. # cette fonction permet d'inc?Šmenter (+) // d?Šcr?Šmenter (-)
  3287. # la variable de tabulation pour les arbres en target
  3288. # manuellement (afin de tab entre 2 series de requetes)
  3289. proc IllCTabulation {s} {
  3290. global S T
  3291. # A-list window/tree des arbres en target d'une session treedyn
  3292. foreach {w t} [Selection::TreeTar] {
  3293. switch -exact $s {
  3294. tab+ {
  3295. if [catch {expr $S($t,LabelMatrixBase) + $S(TabulationAnnot)} result] {
  3296. set S($t,LabelMatrixBase) $S(TabulationAnnot)
  3297. } else {
  3298. set S($t,LabelMatrixBase) $result
  3299. }
  3300. }
  3301. tab- {
  3302. if [catch {expr $S($t,LabelMatrixBase) - $S(TabulationAnnot)} result] {
  3303. # rien
  3304. } else {
  3305. set S($t,LabelMatrixBase) $result
  3306. }
  3307. }
  3308. }
  3309. }
  3310. }
  3311. proc IllCTabulationSet {s v} {
  3312. global S T
  3313. # A-list window/tree des arbres en target d'une session treedyn
  3314. foreach {w t} [Selection::TreeTar] {
  3315. switch -exact $s {
  3316. tab+ {
  3317. if [catch {expr $S($t,LabelMatrixBase) + $v} result] {
  3318. set S($t,LabelMatrixBase) $v
  3319. } else {
  3320. set S($t,LabelMatrixBase) $result
  3321. }
  3322. }
  3323. tab- {
  3324. if [catch {expr $S($t,LabelMatrixBase) - $v} result] {
  3325. # rien
  3326. } else {
  3327. set S($t,LabelMatrixBase) $result
  3328. }
  3329. }
  3330. tab= {
  3331. set S($t,LabelMatrixBase) $v
  3332. }
  3333. }
  3334. }
  3335. }
  3336. proc LillC360bis2 {w t leu} {
  3337. global S ann T
  3338. # cercle d'illustration fixer R le rayon du cercle d'illustration
  3339. # on peut fixer une valeur pour par ex. 200 + tabulation
  3340. # mais mieux de chercher une valeur adapt?Še ?  chaque
  3341. # arbre
  3342. # set R [expr 200 + $S($t,LabelMatrixBase)]
  3343. #set co [$w bbox [list L && T$t]]
  3344. set co [$w bbox [list Z && T$t]]
  3345. set x1 [lindex $co 0]
  3346. set y1 [lindex $co 1]
  3347. set x2 [lindex $co 2]
  3348. set y2 [lindex $co 3]
  3349. set Rx [expr double(($x2 - $x1) /2.0)]
  3350. set Ry [expr double(($y2 - $y1) /2.0)]
  3351. if {$Rx > $Ry} {
  3352. set R [expr $Rx + $S($t,LabelMatrixBase)]
  3353. } else {
  3354. set R [expr $Ry + $S($t,LabelMatrixBase)]
  3355. }
  3356. set a_ref [expr double(6.28318530717958 / [llength $T($t,ue_cod)])]
  3357. set n 0
  3358. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  3359. foreach e $T($t,ue_cod) {
  3360. set a [expr double($n*$a_ref)]
  3361. if {[lsearch $leu $T($t,ctl,$e)] != -1} {
  3362. set x [expr double($R * cos($a))]
  3363. set y [expr double($R * sin($a))]
  3364. set l $T($t,ctl,$e)
  3365. #set illtxt [concat " " [lindex $S(ill-car-fon) 0 ]]
  3366. #set illfon [lrange $S(ill-car-fon) 1 end]
  3367. set illtxt [concat " " $S(ill-car) ]
  3368. set illfon $S(ill-fon)
  3369. set item [$w create text $x $y \
  3370. -text $illtxt \
  3371. -anchor center -justify center \
  3372. -fill $S(col) \
  3373. -font $illfon \
  3374. -tags "ILLCo?$l AnnotMatrix AM$t MA?$l T$t $tagC AMatrixCo"]
  3375. }
  3376. incr n
  3377. }
  3378. # centrage sur arbre tags root "[format "%s%s" $t C] T$t Z"
  3379. set co [$w coords [format "%s%s" $t C]]
  3380. set x1 [lindex $co 0]
  3381. set y1 [lindex $co 1]
  3382. set x2 [lindex $co 2]
  3383. set y2 [lindex $co 3]
  3384. set xcenter [expr ($x1 + $x2) /2.0]
  3385. set ycenter [expr ($y1 + $y2) /2.0]
  3386. $w move $tagC $xcenter $ycenter
  3387. }
  3388. ###
  3389. proc LillC360bis {w t leu} {
  3390. global S ann T
  3391. #set f [expr double($R / $T($t,xmax))]
  3392. set d $S($t,LabelMatrixBase)
  3393. set co [$w bbox [list Z && T$t]]
  3394. set x1 [lindex $co 0]
  3395. set y1 [lindex $co 1]
  3396. set x2 [lindex $co 2]
  3397. set y2 [lindex $co 3]
  3398. set C(dx) [expr abs(($x2 - $x1)) /2.0]
  3399. set C(dy) [expr abs(($y2 - $y1)) /2.0]
  3400. # pb il y a 4 zones de dessin en dehors de l'oval : forme phycir, phyrad etc.
  3401. # on va donc toujours dessiner un cercle, on prend ds ce cas
  3402. # le plus grand cote, soit dx soit dy, et on corrige x et y
  3403. set delta [expr (abs($C(dx) - $C(dy))) / 2.0]
  3404. if {[expr abs($x2 - $x1)] < [expr abs($y2 - $y1)]} {
  3405. # update des x
  3406. set x1 [expr $x1 - $delta]
  3407. set x2 [expr $x2 + $delta]
  3408. # update dx
  3409. set C(dx) $C(dy)
  3410. } {
  3411. # update des y
  3412. set y1 [expr $y1 - $delta]
  3413. set y2 [expr $y2 + $delta]
  3414. # update dy
  3415. set C(dy) $C(dx)
  3416. }
  3417. $w create oval [expr $x1 -$d] [expr $y1 -$d] [expr $x2 +$d] [expr $y2 +$d] \
  3418. -tags "T$t" -outline grey80
  3419. $w create rectangle [expr $x1 -$d] [expr $y1 -$d] [expr $x2 +$d] [expr $y2 +$d] \
  3420. -tags "T$t" -outline grey80
  3421. set a_ref [expr 360.0/ [llength $T($t,ue_cod)]] ;# unit?Š d'angle
  3422. set n 0
  3423. foreach e $T($t,ue_cod) {
  3424. set C(angle,$e) [expr $n*$a_ref]
  3425. if { [lsearch $leu $T($t,ctl,$e)] != -1} {
  3426. # passer ?  l'egalit?Š nom de feuilles
  3427. # degres -> radians
  3428. set angrad [expr (2 * acos(-1) * $C(angle,$e)) / 360.0]
  3429. set x [expr ($C(dx) + $d ) * cos($angrad)]
  3430. set y [expr ($C(dy) + $d ) * sin($angrad)]
  3431. $w create oval [expr $x + $x1 + $C(dx) -2] [expr $y + $y1 + $C(dy) -2] \
  3432. [expr $x + $x1 + $C(dx) +2] [expr $y + $y1 + $C(dy) +2] \
  3433. -fill $S(col) -outline $S(col) \
  3434. -tags "T$t" \
  3435. }
  3436. incr n
  3437. }
  3438. unset C
  3439. }
  3440. ###
  3441. proc CreateShape {w shape x y} {
  3442. global S
  3443. set x [$w canvasx $x]
  3444. set y [$w canvasy $y]
  3445. set id [$w find closest $x $y]
  3446. set tags [$w gettags $id]
  3447. set t [string range [lindex $tags [lsearch -glob $tags T*]] 1 end]
  3448. if {$t != ""} {
  3449. switch -exact $shape {
  3450. line {
  3451. $w create $shape $x $y $x $y \
  3452. -fill $S(col) -width 1 -tags "rubbershape DRAW T$t"
  3453. }
  3454. rectangle - oval {
  3455. $w create $shape $x $y $x $y \
  3456. -fill $S(col) -width 1 -tags "rubbershape DRAW T$t"
  3457. }
  3458. }
  3459. }
  3460. }
  3461. #
  3462. proc CreateShapeFill {w shape x y} {
  3463. global S
  3464. set x [$w canvasx $x]
  3465. set y [$w canvasy $y]
  3466. set id [$w find closest $x $y]
  3467. set tags [$w gettags $id]
  3468. set t [string range [lindex $tags [lsearch -glob $tags T*]] 1 end]
  3469. if {$t != ""} {
  3470. switch -exact $shape {
  3471. line {
  3472. $w create $shape $x $y $x $y \
  3473. -outline $S(col) -width 1 -tags "rubbershape DRAW T$t"
  3474. }
  3475. rectangle - oval {
  3476. $w create $shape $x $y $x $y \
  3477. -outline $S(col) -width 1 -tags "rubbershape DRAW T$t"
  3478. }
  3479. }
  3480. }
  3481. }
  3482. ###
  3483. proc DragShape {w x y} {
  3484. set x [$w canvasx $x]
  3485. set y [$w canvasy $y]
  3486. set coords [$w coords "rubbershape"]
  3487. set coords [lreplace $coords 2 3 $x $y]
  3488. eval $w coords "rubbershape" $coords
  3489. }
  3490. ###
  3491. proc EndShape {w x y} {
  3492. DragShape $w $x $y
  3493. $w dtag "rubbershape"
  3494. }
  3495. }
  3496. ####################
  3497. ####################
  3498. # IMPORT EXPORT
  3499. ####################
  3500. namespace eval ImportExport {
  3501. proc NewickParser_Root {t s} {
  3502. global T S
  3503. set code $t
  3504. set n 0
  3505. set sx 0
  3506. #
  3507. set T($t,xmax) 0
  3508. set T($t,tot) 0
  3509. set T($t,all_cod) $code
  3510. set T($t,dbv,$code) 0
  3511. set T($t,dbl,$code) 0
  3512. set T($t,nwk,$code) $s
  3513. set tp [string last ")" $s]
  3514. set dt [string range $s 0 $tp]
  3515. set dx [string range $s [expr $tp + 1] end]
  3516. set id [BgBdx $dt]
  3517. set bg [string range $dt [expr $id + 1] [expr [string length $dt] - 2]]
  3518. set bd [string range $dt 1 [expr $id - 1]]
  3519. lappend T($t,cbg,$n) $n
  3520. NewickParser2 $t $bg [format "%s%s" $code g] [expr $n + 1] $sx
  3521. NewickParser2 $t $bd [format "%s%s" $code d] [expr $n + 1] $sx
  3522. }
  3523. ###
  3524. proc BgBdx {s} {
  3525. set i -1
  3526. set id -1
  3527. foreach c [split $s {}] {
  3528. incr id
  3529. switch -exact -- $c {
  3530. ( {incr i}
  3531. ) {incr i -1}
  3532. , {if {$i == 0} {return $id}}
  3533. }
  3534. }
  3535. return ""
  3536. }
  3537. ###
  3538. proc NewickParser2 {t s code n sx} {
  3539. global T S
  3540. lappend T($t,all_cod) $code
  3541. set T($t,nwk,$code) $s
  3542. if {[string match *,* $s]} {
  3543. ######
  3544. if {[TDcom::Dicho $s] == 1} {
  3545. set s [format "%s%s%s" ( $s ):0]
  3546. }
  3547. ######
  3548. set tp [string last ")" $s]
  3549. set dt [string range $s 0 $tp]
  3550. set dx [string range $s [expr $tp + 1] end]
  3551. set T($t,dbl,$code) [string range $dx [expr [string last ":" $dx] + 1] end]
  3552. set T($t,dbv,$code) [string range $dx 0 [expr [string last ":" $dx] - 1]]
  3553. ######
  3554. if {[string compare [string range $dt 0 0] ( ] != 0 || \
  3555. [string compare [string range $dt end end] ) ] != 0} {
  3556. set dt [format "%s%s%s" ( $dt )]
  3557. }
  3558. set id [BgBdx $dt]
  3559. set bg [string range $dt [expr $id + 1] [expr [string length $dt] - 2]]
  3560. set bd [string range $dt 1 [expr $id - 1]]
  3561. lappend T($t,cbg,$n) [format "%s%s" $code $n]
  3562. NewickParser2 $t $bg [format "%s%s%s" $code $n g] [expr $n +1] [expr $sx + $T($t,dbl,$code)]
  3563. NewickParser2 $t $bd [format "%s%s%s" $code $n d] [expr $n +1] [expr $sx + $T($t,dbl,$code)]
  3564. } { set tp [string last ":" $s]
  3565. set dt [string range $s 0 [expr $tp - 1]]
  3566. set dx [string range $s [expr $tp + 1] end]
  3567. set T($t,dbl,$code) [string range $dx [expr [string last ":" $dx] + 1] end]
  3568. set T($t,ctl,$code) $dt
  3569. set T($t,ltc,$dt) $code
  3570. lappend T($t,ue_cod) $code
  3571. lappend T($t,ue_lab) $dt
  3572. set sx [expr $sx + $dx]
  3573. set T($t,sox,$code) $sx
  3574. if {$sx >= $T($t,xmax)} {set T($t,xmax) $sx}
  3575. if {$n >= $T($t,tot)} {set T($t,tot) $n}
  3576. return
  3577. }
  3578. }
  3579. ###
  3580. proc UpdateArrayCanvas {w t} {
  3581. global T S B
  3582. ### canvas
  3583. $w delete T$t
  3584. ### array T
  3585. foreach {key value} [array get T $t,*] {
  3586. unset T($key)
  3587. }
  3588. ### array S
  3589. foreach {key value} [array get S $t,*] {
  3590. unset S($key)
  3591. }
  3592. # array B/BLL
  3593. foreach bll $B($t,bll) {
  3594. foreach key [array names B *,$bll] {
  3595. unset B($key)
  3596. }
  3597. }
  3598. unset B($t,bll)
  3599. # array B/SHI
  3600. foreach shi $B($t,shi) {
  3601. foreach key [array names B *,$shi] {
  3602. unset B($key)
  3603. }
  3604. }
  3605. unset B($t,shi)
  3606. #array B/ OVA
  3607. foreach ova $B($t,ova) {
  3608. foreach key [array names B *,$ova] {
  3609. unset B($key)
  3610. }
  3611. }
  3612. #array B/ QYN
  3613. unset B($t,ova)
  3614. foreach qyn $B($t,qyn) {
  3615. foreach key [array names B *,$qyn] {
  3616. unset B($key)
  3617. }
  3618. }
  3619. unset B($t,qyn)
  3620. #mise a jour la liste des tree S(ilt)
  3621. set index [lsearch -exact $S(ilt) $t]
  3622. set S(ilt) [concat [lrange $S(ilt) 0 [expr $index - 1]] \
  3623. [lrange $S(ilt) [expr $index + 1] end]]
  3624. #mise a jour la liste des tree S(w,t)
  3625. set index [lsearch -exact $S($w,t) $t]
  3626. set S($w,t) [concat [lrange $S($w,t) 0 [expr $index - 1]] \
  3627. [lrange $S($w,t) [expr $index + 1] end]]
  3628. }
  3629. }
  3630. ####################
  3631. ####################
  3632. # NAVIGATION
  3633. ####################
  3634. namespace eval Navigation {
  3635. ### FitToContents
  3636. proc FitToContents {w} {
  3637. global S
  3638. $w configure -scrollregion [$w bbox all]
  3639. }
  3640. ### FitToWindow
  3641. proc FitToWindow {w t} {
  3642. global S T
  3643. foreach {x0 y0 x1 y1} [$w bbox all] {}
  3644. set widw [winfo width $w]
  3645. set heiw [winfo height $w]
  3646. set fx [expr abs($widw. /[expr $x1 - $x0])]
  3647. set fy [expr abs($heiw. /[expr $y1 - $y0])]
  3648. $w scale T$t 0 0 $fx $fy
  3649. $w configure -scrollregion [$w bbox all]
  3650. }
  3651. proc deleteDocumentAnnotationL {w} {
  3652. global S
  3653. foreach t $S($w,t) {$w delete AM$t}
  3654. }
  3655. proc deleteDocumentAnnotationN {w} {
  3656. global S
  3657. foreach t $S($w,t) {Interface::D3ActionTree $w $t removeallannotation}
  3658. }
  3659. proc resetDocumentVar {w v} {
  3660. global S
  3661. foreach ti $S($w,t) {
  3662. switch $v {
  3663. tbg {Figuration::GraVarInitBgSubTree $w $ti}
  3664. tfg {Figuration::GraVarInitFgTree $w $ti}
  3665. tlw {Figuration::GraVarInitLineWidth $w $ti}
  3666. tld {Figuration::GraVarInitLineDash $w $ti}
  3667. t {
  3668. Figuration::GraVarInitBgSubTree $w $ti
  3669. Figuration::GraVarInitFgTree $w $ti
  3670. Figuration::GraVarInitLineWidth $w $ti
  3671. Figuration::GraVarInitLineDash $w $ti
  3672. }
  3673. lbg {Figuration::GraVarInitBgLeaf $w $ti}
  3674. lfg {Figuration::GraVarInitFgLeaf $w $ti}
  3675. lfo {Figuration::GraVarInitFont $w $ti}
  3676. l {
  3677. Figuration::GraVarInitBgLeaf $w $ti
  3678. Figuration::GraVarInitFgLeaf $w $ti
  3679. Figuration::GraVarInitFont $w $ti
  3680. }
  3681. tl {
  3682. Figuration::GraVarInitBgSubTree $w $ti
  3683. Figuration::GraVarInitFgTree $w $ti
  3684. Figuration::GraVarInitLineWidth $w $ti
  3685. Figuration::GraVarInitLineDash $w $ti
  3686. Figuration::GraVarInitBgLeaf $w $ti
  3687. Figuration::GraVarInitFgLeaf $w $ti
  3688. Figuration::GraVarInitFont $w $ti
  3689. }
  3690. }
  3691. }
  3692. }
  3693. proc resetTreeVar {w ti v} {
  3694. global S
  3695. switch $v {
  3696. tbg {Figuration::GraVarInitBgSubTree $w $ti}
  3697. tfg {Figuration::GraVarInitFgTree $w $ti}
  3698. tlw {Figuration::GraVarInitLineWidth $w $ti}
  3699. tld {Figuration::GraVarInitLineDash $w $ti}
  3700. t {
  3701. Figuration::GraVarInitBgSubTree $w $ti
  3702. Figuration::GraVarInitFgTree $w $ti
  3703. Figuration::GraVarInitLineWidth $w $ti
  3704. Figuration::GraVarInitLineDash $w $ti
  3705. }
  3706. lbg {Figuration::GraVarInitBgLeaf $w $ti}
  3707. lfg {Figuration::GraVarInitFgLeaf $w $ti}
  3708. lfo {Figuration::GraVarInitFont $w $ti}
  3709. l {
  3710. Figuration::GraVarInitBgLeaf $w $ti
  3711. Figuration::GraVarInitFgLeaf $w $ti
  3712. Figuration::GraVarInitFont $w $ti
  3713. }
  3714. tl {
  3715. Figuration::GraVarInitBgSubTree $w $ti
  3716. Figuration::GraVarInitFgTree $w $ti
  3717. Figuration::GraVarInitLineWidth $w $ti
  3718. Figuration::GraVarInitLineDash $w $ti
  3719. Figuration::GraVarInitBgLeaf $w $ti
  3720. Figuration::GraVarInitFgLeaf $w $ti
  3721. Figuration::GraVarInitFont $w $ti
  3722. }
  3723. }
  3724. }
  3725. proc resetNodeVar {w ti n v} {
  3726. global S
  3727. switch $v {
  3728. tbg {Figuration::GraVarInitBgSubTree $w $ti $n}
  3729. tfg {Figuration::GraVarInitFgTree $w $ti $n}
  3730. tlw {Figuration::GraVarInitLineWidth $w $ti $n}
  3731. tld {Figuration::GraVarInitLineDash $w $ti $n}
  3732. t {
  3733. Figuration::GraVarInitBgSubTree $w $ti $n
  3734. Figuration::GraVarInitFgTree $w $ti $n
  3735. Figuration::GraVarInitLineWidth $w $ti $n
  3736. Figuration::GraVarInitLineDash $w $ti $n
  3737. }
  3738. lbg {Figuration::GraVarInitBgLeaf $w $ti $n}
  3739. lfg {Figuration::GraVarInitFgLeaf $w $ti $n}
  3740. lfo {Figuration::GraVarInitFont $w $ti $n}
  3741. l {
  3742. Figuration::GraVarInitBgLeaf $w $ti $n
  3743. Figuration::GraVarInitFgLeaf $w $ti $n
  3744. Figuration::GraVarInitFont $w $ti $n
  3745. }
  3746. tl {
  3747. Figuration::GraVarInitBgSubTree $w $ti $n
  3748. Figuration::GraVarInitFgTree $w $ti $n
  3749. Figuration::GraVarInitLineWidth $w $ti $n
  3750. Figuration::GraVarInitLineDash $w $ti $n
  3751. Figuration::GraVarInitBgLeaf $w $ti $n
  3752. Figuration::GraVarInitFgLeaf $w $ti $n
  3753. Figuration::GraVarInitFont $w $ti $n
  3754. }
  3755. }
  3756. }
  3757. #
  3758. proc CoPaCollectionCreateInsert {w t n} {
  3759. global S T
  3760. # si aucune collection
  3761. # le [Tools::GenId] est l'ID de la collection
  3762. set IDcollection [Tools::GenId]
  3763. # S(collection) est la liste des ID collections
  3764. lappend S(collection) $IDcollection
  3765. # creation de la fenetre de collection
  3766. set collection [ImportExport::NewCanvas]
  3767. #chaque ID collection reference la path window correspondant
  3768. set S(collection,$IDcollection) $collection
  3769. # ...final, copy paste
  3770. Navigation::CoPaCollectionInsert $w $t $n $IDcollection
  3771. }
  3772. #
  3773. proc CoPaCollectionInsert {wsource tsource nodesource IDcollection} {
  3774. global S T
  3775. set wtarget $S(collection,$IDcollection)
  3776. set t [expr [lrange [lsort -integer -increasing $S(ilt)] end end] + 1]
  3777. lappend S(ilt) $t
  3778. lappend S($wtarget,t) $t
  3779. set code $t
  3780. set data $T($tsource,nwk,$nodesource)
  3781. set T($t,nwk) $data
  3782. ImportExport::TreeInit $t
  3783. if {[catch [ImportExport::NewickParser_Root $t $data] result] != 0} {
  3784. ImportExport::CleanArrayTree $t
  3785. } else {
  3786. set T($t,xmax) $T($tsource,xmax)
  3787. set S($t,w) $wtarget
  3788. set S($t,tit) -
  3789. set S($t,type) $S($tsource,type)
  3790. Conformation::ArrToCanType2 $t $wtarget
  3791. ImportExport::NodeBind $wtarget $t
  3792. Figuration::TransitionVG $wtarget $tsource $nodesource $t
  3793. Figuration::RestaureT $wtarget $t
  3794. Operation::TreeViewerPanelUpdate
  3795. }
  3796. }
  3797. # organisation des arbres d'un canvas en rows columns
  3798. proc Reorganize {w {c ?} {r ?}} {
  3799. global S
  3800. set heMAX 0
  3801. set wiMAX 0
  3802. if {$S($w,BIcol) == "?"} {set S($w,BIcol) 3}
  3803. if {$S($w,BIrow) == "?"} {set S($w,BIrow) [expr round(0.5 + ([llength $S($w,t)]/3))] }
  3804. if {$c == "?"} { set c $S($w,BIcol)}
  3805. if {$r == "?"} { set r $S($w,BIrow)}
  3806. #
  3807. foreach ti $S($w,t) {
  3808. # NON [$w bbox [list Z && T$ti]] (prise en compte taille des feuilles)
  3809. set coords [$w bbox T$ti]
  3810. set wi [expr abs([lindex $coords 0] - [lindex $coords 2])]
  3811. if {$wi >= $wiMAX} {set wiMAX $wi}
  3812. set he [expr abs([lindex $coords 1] - [lindex $coords 3])]
  3813. if {$he >= $heMAX} {set heMAX $he}
  3814. }
  3815. set n [llength $S($w,t)]
  3816. set index -1
  3817. for {set i 0} {$i < $r} {incr i} {
  3818. for {set j 0} {$j < $c} {incr j} {
  3819. incr index
  3820. if {$index < $n} {
  3821. set ti [lindex $S($w,t) $index]
  3822. # attention le move ajoute, donc remettre a zero avant
  3823. set coords [$w bbox T$ti]
  3824. set x [lindex $coords 0]
  3825. set y [lindex $coords 1]
  3826. $w move T$ti [expr 0 - $x] [expr 0 - $y]
  3827. set px [expr $j * $wiMAX]
  3828. set py [expr $i * $heMAX]
  3829. $w move T$ti $px $py
  3830. }
  3831. }
  3832. }
  3833. Navigation::FitToContents $w
  3834. }
  3835. # proc associ?Še a un return sur les entry hauteur/largeur , main panel, onglet navigation
  3836. proc ResizeAuto {} {
  3837. # retourne la A-liste $windows $tree pour tous les tree en target d'une session treedyn
  3838. set Alist [Selection::TreeTar]
  3839. foreach {wi ti} $Alist {
  3840. Navigation::ResizeOneGo $wi $ti
  3841. Figuration::RestaureT $wi $ti
  3842. }
  3843. }
  3844. #
  3845. proc ResizeOneGo {w t} {
  3846. global S
  3847. set co [$w bbox T$t]
  3848. set x [lindex $co 0]
  3849. set y [lindex $co 1]
  3850. Conformation::ArrToCanType3 $t $w $x $y $S(newW) $S(newH)
  3851. Figuration::RestaureT $w $t
  3852. }
  3853. }
  3854. ####################
  3855. ####################
  3856. # ANNOTATION
  3857. ####################
  3858. namespace eval Annotation {
  3859. #
  3860. proc HTTPPanel {} {
  3861. global S
  3862. set S(httpref) ?
  3863. toplevel .annothttp
  3864. wm title .annothttp {W3}
  3865. # frame control
  3866. set f [frame .annothttp.control ]
  3867. #
  3868. # boxlist url
  3869. iwidgets::combobox $f.combourl -width 12 -labeltext "URL:"
  3870. foreach e [list "http://pbil.univ-lyon1.fr/cgi-bin/acnuc-search-ac?query="] {
  3871. $f.combourl insert list end $e
  3872. }
  3873. $f.combourl selection set "http://pbil.univ-lyon1.fr/cgi-bin/acnuc-search-ac?query="
  3874. # Entry reference gene/pr etc
  3875. iwidgets::entryfield $f.ref -textvariable S(httpref) -labeltext "Ref:" -command Annotation::AnnotHttp2
  3876. # boxlist database
  3877. iwidgets::combobox $f.combo -labeltext "Database:" -selectioncommand Annotation::AnnotHttp2
  3878. foreach e [list GenBank EMBL EMGLib NRSub SwissProt NBRF "Hobacgen nucl." \
  3879. "Hobacgen prot." "Hovergen nucl." "Hovergen prot." "RTKdb nucl." "RTKdb prot." \
  3880. "HoGenome nucl." "HoGenome prot." "Hovergen Clean nucl." "Hovergen Clean prot." \
  3881. "HAMAP nucl." "HAMAP prot." "MitALib prot." "MitALib nucl." "Hoppsigen Nurebase nucl." \
  3882. "Nurebase prot." "TestForm prot." "TestForm nucl."] {
  3883. $f.combo insert list end $e
  3884. }
  3885. $f.combo selection set GenBank
  3886. # browser
  3887. set htm [optcl::new -window .annothttp.htm Shell.Explorer.2] ;# MSIE ActiveX Control
  3888. set S(navigator) $htm
  3889. .annothttp.htm config -width 500 -height 400
  3890. #
  3891. grid $f.combourl -row 0 -column 0 -columnspan 2 -sticky news
  3892. grid $f.combo -row 1 -column 0 -sticky news
  3893. grid $f.ref -row 1 -column 1 -sticky news
  3894. grid $f -row 0 -column 0 -sticky news
  3895. grid .annothttp.htm -row 1 -column 0 -sticky news
  3896. grid rowconfigure .annothttp 1 -weight 1
  3897. grid columnconfigure .annothttp 0 -weight 1
  3898. }
  3899. #
  3900. proc AnnotHttp {w x y} {
  3901. global S T
  3902. set unit [$w itemcget current -text]
  3903. if {$unit != ""} {
  3904. if {[winfo exists .annothttp] == 0 } {HTTPPanel}
  3905. set S(httpref) $unit
  3906. set url [.annothttp.control.combourl getcurselection]
  3907. append url $unit
  3908. append url "&db="
  3909. append url [.annothttp.control.combo getcurselection]
  3910. $S(navigator) navigate $url
  3911. }
  3912. }
  3913. #
  3914. proc AnnotHttp2 {} {
  3915. global S T
  3916. set unit $S(httpref)
  3917. if {$unit != "" && $unit != "?"} {
  3918. if {[winfo exists .annothttp] == 0 } {HTTPPanel}
  3919. set url [.annothttp.control.combourl getcurselection]
  3920. append url $unit
  3921. append url "&db="
  3922. append url [.annothttp.control.combo getcurselection]
  3923. $S(navigator) navigate $url
  3924. }
  3925. }
  3926. #
  3927. # .ann.l.lfa.l
  3928. proc MatrixAnnotateGo {} {
  3929. global S ann T
  3930. set lv {}
  3931. set lindex [.ann.l.lfa.l curselection]
  3932. foreach i $lindex {
  3933. lappend lv [.ann.l.lfa.l get $i]
  3934. }
  3935. set lkv [array get S *,tar]
  3936. set ltreetarget {}
  3937. foreach {k v} $lkv {
  3938. if {$S($k) == 1} {
  3939. lappend ltreetarget [string range $k 0 [expr [string first , $k] - 1]]
  3940. }
  3941. }
  3942. MatrixAnnotateGoGo $lv $ltreetarget
  3943. }
  3944. proc MatrixColorsAnnotateGo {} {
  3945. global S ann T
  3946. set lv {}
  3947. set lindex [.ann.l.lfa.l curselection]
  3948. foreach i $lindex {
  3949. lappend lv [.ann.l.lfa.l get $i]
  3950. }
  3951. set lkv [array get S *,tar]
  3952. set ltreetarget {}
  3953. foreach {k v} $lkv {
  3954. if {$S($k) == 1} {
  3955. lappend ltreetarget [string range $k 0 [expr [string first , $k] - 1]]
  3956. }
  3957. }
  3958. MatrixColorsAnnotateGoGo $lv $ltreetarget
  3959. }
  3960. #
  3961. proc MatrixAnnotateGoGo {lv ltreetarget} {
  3962. global S ann T
  3963. foreach ti $ltreetarget {
  3964. set w $S($ti,w)
  3965. set XMAX1 [lindex [$w bbox [list T$ti && Z]] 2]
  3966. set XMAX2 [lindex [$w bbox [list T$ti && L]] 2]
  3967. set XMAX3 [lindex [$w bbox [list T$ti && AnnotMatrix]] 2]
  3968. if {$XMAX1 < $XMAX2} {set XMAX $XMAX2 } {set XMAX $XMAX1}
  3969. if {$XMAX < $XMAX3} {set XMAX $XMAX3 }
  3970. if [catch {expr $S($ti,LabelMatrixBase) + 7} result] {
  3971. set S($ti,LabelMatrixBase) 7
  3972. } else {
  3973. set S($ti,LabelMatrixBase) $result
  3974. }
  3975. #set XMAX1 [lindex [$w bbox [list T$ti && Z]] 2]
  3976. #set XMAX2 [lindex [$w bbox [list T$ti && L]] 2]
  3977. #if {$XMAX1 < $XMAX2} {set XMAX $XMAX2 } {set XMAX $XMAX1}
  3978. switch -exact $S($ti,type) {
  3979. PhyNJ - ClaSla - ClaRec {
  3980. set database $S(database)
  3981. upvar #0 $S(database) X
  3982. set x [expr $XMAX + $S($ti,LabelMatrixBase)]
  3983. set colnumber 0
  3984. foreach var $lv {
  3985. incr colnumber 1
  3986. incr x $ann(binmatPadding)
  3987. set dx [expr $ann(binmatWidth) / 2]
  3988. set dy [expr $ann(binmatHeight) / 2]
  3989. # tag de colonne
  3990. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  3991. if {$ann(binmatColumnsNumber) == 1} {
  3992. set spliNB 0
  3993. foreach lettre [split $colnumber {}] {
  3994. set ycolumns [lindex [$w bbox [list T$ti && Z]] 1]
  3995. $w create text $x [expr $ycolumns - 10 - $spliNB] -text $lettre \
  3996. -fill black -tags "T$ti AnnotMatrix"
  3997. incr spliNB 8
  3998. }
  3999. }
  4000. foreach l $T($ti,ue_lab) {
  4001. # recherche y
  4002. set item [$w find withtag [list [format "%s%s" EUL $l ] && T$ti]]
  4003. if {$item == ""} {
  4004. set items [$w find withtag [list ADD?$l && T$ti]]
  4005. set y 0
  4006. foreach ii $items {
  4007. set yii [lindex [$w coords $ii] 1]
  4008. if {$yii >= $y} {
  4009. set y $yii
  4010. }
  4011. }
  4012. } else {
  4013. set co [$w coords $item]
  4014. set y [lindex $co 1]
  4015. }
  4016. # construction de itemtext sur query
  4017. # attention si des feuilles ds l'arbre mais absentes du fichier de labels !
  4018. set record [Database::dbQueryRecordsFromVarVal $database EU $l]
  4019. set itemtext ""
  4020. if {$record == {}} {
  4021. set itemtext "-"
  4022. } else {
  4023. foreach ri $record {
  4024. foreach {vari val} $X($ri) {
  4025. if {[string equal $var $vari] == 1} {
  4026. if {$val == "1"} {
  4027. set color $ann(binmatColor1)
  4028. } else {
  4029. set color $ann(binmatColor0)
  4030. }
  4031. }
  4032. }
  4033. }
  4034. # coordonnees
  4035. if {$ann(binmatOutline) == 0} {
  4036. $w create rectangle [expr $x-$dx] [expr $y-$dy] [expr $x+$dx] [expr $y+$dy] \
  4037. -fill $color -outline $color \
  4038. -tags "T$ti AnnotMatrix AM$ti MA?$l $tagC AMatrixCo NBC$colnumber"
  4039. } else {
  4040. $w create rectangle [expr $x-$dx] [expr $y-$dy] [expr $x+$dx] [expr $y+$dy] \
  4041. -fill $color -outline black \
  4042. -tags "T$ti AnnotMatrix AM$ti MA?$l $tagC AMatrixCo NBC$colnumber"
  4043. }
  4044. }
  4045. }
  4046. }
  4047. Navigation::FitToContents $w
  4048. }
  4049. PhyRad - PhyCir1 - PhyCir2 - ClaRad {
  4050. # A FAIRE
  4051. }
  4052. ClaCir1 - ClaCir2 - ClaCir3 {
  4053. # A FAIRE
  4054. }
  4055. }
  4056. }
  4057. }
  4058. #
  4059. proc MatrixColorsAnnotateGoGo {lv ltreetarget} {
  4060. global S ann T
  4061. foreach ti $ltreetarget {
  4062. set w $S($ti,w)
  4063. set XMAX1 [lindex [$w bbox [list T$ti && Z]] 2]
  4064. set XMAX2 [lindex [$w bbox [list T$ti && L]] 2]
  4065. set XMAX3 [lindex [$w bbox [list T$ti && AnnotMatrix]] 2]
  4066. if {$XMAX1 < $XMAX2} {set XMAX $XMAX2 } {set XMAX $XMAX1}
  4067. if {$XMAX < $XMAX3} {set XMAX $XMAX3 }
  4068. if [catch {expr $S($ti,LabelMatrixBase) + 7} result] {
  4069. set S($ti,LabelMatrixBase) 7
  4070. } else {
  4071. set S($ti,LabelMatrixBase) $result
  4072. }
  4073. #set XMAX1 [lindex [$w bbox [list T$ti && Z]] 2]
  4074. #set XMAX2 [lindex [$w bbox [list T$ti && L]] 2]
  4075. #if {$XMAX1 < $XMAX2} {set XMAX $XMAX2 } {set XMAX $XMAX1}
  4076. switch -exact $S($ti,type) {
  4077. PhyNJ - ClaSla - ClaRec {
  4078. set database $S(database)
  4079. upvar #0 $S(database) X
  4080. set x [expr $XMAX + $S($ti,LabelMatrixBase)]
  4081. set colnumber 0
  4082. foreach var $lv {
  4083. incr colnumber 1
  4084. incr x $ann(binmatPadding)
  4085. set dx [expr $ann(binmatWidth) / 2]
  4086. set dy [expr $ann(binmatHeight) / 2]
  4087. # tag de colonne
  4088. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  4089. if {$ann(binmatColumnsNumber) == 1} {
  4090. set spliNB 0
  4091. foreach lettre [split $colnumber {}] {
  4092. set ycolumns [lindex [$w bbox [list T$ti && Z]] 1]
  4093. $w create text $x [expr $ycolumns - 10 - $spliNB] -text $lettre \
  4094. -fill black -tags "T$ti AnnotMatrix"
  4095. incr spliNB 8
  4096. }
  4097. }
  4098. foreach l $T($ti,ue_lab) {
  4099. # recherche y
  4100. set item [$w find withtag [list [format "%s%s" EUL $l ] && T$ti]]
  4101. if {$item == ""} {
  4102. set items [$w find withtag [list ADD?$l && T$ti]]
  4103. set y 0
  4104. foreach ii $items {
  4105. set yii [lindex [$w coords $ii] 1]
  4106. if {$yii >= $y} {
  4107. set y $yii
  4108. }
  4109. }
  4110. } else {
  4111. set co [$w coords $item]
  4112. set y [lindex $co 1]
  4113. }
  4114. # construction de itemtext sur query
  4115. # attention si des feuilles ds l'arbre mais absentes du fichier de labels !
  4116. set records [Database::dbQueryRecordsFromVarVal $database EU $l]
  4117. if {$records == {}} {
  4118. $w create text [expr $x-$dx+1] [expr $y-$dy+1] -text - \
  4119. -tags "T$ti AnnotMatrix AM$ti MA?$l $tagC AMatrixCo NBC$colnumber"
  4120. } elseif {[llength $records] >= 2} {
  4121. $w create text [expr $x-$dx+1] [expr $y-$dy+1] -text * \
  4122. -tags "T$ti AnnotMatrix AM$ti MA?$l $tagC AMatrixCo NBC$colnumber"
  4123. } else {
  4124. set record [lindex $records 0]
  4125. foreach {vari val} $X($record) {
  4126. if {[string equal $var $vari] == 1} {
  4127. set rgb [split $val ,]
  4128. set r [lindex $rgb 0]
  4129. set g [lindex $rgb 1]
  4130. set b [lindex $rgb 2]
  4131. puts RGB****$rgb
  4132. puts R***$r
  4133. puts G***$g
  4134. puts B***$b
  4135. set color [format "#%.2x%.2x%.2x" $r $g $b ]
  4136. puts color***$color
  4137. $w create rectangle [expr $x-$dx] [expr $y-$dy] [expr $x+$dx] [expr $y+$dy] \
  4138. -fill $color -outline $color \
  4139. -tags "T$ti AnnotMatrix AM$ti BIN?$$val MA?$l $tagC AMatrixCo NBC$colnumber"
  4140. }
  4141. }
  4142. }
  4143. }
  4144. }
  4145. Navigation::FitToContents $w
  4146. }
  4147. PhyRad - PhyCir1 - PhyCir2 - ClaRad {
  4148. # A FAIRE
  4149. }
  4150. ClaCir1 - ClaCir2 - ClaCir3 {
  4151. # A FAIRE
  4152. }
  4153. }
  4154. }
  4155. }
  4156. proc DrawAnnotateGo {} {
  4157. }
  4158. # ls : listbox source ; lt listbox target
  4159. proc AnnotateAddItem {ls lt} {
  4160. global S
  4161. if {$S(database) != ""} {
  4162. set lindexvariables [$ls curselection] ;# des index
  4163. foreach index $lindexvariables {
  4164. set variable [$ls get $index]
  4165. $ls itemconfigure $index -background NavajoWhite2
  4166. set lvalues [Database::dbQueryValFromVar $S(database) $variable]
  4167. foreach value [lsort -dictionary $lvalues] {
  4168. $lt insert end [format "%s%s%s%s%s" $value < $variable < $S(database)]
  4169. }
  4170. }
  4171. }
  4172. }
  4173. proc AnnotateQuit {} {
  4174. set choix [tk_messageBox -type okcancel -default ok \
  4175. -message "Exit Annotation Browser ?" -icon question]
  4176. if {$choix == "ok"} {
  4177. eval destroy .annotation
  4178. }
  4179. }
  4180. #
  4181. proc AnnotateLabelsFileSwitch {m} {
  4182. global S
  4183. set select [$m get]
  4184. switch -exact $select {
  4185. "?" {puts Default}
  4186. default {set S(database) $select}
  4187. }
  4188. # mise a jour listbox des variables
  4189. set lvar [Database::dbQueryVarAll $S(database)]
  4190. # remplissage listbox
  4191. .annotation.p.pane0.childsite.n.canvas.notebook.cs.page1.cs.lfa.l delete 0 end
  4192. eval {.annotation.p.pane0.childsite.n.canvas.notebook.cs.page1.cs.lfa.l insert end} $lvar
  4193. }
  4194. #
  4195. proc SwitchCol0 {w} {
  4196. global S ann
  4197. $w configure -background $S(col)
  4198. set ann(binmatColor0) $S(col)
  4199. }
  4200. #
  4201. proc SwitchCol1 {w} {
  4202. global S ann
  4203. $w configure -background $S(col)
  4204. set ann(binmatColor1) $S(col)
  4205. }
  4206. #
  4207. proc ANmoveMatrix {w x y} {
  4208. global S
  4209. set id [$w find withtag current]
  4210. if {$id == ""} {set id [$w find closest $x $y]}
  4211. if {$id != ""} {
  4212. set S(mox) $x
  4213. set S(moy) $y
  4214. set tags [$w gettags $id]
  4215. if {[lsearch -exact $tags AnnotMatrix] != -1} {
  4216. # motion sur AM$t
  4217. set i [lindex $tags [lsearch -glob $tags T*]]
  4218. set t [string range $i 1 end]
  4219. bind movematrix <B1-Motion> "Annotation::ANmoveMotion %W %x %y AM$t"
  4220. }
  4221. }
  4222. }
  4223. #
  4224. proc ANmoveCOL {w x y} {
  4225. global S
  4226. set id [$w find withtag current]
  4227. if {$id == ""} {set id [$w find closest $x $y]}
  4228. if {$id != ""} {
  4229. set S(mox) $x
  4230. set S(moy) $y
  4231. set tags [$w gettags $id]
  4232. if {[lsearch -exact $tags AnnotMatrix] != -1} {
  4233. set tag [lindex $tags [lsearch -glob $tags COL?*]]
  4234. bind movecol <B1-Motion> "Annotation::ANmoveMotion %W %x %y $tag"
  4235. }
  4236. }
  4237. }
  4238. #
  4239. proc ANmoveMotion {w x y tag} {
  4240. global S T
  4241. $w move $tag [expr $x - $S(mox)] 0
  4242. #$w move $tag [expr $x - $S(mox)] [expr $y - $S(moy)]
  4243. set S(mox) $x
  4244. set S(moy) $y
  4245. }
  4246. proc ANannfgcol {w x y} {
  4247. global S
  4248. set id [$w find withtag current]
  4249. if {$id == ""} {set id [$w find closest $x $y]}
  4250. if {$id != ""} {
  4251. set tags [$w gettags $id]
  4252. if {[lsearch -exact $tags AnnotMatrix] != -1} {
  4253. set tag [lindex $tags [lsearch -glob $tags COL?*]]
  4254. $w itemconfigure $tag -fill $S(col)
  4255. }
  4256. }
  4257. }
  4258. proc ANannfgrow {w x y} {
  4259. global S
  4260. set id [$w find withtag current]
  4261. if {$id == ""} {set id [$w find closest $x $y]}
  4262. if {$id != ""} {
  4263. set tags [$w gettags $id]
  4264. if {[lsearch -exact $tags AnnotMatrix] != -1} {
  4265. set tag [lindex $tags [lsearch -glob $tags MA?*]]
  4266. catch {$w itemconfigure $tag -fill $S(col)}
  4267. }
  4268. }
  4269. }
  4270. proc ANannfocol {w x y} {
  4271. global S
  4272. set id [$w find withtag current]
  4273. if {$id == ""} {set id [$w find closest $x $y]}
  4274. if {$id != ""} {
  4275. if {[$w type $id] == "text"} {
  4276. set tags [$w gettags $id]
  4277. if {[lsearch -exact $tags AnnotMatrix] != -1} {
  4278. set tag [lindex $tags [lsearch -glob $tags COL?*]]
  4279. set li [$w find withtag $tag]
  4280. foreach i $li {
  4281. if {[$w type $i] == "text"} {
  4282. $w itemconfigure $i -font $S(gfo)}
  4283. }
  4284. }
  4285. }
  4286. }
  4287. }
  4288. proc ANannRowCol {w x y} {
  4289. global S
  4290. set id [$w find withtag current]
  4291. if {$id == ""} {set id [$w find closest $x $y]}
  4292. if {$id != ""} {
  4293. set tags [$w gettags $id]
  4294. if {[lsearch -exact $tags AnnotMatrix] != -1} {
  4295. set tag [lindex $tags [lsearch -glob $tags COL?*]]
  4296. set lid [$w find withtag $tag]
  4297. foreach i $lid {
  4298. set co [$w coords $i]
  4299. #set x [$w canvasx [lindex $co 0]] ; set y [$w canvasy [lindex $co 1]]
  4300. set x [lindex $co 0] ; set y [lindex $co 1]
  4301. set text [lindex [$w itemconfigure $i -text] end]
  4302. if {$text != "" && $text != " -"} {
  4303. set id [format "%s%s" 1 [Tools::GenId]]
  4304. set idtext [format "%s%s%s" anntext ? $id]
  4305. set idlink [format "%s%s%s" annlink ? $id]
  4306. set font [lindex [$w itemconfigure $i -font] end]
  4307. set color [lindex [$w itemconfigure $i -fill] end]
  4308. $w delete $i
  4309. regsub -all " " $text "\n" newtext
  4310. set newtext [string trimleft $newtext "\n"]
  4311. # -stipple @[file join + stipple $S(stipple)]
  4312. $w create oval [expr $x -3] [expr $y - 3] [expr $x + 3] [expr $y + 3] \
  4313. -fill black -outline black -tags $tags
  4314. $w create text [expr $x + 30 ] $y \
  4315. -text $newtext -anchor nw \
  4316. -tags "bullann $idtext $tags" -font $font -fill $color
  4317. #
  4318. $w create line $x $y [expr $x + 30 ] $y \
  4319. -width 1 -fill $color -tags "Link $idlink $tags"
  4320. } else {
  4321. $w delete i
  4322. }
  4323. }
  4324. }
  4325. }
  4326. $w bind bullann <Button-1> {Annotation::ANmovebullann %W %x %y}
  4327. }
  4328. proc ANmovebullann {w x y} {
  4329. global S
  4330. set id [$w find withtag current]
  4331. if {$id == ""} {set id [$w find closest $x $y]}
  4332. if {$id != ""} {
  4333. set S(mox) $x
  4334. set S(moy) $y
  4335. set tags [$w gettags $id]
  4336. if {[lsearch -exact $tags bullann] != -1} {
  4337. set tag [lindex $tags [lsearch -glob $tags anntext?*]]
  4338. $w bind bullann <B1-Motion> "Annotation::ANmotionbullann %W %x %y $tag"
  4339. }
  4340. }
  4341. }
  4342. #
  4343. proc ANmotionbullann {w x y tag} {
  4344. global S T
  4345. # move du text
  4346. $w move $tag [expr $x - $S(mox)] [expr $y - $S(moy)]
  4347. # delete et reconstruction du lien
  4348. set taglink [format "%s%s%s" annlink ? [string trimleft $tag anntext? ]]
  4349. set co [$w coords $taglink]
  4350. set xl [lindex $co 0] ; set yl [lindex $co 1]
  4351. set tags [$w gettags $taglink]
  4352. set color [lindex [$w itemconfigure $taglink -fill] end]
  4353. $w delete $taglink
  4354. set idc [$w create line $xl $yl [$w canvasx $x] [$w canvasy $y] \
  4355. -width 1 -fill $color -tags "Link $taglink $tags"]
  4356. $w lower $idc
  4357. # ok
  4358. set S(mox) $x
  4359. set S(moy) $y
  4360. }
  4361. proc ANannillcol {w x y} {
  4362. global S
  4363. set id [$w find withtag current]
  4364. if {$id == ""} {set id [$w find closest $x $y]}
  4365. if {$id != ""} {
  4366. set tags [$w gettags $id]
  4367. if {[lsearch -exact $tags AnnotMatrix] != -1} {
  4368. set tag [lindex $tags [lsearch -glob $tags COL?*]]
  4369. $w itemconfigure $tag -font $S(ill-fon)
  4370. }
  4371. }
  4372. }
  4373. proc ANannillcar {w x y} {
  4374. global S
  4375. set id [$w find withtag current]
  4376. if {$id == ""} {set id [$w find closest $x $y]}
  4377. if {$id != ""} {
  4378. set tags [$w gettags $id]
  4379. if {[lsearch -exact $tags AnnotMatrix] != -1} {
  4380. set tag [lindex $tags [lsearch -glob $tags COL?*]]
  4381. $w itemconfigure $tag -text $S(ill-car) -font $S(ill-fon)
  4382. }
  4383. }
  4384. }
  4385. proc ANannforow {w x y} {
  4386. global S
  4387. set id [$w find withtag current]
  4388. if {$id == ""} {set id [$w find closest $x $y]}
  4389. if {$id != ""} {
  4390. set tags [$w gettags $id]
  4391. if {[lsearch -exact $tags AnnotMatrix] != -1} {
  4392. set tag [lindex $tags [lsearch -glob $tags MA?*]]
  4393. $w itemconfigure $tag -font $S(gfo)
  4394. }
  4395. }
  4396. }
  4397. proc ANannanchw {w x y} {
  4398. global S
  4399. set id [$w find withtag current]
  4400. if {$id == ""} {set id [$w find closest $x $y]}
  4401. if {$id != ""} {
  4402. set tags [$w gettags $id]
  4403. if {[lsearch -exact $tags AnnotMatrix] != -1} {
  4404. set tag [lindex $tags [lsearch -glob $tags COL?*]]
  4405. $w itemconfigure $tag -anchor w
  4406. }
  4407. }
  4408. }
  4409. proc ANannanche {w x y} {
  4410. global S
  4411. set id [$w find withtag current]
  4412. if {$id == ""} {set id [$w find closest $x $y]}
  4413. if {$id != ""} {
  4414. set tags [$w gettags $id]
  4415. if {[lsearch -exact $tags AnnotMatrix] != -1} {
  4416. set tag [lindex $tags [lsearch -glob $tags COL?*]]
  4417. $w itemconfigure $tag -anchor e
  4418. }
  4419. }
  4420. }
  4421. #
  4422. proc AnnotationPanelUpdate {} {
  4423. global S
  4424. set m .ann.l.m
  4425. if {[winfo exists .ann] == "1"} {
  4426. $m delete 0 end
  4427. foreach lf $S(ldatabase) {$m insert end $lf}
  4428. $m select end
  4429. ANVariablesUpdate
  4430. }
  4431. }
  4432. #
  4433. proc ANLabelsFileSwitch {m} {
  4434. global S
  4435. set select [$m get]
  4436. switch -exact $select {
  4437. "?" {puts Default}
  4438. default {set S(database) $select}
  4439. }
  4440. ANVariablesUpdate
  4441. #pour l'instant
  4442. #.ann.l.lfb.l delete 0 end
  4443. }
  4444. # mise a jour liste des variables pour le fichier de label courant
  4445. proc ANVariablesUpdate {} {
  4446. global S
  4447. # liste des variables
  4448. set lvar [Database::dbQueryVarAll $S(database)]
  4449. # remplissage listbox
  4450. .ann.l.lfa.l delete 0 end
  4451. eval {.ann.l.lfa.l insert end} $lvar
  4452. # reconfiguration background des feuilles de la listbox
  4453. # pour celles deja en selection
  4454. # if {[.ann.l.lfb.l get 0 end] != {}} {ANConfigBg}
  4455. }
  4456. # config bg si deja en selection
  4457. proc ANConfigBg {} {
  4458. global S
  4459. set li {}
  4460. set lni {}
  4461. set lavailable [.ann.l.lfa.l get 0 end] ;# var available
  4462. set selectL [.ann.l.lfb.l get 0 end] ;# feuilles en selection
  4463. foreach e $lavailable {
  4464. set r [lsearch $selectL $e]
  4465. set index [lsearch $lavailable $e]
  4466. if {$r != -1} {
  4467. .ann.l.lfa.l itemconfigure $index -background NavajoWhite2
  4468. } else {
  4469. .ann.l.lfa.l itemconfigure $index -background LightGoldenrodYellow
  4470. }
  4471. }
  4472. }
  4473. #
  4474. proc ANaddVarMouse {listbox x y} {
  4475. global S abs
  4476. set leaf [$listbox get @$x,$y]
  4477. set selectL [.ann.l.lfb.l get 0 end]
  4478. if {[lsearch $selectL $leaf] == -1} {
  4479. .ann.l.lfb.l insert end $leaf
  4480. }
  4481. .ann.l.lfa.l selection clear @$x,$y
  4482. ANConfigBg
  4483. }
  4484. # boutton ajout de la selection leave available dans la liste selection
  4485. proc ANAddL {} {
  4486. global S abs
  4487. # mise a jour listbox fichiers selection
  4488. # on conserve l'ordre des groupes de selection
  4489. set li [.ann.l.lfa.l curselection] ;# des index
  4490. set lsel {}
  4491. foreach i $li {
  4492. lappend lsel [.ann.l.lfa.l get $i]
  4493. .ann.l.lfa.l itemconfigure $i -background NavajoWhite2
  4494. }
  4495. set lall2 [.ann.l.lfb.l get 0 end]
  4496. .ann.l.lfb.l delete 0 end
  4497. # c moche je sais
  4498. foreach e $lsel {
  4499. lappend lall2 $e
  4500. }
  4501. #
  4502. foreach e [Tools::DelRep $lall2] {
  4503. .ann.l.lfb.l insert 0 $e
  4504. }
  4505. # deselection des fichiers liste available
  4506. .ann.l.lfa.l selection clear 0 end
  4507. # update nb de tree total
  4508. }
  4509. #
  4510. proc ANRemL {} {
  4511. global abs
  4512. # attention retrait a partir de l'index le plus bat
  4513. # le delete remet a jour les index
  4514. set li [lsort -decreasing [.ann.l.lfb.l curselection]] ;# des index
  4515. foreach i $li {
  4516. .ann.l.lfb.l delete $i
  4517. }
  4518. # deselection des fichiers liste available
  4519. .ann.l.lfa.l selection clear 0 end
  4520. ANConfigBg
  4521. }
  4522. #
  4523. proc ANremVarMouse {listbox x y} {
  4524. global S abs
  4525. $listbox delete @$x,$y
  4526. ANConfigBg
  4527. }
  4528. # Query Leaves Annotation Mode Leave
  4529. proc qLannL {w t leu} {
  4530. global S ann T
  4531. # tag de colonne
  4532. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  4533. foreach l $leu {
  4534. set i [$w find withtag [list ADD?$l && T$t]]
  4535. if {$i == ""} {
  4536. set i [$w find withtag [list [format "%s%s" EU $l] && T$t]]
  4537. set co [$w coords $i]
  4538. set y [lindex $co 1]
  4539. set i2 [$w find withtag [list [format "%s%s" EUL $l] && T$t]]
  4540. if {[$w itemcget $i2 -state] == "hidden"} {
  4541. set x [lindex [$w bbox $i] 2]
  4542. } else {
  4543. set x [lindex [$w bbox $i2] 2]
  4544. }
  4545. } else {
  4546. set co [$w coords [lindex $i 0]]
  4547. set y [expr [lindex $co 1] + 6]
  4548. set x 0
  4549. foreach ii $i {
  4550. set xii [lindex [$w bbox $ii] 2]
  4551. if {$xii >= $x} {
  4552. set x $xii
  4553. }
  4554. }
  4555. }
  4556. #
  4557. if {$x != "" && $y != ""} {
  4558. if {$S(DisplayVOV) == 0} {set sss [lrange $S(query) 2 end]}
  4559. set lc [split $sss {}]
  4560. set nbc [llength $lc]
  4561. if {[expr $nbc / 2 * 2] == $nbc} {
  4562. set s $sss
  4563. } else {
  4564. set s " $sss"
  4565. }
  4566. $w create text $x $y -text $s \
  4567. -font $S(gfo) \
  4568. -fill $S(col) \
  4569. -anchor center -justify center \
  4570. -tags "ADD?$l T$t AnnotMatrix $tagC AM$t MA?$l" -anchor w
  4571. }
  4572. }
  4573. }
  4574. #
  4575. proc qLannC {w t leu} {
  4576. global S ann T
  4577. switch -exact $S($t,type) {
  4578. PhyNJ - ClaSla - ClaRec {
  4579. # recherche x
  4580. if {$S(illustration-tabulation) == 1} {
  4581. set XMAX1 [lindex [$w bbox [list T$t && Z]] 2]
  4582. set XMAX2 [lindex [$w bbox [list T$t && L]] 2]
  4583. set XMAX3 [lindex [$w bbox [list T$t && AnnotMatrix]] 2]
  4584. if {$XMAX1 < $XMAX2} {set XMAX $XMAX2 } {set XMAX $XMAX1}
  4585. if {$XMAX < $XMAX3} {set XMAX $XMAX3 }
  4586. set x [expr $XMAX + $S($t,LabelMatrixBase)]
  4587. } else {
  4588. set XMAX1 [lindex [$w bbox [list T$t && Z]] 2]
  4589. set XMAX2 [lindex [$w bbox [list T$t && L]] 2]
  4590. if {$XMAX1 < $XMAX2} {set XMAX $XMAX2 } {set XMAX $XMAX1}
  4591. set x [expr $XMAX + $S($t,LabelMatrixBase)]
  4592. }
  4593. # tag de colonne
  4594. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  4595. foreach l $leu {
  4596. # recherche y (code arrete terminale)
  4597. set item [$w find withtag [list [format "%s%s" EU $l ] && T$t]]
  4598. if {$item != ""} {
  4599. set co [$w coords $item]
  4600. set y [lindex $co 1]
  4601. # avoir un nombre pair de caractere pour bien centrer
  4602. # sinon on ajoute devant un espace
  4603. #if {$S(DisplayVOV) == 0} {set sss [lrange $S(query) 2 end]}
  4604. if {$S(DisplayVOV) == 0} {set sss $S(query)}
  4605. set lc [split $sss {}]
  4606. set nbc [llength $lc]
  4607. if {[expr $nbc / 2 * 2] == $nbc} {
  4608. set s $sss
  4609. } else {
  4610. set s " $sss"
  4611. }
  4612. $w create text $x $y \
  4613. -text $s \
  4614. -fill $S(col) \
  4615. -font $S(gfo) \
  4616. -anchor w -justify center \
  4617. -tags "T$t AnnotMatrix AM$t MA?$l $tagC AMatrixCo"
  4618. }
  4619. }
  4620. }
  4621. PhyRad - PhyCir1 - PhyCir2 - ClaRad {
  4622. qLannC360 $w $t $leu
  4623. }
  4624. ClaCir1 - ClaCir2 - ClaCir3 {
  4625. qLannC360 $w $t $leu
  4626. }
  4627. }
  4628. }
  4629. ###
  4630. proc qLannC360old {w t leu} {
  4631. global S ann T
  4632. #puts coucou
  4633. set d $S($t,LabelMatrixBase)
  4634. #set co [$w bbox [list Z && T$t]]
  4635. set co [$w bbox [list L && T$t]]
  4636. set x1 [lindex $co 0]
  4637. set y1 [lindex $co 1]
  4638. set x2 [lindex $co 2]
  4639. set y2 [lindex $co 3]
  4640. set C(dx) [expr abs(($x2 - $x1)) /2.0]
  4641. set C(dy) [expr abs(($y2 - $y1)) /2.0]
  4642. # test pour eviter l'oval
  4643. #if {$C(dx) >= $C(dy)} {set C(dy) $C(dx)} {set C(dx) $C(dy)}
  4644. set R [expr 200 + $S($t,LabelMatrixBase)]
  4645. set a_ref [expr 360.0/ [llength $T($t,ue_cod)]] ;# unit?Š d'angle
  4646. set n 0
  4647. # tag de colonne
  4648. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  4649. # inversion de la liste des eus
  4650. if { $S($t,type) == "ClaCir2"} {
  4651. set LLE {}
  4652. foreach e $T($t,ue_cod) {
  4653. set LLE [concat $e $LLE]
  4654. }
  4655. set n 1
  4656. } else {
  4657. set LLE $T($t,ue_cod)
  4658. }
  4659. # l?Šger d?Šcalage du a anchor/justify si l'annotation a un seul caractere
  4660. # on ajoute a l'avant un espace
  4661. foreach e $LLE {
  4662. set C(angle,$e) [expr $n*$a_ref]
  4663. if {[lsearch $leu $T($t,ctl,$e)] != -1} {
  4664. # degres -> radians
  4665. set angrad [expr (2 * acos(-1) * $C(angle,$e)) / 360.0]
  4666. # d est l'augmentation du rayon du cercle
  4667. set x [expr ($C(dx) + $d ) * cos($angrad)]
  4668. set y [expr ($C(dy) + $d ) * sin($angrad)]
  4669. set l $T($t,ctl,$e)
  4670. # query
  4671. if {$S(DisplayVOV) == 0} {set sss [lrange $S(query) 2 end]}
  4672. # avoir un nombre pair de caractere pour bien centrer
  4673. # sinon on ajoute devant un espace
  4674. set lc [split $sss {}]
  4675. set nbc [llength $lc]
  4676. if {[expr $nbc / 2 * 2] == $nbc} {
  4677. set s $sss
  4678. } else {
  4679. set s " $sss"
  4680. }
  4681. $w create text [expr $x + $x1 + $C(dx)] [expr $y + $y1 + $C(dy)] \
  4682. -text $s \
  4683. -anchor center -justify center \
  4684. -fill $S(col) \
  4685. -font $S(gfo) \
  4686. -tags "ILLCo?$l T$t AnnotMatrix AM$t MA?$l $tagC AMatrixCo"
  4687. }
  4688. incr n
  4689. }
  4690. unset C
  4691. }
  4692. # NB pb si les feuilles de sont pas affich?Šes
  4693. # en plus attention en circulaire sans longueur de branche
  4694. # il
  4695. proc qLannC360 {w t leu} {
  4696. global S ann T
  4697. # cercle d'illustration fixer R le rayon du cercle d'illustration
  4698. # on peut fixer une valeur pour par ex. 200 + tabulation
  4699. # mais mieux de chercher une valeur adapt?Še ?  chaque
  4700. # arbre
  4701. # set R [expr 200 + $S($t,LabelMatrixBase)]
  4702. set co [$w bbox [list L && T$t]]
  4703. # si les feuilles ne sont pas affich?Šes on prend les arretes terminales
  4704. set co [$w bbox [list Z && T$t]]
  4705. # et si on utillisait toujours sur Z ?
  4706. set x1 [lindex $co 0]
  4707. set y1 [lindex $co 1]
  4708. set x2 [lindex $co 2]
  4709. set y2 [lindex $co 3]
  4710. set Rx [expr ($x2 - $x1) /2.0]
  4711. set Ry [expr ($y2 - $y1) /2.0]
  4712. if {$Rx > $Ry} {
  4713. set R [expr $Rx + $S($t,LabelMatrixBase)]
  4714. } else {
  4715. set R [expr $Ry + $S($t,LabelMatrixBase)]
  4716. }
  4717. set a_ref [expr 6.28318530717958 / [llength $T($t,ue_cod)]]
  4718. set n 0
  4719. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  4720. # inversion ordre liste feuilles selon conformation
  4721. if { $S($t,type) == "ClaCir2"} {
  4722. set LLE {}
  4723. foreach e $T($t,ue_cod) {
  4724. set LLE [concat $e $LLE]
  4725. }
  4726. set n 1
  4727. } else {
  4728. set LLE $T($t,ue_cod)
  4729. }
  4730. # l?Šger d?Šcalage du a anchor/justify si l'annotation a un seul caractere
  4731. # ou nombre impair, on ajoute a l'avant un espace
  4732. foreach e $LLE {
  4733. set a [expr double($n*$a_ref)]
  4734. if {[lsearch $leu $T($t,ctl,$e)] != -1} {
  4735. set x [expr $R * cos($a)]
  4736. set y [expr $R * sin($a)]
  4737. # TAG
  4738. set l $T($t,ctl,$e)
  4739. # query
  4740. if {$S(DisplayVOV) == 0} {set sss [lrange $S(query) 2 end]}
  4741. # avoir un nombre pair de caractere pour bien centrer
  4742. # sinon on ajoute devant un espace
  4743. set lc [split $sss {}]
  4744. set nbc [llength $lc]
  4745. if {[expr $nbc / 2 * 2] == $nbc} {
  4746. set s $sss
  4747. } else {
  4748. set s " $sss"
  4749. }
  4750. $w create text $x $y \
  4751. -text $s \
  4752. -anchor center -justify center \
  4753. -fill $S(col) \
  4754. -font $S(gfo) \
  4755. -tags "ILLCo?$l T$t AnnotMatrix AM$t MA?$l $tagC AMatrixCo"
  4756. }
  4757. incr n
  4758. }
  4759. # centrage sur arbre tags root "[format "%s%s" $t C] T$t Z"
  4760. set co [$w coords [format "%s%s" $t C]]
  4761. set x1 [lindex $co 0]
  4762. set y1 [lindex $co 1]
  4763. set x2 [lindex $co 2]
  4764. set y2 [lindex $co 3]
  4765. set xcenter [expr ($x1 + $x2) /2.0]
  4766. set ycenter [expr ($y1 + $y2) /2.0]
  4767. $w move $tagC $xcenter $ycenter
  4768. }
  4769. # Leaves Annotation Mode Leave
  4770. proc LannLtoolbox {w x y} {
  4771. global T
  4772. set tags [$w gettags [$w find withtag current]]
  4773. set t [string range \
  4774. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  4775. set n [string trimright \
  4776. [lindex $tags [lsearch -glob $tags *C]] C]
  4777. if {$n != ""} {
  4778. set p [format "%s%s" $n *]
  4779. set leu {}
  4780. foreach e $T($t,ue_cod) {
  4781. if {[string match $p $e] == 1} {
  4782. lappend leu $T($t,ctl,$e)
  4783. }
  4784. }
  4785. LannL $w $t $leu
  4786. }
  4787. }
  4788. #
  4789. proc LannL {w t leu} {
  4790. global S ann T
  4791. switch -exact $S($t,type) {
  4792. PhyNJ - ClaSla - ClaRec {
  4793. # tag de colonne
  4794. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  4795. foreach l $leu {
  4796. set i [$w find withtag [list ADD?$l && T$t]]
  4797. if {$i == ""} {
  4798. set i [$w find withtag [list [format "%s%s" EU $l] && T$t]]
  4799. set co [$w coords $i]
  4800. set y [lindex $co 1]
  4801. set i2 [$w find withtag [list [format "%s%s" EUL $l] && T$t]]
  4802. if {[$w itemcget $i2 -state] == "hidden"} {
  4803. set x [lindex [$w bbox $i] 2]
  4804. } else {
  4805. set x [lindex [$w bbox $i2] 2]
  4806. }
  4807. } else {
  4808. set co [$w coords [lindex $i 0]]
  4809. set y [lindex $co 1]
  4810. set x 0
  4811. foreach ii $i {
  4812. set xii [lindex [$w bbox $ii] 2]
  4813. if {$xii >= $x} {
  4814. set x $xii
  4815. }
  4816. }
  4817. }
  4818. if {$x != "" && $y != ""} {
  4819. # avoir un nombre pair de caractere pour bien centrer
  4820. # sinon on ajoute devant un espace
  4821. set lc [split $S(AnnotateNote) {}]
  4822. set nbc [llength $lc]
  4823. if {[expr $nbc / 2 * 2] == $nbc} {
  4824. set s $S(AnnotateNote)
  4825. } else {
  4826. set s " $S(AnnotateNote)"
  4827. }
  4828. $w create text $x $y -text $s \
  4829. -font $S(gfo) \
  4830. -fill $S(col) \
  4831. -anchor center -justify center \
  4832. -tags "ADD?$l T$t $tagC AnnotMatrix AM$t MA?$l" -anchor w
  4833. }
  4834. }
  4835. }
  4836. PhyRad - PhyCir1 - PhyCir2 - ClaRad {
  4837. # rien pour l'instant
  4838. }
  4839. ClaCir1 - ClaCir2 - ClaCir3 {
  4840. # pour l'instant on reste sur LannC360 mais il faudra
  4841. # passer par une proc LannL360
  4842. LannC360 $w $t $leu
  4843. }
  4844. }
  4845. }
  4846. # AnnotMatrix AM$t MA?$l
  4847. proc LannCtoolbox {w x y} {
  4848. global T
  4849. set tags [$w gettags [$w find withtag current]]
  4850. set t [string range \
  4851. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  4852. set n [string trimright \
  4853. [lindex $tags [lsearch -glob $tags *C]] C]
  4854. if {$n != ""} {
  4855. set p [format "%s%s" $n *]
  4856. set leu {}
  4857. foreach e $T($t,ue_cod) {
  4858. if {[string match $p $e] == 1} {
  4859. lappend leu $T($t,ctl,$e)
  4860. }
  4861. }
  4862. LannC $w $t $leu
  4863. }
  4864. }
  4865. #
  4866. proc LannC {w t leu} {
  4867. global S ann T
  4868. switch -exact $S($t,type) {
  4869. PhyNJ - ClaSla - ClaRec {
  4870. # recherche x
  4871. if {$S(illustration-tabulation) == 1} {
  4872. set XMAX1 [lindex [$w bbox [list T$t && Z]] 2]
  4873. set XMAX2 [lindex [$w bbox [list T$t && L]] 2]
  4874. set XMAX3 [lindex [$w bbox [list T$t && AnnotMatrix]] 2]
  4875. if {$XMAX1 < $XMAX2} {set XMAX $XMAX2 } {set XMAX $XMAX1}
  4876. if {$XMAX < $XMAX3} {set XMAX $XMAX3 }
  4877. set x [expr $XMAX + $S($t,LabelMatrixBase)]
  4878. } else {
  4879. set XMAX1 [lindex [$w bbox [list T$t && Z]] 2]
  4880. set XMAX2 [lindex [$w bbox [list T$t && L]] 2]
  4881. if {$XMAX1 < $XMAX2} {set XMAX $XMAX2 } {set XMAX $XMAX1}
  4882. set x [expr $XMAX + $S($t,LabelMatrixBase)]
  4883. }
  4884. # tag de colonne
  4885. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  4886. foreach l $leu {
  4887. # recherche y (code arrete terminale)
  4888. set item [$w find withtag [list [format "%s%s" EU $l ] && T$t]]
  4889. if {$item != ""} {
  4890. set co [$w coords $item]
  4891. set y [lindex $co 1]
  4892. # avoir un nombre pair de caractere pour bien centrer
  4893. # sinon on ajoute devant un espace
  4894. set lc [split $S(AnnotateNote) {}]
  4895. set nbc [llength $lc]
  4896. if {[expr $nbc / 2 * 2] == $nbc} {
  4897. set s $S(AnnotateNote)
  4898. } else {
  4899. set s " $S(AnnotateNote)"
  4900. }
  4901. $w create text $x $y \
  4902. -text $s \
  4903. -fill $S(col) \
  4904. -font $S(gfo) \
  4905. -anchor center -justify center \
  4906. -tags "T$t AnnotMatrix AM$t MA?$l $tagC AMatrixCo"
  4907. }
  4908. }
  4909. }
  4910. PhyRad - PhyCir1 - PhyCir2 - ClaRad {
  4911. LannC360 $w $t $leu
  4912. }
  4913. ClaCir1 - ClaCir2 - ClaCir3 {
  4914. LannC360 $w $t $leu
  4915. }
  4916. }
  4917. }
  4918. ###
  4919. proc LannC360 {w t leu} {
  4920. global S ann T
  4921. # cercle d'illustration fixer R le rayon du cercle d'illustration
  4922. # on peut fixer une valeur pour par ex. 200 + tabulation
  4923. # mais mieux de chercher une valeur adapt?Še ?  chaque
  4924. # arbre
  4925. # set R [expr 200 + $S($t,LabelMatrixBase)]
  4926. set co [$w bbox [list L && T$t]]
  4927. set x1 [lindex $co 0]
  4928. set y1 [lindex $co 1]
  4929. set x2 [lindex $co 2]
  4930. set y2 [lindex $co 3]
  4931. set Rx [expr ($x2 - $x1) /2.0]
  4932. set Ry [expr ($y2 - $y1) /2.0]
  4933. if {$Rx > $Ry} {
  4934. set R [expr $Rx + $S($t,LabelMatrixBase)]
  4935. } else {
  4936. set R [expr $Ry + $S($t,LabelMatrixBase)]
  4937. }
  4938. set a_ref [expr 6.28318530717958 / [llength $T($t,ue_cod)]]
  4939. set n 0
  4940. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  4941. # inversion ordre liste feuilles selon conformation
  4942. if { $S($t,type) == "ClaCir2"} {
  4943. set LLE {}
  4944. foreach e $T($t,ue_cod) {
  4945. set LLE [concat $e $LLE]
  4946. }
  4947. set n 1
  4948. } else {
  4949. set LLE $T($t,ue_cod)
  4950. }
  4951. # l?Šger d?Šcalage du a anchor/justify si l'annotation a un seul caractere
  4952. # on ajoute a l'avant un espace
  4953. foreach e $LLE {
  4954. set a [expr double($n*$a_ref)]
  4955. if {[lsearch $leu $T($t,ctl,$e)] != -1} {
  4956. set x [expr $R * cos($a)]
  4957. set y [expr $R * sin($a)]
  4958. # TAG
  4959. set l $T($t,ctl,$e)
  4960. # avoir un nombre pair de caractere pour bien centrer
  4961. # sinon on ajoute devant un espace
  4962. set lc [split $S(AnnotateNote) {}]
  4963. set nbc [llength $lc]
  4964. if {[expr $nbc / 2 * 2] == $nbc} {
  4965. set s $S(AnnotateNote)
  4966. } else {
  4967. set s " $S(AnnotateNote)"
  4968. }
  4969. #-text $S(AnnotateNote)
  4970. $w create text $x $y \
  4971. -text $s \
  4972. -anchor center -justify center \
  4973. -fill $S(col) \
  4974. -font $S(gfo) \
  4975. -tags "ILLCo?$l T$t AnnotMatrix AM$t MA?$l $tagC AMatrixCo"
  4976. }
  4977. incr n
  4978. }
  4979. # centrage sur arbre tags root "[format "%s%s" $t C] T$t Z"
  4980. set co [$w coords [format "%s%s" $t C]]
  4981. set x1 [lindex $co 0]
  4982. set y1 [lindex $co 1]
  4983. set x2 [lindex $co 2]
  4984. set y2 [lindex $co 3]
  4985. set xcenter [expr ($x1 + $x2) /2.0]
  4986. set ycenter [expr ($y1 + $y2) /2.0]
  4987. $w move $tagC $xcenter $ycenter
  4988. }
  4989. proc DrawANGo {} {
  4990. global S ann T
  4991. set lv {}
  4992. set lindex [.ann.l.lfa.l curselection]
  4993. foreach i $lindex {
  4994. lappend lv [.ann.l.lfa.l get $i]
  4995. }
  4996. set lkv [array get S *,tar]
  4997. set ltreetarget {}
  4998. foreach {k v} $lkv {
  4999. if {$S($k) == 1} {
  5000. lappend ltreetarget [string range $k 0 [expr [string first , $k] - 1]]
  5001. }
  5002. }
  5003. DrawANGoGo $lv $ltreetarget
  5004. }
  5005. proc DrawANGoGo {lv ltreetarget} {
  5006. global S ann T
  5007. foreach ti $ltreetarget {
  5008. switch -exact $S($ti,type) {
  5009. PhyNJ - ClaSla - ClaRec {
  5010. set database $S(database)
  5011. upvar #0 $S(database) X
  5012. foreach var $lv {
  5013. set w $S($ti,w)
  5014. set XMAX1 [lindex [$w bbox [list T$ti && Z]] 2]
  5015. set XMAX2 [lindex [$w bbox [list T$ti && L]] 2]
  5016. set XMAX3 [lindex [$w bbox [list T$ti && AnnotMatrix]] 2]
  5017. if {$XMAX1 < $XMAX2} {set XMAX $XMAX2 } {set XMAX $XMAX1}
  5018. if {$XMAX < $XMAX3} {set XMAX $XMAX3 }
  5019. if [catch {expr $S($ti,LabelMatrixBase) + $S(TabulationAnnot)} result] {
  5020. set S($ti,LabelMatrixBase) $S(TabulationAnnot)
  5021. } else {
  5022. set S($ti,LabelMatrixBase) $result
  5023. }
  5024. set x [expr $XMAX + $S($ti,LabelMatrixBase)]
  5025. # tag de colonne
  5026. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  5027. foreach l $T($ti,ue_lab) {
  5028. #
  5029. # x et y appliquent une translation en et y respectivement
  5030. # f est un facteur d'amplication de taille
  5031. set lcoordsCONTOUR {} ; set f 100.0
  5032. # recherche y
  5033. set item [$w find withtag [list [format "%s%s" EUL $l ] && T$ti]]
  5034. if {$item == ""} {
  5035. set items [$w find withtag [list ADD?$l && T$ti]]
  5036. set y 0
  5037. foreach ii $items {
  5038. set yii [lindex [$w coords $ii] 1]
  5039. if {$yii >= $y} {
  5040. set y $yii
  5041. }
  5042. }
  5043. } else {
  5044. set co [$w coords $item]
  5045. set y [lindex $co 1]
  5046. }
  5047. switch $ann(ann-fgfiguration) {
  5048. asleaf {set itemfgcolor [$w itemcget $item -fill]}
  5049. asuser {set itemfgcolor $S(col)}
  5050. }
  5051. switch $ann(ann-fofiguration) {
  5052. asleaf {set itemfont [$w itemcget $item -font]}
  5053. asuser {set itemfont $S(gfo)}
  5054. }
  5055. # construction de itemtext sur query
  5056. set record [Database::dbQueryRecordsFromVarVal $database EU $l]
  5057. set itemtext ""
  5058. if {$record == {}} {
  5059. set itemtext "-"
  5060. } else {
  5061. foreach ri $record {
  5062. foreach {vari val} $X($ri) {
  5063. if {[string equal $var $vari] == 1} {
  5064. append itemtext " $val"
  5065. }
  5066. }
  5067. }
  5068. }
  5069. set ID [Tools::GenId]
  5070. # transformation coordonnees
  5071. foreach {xi yi} $itemtext {
  5072. set xx [expr $x + ($xi * $ann(DrawFactor))]
  5073. set yy [expr $y + ($yi * $ann(DrawFactor))]
  5074. append lcoordsCONTOUR $xx
  5075. append lcoordsCONTOUR " "
  5076. append lcoordsCONTOUR $yy
  5077. append lcoordsCONTOUR " "
  5078. if {$ann(DrawNode) == 1} {
  5079. $w create rectangle [expr $xx -1] [expr $yy-1] [expr $xx+1] [expr $yy+1] -fill white -outline black \
  5080. -tags "T$ti AnnotMatrix AM$ti MA?$l $tagC AMatrixCo Morpho MOR$ID"
  5081. }
  5082. }
  5083. set iitteemm [$w create polygon $lcoordsCONTOUR -fill white -outline black \
  5084. -tags "T$ti AnnotMatrix AM$ti MA?$l $tagC AMatrixCo Morpho MOR$ID" ]
  5085. $w lower $iitteemm
  5086. }
  5087. }
  5088. }
  5089. PhyRad - PhyCir1 - PhyCir2 - ClaRad {
  5090. # A FAIRE
  5091. }
  5092. ClaCir1 - ClaCir2 - ClaCir3 {
  5093. # A FAIRE
  5094. }
  5095. }
  5096. }
  5097. }
  5098. proc DrawPlotANGo {} {
  5099. global S ann T
  5100. set lv {}
  5101. set lindex [.ann.l.lfa.l curselection]
  5102. foreach i $lindex {
  5103. lappend lv [.ann.l.lfa.l get $i]
  5104. }
  5105. set lkv [array get S *,tar]
  5106. set ltreetarget {}
  5107. foreach {k v} $lkv {
  5108. if {$S($k) == 1} {
  5109. lappend ltreetarget [string range $k 0 [expr [string first , $k] - 1]]
  5110. }
  5111. }
  5112. DrawPlotANGoGo $lv $ltreetarget
  5113. }
  5114. proc DrawPlotANGoGo {lv ltreetarget} {
  5115. global S ann T
  5116. foreach ti $ltreetarget {
  5117. switch -exact $S($ti,type) {
  5118. PhyNJ - ClaSla - ClaRec {
  5119. set database $S(database)
  5120. upvar #0 $S(database) X
  5121. foreach var $lv {
  5122. set w $S($ti,w)
  5123. set XMAX1 [lindex [$w bbox [list T$ti && Z]] 2]
  5124. set XMAX2 [lindex [$w bbox [list T$ti && L]] 2]
  5125. set XMAX3 [lindex [$w bbox [list T$ti && AnnotMatrix]] 2]
  5126. if {$XMAX1 < $XMAX2} {set XMAX $XMAX2 } {set XMAX $XMAX1}
  5127. if {$XMAX < $XMAX3} {set XMAX $XMAX3 }
  5128. if [catch {expr $S($ti,LabelMatrixBase) + $S(TabulationAnnot)} result] {
  5129. set S($ti,LabelMatrixBase) $S(TabulationAnnot)
  5130. } else {
  5131. set S($ti,LabelMatrixBase) $result
  5132. }
  5133. set x [expr $XMAX + $S($ti,LabelMatrixBase)]
  5134. # tag de colonne
  5135. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  5136. foreach l $T($ti,ue_lab) {
  5137. #
  5138. # x et y appliquent une translation en et y respectivement
  5139. # f est un facteur d'amplication de taille
  5140. set lcoordsCONTOUR {} ; set f 100.0
  5141. # recherche y
  5142. set item [$w find withtag [list [format "%s%s" EUL $l ] && T$ti]]
  5143. if {$item == ""} {
  5144. set items [$w find withtag [list ADD?$l && T$ti]]
  5145. set y 0
  5146. foreach ii $items {
  5147. set yii [lindex [$w coords $ii] 1]
  5148. if {$yii >= $y} {
  5149. set y $yii
  5150. }
  5151. }
  5152. } else {
  5153. set co [$w coords $item]
  5154. set y [lindex $co 1]
  5155. }
  5156. switch $ann(ann-fgfiguration) {
  5157. asleaf {set itemfgcolor [$w itemcget $item -fill]}
  5158. asuser {set itemfgcolor $S(col)}
  5159. }
  5160. switch $ann(ann-fofiguration) {
  5161. asleaf {set itemfont [$w itemcget $item -font]}
  5162. asuser {set itemfont $S(gfo)}
  5163. }
  5164. # construction de itemtext sur query
  5165. set record [Database::dbQueryRecordsFromVarVal $database EU $l]
  5166. set itemtext ""
  5167. if {$record == {}} {
  5168. set itemtext "-"
  5169. } else {
  5170. foreach ri $record {
  5171. foreach {vari val} $X($ri) {
  5172. if {[string equal $var $vari] == 1} {
  5173. append itemtext " $val"
  5174. }
  5175. }
  5176. }
  5177. }
  5178. # transformation coordonnees
  5179. set ximax 0 ; set yimax 0
  5180. # recherche xmax ymax
  5181. foreach {xi yi} $itemtext {
  5182. if {$xi >= $ximax} {set ximax $xi}
  5183. if {$yi >= $yimax} {set yimax $yi}
  5184. }
  5185. set fx [expr $ann(DrawXsize) / $ximax]
  5186. set fy [expr $ann(DrawYsize) / $yimax]
  5187. switch $ann(XYmode) {
  5188. scatter {
  5189. foreach {xi yi} $itemtext {
  5190. set xx [expr $x + ($xi * $fx)]
  5191. set yy [expr $y + ($yi * $fy)]
  5192. $w create line $xx $yy [expr $xx +1] [expr $yy +1] -fill black \
  5193. -tags "T$ti AnnotMatrix AM$ti MA?$l $tagC AMatrixCo"
  5194. }
  5195. }
  5196. batons {
  5197. foreach {xi yi} $itemtext {
  5198. set xx [expr $x + ($xi * $fx)]
  5199. set yy [expr $y + ($yi * $fy)]
  5200. $w create line $xx [expr $y + $ann(DrawYsize) + 3] $xx [expr $yy +1] -fill black \
  5201. -tags "T$ti AnnotMatrix AM$ti MA?$l $tagC AMatrixCo"
  5202. }
  5203. }
  5204. curve {
  5205. set ldot ""
  5206. foreach {xi yi} $itemtext {
  5207. set xx [expr $x + ($xi * $fx)]
  5208. set yy [expr $y + ($yi * $fy)]
  5209. $w create line $xx $yy [expr $xx +1] [expr $yy +1] -fill black \
  5210. -tags "T$ti AnnotMatrix AM$ti MA?$l $tagC AMatrixCo"
  5211. append ldot " $xx $yy"
  5212. }
  5213. $w create line $ldot -fill black \
  5214. -tags "T$ti AnnotMatrix AM$ti MA?$l $tagC AMatrixCo"
  5215. }
  5216. }
  5217. # voir si bbox
  5218. set iit [$w create rectangle \
  5219. [expr $x - $ann(DrawXsize) - 3 ] [expr $y - $ann(DrawYsize) - 3] \
  5220. [expr $x + $ann(DrawXsize) + 3] [expr $y + $ann(DrawYsize) + 3] -fill white -outline black \
  5221. -tags "T$ti AnnotMatrix AM$ti MA?$l $tagC AMatrixCo" ]
  5222. $w lower $iit
  5223. }
  5224. }
  5225. }
  5226. PhyRad - PhyCir1 - PhyCir2 - ClaRad {
  5227. # A FAIRE
  5228. }
  5229. ClaCir1 - ClaCir2 - ClaCir3 {
  5230. # A FAIRE
  5231. }
  5232. }
  5233. }
  5234. }
  5235. #
  5236. proc PlotNodeMGo {w t n database variable} {
  5237. set ln [Tools::NodeNoCoFaToNoCoCh $t $n]
  5238. foreach ni $ln {
  5239. if {$ni == $t} {
  5240. set co [$w coords [format "%s%s" $n C]]
  5241. set x [lindex $co 0]
  5242. set y [expr ([lindex $co 3] - [lindex $co 1]) / 2.0]
  5243. } else {
  5244. set co [$w coords $ni]
  5245. set x [lindex $co 0]
  5246. set y [lindex $co 1]
  5247. }
  5248. PlotNodeGo $w $t $ni $database $variable $x $y
  5249. }
  5250. }
  5251. #
  5252. proc PlotNodeGo {w t n database variable x y} {
  5253. global S T ann B
  5254. # liste feuilles sources
  5255. set SouRefLea [Tools::NodeLeCoToRe $t [Tools::NodeNoToLe $t $n]]
  5256. # liste records correspondant aux feuilles sources
  5257. set MatchingRecords {}
  5258. foreach f $SouRefLea {
  5259. set recordsOK [Database::dbQueryRecordsFromVarPatVal $database EU $f]
  5260. foreach r $recordsOK {
  5261. lappend MatchingRecords $r
  5262. }
  5263. }
  5264. # liste valeurs pour $variable sur les matching records
  5265. upvar #0 $database X
  5266. set MatchingValues {}
  5267. foreach r $MatchingRecords {
  5268. set toc $X($r)
  5269. if {!([set pos [lsearch $toc $variable]]%2)} {
  5270. set val [lindex $toc [incr pos]]
  5271. if {[lsearch -exact $MatchingValues $val] == -1} {lappend MatchingValues $val}
  5272. }
  5273. }
  5274. # $MatchingValues est une liste de liste de coordonn?Šes non ordonn?Še
  5275. set nb [llength $MatchingValues] ;# on va calculer la moyenne
  5276. foreach lc $MatchingValues {
  5277. set cindex 0
  5278. foreach c $lc {
  5279. incr cindex
  5280. if [catch {expr $Somme($cindex) + $c} result] {
  5281. set Somme($cindex) $c
  5282. } else {
  5283. set Somme($cindex) $result
  5284. }
  5285. }
  5286. }
  5287. # passage array vers liste
  5288. # probleme recuperer dans l'ordre
  5289. set itemtext {}
  5290. for {set i 1} {$i <= $cindex} {incr i 1} {
  5291. append itemtext " [expr $Somme($i) / $nb]"
  5292. }
  5293. # transformation coordonnees
  5294. set ID [Tools::GenId]
  5295. # transformation coordonnees
  5296. set ximax 0 ; set yimax 0
  5297. # recherche xmax ymax
  5298. foreach {xi yi} $itemtext {
  5299. if {$xi >= $ximax} {set ximax $xi}
  5300. if {$yi >= $yimax} {set yimax $yi}
  5301. }
  5302. set fx [expr $ann(DrawXsize) / $ximax]
  5303. set fy [expr $ann(DrawYsize) / $yimax]
  5304. switch $ann(XYmode) {
  5305. scatter {
  5306. foreach {xi yi} $itemtext {
  5307. set xx [expr $x + ($xi * $fx)]
  5308. set yy [expr $y + ($yi * $fy)]
  5309. $w create line $xx $yy [expr $xx +1] [expr $yy +1] -fill black \
  5310. -tags "T$t bullab BLL?$ID AnnotMatrix AM$t AMatrixCo Plot Plot$ID"
  5311. }
  5312. }
  5313. batons {
  5314. foreach {xi yi} $itemtext {
  5315. set xx [expr $x + ($xi * $fx)]
  5316. set yy [expr $y + ($yi * $fy)]
  5317. $w create line $xx [expr $y + $ann(DrawYsize) + 3] $xx [expr $yy +1] -fill black \
  5318. -tags "T$t bullab BLL?$ID AnnotMatrix AM$t AMatrixCo Plot Plot$ID"
  5319. }
  5320. }
  5321. curve {
  5322. set ldot ""
  5323. foreach {xi yi} $itemtext {
  5324. set xx [expr $x + ($xi * $fx)]
  5325. set yy [expr $y + ($yi * $fy)]
  5326. $w create line $xx $yy [expr $xx +1] [expr $yy +1] -fill black \
  5327. -tags "T$t bullab BLL?$ID AnnotMatrix AM$t AMatrixCo Plot Plot$ID"
  5328. append ldot " $xx $yy"
  5329. }
  5330. $w create line $ldot -fill black \
  5331. -tags "T$t AnnotMatrix AM$t MA?$l $tagC AMatrixCo"
  5332. }
  5333. }
  5334. set iit [$w create rectangle \
  5335. [expr $x - $ann(DrawXsize) - 3] [expr $y - $ann(DrawYsize) - 3] \
  5336. [expr $x + $ann(DrawXsize) + 3] [expr $y + $ann(DrawYsize) + 3] -fill white -outline black \
  5337. -tags "T$t bullab BLL?$ID AnnotMatrix AM$t AMatrixCo Plot Plot$ID" ]
  5338. $w lower $iit
  5339. BLLmake4 $w $t $x $y $ID $n
  5340. }
  5341. proc SubtreeShapeMGo {w t n database variable} {
  5342. set ln [Tools::NodeNoCoFaToNoCoCh $t $n]
  5343. foreach ni $ln {
  5344. if {$ni == $t} {
  5345. set co [$w coords [format "%s%s" $n C]]
  5346. set x [lindex $co 0]
  5347. set y [expr ([lindex $co 3] - [lindex $co 1]) / 2.0]
  5348. } else {
  5349. set co [$w coords $ni]
  5350. set x [lindex $co 0]
  5351. set y [lindex $co 1]
  5352. }
  5353. SubtreeShapeGo $w $t $ni $database $variable $x $y
  5354. }
  5355. }
  5356. #
  5357. proc SubtreeShapeGo {w t n database variable x y} {
  5358. global S T ann B
  5359. # liste feuilles sources
  5360. set SouRefLea [Tools::NodeLeCoToRe $t [Tools::NodeNoToLe $t $n]]
  5361. # liste records correspondant aux feuilles sources
  5362. set MatchingRecords {}
  5363. foreach f $SouRefLea {
  5364. set recordsOK [Database::dbQueryRecordsFromVarPatVal $database EU $f]
  5365. foreach r $recordsOK {
  5366. lappend MatchingRecords $r
  5367. }
  5368. }
  5369. # liste valeurs pour $variable sur les matching records
  5370. upvar #0 $database X
  5371. set MatchingValues {}
  5372. foreach r $MatchingRecords {
  5373. set toc $X($r)
  5374. if {!([set pos [lsearch $toc $variable]]%2)} {
  5375. set val [lindex $toc [incr pos]]
  5376. if {[lsearch -exact $MatchingValues $val] == -1} {lappend MatchingValues $val}
  5377. }
  5378. }
  5379. # $MatchingValues est une liste de liste de coordonn?Šes non ordonn?Še
  5380. set nb [llength $MatchingValues] ;# on va calculer la moyenne
  5381. foreach lc $MatchingValues {
  5382. set cindex 0
  5383. foreach c $lc {
  5384. incr cindex
  5385. if [catch {expr $Somme($cindex) + $c} result] {
  5386. set Somme($cindex) $c
  5387. } else {
  5388. set Somme($cindex) $result
  5389. }
  5390. }
  5391. }
  5392. # passage array vers liste
  5393. # probleme recuperer dans l'ordre
  5394. set itemtext {}
  5395. for {set i 1} {$i <= $cindex} {incr i 1} {
  5396. append itemtext " [expr $Somme($i) / $nb]"
  5397. }
  5398. # transformation coordonnees
  5399. set ID [Tools::GenId]
  5400. foreach {xi yi} $itemtext {
  5401. set xx [expr $x + ($xi * $ann(DrawFactor))]
  5402. set yy [expr $y + ($yi * $ann(DrawFactor))]
  5403. append lcoordsCONTOUR $xx
  5404. append lcoordsCONTOUR " "
  5405. append lcoordsCONTOUR $yy
  5406. append lcoordsCONTOUR " "
  5407. if {$ann(DrawNode) == 1} {
  5408. $w create rectangle [expr $xx -1] [expr $yy-1] [expr $xx+1] [expr $yy+1] -fill white -outline black \
  5409. -tags "T$t bullab BLL?$ID AnnotMatrix AM$t AMatrixCo Morpho MOR$ID"
  5410. }
  5411. }
  5412. if {$S(stipple) == "z.xbm"} {
  5413. if {$ann(DrawFill) == 1} {
  5414. set iitt [$w create polygon $lcoordsCONTOUR -outline black -fill $S(col) \
  5415. -tags "bullab BLL?$ID T$t AnnotMatrix AM$t AMatrixCo Morpho MOR$ID"]
  5416. } else {
  5417. set iitt [$w create polygon $lcoordsCONTOUR -outline black -fill white \
  5418. -tags "bullab BLL?$ID T$t AnnotMatrix AM$t AMatrixCo Morpho MOR$ID"]
  5419. }
  5420. } else {
  5421. set iitt [$w create polygon $lcoordsCONTOUR -fill $S(col) -outline black \
  5422. -stipple @[file join $S(TheoPATH) + stipple $S(stipple)] \
  5423. -tags "bullab BLL?$ID T$t AnnotMatrix AM$t AMatrixCo Morpho MOR$ID"]
  5424. }
  5425. $w lower $iitt
  5426. BLLmake4 $w $t $x $y $ID $n
  5427. }
  5428. # nb anchor a remplacer par justify
  5429. proc ANGoNew {} {
  5430. global S ann T
  5431. set lv {}
  5432. set lib .annotation.p.pane0.childsite.n.canvas.notebook.cs.page1.cs.lfa.l
  5433. set lindex [$lib curselection]
  5434. foreach i $lindex {
  5435. lappend lv [$lib get $i]
  5436. }
  5437. set lkv [array get S *,tar]
  5438. set ltreetarget {}
  5439. foreach {k v} $lkv {
  5440. if {$S($k) == 1} {
  5441. lappend ltreetarget [string range $k 0 [expr [string first , $k] - 1]]
  5442. }
  5443. }
  5444. ANGoGo $lv $ltreetarget
  5445. }
  5446. proc ANGo {} {
  5447. global S ann T
  5448. set lv {}
  5449. set lindex [.ann.l.lfa.l curselection]
  5450. foreach i $lindex {
  5451. lappend lv [.ann.l.lfa.l get $i]
  5452. }
  5453. set lkv [array get S *,tar]
  5454. set ltreetarget {}
  5455. foreach {k v} $lkv {
  5456. if {$S($k) == 1} {
  5457. lappend ltreetarget [string range $k 0 [expr [string first , $k] - 1]]
  5458. }
  5459. }
  5460. ANGoGo $lv $ltreetarget
  5461. }
  5462. #
  5463. proc ANGoLeaves {lv ltreetarget} {
  5464. global S ann T
  5465. switch $ann(ann-leavemod) {
  5466. add {
  5467. ANGoLeavesAdd $lv $ltreetarget
  5468. }
  5469. replace {
  5470. ANGoLeavesReplace $lv $ltreetarget
  5471. }
  5472. }
  5473. }
  5474. # lv liste de variables
  5475. proc ANGoGoNew {lv ltreetarget} {
  5476. global S ann T
  5477. switch $ann(ann-textmod) {
  5478. add {
  5479. ANGoLeavesAdd $lv $ltreetarget
  5480. #
  5481. set li .annotation.p.pane2.childsite.n.canvas.notebook.cs.page1.cs.s1.l
  5482. #$li insert end "color $ann(ann-fgfiguration) asleaf
  5483. #set ann(ann-fofiguration)
  5484. foreach v $lv {
  5485. $li insert end "AN LeavesAdd {$S(database) {$v}} {prefix \"$ann(ann-prefix)\" suffix \"$ann(ann-suffix)\" exposant \"$ann(ann-exposant)\"}"
  5486. }
  5487. }
  5488. replace {
  5489. ANGoLeavesReplace $lv $ltreetarget
  5490. set li .annotation.p.pane2.childsite.n.canvas.notebook.cs.page1.cs.s1.l
  5491. foreach v $lv {
  5492. $li insert end "AN LeavesReplace {$S(database) {$v}} {prefix \"$ann(ann-prefix)\" suffix \"$ann(ann-suffix)\" exposant \"$ann(ann-exposant)\"}"
  5493. }
  5494. }
  5495. addcolumns {
  5496. ANGoColumns $lv $ltreetarget
  5497. set li .annotation.p.pane2.childsite.n.canvas.notebook.cs.page1.cs.s1.l
  5498. foreach v $lv {
  5499. $li insert end "AN LeavesAddColumns {$S(database) {$v}} {prefix \"$ann(ann-prefix)\" suffix \"$ann(ann-suffix)\" exposant \"$ann(ann-exposant)\"}"
  5500. }
  5501. }
  5502. }
  5503. }
  5504. proc ANGoGo {lv ltreetarget} {
  5505. global S ann T
  5506. switch $ann(ann-position) {
  5507. add {
  5508. ANGoLeaves $lv $ltreetarget
  5509. }
  5510. justify {
  5511. ANGoColumns $lv $ltreetarget
  5512. }
  5513. }
  5514. }
  5515. # set S($t,type) ClaCir5 (circulaire interne)
  5516. proc ANGoColumns {lv ltreetarget} {
  5517. global S ann T
  5518. foreach ti $ltreetarget {
  5519. switch -exact $S($ti,type) {
  5520. PhyNJ - ClaSla - ClaRec {
  5521. set database $S(database)
  5522. upvar #0 $S(database) X
  5523. foreach var $lv {
  5524. set w $S($ti,w)
  5525. set XMAX1 [lindex [$w bbox [list T$ti && Z]] 2]
  5526. set XMAX2 [lindex [$w bbox [list T$ti && L]] 2]
  5527. set XMAX3 [lindex [$w bbox [list T$ti && AnnotMatrix]] 2]
  5528. if {$XMAX1 < $XMAX2} {set XMAX $XMAX2 } {set XMAX $XMAX1}
  5529. if {$XMAX < $XMAX3} {set XMAX $XMAX3 }
  5530. if [catch {expr $S($ti,LabelMatrixBase) + 7} result] {
  5531. set S($ti,LabelMatrixBase) 7
  5532. } else {
  5533. set S($ti,LabelMatrixBase) $result
  5534. }
  5535. set x [expr $XMAX + $S($ti,LabelMatrixBase)]
  5536. # tag de colonne
  5537. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  5538. foreach l $T($ti,ue_lab) {
  5539. # recherche y
  5540. set item [$w find withtag [list [format "%s%s" EUL $l ] && T$ti]]
  5541. if {$item == ""} {
  5542. set items [$w find withtag [list ADD?$l && T$ti]]
  5543. set y 0
  5544. foreach ii $items {
  5545. set yii [lindex [$w coords $ii] 1]
  5546. if {$yii >= $y} {
  5547. set y $yii
  5548. }
  5549. }
  5550. } else {
  5551. set co [$w coords $item]
  5552. set y [lindex $co 1]
  5553. }
  5554. switch $ann(ann-fgfiguration) {
  5555. asleaf {set itemfgcolor [$w itemcget $item -fill]}
  5556. asuser {set itemfgcolor $S(col)}
  5557. }
  5558. switch $ann(ann-fofiguration) {
  5559. asleaf {set itemfont [$w itemcget $item -font]}
  5560. asuser {set itemfont $S(gfo)}
  5561. }
  5562. # construction de itemtext sur query
  5563. set record [Database::dbQueryRecordsFromVarVal $database EU $l]
  5564. set itemtext ""
  5565. if {$record == {}} {
  5566. set itemtext "-"
  5567. } else {
  5568. foreach ri $record {
  5569. foreach {vari val} $X($ri) {
  5570. if {[string equal $var $vari] == 1} {
  5571. append itemtext " $val"
  5572. }
  5573. }
  5574. }
  5575. }
  5576. # coordonnees
  5577. set texto [format "%s%s%s" $ann(ann-prefix) $itemtext $ann(ann-suffix)]
  5578. $w create text $x [expr $y + $ann(ann-exposant)] \
  5579. -text $texto \
  5580. -fill $itemfgcolor \
  5581. -font $itemfont \
  5582. -tags "T$ti AnnotMatrix AM$ti MA?$l $tagC AMatrixCo" -anchor w
  5583. }
  5584. }
  5585. }
  5586. PhyRad - PhyCir1 - PhyCir2 - ClaRad {
  5587. # A FAIRE
  5588. }
  5589. ClaCir1 - ClaCir2 - ClaCir3 {
  5590. # A FAIRE
  5591. }
  5592. }
  5593. }
  5594. }
  5595. # ATTENTION PB si leaf hidden
  5596. proc ANGoLeavesAdd {lv ltreetarget} {
  5597. global S ann T
  5598. foreach ti $ltreetarget {
  5599. switch -exact $S($ti,type) {
  5600. PhyNJ - ClaSla - ClaRec {
  5601. set database $S(database)
  5602. upvar #0 $S(database) X
  5603. foreach var $lv {
  5604. set w $S($ti,w)
  5605. # tag de colonne
  5606. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  5607. foreach l $T($ti,ue_lab) {
  5608. set item [$w find withtag [list [format "%s%s" EUL $l ] && T$ti]]
  5609. set itemfgcolor [$w itemcget $item -fill]
  5610. set itemfont [$w itemcget $item -font]
  5611. set record [Database::dbQueryRecordsFromVarVal $database EU $l]
  5612. set itemtext ""
  5613. if {$record == {}} {
  5614. set itemtext "-"
  5615. } else {
  5616. foreach ri $record {
  5617. foreach {vari val} $X($ri) {
  5618. if {[string equal $var $vari] == 1} {
  5619. append itemtext $val
  5620. }
  5621. }
  5622. }
  5623. }
  5624. foreach vi $itemtext {
  5625. set i [$w find withtag [list ADD?$l && T$ti]]
  5626. if {$i == ""} {
  5627. set i [$w find withtag [list [format "%s%s" EU $l] && T$ti]]
  5628. set co [$w coords $i]
  5629. set y [lindex $co 1]
  5630. set i2 [$w find withtag [list [format "%s%s" EUL $l] && T$ti]]
  5631. if {[$w itemcget $i2 -state] == "hidden"} {
  5632. set x [lindex [$w bbox $i] 2]
  5633. } else {
  5634. set x [lindex [$w bbox $i2] 2]
  5635. }
  5636. } else {
  5637. set co [$w coords [lindex $i 0]]
  5638. set y [lindex $co 1]
  5639. set x 0
  5640. foreach ii $i {
  5641. set xii [lindex [$w bbox $ii] 2]
  5642. if {$xii >= $x} {
  5643. set x $xii
  5644. }
  5645. }
  5646. }
  5647. switch $ann(ann-fgfiguration) {
  5648. asleaf {
  5649. set item [$w find withtag [list [format "%s%s" EUL $l] && T$ti]]
  5650. set itemfgcolor [$w itemcget $item -fill]
  5651. }
  5652. asuser {set itemfgcolor $S(col)}
  5653. }
  5654. switch $ann(ann-fofiguration) {
  5655. asleaf {
  5656. set item [$w find withtag [list [format "%s%s" EUL $l] && T$ti]]
  5657. set itemfont [$w itemcget $item -font]
  5658. }
  5659. asuser {set itemfont $S(gfo)}
  5660. }
  5661. if {$x != "" && $y != ""} {
  5662. set vi [string trimleft $vi " "]
  5663. set texto [format "%s%s%s" $ann(ann-prefix) $vi $ann(ann-suffix)]
  5664. $w create text $x [expr $y + $ann(ann-exposant)] -text "$texto" \
  5665. -font $itemfont \
  5666. -fill $itemfgcolor \
  5667. -tags "ADD?$l T$ti MA$l $tagC AnnotMatrix AM$ti" -anchor w
  5668. }
  5669. }
  5670. }
  5671. }
  5672. }
  5673. PhyRad - PhyCir1 - PhyCir2 - ClaRad {
  5674. # A FAIRE
  5675. }
  5676. ClaCir1 - ClaCir2 - ClaCir3 {
  5677. # A FAIRE
  5678. }
  5679. }
  5680. }
  5681. }
  5682. #
  5683. proc ANGoLeavesReplaceORI {lv ltreetarget} {
  5684. global S ann T
  5685. foreach ti $ltreetarget {
  5686. switch -exact $S($ti,type) {
  5687. PhyNJ - ClaSla - ClaRec {
  5688. set database $S(database)
  5689. upvar #0 $S(database) X
  5690. foreach var $lv {
  5691. set w $S($ti,w)
  5692. # tag de colonne
  5693. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  5694. foreach l $T($ti,ue_lab) {
  5695. set item [$w find withtag [list [format "%s%s" EUL $l ] && T$ti]]
  5696. set itemfgcolor [$w itemcget $item -fill]
  5697. set itemfont [$w itemcget $item -font]
  5698. set record [Database::dbQueryRecordsFromVarVal $database EU $l]
  5699. set itemtext ""
  5700. if {$record == {}} {
  5701. set itemtext "-"
  5702. } else {
  5703. foreach ri $record {
  5704. foreach {vari val} $X($ri) {
  5705. if {[string equal $var $vari] == 1} {
  5706. append itemtext $val
  5707. }
  5708. }
  5709. }
  5710. }
  5711. foreach vi $itemtext {
  5712. set i [$w find withtag [list ADD?$l && T$ti]]
  5713. if {$i == ""} {
  5714. set i [$w find withtag [list [format "%s%s" EUL $l] && T$ti]]
  5715. set co [$w coords $i]
  5716. set y [lindex $co 1]
  5717. set x [lindex [$w bbox $i] 0]
  5718. } else {
  5719. # cas si plusieurs ajout on recup le i de plus gran x
  5720. set co [$w coords [lindex $i 0]]
  5721. set y [lindex $co 1]
  5722. set x 0
  5723. foreach ii $i {
  5724. set xii [lindex [$w bbox $ii] 2]
  5725. if {$xii >= $x} {
  5726. set x $xii
  5727. }
  5728. }
  5729. }
  5730. switch $ann(ann-fgfiguration) {
  5731. asleaf {
  5732. set item [$w find withtag [list [format "%s%s" EUL $l] && T$ti]]
  5733. set itemfgcolor [$w itemcget $item -fill]
  5734. }
  5735. asuser {set itemfgcolor $S(col)}
  5736. }
  5737. switch $ann(ann-fofiguration) {
  5738. asleaf {
  5739. set item [$w find withtag [list [format "%s%s" EUL $l] && T$ti]]
  5740. set itemfont [$w itemcget $item -font]
  5741. }
  5742. asuser {set itemfont $S(gfo)}
  5743. }
  5744. set vi [string trimleft $vi " "]
  5745. $w itemconfigure $item -state hidden
  5746. set texto [format "%s%s%s" $ann(ann-prefix) $vi $ann(ann-suffix)]
  5747. $w create text $x [expr $y + $ann(ann-exposant)] -text "$texto" \
  5748. -font $itemfont \
  5749. -fill $itemfgcolor \
  5750. -tags "ADD?$l T$ti MA$l $tagC AnnotMatrix AM$ti" -anchor w
  5751. }
  5752. }
  5753. }
  5754. }
  5755. PhyRad - PhyCir1 - PhyCir2 - ClaRad {
  5756. # A FAIRE
  5757. }
  5758. ClaCir1 - ClaCir2 - ClaCir3 {
  5759. # A FAIRE
  5760. }
  5761. }
  5762. }
  5763. }
  5764. #
  5765. proc ANGoLeavesReplace {lv ltreetarget} {
  5766. global S ann T
  5767. foreach ti $ltreetarget {
  5768. switch -exact $S($ti,type) {
  5769. PhyNJ - ClaSla - ClaRec {
  5770. set database $S(database)
  5771. upvar #0 $S(database) X
  5772. foreach var $lv {
  5773. set w $S($ti,w)
  5774. # tag de colonne
  5775. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  5776. foreach l $T($ti,ue_lab) {
  5777. set item [$w find withtag [list [format "%s%s" EUL $l ] && T$ti]]
  5778. set itemfgcolor [$w itemcget $item -fill]
  5779. set itemfont [$w itemcget $item -font]
  5780. set record [Database::dbQueryRecordsFromVarVal $database EU $l]
  5781. set itemtext ""
  5782. if {$record == {}} {
  5783. set itemtext "-"
  5784. } else {
  5785. foreach ri $record {
  5786. foreach {vari val} $X($ri) {
  5787. if {[string equal $var $vari] == 1} {
  5788. append itemtext $val
  5789. }
  5790. }
  5791. }
  5792. }
  5793. set i [$w find withtag [list ADD?$l && T$ti]]
  5794. if {$i == ""} {
  5795. set i [$w find withtag [list [format "%s%s" EUL $l] && T$ti]]
  5796. set co [$w coords $i]
  5797. set y [lindex $co 1]
  5798. set x [lindex [$w bbox $i] 0]
  5799. } else {
  5800. # cas si plusieurs ajout on recup le i de plus gran x
  5801. set co [$w coords [lindex $i 0]]
  5802. set y [lindex $co 1]
  5803. set x 0
  5804. foreach ii $i {
  5805. set xii [lindex [$w bbox $ii] 2]
  5806. if {$xii >= $x} {
  5807. set x $xii
  5808. }
  5809. }
  5810. }
  5811. switch $ann(ann-fgfiguration) {
  5812. asleaf {
  5813. set item [$w find withtag [list [format "%s%s" EUL $l] && T$ti]]
  5814. set itemfgcolor [$w itemcget $item -fill]
  5815. }
  5816. asuser {set itemfgcolor $S(col)}
  5817. }
  5818. switch $ann(ann-fofiguration) {
  5819. asleaf {
  5820. set item [$w find withtag [list [format "%s%s" EUL $l] && T$ti]]
  5821. set itemfont [$w itemcget $item -font]
  5822. }
  5823. asuser {set itemfont $S(gfo)}
  5824. }
  5825. set vi [string trimleft $itemtext " "]
  5826. $w itemconfigure $item -state hidden
  5827. set texto [format "%s%s%s" $ann(ann-prefix) $vi $ann(ann-suffix)]
  5828. $w create text $x [expr $y + $ann(ann-exposant)] -text "$texto" \
  5829. -font $itemfont \
  5830. -fill $itemfgcolor \
  5831. -tags "ADD?$l T$ti MA$l $tagC AnnotMatrix AM$ti" -anchor w
  5832. }
  5833. }
  5834. }
  5835. PhyRad - PhyCir1 - PhyCir2 - ClaRad {
  5836. # A FAIRE
  5837. }
  5838. ClaCir1 - ClaCir2 - ClaCir3 {
  5839. # A FAIRE
  5840. }
  5841. }
  5842. }
  5843. }
  5844. ###
  5845. proc CanvasTextSelect {w x y} {
  5846. global S
  5847. set x [$w canvasx $x]
  5848. set y [$w canvasy $y]
  5849. CanvasTextDone $w
  5850. if {[$w type current] == "text"} {
  5851. $w addtag "EdiText" withtag current
  5852. } else {
  5853. set ltags {EdiText TXT}
  5854. foreach ti $S($w,t) {
  5855. lappend ltags "T$ti"
  5856. }
  5857. $w create text $x $y -font $S(gfo) -fill $S(col) -justify left -tags $ltags
  5858. }
  5859. focus $w
  5860. $w focus "EdiText"
  5861. $w icursor "EdiText" @$x,$y
  5862. }
  5863. ###
  5864. proc CanvasTextEditAdd {w s} {
  5865. $w insert "EdiText" insert $s
  5866. }
  5867. ###
  5868. proc CanvasTextEnd {w } {
  5869. $w delete "EdiText"
  5870. }
  5871. ###
  5872. proc CanvasTextEditBacksp {w} {
  5873. set pos [expr [$w index "EdiText" insert] -1]
  5874. if {$pos >= 0} {
  5875. $w dchars "EdiText" $pos
  5876. }
  5877. }
  5878. ###
  5879. proc CanvasTextDone {w} {
  5880. set msg [$w itemcget "EdiText" -text]
  5881. if {[string length [string trim $msg]] == 0} {
  5882. $w delete "EdiText"
  5883. }
  5884. $w dtag "EdiText"
  5885. $w focus ""
  5886. }
  5887. ### A REVOIR
  5888. proc Insert {what} {
  5889. global S T
  5890. set w [format "%s%s%s" .t $S(ict) .c]
  5891. switch -exact $what {
  5892. Scale {$w delete SCA
  5893. set kv [array get T $S(ict),dbl,*]
  5894. set max 0
  5895. foreach {key value} $kv {
  5896. if {$value >= $max} {set max $value ; set keymax $key}
  5897. }
  5898. set code [string range $keymax [expr [string last "," $keymax] +1] end]
  5899. set cood [$w coords $code]
  5900. set leng [expr [lrange $cood 0 0] - [lrange $cood 2 2]]
  5901. set wgoal [expr [winfo width $w] / 10.0]
  5902. set r [expr $wgoal / $leng]
  5903. set dxfinal [expr $r * $max]
  5904. set deci [string last . $dxfinal]
  5905. set dxfinal [string range $dxfinal 0 [expr $deci +2] ]
  5906. set lefinal [expr $r * $leng]
  5907. set ori_x 20.0
  5908. set ori_y 20.0
  5909. $w create line $ori_x $ori_y \
  5910. $ori_x [expr $ori_y + 7.0] \
  5911. $ori_x [expr $ori_y + 3.0] \
  5912. [expr $ori_x + $lefinal] [expr $ori_y + 3.0] \
  5913. [expr $ori_x + $lefinal] [expr $ori_y + 7.0] \
  5914. [expr $ori_x + $lefinal] $ori_y \
  5915. -width 1 -fill blue -tags SCA
  5916. $w create text [expr $ori_x + $lefinal / 2] [expr $ori_y + 10.0] \
  5917. -text $dxfinal -font $T($S(ict),gfo) -fill blue -tags SCA -anchor center
  5918. set S(und) "$w delete SCA"
  5919. }
  5920. Date {set s [clock format [clock seconds] -format "%A %B %d %H:%M:%S %Z %Y"]
  5921. $w create text 30 30 -text $s -font $S(gfo) -fill $T($S(ict),gfg) -tags "TXT"
  5922. }
  5923. File {set s $T($S(ict),fil)
  5924. $w create text 40 40 -text $s -font $S(gfo) -fill $T($S(ict),gfg) -tags "TXT"
  5925. }
  5926. Text {set s $T($S(ict),fil)
  5927. Interface::toolbar_select .treedyn.n.tab.notebook.page1.w.pt textinsert
  5928. TBA::CanvasTextSelect $w 10 10
  5929. }
  5930. }
  5931. }
  5932. #
  5933. proc AnnotateBuiltIn {w t x y what {color black} } {
  5934. global S T
  5935. switch -exact $what {
  5936. Scale {
  5937. #$w delete SCA
  5938. set kv [array get T $t,dbl,*]
  5939. # recherche d'une longueur de branche moyenne
  5940. set dblB 0.0
  5941. foreach {key value} $kv {
  5942. if {$value >= $dblB} {set dblB $value ; set keymax $key}
  5943. }
  5944. set dblA $dblB
  5945. foreach {key value} $kv {
  5946. if {$value <= $dblA} {set dblA $value ; set keymin $key}
  5947. }
  5948. set dblmoy [expr ($dblB - $dblA) / 2.0]
  5949. # longueur C du trait correspondant a la dblmoy
  5950. set code [string range $keymax [expr [string last "," $keymax] +1] end]
  5951. if { $S($t,type) == "PhyRad"} {
  5952. set code [format "%s%s" $code C]
  5953. }
  5954. set cood [$w coords $code]
  5955. set B [expr [lrange $cood 0 0] - [lrange $cood 2 2]]
  5956. set C [expr ($dblmoy * $B) / $dblB]
  5957. #arrondir dblmoy
  5958. set scientif [format "%e" $dblmoy]
  5959. set exposant [string range $scientif [string first e $scientif] end]
  5960. set prefixe [expr round([string range $scientif 0 [expr [string first e $scientif] -1]])]
  5961. set dblmoyarrondi [format "%f" [format "%s%s" $prefixe $exposant]]
  5962. #ajuster la longueur du trait moyen a l'arrondi
  5963. set D [expr ($dblmoyarrondi * $C) / $dblmoy]
  5964. # dessin
  5965. set ori_x $x
  5966. set ori_y $y
  5967. set tagi [format "%s%s" TSCA [Tools::GenId]]
  5968. $w create line $ori_x $ori_y [expr $ori_x + $D] $ori_y \
  5969. -width 1 -fill $color -tags "SCA T$t $tagi"
  5970. $w create text [expr $ori_x + $D / 2] [expr $ori_y + 10.0] \
  5971. -text [string trimright $dblmoyarrondi 0 ] -font $S(gfo) -fill $color -tags "SCA T$t $tagi" -anchor center
  5972. set S(und) "$w delete [list SCA && T$t]"
  5973. }
  5974. Scale100 {
  5975. set co [$w bbox [list T$t && Z]]
  5976. set x1 [lindex $co 0]
  5977. set x2 [lindex $co 2]
  5978. set dx [expr $x2 - $x1]
  5979. set unit [expr $dx / 10.0]
  5980. set tagi [format "%s%s" TSCA [Tools::GenId]]
  5981. for {set i 0} {$i <= 10} {incr i 1} {
  5982. $w create line [expr $x + ($i * $unit)] [expr $y -3] \
  5983. [expr $x + ($i * $unit)] [expr $y +4] -width 1 -fill black -tags "SCA T$t $tagi"
  5984. set texto [format "%s%s" [expr 10 * $i] "%"]
  5985. $w create text [expr $x + ($i * $unit)] [expr $y -5] -text $texto \
  5986. -fill black -tags "SCA T$t $tagi" -anchor s -justify center
  5987. }
  5988. $w create line $x $y [expr $x + $dx] $y -width 1 -fill black -tags "SCA T$t $tagi"
  5989. }
  5990. Date {
  5991. $w create text $x $y -text [clock format [clock seconds] -format "%A %B %d %Y"] \
  5992. -font $S(gfo) -fill $S(col) -tags "TXT T$t"
  5993. }
  5994. File {
  5995. #
  5996. #[wm title [winfo parent $w]]
  5997. $w create text $x $y -text $S($t,tit) -font $S(gfo) -fill $S(col) -tags "TXT T$t" -anchor w
  5998. }
  5999. }
  6000. }
  6001. ###
  6002. proc DisplayDBL {w t} {
  6003. global T S
  6004. set li [$w find withtag [list T$t && DBL]]
  6005. if {$li != ""} {
  6006. $w delete [list T$t && DBL]
  6007. } else {
  6008. $w delete [list T$t && DBL]
  6009. set l [lrange $T($t,all_cod) 1 end]
  6010. foreach i $l {
  6011. if {[$w itemcget $i -state] != "hidden"} {
  6012. set co [$w coords $i]
  6013. if {$co != ""} {
  6014. set x [lrange $co 2 2]
  6015. set y [lrange $co 1 1]
  6016. eval {$w create text} \
  6017. {$x $y} \
  6018. {-text $T($t,dbl,$i) -fill $S(col) \
  6019. -font $S(gfo) -anchor nw -tags "T$t DBL"}
  6020. }
  6021. }
  6022. }
  6023. }
  6024. }
  6025. ###
  6026. proc DisplayDBLpercent {w t} {
  6027. global T S
  6028. # recherche plus grande longueur de branche
  6029. set ls [lrange $T($t,all_cod) 1 end]
  6030. set blmax 0
  6031. foreach l $ls {
  6032. if {$T($t,dbl,$l) > $blmax} {set blmax $T($t,dbl,$l)}
  6033. }
  6034. # facteur / 100
  6035. set N [expr $blmax / 100.0]
  6036. set li [$w find withtag [list T$t && DBL]]
  6037. if {$li != ""} {
  6038. $w delete [list T$t && DBL]
  6039. } else {
  6040. $w delete [list T$t && DBL]
  6041. set l [lrange $T($t,all_cod) 1 end]
  6042. foreach i $l {
  6043. if {[$w itemcget $i -state] != "hidden"} {
  6044. set co [$w coords $i]
  6045. if {$co != ""} {
  6046. set x [lrange $co 2 2]
  6047. set y [lrange $co 1 1]
  6048. set bl [format "%s%s" [expr round($T($t,dbl,$i) / $N)] %]
  6049. eval {$w create text} \
  6050. {$x $y} \
  6051. {-text $bl -fill $S(col) \
  6052. -font $S(gfo) -anchor nw -tags "T$t DBL"}
  6053. }
  6054. }
  6055. }
  6056. }
  6057. }
  6058. #
  6059. proc NodeDBLp {w x y} {
  6060. global S T
  6061. set x [$w canvasx $x] ; set y [$w canvasy $y]
  6062. set tags [$w gettags [$w find withtag current]]
  6063. set n [string trimright \
  6064. [lindex $tags [lsearch -glob $tags *C]] C]
  6065. set t [string range \
  6066. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  6067. if {$n != ""} {
  6068. # recherche plus grande longueur de branche
  6069. set ls [lrange $T($t,all_cod) 1 end]
  6070. set blmax 0
  6071. foreach l $ls {
  6072. if {$T($t,dbl,$l) > $blmax} {set blmax $T($t,dbl,$l)}
  6073. }
  6074. # facteur / 100
  6075. set N [expr $blmax / 100.0]
  6076. set bl [format "%s%s" [expr round($T($t,dbl,$n) / $N)] %]
  6077. $w create text $x $y -text $bl -fill $S(col) \
  6078. -font $S(gfo) -anchor nw -tags "T$t DBL"
  6079. }
  6080. }
  6081. #
  6082. proc NodeDBL {w x y} {
  6083. global S T
  6084. set x [$w canvasx $x] ; set y [$w canvasy $y]
  6085. set tags [$w gettags [$w find withtag current]]
  6086. set n [string trimright \
  6087. [lindex $tags [lsearch -glob $tags *C]] C]
  6088. set t [string range \
  6089. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  6090. if {$n != ""} {
  6091. $w create text $x $y -text $T($t,dbl,$n) -fill $S(col) \
  6092. -font $S(gfo) -anchor nw -tags "T$t DBL"
  6093. }
  6094. }
  6095. #
  6096. proc NodeDBV {w x y} {
  6097. global S T
  6098. set x [$w canvasx $x] ; set y [$w canvasy $y]
  6099. set tags [$w gettags [$w find withtag current]]
  6100. set n [string trimright \
  6101. [lindex $tags [lsearch -glob $tags *C]] C]
  6102. set t [string range \
  6103. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  6104. if {$n != ""} {
  6105. if [catch {set test $T($t,dbv,$n)} res] {
  6106. #nothing
  6107. } else {
  6108. $w create text $x $y -text $T($t,dbv,$n) -fill $S(col) \
  6109. -font $S(gfo) -anchor nw -tags "T$t DBL"
  6110. }
  6111. }
  6112. }
  6113. #
  6114. proc NodeDBVp {w x y} {
  6115. global S T
  6116. set x [$w canvasx $x] ; set y [$w canvasy $y]
  6117. set tags [$w gettags [$w find withtag current]]
  6118. set n [string trimright \
  6119. [lindex $tags [lsearch -glob $tags *C]] C]
  6120. set t [string range \
  6121. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  6122. if {$n != ""} {
  6123. if [catch {set test $T($t,dbv,$n)} res] {
  6124. #nothing
  6125. } else {
  6126. set lall [lrange $T($t,all_cod) 1 end]
  6127. # on retire les codes des ue
  6128. set l [Tools::SousL $lall $T($t,ue_cod)]
  6129. # recherche plus grande valeur bootstrap
  6130. set bvmax 0
  6131. foreach i $l {
  6132. if {$T($t,dbv,$i) > $bvmax} {set bvmax $T($t,dbv,$i)}
  6133. }
  6134. # facteur / 100
  6135. set N [expr $bvmax / 100.0]
  6136. if {$T($t,dbv,$n) != ""} {
  6137. set txt [format "%s%s" [expr round($T($t,dbv,$n) / $N)] %]
  6138. $w create text $x $y -text $txt -fill $S(col) \
  6139. -font $S(gfo) -anchor nw -tags "T$t DBL"
  6140. }
  6141. }
  6142. }
  6143. }
  6144. ###
  6145. proc DisplayDBV {w t} {
  6146. global T S
  6147. set x [$w canvasx $x] ; set y [$w canvasy $y]
  6148. set li [$w find withtag [list T$t && DBV]]
  6149. if {$li != ""} {
  6150. $w delete [list T$t && DBV]
  6151. } else {
  6152. set lall [lrange $T($t,all_cod) 1 end]
  6153. # on retire les codes des ue
  6154. set l [Tools::SousL $lall $T($t,ue_cod)]
  6155. $w delete [list T$t && DBV]
  6156. foreach i $l {
  6157. if {[$w itemcget $i -state] != "hidden"} {
  6158. set co [$w coords $i]
  6159. if {$co != ""} {
  6160. set x [lrange $co 0 0]
  6161. set y [lrange $co 1 1]
  6162. if {$T($t,dbv,$i) != ""} {
  6163. set txt $T($t,dbv,$i)
  6164. eval {$w create text} \
  6165. {$x $y} \
  6166. {-text $txt -fill $S(col) \
  6167. -font $S(gfo) -anchor nw -tags "T$t DBV"}
  6168. }
  6169. }
  6170. }
  6171. }
  6172. }
  6173. }
  6174. proc DisplayDBVseuilGO {w t} {
  6175. global T S
  6176. $w delete [list T$t && DBV]
  6177. set lall [lrange $T($t,all_cod) 1 end]
  6178. set l [Tools::SousL $lall $T($t,ue_cod)]
  6179. foreach i $l {
  6180. if {[$w itemcget $i -state] != "hidden"} {
  6181. set co [$w coords $i]
  6182. if {$co != ""} {
  6183. set x [lrange $co 0 0]
  6184. set y [lrange $co 1 1]
  6185. if {$T($t,dbv,$i) != "" && $T($t,dbv,$i) >= $S(dbvseuil) } {
  6186. set txt $T($t,dbv,$i)
  6187. eval {$w create text} \
  6188. {$x $y} \
  6189. {-text $txt -fill $S(col) \
  6190. -font $S(gfo) -anchor nw -tags "T$t DBV"}
  6191. }
  6192. }
  6193. }
  6194. }
  6195. }
  6196. proc DisplayDBLseuilGO {w t} {
  6197. global T S
  6198. $w delete [list T$t && DBL]
  6199. set l [lrange $T($t,all_cod) 1 end]
  6200. foreach i $l {
  6201. if {[$w itemcget $i -state] != "hidden"} {
  6202. set co [$w coords $i]
  6203. if {$co != ""} {
  6204. set x [lrange $co 2 2]
  6205. set y [lrange $co 1 1]
  6206. if {$T($t,dbl,$i) != "" && $T($t,dbl,$i) >= $S(dblseuil) } {
  6207. eval {$w create text} \
  6208. {$x $y} \
  6209. {-text $T($t,dbl,$i) -fill $S(col) \
  6210. -font $S(gfo) -anchor nw -tags "T$t DBL"}
  6211. }
  6212. }
  6213. }
  6214. }
  6215. }
  6216. ###
  6217. proc DisplayDBVpercent {w t} {
  6218. global T S
  6219. $w delete [list T$t && DBV]
  6220. set lall [lrange $T($t,all_cod) 1 end]
  6221. # on retire les codes des ue
  6222. set l [Tools::SousL $lall $T($t,ue_cod)]
  6223. # recherche plus grande valeur bootstrap
  6224. set bvmax 0
  6225. foreach i $l {
  6226. if {$T($t,dbv,$i) > $bvmax} {set bvmax $T($t,dbv,$i)}
  6227. }
  6228. # facteur / 100
  6229. set N [expr $bvmax / 100.0]
  6230. $w delete [list T$t && DBV]
  6231. foreach i $l {
  6232. if {[$w itemcget $i -state] != "hidden"} {
  6233. set co [$w coords $i]
  6234. if {$co != ""} {
  6235. set x [lrange $co 0 0]
  6236. set y [lrange $co 1 1]
  6237. if {$T($t,dbv,$i) != ""} {
  6238. set txt [format "%s%s" [expr round($T($t,dbv,$i) / $N)] %]
  6239. eval {$w create text} \
  6240. {$x $y} \
  6241. {-text $txt -fill $S(col) \
  6242. -font $S(gfo) -anchor nw -tags "T$t DBV"}
  6243. }
  6244. }
  6245. }
  6246. }
  6247. }
  6248. #
  6249. proc LabelMatrix {w t EUS tagquery} {
  6250. global S
  6251. set tagquery [format "%s%s%s" MA ? $tagquery]
  6252. set XMAX1 [lindex [$w bbox [list T$t && Z]] 2]
  6253. set XMAX2 [lindex [$w bbox [list T$t && L]] 2]
  6254. if {$XMAX1 < $XMAX2} {set XMAX $XMAX2 } {set XMAX $XMAX1}
  6255. if [catch {expr $S($t,LabelMatrixBase) + $S(TabulationAnnot)} result] {
  6256. set S($t,LabelMatrixBase) $S(TabulationAnnot)
  6257. } else {
  6258. set S($t,LabelMatrixBase) $result
  6259. }
  6260. set x [expr $XMAX + $S($t,LabelMatrixBase)]
  6261. foreach eu $EUS {
  6262. set i [$w find withtag [list T$t && EUL$eu]]
  6263. if {$i != ""} {
  6264. set co [$w coords $i]
  6265. set y [lindex $co 1]
  6266. $w create text $x $y -text + -fill $S(col) -tags "T$t $tagquery AnnotMatrix ML?$eu"
  6267. }
  6268. }
  6269. $w bind AnnotMatrix <Any-Enter> "after 500 Annotation::AnyEnterAM %W %x %y"
  6270. $w bind AnnotMatrix <Any-Leave> "after 500 Annotation::AnyLeaveAM %W"
  6271. }
  6272. #
  6273. proc AnyEnterAM {w x y} {
  6274. set tags [$w gettags current]
  6275. set color [$w itemcget current -fill]
  6276. set maq [lindex $tags [lsearch -glob $tags MA*]]
  6277. set maf [lindex $tags [lsearch -glob $tags ML*]]
  6278. set q [lindex [split $maq ?] end]
  6279. set ql [lindex [split $maf ?] end]
  6280. $w create text [expr $x + 15] $y -text [format "%s%s%s" $ql : $q] \
  6281. -anchor w -tag AMi -fill $color
  6282. }
  6283. proc AnyLeaveAM {w} {
  6284. $w delete AMi
  6285. }
  6286. #
  6287. proc BLLmake {w t x y titre text n} {
  6288. global B S
  6289. # attention 1n:nBLL
  6290. set id [format "%s%s" $t [Tools::GenId]]
  6291. set idtext [format "%s%s%s" BLL ? $id]
  6292. set idlink [format "%s%s%s" LIN ? $id]
  6293. #BLL
  6294. set txt $text
  6295. set txtfinal $txt
  6296. $w create text [$w canvasx [expr $x + 30 ] ] [$w canvasy [expr $y + 30 ]] \
  6297. -text $txtfinal -font $S(gfo) -fill $S(col) -anchor nw \
  6298. -tags "bullab T$t $idtext"
  6299. # LIN [expr $x + 30 ] [expr $y + 30 ]
  6300. $w create line [$w canvasx $x] [$w canvasy $y] [$w canvasx [expr $x + 30 ] ] [$w canvasy [expr $y + 30 ]] \
  6301. -width 1 -fill $S(col) -tags "Link T$t $idlink"
  6302. # MEM
  6303. set B(BLLtre,$id) $t
  6304. set B(BLLnod,$id) $n
  6305. set B(BLLtxt,$id) $txtfinal
  6306. set B(BLLidt,$id) $idtext
  6307. set B(BLLidl,$id) $idlink
  6308. set B(BLLcol,$id) $S(col)
  6309. set B(BLLgfo,$id) $S(gfo)
  6310. set B(BLLxxx,$id) [expr $x + 30 ]
  6311. set B(BLLyyy,$id) [expr $y + 30 ]
  6312. # Liste des BLL par tree
  6313. lappend B($t,bll) $id
  6314. }
  6315. # idem que BLLmake mais ne cree pas les items graphiques
  6316. # utilise dans les copy/paste et restauration
  6317. # 2 arguments suple la couleur et la fonte
  6318. proc BLLmake2 {w t x y titre text n col gfo} {
  6319. global B S
  6320. # attention 1n:nBLL
  6321. set id [format "%s%s" $t [Tools::GenId]]
  6322. set idtext [format "%s%s%s" BLL ? $id]
  6323. set idlink [format "%s%s%s" LIN ? $id]
  6324. #BLL
  6325. set txt $text
  6326. #set txtfinal [format "%s%s%s" $titre \n $txt]
  6327. set txtfinal $txt
  6328. # MEM
  6329. set B(BLLtre,$id) $t
  6330. set B(BLLnod,$id) $n
  6331. set B(BLLtxt,$id) $txtfinal
  6332. set B(BLLidt,$id) $idtext
  6333. set B(BLLidl,$id) $idlink
  6334. set B(BLLcol,$id) $col
  6335. set B(BLLgfo,$id) $gfo
  6336. set B(BLLxxx,$id) [expr $x + 30 ]
  6337. set B(BLLyyy,$id) [expr $y + 30 ]
  6338. # Liste des BLL par tree
  6339. lappend B($t,bll) $id
  6340. }
  6341. # comme BLLmake mais ici on utilise les fontes pour illustration
  6342. proc BLLmake3 {w t x y text n} {
  6343. global B S
  6344. # attention 1n:nBLL
  6345. set id [format "%s%s" $t [Tools::GenId]]
  6346. set idtext [format "%s%s%s" BLL ? $id]
  6347. set idlink [format "%s%s%s" LIN ? $id]
  6348. #BLL
  6349. set txt $text
  6350. set txtfinal $txt
  6351. $w create text [$w canvasx [expr $x + 30 ] ] [$w canvasy [expr $y + 30 ]] \
  6352. -text $txtfinal -font $S(ill-fon) -fill $S(col) -anchor nw \
  6353. -tags "bullab T$t $idtext"
  6354. # LIN [expr $x + 30 ] [expr $y + 30 ]
  6355. $w create line [$w canvasx $x] [$w canvasy $y] [$w canvasx [expr $x + 30 ] ] [$w canvasy [expr $y + 30 ]] \
  6356. -width 1 -fill $S(col) -tags "Link T$t $idlink"
  6357. # MEM
  6358. set B(BLLtre,$id) $t
  6359. set B(BLLnod,$id) $n
  6360. set B(BLLtxt,$id) $txtfinal
  6361. set B(BLLidt,$id) $idtext
  6362. set B(BLLidl,$id) $idlink
  6363. set B(BLLcol,$id) $S(col)
  6364. set B(BLLgfo,$id) $S(ill-fon)
  6365. set B(BLLxxx,$id) [expr $x + 30 ]
  6366. set B(BLLyyy,$id) [expr $y + 30 ]
  6367. # Liste des BLL par tree
  6368. lappend B($t,bll) $id
  6369. }
  6370. ###
  6371. # comme BLLmake mais ici une forme complexe type polygon
  6372. # id est un tag unique partage par tous les items composant la structure
  6373. proc BLLmake4 {w t x y id n} {
  6374. global B S
  6375. # attention 1n:nBLL
  6376. # set id [format "%s%s" $t [Tools::GenId]]
  6377. # set idtext [format "%s%s%s" BLL ? $id]
  6378. set idlink [format "%s%s%s" LIN ? $id]
  6379. $w create line [$w canvasx $x] [$w canvasy $y] [$w canvasx [expr $x + 30 ] ] [$w canvasy [expr $y + 30 ]] \
  6380. -width 1 -fill $S(col) -tags "Link T$t $idlink"
  6381. # MEM
  6382. set B(BLLtre,$id) $t
  6383. set B(BLLnod,$id) $n
  6384. set B(BLLtxt,$id) -
  6385. set B(BLLidt,$id) MOR$id
  6386. set B(BLLidl,$id) $idlink
  6387. set B(BLLcol,$id) $S(col)
  6388. set B(BLLgfo,$id) $S(ill-fon)
  6389. set B(BLLxxx,$id) [expr $x + 30 ]
  6390. set B(BLLyyy,$id) [expr $y + 30 ]
  6391. # Liste des BLL par tree
  6392. lappend B($t,bll) $id
  6393. }
  6394. ###
  6395. proc BLLDelete {w i} {
  6396. global B
  6397. set tags [$w gettags $i]
  6398. set id [lindex [split [lindex $tags [lsearch -glob $tags BLL*]] ?] end]
  6399. $w delete [format "%s%s%s" BLL ? $id]
  6400. $w delete [format "%s%s%s" LIN ? $id]
  6401. set t $B(BLLtre,$id)
  6402. foreach key [array names B *,$id] {
  6403. unset B($key)
  6404. }
  6405. #retirer
  6406. set index [lsearch -exact $B($t,bll) $id]
  6407. set B($t,bll) [concat [lrange $B($t,bll) 0 [expr $index - 1]] \
  6408. [lrange $B($t,bll) [expr $index + 1] end]]
  6409. }
  6410. ###
  6411. proc BLLDelete2 {w id} {
  6412. global B
  6413. $w delete [format "%s%s%s" BLL ? $id]
  6414. $w delete [format "%s%s%s" LIN ? $id]
  6415. set t $B(BLLtre,$id)
  6416. foreach key [array names B *,$id] {
  6417. unset B($key)
  6418. }
  6419. #retirer
  6420. set index [lsearch -exact $B($t,bll) $id]
  6421. set B($t,bll) [concat [lrange $B($t,bll) 0 [expr $index - 1]] \
  6422. [lrange $B($t,bll) [expr $index + 1] end]]
  6423. }
  6424. ###
  6425. proc BLLUpdateColor {w i} {
  6426. global B S
  6427. set tags [$w gettags $i]
  6428. set id [lindex [split [lindex $tags [lsearch -glob $tags BLL*]] ?] end]
  6429. $w itemconfigure [format "%s%s%s" BLL ? $id] -fill $S(col)
  6430. $w itemconfigure [format "%s%s%s" LIN ? $id] -fill $S(col)
  6431. set B(BLLcol,$id) $S(col)
  6432. }
  6433. ###
  6434. proc BLLUpdateFont {w i} {
  6435. global B S
  6436. set tags [$w gettags $i]
  6437. set id [lindex [split [lindex $tags [lsearch -glob $tags BLL*]] ?] end]
  6438. $w itemconfigure [format "%s%s%s" BLL ? $id] -font $S(gfo)
  6439. set B(BLLgfo,$id) $S(gfo)
  6440. }
  6441. ###
  6442. proc BLLmove {w x y i} {
  6443. global B S
  6444. $w move $S(mov) [expr $x - $S(mox)] [expr $y - $S(moy)]
  6445. set S(mox) $x
  6446. set S(moy) $y
  6447. set tags [$w gettags $i]
  6448. set id [lindex [split [lindex $tags [lsearch -glob $tags BLL*]] ?] end]
  6449. if {$B(BLLnod,$id) == $B(BLLtre,$id)} {
  6450. set co_sou [$w coords [format "%s%s" $B(BLLnod,$id) C]]
  6451. set x1 [lindex $co_sou 0]
  6452. set y1 [expr ([lindex $co_sou 3] - [lindex $co_sou 1]) / 2.0]
  6453. } else {
  6454. set co_sou [$w coords $B(BLLnod,$id)]
  6455. set x1 [lindex $co_sou 0]
  6456. set y1 [lindex $co_sou 1]
  6457. }
  6458. set co_tar [$w coords $i]
  6459. set x2 [lindex $co_tar 0]
  6460. set y2 [lindex $co_tar 1]
  6461. # il peu y avoir des tags suplementaires a la liste "Link T$B(BLLtre,$id) $idlink"
  6462. # en particulier le tag lie aux decompositions
  6463. set tagslink [$w gettags $B(BLLidl,$id)]
  6464. $w delete $B(BLLidl,$id)
  6465. $w create line $x1 $y1 $x2 $y2 \
  6466. -width 1 -fill $B(BLLcol,$id) -tags $tagslink
  6467. set B(BLLxxx,$id) $x
  6468. set B(BLLyyy,$id) $y
  6469. }
  6470. # QUERYNODE
  6471. proc QueryNode {w t eu} {
  6472. global S T B
  6473. set id [format "%s%s" $t [Tools::GenId]]
  6474. set idtext [format "%s%s%s" QYN ? $id]
  6475. set co [$w bbox [list Z && T$t]]
  6476. $w create text [lindex $co 0] [lindex $co 1] -text $S(query) \
  6477. -fill $S(col) -font $S(gfo) -tags "querynode T$t $idtext" -anchor nw
  6478. $w raise Q$t
  6479. # restriction de result aux EU appartenant au tree target
  6480. set leu {}
  6481. foreach e $eu {
  6482. if {[lsearch -exact $T($t,ue_lab) $e] != -1} {lappend leu $e}
  6483. }
  6484. set B(QYNres,$id) $leu
  6485. set B(QYNqry,$id) $S(query)
  6486. set B(QYNtre,$id) $t
  6487. set B(QYNidt,$id) $idtext
  6488. set B(QYNcol,$id) $S(col)
  6489. set B(QYNgfo,$id) $S(gfo)
  6490. set B(QYNxxx,$id) 0
  6491. set B(QYNyyy,$id) 0
  6492. lappend B($t,qyn) $id
  6493. }
  6494. ### NB : pas de QueryNodeLink sur les nodes, trop de recouvrements
  6495. proc QueryNodeLinkLeaf {id leu} {
  6496. global B S T
  6497. # set tags [$w gettags $i]
  6498. # set id [lindex [split [lindex $tags [lsearch -glob $tags QYN*]] ?] end]
  6499. set w $S($B(QYNtre,$id),w)
  6500. set co_sou [$w coords [format "%s%s%s" QYN ? $id]]
  6501. set x1 [lindex $co_sou 0]
  6502. set y1 [lindex $co_sou 1]
  6503. foreach eu $leu {
  6504. set i2 [$w find withtag [list [format "%s%s" EU $eu] && T$B(QYNtre,$id)]]
  6505. set co_tar [$w coords $i2]
  6506. set x2 [lindex $co_tar 0]
  6507. set y2 [lindex $co_tar 1]
  6508. set idlink [format "%s%s%s" LIN ? $id]
  6509. QueryNodeLink $w $x1 $y1 $x2 $y2 $B(QYNcol,$id) "Link $idlink T$B(QYNtre,$id)"
  6510. }
  6511. }
  6512. proc QueryNodeUnLinkLeaf {id leu} {
  6513. global B S
  6514. set w $S($B(QYNtre,$id),w)
  6515. set idlink [format "%s%s%s" LIN ? $id]
  6516. $w delete $idlink
  6517. }
  6518. ###
  6519. proc QueryNodeLink {w x1 y1 x2 y2 c tags} {
  6520. $w create line $x1 $y1 $x2 $y2 -width 1 -fill $c -tags $tags
  6521. }
  6522. ###
  6523. proc QueryNodeUpdateColor {w id} {
  6524. global B S
  6525. $w itemconfigure [format "%s%s%s" QYN ? $id] -fill $S(col)
  6526. $w itemconfigure [format "%s%s%s" LIN ? $id] -fill $S(col)
  6527. set B(QYNcol,$id) $S(col)
  6528. }
  6529. ###
  6530. proc QueryNodeUpdateFont {w id} {
  6531. global B S
  6532. $w itemconfigure [format "%s%s%s" QYN ? $id] -font $S(gfo)
  6533. set B(QYNgfo,$id) $S(gfo)
  6534. }
  6535. ### OK
  6536. proc QueryNodeLocalisation {id} {
  6537. global B S T
  6538. set t $B(QYNtre,$id)
  6539. set w $S($t,w)
  6540. # restriction aux eus du tree target,
  6541. # voir aussi si prise en compte des eus sous shrink
  6542. set EUS {}
  6543. foreach e $B(QYNres,$id) {
  6544. if {[lsearch -exact $T($t,ue_lab) $e] != -1} {lappend EUS $e}
  6545. }
  6546. Operation::Operation $w $t $EUS
  6547. }
  6548. ###
  6549. proc QueryNodeMove {w x y i} {
  6550. global S T B
  6551. $w move $S(mov) [expr $x - $S(mox)] [expr $y - $S(moy)]
  6552. set S(mox) $x
  6553. set S(moy) $y
  6554. set tags [$w gettags $i]
  6555. set id [lindex [split [lindex $tags [lsearch -glob $tags QYN*]] ?] end]
  6556. # delete et redraw des link
  6557. if {[$w find withtag [format "%s%s%s" LIN ? $id]] != {} } {
  6558. $w delete [format "%s%s%s" LIN ? $id]
  6559. set co_sou [$w coords $i]
  6560. set x1 [lindex $co_sou 0]
  6561. set y1 [lindex $co_sou 1]
  6562. foreach eu $B(QYNres,$id) {
  6563. set i2 [$w find withtag [list [format "%s%s" EU $eu] && T$B(QYNtre,$id)]]
  6564. set co_tar [$w coords $i2]
  6565. set x2 [lindex $co_tar 0]
  6566. set y2 [lindex $co_tar 1]
  6567. set idlink [format "%s%s%s" LIN ? $id]
  6568. QueryNodeLink $w $x1 $y1 $x2 $y2 $B(QYNcol,$id) "Link $idlink T$B(QYNtre,$id)"
  6569. }
  6570. }
  6571. set B(QYNxxx,$id) $x
  6572. set B(QYNyyy,$id) $y
  6573. }
  6574. ###
  6575. proc QueryNodeDelete {w id} {
  6576. global B
  6577. $w delete [format "%s%s%s" QYN ? $id]
  6578. $w delete [format "%s%s%s" LIN ? $id]
  6579. set t $B(QYNtre,$id)
  6580. foreach key [array names B *,$id] {
  6581. unset B($key)
  6582. }
  6583. #retirer
  6584. set index [lsearch -exact $B($t,qyn) $id]
  6585. set B($t,bll) [concat [lrange $B($t,qyn) 0 [expr $index - 1]] \
  6586. [lrange $B($t,qyn) [expr $index + 1] end]]
  6587. }
  6588. ###
  6589. proc InsertTextNode {w x y} {
  6590. set tags [$w gettags [$w find withtag current]]
  6591. set n [string trimright \
  6592. [lindex $tags [lsearch -glob $tags *C]] C]
  6593. set t [string range \
  6594. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  6595. if {$n != ""} {
  6596. InsertTextNodeMake $w $t $x $y $n
  6597. }
  6598. }
  6599. ###
  6600. proc InsertTextNodeMake {w t x y n} {
  6601. global S
  6602. # set x [$w canvasx $x]
  6603. # set y [$w canvasy $y]
  6604. set text $S(AnnotateNote)
  6605. Annotation::BLLmake $w $t $x $y "Note :" $text $n
  6606. $w configure -scrollregion [$w bbox all]
  6607. }
  6608. #
  6609. proc InsertSymbolNode {w x y} {
  6610. set tags [$w gettags [$w find withtag current]]
  6611. set n [string trimright \
  6612. [lindex $tags [lsearch -glob $tags *C]] C]
  6613. set t [string range \
  6614. [lindex $tags [lsearch -glob $tags T*]] 1 end]
  6615. if {$n != ""} {
  6616. InsertSymbolNodeMake $w $t $x $y $n
  6617. }
  6618. }
  6619. ###
  6620. proc InsertSymbolNodeMake {w t x y n} {
  6621. global S
  6622. # set x [$w canvasx $x]
  6623. # set y [$w canvasy $y]
  6624. set text $S(ill-car)
  6625. Annotation::BLLmake3 $w $t $x $y $text $n
  6626. $w configure -scrollregion [$w bbox all]
  6627. }
  6628. ###
  6629. # s est soit tab- soit tab+
  6630. # cette fonction permet d'inc?Šmenter (+) // d?Šcr?Šmenter (-)
  6631. # la variable de tabulation pour les arbres en target
  6632. # manuellement (afin de tab entre 2 series de requetes)
  6633. proc AnnCTabulation {s} {
  6634. global S T
  6635. # A-list window/tree des arbres en target d'une session treedyn
  6636. foreach {w t} [Selection::TreeTar] {
  6637. switch -exact $s {
  6638. tab+ {
  6639. if [catch {expr $S($t,LabelMatrixBase) + $S(TabulationAnnot)} result] {
  6640. set S($t,LabelMatrixBase) $S(TabulationAnnot)
  6641. } else {
  6642. set S($t,LabelMatrixBase) $result
  6643. }
  6644. }
  6645. tab- {
  6646. if [catch {expr $S($t,LabelMatrixBase) - $S(TabulationAnnot)} result] {
  6647. # rien
  6648. } else {
  6649. set S($t,LabelMatrixBase) $result
  6650. }
  6651. }
  6652. }
  6653. }
  6654. }
  6655. }
  6656. ####################
  6657. ####################
  6658. # ABSTRACTION
  6659. ####################
  6660. namespace eval Abstraction {
  6661. # Collapse cumulatif de la selection user
  6662. proc CollapseToolbox {w} {
  6663. global B T
  6664. set item [$w find withtag current]
  6665. set tags [$w gettags $item]
  6666. set t [string range [lindex $tags [lsearch -glob $tags T*]] 1 end]
  6667. set n [string trimright \
  6668. [lindex $tags [lsearch -glob $tags *C]] C]
  6669. if {$n != ""} {
  6670. set TarCodLea [Tools::NodeNoToLe $t $n]
  6671. set TarRefLea [Tools::NodeLeCoToRe $t $TarCodLea]
  6672. # ON AJOUTE
  6673. foreach i $TarRefLea {lappend T($t,eu_collapse) $i}
  6674. set finalleaves [Tools::SousL $T($t,ue_lab) $T($t,eu_collapse)]
  6675. # on envoie les feuilles qu'on garde
  6676. NewickAbstract $w $t $finalleaves
  6677. }
  6678. }
  6679. # UnCollapse cumulatif de la selection user
  6680. proc CollapseUnToolbox {w} {
  6681. global B T
  6682. set item [$w find withtag current]
  6683. set tags [$w gettags $item]
  6684. set t [string range [lindex $tags [lsearch -glob $tags T*]] 1 end]
  6685. set n [string trimright \
  6686. [lindex $tags [lsearch -glob $tags *C]] C]
  6687. if {$n != ""} {
  6688. set TarCodLea [Tools::NodeNoToLe $t $n]
  6689. set TarRefLea [Tools::NodeLeCoToRe $t $TarCodLea]
  6690. # ON SOUSTRAIT
  6691. set T($t,eu_collapse) [Tools::SousL $T($t,eu_collapse) $TarRefLea]
  6692. set finalleaves [Tools::SousL $T($t,ue_lab) $T($t,eu_collapse)]
  6693. # on envoie les feuilles qu'on garde
  6694. NewickAbstract $w $t $finalleaves
  6695. }
  6696. }
  6697. # Collapse cumulatif de la selection user
  6698. proc Collapse {w t TarRefLea} {
  6699. global B T
  6700. # ON AJOUTE
  6701. foreach i $TarRefLea {lappend T($t,eu_collapse) $i}
  6702. set finalleaves [Tools::SousL $T($t,ue_lab) $T($t,eu_collapse)]
  6703. # on envoie les feuilles qu'on garde
  6704. NewickAbstract $w $t $finalleaves
  6705. }
  6706. # UnCollapse cumulatif de la selection user
  6707. proc CollapseUn {w t TarRefLea} {
  6708. global B T
  6709. # ON SOUSTRAIT
  6710. set T($t,eu_collapse) [Tools::SousL $T($t,eu_collapse) $TarRefLea]
  6711. set finalleaves [Tools::SousL $T($t,ue_lab) $T($t,eu_collapse)]
  6712. # on envoie les feuilles qu'on garde
  6713. NewickAbstract $w $t $finalleaves
  6714. }
  6715. proc Shrink3 {w t n} {
  6716. global S T B IMGshn
  6717. set id [format "%s%s" $t [Tools::GenId]]
  6718. set TAG [format "%s%s%s" SHI ? $id]
  6719. set c0 [$w bbox $n]
  6720. set x0 [lindex $c0 0]
  6721. set y0 [lindex $c0 1]
  6722. set leafs [Tools::NodeNoToLe $t $n]
  6723. set lxy [Figuration::NodeColorBgSubTreeContour $w $t $n]
  6724. $w create polygon "$x0 $y0 $lxy $x0 $y0" -smooth 1 -splinesteps 100 \
  6725. -fill $S(col) -outline $S(col) -tags "SHRINK [format "%s%s%s" SHN ? $id] T$t"
  6726. $w lower [format "%s%s%s" SHN ? $id] all
  6727. # BLL
  6728. set pattern [format "%s%s" $n *]
  6729. foreach idbll $B($t,bll) {
  6730. if {[string match $pattern $B(BLLnod,$idbll)] == 1 } {
  6731. if {[$w itemcget $B(BLLidt,$idbll) -state] != "hidden"} {
  6732. $w addtag $TAG withtag $B(BLLidt,$idbll)
  6733. $w addtag $TAG withtag $B(BLLidl,$idbll)
  6734. $w itemconfigure $B(BLLidt,$idbll) -state hidden
  6735. $w itemconfigure $B(BLLidl,$idbll) -state hidden
  6736. }
  6737. }
  6738. }
  6739. # leaves
  6740. set leafs [Tools::NodeNoToLe $t $n]
  6741. foreach i $leafs {
  6742. set tagi [list [format "%s%s" EUL $T($t,ctl,$i)] && T$t]
  6743. if {[$w itemcget $tagi -state] != "hidden"} {
  6744. $w addtag $TAG withtag $tagi
  6745. $w itemconfigure $tagi -state hidden
  6746. }
  6747. }
  6748. # background leaves
  6749. set pattern [format "%s%s" $n *]
  6750. foreach idi $B($t,bgl) {
  6751. if {[string match $pattern $B(BGLnod,$idi)] == 1 } {
  6752. if {[$w itemcget [format "%s%s%s" BGL ? $idi] -state] != "hidden"} {
  6753. $w addtag $TAG withtag [format "%s%s%s" BGL ? $idi]
  6754. $w itemconfigure [format "%s%s%s" BGL ? $idi] -state hidden
  6755. }
  6756. }
  6757. }
  6758. # arretes terminales
  6759. set Le [Tools::NodeNoToLe $t $n]
  6760. foreach e $Le {
  6761. if {[$w itemcget $e -state] != "hidden"} {
  6762. $w addtag $TAG withtag $e
  6763. $w itemconfigure $e -state hidden
  6764. }
  6765. }
  6766. # tree
  6767. set lchild [Tools::NodeNoCoFaToNoCoCh $t $n]
  6768. foreach i $lchild {
  6769. if {[$w itemcget $i -state] != "hidden"} {
  6770. $w addtag $TAG withtag [format "%s%s" $i C]
  6771. $w itemconfigure [format "%s%s" $i C] -state hidden
  6772. }
  6773. }
  6774. # ova (en fait que le link)
  6775. set pattern [format "%s%s" $n *]
  6776. foreach idi $B($t,ova) {
  6777. if {[string match $pattern $B(OVAnod1,$idi)] == 1 } {
  6778. if {[$w itemcget [format "%s%s%s" BGS ? $idi] -state] != "hidden"} {
  6779. $w addtag $TAG withtag [format "%s%s%s" link ? $idi ]
  6780. $w itemconfigure [format "%s%s%s" link ? $idi ] -state hidden
  6781. }
  6782. }
  6783. }
  6784. # background tree
  6785. set pattern [format "%s%s" $n *]
  6786. foreach idi $B($t,bgs) {
  6787. if {[string match $pattern $B(BGSnod,$idi)] == 1 } {
  6788. if {[$w itemcget [format "%s%s%s" BGS ? $idi] -state] != "hidden"} {
  6789. $w addtag $TAG withtag [format "%s%s%s" BGS ? $idi]
  6790. $w itemconfigure [format "%s%s%s" BGS ? $idi] -state hidden
  6791. }
  6792. }
  6793. }
  6794. ### mem & text a afficher en D3
  6795. lappend B($t,shi) $id
  6796. set B(SHInod,$id) $n
  6797. set B(SHItxt,$id) -
  6798. set B(SHItre,$id) $t
  6799. set B(SHIcol,$id) $S(col)
  6800. set B(SHIsta,$id) normal
  6801. # UNDO
  6802. set S(und) "Abstraction::ShrinkUn $w $t $id"
  6803. return $id
  6804. }
  6805. proc Shrink4 {w t n} {
  6806. global S T B IMGshn
  6807. set id [format "%s%s" $t [Tools::GenId]]
  6808. set TAG [format "%s%s%s" SHI ? $id]
  6809. set c0 [$w bbox $n]
  6810. set x0 [lindex $c0 0]
  6811. set y0 [lindex $c0 1]
  6812. set leafs [Tools::NodeNoToLe $t $n]
  6813. set lxy [Figuration::NodeColorBgSubTreeContour $w $t $n]
  6814. $w create polygon "$x0 $y0 $lxy $x0 $y0" -smooth 1 -splinesteps 100 \
  6815. -fill $S(col) -outline $S(col) -tags "SHRINK [format "%s%s%s" SHN ? $id] T$t"
  6816. $w lower [format "%s%s%s" SHN ? $id] all
  6817. # BLL
  6818. set pattern [format "%s%s" $n *]
  6819. foreach idbll $B($t,bll) {
  6820. if {[string match $pattern $B(BLLnod,$idbll)] == 1 } {
  6821. if {[$w itemcget $B(BLLidt,$idbll) -state] != "hidden"} {
  6822. $w addtag $TAG withtag $B(BLLidt,$idbll)
  6823. $w addtag $TAG withtag $B(BLLidl,$idbll)
  6824. $w itemconfigure $B(BLLidt,$idbll) -state hidden
  6825. $w itemconfigure $B(BLLidl,$idbll) -state hidden
  6826. }
  6827. }
  6828. }
  6829. # leaves
  6830. set leafs [Tools::NodeNoToLe $t $n]
  6831. foreach i $leafs {
  6832. set tagi [list [format "%s%s" EUL $T($t,ctl,$i)] && T$t]
  6833. if {[$w itemcget $tagi -state] != "hidden"} {
  6834. $w addtag $TAG withtag $tagi
  6835. $w itemconfigure $tagi -state hidden
  6836. }
  6837. }
  6838. # background leaves
  6839. set pattern [format "%s%s" $n *]
  6840. foreach idi $B($t,bgl) {
  6841. if {[string match $pattern $B(BGLnod,$idi)] == 1 } {
  6842. if {[$w itemcget [format "%s%s%s" BGL ? $idi] -state] != "hidden"} {
  6843. $w addtag $TAG withtag [format "%s%s%s" BGL ? $idi]
  6844. $w itemconfigure [format "%s%s%s" BGL ? $idi] -state hidden
  6845. }
  6846. }
  6847. }
  6848. # arretes terminales
  6849. set Le [Tools::NodeNoToLe $t $n]
  6850. foreach e $Le {
  6851. if {[$w itemcget $e -state] != "hidden"} {
  6852. $w addtag $TAG withtag $e
  6853. $w itemconfigure $e -state hidden
  6854. }
  6855. }
  6856. # tree
  6857. set lchild [Tools::NodeNoCoFaToNoCoCh $t $n]
  6858. foreach i $lchild {
  6859. if {[$w itemcget $i -state] != "hidden"} {
  6860. $w addtag $TAG withtag [format "%s%s" $i C]
  6861. $w itemconfigure [format "%s%s" $i C] -state hidden
  6862. }
  6863. }
  6864. # ova (en fait que le link)
  6865. set pattern [format "%s%s" $n *]
  6866. foreach idi $B($t,ova) {
  6867. if {[string match $pattern $B(OVAnod1,$idi)] == 1 } {
  6868. if {[$w itemcget [format "%s%s%s" BGS ? $idi] -state] != "hidden"} {
  6869. $w addtag $TAG withtag [format "%s%s%s" link ? $idi ]
  6870. $w itemconfigure [format "%s%s%s" link ? $idi ] -state hidden
  6871. }
  6872. }
  6873. }
  6874. # background tree
  6875. set pattern [format "%s%s" $n *]
  6876. foreach idi $B($t,bgs) {
  6877. if {[string match $pattern $B(BGSnod,$idi)] == 1 } {
  6878. if {[$w itemcget [format "%s%s%s" BGS ? $idi] -state] != "hidden"} {
  6879. $w addtag $TAG withtag [format "%s%s%s" BGS ? $idi]
  6880. $w itemconfigure [format "%s%s%s" BGS ? $idi] -state hidden
  6881. }
  6882. }
  6883. }
  6884. ### mem & text a afficher en D3
  6885. lappend B($t,shi) $id
  6886. set B(SHInod,$id) $n
  6887. set B(SHItxt,$id) -
  6888. set B(SHItre,$id) $t
  6889. set B(SHIcol,$id) $S(col)
  6890. set B(SHIsta,$id) normal
  6891. # UNDO
  6892. set S(und) "Abstraction::ShrinkUn $w $t $id"
  6893. return $id
  6894. }
  6895. ###
  6896. proc Shrink {w t n {txt user}} {
  6897. global T S B IMGshn
  6898. set id [format "%s%s" $t [Tools::GenId]]
  6899. # le tag commun a tous les items qui vont passer en mode hidden
  6900. set TAG [format "%s%s%s" SHI ? $id]
  6901. if {[lsearch -exact $B($t,shi) $id] == -1} {
  6902. # dessin
  6903. set c0 [$w coords $n]
  6904. set x0 [lindex $c0 2]
  6905. set y0 [lindex $c0 3]
  6906. $w create text [expr $x0 +5] $y0 -text + \
  6907. -tags "SHRINK [format "%s%s%s" SHN ? $id] T$t" -font $S(gfo) -fill $S(col)
  6908. # BLL
  6909. set pattern [format "%s%s" $n *]
  6910. foreach idbll $B($t,bll) {
  6911. if {[string match $pattern $B(BLLnod,$idbll)] == 1 } {
  6912. if {[$w itemcget $B(BLLidt,$idbll) -state] != "hidden"} {
  6913. $w addtag $TAG withtag $B(BLLidt,$idbll)
  6914. $w addtag $TAG withtag $B(BLLidl,$idbll)
  6915. $w itemconfigure $B(BLLidt,$idbll) -state hidden
  6916. $w itemconfigure $B(BLLidl,$idbll) -state hidden
  6917. }
  6918. }
  6919. }
  6920. # leaves
  6921. set leafs [Tools::NodeNoToLe $t $n]
  6922. foreach i $leafs {
  6923. set tagi [list [format "%s%s" EUL $T($t,ctl,$i)] && T$t]
  6924. if {[$w itemcget $tagi -state] != "hidden"} {
  6925. $w addtag $TAG withtag $tagi
  6926. $w itemconfigure $tagi -state hidden
  6927. }
  6928. }
  6929. # background leaves
  6930. set pattern [format "%s%s" $n *]
  6931. foreach idi $B($t,bgl) {
  6932. if {[string match $pattern $B(BGLnod,$idi)] == 1 } {
  6933. if {[$w itemcget [format "%s%s%s" BGL ? $idi] -state] != "hidden"} {
  6934. $w addtag $TAG withtag [format "%s%s%s" BGL ? $idi]
  6935. $w itemconfigure [format "%s%s%s" BGL ? $idi] -state hidden
  6936. }
  6937. }
  6938. }
  6939. # arretes terminales
  6940. set Le [Tools::NodeNoToLe $t $n]
  6941. foreach e $Le {
  6942. if {[$w itemcget $e -state] != "hidden"} {
  6943. $w addtag $TAG withtag $e
  6944. $w itemconfigure $e -state hidden
  6945. }
  6946. }
  6947. # tree
  6948. set lchild [Tools::NodeNoCoFaToNoCoCh $t $n]
  6949. foreach i $lchild {
  6950. if {[$w itemcget $i -state] != "hidden"} {
  6951. $w addtag $TAG withtag [format "%s%s" $i C]
  6952. $w itemconfigure [format "%s%s" $i C] -state hidden
  6953. }
  6954. }
  6955. # ova (en fait que le link)
  6956. set pattern [format "%s%s" $n *]
  6957. foreach idi $B($t,ova) {
  6958. if {[string match $pattern $B(OVAnod1,$idi)] == 1 } {
  6959. if {[$w itemcget [format "%s%s%s" BGS ? $idi] -state] != "hidden"} {
  6960. $w addtag $TAG withtag [format "%s%s%s" link ? $idi ]
  6961. $w itemconfigure [format "%s%s%s" link ? $idi ] -state hidden
  6962. }
  6963. }
  6964. }
  6965. # background tree
  6966. set pattern [format "%s%s" $n *]
  6967. foreach idi $B($t,bgs) {
  6968. if {[string match $pattern $B(BGSnod,$idi)] == 1 } {
  6969. if {[$w itemcget [format "%s%s%s" BGS ? $idi] -state] != "hidden"} {
  6970. $w addtag $TAG withtag [format "%s%s%s" BGS ? $idi]
  6971. $w itemconfigure [format "%s%s%s" BGS ? $idi] -state hidden
  6972. }
  6973. }
  6974. }
  6975. # sous shrink
  6976. set pattern [format "%s%s" $n *]
  6977. foreach idi $B($t,shi) {
  6978. if {[string match $pattern $B(SHInod,$idi)] == 1 } {
  6979. if {[$w itemcget [format "%s%s%s" SHN ? $idi] -state] != "hidden"} {
  6980. $w addtag $TAG withtag [format "%s%s%s" SHN ? $idi]
  6981. $w itemconfigure [format "%s%s%s" SHN ? $idi] -state hidden
  6982. set B(SHIsta,$idi) hidden
  6983. }
  6984. }
  6985. }
  6986. ### mem & text a afficher en D3
  6987. lappend B($t,shi) $id
  6988. set B(SHInod,$id) $n
  6989. set B(SHItxt,$id) $txt
  6990. set B(SHItre,$id) $t
  6991. set B(SHIcol,$id) $S(col)
  6992. set B(SHIfon,$id) $S(gfo)
  6993. set B(SHIsta,$id) normal
  6994. # UNDO
  6995. set S(und) "Abstraction::ShrinkUn $w $t $id"
  6996. return $id
  6997. }
  6998. }
  6999. ### comme shrink mais array seuleument col argument en plus
  7000. proc Shrink2 {w t n col {txt user} } {
  7001. global T S B IMGshn
  7002. set id [format "%s%s" $t [Tools::GenId]]
  7003. lappend B($t,shi) $id
  7004. set B(SHInod,$id) $n
  7005. set B(SHItxt,$id) $txt
  7006. set B(SHItre,$id) $t
  7007. set B(SHIcol,$id) $col
  7008. set B(SHIsta,$id) normal
  7009. }
  7010. ###
  7011. proc ShrinkUn {w t id} {
  7012. global B S
  7013. if {[lsearch -exact $B($t,shi) $id] != -1} {
  7014. set p [format "%s%s%s" SHI ? $id]
  7015. set litems [$w find withtag $p]
  7016. foreach j $litems {
  7017. $w itemconfigure $j -state normal
  7018. $w dtag $j $p
  7019. }
  7020. $w delete [format "%s%s%s" SHN ? $id]
  7021. # UNDO
  7022. set S(und) "Abstraction::Shrink $w $t $B(SHInod,$id)"
  7023. #mise a jour array B
  7024. set index [lsearch -exact $B($t,shi) $id]
  7025. set B($t,shi) [concat [lrange $B($t,shi) 0 [expr $index - 1]] \
  7026. [lrange $B($t,shi) [expr $index + 1] end]]
  7027. unset B(SHIsta,$id) ; unset B(SHItre,$id) ; unset B(SHItxt,$id) ; unset B(SHIcol,$id) ; unset B(SHInod,$id)
  7028. }
  7029. }
  7030. proc ShrinkUnAll {w t} {
  7031. global B
  7032. foreach id $B($t,shi) {
  7033. ShrinkUn $w $t $id
  7034. }
  7035. }
  7036. # unshrink sachant une liste de node
  7037. proc ShrinkUnLN {w t ln} {
  7038. global B
  7039. set lnshi {}
  7040. foreach id $B($t,shi) {
  7041. lappend lnshi $B(SHInod,$id)
  7042. set transit($B(SHInod,$id)) $id
  7043. }
  7044. foreach n $ln {
  7045. if {[lsearch $lnshi $n] != -1} {
  7046. ShrinkUn $w $t $transit($n)
  7047. }
  7048. }
  7049. if [array exists transit] {unset transit}
  7050. }
  7051. ###
  7052. proc ShrinkNodeUpdateColor {w i} {
  7053. global B S
  7054. set tags [$w gettags $i]
  7055. $w itemconfigure $i -fill $S(col)
  7056. set type [$w type $i]
  7057. if {$type == "polygon"} {
  7058. $w itemconfigure $i -outline $S(col)
  7059. }
  7060. set id [lindex [split [lindex $tags [lsearch -glob $tags SHN*]] ?] end]
  7061. set B(SHIcol,$id) $S(col)
  7062. }
  7063. #
  7064. proc LeafShrink {w t leu} {
  7065. global T S B
  7066. # leaves
  7067. foreach i $leu {
  7068. set tagi [list [format "%s%s" EUL $i] && T$t]
  7069. $w itemconfigure $tagi -state hidden
  7070. }
  7071. # background leaves
  7072. set ln [Operation::FindFatherNode $t $leu]
  7073. foreach n $ln {
  7074. set pattern [format "%s%s" $n *]
  7075. foreach idi $B($t,bgl) {
  7076. if {[string match $pattern $B(BGLnod,$idi)] == 1 } {
  7077. $w itemconfigure [format "%s%s%s" BGL ? $idi] -state hidden
  7078. }
  7079. }
  7080. }
  7081. }
  7082. #
  7083. proc LeafUnShrink {w t leu} {
  7084. global T S B
  7085. # leaves
  7086. foreach i $leu {
  7087. set tagi [list [format "%s%s" EUL $i] && T$t]
  7088. $w itemconfigure $tagi -state normal
  7089. }
  7090. # background leaves
  7091. set ln [Operation::FindFatherNode $t $leu]
  7092. foreach n $ln {
  7093. set pattern [format "%s%s" $n *]
  7094. foreach idi $B($t,bgl) {
  7095. if {[string match $pattern $B(BGLnod,$idi)] == 1 } {
  7096. $w itemconfigure [format "%s%s%s" BGL ? $idi] -state normal
  7097. }
  7098. }
  7099. }
  7100. }
  7101. ### SHRINK OPEN/CLOSE NEXT LEVEL
  7102. proc NodeOpen {{w ?}} {
  7103. global S T
  7104. if {$w == "?"} {set w [format "%s%s%s" .t $S(ict) .c]}
  7105. set t [string range $w 2 [expr [string first .c $w] -1]]
  7106. if {$T($t,currentlevel) == "?"} {
  7107. set level $T($t,tot)
  7108. } elseif {$T($t,currentlevel) == $T($t,tot) } {
  7109. set level $T($t,tot)
  7110. } else {set level $T($t,currentlevel)}
  7111. if {$level != $T($t,tot)} {
  7112. set T($t,currentlevel) [expr $level + 1]
  7113. foreach i $T($t,cbg,$level) {
  7114. set bg [format "%s%s" $i g]
  7115. set bd [format "%s%s" $i d]
  7116. foreach n [list $bg $bd] {
  7117. if {$S(DebugMod) == 1} {
  7118. puts "LEVEL: $level // NODES $T($t,cbg,$level)"
  7119. puts "NODE: $n"
  7120. }
  7121. set Le [TRE::NoToLe $t $n]
  7122. set T($t,lsk) [TRE::SousL $T($t,lsk) $Le]
  7123. set T($t,nsk) [TRE::SousL $T($t,nsk) $n]
  7124. $w delete Z
  7125. }
  7126. }
  7127. }
  7128. TRE::ArrayToCanvasRedisplay $t
  7129. }
  7130. #
  7131. proc NodeClose {{w ?}} {
  7132. global T S
  7133. if {$w == "?"} {set w [format "%s%s%s" .t $S(ict) .c]}
  7134. set t [string range $w 2 [expr [string first .c $w] -1]]
  7135. if {$T($t,currentlevel) == "?"} {
  7136. set level [expr $T($t,tot) - 1]
  7137. } elseif {$T($t,currentlevel) == 0 } {
  7138. set level 0
  7139. } else {set level [expr $T($t,currentlevel) - 1]}
  7140. if {$T($t,currentlevel) != 0} {
  7141. set T($t,currentlevel) $level
  7142. foreach i $T($t,cbg,$level) {
  7143. set bg [format "%s%s" $i g]
  7144. set bd [format "%s%s" $i d]
  7145. foreach n [list $bg $bd] {
  7146. set tagshrink [format "%s%s" $i S]
  7147. set tags [$w gettags [$w find withtag $n]]
  7148. set c0 [$w coords $n]
  7149. if {$S(DebugMod) == 1} {
  7150. puts "LEVEL: $level // NODES $T($t,cbg,$level)"
  7151. puts "NODE: $n // TAGS: $tags"
  7152. }
  7153. set x0 [lindex $c0 2]
  7154. set y0 [lindex $c0 1]
  7155. set Le [TRE::NoToLe $t $n]
  7156. set T($t,lsk) [concat $T($t,lsk) $Le]
  7157. set T($t,nsk) [concat $T($t,nsk) $n]
  7158. foreach e $Le {$w delete $e}
  7159. set lchild [TRE::NoCoFaToNoCoCh $t $n]
  7160. foreach i $lchild {
  7161. $w delete [format "%s%s" $i C]
  7162. $w delete [format "%s%s" $i R] ;# Box
  7163. }
  7164. $w create oval [expr $x0 +2] $y0 [expr $x0 +5] [expr $y0 +3] \
  7165. -outline $T($t,gfg) -fill $T($t,gbg) \
  7166. -tags "$tags L LH Z $tagshrink $Le SHRINK"
  7167. }
  7168. }
  7169. }
  7170. }
  7171. ### Simplification sur la base d'une valeur seuil de bootstrap
  7172. proc NodeOpenClose {{w ?} mode} {
  7173. global T S
  7174. if {$w == "?"} {set w [format "%s%s%s" .t $S(ict) .c]}
  7175. set t [string range $w 2 [expr [string first .c $w] -1]]
  7176. set l {}
  7177. foreach n $T($t,all_cod) {
  7178. if {$n != 0 && [lsearch $T($t,ue_cod) $n] == -1} {
  7179. if {$T($t,dbv,$n) != "?" && $T($t,dbv,$n) != "" && $T($t,dbv,$n) <= $S(lim)} {
  7180. lappend l $n
  7181. }
  7182. }
  7183. }
  7184. set lsup [TRE::FaNoId {} $l]
  7185. # CLOSE
  7186. if {$mode == "c"} {
  7187. foreach i $lsup {
  7188. set n $i
  7189. set tagshrink [format "%s%s" $i S]
  7190. set tags [$w gettags [$w find withtag $n]]
  7191. set c0 [$w coords $n]
  7192. if {$c0 != ""} {
  7193. set x0 [lindex $c0 2]
  7194. set y0 [lindex $c0 1]
  7195. set Le [TRE::NoToLe $t $n]
  7196. set T($t,lsk) [concat $T($t,lsk) $Le]
  7197. set T($t,nsk) [concat $T($t,nsk) $n]
  7198. foreach e $Le {$w delete $e}
  7199. set lchild [TRE::NoCoFaToNoCoCh $t $n]
  7200. foreach i $lchild {
  7201. $w delete [format "%s%s" $i C]
  7202. $w delete [format "%s%s" $i R] ;# Box
  7203. }
  7204. $w create oval [expr $x0 +2] $y0 [expr $x0 +5] [expr $y0 +3] \
  7205. -outline $T($t,gfg) -fill $T($t,gbg) \
  7206. -tags "$tags L LH Z $tagshrink $Le SHRINK"
  7207. }
  7208. }
  7209. }
  7210. # OPEN
  7211. if {$mode == "o"} {
  7212. foreach i $lsup {
  7213. set Le [TRE::NoToLe $t $i]
  7214. set T($t,lsk) [TRE::SousL $T($t,lsk) $Le]
  7215. set T($t,nsk) [TRE::SousL $T($t,nsk) $i]
  7216. $w delete Z
  7217. }
  7218. }
  7219. TRE::ArrayToCanvasRedisplay $t
  7220. }
  7221. #
  7222. proc AbsGo {} {
  7223. global S abs
  7224. if {[.abs.lfb.l get 0 end] != {}} {
  7225. # liste de tree target
  7226. set lkv [array get S *,tar]
  7227. set ltreetarget {}
  7228. foreach {k v} $lkv {
  7229. if {$S($k) == 1} {
  7230. lappend ltreetarget [string range $k 0 [expr [string first , $k] - 1]]
  7231. }
  7232. }
  7233. # feuilles en selection
  7234. # si on est en remove, la liste des feuilles est la
  7235. # liste des feuilles available moins la liste des feuilles en selection
  7236. switch $abs(What) {
  7237. display {
  7238. set EUS [.abs.lfb.l get 0 end]
  7239. }
  7240. hidden {
  7241. set EUS [Tools::SousL [.abs.lfa.l get 0 end] [.abs.lfb.l get 0 end]]
  7242. }
  7243. }
  7244. #
  7245. switch $abs(Mode) {
  7246. shrink {
  7247. # pour chaque tree en target identifier SHRINK
  7248. # des noeuds pere sachant la liste leaf en selection
  7249. foreach t $ltreetarget {
  7250. set peres [FindFatherNode $t $EUS]
  7251. foreach e $peres {
  7252. Shrink $S($t,w) $t $e "Leaves Abstraction"
  7253. }
  7254. }
  7255. }
  7256. collapse {
  7257. # pour chaque tree en target identifier COLLAPSE
  7258. # des noeuds pere sachant la liste leaf en selection
  7259. foreach t $ltreetarget {
  7260. NewickAbstract $S($t,w) $t $EUS
  7261. }
  7262. }
  7263. }
  7264. }
  7265. }
  7266. # mise a jour liste des feuilles en fonction des arbres en target
  7267. proc AbsAddAvailableLeaves {} {
  7268. global S abs T
  7269. # liste de tree target
  7270. set lkv [array get S *,tar]
  7271. set ltreetarget {}
  7272. foreach {k v} $lkv {
  7273. if {$S($k) == 1} {
  7274. lappend ltreetarget [string range $k 0 [expr [string first , $k] - 1]]
  7275. }
  7276. }
  7277. # construction de la liste des feuilles de tous lmes arbres en selection
  7278. # liste sans repetitions, classe par ordre alpha et respectant le filtre
  7279. set leu {}
  7280. if {$abs(stringsearch) != "*"} {
  7281. foreach t $ltreetarget {
  7282. foreach i $T($t,ue_lab) {
  7283. if {[string match $abs(stringsearch) $i]} {lappend leu $i }
  7284. }
  7285. }
  7286. } else {
  7287. foreach t $ltreetarget {
  7288. set leu [concat $leu $T($t,ue_lab)]
  7289. }
  7290. }
  7291. if {[llength $ltreetarget] != 1} {set leu [Tools::DelRep $leu]}
  7292. set leu [lsort -dictionary $leu]
  7293. # remplissage listbox
  7294. .abs.lfa.l delete 0 end
  7295. eval {.abs.lfa.l insert end} $leu
  7296. # reconfiguration background des feuilles de la listbox
  7297. # pour celles deja en selection
  7298. if {[.abs.lfb.l get 0 end] != {}} {AbsConfigBg}
  7299. # mise ajour nb de feuille availabale
  7300. set abs(nbLavailable) [llength [.abs.lfa.l get 0 end]]
  7301. }
  7302. # l'utilisateur modifie le filtre, mise a jour de la listbox des feuilles available
  7303. # attention respect de la casse
  7304. proc AbsUpdateActionFilter {} {
  7305. Abstraction::AbsAddAvailableLeaves
  7306. }
  7307. # config bg si deja en selection
  7308. proc AbsConfigBg {} {
  7309. global S
  7310. set li {}
  7311. set lavailable [.abs.lfa.l get 0 end] ;# feuilles available
  7312. .abs.lfa.l delete 0 end
  7313. eval {.abs.lfa.l insert end} $lavailable
  7314. set selectL [.abs.lfb.l get 0 end] ;# feuilles en selection
  7315. foreach e $selectL {
  7316. set r [lsearch $lavailable $e]
  7317. if {$r != -1} {lappend li $r}
  7318. }
  7319. foreach i $li {
  7320. .abs.lfa.l itemconfigure $i -background NavajoWhite2
  7321. }
  7322. }
  7323. #
  7324. proc AbsaddLeafMouse {listbox x y} {
  7325. global S abs
  7326. set leaf [$listbox get @$x,$y]
  7327. set selectL [.abs.lfb.l get 0 end]
  7328. if {[lsearch $selectL $leaf] == -1} {
  7329. .abs.lfb.l insert 0 $leaf
  7330. }
  7331. .abs.lfa.l selection clear @$x,$y
  7332. AbsConfigBg
  7333. set abs(nbLselection) [llength [.abs.lfb.l get 0 end]]
  7334. }
  7335. # boutton ajout de la selection leave available dans la liste selection
  7336. proc AbsAddL {} {
  7337. global S abs
  7338. # mise a jour listbox fichiers selection
  7339. # on conserve l'ordre des groupes de selection
  7340. set li [.abs.lfa.l curselection] ;# des index
  7341. set lsel {}
  7342. foreach i $li {
  7343. lappend lsel [.abs.lfa.l get $i]
  7344. .abs.lfa.l itemconfigure $i -background NavajoWhite2
  7345. }
  7346. set lall2 [.abs.lfb.l get 0 end]
  7347. .abs.lfb.l delete 0 end
  7348. # c moche je sais
  7349. foreach e $lsel {
  7350. lappend lall2 $e
  7351. }
  7352. #
  7353. foreach e [Tools::DelRep $lall2] {
  7354. .abs.lfb.l insert 0 $e
  7355. }
  7356. # deselection des fichiers liste available
  7357. .abs.lfa.l selection clear 0 end
  7358. # update nb de tree total
  7359. set abs(nbLselection) [llength $lall2]
  7360. }
  7361. #
  7362. proc AbsRemL {} {
  7363. global abs
  7364. # attention retrait a partir de l'index le plus bat
  7365. # le delete remet a jour les index
  7366. set li [lsort -decreasing [.abs.lfb.l curselection]] ;# des index
  7367. foreach i $li {
  7368. .abs.lfb.l delete $i
  7369. }
  7370. # deselection des fichiers liste available
  7371. .abs.lfa.l selection clear 0 end
  7372. set abs(nbLselection) [llength [.abs.lfb.l get 0 end]]
  7373. AbsConfigBg
  7374. }
  7375. #
  7376. proc AbsremLeafMouse {listbox x y} {
  7377. global S abs
  7378. $listbox delete @$x,$y
  7379. AbsConfigBg
  7380. set abs(nbLselection) [llength [.abs.lfb.l get 0 end]]
  7381. }
  7382. ### OPTIMISATION : si un node est ok : ne pas tester ses nodes fils
  7383. proc FindFatherNode {t SouRefLea} {
  7384. global S T
  7385. set L {}
  7386. if {[llength $SouRefLea] != 1} {
  7387. foreach TarCodNod [lsort -dictionary $T($t,all_cod)] {
  7388. # selection des codes leaf issus de node
  7389. set TarCodLea [Tools::NodeNoToLe $t $TarCodNod]
  7390. # passage codes leaf -> references leaf
  7391. set TarRefLea [Tools::NodeLeCoToRe $t $TarCodLea]
  7392. # test inclusion des references leaf de TARGET avec SOURCE
  7393. if {$S(nodefilter) == 0} {
  7394. set r [Tools::ListInclu $TarRefLea $SouRefLea]
  7395. if {$r == 1} {lappend L $TarCodNod}
  7396. } else {
  7397. set r [Tools::ListIncluSauf $TarRefLea $SouRefLea $S(nodefilter)]
  7398. if {$r == 1} {lappend L $TarCodNod}
  7399. }
  7400. }
  7401. # meme node pere possibles
  7402. # differents nodes peres possibles
  7403. # -> identification des nodes peres de plus haut niveau
  7404. set l [Tools::NodeFaNoId {} $L]
  7405. if {$L == {}} {return {}} {return $l}
  7406. } {
  7407. if {[lsearch -exact $T($t,ue_lab) $SouRefLea] != -1} {return $T($t,ltc,$SouRefLea)} else {return {}}
  7408. }
  7409. }
  7410. }
  7411. ####################
  7412. ####################
  7413. # LOCALISATION
  7414. ####################
  7415. namespace eval Localisation {
  7416. ###
  7417. proc LocalisationEU {w t EUS } {
  7418. Operation::Operation $w $t $EUS
  7419. }
  7420. ###
  7421. proc LocalisationDB {w t database var val } {
  7422. global S
  7423. set S(query) [format "%s%s%s" $var " == " $val]
  7424. set records [Database::dbQueryRecordsFromVarVal $database $var $val]
  7425. set EUS [Database::dbQueryEusFromRecords $database $records]
  7426. Operation::Operation $w $t $EUS
  7427. }
  7428. }
  7429. ####################
  7430. ####################
  7431. # IDENTIFICATION
  7432. ####################
  7433. namespace eval Identification {
  7434. #
  7435. proc SelectUpdateAscend {t SouRefLea} {
  7436. global S
  7437. if {$S(nodefilter) == 0} {
  7438. SelectUpdateAscendOriginal $t $SouRefLea
  7439. } else {
  7440. SelectUpdateAscendSauf $t $SouRefLea
  7441. }
  7442. }
  7443. ### OPTIMISATION : si un node est ok : ne pas tester ses nodes fils
  7444. proc SelectUpdateAscendOriginal {t SouRefLea} {
  7445. global S T
  7446. set L {}
  7447. if {[llength $SouRefLea] != 1} {
  7448. foreach TarCodNod [lsort -dictionary $T($t,all_cod)] {
  7449. # selection des codes leaf issus de node
  7450. set TarCodLea [Tools::NodeNoToLe $t $TarCodNod]
  7451. # passage codes leaf -> references leaf
  7452. set TarRefLea [Tools::NodeLeCoToRe $t $TarCodLea]
  7453. # test inclusion des references leaf de TARGET avec SOURCE
  7454. if {$S(nodefilter) == 0} {
  7455. set r [Tools::ListInclu $TarRefLea $SouRefLea]
  7456. if {$r == 1} {lappend L $TarCodNod}
  7457. } else {
  7458. set r [Tools::ListIncluSauf $TarRefLea $SouRefLea $S(nodefilter)]
  7459. if {$r == 1} {lappend L $TarCodNod}
  7460. }
  7461. }
  7462. # meme node pere possibles
  7463. # differents nodes peres possibles
  7464. # -> identification des nodes peres de plus haut niveau
  7465. set l [Tools::NodeFaNoId {} $L]
  7466. if {$L == {}} {return {}} {return $l}
  7467. } {return $T($t,ltc,$SouRefLea) }
  7468. }
  7469. ### OPTIMISATION : si un node est ok : ne pas tester ses nodes fils
  7470. proc SelectUpdateAscendSauf {t SouRefLea} {
  7471. global S T
  7472. set L {}
  7473. # on ne prend pas en compte les codes des feuilles
  7474. set latest [Tools::SousL $T($t,all_cod) $T($t,ue_cod)]
  7475. if {[llength $SouRefLea] != 1} {
  7476. foreach TarCodNod [lsort -dictionary $latest] {
  7477. # selection des codes leaf issus de node
  7478. set TarCodLea [Tools::NodeNoToLe $t $TarCodNod]
  7479. # passage codes leaf -> references leaf
  7480. set TarRefLea [Tools::NodeLeCoToRe $t $TarCodLea]
  7481. # test inclusion des references leaf de TARGET avec SOURCE
  7482. set r [Tools::ListIncluSauf $TarRefLea $SouRefLea $S(nodefilter)]
  7483. if {$r == 1} {lappend L $TarCodNod}
  7484. }
  7485. # meme node pere possibles
  7486. # differents nodes peres possibles
  7487. # -> identification des nodes peres de plus haut niveau
  7488. set l [Tools::NodeFaNoId {} $L]
  7489. if {$L == {}} {return {}} {return $l}
  7490. } {return $T($t,ltc,$SouRefLea) }
  7491. }
  7492. ###
  7493. proc InitGraph {} {
  7494. global S
  7495. foreach key [array names S *,tar] {
  7496. if {$S($key) == 1} {
  7497. set t [string range $key 0 [expr [string first , $key] - 1]]
  7498. Figuration::NodeGraVarInit $t
  7499. }
  7500. }
  7501. }
  7502. ### Bulle Labels : UEs
  7503. proc InsertBulUE {w x y i} {
  7504. global S T
  7505. set tags [$w gettags $i]
  7506. set t [string range [lindex $tags [lsearch -glob $tags T*]] 1 end]
  7507. set n [string trimright [lindex $tags [lsearch -glob $tags *C]] C]
  7508. if {[lsearch -exact $T($t,all_cod) $n] != -1} {
  7509. set La {}
  7510. set SouCodLea [Tools::NodeNoToLe $t $n]
  7511. set UE [lsort -dictionary [Tools::NodeLeCoToRe $t $SouCodLea]]
  7512. foreach i $UE {
  7513. regsub -all {?} $i " " texti
  7514. lappend La $texti
  7515. #lappend La [string toupper $i]
  7516. }
  7517. Annotation::BLLmake $w $t $x $y \
  7518. [format "%s%s" [llength $La] " Leaves : "]\
  7519. [Tools::FormatText $La] $n
  7520. }
  7521. }
  7522. ### Bulle Labels : DB
  7523. proc InsertBulDBCommonTags {w x y i} {
  7524. global S T db
  7525. set tags [$w gettags $i]
  7526. set t [string range [lindex $tags [lsearch -glob $tags T*]] 1 end]
  7527. set n [string trimright [lindex $tags [lsearch -glob $tags *C]] C]
  7528. set euls [Tools::NodeLeCoToRe $t [Tools::NodeNoToLe $t $n]]
  7529. set lrecords {}
  7530. set database $S(database)
  7531. if {$database != ""} {
  7532. foreach eu $euls {
  7533. lappend lrecords [Database::dbQueryRecordsFromVarVal $database EU $eu]
  7534. }
  7535. # pour chaque record on reduit la A-List a une liste de var#val (concat)
  7536. # on a donc une liste de liste, on cherche l'intersection
  7537. upvar #0 $database X
  7538. set ll {}
  7539. foreach record $lrecords {
  7540. set l {}
  7541. foreach {var val} $X($record) {
  7542. lappend l [format "%s%s%s" $var = $val]
  7543. }
  7544. lappend ll $l
  7545. }
  7546. set intersection [lsort -dictionary [Tools::operatorANDll $ll]]
  7547. # ?
  7548. #lappend intersection
  7549. Annotation::BLLmake $w $t $x $y \
  7550. [format "%s%s" [llength $intersection] " Labels (Common, $database) : "]\
  7551. [Tools::FormatText $intersection] $n
  7552. }
  7553. }
  7554. ### LABEL : NODE / Intersection Variables-Modalites avec Specificite
  7555. proc InsertBulDBSpecificTags {w x y i} {
  7556. global S T db
  7557. set tags [$w gettags $i]
  7558. set t [string range [lindex $tags [lsearch -glob $tags T*]] 1 end]
  7559. set n [string trimright [lindex $tags [lsearch -glob $tags *C]] C]
  7560. set euls [Tools::NodeLeCoToRe $t [Tools::NodeNoToLe $t $n]]
  7561. set lrecords {}
  7562. set database $S(database)
  7563. if {$database != ""} {
  7564. foreach eu $euls {
  7565. lappend lrecords [dbQueryRecordsFromVarVal $database EU $eu]
  7566. }
  7567. # pour chaque record on reduit la A-List a une liste de var=val (concat)
  7568. # on a donc une liste de liste, on cherche l'intersection
  7569. upvar #0 $database X
  7570. set ll {}
  7571. foreach record $lrecords {
  7572. set l {}
  7573. foreach {var val} $X($record) {
  7574. lappend l [format "%s%s%s" $var = $val]
  7575. }
  7576. lappend ll $l
  7577. }
  7578. #
  7579. set intersection [lsort -dictionary [Tools::operatorANDll $ll]]
  7580. }
  7581. }
  7582. #
  7583. proc InsertBulDBCouple {w t x y n couple} {
  7584. global S
  7585. set database $S(database)
  7586. Annotation::BLLmake $w $t $x $y \
  7587. $database\
  7588. $couple $n
  7589. }
  7590. #
  7591. proc InsertVarVal {w t x y n} {
  7592. global S
  7593. set database $S(database)
  7594. set q $S(query)
  7595. Annotation::BLLmake $w $t [$w canvasx $x] [$w canvasy $y ] \
  7596. $database [lrange $q [expr [lsearch $q where] + 1] end] $n
  7597. }
  7598. proc InsertVarVal2 {w t x y n} {
  7599. global S
  7600. set database $S(database)
  7601. set q $S(query)
  7602. Annotation::BLLmake $w $t [$w canvasx $x] [$w canvasy $y ] \
  7603. $database [lindex $q end] $n
  7604. }
  7605. }
  7606. ####################
  7607. ####################
  7608. # ORIENTATION
  7609. ####################
  7610. namespace eval Orientation {
  7611. ### proc ok(sauf conformation circulaire)
  7612. ### nb : tourne sur T$t pour l'instant
  7613. ### le menu/submenu "orientation" du menu contextuel TREE
  7614. ### n'apparait pas si le type de l'arbre est circulaire
  7615. ### pour etendre Anchor aux vues circulaires : integrer la gestion des arcs
  7616. ### donc filtrer selon le type de l'item
  7617. proc Anchor {w t} {
  7618. global T S
  7619. set co [$w bbox T$t]
  7620. set wi [expr [lindex $co 2] - [lindex $co 0]]
  7621. set he [expr [lindex $co 3] - [lindex $co 1]]
  7622. set items [$w find withtag T$t]
  7623. set b [$w bbox T$t]
  7624. set x0 [lindex $b 3]
  7625. set x0prim [lindex $b 0]
  7626. foreach i $items {
  7627. set ic [$w coords $i]
  7628. set x1 [lindex $ic 0]
  7629. set y1 [lindex $ic 1]
  7630. set x2 [lindex $ic 2]
  7631. set y2 [lindex $ic 3]
  7632. switch [$w type $i] {
  7633. line {
  7634. $w coords $i [expr $x0 + ($x0 - $x1)] $y1 [expr $x0 + ($x0 - $x2)] $y2
  7635. }
  7636. text {
  7637. $w coords $i [expr $x0 + ($x0 - $x1)] $y1
  7638. $w itemconfigure $i -anchor e
  7639. }
  7640. }
  7641. }
  7642. $w move T$t [expr $x0prim - $x0] 0
  7643. Figuration::RestaureT $w $t
  7644. }
  7645. }
  7646. ####################
  7647. ####################
  7648. # CONFORMATION
  7649. ####################
  7650. namespace eval Conformation {
  7651. # Stage de Alex Guez
  7652. ###
  7653. proc Swap {w {t ?} {n ?}} {
  7654. global S
  7655. if {$n == "?" } {
  7656. set tags [$w gettags [$w find withtag current]]
  7657. set t [string range [lindex $tags [lsearch -glob $tags T*]] 1 end]
  7658. set n [string trimright [lindex $tags [lsearch -glob $tags *C]] C]
  7659. }
  7660. #
  7661. if {$t != "" && $n != ""} {
  7662. SwapOperation $w $t $n
  7663. Figuration::RedrawT $w $t
  7664. Navigation::FitToContents $w
  7665. }
  7666. }
  7667. ###
  7668. proc SwapOperation {w {t ?} {n ?}} {
  7669. global T S B
  7670. if {$n == $t} {
  7671. set gen $t
  7672. set sg [format "%s%s" $gen g]
  7673. set sd [format "%s%s" $gen d]
  7674. } else {
  7675. set gen [expr [llength [split $n {g d}]] - 1]
  7676. set sg [format "%s%s%s" $n $gen g]
  7677. set sd [format "%s%s%s" $n $gen d]
  7678. }
  7679. set NoCoFaToNoCoCh [Tools::NodeNoCoFaToNoCoCh $t $n]
  7680. set SouCodLeaALL $T($t,ue_cod)
  7681. set SouRefLeaALL $T($t,ue_lab)
  7682. set SouCodLeaG [Tools::NodeNoToLe $t $sg]
  7683. set SouRefLeaG [Tools::NodeLeCoToRe $t $SouCodLeaG]
  7684. set SouCodLeaD [Tools::NodeNoToLe $t $sd]
  7685. set SouRefLeaD [Tools::NodeLeCoToRe $t $SouCodLeaD]
  7686. ### T ARRAY MAJ T(t,xxx,from n)
  7687. # ne pas utiliser l'option -all avec les regsub, car 0g* matche 10g*
  7688. set pg [format "%s%s" $sg *]
  7689. set pd [format "%s%s" $sd *]
  7690. set kvg [array get T $t,*,$pg]
  7691. set kvd [array get T $t,*,$pd]
  7692. foreach {key value} $kvd {unset T($key)}
  7693. foreach {key value} $kvg {unset T($key)}
  7694. foreach {key value} $kvg {
  7695. regsub $sg $key $sd keyswi ; set T($keyswi) $value
  7696. }
  7697. foreach {key value} $kvd {
  7698. regsub $sd $key $sg keyswi ; set T($keyswi) $value
  7699. }
  7700. ### T ARRAY MAJ T(t,ltc,*)
  7701. foreach codeleaf $SouCodLeaG nameleaf $SouRefLeaG {
  7702. regsub $sg $T($t,ltc,$nameleaf) \
  7703. $sd T($t,ltc,$nameleaf)
  7704. }
  7705. foreach codeleaf $SouCodLeaD nameleaf $SouRefLeaD {
  7706. regsub $sd $T($t,ltc,$nameleaf) \
  7707. $sg T($t,ltc,$nameleaf)
  7708. }
  7709. # si clic racine et si indice arbre 2 et arbre,tot =2 ca plante
  7710. for {set i 0} {$i < $T($t,tot)} {incr i} {
  7711. set codegene $T($t,cbg,$i)
  7712. set T($t,cbg,$i) {}
  7713. #puts "SWAP DEDANS iteration codegene= $codegene"
  7714. foreach e $codegene {
  7715. switch -glob $e \
  7716. $pg {regsub $sg $e $sd e ; lappend T($t,cbg,$i) $e} \
  7717. $pd {regsub $sd $e $sg e ; lappend T($t,cbg,$i) $e} \
  7718. default {lappend T($t,cbg,$i) $e}
  7719. }
  7720. puts "SWAP T($t,cbg,$i) $T($t,cbg,$i)"
  7721. }
  7722. ### T ARRAY MAJ T(t,all_cod)
  7723. set codall $T($t,all_cod)
  7724. set T($t,all_cod) {}
  7725. foreach e $codall {
  7726. switch -glob $e \
  7727. $pg {regsub $sg $e $sd e ; lappend T($t,all_cod) $e} \
  7728. $pd {regsub $sd $e $sg e ; lappend T($t,all_cod) $e} \
  7729. default {lappend T($t,all_cod) $e}
  7730. }
  7731. # B ARRAY MAJ B(BLLnod,$id)
  7732. set lkv [array get B BLLnod,*]
  7733. foreach {key value} $lkv {
  7734. switch -glob $value \
  7735. $pg {regsub $sg $value $sd value ; set B($key) $value} \
  7736. $pd {regsub $sd $value $sg value ; set B($key) $value} \
  7737. default {set B($key) $value}
  7738. }
  7739. # B ARRAY MAJ B(SHInod,$id)
  7740. set lkv [array get B SHInod,*]
  7741. foreach {key value} $lkv {
  7742. switch -glob $value \
  7743. $pg {regsub $sg $value $sd value ; set B($key) $value} \
  7744. $pd {regsub $sd $value $sg value ; set B($key) $value} \
  7745. default {set B($key) $value}
  7746. }
  7747. # B ARRAY MAJ B(OVAnod,$id)
  7748. set lkv [array get B OVAnod*,*]
  7749. foreach {key value} $lkv {
  7750. switch -glob $value \
  7751. $pg {regsub $sg $value $sd value ; set B($key) $value} \
  7752. $pd {regsub $sd $value $sg value ; set B($key) $value} \
  7753. default {set B($key) $value}
  7754. }
  7755. # B ARRAY MAJ B(BGSnod,$id)
  7756. set lkv [array get B BGSnod*,*]
  7757. foreach {key value} $lkv {
  7758. switch -glob $value \
  7759. $pg {regsub $sg $value $sd value ; set B($key) $value} \
  7760. $pd {regsub $sd $value $sg value ; set B($key) $value} \
  7761. default {set B($key) $value}
  7762. }
  7763. # B ARRAY MAJ B(BGSnod,$id)
  7764. set lkv [array get B BGLnod*,*]
  7765. foreach {key value} $lkv {
  7766. switch -glob $value \
  7767. $pg {regsub $sg $value $sd value ; set B($key) $value} \
  7768. $pd {regsub $sd $value $sg value ; set B($key) $value} \
  7769. default {set B($key) $value}
  7770. }
  7771. # B ARRAY MAJ B(CONnod,$id)
  7772. # ATTENTION value est une liste de node le switch ne passe pas si le node
  7773. # en question n'est pas en debut de liste, on passe tous les elements de value
  7774. # en revue
  7775. set lkv [array get B CONnod,*]
  7776. foreach {key value} $lkv {
  7777. foreach v $value {
  7778. switch -glob $v \
  7779. $pg {regsub $sg $value $sd value ; set B($key) $value} \
  7780. $pd {regsub $sd $value $sg value ; set B($key) $value} \
  7781. default {set B($key) $value}
  7782. }
  7783. }
  7784. set lkv [array get B CONnod,*]
  7785. ### T ARRAY MAJ T(t,ue_cod)
  7786. ### T ARRAY MAJ T(t,ue_lab)
  7787. ### ATTENTION LISTES ORDONNEES
  7788. set esup [lrange $SouRefLeaG 0 0]
  7789. set einf [lrange $SouRefLeaD end end]
  7790. set isup [lsearch $SouRefLeaALL $esup]
  7791. set iinf [lsearch $SouRefLeaALL $einf]
  7792. set T($t,ue_lab) [join [lreplace $SouRefLeaALL $isup $iinf $SouRefLeaD $SouRefLeaG]]
  7793. unset T($t,ue_cod)
  7794. foreach ref $T($t,ue_lab) {
  7795. lappend T($t,ue_cod) $T($t,ltc,$ref)
  7796. }
  7797. }
  7798. ### OUTGROUP
  7799. proc Outgroup {w mode {tsource ?} {n ?}} {
  7800. global T S B
  7801. if {$tsource == "?"} {
  7802. set id [$w find withtag current]
  7803. set tags [$w gettags $id]
  7804. set tsource [string range [lindex $tags [lsearch -glob $tags T*]] 1 end]
  7805. set n [string trimright [lindex $tags [lsearch -glob $tags *C]] C]
  7806. }
  7807. if {$n != "" && $n != $tsource} {
  7808. set co [$w bbox [list Z && T$tsource]]
  7809. set px [lindex $co 0]
  7810. set py [lindex $co 1]
  7811. set wi [expr [lindex $co 2] - [lindex $co 0]]
  7812. set he [expr [lindex $co 3] - [lindex $co 1]]
  7813. set t [expr [lrange [lsort -integer -increasing $S(ilt)] end end] + 1]
  7814. lappend S(ilt) $t
  7815. set T($t,nwk) [NewickReBuild $tsource $n]
  7816. ImportExport::TreeInit $t
  7817. if {[catch [ImportExport::NewickParser_Root $t $T($t,nwk)] result] != 0} {
  7818. ImpotExport::UpdateArrayCanvas $w $t
  7819. Interface::TreeDynMessage "Error"
  7820. } else {
  7821. set w2 [ImportExport::NewCanvas]
  7822. set S($t,w) $w2
  7823. set S($t,tit) $S($tsource,tit)
  7824. set S($t,type) $S($tsource,type)
  7825. lappend S($w2,t) $t
  7826. Conformation::ArrToCanType2 $t $w2 0 0 $wi $he
  7827. ImportExport::NodeBind $w2 $t
  7828. Operation::TreeViewerPanelUpdate
  7829. }
  7830. }
  7831. }
  7832. # outgroup tree meme window delete du tree precedent
  7833. proc Outgroup2 {w mode {tsource ?} {n ?}} {
  7834. global T S B
  7835. if {$tsource == "?"} {
  7836. set id [$w find withtag current]
  7837. set tags [$w gettags $id]
  7838. set tsource [string range [lindex $tags [lsearch -glob $tags T*]] 1 end]
  7839. set n [string trimright [lindex $tags [lsearch -glob $tags *C]] C]
  7840. }
  7841. if {$n != "" && $n != $tsource} {
  7842. set co [$w bbox [list Z && T$tsource]]
  7843. set px [lindex $co 0]
  7844. set py [lindex $co 1]
  7845. set wi [expr [lindex $co 2] - [lindex $co 0]]
  7846. set he [expr [lindex $co 3] - [lindex $co 1]]
  7847. set t [expr [lrange [lsort -integer -increasing $S(ilt)] end end] + 1]
  7848. lappend S(ilt) $t
  7849. set T($t,nwk) [NewickReBuild $tsource $n]
  7850. TDcom::TreeInit $t
  7851. if {[catch [ImportExport::NewickParser_Root $t $T($t,nwk)] result] != 0} {
  7852. ImportExport::UpdateArrayCanvas $w $t
  7853. #Interface::TreeDynMessage "Error"
  7854. } else {
  7855. #set w2 [ImportExport::NewCanvas]
  7856. set S($t,w) $w
  7857. set S($t,tit) $S($tsource,tit)
  7858. set S($t,type) $S($tsource,type)
  7859. lappend S($w,t) $t
  7860. TDcom::PhyNJ $t $w
  7861. #Conformation::ArrToCanType2 $t $w 0 0 $wi $he
  7862. #ImportExport::NodeBind $w $t
  7863. # delete tree
  7864. ImportExport::UpdateArrayCanvas $w $tsource
  7865. set S($t,tar) 1
  7866. #Operation::TreeViewerPanelUpdate
  7867. }
  7868. }
  7869. }
  7870. #
  7871. proc NewickReBuild {t n} {
  7872. global T
  7873. # 50%
  7874. set bl [expr 0.5 * $T($t,dbl,$n)]
  7875. if [catch {set test $T($t,dbv,$n)} res] {
  7876. set bv ""
  7877. } else {
  7878. set np [Tools::NodeParentNode $t $n]
  7879. set bv $T($t,dbv,$np)
  7880. }
  7881. # noeud pointe garde bv et bl/2 (50%)
  7882. set id [string last ":" $T($t,nwk,$n)]
  7883. set nwkn [format "%s%s%s" [string range $T($t,nwk,$n) 0 [expr $id - 1]] ":" $bl]
  7884. # brother node
  7885. set bn [Tools::NodeBrotherNode $n]
  7886. set nwkbn $T($t,nwk,$bn)
  7887. ###
  7888. set T(newick) [format "%s%s%s%s%s%s%s%s%s%s" "(" $nwkn ",(" $nwkbn "," xxx ")" ":" $bl ");"]
  7889. NewickReBuildRec $t $n
  7890. return $T(newick)
  7891. }
  7892. proc NewickReBuildRec {t n} {
  7893. global T
  7894. set nn [string trimleft $n $t]
  7895. switch -exact $nn {
  7896. d1d {NewickInsertFinal $t [format "%s%s" $t g]}
  7897. d1g {NewickInsertFinal $t [format "%s%s" $t g]}
  7898. g1d {NewickInsertFinal $t [format "%s%s" $t d]}
  7899. g1g {NewickInsertFinal $t [format "%s%s" $t d]}
  7900. default {
  7901. set pn [Tools::NodeParentNode $t $n]
  7902. set bn [Tools::NodeBrotherNode $pn]
  7903. NewickInsert $t $bn $pn
  7904. NewickReBuildRec $t $pn
  7905. }
  7906. }
  7907. }
  7908. ###
  7909. proc NewickInsert {t n no} {
  7910. global T
  7911. if [catch {set test $T($t,dbv,$no)} res] {
  7912. set bv ""
  7913. } else {
  7914. set np [Tools::NodeParentNode $t $n]
  7915. set bv $T($t,dbv,$no)
  7916. }
  7917. set ns [format "%s%s%s%s%s%s%s%s" ( xxx , $T($t,nwk,$n) ) $bv : $T($t,dbl,$no) ]
  7918. regsub "xxx" $T(newick) $ns T(newick)
  7919. }
  7920. ###
  7921. proc NewickInsertFinal {t n} {
  7922. global T
  7923. set bl [expr $T($t,dbl,[format "%s%s" $t g]) + $T($t,dbl,[format "%s%s" $t d])]
  7924. set id [string last ":" $T($t,nwk,$n)]
  7925. #set id [string last ")" $T($t,nwk,$n)]
  7926. set nwkn [format "%s%s%s" [string range $T($t,nwk,$n) 0 [expr $id - 1]] ":" $bl]
  7927. puts $T($t,nwk,$n)
  7928. puts $nwkn
  7929. regsub "xxx" $T(newick) $nwkn T(newick)
  7930. }
  7931. ###
  7932. proc NewickReBuildInit {t n} {
  7933. global T
  7934. set bn [Tools::NodeBrotherNode $n]
  7935. set bnd1 [expr 0.8 * $T($t,dbl,$bn)]
  7936. set bnd2 [expr 0.2 * $T($t,dbl,$bn)]
  7937. set tp2 [string last ":" $T($t,nwk,$bn)]
  7938. set nwk [string range $T($t,nwk,$bn) 0 [expr $tp2 - 1]]
  7939. if {[array exists T($t,dbv,$n)] == 0} {
  7940. set T(newick) [format "%s%s%s%s%s%s%s%s%s%s%s" \
  7941. "((" "xxx" "," $nwk ":" $bnd1 "):" $bnd2 "," $T($t,nwk,$n) ")" ]
  7942. } else {
  7943. set T(newick) [format "%s%s%s%s%s%s%s%s%s%s%s%s%s" \
  7944. "((" "xxx" "," $nwk ":" $bnd1 ")" $T($t,dbv,$n) ":" $bnd2 "," $T($t,nwk,$n) ")" ]
  7945. }
  7946. }
  7947. ### LADDER
  7948. proc Ladder {w t in m} {
  7949. global T S
  7950. set pg [format "%s%s%s" $in * g ]
  7951. set espaceg [array get T $t,dbl,$pg ]
  7952. set lcode {}
  7953. foreach {k v} $espaceg {
  7954. set codeg [string range $k [expr [string last "," $k] + 1] end]
  7955. set longcodeg [string length $codeg]
  7956. #set coded [format "%s%s" [string range $codeg 0 [expr $longcodeg - 2] ] d]
  7957. set coded [format "%s%s" [string trimright $codeg g] d]
  7958. set nbchildd [Tools::NodeNoToLeNum $t $coded]
  7959. set nbchildg [Tools::NodeNoToLeNum $t $codeg]
  7960. set cmd [list $nbchildd $m $nbchildg]
  7961. if $cmd {
  7962. set level [expr [regsub -all d $coded d pwet] + [regsub -all g $coded g pwet] -1]
  7963. set longpattern [string length [format "%s%s" $level d]]
  7964. set coco [string range $coded 0 [expr [string length $coded] - $longpattern -1 ] ]
  7965. if {$coco != ""} {lappend lcode $coco}
  7966. }
  7967. }
  7968. set LCODE [lsort -command LengthCompar $lcode]
  7969. foreach code $LCODE {
  7970. SwapOperation $w $t $code
  7971. }
  7972. Figuration::RedrawT $w $t
  7973. }
  7974. ###
  7975. proc LengthCompar {c1 c2} {
  7976. if {[string length $c1] >= [string length $c2]} {
  7977. return 0
  7978. } {
  7979. return 1
  7980. }
  7981. }
  7982. ###
  7983. proc LaddUp {w} {
  7984. set id [$w find withtag current]
  7985. set tags [$w gettags $id]
  7986. set t [string range [lindex $tags [lsearch -glob $tags T*]] 1 end]
  7987. set n [string trimright [lindex $tags [lsearch -glob $tags *C]] C]
  7988. if {$n != ""} {
  7989. Ladder $w $t $n >
  7990. }
  7991. }
  7992. ###
  7993. proc LaddDown {w} {
  7994. set id [$w find withtag current]
  7995. set tags [$w gettags $id]
  7996. set t [string range [lindex $tags [lsearch -glob $tags T*]] 1 end]
  7997. set n [string trimright [lindex $tags [lsearch -glob $tags *C]] C]
  7998. if {$n != ""} {
  7999. Ladder $w $t $n <
  8000. }
  8001. }
  8002. }
  8003. ####################
  8004. ####################
  8005. # SELECTION
  8006. ####################
  8007. namespace eval Selection {
  8008. # retourne la A-liste $windows $tree pour tous les tree en target d'une session treedyn
  8009. proc TreeTar {} {
  8010. global S
  8011. set l {}
  8012. foreach key [array names S *,tar] {
  8013. if {$S($key) == 1} {
  8014. set t [string range $key 0 [expr [string first , $key] - 1]]
  8015. if {$t != 0} {
  8016. if {[lsearch -exact $l $t] == -1} {lappend l $S($t,w) $t}
  8017. }
  8018. }
  8019. }
  8020. return $l
  8021. }
  8022. }
  8023. ####################
  8024. ####################
  8025. # DATABASE query langage implementation + browser interface
  8026. ####################
  8027. namespace eval Database {
  8028. ### OK extraire la liste de tous les enregistrements
  8029. proc dbQueryRecordsAll {database} {
  8030. upvar #0 $database X
  8031. return [array names X]
  8032. }
  8033. ### OK extraire la liste des variables d'une database
  8034. proc dbQueryVarAll {database} {
  8035. upvar #0 $database X
  8036. set l {}
  8037. foreach record [array names X] {
  8038. foreach {key value} $X($record) {
  8039. if {[lsearch -exact $l $key] == -1} {lappend l $key}
  8040. }
  8041. }
  8042. return $l
  8043. }
  8044. ### OK extraire la liste des EUs sachant une liste de records
  8045. proc dbQueryEusFromRecords {database lid} {
  8046. upvar #0 $database X
  8047. set l {}
  8048. foreach record $lid {
  8049. set t $X($record)
  8050. if {!([set pos [lsearch $t EU]]%2)} {
  8051. # lappend l [lindex $t [incr pos]]
  8052. # modif au cas ou plusieurs records pour la meme eu
  8053. set val [lindex $t [incr pos]]
  8054. if {[lsearch -exact $l $val] == -1} {lappend l $val}
  8055. }
  8056. }
  8057. return $l
  8058. }
  8059. ###
  8060. proc dbQueryVarFromRecords {database var lid} {
  8061. upvar #0 $database X
  8062. set l {}
  8063. foreach record $lid {
  8064. set t $X($record)
  8065. if {!([set pos [lsearch $t $var]]%2)} {
  8066. # lappend l [lindex $t [incr pos]]
  8067. # modif au cas ou plusieurs records pour la meme eu
  8068. set val [lindex $t [incr pos]]
  8069. if {[lsearch -exact $l $val] == -1} {lappend l $val}
  8070. }
  8071. }
  8072. return $l
  8073. }
  8074. ### OK extraire la liste des val sachant une var
  8075. proc dbQueryValFromVar {database var} {
  8076. upvar #0 $database X
  8077. set l {}
  8078. foreach record [array names X] {
  8079. set t $X($record)
  8080. if {!([set pos [lsearch $t $var]]%2)} {
  8081. set val [lindex $t [incr pos]]
  8082. if {[lsearch -exact $l $val] == -1} {lappend l $val}
  8083. }
  8084. }
  8085. return $l
  8086. }
  8087. ### OK extraire la liste des Records verifiant un couple variable valeur
  8088. ### EGALITE
  8089. proc dbQueryRecordsFromVarVal {database var val} {
  8090. upvar #0 $database X
  8091. set l {}
  8092. foreach record [array names X] {
  8093. set t $X($record)
  8094. if {!([set pos [lsearch $t $var]]%2)} {
  8095. set valquery [lindex $t [incr pos]]
  8096. if {[lsearch -exact $valquery $val] != -1} {
  8097. lappend l $record
  8098. }
  8099. }
  8100. }
  8101. return $l
  8102. }
  8103. ### OK extraire la liste des Records verifiant l'operator sur un couple variable valeur
  8104. proc dbQueryRecordsFromVarOpVal {database var operator val} {
  8105. upvar #0 $database X
  8106. set l {}
  8107. foreach record [array names X] {
  8108. set t $X($record)
  8109. if {!([set pos [lsearch $t $var]]%2)} {
  8110. set valquery [lindex $t [incr pos]]
  8111. set a [format "%s%s%s" \" $val \"]
  8112. set b [format "%s%s%s" \" $valquery \"]
  8113. if [expr $b $operator $a ] {
  8114. lappend l $record
  8115. }
  8116. }
  8117. }
  8118. return $l
  8119. }
  8120. ### OK extraire la liste des Records verifiant l'operator ## sur un couple variable valeur
  8121. ### l'operator ## est utilis?Š pour un pattern matching
  8122. ### permet de traiter des listes
  8123. proc dbQueryRecordsFromVarPatVal {database var val} {
  8124. upvar #0 $database X
  8125. set l {}
  8126. regsub -all " " $val "" val
  8127. foreach record [array names X] {
  8128. set t $X($record)
  8129. if {!([set pos [lsearch $t $var]]%2)} {
  8130. set valquery [lindex $t [incr pos]]
  8131. # attention le pattern
  8132. # if {[lsearch -exact $valquery $val] != -1} {
  8133. # lappend l $record
  8134. # }
  8135. foreach v $valquery {
  8136. if [string match -nocase $val $v ] {
  8137. lappend l $record
  8138. }
  8139. }
  8140. }
  8141. }
  8142. return $l
  8143. }
  8144. ### l'inverse de dbQueryRecordsFromVarPatVal
  8145. ### permet de traiter des cas comme select les eu qui ne contiennent pas
  8146. ### telle valeur (val) pour telle variable
  8147. ### les listes sont possibles
  8148. proc dbQueryRecordsFromVarPat2Val {database var val} {
  8149. upvar #0 $database X
  8150. set l {}
  8151. regsub -all " " $val "" val
  8152. foreach record [array names X] {
  8153. set t $X($record)
  8154. if {!([set pos [lsearch $t $var]]%2)} {
  8155. set valquery [lindex $t [incr pos]]
  8156. # attention doit etre verifier sur tous les elements de la liste
  8157. set presence 0
  8158. foreach v $valquery {
  8159. if {[string match -nocase $val $v ]} {
  8160. set presence 1
  8161. }
  8162. }
  8163. if {$presence == 0} {lappend l $record}
  8164. }
  8165. }
  8166. return $l
  8167. }
  8168. ### OK extraire la liste des eus verifiant un couple variable valeur
  8169. proc dbQueryEusFromVarVal {database var val} {
  8170. upvar #0 $database X
  8171. set l {}
  8172. foreach record [array names X] {
  8173. set t $X($record)
  8174. if {!([set pos [lsearch $t $var]]%2)} {
  8175. set valquery [lindex $t [incr pos]]
  8176. if {$val == $valquery} {
  8177. lappend l $record
  8178. }
  8179. }
  8180. }
  8181. set eus [dbQueryEusFromRecords $database $l]
  8182. return $eus
  8183. }
  8184. ### SELECT $var1 FROM $database WHERE $var2 $operator $val2 AND/OR ...
  8185. ### SELECT + ResAndOr : cool :)
  8186. proc Select {args} {
  8187. global S T
  8188. regsub -all "\}|\{|and|or" $args "" nb
  8189. switch [llength $nb] {
  8190. 0 { set help " "
  8191. return $help
  8192. }
  8193. 3 {
  8194. set var [lindex $args 0]
  8195. set database [lindex $args 2]
  8196. }
  8197. 7 {
  8198. ### SELECT $var1 FROM $database WHERE $var2 $operator $val2
  8199. set var1 [lindex $args 0]
  8200. set database [lindex $args 2]
  8201. set var2 [lindex $args 4]
  8202. set operator [lindex $args 5]
  8203. set val2 [lindex $args 6]
  8204. if {$operator == "##"} {
  8205. set res1 [Database::dbQueryRecordsFromVarPatVal $database $var2 $val2]
  8206. } elseif {$operator == "!#"} {
  8207. set res1 [Database::dbQueryRecordsFromVarPat2Val $database $var2 $val2]
  8208. } else {
  8209. set res1 [Database::dbQueryRecordsFromVarOpVal $database $var2 $operator $val2]
  8210. }
  8211. set res2 [Database::dbQueryVarFromRecords $database $var1 $res1]
  8212. # allumage
  8213. if {$var1 == "EU" && $S(loc) == 1} {
  8214. set AlistWTtarget [Selection::TreeTar]
  8215. if {$AlistWTtarget != {}} {
  8216. foreach {wi ti} $AlistWTtarget {
  8217. Operation::Operation $wi $ti $res2
  8218. set leu {}
  8219. foreach e $res2 {
  8220. if {[lsearch -exact $T($ti,ue_lab) $e] != -1} {lappend leu $e}
  8221. }
  8222. }
  8223. }
  8224. }
  8225. }
  8226. default {
  8227. if {[lsearch -exact $args and] != -1 || [lsearch -exact $args or] != -1} {
  8228. ########### PHASE 1 résolution des couples $var $op $val
  8229. set S(loc) 0
  8230. set var1 [lindex $args 0]
  8231. set database [lindex $args 2]
  8232. set where [lsearch -exact $args where]
  8233. set queries [lrange $args [expr $where + 1] end]
  8234. regsub -all "\}|\{| and | or " $queries " " Alistqueries
  8235. set i 0
  8236. set lq $queries
  8237. global q
  8238. foreach {var op val} $Alistqueries {
  8239. incr i
  8240. if {$op == "##"} {
  8241. set res1 [Database::dbQueryRecordsFromVarPatVal $database $var $val]
  8242. } elseif {$op == "!#"} {
  8243. set res1 [Database::dbQueryRecordsFromVarPat2Val $database $var $val]
  8244. } else {
  8245. set res1 [Database::dbQueryRecordsFromVarOpVal $database $var $op $val]
  8246. }
  8247. set q($i) $res1
  8248. # je remplace le triplet var op val par l'indice ds array q
  8249. # qui contient le resultat de ce triplet
  8250. regsub -all {\+} "$var $op $val" {\+} vov
  8251. regsub $vov $lq $i lq
  8252. #regsub "$var $op $val" $lq $i lq
  8253. }
  8254. regsub -all {\*} $lq "" lq
  8255. ########### PHASE 2
  8256. # resolution des operateurs AND , OR avec ordre de priorite selon {}
  8257. # ... where $q1 AND {{$q2 OR $q3} AND $q4}
  8258. # ou q est est une liste resulat d'un triplet(var op val)
  8259. set finalrecords [lsort -dictionary [ResAndOr $lq]]
  8260. set res2 [Database::dbQueryVarFromRecords $database $var1 $finalrecords]
  8261. set S(loc) 1
  8262. if {$var1 == "EU" && $S(loc) == 1} {
  8263. set AlistWTtarget [Selection::TreeTar]
  8264. if {$AlistWTtarget != {}} {
  8265. foreach {wi ti} $AlistWTtarget {
  8266. Operation::Operation $wi $ti $res2
  8267. set leu {}
  8268. foreach e $res2 {
  8269. if {[lsearch -exact $T($ti,ue_lab) $e] != -1} {lappend leu $e}
  8270. }
  8271. }
  8272. }
  8273. }
  8274. }
  8275. }
  8276. }
  8277. }
  8278. # recurssif
  8279. # query est de la forme {{1 and 2} or 3}
  8280. # ou 1 2 3 sont des indices du array q
  8281. proc ResAndOr {query} {
  8282. global q
  8283. set arg1 [lindex $query 0]
  8284. set op [lindex $query 1]
  8285. set arg2 [lindex $query 2]
  8286. if {[llength $arg1] != 1 } {
  8287. set l1 [ResAndOr $arg1]
  8288. } else {
  8289. set l1 $q($arg1)
  8290. }
  8291. if {[llength $arg2] != 1 } {
  8292. set l2 [ResAndOr $arg2]
  8293. } else {
  8294. set l2 $q($arg2)
  8295. }
  8296. if {$op == "and"} {
  8297. return [Tools::operatorAND $l1 $l2]
  8298. }
  8299. if {$op == "or"} {
  8300. return [Tools::operatorOR $l1 $l2]
  8301. }
  8302. }
  8303. ###
  8304. proc NodeFilterPanel {} {
  8305. global S
  8306. eval destroy .nodefilter
  8307. set w [toplevel .nodefilter]
  8308. wm title $w "Node Filter"
  8309. # NODE FILTER // tolerance
  8310. set S(nodefilter) 0
  8311. iwidgets::entryfield .nodefilter.ns -width 4 -textvariable S(nodefilter) \
  8312. -labeltext "Missing Leaves / Node :" -labelpos w -validate numeric -fixed 30
  8313. # NODE FILTER // nb de leafs
  8314. set S(nodefilterNB) np
  8315. iwidgets::entryfield .nodefilter.nn -width 4 -textvariable S(nodefilterNB) \
  8316. -labeltext "Minimun Leaves / Node :" -labelpos w -validate numeric -fixed 30
  8317. # PACK
  8318. pack .nodefilter.ns -fill x -expand yes
  8319. pack .nodefilter.nn -fill x -expand yes
  8320. }
  8321. # Percent to color: The following routine produces a color
  8322. # from an integer between 0 and 100, where 0 is red, 50 is yellow,
  8323. # and 100 is green (useful e.g. for painting progress bars):
  8324. proc percent2rgb {n} {
  8325. # map 0..100 to a red-yellow-green sequence
  8326. set n [expr {$n < 0? 0: $n > 100? 100: $n}]
  8327. set red [expr {$n > 75? 60 - ($n * 15 / 25) : 15}]
  8328. set green [expr {$n < 50? $n * 15 / 50 : 15}]
  8329. format "#%01x%01x0" $red $green
  8330. }
  8331. #presented this simple beauty in the Tcl chatroom on 2002-12-18:
  8332. proc randomColor {} {format #%06x [expr {int(rand() * 0xFFFFFF)}]}
  8333. #
  8334. proc AddConsole {s} {
  8335. global window
  8336. puts $s
  8337. }
  8338. #
  8339. proc AddColumn {} {
  8340. # construire la colonne du tableur
  8341. .identification.pw.pane0.childsite.ma.t insert cols end 1
  8342. # remplir la table f
  8343. global f
  8344. set NBvariables [expr [llength [array names f 0,*]] -1]
  8345. set NBrecords [expr [llength [array names f *,0]] -1]
  8346. set col [expr $NBvariables + 1]
  8347. for {set row 1} {$row <= $NBrecords} {incr row} {
  8348. set f($row,$col) -
  8349. }
  8350. set f(0,$col) ?
  8351. # mise a jour
  8352. dbUpdate
  8353. }
  8354. # mise a jour database suite MAJ user sur array f
  8355. # de f vers database
  8356. proc dbUpdate {} {
  8357. global f S
  8358. set NBvariables [expr [llength [array names f 0,*]] -1]
  8359. set NBrecords [expr [llength [array names f *,0]] -1]
  8360. set database $S(database)
  8361. upvar #0 $database X
  8362. #on delete X
  8363. unset X
  8364. #et on reconstruit
  8365. db $database
  8366. for {set row 1} {$row <= $NBrecords} {incr row} {
  8367. set data {}
  8368. append data " \{$f($row,0)\}"
  8369. for {set col 1} {$col <= $NBvariables} {incr col} {
  8370. # on construit la A-List Var Val
  8371. append data " $f(0,$col) \{[split $f($row,$col)]\}"
  8372. }
  8373. set id [incr S(lastid)]
  8374. eval $database [concat $id EU $data]
  8375. }
  8376. BuiltAddVariableConsole
  8377. }
  8378. # pour l'instant on ne traite que les $rows,0
  8379. # pour ca on utilise pas $f($s) directement
  8380. proc LocalisationMatrixUser {s} {
  8381. global f S T
  8382. set row [string range $s 0 [expr [string first , $s] - 1]]
  8383. set indice [format "%s%s%s" $row , 0]
  8384. }
  8385. #
  8386. proc reset {} {
  8387. global asedCon
  8388. interp eval $asedCon {
  8389. if {[lsearch [package names] Tk] != -1} {
  8390. foreach child [winfo children .] {
  8391. if {[winfo exists $child]} {destroy $child}
  8392. }
  8393. wm withdraw .
  8394. }
  8395. }
  8396. }
  8397. #
  8398. proc SetValues {_code _result _errorInfo} {
  8399. global code result errorInfo
  8400. set code $_code
  8401. set result $_result
  8402. set errorInfo $_errorInfo
  8403. }
  8404. }
  8405. ####################
  8406. ####################
  8407. # OPERATION
  8408. ####################
  8409. namespace eval Operation {
  8410. proc ResetAllFig+ {} {
  8411. global S
  8412. set S(OpResetLFgC) 1
  8413. set S(OpResetLBgC) 1
  8414. set S(OpResetLF) 1
  8415. set S(OpResetNFgC) 1
  8416. set S(OpResetNBgC) 1
  8417. set S(OpResetNLW) 1
  8418. set S(OpResetNLD) 1
  8419. set S(OpResetNUS) 1
  8420. set S(OpResetNUC) 1
  8421. set S(OpResetAL) 1
  8422. set S(OpResetAN) 1
  8423. set S(OpResetAC) 1
  8424. }
  8425. #
  8426. proc ResetAllFig- {} {
  8427. global S
  8428. set S(OpResetLFgC) 0
  8429. set S(OpResetLBgC) 0
  8430. set S(OpResetLF) 0
  8431. set S(OpResetNFgC) 0
  8432. set S(OpResetNBgC) 0
  8433. set S(OpResetNLW) 0
  8434. set S(OpResetNLD) 0
  8435. set S(OpResetNUS) 0
  8436. set S(OpResetNUC) 0
  8437. set S(OpResetAL) 0
  8438. set S(OpResetAN) 0
  8439. set S(OpResetAC) 0
  8440. }
  8441. #
  8442. proc ResetGraphicVariables {} {
  8443. global S T
  8444. # cette fonction travaille sur la liste des trees en target
  8445. foreach key [array names S *,tar] {
  8446. if {$S($key) == 1} {
  8447. set t [string range $key 0 [expr [string first , $key] - 1]]
  8448. set w $S($t,w)
  8449. # t va etre reset sur une, plusieurs, ou toutes les variables graphiques
  8450. # ...voir optimisation...
  8451. # Leaf Foreground Color
  8452. if {$S(OpResetLFgC) == 1} {Figuration::GraVarInitFgLeaf $w $t}
  8453. # Leaf Background Color
  8454. if {$S(OpResetLBgC) == 1} {Figuration::GraVarInitBgLeaf $w $t}
  8455. # Leaf Font
  8456. if {$S(OpResetLF) == 1} {Figuration::GraVarInitFont $w $t}
  8457. # Node Foreground Color
  8458. if {$S(OpResetNFgC) == 1} {Figuration::GraVarInitFgTree $w $t}
  8459. # Node Background Color
  8460. if {$S(OpResetNBgC) == 1} {Figuration::GraVarInitBgSubTree $w $t}
  8461. # Node Line Witdh
  8462. if {$S(OpResetNLW) == 1} {Figuration::GraVarInitLineWidth $w $t}
  8463. # Node Line Dash
  8464. if {$S(OpResetNLD) == 1} {Figuration::GraVarInitLineDash $w $t}
  8465. # Node Unshrink
  8466. if {$S(OpResetNUS) == 1} {}
  8467. # Node UnCollapse
  8468. if {$S(OpResetNUC) == 1} {}
  8469. # Remove Annotation Leaf
  8470. if {$S(OpResetAL) == 1} {}
  8471. # Remove Annotation Node
  8472. if {$S(OpResetAN) == 1} {}
  8473. # Remove Annotation Canvas
  8474. if {$S(OpResetAC) == 1} {}
  8475. }
  8476. }
  8477. }
  8478. ### OPTIMISATION : si un node est ok : ne pas tester ses nodes fils
  8479. proc FindFatherNode {t SouRefLea} {
  8480. global S T
  8481. set L {}
  8482. # on ne prend pas en compte les codes des feuilles
  8483. # set latest [Tools::SousL $T($t,all_cod) $T($t,ue_cod)]
  8484. # on prend en compte les codes des feuilles
  8485. set latest $T($t,all_cod)
  8486. if {[llength $SouRefLea] != 1} {
  8487. foreach TarCodNod [lsort -dictionary $latest] {
  8488. # selection des codes leaf issus de node
  8489. set TarCodLea [Tools::NodeNoToLe $t $TarCodNod]
  8490. # passage codes leaf -> references leaf
  8491. set TarRefLea [Tools::NodeLeCoToRe $t $TarCodLea]
  8492. # test inclusion des references leaf de TARGET avec SOURCE
  8493. set r [Tools::ListIncluSauf $TarRefLea $SouRefLea $S(nodefilter)]
  8494. if {$r == 1} {lappend L $TarCodNod}
  8495. }
  8496. # meme node pere possibles
  8497. # differents nodes peres possibles
  8498. # -> identification des nodes peres de plus haut niveau
  8499. set l [Tools::NodeFaNoId {} $L]
  8500. if {$L == {}} {return {}} {return $l}
  8501. } {return $T($t,ltc,$SouRefLea) }
  8502. }
  8503. # operation switch en fonction target, si $t :
  8504. # * : on opere sur la liste des tree en target (panel operation)
  8505. # = : on opere sur la liste des tree de la fenetre en argument
  8506. # finalement on traite $t comme une liste de tree, pouvant se restreindre a un seul elt
  8507. proc Operation {w t EUS} {
  8508. global S
  8509. switch -exact $t {
  8510. \* {
  8511. foreach key [array names S *,tar] {
  8512. if {$S($key) == 1} {
  8513. set ti [string range $key 0 [expr [string first , $key] - 1]]
  8514. if {$ti != 0} {
  8515. set wi $S($ti,w)
  8516. Operation::OperationAction $wi $ti $EUS
  8517. }
  8518. }
  8519. }
  8520. }
  8521. = {
  8522. foreach ti $S($w,t) {
  8523. Operation::OperationAction $w $ti $EUS
  8524. }
  8525. }
  8526. default {
  8527. foreach ti $t {
  8528. Operation::OperationAction $w $ti $EUS
  8529. }
  8530. }
  8531. }
  8532. }
  8533. proc OperationAction {w t EUS} {
  8534. global T S
  8535. # Reset Automatic ?
  8536. if {$S(AutoReset)== 1} {Operation::ResetGraphicVariables}
  8537. foreach op $S(operation) {
  8538. switch $op {
  8539. leafbgcolor {
  8540. set leu {}
  8541. foreach e $EUS {
  8542. if {[lsearch -exact $T($t,ue_lab) $e] != -1} {lappend leu $e}
  8543. }
  8544. Figuration::EUColorBgLeaf $t $leu $S(col)
  8545. }
  8546. leaffgcolor {
  8547. set leu {}
  8548. foreach e $EUS {
  8549. if {[lsearch -exact $T($t,ue_lab) $e] != -1} {lappend leu $e}
  8550. }
  8551. Figuration::EUColorFgLeaf $t $leu $S(col)
  8552. }
  8553. leaffontglob {
  8554. set leu {}
  8555. foreach e $EUS {
  8556. if {[lsearch -exact $T($t,ue_lab) $e] != -1} {lappend leu $e}
  8557. }
  8558. Figuration::FontSetGlobalEU $t $leu $S(gfo)
  8559. }
  8560. leafshrink {
  8561. set leu {}
  8562. foreach e $EUS {
  8563. if {[lsearch -exact $T($t,ue_lab) $e] != -1} {lappend leu $e}
  8564. }
  8565. Abstraction::LeafShrink $w $t $leu
  8566. }
  8567. leafunshrink {
  8568. set leu {}
  8569. foreach e $EUS {
  8570. if {[lsearch -exact $T($t,ue_lab) $e] != -1} {lappend leu $e}
  8571. }
  8572. Abstraction::LeafUnShrink $w $t $leu
  8573. }
  8574. qLannL {
  8575. Annotation::qLannL $w $t $EUS
  8576. }
  8577. qLannC {
  8578. Annotation::qLannC $w $t $EUS
  8579. }
  8580. LannL {
  8581. Annotation::LannL $w $t $EUS
  8582. }
  8583. LannC {
  8584. Annotation::LannC $w $t $EUS
  8585. }
  8586. LillL {
  8587. Illustration::LillL $w $t $EUS
  8588. }
  8589. LillC {
  8590. Illustration::LillC $w $t $EUS
  8591. }
  8592. LillCpolygon {
  8593. Illustration::LillCpolygon $w $t $EUS
  8594. }
  8595. nodefgcolor {
  8596. set peres [FindFatherNode $t $EUS]
  8597. foreach e $peres {Figuration::NodeColorFgTree $t $e $S(col)}
  8598. }
  8599. nodefgcolor2 {
  8600. set peres [FindFatherNode $t $EUS]
  8601. foreach e $peres {Figuration::NodeColorFgTree2 $t $e $S(col)}
  8602. }
  8603. nodebgcolor {
  8604. set peres [FindFatherNode $t $EUS]
  8605. foreach e $peres {Figuration::NodeColorBgSubTree $t $e}
  8606. Figuration::RestaureBGSall $w $t
  8607. }
  8608. insertvarval {
  8609. set peres [FindFatherNode $t $EUS]
  8610. foreach e $peres {
  8611. set co [$w coords $e]
  8612. set x [lindex $co 0]
  8613. set y [lindex $co 1]
  8614. Identification::InsertVarVal $w $t $x $y $e
  8615. }
  8616. }
  8617. insertvarval2 {
  8618. set peres [FindFatherNode $t $EUS]
  8619. foreach e $peres {
  8620. set co [$w coords $e]
  8621. set x [lindex $co 0]
  8622. set y [lindex $co 1]
  8623. Identification::InsertVarVal2 $w $t $x $y $e
  8624. }
  8625. }
  8626. nodeannotate {
  8627. set peres [FindFatherNode $t $EUS]
  8628. foreach e $peres {
  8629. set co [$w bbox $e]
  8630. set x [$w canvasx [lindex $co 0]]
  8631. set y [$w canvasy [lindex $co 1]]
  8632. Annotation::BLLmake $w $t $x $y "" $S(AnnotateNote) $e
  8633. }
  8634. }
  8635. nodeillustration {
  8636. set peres [FindFatherNode $t $EUS]
  8637. foreach e $peres {
  8638. set co [$w coords $e]
  8639. set x [$w canvasx [lindex $co 0]]
  8640. set y [$w canvasy [lindex $co 1]]
  8641. #set S(symbolcolorfill) $S(col)
  8642. #set S(symbolcoloroutline) $S(col)
  8643. #set S(symbolstipple) $S(stipple)
  8644. Illustration::drawsymbol $w [expr $x + 30 ] [expr $y + 30] [list T$t]
  8645. }
  8646. }
  8647. shrink {
  8648. set peres [FindFatherNode $t $EUS]
  8649. foreach e $peres {Abstraction::Shrink $w $t $e ""}
  8650. }
  8651. unshrink {
  8652. set peres [FindFatherNode $t $EUS]
  8653. Abstraction::ShrinkUnLN $w $t $peres
  8654. }
  8655. collapse {Abstraction::Collapse $w $t $EUS}
  8656. uncollapse {Abstraction::CollapseUn $w $t $EUS}
  8657. widthline+ {
  8658. set peres [FindFatherNode $t $EUS]
  8659. foreach e $peres {Figuration::NodeLineWidth $t $e +}
  8660. }
  8661. widthline+2 {
  8662. set peres [FindFatherNode $t $EUS]
  8663. foreach e $peres {Figuration::NodeLineWidth2 $t $e +}
  8664. }
  8665. widthline- {
  8666. set peres [FindFatherNode $t $EUS]
  8667. foreach e $peres {Figuration::NodeLineWidth $t $e -}
  8668. }
  8669. nodedashOn {
  8670. set peres [FindFatherNode $t $EUS]
  8671. foreach e $peres {Figuration::NodeLineDash $t $e 1}
  8672. }
  8673. nodedashOn2 {
  8674. set peres [FindFatherNode $t $EUS]
  8675. foreach e $peres {Figuration::NodeLineDash2 $t $e 1}
  8676. }
  8677. nodedashOff {
  8678. set peres [FindFatherNode $t $EUS]
  8679. foreach e $peres {Figuration::NodeLineDash $t $e 0}
  8680. }
  8681. nodenetwork {
  8682. set lkv {}
  8683. set peres [FindFatherNode $t $EUS]
  8684. foreach ni $peres {
  8685. lappend lkv $t $ni
  8686. }
  8687. Reflection::NodeNetworkBuild $w $lkv " "
  8688. }
  8689. querynode {Annotation::QueryNode $w $t $EUS}
  8690. nodeextract {
  8691. set peres [FindFatherNode $t $EUS]
  8692. PROTO::NodeExtract $t $peres
  8693. }
  8694. symbolnode {
  8695. set peres [FindFatherNode $t $EUS]
  8696. foreach e $peres {
  8697. set co [$w coords $e]
  8698. set x [lindex $co 0]
  8699. set y [lindex $co 1]
  8700. Annotation::InsertSymbolNodeMake $w $t $x $y $e
  8701. }
  8702. }
  8703. }
  8704. }
  8705. }
  8706. }
  8707. ####################
  8708. # ICONOGRAPHIE
  8709. ####################
  8710. namespace eval Iconographie {
  8711. proc MakeIconographie {} {
  8712. global S
  8713. set S(stidir) [file join [file dirname [info script]] +/stipple/]
  8714. image create photo STIz -file [file join [file dirname [info script]] +/stipple/z.xbm]
  8715. image create photo STIa -file [file join [file dirname [info script]] +/stipple/a.xbm]
  8716. image create photo STIb -file [file join [file dirname [info script]] +/stipple/b.xbm]
  8717. image create photo STIc -file [file join [file dirname [info script]] +/stipple/c.xbm]
  8718. image create photo STIe -file [file join [file dirname [info script]] +/stipple/e.xbm]
  8719. image create photo STIf -file [file join [file dirname [info script]] +/stipple/f.xbm]
  8720. image create photo STIl -file [file join [file dirname [info script]] +/stipple/l.xbm]
  8721. image create photo STIm -file [file join [file dirname [info script]] +/stipple/m.xbm]
  8722. image create photo STIg -file [file join [file dirname [info script]] +/stipple/g.xbm]
  8723. image create photo STIh -file [file join [file dirname [info script]] +/stipple/h.xbm]
  8724. image create photo STIi -file [file join [file dirname [info script]] +/stipple/i.xbm]
  8725. image create photo STIj -file [file join [file dirname [info script]] +/stipple/j.xbm]
  8726. image create photo STIk -file [file join [file dirname [info script]] +/stipple/k.xbm]
  8727. }
  8728. }
  8729. ####################
  8730. # TOOLS
  8731. ####################
  8732. namespace eval Tools {
  8733. ### NODE
  8734. proc NodeParentNode {t node} {
  8735. if {[string equal $node $t] == 1} {
  8736. return $t
  8737. } elseif {[string equal $node [format "%s%s" $t g]] == 1} {
  8738. return $t
  8739. } elseif {[string equal $node [format "%s%s" $t d]] == 1} {
  8740. return $t
  8741. } else {
  8742. set gennode [string range $node 0 end-1]
  8743. set fathernode [string trimright $gennode {0 1 2 3 4 5 6 7 8 9}]
  8744. return $fathernode
  8745. }
  8746. }
  8747. # calcul de la distance feuille a feuille
  8748. proc DistLL {t l1 l2} {
  8749. global T
  8750. if {[string equal $l1 $l2] == 1} {
  8751. return 0
  8752. } else {
  8753. set l1code $T($t,ltc,$l1)
  8754. set l2code $T($t,ltc,$l2)
  8755. set node [string trimright [CommunRoot2 0 $l1code $l2code ""] "0123456789"]
  8756. set cumul 0
  8757. foreach n [NodeFathers $t $node] {
  8758. set cumul [expr $cumul + $T($t,dbl,$n)]
  8759. }
  8760. return [expr $T($t,sox,$l1code) + $T($t,sox,$l2code) - (2 * $cumul)]
  8761. }
  8762. }
  8763. #
  8764. proc CommunRoot2 {index s1 s2 string} {
  8765. if {[string equal $s1 $s2]} {
  8766. return $string
  8767. }
  8768. if {[string equal [string index $s1 $index] [string index $s2 $index]]} {
  8769. CommunRoot2 [expr $index +1] $s1 $s2 $string[string index $s1 $index]
  8770. } else {
  8771. return $string
  8772. }
  8773. }
  8774. ###
  8775. proc NodeBrotherNode {node} {
  8776. set gennode [string range $node 0 end-1]
  8777. set letter [string range $node end end ]
  8778. if {$letter == "g"} {
  8779. set brothernode [format "%s%s" $gennode d]
  8780. } {set brothernode [format "%s%s" $gennode g]}
  8781. return $brothernode
  8782. }
  8783. # renvoie la liste des codes nodes de la racine a n (le chemin)
  8784. # lf est initialise a $t a l'appel de la procedure
  8785. proc NodeFathers {lf n} {
  8786. if {$n == "" || $n == [lindex $lf 0]} {
  8787. return $lf
  8788. } else {
  8789. lappend lf $n
  8790. NodeFathers $lf [NodeParentNode [lindex $lf 0] $n]
  8791. }
  8792. }
  8793. ### NoToLe retourne la liste des codes feuilles issues de node
  8794. proc NodeNoToLe {treeid nodecode} {
  8795. global T
  8796. set p [format "%s%s" $nodecode *]
  8797. set l {}
  8798. foreach codei $T($treeid,ue_cod) {
  8799. if {[string match $p $codei]} {lappend l $codei}
  8800. }
  8801. return $l
  8802. }
  8803. ### NoToLeNum
  8804. proc NodeNoToLeNum {t n} {
  8805. global T
  8806. set p [format "%s%s" $n *]
  8807. set l {}
  8808. foreach ni $T($t,ue_cod) {
  8809. if {[string match $p $ni]} {lappend l $ni}
  8810. }
  8811. return [llength $l]
  8812. }
  8813. ### LeCoToRe retourne la liste des REFERENCES feuilles sachant les CODES feuilles
  8814. proc NodeLeCoToRe {treeid lin} {
  8815. global T
  8816. set lout {}
  8817. foreach c $lin {
  8818. lappend lout $T($treeid,ctl,$c)
  8819. }
  8820. return $lout
  8821. }
  8822. # l est une liste de code node
  8823. # FaNoId retourne la liste des nodes de plus haut niveau
  8824. proc NodeFaNoId {leltpass l} {
  8825. set elt [lindex $l 0]
  8826. set lnew [lrange $l 1 end]
  8827. if {[lsearch -exact $leltpass $elt] == -1} {
  8828. set lprov {}
  8829. lappend leltpass $elt
  8830. set p [format "%s%s" $elt *]
  8831. foreach i $l {
  8832. if {[string match $p $i] != 1} {lappend lprov $i}
  8833. }
  8834. Tools::NodeFaNoId $leltpass [lappend lprov $elt]
  8835. } {return $l}
  8836. }
  8837. ### Node Code Father To Node Code Children
  8838. ### (Node Code Father Inclus )
  8839. proc NodeNoCoFaToNoCoCh {IdTree NoCoFa} {
  8840. global T
  8841. set List_NoCoCh {}
  8842. set pattern [format "%s%s" $NoCoFa *]
  8843. foreach NoCoCh $T($IdTree,all_cod) {
  8844. if {[string match $pattern $NoCoCh]} {lappend List_NoCoCh $NoCoCh}
  8845. }
  8846. return $List_NoCoCh
  8847. }
  8848. # recherche d'un node pere commun aux leafs
  8849. proc FatherSearch {t SouRefLea} {
  8850. global S T
  8851. set L {}
  8852. # on ne prend pas en compte les codes des feuilles
  8853. set latest [Tools::SousL $T($t,all_cod) $T($t,ue_cod)]
  8854. if {[llength $SouRefLea] != 1} {
  8855. foreach TarCodNod [lsort -dictionary $latest] {
  8856. # selection des codes leaf issus de node
  8857. set TarCodLea [Tools::NodeNoToLe $t $TarCodNod]
  8858. # passage codes leaf -> references leaf
  8859. set TarRefLea [Tools::NodeLeCoToRe $t $TarCodLea]
  8860. # test inclusion des references leaf de TARGET avec SOURCE
  8861. set r [Tools::ListIncluSauf $TarRefLea $SouRefLea $S(nodefilter)]
  8862. if {$r == 1} {lappend L $TarCodNod}
  8863. }
  8864. # meme node pere possibles
  8865. # differents nodes peres possibles
  8866. # -> identification des nodes peres de plus haut niveau
  8867. set l [Tools::NodeFaNoId {} $L]
  8868. if {$L == {}} {return {}} {return $l}
  8869. } {return $T($t,ltc,$SouRefLea) }
  8870. }
  8871. # recherche d'un node pere commun aux leafs
  8872. proc FatherSearch2 {t SouRefLea} {
  8873. global S T
  8874. set L {}
  8875. # on ne prend pas en compte les codes des feuilles
  8876. set latest [Tools::SousL $T($t,all_cod) $T($t,ue_cod)]
  8877. if {[llength $SouRefLea] != 1} {
  8878. foreach TarCodNod [lsort -dictionary $latest] {
  8879. # selection des codes leaf issus de node
  8880. set TarCodLea [Tools::NodeNoToLe $t $TarCodNod]
  8881. # passage codes leaf -> references leaf
  8882. set TarRefLea [Tools::NodeLeCoToRe $t $TarCodLea]
  8883. # test egalit?Š
  8884. set r1 [Tools::SousL $TarRefLea $SouRefLea]
  8885. set r2 [Tools::SousL $SouRefLea $TarRefLea]
  8886. if {$r1 == {} && $r2 == {}} {lappend L $TarCodNod}
  8887. }
  8888. # meme node pere possibles
  8889. # differents nodes peres possibles
  8890. # -> identification des nodes peres de plus haut niveau
  8891. set l [Tools::NodeFaNoId {} $L]
  8892. if {$L == {}} {return {}} {return $l}
  8893. } {return $T($t,ltc,$SouRefLea) }
  8894. }
  8895. ### /home/user/data/x.tree -> x.tree
  8896. proc PathCut {spath} {
  8897. set id [expr [string last "/" $spath] + 1]
  8898. return [string range $spath $id end]
  8899. }
  8900. ### /home/user/data/x.tree -> x
  8901. proc PathCut2 {spath} {
  8902. set id1 [expr [string last "/" $spath] + 1]
  8903. set id2 [expr [string last "." $spath] - 1]
  8904. return [string range $spath $id1 $id2]
  8905. }
  8906. ### {a b c} -> {a \n b \n c}
  8907. proc FormatText {Lin} {
  8908. set Lout {}
  8909. set ll [lsort -dictionary $Lin]
  8910. lappend Lout [lindex $ll 0]
  8911. set ll1end [lrange $ll 1 end]
  8912. foreach e $ll1end {
  8913. lappend Lout \n
  8914. lappend Lout $e
  8915. }
  8916. regsub -all {\}} $Lout "" Lout
  8917. regsub -all {\{} $Lout "" Lout
  8918. regsub -all , $Lout = Lout
  8919. regsub -all " " $Lout " " Lout
  8920. regsub -all " \n" $Lout "\n" Lout
  8921. regsub -all "\n " $Lout "\n" Lout
  8922. return $Lout
  8923. }
  8924. #
  8925. proc GenId {} {
  8926. global S
  8927. incr S(nbobj)
  8928. return [format "%s%s" [clock second] $S(nbobj)]
  8929. }
  8930. ### DelRep suppression des repetitions d'une liste
  8931. proc DelRep {lin} {
  8932. set lou {}
  8933. foreach i $lin {
  8934. if {[lsearch -exact $lou $i] == -1} {lappend lou $i}
  8935. }
  8936. return $lou
  8937. }
  8938. ### Retourne 1 si l1 est incluse dans l2
  8939. proc ListInclu {l1 l2} {
  8940. foreach i1 $l1 {
  8941. if {[lsearch -exact $l2 $i1] == -1} {set b 0 ; break} {set b 1}
  8942. }
  8943. return $b
  8944. }
  8945. ###
  8946. proc ListIncluSauf {l1 l2 nb} {
  8947. # c est le nb d'elt de l1 n'etant pas dans l2
  8948. set c 0
  8949. foreach i1 $l1 {
  8950. if {[lsearch -exact $l2 $i1] == -1} {incr c}
  8951. }
  8952. if {$c > $nb} {return 0} {return 1}
  8953. }
  8954. # l2 est une liste d'elts devant etre retires de l1
  8955. proc SousL {l1 l2} {
  8956. set lout {}
  8957. foreach e $l1 {
  8958. if {[lsearch -exact $l2 $e] == -1} {lappend lout $e} {}
  8959. }
  8960. return $lout
  8961. }
  8962. # operateur AND # l'intersection des listes
  8963. # ll est une liste de liste
  8964. proc operatorANDll {ll} {
  8965. set lintersect {}
  8966. set l1 [lindex $ll 0]
  8967. set ln [lrange $ll 1 end]
  8968. foreach e $l1 {
  8969. set x 1
  8970. foreach l $ln {
  8971. if {[lsearch -exact $l $e] == -1} {set x 0}
  8972. }
  8973. if {$x != 0} {lappend lintersect $e}
  8974. }
  8975. return [Tools::DelRep $lintersect]
  8976. }
  8977. proc operatorAND {l1 l2} {
  8978. set lintersect {}
  8979. foreach i $l1 {
  8980. if {[lsearch -exact $l2 $i] != -1} {lappend lintersect $i}
  8981. }
  8982. return [Tools::DelRep $lintersect]
  8983. }
  8984. # operator OR # l'union des listes en supprimant les repetitions
  8985. # ll est une liste de liste
  8986. proc operatorORll {ll} {
  8987. set lunion {}
  8988. foreach l $ll {
  8989. lappend lunion $l
  8990. }
  8991. return [Tools::DelRep $lunion]
  8992. }
  8993. proc operatorOR {l1 l2} {
  8994. set lunion {}
  8995. foreach i $l2 {
  8996. lappend l1 $i
  8997. }
  8998. return [Tools::DelRep $l1]
  8999. }
  9000. ### {a b c} -> {a \n b \n c}
  9001. proc FormatText {Lin} {
  9002. set Lout {}
  9003. set ll [lsort -dictionary $Lin]
  9004. lappend Lout [lindex $ll 0]
  9005. set ll1end [lrange $ll 1 end]
  9006. foreach e $ll1end {
  9007. lappend Lout \n
  9008. lappend Lout $e
  9009. }
  9010. regsub -all {\}} $Lout "" Lout
  9011. regsub -all {\{} $Lout "" Lout
  9012. regsub -all , $Lout = Lout
  9013. regsub -all " " $Lout " " Lout
  9014. regsub -all " \n" $Lout "\n" Lout
  9015. regsub -all "\n " $Lout "\n" Lout
  9016. return $Lout
  9017. }
  9018. }
  9019. ####################
  9020. ####################
  9021. # PACKAGE
  9022. ####################
  9023. namespace eval Package {
  9024. namespace eval CanToSVG {
  9025. # can2svg.tcl ---
  9026. # This file provides translation from canvas commands to XML/SVG format.
  9027. # Copyright (c) 2002 Mats Bengtsson
  9028. package provide can2svg 0.1
  9029. namespace eval ::can2svg:: {
  9030. namespace export can2svg canvas2file
  9031. variable formatArrowMarker
  9032. variable formatArrowMarkerLast
  9033. # The key into this array is 'arrowMarkerDef_$col_$a_$b_$c', where
  9034. # col is color, and a, b, c are the arrow's shape.
  9035. variable defsArrowMarkerArr
  9036. # Similarly for stipple patterns.
  9037. variable defsStipplePatternArr
  9038. # This shouldn't be hardcoded!
  9039. variable defaultFont {Helvetica 12}
  9040. variable anglesToRadians [expr 3.14159265359/180.0]
  9041. variable grayStipples {gray75 gray50 gray25 gray12}
  9042. # Make 4x4 squares. Perhaps could be improved.
  9043. variable stippleDataArr
  9044. set stippleDataArr(gray75) \
  9045. {M 0 0 h3 M 0 1 h1 m 1 0 h2 M 0 2 h2 m 1 0 h1 M 0 3 h3}
  9046. set stippleDataArr(gray50) \
  9047. {M 0 0 h1 m 1 0 h1 M 1 1 h1 m 1 0 h1 \
  9048. M 0 2 h1 m 1 0 h1 M 1 3 h1 m 1 0 h1}
  9049. set stippleDataArr(gray25) \
  9050. {M 0 0 h1 M 2 1 h1 M 1 2 h1 M 3 3 h1}
  9051. set stippleDataArr(gray12) {M 0 0 h1 M 2 2 h1}
  9052. }
  9053. proc ::can2svg::can2svg {cmd args} {
  9054. variable defsArrowMarkerArr
  9055. variable defsStipplePatternArr
  9056. variable anglesToRadians
  9057. variable defaultFont
  9058. variable grayStipples
  9059. set nonum_ {[^0-9]}
  9060. set wsp_ {[ ]+}
  9061. set xml ""
  9062. #array set argsArr {-usetags all}
  9063. array set argsArr {-usetags 0}
  9064. array set argsArr $args
  9065. switch -- [lindex $cmd 0] {
  9066. create {
  9067. set type [lindex $cmd 1]
  9068. set rest [lrange $cmd 2 end]
  9069. regexp -indices -- "-${nonum_}" $rest ind
  9070. set ind1 [lindex $ind 0]
  9071. set coo [string trim [string range $rest 0 [expr $ind1 - 1]]]
  9072. set opts [string range $rest $ind1 end]
  9073. array set optArr $opts
  9074. # Figure out if we've got a spline.
  9075. set haveSpline 0
  9076. if {[info exists optArr(-smooth)] && ($optArr(-smooth) != "0") && \
  9077. [info exists optArr(-splinesteps)] && ($optArr(-splinesteps) > 2)} {
  9078. set haveSpline 1
  9079. }
  9080. if {[info exists optArr(-fill)]} {
  9081. set fillValue $optArr(-fill)
  9082. } else {
  9083. set fillValue black
  9084. }
  9085. if {($argsArr(-usetags) != "0") && [info exists optArr(-tags)]} {
  9086. switch -- $argsArr(-usetags) {
  9087. all {
  9088. set idAttr [list "id" $optArr(-tags)]
  9089. }
  9090. first {
  9091. set idAttr [list "id" [lindex $optArr(-tags) 0]]
  9092. }
  9093. last {
  9094. set idAttr [list "id" [lindex $optArr(-tags) end]]
  9095. }
  9096. }
  9097. } else {
  9098. set idAttr ""
  9099. }
  9100. # If we need a marker (arrow head) need to make that first.
  9101. if {[info exists optArr(-arrow)]} {
  9102. if {[info exists optArr(-arrowshape)]} {
  9103. # Make a key of the arrowshape list into the array.
  9104. regsub -all -- $wsp_ $optArr(-arrowshape) _ shapeKey
  9105. set arrowKey ${fillValue}_${shapeKey}
  9106. set arrowShape $optArr(-arrowshape)
  9107. } else {
  9108. set arrowKey ${fillValue}
  9109. set arrowShape {8 10 3}
  9110. }
  9111. if {![info exists defsArrowMarkerArr($arrowKey)]} {
  9112. set defsArrowMarkerArr($arrowKey) \
  9113. [eval {MakeArrowMarker} $arrowShape {$fillValue}]
  9114. append xml $defsArrowMarkerArr($arrowKey)
  9115. append xml "\n\t"
  9116. }
  9117. }
  9118. # If we need a stipple bitmap, need to make that first. Limited!!!
  9119. # Only: gray12, gray25, gray50, gray75
  9120. foreach key {-stipple -outlinestipple} {
  9121. if {[info exists optArr($key)] && \
  9122. ([lsearch $grayStipples $optArr($key)] >= 0)} {
  9123. set stipple $optArr($key)
  9124. if {![info exists defsStipplePatternArr($stipple)]} {
  9125. set defsStipplePatternArr($stipple) \
  9126. [MakeGrayStippleDef $stipple]
  9127. }
  9128. append xml $defsStipplePatternArr($stipple)
  9129. append xml "\n\t"
  9130. }
  9131. }
  9132. switch -- $type {
  9133. arc {
  9134. # Had to do it the hard way! (?)
  9135. # "Wrong" coordinate system :-(
  9136. set elem "path"
  9137. set style [MakeStyle $type $opts]
  9138. foreach {x1 y1 x2 y2} $coo {}
  9139. set cx [expr ($x1 + $x2)/2.0]
  9140. set cy [expr ($y1 + $y2)/2.0]
  9141. set rx [expr abs($x1 - $x2)/2.0]
  9142. set ry [expr abs($y1 - $y2)/2.0]
  9143. set rmin [expr $rx > $ry ? $ry : $rx]
  9144. # This approximation gives a maximum half pixel error.
  9145. set deltaPhi [expr 2.0/sqrt($rmin)]
  9146. set extent [expr $anglesToRadians * $optArr(-extent)]
  9147. set start [expr $anglesToRadians * $optArr(-start)]
  9148. set nsteps [expr int(abs($extent)/$deltaPhi) + 2]
  9149. set delta [expr $extent/$nsteps]
  9150. set data [format "M %.1f %.1f L" \
  9151. [expr $cx + $rx*cos($start)] [expr $cy - $ry*sin($start)]]
  9152. for {set i 0} {$i <= $nsteps} {incr i} {
  9153. set phi [expr $start + $i * $delta]
  9154. append data [format " %.1f %.1f" \
  9155. [expr $cx + $rx*cos($phi)] [expr $cy - $ry*sin($phi)]]
  9156. }
  9157. if {[info exists optArr(-style)]} {
  9158. switch -- $optArr(-style) {
  9159. chord {
  9160. append data " Z"
  9161. }
  9162. pieslice {
  9163. append data [format " %.1f %.1f Z" $cx $cy]
  9164. }
  9165. }
  9166. } else {
  9167. # Pieslice is the default.
  9168. append data [format " %.1f %.1f Z" $cx $cy]
  9169. }
  9170. set attr [list "d" $data "style" $style]
  9171. if {[string length $idAttr] > 0} {
  9172. set attr [concat $attr $idAttr]
  9173. }
  9174. set xmlList [MakeXMLList $elem -attrlist $attr]
  9175. }
  9176. image - bitmap {
  9177. set elem "image"
  9178. set attr [MakeImageAttr $coo $opts]
  9179. if {[string length $idAttr] > 0} {
  9180. set attr [concat $attr $idAttr]
  9181. }
  9182. set xmlList [MakeXMLList $elem -attrlist $attr]
  9183. }
  9184. line {
  9185. if {$haveSpline} {
  9186. set elem "path"
  9187. set style [MakeStyle $type $opts]
  9188. set data "M [lrange $coo 0 1] Q"
  9189. set i 4
  9190. foreach {x y} [lrange $coo 2 end-4] {
  9191. set x0 [expr ($x + [lindex $coo $i])/2.0]
  9192. incr i
  9193. set y0 [expr ($y + [lindex $coo $i])/2.0]
  9194. incr i
  9195. append data " $x $y $x0 $y0"
  9196. }
  9197. append data " [lrange $coo end-3 end]"
  9198. set attr [list "d" $data "style" $style]
  9199. } else {
  9200. set elem "polyline"
  9201. set style [MakeStyle $type $opts]
  9202. set attr [list "points" $coo "style" $style]
  9203. }
  9204. if {[string length $idAttr] > 0} {
  9205. set attr [concat $attr $idAttr]
  9206. }
  9207. set xmlList [MakeXMLList $elem -attrlist $attr]
  9208. }
  9209. oval {
  9210. foreach {x y w h} [NormalizeRectCoords $coo] {}
  9211. if {[expr $w == $h]} {
  9212. set elem "circle"
  9213. set attr [list \
  9214. "cx" [expr $x + $w/2.0] \
  9215. "cy" [expr $y + $h/2.0] \
  9216. "r" [expr $w/2.0]]
  9217. } else {
  9218. set elem "ellipse"
  9219. set attr [list \
  9220. "cx" [expr $x + $w/2.0] \
  9221. "cy" [expr $y + $h/2.0] \
  9222. "rx" [expr $w/2.0] \
  9223. "ry" [expr $h/2.0]]
  9224. }
  9225. set style [MakeStyle $type $opts]
  9226. lappend attr "style" $style
  9227. if {[string length $idAttr] > 0} {
  9228. set attr [concat $attr $idAttr]
  9229. }
  9230. set xmlList [MakeXMLList $elem -attrlist $attr]
  9231. }
  9232. polygon {
  9233. if {$haveSpline} {
  9234. set elem "path"
  9235. set style [MakeStyle $type $opts]
  9236. # Translating a closed polygon into a qubic bezier
  9237. # path is a little bit tricky.
  9238. set x0 [expr ([lindex $coo end-1] + [lindex $coo 0])/2.0]
  9239. set y0 [expr ([lindex $coo end] + [lindex $coo 1])/2.0]
  9240. set data "M $x0 $y0 Q"
  9241. set i 2
  9242. foreach {x y} [lrange $coo 0 end-2] {
  9243. set x1 [expr ($x + [lindex $coo $i])/2.0]
  9244. incr i
  9245. set y1 [expr ($y + [lindex $coo $i])/2.0]
  9246. incr i
  9247. append data " $x $y $x1 $y1"
  9248. }
  9249. append data " [lrange $coo end-1 end] $x0 $y0"
  9250. set attr [list "d" $data "style" $style]
  9251. } else {
  9252. set elem "polygon"
  9253. set style [MakeStyle $type $opts]
  9254. puts "AVANT $type $opts APRES $style"
  9255. set attr [list "points" $coo "style" $style]
  9256. }
  9257. if {[string length $idAttr] > 0} {
  9258. set attr [concat $attr $idAttr]
  9259. }
  9260. set xmlList [MakeXMLList $elem -attrlist $attr]
  9261. }
  9262. rectangle {
  9263. set elem "rect"
  9264. set style [MakeStyle $type $opts]
  9265. # width and height must be non-negative!
  9266. foreach {x y w h} [NormalizeRectCoords $coo] {}
  9267. set attr [list "x" $x "y" $y "width" $w "height" $h]
  9268. lappend attr "style" $style
  9269. if {[string length $idAttr] > 0} {
  9270. set attr [concat $attr $idAttr]
  9271. }
  9272. set xmlList [MakeXMLList $elem -attrlist $attr]
  9273. }
  9274. text {
  9275. set elem "text"
  9276. set style [MakeStyle $type $opts]
  9277. set nlines 1
  9278. if {[info exists optArr(-text)]} {
  9279. set chdata $optArr(-text)
  9280. set nlines [expr [regexp -all "\n" $chdata] + 1]
  9281. } else {
  9282. set chdata ""
  9283. }
  9284. # Figure out the coords of the first baseline.
  9285. set anchor center
  9286. if {[info exists optArr(-anchor)]} {
  9287. set anchor $optArr(-anchor)
  9288. }
  9289. if {[info exists optArr(-font)]} {
  9290. set theFont $optArr(-font)
  9291. } else {
  9292. set theFont $defaultFont
  9293. }
  9294. set ascent [font metrics $theFont -ascent]
  9295. set lineSpace [font metrics $theFont -linespace]
  9296. foreach {xbase ybase} \
  9297. [GetTextSVGCoords $coo $anchor $chdata $theFont $nlines] {}
  9298. set attr [list "x" $xbase "y" $ybase]
  9299. lappend attr "style" $style
  9300. if {[string length $idAttr] > 0} {
  9301. set attr [concat $attr $idAttr]
  9302. }
  9303. set dy 0
  9304. if {$nlines > 1} {
  9305. # Use the 'tspan' trick here.
  9306. set subList {}
  9307. foreach line [split $chdata "\n"] {
  9308. lappend subList [MakeXMLList "tspan" \
  9309. -attrlist [list "x" $xbase "dy" $dy] -chdata $line]
  9310. set dy $lineSpace
  9311. }
  9312. set xmlList [MakeXMLList $elem -attrlist $attr \
  9313. -subtags $subList]
  9314. } else {
  9315. set xmlList [MakeXMLList $elem -attrlist $attr \
  9316. -chdata $chdata]
  9317. }
  9318. }
  9319. }
  9320. }
  9321. move {
  9322. foreach {tag dx dy} [lrange $cmd 1 3] {}
  9323. set attr [list "transform" "translate($dx,$dy)" \
  9324. "xlink:href" "#$tag"]
  9325. set xmlList [MakeXMLList "use" -attrlist $gattr]
  9326. }
  9327. scale {
  9328. }
  9329. }
  9330. append xml [MakeXML $xmlList]
  9331. return $xml
  9332. }
  9333. proc ::can2svg::MakeStyle {type opts} {
  9334. # Defaults for everything except text.
  9335. if {![string equal $type "text"]} {
  9336. array set styleArr {fill none stroke black}
  9337. }
  9338. set fillCol black
  9339. foreach {key value} $opts {
  9340. switch -- $key {
  9341. -arrow {
  9342. set arrowValue $value
  9343. }
  9344. -arrowshape {
  9345. set arrowShape $value
  9346. }
  9347. -capstyle {
  9348. if {[string equal $value "projecting"]} {
  9349. set value "square"
  9350. }
  9351. if {![string equal $value "butt"]} {
  9352. set styleArr(stroke-linecap) $value
  9353. }
  9354. }
  9355. -dash {
  9356. set dashValue $value
  9357. }
  9358. -dashoffset {
  9359. if {$value != 0} {
  9360. set styleArr(stroke-dashoffset) $value
  9361. }
  9362. }
  9363. -fill {
  9364. set fillCol $value
  9365. if {[string equal $type "line"]} {
  9366. set styleArr(stroke) [MapEmptyToNone $value]
  9367. } else {
  9368. set styleArr(fill) [MapEmptyToNone $value]
  9369. }
  9370. }
  9371. -font {
  9372. set styleArr(font-family) [lindex $value 0]
  9373. if {[llength $value] > 1} {
  9374. set styleArr(font-size) [format "%s%s" [lindex $value 1] pt]
  9375. }
  9376. if {[llength $value] > 2} {
  9377. set tkstyle [lindex $value 2]
  9378. switch -- $tkstyle {
  9379. bold {
  9380. set styleArr(font-weight) $tkstyle
  9381. }
  9382. italic {
  9383. set styleArr(font-style) $tkstyle
  9384. }
  9385. underline {
  9386. set styleArr(text-decoration) underline
  9387. }
  9388. overstrike {
  9389. set styleArr(text-decoration) overline
  9390. }
  9391. }
  9392. }
  9393. }
  9394. -joinstyle {
  9395. set styleArr(stroke-linejoin) $value
  9396. }
  9397. -outline {
  9398. set styleArr(stroke) [MapEmptyToNone $value]
  9399. }
  9400. -outlinestipple {
  9401. set outlineStippleValue $value
  9402. }
  9403. -stipple {
  9404. set stippleValue $value
  9405. }
  9406. -width {
  9407. set styleArr(stroke-width) $value
  9408. }
  9409. }
  9410. }
  9411. # If any arrow specify its marker def url key.
  9412. if {[info exists arrowValue]} {
  9413. if {[info exists arrowShape]} {
  9414. foreach {a b c} $arrowShape {}
  9415. set arrowIdKey "arrowMarkerDef_${fillCol}_${a}_${b}_${c}"
  9416. set arrowIdKeyLast "arrowMarkerLastDef_${fillCol}_${a}_${b}_${c}"
  9417. } else {
  9418. set arrowIdKey "arrowMarkerDef_${fillCol}"
  9419. }
  9420. switch -- $arrowValue {
  9421. first {
  9422. set styleArr(marker-start) "url(#$arrowIdKey)"
  9423. }
  9424. last {
  9425. set styleArr(marker-end) "url(#$arrowIdKeyLast)"
  9426. }
  9427. both {
  9428. set styleArr(marker-start) "url(#$arrowIdKey)"
  9429. set styleArr(marker-end) "url(#$arrowIdKeyLast)"
  9430. }
  9431. }
  9432. }
  9433. if {[info exists stippleValue]} {
  9434. # Overwrite any existing.
  9435. set styleArr(fill) "url(#tile$stippleValue)"
  9436. }
  9437. if {[info exists outlineStippleValue]} {
  9438. # Overwrite any existing.
  9439. set styleArr(stroke) "url(#tile$stippleValue)"
  9440. }
  9441. # Transform dash value.
  9442. if {[info exists dashValue]} {
  9443. # Two different syntax here.
  9444. if {[regexp {[\.,\-_ ]} $dashValue]} {
  9445. # .=2 ,=4 -=6 space=4 times stroke width.
  9446. # A space enlarges the... space.
  9447. # Not foolproof!
  9448. regsub -all -- {[^ ]} $dashValue "& " dash
  9449. regsub -all -- " " $dash "12 " dash
  9450. regsub -all -- " " $dash "8 " dash
  9451. regsub -all -- " " $dash "4 " dash
  9452. regsub -all -- {\.} $dash "2 " dash
  9453. regsub -all -- {,} $dash "4 " dash
  9454. regsub -all -- {-} $dash "6 " dash
  9455. # Multiply with stroke width if > 1.
  9456. if {[info exists styleArr(stroke-width)] && \
  9457. ($styleArr(stroke-width) > 1)} {
  9458. set width $styleArr(stroke-width)
  9459. set dashOrig $dash
  9460. set dash {}
  9461. foreach num $dashOrig {
  9462. lappend dash [expr int($width * $num)]
  9463. }
  9464. }
  9465. set styleArr(stroke-dasharray) [string trim $dash]
  9466. } else {
  9467. set styleArr(stroke-dasharray) $value
  9468. }
  9469. }
  9470. if {[string equal $type "polygon"]} {
  9471. set styleArr(fill-rule) "evenodd"
  9472. }
  9473. set style ""
  9474. foreach {key value} [array get styleArr] {
  9475. append style "${key}: ${value}; "
  9476. }
  9477. return [string trim $style]
  9478. }
  9479. proc ::can2svg::MakeImageAttr {coo opts} {
  9480. array set optArr {-anchor nw}
  9481. array set optArr $opts
  9482. set theImage $optArr(-image)
  9483. set w [image width $theImage]
  9484. set h [image height $theImage]
  9485. # We should make this an URI.
  9486. set theFile [$theImage cget -file]
  9487. set uri [UriFromLocalFile $theFile]
  9488. foreach {x0 y0} $coo {}
  9489. switch -- $optArr(-anchor) {
  9490. nw {
  9491. set x $x0
  9492. set y $y0
  9493. }
  9494. n {
  9495. set x [expr $x0 - $w/2.0]
  9496. set y $y0
  9497. }
  9498. ne {
  9499. set x [expr $x0 - $w]
  9500. set y $y0
  9501. }
  9502. e {
  9503. set x $x0
  9504. set y [expr $y0 - $h/2.0]
  9505. }
  9506. se {
  9507. set x [expr $x0 - $w]
  9508. set y [expr $y0 - $h]
  9509. }
  9510. s {
  9511. set x [expr $x0 - $w/2.0]
  9512. set y [expr $y0 - $h]
  9513. }
  9514. sw {
  9515. set x $x0
  9516. set y [expr $y0 - $h]
  9517. }
  9518. w {
  9519. set x $x0
  9520. set y [expr $y0 - $h/2.0]
  9521. }
  9522. center {
  9523. set x [expr $x0 - $w/2.0]
  9524. set y [expr $y0 - $h/2.0]
  9525. }
  9526. }
  9527. set attrList [list "x" $x "y" $y "width" $w "height" $h \
  9528. "xlink:href" $uri]
  9529. return $attrList
  9530. }
  9531. proc ::can2svg::GetTextSVGCoords {coo anchor chdata theFont nlines} {
  9532. foreach {x y} $coo {}
  9533. set ascent [font metrics $theFont -ascent]
  9534. set lineSpace [font metrics $theFont -linespace]
  9535. # If not anchored to the west it gets more complicated.
  9536. if {![string match $anchor "*w*"]} {
  9537. # Need to figure out the extent of the text.
  9538. if {$nlines <= 1} {
  9539. set textWidth [font measure $theFont $chdata]
  9540. } else {
  9541. set textWidth 0
  9542. foreach line [split $chdata "\n"] {
  9543. set lineWidth [font measure $theFont $line]
  9544. if {$lineWidth > $textWidth} {
  9545. set textWidth $lineWidth
  9546. }
  9547. }
  9548. }
  9549. }
  9550. switch -- $anchor {
  9551. nw {
  9552. set xbase $x
  9553. set ybase [expr $y + $ascent]
  9554. }
  9555. w {
  9556. set xbase $x
  9557. set ybase [expr $y - $nlines*$lineSpace/2.0 + $ascent]
  9558. }
  9559. sw {
  9560. set xbase $x
  9561. set ybase [expr $y - $nlines*$lineSpace + $ascent]
  9562. }
  9563. s {
  9564. set xbase [expr $x - $textWidth/2.0]
  9565. set ybase [expr $y - $nlines*$lineSpace + $ascent]
  9566. }
  9567. se {
  9568. set xbase [expr $x - $textWidth]
  9569. set ybase [expr $y - $nlines*$lineSpace + $ascent]
  9570. }
  9571. e {
  9572. set xbase [expr $x - $textWidth]
  9573. set ybase [expr $y - $nlines*$lineSpace/2.0 + $ascent]
  9574. }
  9575. ne {
  9576. set xbase [expr $x - $textWidth]
  9577. set ybase [expr $y + $ascent]
  9578. }
  9579. n {
  9580. set xbase [expr $x - $textWidth/2.0]
  9581. set ybase [expr $y + $ascent]
  9582. }
  9583. center {
  9584. set xbase [expr $x - $textWidth/2.0]
  9585. set ybase [expr $y - $nlines*$lineSpace/2.0 + $ascent]
  9586. }
  9587. }
  9588. return [list $xbase $ybase]
  9589. }
  9590. proc ::can2svg::MakeArrowMarker {a b c col} {
  9591. variable formatArrowMarker
  9592. variable formatArrowMarkerLast
  9593. catch {unset formatArrowMarker}
  9594. if {![info exists formatArrowMarker]} {
  9595. # "M 0 c, b 0, a c, b 2*c Z" for the start marker.
  9596. # "M 0 0, b c, 0 2*c, b-a c Z" for the last marker.
  9597. set data "M 0 %s, %s 0, %s %s, %s %s Z"
  9598. set style "fill: %s; stroke: %s;"
  9599. set attr [list "d" $data "style" $style]
  9600. set arrowList [MakeXMLList "path" -attrlist $attr]
  9601. set markerAttr [list "id" %s "markerWidth" %s "markerHeight" %s \
  9602. "refX" %s "refY" %s "orient" "auto"]
  9603. set defElemList [MakeXMLList "defs" -subtags \
  9604. [list [MakeXMLList "marker" -attrlist $markerAttr \
  9605. -subtags [list $arrowList] ] ] ]
  9606. set formatArrowMarker [MakeXML $defElemList]
  9607. # ...and the last arrow marker.
  9608. set dataLast "M 0 0, %s %s, 0 %s, %s %s Z"
  9609. set attrLast [list "d" $dataLast "style" $style]
  9610. set arrowLastList [MakeXMLList "path" -attrlist $attrLast]
  9611. set defElemLastList [MakeXMLList "defs" -subtags \
  9612. [list [MakeXMLList "marker" -attrlist $markerAttr \
  9613. -subtags [list $arrowLastList] ] ] ]
  9614. set formatArrowMarkerLast [MakeXML $defElemLastList]
  9615. }
  9616. set idKey "arrowMarkerDef_${col}_${a}_${b}_${c}"
  9617. set idKeyLast "arrowMarkerLastDef_${col}_${a}_${b}_${c}"
  9618. # Figure out the order of all %s substitutions.
  9619. set markerXML [format $formatArrowMarker $idKey \
  9620. $b [expr 2*$c] 0 $c \
  9621. $c $b $a $c $b [expr 2*$c] $col $col]
  9622. set markerLastXML [format $formatArrowMarkerLast $idKeyLast \
  9623. $b [expr 2*$c] $b $c \
  9624. $b $c [expr 2*$c] [expr $b-$a] $c $col $col]
  9625. return "$markerXML\n\t$markerLastXML"
  9626. }
  9627. proc ::can2svg::MakeGrayStippleDef {stipple} {
  9628. variable stippleDataArr
  9629. set pathList [MakeXMLList "path" -attrlist \
  9630. [list "d" $stippleDataArr($stipple) "style" "stroke: black; fill: none;"]]
  9631. set patterAttr [list "id" "tile$stipple" "x" 0 "y" 0 "width" 4 "height" 4 \
  9632. "patternUnits" "userSpaceOnUse"]
  9633. set defElemList [MakeXMLList "defs" -subtags \
  9634. [list [MakeXMLList "pattern" -attrlist $patterAttr \
  9635. -subtags [list $pathList] ] ] ]
  9636. return [MakeXML $defElemList]
  9637. }
  9638. proc ::can2svg::MapEmptyToNone {val} {
  9639. if {[string length $val] == 0} {
  9640. return "none"
  9641. } else {
  9642. return $val
  9643. }
  9644. }
  9645. proc ::can2svg::NormalizeRectCoords {coo} {
  9646. foreach {x1 y1 x2 y2} $coo {}
  9647. return [list [expr $x2 > $x1 ? $x1 : $x2] \
  9648. [expr $y2 > $y1 ? $y1 : $y2] \
  9649. [expr abs($x1-$x2)] \
  9650. [expr abs($y1-$y2)]]
  9651. }
  9652. proc ::can2svg::makedocument {width height xml} {
  9653. set pre "<?xml version=\"1.0\"?>
  9654. <!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"
  9655. \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">"
  9656. # <?xml version='1.1'?>\n\
  9657. # <!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\
  9658. # \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">"
  9659. #set svgStart "<svg width='$width' height='$height'>"
  9660. set svgStart "<svg xmlns=\"http://www.w3.org/2000/svg\"> \n <g id=\"g\" transform=\"translate(10, 10) scale(1.5)\">"
  9661. set svgEnd " </g>\n</svg>"
  9662. return "${pre}\n${svgStart}\n${xml}${svgEnd}"
  9663. }
  9664. proc ::can2svg::canvas2file {wcan path args} {
  9665. variable defsArrowMarkerArr
  9666. variable defsStipplePatternArr
  9667. # Need to make a fresh start for marker def's.
  9668. catch {unset defsArrowMarkerArr}
  9669. catch {unset defsStipplePatternArr}
  9670. #array set argsArr \
  9671. # [list -width [winfo width $wcan] -height [winfo height $wcan]]
  9672. # correction chevenet
  9673. $wcan configure -scrollregion [$wcan bbox all]
  9674. $wcan xview moveto 0
  9675. $wcan yview moveto 0
  9676. set width [expr [lindex [$wcan bbox all] 2] - [lindex [$wcan bbox all] 0]]
  9677. set height [expr [lindex [$wcan bbox all] 3] - [lindex [$wcan bbox all] 1]]
  9678. array set argsArr [list -width $width -height $height]
  9679. array set argsArr $args
  9680. set fd [open $path w]
  9681. set xml ""
  9682. # ici pour la modification sur les tags // hidden
  9683. foreach id [$wcan find all] {
  9684. set type [$wcan type $id]
  9685. set opts [$wcan itemconfigure $id]
  9686. set opcmd {}
  9687. foreach opt $opts {
  9688. set op [lindex $opt 0]
  9689. set val [lindex $opt 4]
  9690. # Empty val's except -fill can be stripped off.
  9691. if {![string equal $op "-fill"] && ([string length $val] == 0)} {
  9692. continue
  9693. }
  9694. lappend opcmd $op $val
  9695. }
  9696. set co [$wcan coords $id]
  9697. set cmd [concat "create" $type $co $opcmd]
  9698. append xml "\t[can2svg $cmd]\n"
  9699. }
  9700. regsub -all "'" [makedocument $argsArr(-width) $argsArr(-height) $xml] "\"" sgvdisplay
  9701. puts $fd $sgvdisplay
  9702. close $fd
  9703. }
  9704. proc ::can2svg::MakeXML {xmlList} {
  9705. # Extract the XML data items.
  9706. foreach {tag attrlist isempty chdata childlist} $xmlList {}
  9707. set rawxml "<$tag"
  9708. foreach {attr value} $attrlist {
  9709. append rawxml " ${attr}='${value}'"
  9710. }
  9711. if {$isempty} {
  9712. append rawxml "/>"
  9713. return $rawxml
  9714. } else {
  9715. append rawxml ">"
  9716. }
  9717. foreach child $childlist {
  9718. append rawxml [MakeXML $child]
  9719. }
  9720. # Make standard entity replacements.
  9721. if {[string length $chdata]} {
  9722. append rawxml [XMLCrypt $chdata]
  9723. }
  9724. append rawxml "</$tag>"
  9725. return $rawxml
  9726. }
  9727. proc ::can2svg::MakeXMLList {tagname args} {
  9728. array set xmlarr {-isempty 1 -attrlist {} -chdata {} -subtags {}}
  9729. if {[llength $args] > 0} {
  9730. array set xmlarr $args
  9731. }
  9732. if {!(($xmlarr(-chdata) == "") && ($xmlarr(-subtags) == ""))} {
  9733. set xmlarr(-isempty) 0
  9734. }
  9735. set sublist {}
  9736. foreach child $xmlarr(-subtags) {
  9737. lappend sublist $child
  9738. }
  9739. set xmlList [list $tagname $xmlarr(-attrlist) $xmlarr(-isempty) \
  9740. $xmlarr(-chdata) $sublist]
  9741. return $xmlList
  9742. }
  9743. proc ::can2svg::XMLCrypt {chdata} {
  9744. foreach from {\& < > {"} {'}} \
  9745. to {{\&amp;} {\&lt;} {\&gt;} {\&quot;} {\&apos;}} {
  9746. regsub -all $from $chdata $to chdata
  9747. }
  9748. return $chdata
  9749. }
  9750. proc ::can2svg::UriFromLocalFile {path} {
  9751. if {[string equal $::tcl_platform(platform) "windows"]} {
  9752. set vol_ {([A-Z]:/|[A-Z]:\\)}
  9753. regexp "${vol_}+(.+)$" $path match x path
  9754. }
  9755. set pathList [split $path "/:\\"]
  9756. set pathJoin [join $pathList /]
  9757. regsub -all -- " " $pathJoin "%20" pathJoin
  9758. return file:///${pathJoin}
  9759. }
  9760. }
  9761. }
  9762. ####################
  9763. # AMELIE
  9764. ####################
  9765. namespace eval Amelie {
  9766. #
  9767. proc faiaddGo1 {lv} {
  9768. global S
  9769. set lkv [array get S *,tar]
  9770. set ltreetarget {}
  9771. foreach {k v} $lkv {
  9772. if {$S($k) == 1} {
  9773. lappend ltreetarget [string range $k 0 [expr [string first , $k] - 1]]
  9774. }
  9775. }
  9776. foreach v $lv {
  9777. DrawGoAuto [list $v] $ltreetarget
  9778. }
  9779. }
  9780. #
  9781. proc faiaddGo2 {w t database variable eu} {
  9782. global S
  9783. set records [Database::dbQueryRecordsFromVarVal $database EU $eu]
  9784. set values [Database::dbQueryVarFromRecords $database $variable $records]
  9785. set i [format "%s%s%s" $eu : $values ]
  9786. faiaddGo1 [list $i]
  9787. }
  9788. #
  9789. proc userColor {id} {
  9790. global S
  9791. set S(col) [tk_chooseColor]
  9792. $id configure -background $S(col)
  9793. }
  9794. #
  9795. proc PatternSelection {w} {
  9796. global S
  9797. $w selection clear 0 end
  9798. set litems [$w get 0 end]
  9799. set id 0
  9800. foreach i $litems {
  9801. set leaf [lindex [split $i :] 0]
  9802. if {[string match $S(IGfilter) $leaf]} {$w selection set $id }
  9803. incr id
  9804. }
  9805. $w yview [lindex [$w curselection] 0]
  9806. }
  9807. #
  9808. proc GenId {} {
  9809. global S
  9810. incr S(nbobj)
  9811. return [format "%s%s" [clock second] $S(nbobj)]
  9812. }
  9813. #
  9814. proc ColorSpecific {w} {
  9815. global S
  9816. $w configure -background $S(col)
  9817. set S(AmelieColor) $S(col)
  9818. }
  9819. # ls : listbox source ; lt listbox target
  9820. proc AnnotateAddItem {ls lt} {
  9821. global S
  9822. if {$S(database) != ""} {
  9823. $lt delete 0 end
  9824. set variable [$ls get [$ls curselection]]
  9825. set lrecords [Database::dbQueryRecordsAll $S(database)]
  9826. set lres {}
  9827. foreach record $lrecords {
  9828. set leaf [Database::dbQueryVarFromRecords $S(database) EU $record]
  9829. set int [Database::dbQueryVarFromRecords $S(database) $variable $record]
  9830. #$lt insert end [format "%s%s%s" $leaf : $int ]
  9831. lappend lres [format "%s%s%s" $leaf : $int ]
  9832. }
  9833. foreach r [lsort -dictionary $lres] {
  9834. $lt insert end $r
  9835. }
  9836. }
  9837. }
  9838. #
  9839. proc CommunRoot {index s1 s2 string} {
  9840. if {[string equal [string index $s1 $index] [string index $s2 $index]]} {
  9841. CommunRoot [expr $index +1] $s1 $s2 $string[string index $s1 $index]
  9842. } else {
  9843. return [string length $string]
  9844. }
  9845. }
  9846. #
  9847. proc CommunRoot2 {index s1 s2 string} {
  9848. if {[string equal $s1 $s2]} {
  9849. return $string
  9850. }
  9851. if {[string equal [string index $s1 $index] [string index $s2 $index]]} {
  9852. CommunRoot2 [expr $index +1] $s1 $s2 $string[string index $s1 $index]
  9853. } else {
  9854. return $string
  9855. }
  9856. }
  9857. #
  9858. proc DrawGoUser {lv ltreetarget} {
  9859. global S ann T
  9860. foreach ti $ltreetarget {
  9861. switch -exact $S($ti,type) {
  9862. PhyNJ - ClaSla - ClaRec {
  9863. set database $S(database)
  9864. upvar #0 $S(database) X
  9865. set w $S($ti,w)
  9866. set XMAX1 [lindex [$w bbox [list T$ti && Z]] 2]
  9867. set XMAX2 [lindex [$w bbox [list T$ti && L]] 2]
  9868. if {$XMAX1 < $XMAX2} {set XMAX $XMAX2 } {set XMAX $XMAX1}
  9869. set x [expr $XMAX + $S(IGtabul)]
  9870. set tagS [format "%s%s%s" SEL ? [Tools::GenId]]
  9871. foreach v $lv {
  9872. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  9873. set vsplit [split $v ":"]
  9874. set l [lindex $vsplit 0] ;# source
  9875. set ll [lindex [lindex $vsplit end] 0] ;# targets
  9876. set y1 [WhatY $w $ti $l]
  9877. foreach vi [split $ll] {
  9878. set tagos [format "%s%s%s%s%s" ARCU ? $l ? $vi]
  9879. if {$vi != $l} {
  9880. set y2 [WhatY $w $ti $vi]
  9881. set ymoy [expr ($y1 + $y2) / 2]
  9882. if {$y1 != 0 && $y2 !=0 } {
  9883. $w create line $x $y1 [expr $x + $S(IGcurve)] $ymoy \
  9884. $x $y2 -width $S(IGline) -smooth 1 -splinesteps 100 -fill $S(col) \
  9885. -tags "T$ti A$ti $tagC Arc$l Arc$vi Arc $tagS $tagos"
  9886. if {$S(IGannot) == 1} {
  9887. $w create text $x $y1 \
  9888. -fill $S(col) -anchor e -text "$l" -font $S(gfo)\
  9889. -tags "T$ti A$ti $tagC Arc$l Arc$vi Arc $tagS $tagos"
  9890. $w create text $x $y2 \
  9891. -fill $S(col) -anchor e -text "$vi" -font $S(gfo)\
  9892. -tags "T$ti A$ti $tagC Arc$l Arc$vi Arc $tagS $tagos"
  9893. }
  9894. }
  9895. } else {
  9896. set y2 [WhatY $w $ti $vi]
  9897. set ymoy [expr ($y1 + $y2) / 2]
  9898. if {$y1 != 0 && $y2 !=0 } {
  9899. $w create oval [expr $x - 20] [expr $y1 -5] $x [expr $y1 +5] -outline $S(col) \
  9900. -tags "T$ti A$ti $tagC Arc$l Arc$vi Arc $tagos $tagS "
  9901. }
  9902. }
  9903. }
  9904. }
  9905. }
  9906. PhyRad - PhyCir1 - PhyCir2 - ClaRad {
  9907. }
  9908. ClaCir1 - ClaCir2 {
  9909. }
  9910. ClaCir3 {
  9911. set database $S(database)
  9912. upvar #0 $S(database) X
  9913. set w $S($ti,w)
  9914. set co [$w bbox [list T$ti && Z]]
  9915. set x1 [lindex $co 0]
  9916. set y1 [lindex $co 1]
  9917. set x2 [lindex $co 2]
  9918. set y2 [lindex $co 3]
  9919. set xcenter [expr double($x2 + $x1)/2]
  9920. set ycenter [expr double($y2 + $y1)/2]
  9921. set tagS [format "%s%s%s" SEL ? [Tools::GenId]]
  9922. foreach v $lv {
  9923. set tagC [format "%s%s%s" COL ? [Tools::GenId]]
  9924. set vsplit [split $v ":"]
  9925. set l [lindex $vsplit 0] ;# source
  9926. set ll [lindex [lindex $vsplit end] 0] ;# targets
  9927. foreach vi [split $ll] {
  9928. set tagos [format "%s%s%s%s%s" ARCU ? $l ? $vi]
  9929. if {[lsearch $T($ti,ue_lab) $vi] != -1 && [lsearch $T($ti,ue_lab) $l] != -1} {
  9930. set coVI [$w coords [$w find withtag [list [format "%s%s" $T($ti,ltc,$vi) C ] && T$ti]]]
  9931. set coL [$w coords [$w find withtag [list [format "%s%s" $T($ti,ltc,$l) C ] && T$ti]]]
  9932. set xVI [lindex $coVI 2]
  9933. set yVI [lindex $coVI 3]
  9934. set xL [lindex $coL 2]
  9935. set yL [lindex $coL 3]
  9936. if {$yVI != 0 && $yL !=0 && $xVI !=0 && $xL !=0} {
  9937. $w create line $xVI $yVI $xcenter $ycenter $xL $yL \
  9938. -width $S(IGline) -smooth 1 -splinesteps 100 -fill $S(col) \
  9939. -tags "T$ti A$ti $tagC Arc$l Arc$vi Arc $tagos $tagS"
  9940. }
  9941. }
  9942. }
  9943. }
  9944. }
  9945. }
  9946. }
  9947. }
  9948. #
  9949. proc WhatY {w t l} {
  9950. set item [$w find withtag [list [format "%s%s" EUL $l ] && T$t]]
  9951. if {$item == ""} {
  9952. set items [$w find withtag [list ADD?$l && T$t]]
  9953. set y 0
  9954. foreach ii $items {
  9955. set yii [lindex [$w coords $ii] 1]
  9956. if {$yii >= $y} {
  9957. set y $yii
  9958. }
  9959. }
  9960. } else {
  9961. set co [$w coords $item]
  9962. set y [lindex $co 1]
  9963. }
  9964. return $y
  9965. }
  9966. }
  9967. ####################
  9968. ####################
  9969. # TDCOM
  9970. ####################
  9971. namespace eval TDcom {
  9972. proc com {argv} {
  9973. wm withdraw .
  9974. global T S Export asedCon fileGeneric
  9975. set S(version) 179
  9976. set S(ilw) 0
  9977. set S(display_eu) normal
  9978. set S(gfo) {Helvetica 8 normal}
  9979. set S(lastid) 0
  9980. set S(nbobj) 0
  9981. set S(database) ""
  9982. set S(ldatabase) {}
  9983. set S(nodefilter) 0
  9984. set S(stipple) z.xbm
  9985. set S(defaultshape) 1
  9986. # default values for tree command
  9987. set S(tree-conformation) 01
  9988. set S(tree-x) 10
  9989. set S(tree-y) 20
  9990. set S(tree-height) auto
  9991. set S(tree-width) 150
  9992. set S(tree-font) {Helvetica 8 normal}
  9993. set S(tree-foreground) black
  9994. set S(tree-background) none
  9995. set S(tree-outline) none
  9996. set S(tree-state) normal
  9997. set S(tree-linewidth) 1
  9998. set S(tree-symbol) none
  9999. set S(tree-text) none
  10000. set S(tree-scale) none
  10001. #
  10002. set S(operation) nodebgcolor
  10003. set S(symboldy) 3
  10004. set fileTLF ""
  10005. set fileTDS ""
  10006. set fileGeneric out
  10007. # pour test en local
  10008. set S(TDOcgiDIR) [pwd]
  10009. set S(TDOhtmlDIR) [pwd]
  10010. foreach {k v} $argv {
  10011. switch -- $k {
  10012. "-tree" {
  10013. set fileNWK [file join $S(TDOcgiDIR) $v]
  10014. }
  10015. "-label" {
  10016. set fileTLF [file join $S(TDOcgiDIR) $v]
  10017. }
  10018. "-script" {
  10019. set fileTDS [file join $S(TDOcgiDIR) $v]
  10020. }
  10021. "-out" {
  10022. set fileGeneric $v
  10023. }
  10024. }
  10025. }
  10026. set fid [open $fileNWK r]
  10027. set s [read -nonewline $fid]
  10028. close $fid
  10029. regsub -all "\n| " $s "" s
  10030. regsub -all {\[} $s "" s
  10031. regsub -all {:-} $s ":" s
  10032. regsub -all {\]} $s "" s
  10033. set l [split $s ";"]
  10034. set t 0
  10035. set c .c
  10036. set S($c,t) {}
  10037. set S($c,con) {} ;# la liste des ID des connectors de la fenetre
  10038. set S($c,com) {} ;# la liste des ID des comments de la fenetre
  10039. set S(sav,$c) ""
  10040. set S($c,BIcol) ?
  10041. set S($c,BIrow) ?
  10042. canvas .c
  10043. foreach s [lrange $l 0 end-1] {
  10044. TDcom::NewickToTreeDyn $s
  10045. set lkv [array get Export]
  10046. foreach {key value} $lkv {set T(xxx,$key) $value}
  10047. unset Export
  10048. incr t
  10049. lappend S(ilt) $t
  10050. lappend S($c,t) $t
  10051. set S($t,w) $c
  10052. set S($t,tar) 1
  10053. TDcom::TreeInit $t
  10054. TDcom::xxxEncode $t
  10055. TDcom::PhyNJ $t $c
  10056. }
  10057. set S(targetTree) $t
  10058. set S(targetWind) $c
  10059. if {$fileTLF != ""} {TDcom::LoadAnnotations $fileTLF}
  10060. if {$fileTDS != ""} {TDcom::OpenScript $fileTDS}
  10061. ### EXPORT
  10062. TDcom::exportPS [file join $S(TDOhtmlDIR) $fileGeneric] $c
  10063. TDcom::exportTGF [file join $S(TDOhtmlDIR) $fileGeneric] $c
  10064. TDcom::exportSVG [file join $S(TDOhtmlDIR) $fileGeneric] $c
  10065. exit
  10066. }
  10067. ###
  10068. proc xxxEncode {t} {
  10069. global T
  10070. set uold xxx
  10071. set unew $t
  10072. set kvT [array get T xxx*]
  10073. foreach {key value} $kvT {
  10074. regsub -all xxx $value $t valueswi
  10075. unset T($key) ; regsub -all xxx $key $t keyswi ; set T($keyswi) $valueswi
  10076. }
  10077. }
  10078. ### TreeInit
  10079. proc TreeInit {t} {
  10080. global T S B
  10081. set S($t,orient) W
  10082. set S($t,a_ori) 0 ;# angle aditionel utilise dans les rotations
  10083. set S($t,a_uni) 0 ;# unite d'angle
  10084. set S($t,tit) "" ;# le pathcut2 du fichier tdy
  10085. set S($t,type) PhyNJ ;# le type de tree par defaut
  10086. set S($t,init) 0 ;# cette variable fixe le mode inclusif/exclusif du panel identification
  10087. set S($t,display_eu) $S(display_eu)
  10088. set S($t,LabelMatrixBase) 5 ;# matrice d'annotation
  10089. set T($t,eu_collapse) {} ;# liste des noms de feuilles a retirer en abstraction
  10090. set T($t,xmax) 0 ;# branch length max
  10091. set T($t,tot) 0 ;# level max
  10092. set T($t,all_cod) {} ;# codes nodes
  10093. set T($t,ue_cod) {} ;# UE - codes LISTE ORDONNEE
  10094. set T($t,ue_lab) {} ;# UE - labels LISTE ORDONNEE
  10095. set B($t,shi) {} ;# List des nodes shrink
  10096. set B($t,qyn) {} ;# list des items querynode
  10097. set B($t,ova) {} ;# la liste des node reliant 1 tree (decomposition)
  10098. set B($t,bll) {} ;# la liste des nodes ayant des BLL (bulles labels link : eu;db,users)
  10099. set B($t,bgs) {} ;# la liste des items background nodes
  10100. set B($t,bgl) {} ;# la liste des items background leaves
  10101. set B($t,con) {} ;# la liste des r?Šseaux de connection
  10102. }
  10103. ###
  10104. proc exportPS {file c} {
  10105. global S T
  10106. foreach {x0 y0 x1 y1} [$c bbox all] {}
  10107. set w [expr $x1 - $x0]
  10108. set h [expr $y1 - $y0]
  10109. $c postscript -file [format "%s%s" $file .ps] -colormode color \
  10110. -x $x0 -y $y0 -width $w -height $h \
  10111. -pagex 0 -pagey 0 -pagewidth 20.c -pageheight 30.c \
  10112. -pageanchor nw
  10113. }
  10114. ###
  10115. proc exportTGF {file c} {
  10116. global S
  10117. set file [format "%s%s" $file .tgf]
  10118. set script [canvas_saveArray $c $S($c,t)]
  10119. append script [canvas_saveItems $c $S($c,t)]
  10120. set fid [open $file w]
  10121. set data [split $script "\n"]
  10122. foreach elt $data {puts $fid $elt}
  10123. close $fid
  10124. }
  10125. ###
  10126. proc exportSVG {file c} {
  10127. global S
  10128. set file [format "%s%s" $file .svg]
  10129. ::can2svg::canvas2file $c $file
  10130. }
  10131. ###
  10132. proc canvas_saveArray {w lt} {
  10133. global S T B
  10134. set script "### $S(version)\n"
  10135. append script "set E(tree) \{$lt\} \n"
  10136. #set script "set E(tree) \{$lt\} \n"
  10137. # attention a conserver l'espace entre "\{" et $v
  10138. foreach t $lt {
  10139. set pattern [format "%s%s%s" $t , * ]
  10140. ######### ARRAY T
  10141. append script "### T\n"
  10142. foreach {k v} [array get T [format "%s%s" $t *]] {
  10143. append script "set ET($k) \{ $v\} \n"
  10144. }
  10145. ######### ARRAY S
  10146. append script "### S\n"
  10147. foreach {k v} [array get S [format "%s%s" $t *]] {
  10148. append script "set ES($k) \{ $v\} \n"
  10149. }
  10150. ######### ARRAY B ici pas d'espace avant v
  10151. append script "### B\n"
  10152. foreach {k v} [array get B [format "%s%s" $t *]] {
  10153. append script "set EB($k) \{$v\} \n"
  10154. }
  10155. # B // BGS
  10156. foreach Id $B($t,bgs) {
  10157. set pattern [format "%s%s%s" BGS* , $Id]
  10158. foreach {k v} [array get B $pattern] {
  10159. append script "set EB($k) \{ $v\} \n"
  10160. }
  10161. }
  10162. # B // BGL
  10163. foreach Id $B($t,bgl) {
  10164. set pattern [format "%s%s%s" BGL* , $Id]
  10165. foreach {k v} [array get B $pattern] {
  10166. append script "set EB($k) \{ $v\} \n"
  10167. }
  10168. }
  10169. # B // SHI
  10170. foreach Id $B($t,shi) {
  10171. set pattern [format "%s%s%s" SHI* , $Id]
  10172. foreach {k v} [array get B $pattern] {
  10173. append script "set EB($k) \{ $v\} \n"
  10174. }
  10175. }
  10176. # B // BLL
  10177. foreach Id $B($t,bll) {
  10178. set pattern [format "%s%s%s" BLL* , $Id]
  10179. foreach {k v} [array get B $pattern] {
  10180. append script "set EB($k) \{ $v\} \n"
  10181. }
  10182. }
  10183. # B // QYN
  10184. foreach i $B($t,qyn) {
  10185. set pattern [format "%s%s%s" QYN* , $i]
  10186. foreach {k v} [array get B $pattern] {
  10187. append script "set EB($k) \{ $v\} \n"
  10188. }
  10189. }
  10190. # B // OVA
  10191. foreach i $B($t,ova) {
  10192. set pattern [format "%s%s%s" OVA* , $i]
  10193. foreach {k v} [array get B $pattern] {
  10194. append script "set EB($k) \{ $v\} \n"
  10195. }
  10196. }
  10197. }
  10198. # items sans reference a un IDtree, ou faisant reference a plusieurs IDtree
  10199. # B // CON = connectors
  10200. append script "set ES(con) \{$S($w,con)\} \n"
  10201. foreach i $S($w,con) {
  10202. set pattern [format "%s%s%s" CON* , $i]
  10203. foreach {k v} [array get B $pattern] {
  10204. append script "set EB($k) \{ $v\} \n"
  10205. }
  10206. }
  10207. # B // COM = comments
  10208. # FIN
  10209. return $script
  10210. }
  10211. ###
  10212. proc canvas_saveItems {w lt} {
  10213. global S
  10214. foreach t $lt {
  10215. set lid { }
  10216. foreach item [$w find withtag T$t] {
  10217. set id [Tools::GenId]
  10218. lappend lid $id
  10219. set tags [$w gettags $item]
  10220. set type [$w type $item]
  10221. set coords [$w coords $item]
  10222. set opts ""
  10223. foreach desc [$w itemconfigure $item] {
  10224. set name [lindex $desc 0]
  10225. set init [lindex $desc 3]
  10226. set val [lindex $desc 4]
  10227. # correction bug canvas qui place la valeur "bezier" au lieu de "true"
  10228. # comme valeur de l'option -smooth dans les items canvas
  10229. if {$val == "bezier"} {set val true}
  10230. if {$val != $init} {
  10231. if {$name != "-tags"} {
  10232. lappend opts $name $val
  10233. }
  10234. }
  10235. }
  10236. append script "set EC($t,opts,$id) \{ $type $coords $opts\} \n"
  10237. append script "set EC($t,tags,$id) \{ $tags\} \n"
  10238. }
  10239. append script "set EC($t,ids) \{ $lid\} \n"
  10240. }
  10241. # items graphique non identifie par $id
  10242. # cas des connectors par exemple
  10243. # cas des notes canvas par exemple
  10244. # CONNECTORS, 2 type d'items : line et chaine d'iconification (tags distincts)
  10245. foreach item [$w find withtag {Connect || ConnectIcon}] {
  10246. set id [Tools::GenId]
  10247. lappend lid $id
  10248. set tags [$w gettags $item]
  10249. set type [$w type $item]
  10250. set coords [$w coords $item]
  10251. set opts ""
  10252. foreach desc [$w itemconfigure $item] {
  10253. set name [lindex $desc 0]
  10254. set init [lindex $desc 3]
  10255. set val [lindex $desc 4]
  10256. if {$val != $init} {
  10257. if {$name != "-tags"} {
  10258. lappend opts $name $val
  10259. }
  10260. }
  10261. }
  10262. append script "set EC($t,opts,$id) \{ $type $coords $opts\} \n"
  10263. append script "set EC($t,tags,$id) \{ $tags\} \n"
  10264. }
  10265. #essai save legend
  10266. foreach item [$w find withtag Legend] {
  10267. set id [Tools::GenId]
  10268. lappend lid $id
  10269. set tags [$w gettags $item]
  10270. set type [$w type $item]
  10271. set coords [$w coords $item]
  10272. set opts ""
  10273. foreach desc [$w itemconfigure $item] {
  10274. set name [lindex $desc 0]
  10275. set init [lindex $desc 3]
  10276. set val [lindex $desc 4]
  10277. if {$val != $init} {
  10278. if {$name != "-tags"} {
  10279. lappend opts $name $val
  10280. }
  10281. }
  10282. }
  10283. append script "set EC($t,opts,$id) \{ $type $coords $opts\} \n"
  10284. append script "set EC($t,tags,$id) \{ $tags\} \n"
  10285. }
  10286. append script "set EC($t,ids) \{ $lid\} \n"
  10287. # FIN
  10288. return $script
  10289. }
  10290. ###
  10291. proc NewickToTreeDyn {s} {
  10292. global Export
  10293. set code xxx ; set n 0
  10294. set Export(xmax) 0
  10295. set Export(tot) 0
  10296. set Export(all_cod) $code
  10297. set Export(ue_lab) {}
  10298. set Export(ue_cod) {}
  10299. set Export(Duplication) {}
  10300. if {[string match *:* $s] == 0} {
  10301. regsub -all "," $s {:1.0,} s
  10302. regsub -all {\)} $s {:1.0)} s
  10303. }
  10304. set Export(dbl,$code) 0
  10305. set Export(nwk,$code) $s
  10306. if {[Dicho $s] == 1} {
  10307. set s [format "%s%s%s" ( $s ):0]
  10308. }
  10309. set tp [string last ")" $s]
  10310. set dt [string range $s 0 $tp]
  10311. if {[string compare [string range $dt 0 0] ( ] != 0 || \
  10312. [string compare [string range $dt end end] ) ] != 0} {
  10313. set dt [format "%s%s%s" ( $dt )]
  10314. }
  10315. set id [BgBdx $dt]
  10316. set bg [string range $dt [expr $id + 1] [expr [string length $dt] - 2]]
  10317. set bd [string range $dt 1 [expr $id - 1]]
  10318. lappend Export(cbg,$n) 0
  10319. incr n
  10320. NewickParser $bg [format "%s%s" $code g] $n 0
  10321. NewickParser $bd [format "%s%s" $code d] $n 0
  10322. return
  10323. }
  10324. ###
  10325. proc NewickParser {s code n sx} {
  10326. global Export
  10327. lappend Export(all_cod) $code
  10328. set Export(nwk,$code) $s
  10329. if {[string match *,* $s]} {
  10330. if {[Dicho $s] == 1} {
  10331. set s [format "%s%s%s" ( $s ):0]
  10332. }
  10333. set tp [string last ")" $s]
  10334. set dt [string range $s 0 $tp]
  10335. set dx [string range $s [expr $tp + 1] end]
  10336. set Export(dbl,$code) [expr abs([string range $dx [expr [string last ":" $dx] + 1] end])]
  10337. set Export(dbv,$code) [string range $dx 0 [expr [string last ":" $dx] - 1]]
  10338. if {[string compare [string range $dt 0 0] ( ] != 0 || \
  10339. [string compare [string range $dt end end] ) ] != 0} {
  10340. set dt [format "%s%s%s" ( $dt )]
  10341. }
  10342. set id [BgBdx $dt]
  10343. set bg [string range $dt [expr $id + 1] [expr [string length $dt] - 2]]
  10344. set bd [string range $dt 1 [expr $id - 1]]
  10345. lappend Export(cbg,$n) [format "%s%s" $code $n]
  10346. NewickParser $bg [format "%s%s%s" $code $n g] [expr $n +1] [expr $sx + $Export(dbl,$code)]
  10347. NewickParser $bd [format "%s%s%s" $code $n d] [expr $n +1] [expr $sx + $Export(dbl,$code)]
  10348. } {
  10349. set tp [string last ":" $s]
  10350. set dt [string range $s 0 [expr $tp - 1]]
  10351. set dx [string range $s [expr $tp + 1] end]
  10352. set Export(dbl,$code) [expr abs([string range $dx [expr [string last ":" $dx] + 1] end])]
  10353. if {[lsearch $Export(ue_lab) $dt] == -1} {
  10354. lappend Export(ue_lab) $dt
  10355. set Export(ctl,$code) $dt
  10356. set Export(ltc,$dt) $code
  10357. } else {
  10358. set newdt [format "%s%s%s" $dt - [GenId]]
  10359. lappend Export(Duplication) "$dt swtich to $newdt"
  10360. lappend Export(ue_lab) $newdt
  10361. set Export(ctl,$code) $newdt
  10362. set Export(ltc,$newdt) $code
  10363. }
  10364. lappend Export(ue_cod) $code
  10365. set sx [expr $sx + $dx]
  10366. set Export(sox,$code) $sx
  10367. if {$sx >= $Export(xmax)} {set Export(xmax) $sx}
  10368. if {$n >= $Export(tot)} {set Export(tot) $n}
  10369. return
  10370. }
  10371. }
  10372. ###
  10373. proc GenId {} {
  10374. global S
  10375. incr S(nbobj)
  10376. return [format "%s%s" [clock second] $S(nbobj)]
  10377. }
  10378. ###
  10379. proc BgBdx {s} {
  10380. set i -1
  10381. set id -1
  10382. foreach c [split $s {}] {
  10383. incr id
  10384. switch -exact -- $c {
  10385. ( {incr i}
  10386. ) {incr i -1}
  10387. , {if {$i == 0} {return $id}}
  10388. }
  10389. }
  10390. return ""
  10391. }
  10392. ###
  10393. proc Dicho {s} {
  10394. set i 0 ; set id 0 ; set r 1
  10395. foreach c [split $s {}] {
  10396. switch -exact -- $c {
  10397. ( {incr i}
  10398. ) {incr i -1}
  10399. }
  10400. if {$i == 0} {
  10401. set r [string match *,* [string range $s [expr $id + 1] end]]
  10402. break
  10403. }
  10404. incr id
  10405. }
  10406. return $r
  10407. }
  10408. ###
  10409. proc PhyNJ {t w} {
  10410. global T S
  10411. set y 0
  10412. set nb [llength $T($t,ue_cod)]
  10413. set largeur $S(tree-width)
  10414. if {$S(tree-height) == "auto"} {
  10415. set hauteur [expr 10 * $nb]
  10416. } else {
  10417. set hauteur $S(tree-height)
  10418. }
  10419. set fy [expr double($hauteur) / $nb ]
  10420. set fx [expr double($largeur) / $T($t,xmax)]
  10421. set n 0
  10422. set t3 [format "%s%s" T $t ]
  10423. ### EU
  10424. foreach i $T($t,ue_cod) {
  10425. incr n
  10426. set y [expr $n * $fy ]
  10427. set G($i,x) [expr ($T($t,sox,$i) - $T($t,dbl,$i) )* $fx]
  10428. set G($i,y) $y
  10429. set t2 [format "%s%s" EU $T($t,ctl,$i) ]
  10430. set t4 [format "%s%s" EUL $T($t,ctl,$i) ]
  10431. set t2bis [format "%s%s" $i C]
  10432. $w create line [expr $T($t,sox,$i) * $fx] $G($i,y) $G($i,x) $G($i,y) \
  10433. -tags "$i $t2 $t3 $t2bis Z" -fill $S(tree-foreground) -width $S(tree-linewidth)
  10434. $w create text [expr ($T($t,sox,$i) * $fx) + 2] $G($i,y) \
  10435. -text $T($t,ctl,$i) -anchor w \
  10436. -tags " $t3 $t4 L" \
  10437. -font $S(tree-font) -state $S(tree-state)
  10438. }
  10439. ### NODES
  10440. for {set i [expr $T($t,tot) - 1 ]} {$i >= 1} {incr i -1} {
  10441. foreach b $T($t,cbg,$i) {
  10442. set bg [format "%s%s" $b g]
  10443. set bd [format "%s%s" $b d]
  10444. set yn [expr $G($bg,y) - (($G($bg,y) - $G($bd,y)) / 2)]
  10445. set j [string range $bg 0 [expr [string last $i $bg] - 1]]
  10446. set t2 [format "%s%s" $j C]
  10447. # Vertical
  10448. $w create line $G($bg,x) $G($bg,y) $G($bg,x) $G($bd,y) -tags "$t2 $t3 Z" -fill $S(tree-foreground) -width $S(tree-linewidth)
  10449. # Horizontal
  10450. set G($j,x) [expr $G($bg,x) - ($T($t,dbl,$j) * $fx)]
  10451. $w create line $G($bg,x) $yn $G($j,x) $yn -tags "$j $t2 $t3 Z" -fill $S(tree-foreground) -width $S(tree-linewidth)
  10452. set G($j,y) $yn
  10453. }
  10454. }
  10455. unset G
  10456. ### ROOT
  10457. set ch [$w coords [format "%s%s" $t g]]
  10458. set cb [$w coords [format "%s%s" $t d]]
  10459. set yh [lrange $ch 1 1]
  10460. set yb [lrange $cb 3 3]
  10461. set x [lrange $ch 2 2]
  10462. set yn [expr $yh - (($yh - $yb) / 2)]
  10463. $w create line $x $yh $x $yb -tags "[format "%s%s" $t C] $t3 Z" -fill $S(tree-foreground) -width $S(tree-linewidth)
  10464. $w configure -scrollregion [$w bbox all]
  10465. # POSITION TREE
  10466. $w move $t3 $S(tree-x) $S(tree-y)
  10467. # BACKGROUND TREE passer au bg sur node 0
  10468. # if {$S(tree-background) != "none"} {
  10469. # set coords [$w bbox $t3]
  10470. # set x1 [lindex $coords 0]
  10471. # set y1 [lindex $coords 1]
  10472. # set x2 [lindex $coords 2]
  10473. # set y2 [lindex $coords 3]
  10474. # set id [ $w create rectangle $x1 $y1 $x2 $y2 -tags "$t3 " -fill $S(tree-background) -outline $S(tree-outline) ]
  10475. # $w lower $id
  10476. # }
  10477. # SYMBOL TREE {none ou {$type $x $y $width $height $color $stipple}}
  10478. if {$S(tree-symbol) != "none"} {
  10479. set S(symboltype) [lindex $S(tree-symbol) 0]
  10480. set x [lindex $S(tree-symbol) 1]
  10481. set y [lindex $S(tree-symbol) 2]
  10482. set S(symboldx) [expr [lindex $S(tree-symbol) 3] / 2.0]
  10483. set S(symboldy) [expr [lindex $S(tree-symbol) 4] / 2.0]
  10484. set S(symbolcolorfill) [lindex $S(tree-symbol) 5]
  10485. set S(symbolcoloroutline) [lindex $S(tree-symbol) 5]
  10486. switch -- [lindex $S(tree-symbol) 6] {
  10487. 01 { set S(symbolstipple) z.xbm}
  10488. 02 { set S(symbolstipple) a.xbm}
  10489. 03 { set S(symbolstipple) b.xbm}
  10490. 04 { set S(symbolstipple) h.xbm}
  10491. 05 { set S(symbolstipple) j.xbm}
  10492. }
  10493. Illustration::drawsymbol $w $x $y $t3
  10494. }
  10495. # TEXT TREE {none ou {$text $x $y $font $color}}
  10496. if {$S(tree-text) != "none"} {
  10497. set text [lindex $S(tree-text) 0]
  10498. set x [lindex $S(tree-text) 1]
  10499. set y [lindex $S(tree-text) 2]
  10500. set font [lindex $S(tree-text) 3]
  10501. set color [lindex $S(tree-text) 4]
  10502. $w create text $x $y -text $text -anchor w -tags " $t3" -font $font -fill $color
  10503. }
  10504. # SCALE TREE {none ou {$x $y $color}}
  10505. if {$S(tree-scale) != "none"} {
  10506. set x [lindex $S(tree-scale) 0]
  10507. set y [lindex $S(tree-scale) 1]
  10508. set color [lindex $S(tree-scale) 2]
  10509. Annotation::AnnotateBuiltIn $w $t $x $y Scale $color
  10510. }
  10511. }
  10512. proc PhyRad {t w} {
  10513. global T S G
  10514. set S($t,a_ori) 0
  10515. set nb [llength $T($t,ue_cod)]
  10516. set largeur $S(treewidth)
  10517. if {$S(treeheight) == "auto"} {
  10518. set hauteur [expr 10 * $nb]
  10519. } else {
  10520. set hauteur $S(treeheight)
  10521. }
  10522. set x0 [expr $largeur/2.0]
  10523. set y0 [expr $hauteur/2.0]
  10524. if {$x0 <= $y0} {set R $x0} {set R $y0}
  10525. set pi2 [expr 2 * acos(-1)]
  10526. set f [expr $R / $T($t,xmax)]
  10527. set dd [expr ((acos(-1)) * [expr 360.0 / $nb])/ 180.0]
  10528. set S($t,a_uni) $dd
  10529. set td [format "%s%s" $t d]
  10530. set tg [format "%s%s" $t g]
  10531. set nbg [Tools::NodeNoToLeNum $t $tg]
  10532. set nbd [Tools::NodeNoToLeNum $t $td]
  10533. # $t d
  10534. set G($td,a_amplitude) [expr $nbd * $dd]
  10535. #set G($td,a_from) 0 modification pour la rotation
  10536. set G($td,a_from) $S($t,a_ori)
  10537. set G($td,a_to) [expr $G($td,a_from) + $G($td,a_amplitude) ]
  10538. #set G($td,a) [expr $G($td,a_from) + ($G($td,a_amplitude) / 2.0)]
  10539. set G($td,a) [expr ($G($td,a_from) + ($G($td,a_amplitude) / 2.0)) + $S($t,a_ori)]
  10540. set G($td,x) [expr $T($t,dbl,$td) * $f * cos($G($td,a))]
  10541. set G($td,y) [expr $T($t,dbl,$td) * $f * sin($G($td,a))]
  10542. # $t g
  10543. set G($tg,a_amplitude) [expr $nbg * $dd]
  10544. set G($tg,a_from) $G($td,a_to)
  10545. set G($tg,a_to) [expr $G($tg,a_from) + $G($tg,a_amplitude) ]
  10546. #set G($tg,a) [expr $G($tg,a_from) + ($G($tg,a_amplitude) / 2.0)]
  10547. set G($tg,a) [expr ($G($tg,a_from) + ($G($tg,a_amplitude) / 2.0)) + $S($t,a_ori)]
  10548. set G($tg,x) [expr $T($t,dbl,$tg) * $f * cos($G($tg,a))]
  10549. set G($tg,y) [expr $T($t,dbl,$tg) * $f * sin($G($tg,a))]
  10550. # tags
  10551. set tag1 [format "%s%s" $t C]
  10552. set tag2 [format "%s%s" $t C]
  10553. set tag11 [format "%s%s" $tg C]
  10554. set tag22 [format "%s%s" $td C]
  10555. # trace $td & $tg
  10556. $w create line 0 0 $G($tg,x) $G($tg,y) -tags "$tag1 $tag11 T$t Z" -fill black
  10557. $w create line 0 0 $G($td,x) $G($td,y) -tags "$tag2 $tag22 T$t Z" -fill black
  10558. #
  10559. for {set i 1} {$i < $T($t,tot)} {incr i} {
  10560. foreach b $T($t,cbg,$i) {
  10561. set j [string trimright $b {[0123456789]}]
  10562. set t2 [format "%s%s" $j C]
  10563. set bd [format "%s%s" $b d]
  10564. set bg [format "%s%s" $b g]
  10565. set nbg [Tools::NodeNoToLeNum $t $bg]
  10566. set nbd [Tools::NodeNoToLeNum $t $bd]
  10567. ### D
  10568. set G($bd,a_amplitude) [expr $nbd * $dd]
  10569. set G($bd,a_from) $G($j,a_from)
  10570. set G($bd,a_to) [expr $G($bd,a_from) + $G($bd,a_amplitude) ]
  10571. set G($bd,a) [expr $G($bd,a_from) + ($G($bd,a_amplitude) / 2.0)]
  10572. set gamma [expr abs($G($j,a) - $G($bd,a))]
  10573. set a [expr cos($gamma) * $T($t,dbl,$j)]
  10574. set b2 [expr sin($gamma) * $T($t,dbl,$j)]
  10575. set c [expr sqrt( abs (($T($t,dbl,$bd) * $T($t,dbl,$bd)) - ($b2 * $b2) ))]
  10576. set L [expr $c + $a]
  10577. set G($bd,x) [expr $G($j,x) + $f * cos($G($bd,a)) * $L]
  10578. set G($bd,y) [expr $G($j,y) + $f * sin($G($bd,a)) * $L]
  10579. ### G
  10580. set G($bg,a_amplitude) [expr $nbg * $dd]
  10581. set G($bg,a_from) $G($bd,a_to)
  10582. set G($bg,a_to) [expr $G($bg,a_from) + $G($bg,a_amplitude) ]
  10583. set G($bg,a) [expr $G($bg,a_from) + ($G($bg,a_amplitude) / 2.0)]
  10584. set gamma [expr abs($G($j,a) - $G($bg,a))]
  10585. set a [expr cos($gamma) * $T($t,dbl,$j)]
  10586. set b2 [expr sin($gamma) * $T($t,dbl,$j)]
  10587. set c [expr sqrt( abs( ($T($t,dbl,$bg)*$T($t,dbl,$bg)) - ($b2 * $b2) ))]
  10588. set L [expr $c + $a]
  10589. set G($bg,x) [expr $G($j,x) + $f * cos($G($bg,a)) * $L]
  10590. set G($bg,y) [expr $G($j,y) + $f * sin($G($bg,a)) * $L]
  10591. ### trace
  10592. $w create line $G($j,x) $G($j,y) $G($bg,x) $G($bg,y) \
  10593. -tags "[format "%s%s" $bg C] $bg T$t Z" -fill black
  10594. $w create line $G($j,x) $G($j,y) $G($bd,x) $G($bd,y) \
  10595. -tags "[format "%s%s" $bd C] $bd T$t Z" -fill black
  10596. }
  10597. }
  10598. # leaf labels
  10599. foreach i $T($t,ue_cod) {
  10600. set angledegre [expr ($G($i,a) * 360) / 6.283185]
  10601. set anchor center
  10602. if {$angledegre >= 0 && $angledegre < 90} {
  10603. set anchor nw
  10604. } elseif {$angledegre >= 90 && $angledegre < 180} {
  10605. set anchor ne
  10606. } elseif {$angledegre >= 180 && $angledegre < 270} {
  10607. set anchor se
  10608. } elseif {$angledegre >= 270 && $angledegre < 360} {
  10609. set anchor sw
  10610. }
  10611. regsub -all {?} $T($t,ctl,$i) " " texto
  10612. $w create text $G($i,x) $G($i,y) -text $texto \
  10613. -tags "T$t [format "%s%s" EUL $T($t,ctl,$i) ] L" \
  10614. -font $S(gfo) -state $S($t,display_eu) -anchor $anchor
  10615. }
  10616. # ajout tag des arretes terminales (eu)
  10617. foreach i $T($t,ue_cod) {
  10618. set t2 [format "%s%s" EU $T($t,ctl,$i)]
  10619. $w addtag $t2 withtag [list $i && T$t]
  10620. $w addtag Z withtag [list $i && T$t]
  10621. }
  10622. # centrage et scrollregion
  10623. $w move T$t $x0 $y0
  10624. $w configure -scrollregion [$w bbox all]
  10625. set S($t,type) PhyRad
  10626. unset G
  10627. }
  10628. ### ArrayToCanvasCirculaire
  10629. proc PhyCir1 {t w} {
  10630. global T S
  10631. set nb [llength $T($t,ue_cod)]
  10632. set hauteur [expr 10 * $nb]
  10633. set largeur $hauteur
  10634. set basedegre [expr 360.0 / [llength $T($t,ue_cod)]]
  10635. # passage radians
  10636. set dd [expr ((acos(-1)) * $basedegre)/ 180.0]
  10637. set S($t,a_uni) $dd
  10638. #rayon du cercle primaire
  10639. set xcenter [expr double($largeur)/2]
  10640. set ycenter [expr double($hauteur)/2]
  10641. if {$xcenter <= $ycenter} {set R $xcenter} {set R $ycenter}
  10642. #if {$xcenter < $ycenter} {set R $ycenter} {set R $xcenter}
  10643. set n 0
  10644. # facteur de zoom
  10645. set f [expr double($R / $T($t,xmax))]
  10646. ### EU
  10647. foreach i $T($t,ue_cod) {
  10648. # incr n
  10649. set G($i,a) [expr ($n * $dd) + $S($t,a_ori)]
  10650. set x1 [expr ($T($t,sox,$i)* $f) * cos($G($i,a))]
  10651. set y1 [expr ($T($t,sox,$i)* $f) * sin($G($i,a))]
  10652. set x2 [expr ((($T($t,sox,$i) - $T($t,dbl,$i) )* $f) * cos($G($i,a)))]
  10653. set y2 [expr ((($T($t,sox,$i) - $T($t,dbl,$i) )* $f) * sin($G($i,a)))]
  10654. set G($i,x) $x2
  10655. set G($i,y) $y2
  10656. $w create line $x2 $y2 $x1 $y1 \
  10657. -tags "$i [format "%s%s" EU $T($t,ctl,$i) ] [format "%s%s" $i C] T$t Z" -fill $S(Preference_fgc)
  10658. # feuilles en radial
  10659. regsub -all {?} $T($t,ctl,$i) " " texto
  10660. #set ls [split $T($t,ctl,$i) {}]
  10661. set ls [split $texto {}]
  10662. set an center ;# anchor
  10663. set ju center ;# justification
  10664. set angledegre [expr ($G($i,a) * 360) / 6.283185]
  10665. if {$angledegre >= 90 && $angledegre < 270} {
  10666. set b [expr 6 * [llength $ls]]
  10667. foreach s $ls {
  10668. # SPLIT + LEAVES
  10669. # COK
  10670. set xbis [expr $x1 + ($b * cos($G($i,a)))]
  10671. set ybis [expr $y1 + ($b * sin($G($i,a)))]
  10672. $w create text $xbis $ybis \
  10673. -text $s -anchor $an -justify $ju \
  10674. -tags "T$t [format "%s%s" EUL $T($t,ctl,$i) ] L" \
  10675. -font $S(gfo) -state $S($t,display_eu)
  10676. incr b -6
  10677. }
  10678. } else {
  10679. set b 2
  10680. foreach s $ls {
  10681. # SPLIT + LEAVES
  10682. # COK
  10683. set xbis [expr $x1 + ($b * cos($G($i,a)))]
  10684. set ybis [expr $y1 + ($b * sin($G($i,a)))]
  10685. $w create text $xbis $ybis \
  10686. -text $s -anchor $an -justify $ju \
  10687. -tags "T$t [format "%s%s" EUL $T($t,ctl,$i) ] L" \
  10688. -font $S(gfo) -state $S($t,display_eu)
  10689. incr b 6
  10690. }
  10691. }
  10692. incr n
  10693. }
  10694. ### NODES
  10695. for {set i [expr $T($t,tot) - 1 ]} {$i >= 1} {incr i -1} {
  10696. foreach b $T($t,cbg,$i) {
  10697. set bg [format "%s%s" $b g] ;# code bras gauche precedent (un niveau de profondeur plus loin)
  10698. set bd [format "%s%s" $b d] ;# code bras droit precedent (un niveau de profondeur plus loin)
  10699. set j [string trimright $b {[0123456789]}] ;# code bras gauche ou droit
  10700. set t2 [format "%s%s" $j C]
  10701. set ad [expr (180.0 * $G($bd,a)) / acos(-1)]
  10702. set ag [expr (180.0 * $G($bg,a)) / acos(-1)]
  10703. set G($j,a) [expr ($G($bg,a) + $G($bd,a)) / 2.0 ]
  10704. set rho [expr $G($bg,x) / cos($G($bg,a))]
  10705. set x1 [expr $rho * cos($G($j,a))]
  10706. set y1 [expr $rho * sin($G($j,a))]
  10707. set x2 [expr $x1 - ($T($t,dbl,$j) * $f * cos($G($j,a)))]
  10708. set y2 [expr $y1 - ($T($t,dbl,$j) * $f * sin($G($j,a)))]
  10709. set G($j,x) $x2
  10710. set G($j,y) $y2
  10711. $w create arc [expr 0 -$rho] $rho $rho [expr 0 -$rho] \
  10712. -start -$ad -extent [expr $ad - $ag] -style arc \
  10713. -tags "$t2 T$t Z" -outline $S(Preference_fgc)
  10714. $w create line $x1 $y1 $x2 $y2 \
  10715. -tags "$j $t2 T$t Z" -fill $S(Preference_fgc)
  10716. }
  10717. }
  10718. # root
  10719. #$w create line $xcenter $ycenter $xcenter $ycenter \
  10720. # -tags "[format "%s%s" $t C] T$t Z" -fill $S(Preference_fgc)
  10721. #translation
  10722. $w move T$t $xcenter $ycenter
  10723. $w configure -scrollregion [$w bbox all]
  10724. $w create line $xcenter $ycenter $xcenter $ycenter \
  10725. -tags "[format "%s%s" $t C] T$t Z" -fill $S(Preference_fgc)
  10726. unset G
  10727. }
  10728. proc ResizeAllGo {w} {
  10729. global S
  10730. foreach t $S($w,t) {
  10731. set co [$w bbox T$t]
  10732. set x [lindex $co 0]
  10733. set y [lindex $co 1]
  10734. $w delete T$t
  10735. switch -exact $S($t,type) {
  10736. PhyNJ {set S($t,type) PhyNJ ; TDcom::PhyNJ $t $w }
  10737. PhyRad {set S($t,type) PhyRad ; TDcom::PhyRad $t $w }
  10738. PhyCir1 {set S($t,type) PhyCir1 ; TDcom::PhyCir1 $t $w }
  10739. default {set S($t,type) PhyNJ ; TDcom::PhyNJ $t $w }
  10740. }
  10741. $w move T$t $x $y
  10742. Figuration::RestaureT $w $t
  10743. Reflection::UpdateAll $w
  10744. }
  10745. set S(treeheight) auto
  10746. }
  10747. ###
  10748. proc LoadAnnotations {filename} {
  10749. global S asedCon
  10750. set currentfile [Tools::PathCut2 $filename]
  10751. if {[lsearch $S(ldatabase) $currentfile] != -1 } {
  10752. upvar #0 $currentfile X
  10753. array unset X
  10754. } else {
  10755. lappend S(ldatabase) $currentfile
  10756. }
  10757. # TDcom::db $currentfile
  10758. TDcom::db TDO
  10759. catch {open $filename r} fid
  10760. while {[eof $fid] != 1} {
  10761. set id [incr S(lastid)]
  10762. gets $fid data
  10763. # modif
  10764. regsub -all " " [lindex $data 0] "?" sans
  10765. set datasans [lreplace $data 0 0 $sans]
  10766. interp eval treedyn TDO [concat $id EU $datasans]
  10767. # interp eval treedyn $currentfile [concat $id EU $datasans]
  10768. # interp eval treedyn $currentfile [concat $id EU $data]
  10769. }
  10770. close $fid
  10771. #set S(database) $currentfile
  10772. set S(database) TDO
  10773. }
  10774. ###
  10775. # proc db de Richard Suchenwirth
  10776. proc db {database args} {
  10777. global asedCon
  10778. upvar #0 $database db
  10779. set key ""
  10780. foreach {- key item value} $args break
  10781. set exists [info exists db($key)]
  10782. set res {}
  10783. switch [llength $args] {
  10784. 0 {
  10785. array set db {}
  10786. interp alias {} $database {} TDcom::db $database -
  10787. $asedCon alias $database TDcom::db $database -
  10788. set res $database
  10789. }
  10790. 1 {set res [array names db]}
  10791. 2 {
  10792. if {$key != ""} {
  10793. if {$exists} {set res $db($key)}
  10794. } else {array unset db }
  10795. }
  10796. 3 {if {$item != ""} {
  10797. if {$exists} {
  10798. set t $db($key)
  10799. if {!([set pos [lsearch $t $item]]%2)} {
  10800. set res [lindex $t [incr pos]]
  10801. }
  10802. }
  10803. } elseif {$exists} {unset db($key)}
  10804. }
  10805. 4 {
  10806. if {$exists} {
  10807. if {!([set pos [lsearch $db($key) $item]]%2)} {
  10808. if {$value != ""} {
  10809. set db($key) [lreplace $db($key) [incr pos] $pos $value]
  10810. } else {set db($key) [lreplace $db($key) $pos [incr pos]]}
  10811. } elseif {$value != ""} {
  10812. lappend db($key) $item $value
  10813. }
  10814. } elseif {$value != ""} {set db($key) [list $item $value]}
  10815. set res $value
  10816. }
  10817. default {
  10818. if {[llength $args]%2} {error "non-paired item/value list"}
  10819. foreach {item value} [lrange $args 2 end] {
  10820. db $database - $key $item $value
  10821. }
  10822. }
  10823. }
  10824. }
  10825. proc OpenScript {filename} {
  10826. global S T tds fileGeneric
  10827. catch {open $filename r} fid
  10828. set ltreetarget {} ; set lwindowtarget {}
  10829. foreach {w t} [Selection::TreeTar] {
  10830. lappend ltreetarget $t
  10831. lappend lwindowtarget $w
  10832. }
  10833. set lwindowtarget [Tools::DelRep $lwindowtarget]
  10834. # valeur par defaut
  10835. set S(ScriptingLegend) 0
  10836. while {[eof $fid] != 1} {
  10837. gets $fid raw
  10838. set type [lindex $raw 0]
  10839. set command [lrange $raw 1 end]
  10840. #conPuts $raw
  10841. switch -exact $type {
  10842. annotation {
  10843. # il faut AN Columns {TDO {TypeStrain}}
  10844. # on a annotation Columns {TypeStrain}
  10845. global ann
  10846. set mode [lindex $command 0]
  10847. if {$mode == "matrix"} {
  10848. set S(database) TDO
  10849. set ann(binmatPadding) 6
  10850. set ann(binmatHeight) 4
  10851. set ann(binmatWidth) 4
  10852. set ann(binmatColor0) white
  10853. set ann(binmatColor1) black
  10854. set ann(binmatOutline) 1
  10855. set ann(binmatColumnsNumber) 0
  10856. Annotation::MatrixAnnotateGoGo [lindex $command 1] $ltreetarget
  10857. } elseif {$mode == "matrixrgb"} {
  10858. set S(database) TDO
  10859. set ann(binmatPadding) 6
  10860. set ann(binmatHeight) 4
  10861. set ann(binmatWidth) 4
  10862. set ann(binmatColor0) white
  10863. set ann(binmatColor1) black
  10864. set ann(binmatOutline) 1
  10865. set ann(binmatColumnsNumber) 0
  10866. Annotation::MatrixColorsAnnotateGoGo [lindex $command 1] $ltreetarget
  10867. } elseif {$mode == "newick"} {
  10868. set command [lrange $command 1 end]
  10869. # annotationnewick ?[-what ":x ou x:"] ?[-treshold $valeur] ?[-leaf "0 ou 1"] ?[-where "nw sw ne se n s"] -color -font
  10870. # valeur par defaut
  10871. set S(-what) :x ;# :x ou x:
  10872. set S(-treshold) all ;# all ou $valeur
  10873. set S(-leaf) 1 ;# 0 1
  10874. set S(-where) nw ;# "nw sw ne se n s e"
  10875. set S(-font) {Helvetica 8 normal} ;#
  10876. set S(-color) blue ;#
  10877. # traitements flags
  10878. foreach {variable value} $command {
  10879. eval set S($variable) $value
  10880. }
  10881. # display
  10882. foreach {w t} [Selection::TreeTar] {
  10883. ANBLgo $w $t
  10884. }
  10885. } elseif {$mode == "draw"} {
  10886. set command [lrange $command 1 end]
  10887. # default values
  10888. set x(-l) {}
  10889. set x(-text) ""
  10890. set x(-color) red
  10891. set x(-font) {Arial 8 normal}
  10892. set x(-tab) 0
  10893. set x(-width) 5
  10894. set x(-background) red
  10895. set x(-stipple) 01
  10896. # traitements flags
  10897. foreach {variable value} $command {
  10898. eval set x($variable) $value
  10899. }
  10900. switch -exact $x(-stipple) {
  10901. 01 { set x(-stipple) z.xbm}
  10902. 02 { set x(-stipple) a.xbm}
  10903. 03 { set x(-stipple) b.xbm}
  10904. 04 { set x(-stipple) h.xbm}
  10905. 05 { set x(-stipple) j.xbm}
  10906. }
  10907. foreach {w t} [Selection::TreeTar] {
  10908. # ds leafs eventuellement des patterns
  10909. set l {}
  10910. foreach li $x(-l) {
  10911. append l " [lsearch -all -inline -regexp $T($t,ue_lab) $li]"
  10912. }
  10913. if {$l != {}} {
  10914. # recuperer la liste des noeuds peres
  10915. set peres [Operation::FindFatherNode $t $l]
  10916. foreach p $peres {
  10917. set SouCodLea [Tools::NodeNoToLe $t $p]
  10918. set SouRefLea [Tools::NodeLeCoToRe $t $SouCodLea]
  10919. Illustration::BracketDrawLeafs $w $t $SouRefLea $x(-text) $x(-color) \
  10920. $x(-font) $x(-tab) $x(-width) $x(-background) $x(-stipple)
  10921. }
  10922. }
  10923. }
  10924. unset x
  10925. } elseif {$mode == "arcs"} {
  10926. set command [lrange $command 1 end]
  10927. # valeur par defaut
  10928. set S(-tab) 50
  10929. set S(-text) 1
  10930. set S(-curve) 10
  10931. set S(-line) 1
  10932. set S(-color) blue
  10933. # traitements flags
  10934. foreach {variable value} $command {
  10935. eval set S($variable) $value
  10936. }
  10937. # affectation des variables globales
  10938. set S(col) $S(-color)
  10939. set S(IGtabul) $S(-tab)
  10940. set S(IGcurve) $S(-curve)
  10941. set S(IGline) $S(-line)
  10942. set S(IGannot) $S(-text)
  10943. # construction liste lv : leaf source listes des feuilles target
  10944. set S(database) TDO
  10945. set id [Database::dbQueryRecordsFromVarVal TDO EU $S(-leaf)]
  10946. set l [Database::dbQueryVarFromRecords TDO $S(-variable) $id]
  10947. set lv [list [format "%s%s%s%s" $S(-leaf) ":{" $l "}"]]
  10948. # display
  10949. foreach {w t} [Selection::TreeTar] {
  10950. Amelie::DrawGoUser $lv $t
  10951. }
  10952. } else {
  10953. if {$mode == "replace" } {set mode LeavesReplace }
  10954. if {$mode == "juxtapose" } {set mode LeavesAdd }
  10955. if {$mode == "column" } {set mode Columns }
  10956. set ann(ann-fgfiguration) asuser
  10957. set ann(ann-fofiguration) asuser
  10958. set ann(ann-prefix) " "
  10959. set ann(ann-suffix) ""
  10960. set ann(ann-exposant) 0
  10961. set fct [format "%s%s" Annotation::ANGo $mode] ;# la fonction d'annotation
  10962. set lv [lindex $command 1] ;# database liste_de_variables
  10963. #set S(database) [lindex $var 0]
  10964. set S(database) TDO
  10965. #set lv [lindex $var 1] ;# liste de variables
  10966. set args [lindex $command 2] ;# options
  10967. if {$args != ""} {
  10968. foreach {option value} $args {
  10969. set ann(ann-$option) $value
  10970. }
  10971. }
  10972. eval $fct $lv [list $ltreetarget]
  10973. set ann(ann-prefix) " "
  10974. set ann(ann-suffix) ""
  10975. set ann(ann-exposant) 0
  10976. }
  10977. }
  10978. find {
  10979. set S(query) $command
  10980. foreach {w t} [Selection::TreeTar] {
  10981. foreach ci [lindex $command 0] {
  10982. #set leu {}
  10983. #foreach i $T($t,ue_lab) {
  10984. # if {[string match $ci $i]} {lappend leu $i }
  10985. #}
  10986. set leu [ lsearch -all -inline -regexp $T($t,ue_lab) $ci ]
  10987. Operation::Operation $w $t $leu
  10988. if {$S(ScriptingLegend)} {
  10989. # legende MODIF si symbol
  10990. if {$S(operation) == "LillC"} {
  10991. foreach wi $lwindowtarget {
  10992. set co [$wi bbox Legend]
  10993. if {$co == ""} {
  10994. set x 0 ; set y 0
  10995. } else {
  10996. set x 0 ; set y [expr [lindex $co end] + $S(symboldy)+3]
  10997. }
  10998. #set S(symbolcolorfill) $S(col)
  10999. #set S(symbolcoloroutline) $S(col)
  11000. #set S(symbolstipple) $S(stipple)
  11001. Illustration::drawsymbol $wi $x $y [list Legend $S(ScriptingLegendTAG)]
  11002. $wi create text [expr $x + 15] [expr $y + 2] \
  11003. -text $ci -tags "Legend txt $S(ScriptingLegendTAG)"
  11004. }
  11005. incr y 15
  11006. } else {
  11007. foreach wi $lwindowtarget {
  11008. set co [$wi bbox Legend]
  11009. if {$co == ""} {
  11010. set x 0 ; set y 0
  11011. } else {
  11012. set x 0 ; set y [expr [lindex $co end] + $S(symboldy)+3]
  11013. }
  11014. #set S(symbolcolorfill) $S(col)
  11015. #set S(symbolcoloroutline) $S(col)
  11016. #set S(symbolstipple) $S(stipple)
  11017. Illustration::drawsymbol $wi $x $y [list Legend $S(ScriptingLegendTAG)]
  11018. $wi create text [expr $x + 11] [expr $y + 2] \
  11019. -text $ci -tags "Legend txt $S(ScriptingLegendTAG)"
  11020. }
  11021. incr y 10
  11022. }
  11023. }
  11024. }
  11025. }
  11026. }
  11027. query {
  11028. set var [lindex $command 0]
  11029. set ope [lindex $command 1]
  11030. foreach val [lindex $command 2] {
  11031. set com [concat EU from TDO where $var $ope $val]
  11032. eval Database::Select $com
  11033. if {$S(ScriptingLegend)} {
  11034. # legende MODIF si symbol
  11035. if {$S(operation) == "LillC"} {
  11036. foreach wi $lwindowtarget {
  11037. set co [$wi bbox Legend]
  11038. if {$co == ""} {
  11039. set x 0 ; set y 0
  11040. } else {
  11041. set x 0 ; set y [expr [lindex $co end] + $S(symboldy)+3]
  11042. }
  11043. #set S(symbolcolorfill) $S(col)
  11044. #set S(symbolcoloroutline) $S(col)
  11045. #set S(symbolstipple) $S(stipple)
  11046. Illustration::drawsymbol $wi $x $y [list Legend $S(ScriptingLegendTAG)]
  11047. $wi create text [expr $x + 15] [expr $y + 2] \
  11048. -text [lindex $com end] -tags "Legend txt $S(ScriptingLegendTAG)"
  11049. }
  11050. incr y 15
  11051. } else {
  11052. foreach wi $lwindowtarget {
  11053. set co [$wi bbox Legend]
  11054. if {$co == ""} {
  11055. set x 0 ; set y 0
  11056. } else {
  11057. set x 0 ; set y [expr [lindex $co end] + $S(symboldy)+3]
  11058. }
  11059. #set S(symbolcolorfill) $S(col)
  11060. #set S(symbolcoloroutline) $S(col)
  11061. #set S(symbolstipple) $S(stipple)
  11062. Illustration::drawsymbol $wi $x $y [list Legend $S(ScriptingLegendTAG)]
  11063. $wi create text [expr $x + 11] [expr $y + 2] \
  11064. -text [lindex $com end] -tags "Legend txt $S(ScriptingLegendTAG)"
  11065. }
  11066. incr y 10
  11067. }
  11068. }
  11069. }
  11070. }
  11071. font {
  11072. set S(gfo) $command
  11073. }
  11074. tree {
  11075. # traitements flags -height -width -font -foreground -background etc
  11076. foreach {variable value} $command {
  11077. set variabletree [format "%s%s" tree $variable]
  11078. eval set S($variabletree) $value
  11079. }
  11080. foreach {w t} [Selection::TreeTar] {
  11081. $w delete T$t
  11082. switch -- $S(tree-conformation) {
  11083. 01 { TDcom::PhyNJ $t $w}
  11084. 02 { TDcom::PhyRad $t $w}
  11085. }
  11086. #Figuration::RestaureT $w $t
  11087. }
  11088. }
  11089. legend {
  11090. switch -exact $command {
  11091. on {
  11092. set S(ScriptingLegend) 1
  11093. set tagi [format "%s%s" LE [Tools::GenId]]
  11094. set S(ScriptingLegendTAG) $tagi
  11095. }
  11096. off {
  11097. set S(ScriptingLegend) 0
  11098. }
  11099. }
  11100. }
  11101. text {
  11102. set S(AnnotateNote) $command
  11103. }
  11104. scale {
  11105. foreach {w t} [Selection::TreeTar] {
  11106. set co [$w bbox T$t]
  11107. set x [lindex $co 0]
  11108. set y [lindex $co 1]
  11109. Annotation::AnnotateBuiltIn $w $t [expr [lindex $command 0] + $x] [expr [lindex $command 1] + $y] Scale
  11110. }
  11111. }
  11112. conformation {
  11113. set mode [lindex $command 0]
  11114. switch -exact $mode {
  11115. 01 {
  11116. foreach {w t} [Selection::TreeTar] {
  11117. $w delete T$t
  11118. TDcom::PhyNJ $t $w
  11119. }
  11120. }
  11121. 02 {
  11122. foreach {w t} [Selection::TreeTar] {
  11123. $w delete T$t
  11124. TDcom::PhyRad $t $w
  11125. }
  11126. }
  11127. 03 {
  11128. foreach {w t} [Selection::TreeTar] {
  11129. $w delete T$t
  11130. TDcom::PhyCir1 $t $w
  11131. }
  11132. }
  11133. }
  11134. }
  11135. swap {
  11136. set ll [lindex $command 0]
  11137. foreach {w t} [Selection::TreeTar] {
  11138. set leu {}
  11139. foreach e $ll {
  11140. if {[lsearch -exact $T($t,ue_lab) $e] != -1} {lappend leu $e}
  11141. }
  11142. set n [Operation::FindFatherNode $t $leu]
  11143. if {[lindex $n 0] != ""} {
  11144. Conformation::Swap $w $t $n
  11145. }
  11146. }
  11147. }
  11148. root {
  11149. set ll [lindex $command 0]
  11150. foreach {w t} [Selection::TreeTar] {
  11151. set leu {}
  11152. foreach e $ll {
  11153. if {[lsearch -exact $T($t,ue_lab) $e] != -1} {lappend leu $e}
  11154. }
  11155. set n [Operation::FindFatherNode $t $leu]
  11156. if {[lindex $n 0] != ""} {
  11157. Conformation::Outgroup2 $w - $t $n
  11158. }
  11159. }
  11160. }
  11161. size {
  11162. set S(newW) [lindex $command 0]
  11163. set S(newH) [lindex $command 1]
  11164. set S(treewidth) [lindex $command 0]
  11165. set S(treeheight) [lindex $command 1]
  11166. foreach wi $lwindowtarget {TDcom::ResizeAllGo $wi}
  11167. }
  11168. rowcolumn {
  11169. set row [lindex $command 0]
  11170. set column [lindex $command 1]
  11171. foreach wi $lwindowtarget {Navigation::Reorganize $wi $column $row}
  11172. }
  11173. symbol {
  11174. set S(symboltype) [lindex $command 0]
  11175. set S(symboldx) [lindex $command 1]
  11176. set S(symboldy) [lindex $command 2]
  11177. set S(symbolcolorfill) [lindex $command 3]
  11178. set S(symbolcoloroutline) [lindex $command 4]
  11179. switch -exact [lindex $command 5] {
  11180. 01 { set S(symbolstipple) z.xbm}
  11181. 02 { set S(symbolstipple) a.xbm}
  11182. 03 { set S(symbolstipple) b.xbm}
  11183. 04 { set S(symbolstipple) h.xbm}
  11184. 05 { set S(symbolstipple) j.xbm}
  11185. default { set S(symbolstipple) z.xbm}
  11186. }
  11187. }
  11188. tabulation {
  11189. switch -exact [lindex $command 0] {
  11190. + {Illustration::IllCTabulationSet tab+ [lindex $command 1]}
  11191. - {Illustration::IllCTabulationSet tab- [lindex $command 1]}
  11192. = {Illustration::IllCTabulationSet tab= [lindex $command 1]}
  11193. auto {set S(TabulationAnnot) [lindex $command 1] ; set S(illustration-tabulation) 1}
  11194. manual {set S(illustration-tabulation) 0}
  11195. }
  11196. }
  11197. color {
  11198. eval set S(col) $command
  11199. }
  11200. stipple {
  11201. switch -exact [lindex $command 0] {
  11202. 01 { set S(stipple) z.xbm}
  11203. 02 { set S(stipple) a.xbm}
  11204. 03 { set S(stipple) b.xbm}
  11205. 04 { set S(stipple) h.xbm}
  11206. 05 { set S(stipple) j.xbm}
  11207. }
  11208. }
  11209. shape {
  11210. switch -exact [lindex $command 0] {
  11211. 01 { set S(defaultshape) 1}
  11212. 02 { set S(defaultshape) 2}
  11213. 03 { set S(defaultshape) 3}
  11214. 04 { set S(defaultshape) 4}
  11215. 05 { set S(defaultshape) 5}
  11216. }
  11217. }
  11218. operation {
  11219. set S(operation) {}
  11220. foreach op $command {
  11221. switch $op {
  11222. l01 {eval lappend S(operation) leaffgcolor}
  11223. l02 {eval lappend S(operation) leafbgcolor}
  11224. l03 {eval lappend S(operation) leaffontglob}
  11225. l04 {eval lappend S(operation) LillL}
  11226. l05 {eval lappend S(operation) LillC}
  11227. l06 {eval lappend S(operation) LannL}
  11228. l07 {eval lappend S(operation) LannC}
  11229. l08 {eval lappend S(operation) leafshrink}
  11230. l09 {eval lappend S(operation) leafunshrink}
  11231. n00 {eval lappend S(operation) nodefgcolor}
  11232. n01 {eval lappend S(operation) nodebgcolor}
  11233. n02 {eval lappend S(operation) widthline+}
  11234. n03 {eval lappend S(operation) widthline-}
  11235. n04 {eval lappend S(operation) nodedashOn}
  11236. n05 {eval lappend S(operation) nodedashOff}
  11237. n06 {eval lappend S(operation) nodeillustration}
  11238. n07 {eval lappend S(operation) symbolnode}
  11239. n08 {eval lappend S(operation) nodeannotate}
  11240. n09 {eval lappend S(operation) insertvarval}
  11241. n10 {eval lappend S(operation) insertvarval2}
  11242. n11 {eval lappend S(operation) shrink}
  11243. n12 {eval lappend S(operation) unshrinnk}
  11244. n13 {eval lappend S(operation) nodenetwork}
  11245. n14 {eval lappend S(operation) nodeextract}
  11246. n15 {eval lappend S(operation) nodefgcolor2}
  11247. n16 {eval lappend S(operation) widthline+2}
  11248. n17 {eval lappend S(operation) nodedashOn2}
  11249. c00 {eval lappend S(operation) querynode}
  11250. }
  11251. }
  11252. }
  11253. infocoord {
  11254. switch $command {
  11255. leave {
  11256. set fileINFO [format "%s%s" [file join $S(TDOhtmlDIR) $fileGeneric] infocoordleave.txt]
  11257. set fid2 [open $fileINFO w]
  11258. foreach {w t} [Selection::TreeTar] {
  11259. foreach l $T($t,ue_lab) {
  11260. set coL [$w bbox [$w find withtag [list [format "%s%s" EUL $l ] && T$t]]]
  11261. #set coL [$w coords [$w find withtag [list [format "%s%s" $T($t,ltc,$l) C ] && T$t]]]
  11262. puts $fid2 "$l $coL"
  11263. }
  11264. }
  11265. close $fid2
  11266. }
  11267. tree {
  11268. set fileINFO [format "%s%s" [file join $S(TDOhtmlDIR) $fileGeneric] infocoordtree.txt]
  11269. set fid2 [open $fileINFO w]
  11270. foreach {w t} [Selection::TreeTar] {
  11271. if {$S(illustration-tabulation) == 1} {
  11272. set XMAX1 [lindex [$w bbox [list T$t && Z]] 2]
  11273. set XMAX2 [lindex [$w bbox [list T$t && L]] 2]
  11274. set XMAX3 [lindex [$w bbox [list T$t && AnnotMatrix]] 2]
  11275. if {$XMAX1 < $XMAX2} {set XMAX $XMAX2 } {set XMAX $XMAX1}
  11276. if {$XMAX < $XMAX3} {set XMAX $XMAX3 }
  11277. set x [expr $XMAX + $S($t,LabelMatrixBase)]
  11278. } else {
  11279. set XMAX1 [lindex [$w bbox [list T$t && Z]] 2]
  11280. set XMAX2 [lindex [$w bbox [list T$t && L]] 2]
  11281. if {$XMAX1 < $XMAX2} {set XMAX $XMAX2 } {set XMAX $XMAX1}
  11282. set x [expr $XMAX + $S($t,LabelMatrixBase)]
  11283. }
  11284. puts $fid2 "$t $x"
  11285. }
  11286. close $fid2
  11287. }
  11288. node {
  11289. set fileINFO [format "%s%s" [file join $S(TDOhtmlDIR) $fileGeneric] infocoordnode.txt]
  11290. set fid2 [open $fileINFO w]
  11291. foreach {w t} [Selection::TreeTar] {
  11292. set id 0
  11293. foreach node $T($t,all_cod) {
  11294. set l [Tools::NodeLeCoToRe $t [Tools::NodeNoToLe $t $node]]
  11295. puts $fid2 "$id \t $node \t [list [lsort -dictionary $l]] \t [list [$w coords $node]]"
  11296. incr id
  11297. }
  11298. }
  11299. close $fid2
  11300. }
  11301. }
  11302. }
  11303. }
  11304. }
  11305. close $fid
  11306. }
  11307. proc ANBLgo {w t} {
  11308. global T S
  11309. switch -- $S(-what) {
  11310. ":x" {
  11311. if {$S(-treshold) == "all"} {
  11312. set l [lrange $T($t,all_cod) 1 end]
  11313. if {$S(-leaf) == 0} {set l [Tools::SousL $l $T($t,ue_cod)]}
  11314. foreach i $l {
  11315. if {[$w itemcget $i -state] != "hidden"} {
  11316. set co [$w coords $i]
  11317. if {$co != ""} {
  11318. switch -- $S(-where) {
  11319. nw {
  11320. # gauche haut
  11321. set x [expr [lindex $co 2] + 2]
  11322. set y [lindex $co 1]
  11323. set anchor sw ; set justify left
  11324. }
  11325. sw {
  11326. # gauche bas
  11327. set x [expr [lindex $co 2] + 2]
  11328. set y [expr [lindex $co 1] + 2]
  11329. set anchor nw ; set justify left
  11330. }
  11331. ne {
  11332. # droite haut
  11333. set x [lindex $co 0]
  11334. set y [lindex $co 1]
  11335. set anchor se ; set justify right
  11336. }
  11337. se {
  11338. # doite bas
  11339. set x [lindex $co 0]
  11340. set y [expr [lindex $co 1] + 2]
  11341. set anchor ne ; set justify right
  11342. }
  11343. n {
  11344. # centre haut
  11345. set x [expr abs([lindex $co 0] + (([lindex $co 2] - [lindex $co 0]) / 2.0) ) ]
  11346. set y [lindex $co 1]
  11347. set anchor s ; set justify center
  11348. }
  11349. s {
  11350. # centre bas
  11351. set x [expr abs([lindex $co 0] + (([lindex $co 2] - [lindex $co 0]) / 2.0) ) ]
  11352. set y [expr [lindex $co 1] + 2]
  11353. set anchor n ; set justify center
  11354. }
  11355. e {
  11356. # special
  11357. set x [expr [lindex $co 0] +2]
  11358. set y [expr [lindex $co 1] +1]
  11359. set anchor w ; set justify left
  11360. }
  11361. }
  11362. if [catch {set test $T($t,dbl,$i)} res] {} else {
  11363. eval {$w create text} \
  11364. {$x $y} \
  11365. {-text $T($t,dbl,$i) -fill $S(-color) \
  11366. -font $S(-font) -anchor $anchor -justify $justify -tags "T$t DBL"}
  11367. }
  11368. }
  11369. }
  11370. }
  11371. } else {
  11372. set l [lrange $T($t,all_cod) 1 end]
  11373. if {$S(-leaf) == 0} {set l [Tools::SousL $l $T($t,ue_cod)]}
  11374. foreach i $l {
  11375. if {[$w itemcget $i -state] != "hidden"} {
  11376. set co [$w coords $i]
  11377. if {$co != ""} {
  11378. switch -- $S(-where) {
  11379. nw {
  11380. # gauche haut
  11381. set x [expr [lindex $co 2] + 2]
  11382. set y [lindex $co 1]
  11383. set anchor sw ; set justify left
  11384. }
  11385. sw {
  11386. # gauche bas
  11387. set x [expr [lindex $co 2] + 2]
  11388. set y [expr [lindex $co 1] + 2]
  11389. set anchor nw ; set justify left
  11390. }
  11391. ne {
  11392. # droite haut
  11393. set x [lindex $co 0]
  11394. set y [lindex $co 1]
  11395. set anchor se ; set justify right
  11396. }
  11397. se {
  11398. # doite bas
  11399. set x [lindex $co 0]
  11400. set y [expr [lindex $co 1] + 2]
  11401. set anchor ne ; set justify right
  11402. }
  11403. n {
  11404. # centre haut
  11405. set x [expr abs([lindex $co 0] + (([lindex $co 2] - [lindex $co 0]) / 2.0) ) ]
  11406. set y [lindex $co 1]
  11407. set anchor s ; set justify center
  11408. }
  11409. s {
  11410. # centre bas
  11411. set x [expr abs([lindex $co 0] + (([lindex $co 2] - [lindex $co 0]) / 2.0) ) ]
  11412. set y [expr [lindex $co 1] + 2]
  11413. set anchor n ; set justify center
  11414. }
  11415. e {
  11416. # special
  11417. set x [expr [lindex $co 0] +2]
  11418. set y [expr [lindex $co 1] +1]
  11419. set anchor w ; set justify left
  11420. }
  11421. }
  11422. if [catch {set test $T($t,dbl,$i)} res] {} else {
  11423. if { $T($t,dbl,$i) >= $S(-treshold) } {
  11424. eval {$w create text} \
  11425. {$x $y} \
  11426. {-text $T($t,dbl,$i) -fill $S(-color) \
  11427. -font $S(-font) -anchor $anchor -tags "T$t DBL"}
  11428. }
  11429. }
  11430. }
  11431. }
  11432. }
  11433. }
  11434. }
  11435. "x:" {
  11436. if {$S(-treshold) == "all"} {
  11437. set l [lrange $T($t,all_cod) 1 end]
  11438. if {$S(-leaf) == 0} {set l [Tools::SousL $l $T($t,ue_cod)]}
  11439. foreach i $l {
  11440. if {[$w itemcget $i -state] != "hidden"} {
  11441. set co [$w coords $i]
  11442. if {$co != ""} {
  11443. switch -- $S(-where) {
  11444. nw {
  11445. # gauche haut
  11446. set x [expr [lindex $co 2] + 2]
  11447. set y [lindex $co 1]
  11448. set anchor sw ; set justify left
  11449. }
  11450. sw {
  11451. # gauche bas
  11452. set x [expr [lindex $co 2] + 2]
  11453. set y [expr [lindex $co 1] + 2]
  11454. set anchor nw ; set justify left
  11455. }
  11456. ne {
  11457. # droite haut
  11458. set x [lindex $co 0]
  11459. set y [lindex $co 1]
  11460. set anchor se ; set justify right
  11461. }
  11462. se {
  11463. # doite bas
  11464. set x [lindex $co 0]
  11465. set y [expr [lindex $co 1] + 2]
  11466. set anchor ne ; set justify right
  11467. }
  11468. n {
  11469. # centre haut
  11470. set x [expr abs([lindex $co 0] + (([lindex $co 2] - [lindex $co 0]) / 2.0) ) ]
  11471. set y [lindex $co 1]
  11472. set anchor s ; set justify center
  11473. }
  11474. s {
  11475. # centre bas
  11476. set x [expr abs([lindex $co 0] + (([lindex $co 2] - [lindex $co 0]) / 2.0) ) ]
  11477. set y [expr [lindex $co 1] + 2]
  11478. set anchor n ; set justify center
  11479. }
  11480. e {
  11481. # special
  11482. set x [expr [lindex $co 0] +2]
  11483. set y [expr [lindex $co 1] +1]
  11484. set anchor w ; set justify left
  11485. }
  11486. }
  11487. if [catch {set test $T($t,dbv,$i)} res] {} else {
  11488. eval {$w create text} \
  11489. {$x $y} \
  11490. {-text $T($t,dbv,$i) -fill $S(-color) \
  11491. -font $S(-font) -anchor $anchor -tags "T$t DBL"}
  11492. }
  11493. }
  11494. }
  11495. }
  11496. } else {
  11497. set l [lrange $T($t,all_cod) 1 end]
  11498. if {$S(-leaf) == 0} {set l [Tools::SousL $l $T($t,ue_cod)]}
  11499. foreach i $l {
  11500. if {[$w itemcget $i -state] != "hidden"} {
  11501. set co [$w coords $i]
  11502. if {$co != ""} {
  11503. switch -- $S(-where) {
  11504. nw {
  11505. # gauche haut
  11506. set x [expr [lindex $co 2] + 2]
  11507. set y [lindex $co 1]
  11508. set anchor sw ; set justify left
  11509. }
  11510. sw {
  11511. # gauche bas
  11512. set x [expr [lindex $co 2] + 2]
  11513. set y [expr [lindex $co 1] + 2]
  11514. set anchor nw ; set justify left
  11515. }
  11516. ne {
  11517. # droite haut
  11518. set x [lindex $co 0]
  11519. set y [lindex $co 1]
  11520. set anchor se ; set justify right
  11521. }
  11522. se {
  11523. # doite bas
  11524. set x [lindex $co 0]
  11525. set y [expr [lindex $co 1] + 2]
  11526. set anchor ne ; set justify right
  11527. }
  11528. n {
  11529. # centre haut
  11530. set x [expr abs([lindex $co 0] + (([lindex $co 2] - [lindex $co 0]) / 2.0) ) ]
  11531. set y [lindex $co 1]
  11532. set anchor s ; set justify center
  11533. }
  11534. s {
  11535. # centre bas
  11536. set x [expr abs([lindex $co 0] + (([lindex $co 2] - [lindex $co 0]) / 2.0) ) ]
  11537. set y [expr [lindex $co 1] + 2]
  11538. set anchor n ; set justify center
  11539. }
  11540. e {
  11541. # special
  11542. set x [expr [lindex $co 0] +2]
  11543. set y [expr [lindex $co 1] +1]
  11544. set anchor w ; set justify left
  11545. }
  11546. }
  11547. if [catch {set test $T($t,dbv,$i)} res] {} else {
  11548. if { $T($t,dbv,$i) >= $S(-treshold) } {
  11549. eval {$w create text} \
  11550. {$x $y} \
  11551. {-text $T($t,dbv,$i) -fill $S(-color) \
  11552. -font $S(-font) -anchor $anchor -tags "T$t DBL"}
  11553. }
  11554. }
  11555. }
  11556. }
  11557. }
  11558. }
  11559. }
  11560. }
  11561. }
  11562. }
  11563. ####################
  11564. ####################
  11565. # GO
  11566. ####################
  11567. Interface::TreeDynInitialisation
  11568. #proc bgerror {m} {}
  11569. global S
  11570. #source tdopath.tcl
  11571. #set S(ImportDIR) $S(TDOcgiDIR)
  11572. #set S(userDIR) $S(TDOcgiDIR)
  11573. #set S(TheoPATH) [pwd]
  11574. set S(TheoPATH) /data/http/www/binaries/theo
  11575. $asedCon alias db "TDcom::db"
  11576. TDcom::com $argv
  11577. exit
  11578. ####################