0030969: Coding Rules - refactor Quantity_Color.cxx color table definition
[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 ""
35 catch { set aFontFile [locate_data_file DejaVuSans.ttf] }
36 set aLabelFont "Arial"
37 if { "$aFontFile" != "" } {
38   vfont add "$aFontFile" SansFont
39   set aLabelFont "SansFont"
40 }
41
42 # reset the viewer
43 vclear
44 vclose ALL
45 vinit name=View1 l=32 t=32 w=512 h=512
46
47 puts "Draw box in advance which should fit all our markers"
48 box b -8 -8 0 16 16 2
49 vbottom
50 vdisplay -noupdate -dispmode 0 b
51 vfit
52 vremove -noupdate b
53
54 puts "Draw markers of different type and size"
55 for { 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 }
76 puts "All markers have been displayed"