()
| 117 | } |
| 118 | |
| 119 | func (tg *SimMatGrid) Render() { |
| 120 | if tg.SimMat == nil || tg.SimMat.Mat.Len() == 0 { |
| 121 | return |
| 122 | } |
| 123 | tg.EnsureColorMap() |
| 124 | tg.UpdateRange() |
| 125 | pc := &tg.Scene.PaintContext |
| 126 | |
| 127 | pos := tg.Geom.Pos.Content |
| 128 | sz := tg.Geom.Size.Actual.Content |
| 129 | |
| 130 | effsz := sz |
| 131 | effsz.X -= tg.rowMaxSz.X + LabelSpace |
| 132 | effsz.Y -= tg.colMaxSz.Y + LabelSpace |
| 133 | |
| 134 | pc.FillBox(pos, sz, tg.Styles.Background) |
| 135 | |
| 136 | tsr := tg.SimMat.Mat |
| 137 | |
| 138 | rows, cols, _, _ := tensor.Projection2DShape(tsr.Shape(), tg.Display.OddRow) |
| 139 | rowEx := tg.rowNGps |
| 140 | colEx := tg.colNGps |
| 141 | frw := float32(rows) + float32(rowEx)*tg.Display.DimExtra // extra spacing |
| 142 | fcl := float32(cols) + float32(colEx)*tg.Display.DimExtra // extra spacing |
| 143 | tsz := math32.Vec2(fcl, frw) |
| 144 | gsz := effsz.Div(tsz) |
| 145 | |
| 146 | // Render Rows |
| 147 | epos := pos |
| 148 | epos.Y += tg.colMaxSz.Y + LabelSpace |
| 149 | nr := len(tg.SimMat.Rows) |
| 150 | mx := min(nr, rows) |
| 151 | tr := paint.Text{} |
| 152 | txsty := tg.Styles.Text |
| 153 | txsty.AlignV = styles.Start |
| 154 | ygp := 0 |
| 155 | prvyblk := false |
| 156 | fr := tg.Styles.FontRender() |
| 157 | for y := 0; y < mx; y++ { |
| 158 | lb := tg.SimMat.Rows[y] |
| 159 | if len(lb) == 0 { |
| 160 | prvyblk = true |
| 161 | continue |
| 162 | } |
| 163 | if prvyblk { |
| 164 | ygp++ |
| 165 | prvyblk = false |
| 166 | } |
| 167 | yex := float32(ygp) * tg.Display.DimExtra |
| 168 | tr.SetString(lb, fr, &tg.Styles.UnitContext, &txsty, true, 0, 0) |
| 169 | tr.LayoutStdLR(&txsty, fr, &tg.Styles.UnitContext, tg.rowMaxSz) |
| 170 | cr := math32.Vec2(0, float32(y)+yex) |
| 171 | pr := epos.Add(cr.Mul(gsz)) |
| 172 | tr.Render(pc, pr) |
| 173 | } |
| 174 | |
| 175 | // Render Cols |
| 176 | epos = pos |
nothing calls this directly
no test coverage detected