b2d44b52eb7e4afa434d140668863c3d97ba6f6f
[occt.git] / samples / tcl / markers.tcl
1 # Markers demo
2 #
3 # It shows the various marker types supported by OCCT.
4
5 #Category: Visualization
6 #Title: Markers in 3d viewer
7
8 pload MODELING VISUALIZATION
9
10 # reflects Aspect_TypeOfMarker enumeration
11 set aMarkerTypeNames {
12   Aspect_TOM_POINT
13   Aspect_TOM_PLUS
14   Aspect_TOM_STAR
15   Aspect_TOM_X
16   Aspect_TOM_O
17   Aspect_TOM_O_POINT
18   Aspect_TOM_O_PLUS
19   Aspect_TOM_O_STAR
20   Aspect_TOM_O_X
21   Aspect_TOM_RING1
22   Aspect_TOM_RING2
23   Aspect_TOM_RING3
24   Aspect_TOM_BALL
25   Aspect_TOM_USERDEFINED
26 }
27
28 # custom marker
29 set aCustom1 [locate_data_file images/marker_box1.png]
30 set aCustom2 [locate_data_file images/marker_box2.png]
31 set aCustom3 [locate_data_file images/marker_kr.png]
32 set aCustom4 [locate_data_file images/marker_dot.png]
33
34 set aFontFile [locate_data_file DejaVuSans.ttf]
35 set aLabelFont "Arial"
36 if { "$aFontFile" != "" } {
37   vfont add "$aFontFile" SansFont
38   set aLabelFont "SansFont"
39 }
40
41 # reset the viewer
42 vclear
43 vclose ALL
44 vinit name=View1 l=32 t=32 w=512 h=512
45
46 puts "Draw box in advance which should fit all our markers"
47 box b -8 -8 0 16 16 2
48 vbottom
49 vdisplay -noupdate -dispmode 0 b
50 vfit
51 vremove -noupdate b
52
53 puts "Draw markers of different type and size"
54 for { set aMarkerType 0 } { $aMarkerType <= 13 } { incr aMarkerType } {
55   set aRow [expr $aMarkerType - 7]
56   set aCol 5
57   set aName [lindex $aMarkerTypeNames $aMarkerType]
58   vdrawtext "$aName" "$aName" -pos 0 [expr $aRow + 0.5] 0 -color 0.5 1.0 1.0 -halign center -valign center -angle 000 -zoom 0 -height 12 -aspect bold -font $aLabelFont
59   if { $aMarkerType == 13 } {
60     vmarkerstest m${aMarkerType}_${aCol} $aCol $aRow 0 PointsOnSide=1 FileName=$aCustom1
61     set aCol [expr $aCol - 1]
62     vmarkerstest m${aMarkerType}_${aCol} $aCol $aRow 0 PointsOnSide=1 FileName=$aCustom2
63     set aCol [expr $aCol - 1]
64     vmarkerstest m${aMarkerType}_${aCol} $aCol $aRow 0 PointsOnSide=1 FileName=$aCustom3
65     set aCol [expr $aCol - 1]
66     vmarkerstest m${aMarkerType}_${aCol} $aCol $aRow 0 PointsOnSide=1 FileName=$aCustom4
67   } else {
68     for { set aMarkerScale 1.0 } { $aMarkerScale <= 7 } { set aMarkerScale [expr $aMarkerScale + 0.5] } {
69       vmarkerstest m${aMarkerType}_${aCol} $aCol $aRow 0 MarkerType=$aMarkerType Scale=$aMarkerScale PointsOnSide=1
70       set aCol [expr $aCol - 1]
71     }
72   }
73 }
74 puts "All markers have been displayed"