File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
Interaction/Widgets/OrientationMarkerWidget/example
Rendering/Core/AnnotatedCubeActor Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ axes.setDefaultStyle({
40
40
fontColor : 'black' ,
41
41
fontSizeScale : ( res ) => res / 2 ,
42
42
faceColor : '#0000ff' ,
43
+ faceRotation : 0 ,
43
44
edgeThickness : 0.1 ,
44
45
edgeColor : 'black' ,
45
46
resolution : 400 ,
@@ -48,6 +49,7 @@ axes.setDefaultStyle({
48
49
axes . setXMinusFaceProperty ( {
49
50
text : '-X' ,
50
51
faceColor : '#ffff00' ,
52
+ faceRotation : 90 ,
51
53
fontStyle : 'italic' ,
52
54
} ) ;
53
55
axes . setYPlusFaceProperty ( {
@@ -60,8 +62,11 @@ axes.setYMinusFaceProperty({
60
62
faceColor : '#00ffff' ,
61
63
fontColor : 'white' ,
62
64
} ) ;
63
- axes . setZPlusFaceProperty ( { text : '+Z' , edgeColor : 'yellow' } ) ;
64
- axes . setZMinusFaceProperty ( { text : '-Z' , edgeThickness : 0 } ) ;
65
+ axes . setZPlusFaceProperty ( {
66
+ text : '+Z' ,
67
+ edgeColor : 'yellow' ,
68
+ } ) ;
69
+ axes . setZMinusFaceProperty ( { text : '-Z' , faceRotation : 45 , edgeThickness : 0 } ) ;
65
70
66
71
// create orientation widget
67
72
const orientationWidget = vtkOrientationMarkerWidget . newInstance ( {
Original file line number Diff line number Diff line change @@ -69,13 +69,20 @@ function vtkAnnotatedCubeActor(publicAPI, model) {
69
69
ctxt . strokeRect ( 0 , 0 , canvas . width , canvas . height ) ;
70
70
}
71
71
72
+ // set face rotation
73
+ ctxt . save ( ) ;
74
+ ctxt . translate ( canvas . width / 2 , canvas . height / 2 ) ;
75
+ ctxt . rotate ( - Math . PI * ( prop . faceRotation / 180.0 ) ) ;
76
+
72
77
// set foreground text
73
78
const textSize = prop . fontSizeScale ( prop . resolution ) ;
74
79
ctxt . fillStyle = prop . fontColor ;
75
80
ctxt . textAlign = 'center' ;
76
81
ctxt . textBaseline = 'middle' ;
77
82
ctxt . font = `${ prop . fontStyle } ${ textSize } px "${ prop . fontFamily } "` ;
78
- ctxt . fillText ( prop . text , canvas . width / 2 , canvas . height / 2 ) ;
83
+ ctxt . fillText ( prop . text , 0 , 0 ) ;
84
+
85
+ ctxt . restore ( ) ;
79
86
80
87
const vtkImage = ImageHelper . canvasToImageData ( canvas ) ;
81
88
texture . setInputData ( vtkImage , FACE_TO_INDEX [ faceName ] ) ;
@@ -130,6 +137,7 @@ export const DEFAULT_VALUES = {
130
137
defaultStyle : {
131
138
text : '' ,
132
139
faceColor : 'white' ,
140
+ faceRotation : 0 ,
133
141
fontFamily : 'Arial' ,
134
142
fontColor : 'black' ,
135
143
fontStyle : 'normal' ,
You can’t perform that action at this time.
0 commit comments