/
attaxis.go
116 lines (99 loc) · 2.54 KB
/
attaxis.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright ©2017 The go-hep Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package rbase
import (
"fmt"
"reflect"
"go-hep.org/x/hep/groot/rbytes"
"go-hep.org/x/hep/groot/root"
"go-hep.org/x/hep/groot/rtypes"
"go-hep.org/x/hep/groot/rvers"
)
type AttAxis struct {
Ndivs int32 // number of divisions (10000*n3 + 100*n2 + n1)
AxisColor int16 // color of the line axis
LabelColor int16 // color of labels
LabelFont int16 // font for labels
LabelOffset float32 // offset of labels
LabelSize float32 // size of labels
Ticks float32 // length of tick marks
TitleOffset float32 // offset of axis title
TitleSize float32 // size of axis title
TitleColor int16 // color of axis title
TitleFont int16 // font for axis title
}
func NewAttAxis() *AttAxis {
return &AttAxis{
Ndivs: 510, // FIXME(sbinet)
AxisColor: 1,
LabelColor: 1,
LabelFont: 42,
LabelOffset: 0.005,
LabelSize: 0.035,
Ticks: 0.03,
TitleOffset: 1,
TitleSize: 0.035,
TitleColor: 1,
TitleFont: 42,
}
}
func (*AttAxis) RVersion() int16 {
return rvers.AttAxis
}
func (*AttAxis) Class() string {
return "TAttAxis"
}
func (a *AttAxis) MarshalROOT(w *rbytes.WBuffer) (int, error) {
if w.Err() != nil {
return 0, w.Err()
}
pos := w.WriteVersion(a.RVersion())
w.WriteI32(a.Ndivs)
w.WriteI16(a.AxisColor)
w.WriteI16(a.LabelColor)
w.WriteI16(a.LabelFont)
w.WriteF32(a.LabelOffset)
w.WriteF32(a.LabelSize)
w.WriteF32(a.Ticks)
w.WriteF32(a.TitleOffset)
w.WriteF32(a.TitleSize)
w.WriteI16(a.TitleColor)
w.WriteI16(a.TitleFont)
return w.SetByteCount(pos, a.Class())
}
func (a *AttAxis) UnmarshalROOT(r *rbytes.RBuffer) error {
if r.Err() != nil {
return r.Err()
}
beg := r.Pos()
vers, pos, bcnt := r.ReadVersion(a.Class())
if vers < 4 {
return fmt.Errorf("rbase: TAttAxis version too old (%d < 4)", vers)
}
a.Ndivs = r.ReadI32()
a.AxisColor = r.ReadI16()
a.LabelColor = r.ReadI16()
a.LabelFont = r.ReadI16()
a.LabelOffset = r.ReadF32()
a.LabelSize = r.ReadF32()
a.Ticks = r.ReadF32()
a.TitleOffset = r.ReadF32()
a.TitleSize = r.ReadF32()
a.TitleColor = r.ReadI16()
a.TitleFont = r.ReadI16()
r.CheckByteCount(pos, bcnt, beg, a.Class())
return r.Err()
}
func init() {
f := func() reflect.Value {
o := NewAttAxis()
return reflect.ValueOf(o)
}
rtypes.Factory.Add("TAttAxis", f)
}
var (
_ root.Object = (*AttAxis)(nil)
_ rbytes.Marshaler = (*AttAxis)(nil)
_ rbytes.Unmarshaler = (*AttAxis)(nil)
)