forked from emer/emergent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
params.go
59 lines (52 loc) · 2.06 KB
/
params.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
// Copyright (c) 2019, The Emergent 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 netview
import (
"github.com/emer/etable/minmax"
"github.com/goki/gi/giv"
)
// Params holds parameters controlling how the view is rendered
type Params struct {
UnitSize float32 `min:"0.1" max:"1" step:"0.1" def:"0.9" desc:"size of a single unit, where 1 = full width and no space.. .9 default"`
LayNmSize float32 `min:"0.01" max:".1" step:"0.01" def:"0.05" desc:"size of the layer name labels -- entire network view is unit sized"`
ColorMap giv.ColorMapName `desc:"name of color map to use"`
ZeroAlpha float32 `min:"0" max:"1" step:"0.1" def:"0.4" desc:"opacity (0-1) of zero values -- greater magnitude values become increasingly opaque on either side of this minimum"`
NetView *NetView `copy:"-" json:"-" xml:"-" view:"-" desc:"our netview, for update method"`
}
func (nv *Params) Defaults() {
if nv.UnitSize == 0 {
nv.UnitSize = .9
}
if nv.LayNmSize == 0 {
nv.LayNmSize = .05
}
if nv.ZeroAlpha == 0 {
nv.ZeroAlpha = 0.4
}
if nv.ColorMap == "" {
nv.ColorMap = giv.ColorMapName("ColdHot")
}
}
// Update satisfies the gi.Updater interface and will trigger display update on edits
func (nv *Params) Update() {
if nv.NetView != nil {
nv.NetView.Config()
nv.NetView.Update("")
}
}
// VarParams holds parameters for display of each variable
type VarParams struct {
Var string `desc:"name of the variable"`
ZeroCtr bool `desc:"keep Min - Max centered around 0, and use negative heights for units -- else use full min-max range for height (no negative heights)"`
Range minmax.Range32 `view:"inline" desc:"range to display"`
MinMax minmax.F32 `view:"inline" desc:"if not using fixed range, this is the actual range of data"`
}
// Defaults sets default values if otherwise not set
func (vp *VarParams) Defaults() {
if vp.Range.Max == 0 && vp.Range.Min == 0 {
vp.ZeroCtr = true
vp.Range.SetMin(-1)
vp.Range.SetMax(1)
}
}