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
8pload MODELING VISUALIZATION
9
10# reflects Aspect_TypeOfMarker enumeration
11set 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
29set aCustom1 [locate_data_file images/marker_box1.png]
30set aCustom2 [locate_data_file images/marker_box2.png]
31set aCustom3 [locate_data_file images/marker_kr.png]
32set aCustom4 [locate_data_file images/marker_dot.png]
33
34set aFontFile ""
35catch { set aFontFile [locate_data_file DejaVuSans.ttf] }
36set aLabelFont "Arial"
37if { "$aFontFile" != "" } {
38  vfont add "$aFontFile" SansFont
39  set aLabelFont "SansFont"
40}
41
42# reset the viewer
43vclear
44vclose ALL
45vinit name=View1 l=32 t=32 w=512 h=512
46
47puts "Draw box in advance which should fit all our markers"
48box b -8 -8 0 16 16 2
49vbottom
50vdisplay -noupdate -dispmode 0 b
51vfit
52vremove -noupdate b
53
54puts "Draw markers of different type and size"
55for { set aMarkerType 0 } { $aMarkerType <= 13 } { incr aMarkerType } {
56  set aRow [expr $aMarkerType - 7]
57  set aCol 5
58  set aName [lindex $aMarkerTypeNames $aMarkerType]
59  vdrawtext "$aName" "$aName" -pos 0 [expr $aRow + 0.5] 0 -color 7FFFFF -halign center -valign center -angle 000 -zoom 0 -height 12 -aspect bold -font $aLabelFont -noupdate
60  vdisplay -top -noupdate "$aName"
61  if { $aMarkerType == 13 } {
62    vmarkerstest m${aMarkerType}_${aCol} $aCol $aRow 0 PointsOnSide=1 FileName=$aCustom1
63    set aCol [expr $aCol - 1]
64    vmarkerstest m${aMarkerType}_${aCol} $aCol $aRow 0 PointsOnSide=1 FileName=$aCustom2
65    set aCol [expr $aCol - 1]
66    vmarkerstest m${aMarkerType}_${aCol} $aCol $aRow 0 PointsOnSide=1 FileName=$aCustom3
67    set aCol [expr $aCol - 1]
68    vmarkerstest m${aMarkerType}_${aCol} $aCol $aRow 0 PointsOnSide=1 FileName=$aCustom4
69  } else {
70    for { set aMarkerScale 1.0 } { $aMarkerScale <= 7 } { set aMarkerScale [expr $aMarkerScale + 0.5] } {
71      vmarkerstest m${aMarkerType}_${aCol} $aCol $aRow 0 MarkerType=$aMarkerType Scale=$aMarkerScale PointsOnSide=1
72      set aCol [expr $aCol - 1]
73    }
74  }
75}
76puts "All markers have been displayed"
77