0022785: Draw Harness - add possibility to remove a text drawn by the command vdrawtext
[occt.git] / samples / tcl / materials.tcl
CommitLineData
44c7c33e 1# Script displays properties of different materials available in OCCT
2
ab91ab6f 3#Category: Visualization
4#Title: Material properties in viewer
5
44c7c33e 6set THE_MATERIALS {brass bronze copper gold jade neon_phc pewter obsidian plaster plastic satin silver steel stone chrome aluminium water glass diamond charcoal}
7set THE_COLORS {default red green blue1}
8set THE_ROW_DIST 35
9
10proc drawLabels {} {
11 set x 20
12 set y 15
29e2c6d2 13 set r 0.098
14 set g 0.098
15 set b 0.098
44c7c33e 16 foreach aMatIter $::THE_MATERIALS {
29e2c6d2 17 vdrawtext "$aMatIter" "$aMatIter" -pos $x $y 0 -color $r $g $b -halign right -valign center -angle 000 -zoom 0 -height 14 -aspect regular -font Arial
44c7c33e 18 incr y 10
19 }
20 set x 40
21 set y 5
22 foreach aColIter $::THE_COLORS {
23 if { $aColIter == "red" } {
29e2c6d2 24 set r 1.0
25 set g 0.0
44c7c33e 26 set b 0
27 } elseif { $aColIter == "green" } {
29e2c6d2 28 set r 0.0
29 set g 1.0
30 set b 0.0
44c7c33e 31 } elseif { $aColIter == "blue1" } {
29e2c6d2 32 set r 0.0
33 set g 0.0
34 set b 1.0
44c7c33e 35 }
29e2c6d2 36 vdrawtext "$aColIter" "$aColIter" -pos $x $y 0 -color $r $g $b -halign center -valign center -angle 000 -zoom 0 -height 14 -aspect regular -font Arial
44c7c33e 37 incr x $::THE_ROW_DIST
38 }
39}
40
41proc drawObjects {theRow theColor} {
42 set aSize 4
43 set aCtr -2
44 set aCounter 0
45 set x [expr 30 + $theRow * $::THE_ROW_DIST]
46 set y 15
47 foreach aMatIter $::THE_MATERIALS {
48 set aSph s${theRow}_${aCounter}
49 set aBox b${theRow}_${aCounter}
50 uplevel #0 psphere $aSph $aSize
51 uplevel #0 box $aBox $aCtr $aCtr $aCtr $aSize $aSize $aSize
52 uplevel #0 ttranslate $aSph $x $y 0
53 uplevel #0 ttranslate $aBox [expr $x + 10] $y 0
54 uplevel #0 vdisplay -noredraw $aSph $aBox
55 uplevel #0 vsetmaterial -noredraw $aSph $aBox $aMatIter
56 if {$theColor != ""} {
57 uplevel #0 vsetcolor -noredraw $aSph $aBox $theColor
58 }
59 incr aCounter
60 incr y 10
61 }
62}
63
64# setup 3D viewer content
65pload MODELING VISUALIZATION
66
67catch { vclose View1 }
68vinit View1 w=768 h=768
69vclear
70vtop
71vglinfo
72vsetgradientbg 180 200 255 180 180 180 2
73vlight change 0 pos -1 1 1
74vsetdispmode 1
75
76# adjust scene bounding box
77box bnd 0 0 0 180 210 1
78vdisplay -noredraw bnd
79vsetdispmode bnd 0
80vfit
81vremove -noredraw bnd
82
83# draw spheres and boxes with different materials
84drawLabels
85drawObjects 0 ""
86drawObjects 1 red
87drawObjects 2 green
88drawObjects 3 blue1
89#vfit
90vzfit