etview

package
v2.0.0-dev0.0.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2024 License: BSD-3-Clause Imports: 26 Imported by: 11

README

etview

Docs: GoDoc

etview provides GUI Views of etable.Table and etensor.Tensor structures using the GoGi View framework, as GoGi Widgets.

Add this to import to get these views to be registered with the Cogent Core Value system:

	_ "github.com/goki/etable/v2/etview" // include to get gui views
  • 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.

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

View Source
const LabelSpace = float32(8)

Variables

View Source
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

View Source
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

View Source
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

func SimMatGridDialog(ctx core.Widget, smat *simat.SimMat, title string)

SimMatGridDialog is for viewing a etensor.Tensor using a SimMatGrid. dialog signals (nil to ignore) gopy:interface=handle

func TableViewDialog

func TableViewDialog(ctx core.Widget, ix *etable.IndexView, title string)

TableViewDialog is for editing an etable.Table using a TableView. gopy:interface=handle

func TensorGridDialog

func TensorGridDialog(ctx core.Widget, tsr etensor.Tensor, title string)

TensorGridDialog is for viewing a etensor.Tensor using a TensorGrid. 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) New

func (t *SimMatGrid) New() tree.Node

New returns a new *SimMatGrid value

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]

func (*SimMatGrid) SizeLabel

func (tg *SimMatGrid) SizeLabel(lbs []string, col bool) (minBlank, ngps int, sz math32.Vector2)

type SimMatValue

type SimMatValue struct {
	views.ValueBase[*core.Button]
}

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

type TableValue struct {
	views.ValueBase[*core.Button]
}

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

func NewTableView(parent tree.Node, name ...string) *TableView

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

func (tv *TableView) ColTensorBlank(cidx int, col etensor.Tensor) *etensor.Float64

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) Config

func (tv *TableView) Config()

Config configures the view

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 (tv *TableView) ConfigToolbar(tb *core.Toolbar)

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 (tv *TableView) HasStyleFunc() bool

func (*TableView) New

func (t *TableView) New() tree.Node

New returns a new *TableView value

func (*TableView) NodeType

func (t *TableView) NodeType() *types.Type

NodeType returns the *types.Type of TableView

func (*TableView) OnInit

func (tv *TableView) OnInit()

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

func (tv *TableView) RowWidgetNs() (nWidgPerRow, idxOff int)

RowWidgetNs returns number of widgets per row and offset for index label

func (*TableView) SetBlankFloat

func (t *TableView) SetBlankFloat(v float64) *TableView

SetBlankFloat sets the [TableView.BlankFloat]

func (*TableView) SetBlankString

func (t *TableView) SetBlankString(v string) *TableView

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

func (t *TableView) SetColTsrBlank(v map[int]*etensor.Float64) *TableView

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

func (t *TableView) SetHeaderWidths(v ...int) *TableView

SetHeaderWidths sets the [TableView.HeaderWidths]: HeaderWidths has number of characters in each header, per visfields

func (*TableView) SetInitSelectedIndex

func (t *TableView) SetInitSelectedIndex(v int) *TableView

SetInitSelectedIndex sets the [TableView.InitSelectedIndex]

func (*TableView) SetMinRows

func (t *TableView) SetMinRows(v int) *TableView

SetMinRows sets the [TableView.MinRows]

func (*TableView) SetNCols

func (t *TableView) SetNCols(v int) *TableView

SetNCols sets the [TableView.NCols]: number of columns in table (as of last update)

func (*TableView) SetSelectedIndex

func (t *TableView) SetSelectedIndex(v int) *TableView

SetSelectedIndex sets the [TableView.SelectedIndex]

func (*TableView) SetSelectedValue

func (t *TableView) SetSelectedValue(v any) *TableView

SetSelectedValue sets the [TableView.SelectedValue]

func (*TableView) SetSortDesc

func (t *TableView) SetSortDesc(v bool) *TableView

SetSortDesc sets the [TableView.SortDesc]: whether current sort order is descending

func (*TableView) SetSortFieldName

func (tv *TableView) SetSortFieldName(nm string)

SetSortField sets sorting to happen on given field and direction -- see SortFieldName for details

func (*TableView) SetSortIndex

func (t *TableView) SetSortIndex(v int) *TableView

SetSortIndex sets the [TableView.SortIndex]: current sort index

func (*TableView) SetStyles

func (tv *TableView) SetStyles()

func (*TableView) SetTable

func (tv *TableView) SetTable(et *etable.Table) *TableView

SetTable sets the source table that we are viewing, using a sequential IndexView and then configures the display

func (*TableView) SetTableView

func (tv *TableView) SetTableView(ix *etable.IndexView) *TableView

SetTableView sets the source IndexView of a table (using a copy so original is not modified) and then configures the display

func (*TableView) SetTooltip

func (t *TableView) SetTooltip(v string) *TableView

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

func (t *TableView) SetViewPath(v string) *TableView

SetViewPath sets the [TableView.ViewPath]

func (*TableView) SizeFinal

func (tv *TableView) SizeFinal()

func (*TableView) SliceDeleteAt

func (tv *TableView) SliceDeleteAt(idx int)

SliceDeleteAt deletes element at given index from slice

func (*TableView) SliceHeader

func (tv *TableView) SliceHeader() *core.Frame

SliceHeader returns the Frame header for slice grid

func (*TableView) SliceNewAt

func (tv *TableView) SliceNewAt(idx int)

SliceNewAt inserts a new blank element at given index in the slice -- -1 means the end

func (*TableView) SortFieldName

func (tv *TableView) SortFieldName() string

SortFieldName returns the name of the field being sorted, along with :up or :down depending on descending

func (*TableView) SortSliceAction

func (tv *TableView) SortSliceAction(fldIndex int)

SortSliceAction sorts the slice for given field index -- toggles ascending vs. descending if already sorting on this dimension

func (*TableView) StyleRow

func (tv *TableView) StyleRow(w core.Widget, idx, fidx int)

func (*TableView) StyleValueWidget

func (tv *TableView) StyleValueWidget(w core.Widget, s *styles.Style, row, col int)

StyleValueWidget performs additional value widget styling

func (*TableView) TensorDispAction

func (tv *TableView) TensorDispAction(fldIndex int)

TensorDispAction allows user to select tensor display options for column pass -1 for global params for the entire table

func (*TableView) UpdateSliceSize

func (tv *TableView) UpdateSliceSize() int

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) Color

func (tg *TensorGrid) Color(val float64) (norm float64, clr color.Color)

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) New

func (t *TensorGrid) New() tree.Node

New returns a new *TensorGrid value

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

type TensorValue struct {
	views.ValueBase[*core.Button]
}

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()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL