-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_heatmap.go
101 lines (81 loc) · 2.07 KB
/
plot_heatmap.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
package gig
import (
"github.com/leonsal/gig/imgui"
)
type PlotHeatmap struct {
Widget
labelId imgui.CString
v interface{}
rows int
cols int
scaleMin float64
scaleMax float64
labelFmt imgui.CString
boundsMin imgui.PlotPoint
boundsMax imgui.PlotPoint
renderIndex int
}
func NewPlotHeatmap(label string) *PlotHeatmap {
p := new(PlotHeatmap)
p.Init(p)
p.labelId.SetString(label)
p.scaleMin = 0
p.scaleMax = 0
p.labelFmt.SetString("%.1f")
p.boundsMin = imgui.PlotPoint{0, 0}
p.boundsMax = imgui.PlotPoint{1, 1}
p.SetRender(func() {
switch p.renderIndex {
case indexPlotI32:
imgui.PlotHeatmapInt32CS(p.labelId, p.v.(*int32), p.rows, p.cols, p.scaleMin, p.scaleMax, p.labelFmt, p.boundsMin, p.boundsMax)
case indexPlotF32:
imgui.PlotHeatmapFloat32CS(p.labelId, p.v.(*float32), p.rows, p.cols, p.scaleMin, p.scaleMax, p.labelFmt, p.boundsMin, p.boundsMax)
case indexPlotF64:
imgui.PlotHeatmapFloat64CS(p.labelId, p.v.(*float64), p.rows, p.cols, p.scaleMin, p.scaleMax, p.labelFmt, p.boundsMin, p.boundsMax)
}
})
return p
}
func (p *PlotHeatmap) Save(pp **PlotHeatmap) *PlotHeatmap {
*pp = p
return p
}
func (p *PlotHeatmap) SetLabel(label string) *PlotHeatmap {
p.labelId.SetString(label)
return p
}
func (p *PlotHeatmap) SetValuesInt32(v *int32, rows, cols int) *PlotHeatmap {
p.v = v
p.rows = rows
p.cols = cols
p.renderIndex = indexPlotI32
return p
}
func (p *PlotHeatmap) SetValuesFloat32(v *float32, rows, cols int) *PlotHeatmap {
p.v = v
p.rows = rows
p.cols = cols
p.renderIndex = indexPlotF32
return p
}
func (p *PlotHeatmap) SetValuesFloat64(v *float64, rows, cols int) *PlotHeatmap {
p.v = v
p.rows = rows
p.cols = cols
p.renderIndex = indexPlotF64
return p
}
func (p *PlotHeatmap) SetScale(min, max float64) *PlotHeatmap {
p.scaleMin = min
p.scaleMax = max
return p
}
func (p *PlotHeatmap) SetLabelFmt(fmt string) *PlotHeatmap {
p.labelFmt.SetString(fmt)
return p
}
func (p *PlotHeatmap) SetBounds(min, max imgui.PlotPoint) *PlotHeatmap {
p.boundsMin = min
p.boundsMax = max
return p
}