go-hep.org/x/hep@v0.38.1/groot/rbase/attpad.go (about) 1 // Copyright ©2023 The go-hep Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package rbase 6 7 import ( 8 "reflect" 9 10 "go-hep.org/x/hep/groot/rbytes" 11 "go-hep.org/x/hep/groot/root" 12 "go-hep.org/x/hep/groot/rtypes" 13 "go-hep.org/x/hep/groot/rvers" 14 ) 15 16 type AttPad struct { 17 fLeftMargin float32 // LeftMargin 18 fRightMargin float32 // RightMargin 19 fBottomMargin float32 // BottomMargin 20 fTopMargin float32 // TopMargin 21 fXfile float32 // X position where to draw the file name 22 fYfile float32 // Y position where to draw the file name 23 fAfile float32 // Alignment for the file name 24 fXstat float32 // X position where to draw the statistics 25 fYstat float32 // Y position where to draw the statistics 26 fAstat float32 // Alignment for the statistics 27 fFrameFillColor int16 // Pad frame fill color 28 fFrameLineColor int16 // Pad frame line color 29 fFrameFillStyle int16 // Pad frame fill style 30 fFrameLineStyle int16 // Pad frame line style 31 fFrameLineWidth int16 // Pad frame line width 32 fFrameBorderSize int16 // Pad frame border size 33 fFrameBorderMode int32 // Pad frame border mode 34 } 35 36 func (*AttPad) RVersion() int16 { 37 return rvers.AttPad 38 } 39 40 func (*AttPad) Class() string { 41 return "TAttPad" 42 } 43 44 func (a *AttPad) MarshalROOT(w *rbytes.WBuffer) (int, error) { 45 if w.Err() != nil { 46 return 0, w.Err() 47 } 48 49 hdr := w.WriteHeader(a.Class(), a.RVersion()) 50 51 w.WriteF32(a.fLeftMargin) 52 w.WriteF32(a.fRightMargin) 53 w.WriteF32(a.fBottomMargin) 54 w.WriteF32(a.fTopMargin) 55 w.WriteF32(a.fXfile) 56 w.WriteF32(a.fYfile) 57 w.WriteF32(a.fAfile) 58 w.WriteF32(a.fXstat) 59 w.WriteF32(a.fYstat) 60 w.WriteF32(a.fAstat) 61 w.WriteI16(a.fFrameFillColor) 62 w.WriteI16(a.fFrameLineColor) 63 w.WriteI16(a.fFrameFillStyle) 64 w.WriteI16(a.fFrameLineStyle) 65 w.WriteI16(a.fFrameLineWidth) 66 w.WriteI16(a.fFrameBorderSize) 67 w.WriteI32(a.fFrameBorderMode) 68 69 return w.SetHeader(hdr) 70 } 71 72 func (a *AttPad) UnmarshalROOT(r *rbytes.RBuffer) error { 73 if r.Err() != nil { 74 return r.Err() 75 } 76 77 hdr := r.ReadHeader(a.Class(), a.RVersion()) 78 a.fLeftMargin = r.ReadF32() 79 a.fRightMargin = r.ReadF32() 80 a.fBottomMargin = r.ReadF32() 81 a.fTopMargin = r.ReadF32() 82 a.fXfile = r.ReadF32() 83 a.fYfile = r.ReadF32() 84 a.fAfile = r.ReadF32() 85 a.fXstat = r.ReadF32() 86 a.fYstat = r.ReadF32() 87 a.fAstat = r.ReadF32() 88 if hdr.Vers > 1 { 89 a.fFrameFillColor = r.ReadI16() 90 a.fFrameLineColor = r.ReadI16() 91 a.fFrameFillStyle = r.ReadI16() 92 a.fFrameLineStyle = r.ReadI16() 93 a.fFrameLineWidth = r.ReadI16() 94 a.fFrameBorderSize = r.ReadI16() 95 a.fFrameBorderMode = r.ReadI32() 96 } 97 98 r.CheckHeader(hdr) 99 100 return r.Err() 101 } 102 103 func init() { 104 f := func() reflect.Value { 105 var v AttPad 106 return reflect.ValueOf(&v) 107 } 108 rtypes.Factory.Add("TAttPad", f) 109 } 110 111 var ( 112 _ root.Object = (*AttPad)(nil) 113 _ rbytes.Marshaler = (*AttPad)(nil) 114 _ rbytes.Unmarshaler = (*AttPad)(nil) 115 )