Skip to content

Commit

Permalink
extra arg for LooperControl to have multiple (needed for multiple net…
Browse files Browse the repository at this point in the history
…works); other misc improvements for sims
  • Loading branch information
rcoreilly committed Aug 28, 2024
1 parent c67ca55 commit 926d9b3
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 16 deletions.
24 changes: 14 additions & 10 deletions egui/loopctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ import (

// AddLooperCtrl adds toolbar control for looper.Stack
// with Run, Step controls.
func (gui *GUI) AddLooperCtrl(p *tree.Plan, loops *looper.Manager, modes []etime.Modes) {
gui.AddToolbarItem(p, ToolbarItem{Label: "Stop",
func (gui *GUI) AddLooperCtrl(p *tree.Plan, loops *looper.Manager, modes []etime.Modes, prefix ...string) {
pfx := ""
if len(prefix) == 1 {
pfx = prefix[0] + ": "
}
gui.AddToolbarItem(p, ToolbarItem{Label: pfx + "Stop",
Icon: icons.Stop,
Tooltip: "Interrupts running. running / stepping picks back up where it left off.",
Active: ActiveRunning,
Expand All @@ -31,10 +35,10 @@ func (gui *GUI) AddLooperCtrl(p *tree.Plan, loops *looper.Manager, modes []etime

for _, m := range modes {
mode := m
tree.AddAt(p, mode.String()+"-run", func(w *core.Button) {
tree.AddAt(p, pfx+mode.String()+"-run", func(w *core.Button) {
tb := p.Parent.(*core.Toolbar)
w.SetText(mode.String() + " Run").SetIcon(icons.PlayArrow).
SetTooltip("Run the " + mode.String() + " process")
w.SetText(pfx + mode.String() + " Run").SetIcon(icons.PlayArrow).
SetTooltip("Run the " + pfx + mode.String() + " process")
w.FirstStyler(func(s *styles.Style) { s.SetEnabled(!gui.IsRunning) })
w.OnClick(func(e events.Event) {
if !gui.IsRunning {
Expand All @@ -56,10 +60,10 @@ func (gui *GUI) AddLooperCtrl(p *tree.Plan, loops *looper.Manager, modes []etime
stringToEnumTime[st.String()] = st
}

tree.AddAt(p, mode.String()+"-step", func(w *core.Button) {
tree.AddAt(p, pfx+mode.String()+"-step", func(w *core.Button) {
tb := p.Parent.(*core.Toolbar)
w.SetText("Step").SetIcon(icons.SkipNext).
SetTooltip("Step the " + mode.String() + " process according to the following step level and N")
w.SetText(pfx + "Step").SetIcon(icons.SkipNext).
SetTooltip("Step the " + pfx + mode.String() + " process according to the following step level and N")
w.FirstStyler(func(s *styles.Style) {
s.SetEnabled(!gui.IsRunning)
s.SetAbilities(true, abilities.RepeatClickable)
Expand All @@ -79,7 +83,7 @@ func (gui *GUI) AddLooperCtrl(p *tree.Plan, loops *looper.Manager, modes []etime

var chs *core.Chooser
var sp *core.Spinner
tree.AddAt(p, mode.String()+"-level", func(w *core.Chooser) {
tree.AddAt(p, pfx+mode.String()+"-level", func(w *core.Chooser) {
chs = w
stepStrs := []string{}
for _, s := range steps {
Expand All @@ -96,7 +100,7 @@ func (gui *GUI) AddLooperCtrl(p *tree.Plan, loops *looper.Manager, modes []etime
})
})

tree.AddAt(p, mode.String()+"-n", func(w *core.Spinner) {
tree.AddAt(p, pfx+mode.String()+"-n", func(w *core.Spinner) {
sp = w
w.SetStep(1).SetMin(1).SetValue(1)
w.SetTooltip("number of iterations per step")
Expand Down
2 changes: 1 addition & 1 deletion elog/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type WriteMap map[etime.ScopeKey]WriteFunc

// Item describes one item to be logged -- has all the info
// for this item, across all scopes where it is relevant.
type Item struct {
type Item struct { //types:add -setters

// name of column -- must be unique for a table
Name string
Expand Down
61 changes: 60 additions & 1 deletion elog/typegen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions netview/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ func (nv *NetView) UpdatePaths() {
return
}
nv.hasPaths = true
nv.pathTypeShown = nv.Options.PathType
nv.pathWidthShown = nv.Options.PathWidth

nmin, nmax := nb.MinPos, nb.MaxPos
nsz := nmax.Sub(nmin).Sub(math32.Vec3(1, 1, 0)).Max(math32.Vec3(1, 1, 1))
Expand Down Expand Up @@ -405,6 +403,8 @@ func (nv *NetView) UpdatePaths() {
sfp.Pose.Pos = laySidePos(lb, selfSide, 1, pi, npt, 0)
}
}
nv.pathTypeShown = nv.Options.PathType
nv.pathWidthShown = nv.Options.PathWidth
}

func (nv *NetView) pathTypeNameMatch(pcls string) bool {
Expand All @@ -427,11 +427,12 @@ func (nv *NetView) pathTypeNameMatch(pcls string) bool {
func (nv *NetView) selfPrjn(se *xyz.Scene, side int) xyz.Mesh {
selfnm := fmt.Sprintf("selfPathSide%d", side)
sm, err := se.MeshByName(selfnm)
if err == nil {
if err == nil && nv.pathWidthShown == nv.Options.PathWidth {
return sm
}
szm := max(nv.Options.PathWidth/0.002, 1)
lineWidth := 1.5 * nv.Options.PathWidth
size := float32(0.015)
size := float32(0.015) * szm
sideFact := float32(1.5)
if side == 1 {
sideFact = -1.5
Expand Down

0 comments on commit 926d9b3

Please sign in to comment.