Documentation ¶
Overview ¶
Package etview provides GUI Views of etable Table and Tensor structures using the Cogent Core View framework: https://cogentcore.org/core
* TableView provides a row-and-column tabular GUI interface, similar to a spreadsheet, for viewing and editing Table data. Any higher-dimensional tensor columns are shown as TensorGrid elements that can be clicked to open a TensorView editor with actual numeric values in a similar spreadsheet- like GUI.
* TensorView provides a spreadsheet-like GUI for viewing and editing tensor data.
* TensorGrid provides a 2D colored grid display of tensor data, collapsing any higher dimensions down to 2D. Different views.ColorMaps can be used to translate values into colors.
Index ¶
- Constants
- Variables
- func SimMatGridDialog(ctx core.Widget, smat *simat.SimMat, title string)
- func TableViewDialog(ctx core.Widget, ix *etable.IndexView, title string)
- func TensorGridDialog(ctx core.Widget, tsr etensor.Tensor, title string)
- type SimMatGrid
- func (tg *SimMatGrid) MinSize() math32.Vector2
- func (t *SimMatGrid) New() tree.Node
- func (t *SimMatGrid) NodeType() *types.Type
- func (tg *SimMatGrid) OnInit()
- func (tg *SimMatGrid) Render()
- func (t *SimMatGrid) SetColorMap(v *colormap.Map) *SimMatGrid
- func (t *SimMatGrid) SetDisp(v TensorDisp) *SimMatGrid
- func (tg *SimMatGrid) SetSimMat(smat *simat.SimMat) *SimMatGrid
- func (t *SimMatGrid) SetTooltip(v string) *SimMatGrid
- func (tg *SimMatGrid) SizeLabel(lbs []string, col bool) (minBlank, ngps int, sz math32.Vector2)
- type SimMatValue
- type TableValue
- type TableView
- func (tv *TableView) ColTensorBlank(cidx int, col etensor.Tensor) *etensor.Float64
- func (tv *TableView) ColTensorDisp(col int) *TensorDisp
- func (tv *TableView) Config()
- func (tv *TableView) ConfigFrame()
- func (tv *TableView) ConfigHeader()
- func (tv *TableView) ConfigRows()
- func (tv *TableView) ConfigTableView()
- func (tv *TableView) ConfigToolbar(tb *core.Toolbar)
- func (tv *TableView) GoUpdateView()
- func (tv *TableView) HasStyleFunc() bool
- func (t *TableView) New() tree.Node
- func (t *TableView) NodeType() *types.Type
- func (tv *TableView) OnInit()
- func (tv *TableView) RowFirstVisWidget(row int) (*core.WidgetBase, bool)
- func (tv *TableView) RowGrabFocus(row int) *core.WidgetBase
- func (tv *TableView) RowWidgetNs() (nWidgPerRow, idxOff int)
- func (t *TableView) SetBlankFloat(v float64) *TableView
- func (t *TableView) SetBlankString(v string) *TableView
- func (tv *TableView) SetColTensorDisp(col int) *TensorDisp
- func (t *TableView) SetColTsrBlank(v map[int]*etensor.Float64) *TableView
- func (t *TableView) SetColTsrDisp(v map[int]*TensorDisp) *TableView
- func (t *TableView) SetHeaderWidths(v ...int) *TableView
- func (t *TableView) SetInitSelectedIndex(v int) *TableView
- func (t *TableView) SetMinRows(v int) *TableView
- func (t *TableView) SetNCols(v int) *TableView
- func (t *TableView) SetSelectedIndex(v int) *TableView
- func (t *TableView) SetSelectedValue(v any) *TableView
- func (t *TableView) SetSortDesc(v bool) *TableView
- func (tv *TableView) SetSortFieldName(nm string)
- func (t *TableView) SetSortIndex(v int) *TableView
- func (tv *TableView) SetStyles()
- func (tv *TableView) SetTable(et *etable.Table) *TableView
- func (tv *TableView) SetTableView(ix *etable.IndexView) *TableView
- func (t *TableView) SetTooltip(v string) *TableView
- func (t *TableView) SetTsrDisp(v TensorDisp) *TableView
- func (t *TableView) SetViewPath(v string) *TableView
- func (tv *TableView) SizeFinal()
- func (tv *TableView) SliceDeleteAt(idx int)
- func (tv *TableView) SliceHeader() *core.Frame
- func (tv *TableView) SliceNewAt(idx int)
- func (tv *TableView) SortFieldName() string
- func (tv *TableView) SortSliceAction(fldIndex int)
- func (tv *TableView) StyleRow(w core.Widget, idx, fidx int)
- func (tv *TableView) StyleValueWidget(w core.Widget, s *styles.Style, row, col int)
- func (tv *TableView) TensorDispAction(fldIndex int)
- func (tv *TableView) UpdateSliceSize() int
- func (tv *TableView) UpdateWidgets()
- type TensorDisp
- type TensorGrid
- func (tg *TensorGrid) Color(val float64) (norm float64, clr color.Color)
- func (tg *TensorGrid) EditSettings()
- func (tg *TensorGrid) EnsureColorMap()
- func (tg *TensorGrid) HandleEvents()
- func (tg *TensorGrid) MinSize() math32.Vector2
- func (t *TensorGrid) New() tree.Node
- func (t *TensorGrid) NodeType() *types.Type
- func (tg *TensorGrid) OnInit()
- func (tg *TensorGrid) OpenTensorView()
- func (tg *TensorGrid) Render()
- func (t *TensorGrid) SetColorMap(v *colormap.Map) *TensorGrid
- func (t *TensorGrid) SetDisp(v TensorDisp) *TensorGrid
- func (tg *TensorGrid) SetStyles()
- func (tg *TensorGrid) SetTensor(tsr etensor.Tensor) *TensorGrid
- func (t *TensorGrid) SetTooltip(v string) *TensorGrid
- func (tg *TensorGrid) UpdateRange()
- type TensorGridValue
- type TensorLayout
- type TensorValue
Constants ¶
const LabelSpace = float32(8)
Variables ¶
var SimMatGridType = types.AddType(&types.Type{Name: "github.com/emer/etable/v2/etview.SimMatGrid", IDName: "sim-mat-grid", Doc: "SimMatGrid is a widget that displays a similarity / distance matrix\nwith tensor values as a grid of colored squares, and labels for rows, cols", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Embeds: []types.Field{{Name: "TensorGrid"}}, Fields: []types.Field{{Name: "SimMat", Doc: "the similarity / distance matrix"}, {Name: "rowMaxSz"}, {Name: "rowMinBlank"}, {Name: "rowNGps"}, {Name: "colMaxSz"}, {Name: "colMinBlank"}, {Name: "colNGps"}}, Instance: &SimMatGrid{}})
SimMatGridType is the types.Type for SimMatGrid
var TableViewType = types.AddType(&types.Type{Name: "github.com/emer/etable/v2/etview.TableView", IDName: "table-view", Doc: "etview.TableView provides a GUI interface for etable.Table's", Embeds: []types.Field{{Name: "SliceViewBase"}}, Fields: []types.Field{{Name: "Table", Doc: "the idx view of the table that we're a view of"}, {Name: "TsrDisp", Doc: "overall display options for tensor display"}, {Name: "ColTsrDisp", Doc: "per column tensor display params"}, {Name: "ColTsrBlank", Doc: "per column blank tensor values"}, {Name: "NCols", Doc: "number of columns in table (as of last update)"}, {Name: "SortIndex", Doc: "current sort index"}, {Name: "SortDesc", Doc: "whether current sort order is descending"}, {Name: "HeaderWidths", Doc: "HeaderWidths has number of characters in each header, per visfields"}, {Name: "ColMaxWidths", Doc: "ColMaxWidths records maximum width in chars of string type fields"}, {Name: "BlankString", Doc: "\tblank values for out-of-range rows"}, {Name: "BlankFloat"}}, Instance: &TableView{}})
TableViewType is the types.Type for TableView
var TensorGridType = types.AddType(&types.Type{Name: "github.com/emer/etable/v2/etview.TensorGrid", IDName: "tensor-grid", Doc: "TensorGrid is a widget that displays tensor values as a grid of colored squares.", Methods: []types.Method{{Name: "EditSettings", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}}, Embeds: []types.Field{{Name: "WidgetBase"}}, Fields: []types.Field{{Name: "Tensor", Doc: "the tensor that we view"}, {Name: "Disp", Doc: "display options"}, {Name: "ColorMap", Doc: "the actual colormap"}}, Instance: &TensorGrid{}})
TensorGridType is the types.Type for TensorGrid
Functions ¶
func SimMatGridDialog ¶
SimMatGridDialog is for viewing a etensor.Tensor using a SimMatGrid. dialog signals (nil to ignore) gopy:interface=handle
func TableViewDialog ¶
TableViewDialog is for editing an etable.Table using a TableView. gopy:interface=handle
Types ¶
type SimMatGrid ¶
type SimMatGrid struct { TensorGrid // the similarity / distance matrix SimMat *simat.SimMat `set:"-"` // contains filtered or unexported fields }
SimMatGrid is a widget that displays a similarity / distance matrix with tensor values as a grid of colored squares, and labels for rows, cols
func NewSimMatGrid ¶
func NewSimMatGrid(parent tree.Node, name ...string) *SimMatGrid
NewSimMatGrid adds a new SimMatGrid with the given name to the given parent: SimMatGrid is a widget that displays a similarity / distance matrix with tensor values as a grid of colored squares, and labels for rows, cols
func (*SimMatGrid) MinSize ¶
func (tg *SimMatGrid) MinSize() math32.Vector2
func (*SimMatGrid) NodeType ¶
func (t *SimMatGrid) NodeType() *types.Type
NodeType returns the *types.Type of SimMatGrid
func (*SimMatGrid) OnInit ¶
func (tg *SimMatGrid) OnInit()
Defaults sets defaults for values that are at nonsensical initial values
func (*SimMatGrid) Render ¶
func (tg *SimMatGrid) Render()
func (*SimMatGrid) SetColorMap ¶
func (t *SimMatGrid) SetColorMap(v *colormap.Map) *SimMatGrid
SetColorMap sets the [SimMatGrid.ColorMap]
func (*SimMatGrid) SetDisp ¶
func (t *SimMatGrid) SetDisp(v TensorDisp) *SimMatGrid
SetDisp sets the [SimMatGrid.Disp]
func (*SimMatGrid) SetSimMat ¶
func (tg *SimMatGrid) SetSimMat(smat *simat.SimMat) *SimMatGrid
SetSimMat sets the similarity matrix and triggers a display update
func (*SimMatGrid) SetTooltip ¶
func (t *SimMatGrid) SetTooltip(v string) *SimMatGrid
SetTooltip sets the [SimMatGrid.Tooltip]
type SimMatValue ¶
SimMatValue presents a button that pulls up the SimMatGridView viewer for an etable.Table
func (*SimMatValue) Config ¶
func (v *SimMatValue) Config()
func (*SimMatValue) ConfigDialog ¶
func (v *SimMatValue) ConfigDialog(d *core.Body) (bool, func())
func (*SimMatValue) Update ¶
func (v *SimMatValue) Update()
type TableValue ¶
TableValue presents a button that pulls up the TableView viewer for an etable.Table
func (*TableValue) Config ¶
func (v *TableValue) Config()
func (*TableValue) ConfigDialog ¶
func (v *TableValue) ConfigDialog(d *core.Body) (bool, func())
func (*TableValue) Update ¶
func (v *TableValue) Update()
type TableView ¶
type TableView struct { views.SliceViewBase // the idx view of the table that we're a view of Table *etable.IndexView `set:"-"` // overall display options for tensor display TsrDisp TensorDisp // per column tensor display params ColTsrDisp map[int]*TensorDisp // per column blank tensor values ColTsrBlank map[int]*etensor.Float64 // number of columns in table (as of last update) NCols int `edit:"-"` // current sort index SortIndex int // whether current sort order is descending SortDesc bool // HeaderWidths has number of characters in each header, per visfields HeaderWidths []int `copier:"-" view:"-" json:"-" xml:"-"` // ColMaxWidths records maximum width in chars of string type fields ColMaxWidths []int `set:"-" copier:"-" json:"-" xml:"-"` // blank values for out-of-range rows BlankString string BlankFloat float64 }
etview.TableView provides a GUI interface for etable.Table's
func NewTableView ¶
NewTableView adds a new TableView with the given name to the given parent: etview.TableView provides a GUI interface for etable.Table's
func (*TableView) ColTensorBlank ¶
ColTensorBlank returns tensor blanks for given tensor col
func (*TableView) ColTensorDisp ¶
func (tv *TableView) ColTensorDisp(col int) *TensorDisp
ColTensorDisp returns tensor display parameters for this column either the overall defaults or the per-column if set
func (*TableView) ConfigFrame ¶
func (tv *TableView) ConfigFrame()
func (*TableView) ConfigHeader ¶
func (tv *TableView) ConfigHeader()
func (*TableView) ConfigRows ¶
func (tv *TableView) ConfigRows()
ConfigRows configures VisRows worth of widgets to display slice data. It should only be called when NeedsConfigRows is true: when VisRows changes.
func (*TableView) ConfigTableView ¶
func (tv *TableView) ConfigTableView()
func (*TableView) ConfigToolbar ¶
func (*TableView) GoUpdateView ¶
func (tv *TableView) GoUpdateView()
GoUpdateView updates the display for asynchronous updating from other goroutines. Also updates indexview (calling Sequential).
func (*TableView) HasStyleFunc ¶
func (*TableView) NodeType ¶
NodeType returns the *types.Type of TableView
func (*TableView) RowFirstVisWidget ¶
func (tv *TableView) RowFirstVisWidget(row int) (*core.WidgetBase, bool)
RowFirstVisWidget returns the first visible widget for given row (could be index or not) -- false if out of range
func (*TableView) RowGrabFocus ¶
func (tv *TableView) RowGrabFocus(row int) *core.WidgetBase
RowGrabFocus grabs the focus for the first focusable widget in given row -- returns that element or nil if not successful -- note: grid must have already rendered for focus to be grabbed!
func (*TableView) RowWidgetNs ¶
RowWidgetNs returns number of widgets per row and offset for index label
func (*TableView) SetBlankFloat ¶
SetBlankFloat sets the [TableView.BlankFloat]
func (*TableView) SetBlankString ¶
SetBlankString sets the [TableView.BlankString]:
blank values for out-of-range rows
func (*TableView) SetColTensorDisp ¶
func (tv *TableView) SetColTensorDisp(col int) *TensorDisp
SetColTensorDisp sets per-column tensor display params and returns them if already set, just returns them
func (*TableView) SetColTsrBlank ¶
SetColTsrBlank sets the [TableView.ColTsrBlank]: per column blank tensor values
func (*TableView) SetColTsrDisp ¶
func (t *TableView) SetColTsrDisp(v map[int]*TensorDisp) *TableView
SetColTsrDisp sets the [TableView.ColTsrDisp]: per column tensor display params
func (*TableView) SetHeaderWidths ¶
SetHeaderWidths sets the [TableView.HeaderWidths]: HeaderWidths has number of characters in each header, per visfields
func (*TableView) SetInitSelectedIndex ¶
SetInitSelectedIndex sets the [TableView.InitSelectedIndex]
func (*TableView) SetMinRows ¶
SetMinRows sets the [TableView.MinRows]
func (*TableView) SetNCols ¶
SetNCols sets the [TableView.NCols]: number of columns in table (as of last update)
func (*TableView) SetSelectedIndex ¶
SetSelectedIndex sets the [TableView.SelectedIndex]
func (*TableView) SetSelectedValue ¶
SetSelectedValue sets the [TableView.SelectedValue]
func (*TableView) SetSortDesc ¶
SetSortDesc sets the [TableView.SortDesc]: whether current sort order is descending
func (*TableView) SetSortFieldName ¶
SetSortField sets sorting to happen on given field and direction -- see SortFieldName for details
func (*TableView) SetSortIndex ¶
SetSortIndex sets the [TableView.SortIndex]: current sort index
func (*TableView) SetTable ¶
SetTable sets the source table that we are viewing, using a sequential IndexView and then configures the display
func (*TableView) SetTableView ¶
SetTableView sets the source IndexView of a table (using a copy so original is not modified) and then configures the display
func (*TableView) SetTooltip ¶
SetTooltip sets the [TableView.Tooltip]
func (*TableView) SetTsrDisp ¶
func (t *TableView) SetTsrDisp(v TensorDisp) *TableView
SetTsrDisp sets the [TableView.TsrDisp]: overall display options for tensor display
func (*TableView) SetViewPath ¶
SetViewPath sets the [TableView.ViewPath]
func (*TableView) SliceDeleteAt ¶
SliceDeleteAt deletes element at given index from slice
func (*TableView) SliceHeader ¶
SliceHeader returns the Frame header for slice grid
func (*TableView) SliceNewAt ¶
SliceNewAt inserts a new blank element at given index in the slice -- -1 means the end
func (*TableView) SortFieldName ¶
SortFieldName returns the name of the field being sorted, along with :up or :down depending on descending
func (*TableView) SortSliceAction ¶
SortSliceAction sorts the slice for given field index -- toggles ascending vs. descending if already sorting on this dimension
func (*TableView) StyleValueWidget ¶
StyleValueWidget performs additional value widget styling
func (*TableView) TensorDispAction ¶
TensorDispAction allows user to select tensor display options for column pass -1 for global params for the entire table
func (*TableView) UpdateSliceSize ¶
func (*TableView) UpdateWidgets ¶
func (tv *TableView) UpdateWidgets()
UpdateWidgets updates the row widget display to represent the current state of the slice data, including which range of data is being displayed. This is called for scrolling, navigation etc.
type TensorDisp ¶
type TensorDisp struct { TensorLayout // range to plot Range minmax.Range64 `view:"inline"` // if not using fixed range, this is the actual range of data MinMax minmax.F64 `view:"inline"` // the name of the color map to use in translating values to colors ColorMap views.ColorMapName // what proportion of grid square should be filled by color block -- 1 = all, .5 = half, etc GridFill float32 `min:"0.1" max:"1" step:"0.1" default:"0.9,1"` // amount of extra space to add at dimension boundaries, as a proportion of total grid size DimExtra float32 `min:"0" max:"1" step:"0.02" default:"0.1,0.3"` // minimum size for grid squares -- they will never be smaller than this GridMinSize float32 // maximum size for grid squares -- they will never be larger than this GridMaxSize float32 // total preferred display size along largest dimension. // grid squares will be sized to fit within this size, // subject to harder GridMin / Max size constraints TotPrefSize float32 // font size in standard point units for labels (e.g., SimMat) FontSize float32 // our gridview, for update method GridView *TensorGrid `copier:"-" json:"-" xml:"-" view:"-"` }
TensorDisp are options for displaying tensors
func (*TensorDisp) Defaults ¶
func (td *TensorDisp) Defaults()
Defaults sets defaults for values that are at nonsensical initial values
func (*TensorDisp) FromMeta ¶
func (td *TensorDisp) FromMeta(tsr etensor.Tensor)
FromMeta sets display options from Tensor meta-data
type TensorGrid ¶
type TensorGrid struct { core.WidgetBase // the tensor that we view Tensor etensor.Tensor `set:"-"` // display options Disp TensorDisp // the actual colormap ColorMap *colormap.Map }
TensorGrid is a widget that displays tensor values as a grid of colored squares.
func NewTensorGrid ¶
func NewTensorGrid(parent tree.Node, name ...string) *TensorGrid
NewTensorGrid adds a new TensorGrid with the given name to the given parent: TensorGrid is a widget that displays tensor values as a grid of colored squares.
func (*TensorGrid) EditSettings ¶
func (tg *TensorGrid) EditSettings()
func (*TensorGrid) EnsureColorMap ¶
func (tg *TensorGrid) EnsureColorMap()
EnsureColorMap makes sure there is a valid color map that matches specified name
func (*TensorGrid) HandleEvents ¶
func (tg *TensorGrid) HandleEvents()
func (*TensorGrid) MinSize ¶
func (tg *TensorGrid) MinSize() math32.Vector2
MinSize returns minimum size based on tensor and display settings
func (*TensorGrid) NodeType ¶
func (t *TensorGrid) NodeType() *types.Type
NodeType returns the *types.Type of TensorGrid
func (*TensorGrid) OnInit ¶
func (tg *TensorGrid) OnInit()
func (*TensorGrid) OpenTensorView ¶
func (tg *TensorGrid) OpenTensorView()
OpenTensorView pulls up a TensorView of our tensor
func (*TensorGrid) Render ¶
func (tg *TensorGrid) Render()
func (*TensorGrid) SetColorMap ¶
func (t *TensorGrid) SetColorMap(v *colormap.Map) *TensorGrid
SetColorMap sets the [TensorGrid.ColorMap]: the actual colormap
func (*TensorGrid) SetDisp ¶
func (t *TensorGrid) SetDisp(v TensorDisp) *TensorGrid
SetDisp sets the [TensorGrid.Disp]: display options
func (*TensorGrid) SetStyles ¶
func (tg *TensorGrid) SetStyles()
func (*TensorGrid) SetTensor ¶
func (tg *TensorGrid) SetTensor(tsr etensor.Tensor) *TensorGrid
SetTensor sets the tensor and triggers a display update
func (*TensorGrid) SetTooltip ¶
func (t *TensorGrid) SetTooltip(v string) *TensorGrid
SetTooltip sets the [TensorGrid.Tooltip]
func (*TensorGrid) UpdateRange ¶
func (tg *TensorGrid) UpdateRange()
type TensorGridValue ¶
type TensorGridValue struct { views.ValueBase[*TensorGrid] }
TensorGridValue manages a TensorGrid view of an etensor.Tensor
func (*TensorGridValue) Config ¶
func (v *TensorGridValue) Config()
func (*TensorGridValue) Update ¶
func (v *TensorGridValue) Update()
type TensorLayout ¶
type TensorLayout struct { // even-numbered dimensions are displayed as Y*X rectangles -- this determines along which dimension to display any remaining odd dimension: OddRow = true = organize vertically along row dimension, false = organize horizontally across column dimension OddRow bool // if true, then the Y=0 coordinate is displayed from the top-down; otherwise the Y=0 coordinate is displayed from the bottom up, which is typical for emergent network patterns. TopZero bool // display the data as a bitmap image. if a 2D tensor, then it will be a greyscale image. if a 3D tensor with size of either the first or last dim = either 3 or 4, then it is a RGB(A) color image Image bool }
TensorLayout are layout options for displaying tensors
type TensorValue ¶
TensorValue presents a button that pulls up the TensorView viewer for an etensor.Tensor
func (*TensorValue) Config ¶
func (v *TensorValue) Config()
func (*TensorValue) ConfigDialog ¶
func (v *TensorValue) ConfigDialog(d *core.Body) (bool, func())
func (*TensorValue) Update ¶
func (v *TensorValue) Update()