etview

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2019 License: BSD-3-Clause Imports: 19 Imported by: 183

Documentation

Overview

Package etview provides GUI Views of etable Table and Tensor structures using the GoGi View framework: https://github.com/goki/gi

* 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 giv.ColorMaps can be used to translate values into colors.

Index

Constants

This section is empty.

Variables

View Source
var KiT_TableValueView = kit.Types.AddType(&TableValueView{}, nil)
View Source
var KiT_TableView = kit.Types.AddType(&TableView{}, TableViewProps)
View Source
var KiT_TensorGrid = kit.Types.AddType(&TensorGrid{}, nil)
View Source
var KiT_TensorGridValueView = kit.Types.AddType(&TensorGridValueView{}, nil)
View Source
var KiT_TensorValueView = kit.Types.AddType(&TensorValueView{}, nil)
View Source
var KiT_TensorView = kit.Types.AddType(&TensorView{}, TensorViewProps)
View Source
var TableViewProps = ki.Props{
	"background-color": &gi.Prefs.Colors.Background,
	"color":            &gi.Prefs.Colors.Font,
	"max-width":        -1,
	"max-height":       -1,
}
View Source
var TensorViewProps = ki.Props{
	"background-color": &gi.Prefs.Colors.Background,
	"color":            &gi.Prefs.Colors.Font,
	"max-width":        -1,
	"max-height":       -1,
}

Functions

func TableViewDialog

func TableViewDialog(avp *gi.Viewport2D, et *etable.Table, opts giv.DlgOpts, recv ki.Ki, dlgFunc ki.RecvFunc) *gi.Dialog

optionally connects to given signal receiving object and function for dialog signals (nil to ignore)

func TensorViewDialog

func TensorViewDialog(avp *gi.Viewport2D, tsr etensor.Tensor, opts giv.DlgOpts, recv ki.Ki, dlgFunc ki.RecvFunc) *gi.Dialog

optionally connects to given signal receiving object and function for dialog signals (nil to ignore)

Types

type TableValueView

type TableValueView struct {
	giv.ValueViewBase
}

TableValueView presents a button that pulls up the TableView viewer for an etable.Table

func (*TableValueView) Activate

func (vv *TableValueView) Activate(vp *gi.Viewport2D, recv ki.Ki, dlgFunc ki.RecvFunc)

func (*TableValueView) ConfigWidget

func (vv *TableValueView) ConfigWidget(widg gi.Node2D)

func (*TableValueView) HasAction

func (vv *TableValueView) HasAction() bool

func (*TableValueView) UpdateWidget

func (vv *TableValueView) UpdateWidget()

func (*TableValueView) WidgetType

func (vv *TableValueView) WidgetType() reflect.Type

type TableView

type TableView struct {
	giv.SliceViewBase
	Table      *etable.Table       `desc:"the table that we're a view of"`
	TsrDisp    TensorDisp          `desc:"overall display options for tensor display"`
	ColTsrDisp map[int]*TensorDisp `desc:"per column tensor display"`
	NCols      int                 `inactive:"+" desc:"number of columns in table (as of last update)"`
	SortIdx    int                 `desc:"current sort index"`
	SortDesc   bool                `desc:"whether current sort order is descending"`
}

etview.TableView provides a GUI interface for etable.Table's

func AddNewTableView

func AddNewTableView(parent ki.Ki, name string) *TableView

AddNewTableView adds a new tableview to given parent node, with given name.

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

func (tv *TableView) ConfigSliceGrid()

ConfigSliceGrid configures the SliceGrid for the current slice this is only called by global Config and updates are guarded by that

func (*TableView) ConfigToolbar

func (tv *TableView) ConfigToolbar()

ConfigToolbar configures the toolbar actions

func (*TableView) CopySelToMime

func (tv *TableView) CopySelToMime() mimedata.Mimes

CopySelToMime copies selected rows to mime data

func (*TableView) GridLayout

func (tv *TableView) GridLayout() *gi.Layout

GridLayout returns the SliceGrid grid-layout widget, with grid and scrollbar

func (*TableView) IsConfiged

func (tv *TableView) IsConfiged() bool

IsConfiged returns true if the widget is fully configured

func (*TableView) ItemCtxtMenu

func (tv *TableView) ItemCtxtMenu(idx int)

func (*TableView) Layout2D

func (tv *TableView) Layout2D(parBBox image.Rectangle, iter int) bool

func (*TableView) LayoutHeader

func (tv *TableView) LayoutHeader()

LayoutHeader updates the header layout based on field widths

func (*TableView) LayoutSliceGrid

func (tv *TableView) LayoutSliceGrid() bool

LayoutSliceGrid does the proper layout of slice grid depending on allocated size returns true if UpdateSliceGrid should be called after this

func (*TableView) PasteAssign

func (tv *TableView) PasteAssign(md mimedata.Mimes, idx int)

PasteAssign assigns mime data (only the first one!) to this idx

func (*TableView) PasteAtIdx

func (tv *TableView) PasteAtIdx(md mimedata.Mimes, idx int)

PasteAtIdx inserts object(s) from mime data at (before) given slice index

func (*TableView) RowFirstVisWidget

func (tv *TableView) RowFirstVisWidget(row int) (*gi.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) *gi.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) ScrollBar

func (tv *TableView) ScrollBar() *gi.ScrollBar

ScrollBar returns the SliceGrid scrollbar

func (*TableView) SelectRowWidgets

func (tv *TableView) SelectRowWidgets(row int, sel bool)

SelectRowWidgets sets the selection state of given row of widgets

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

func (tv *TableView) SetSortFieldName(nm string)

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

func (*TableView) SetTable

func (tv *TableView) SetTable(et *etable.Table, tmpSave giv.ValueView)

SetTable sets the source table that we are viewing

func (*TableView) SliceDeleteAt

func (tv *TableView) SliceDeleteAt(idx int, doupdt bool)

SliceDeleteAt deletes element at given index from slice -- doupdt means call UpdateSliceGrid to update display

func (*TableView) SliceFrame

func (tv *TableView) SliceFrame() *gi.Frame

SliceFrame returns the outer frame widget, which contains all the header, fields and values

func (*TableView) SliceGrid

func (tv *TableView) SliceGrid() *gi.Frame

SliceGrid returns the SliceGrid grid frame widget, which contains all the fields and values, within SliceFrame

func (*TableView) SliceHeader

func (tv *TableView) SliceHeader() *gi.ToolBar

SliceHeader returns the Toolbar 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(fldIdx 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(svnp reflect.Value, widg gi.Node2D, idx, fidx int, vv giv.ValueView)

func (*TableView) TensorDispAction

func (tv *TableView) TensorDispAction(fldIdx int)

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

func (*TableView) ToolBar

func (tv *TableView) ToolBar() *gi.ToolBar

ToolBar returns the toolbar widget

func (*TableView) UpdateSliceGrid

func (tv *TableView) UpdateSliceGrid()

UpdateSliceGrid updates grid display -- robust to any time calling

func (*TableView) UpdtSliceSize

func (tv *TableView) UpdtSliceSize() int

type TensorDisp

type TensorDisp struct {
	TensorLayout
	Range       minmax.Range64   `view:"inline" desc:"range to plot"`
	MinMax      minmax.F64       `view:"inline" desc:"if not using fixed range, this is the actual range of data"`
	ColorMap    giv.ColorMapName `desc:"the name of the color map to use in translating values to colors"`
	GridMinSize units.Value      `desc:"minimum size for grid squares -- they will never be smaller than this"`
	GridMaxSize units.Value      `desc:"maximum size for grid squares -- they will never be larger than this"`
	TotPrefSize units.Value      `` /* 163-byte string literal not displayed */
}

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

func (td *TensorDisp) ToDots(uc *units.Context)

type TensorGrid

type TensorGrid struct {
	gi.WidgetBase
	Tensor etensor.Tensor `desc:"the tensor that we view"`
	Disp   TensorDisp     `desc:"display options"`
	Map    *giv.ColorMap  `desc:"the actual colormap"`
}

TensorGrid is a widget that displays tensor values as a grid of colored squares.

func AddNewTensorGrid

func AddNewTensorGrid(parent ki.Ki, name string, tsr etensor.Tensor) *TensorGrid

AddNewTensorGrid adds a new tensor grid to given parent node, with given name.

func (*TensorGrid) Color

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

func (*TensorGrid) ConnectEvents2D

func (tg *TensorGrid) ConnectEvents2D()

func (*TensorGrid) Defaults

func (tg *TensorGrid) Defaults()

Defaults sets defaults for values that are at nonsensical initial values

func (*TensorGrid) EnsureColorMap

func (tg *TensorGrid) EnsureColorMap()

EnsureColorMap makes sure there is a valid color map that matches specified name

func (*TensorGrid) MouseEvent

func (tg *TensorGrid) MouseEvent()

MouseEvent handles button MouseEvent

func (*TensorGrid) OpenTensorView

func (tg *TensorGrid) OpenTensorView()

OpenTensorView pulls up a TensorView of our tensor

func (*TensorGrid) Render2D

func (tg *TensorGrid) Render2D()

func (*TensorGrid) RenderTensor

func (tg *TensorGrid) RenderTensor()

func (*TensorGrid) SetTensor

func (tg *TensorGrid) SetTensor(tsr etensor.Tensor)

SetTensor sets the tensor and triggers a display update

func (*TensorGrid) Size2D

func (tg *TensorGrid) Size2D(iter int)

func (*TensorGrid) Style2D

func (tg *TensorGrid) Style2D()

func (*TensorGrid) UpdateRange

func (tg *TensorGrid) UpdateRange()

type TensorGridValueView

type TensorGridValueView struct {
	giv.ValueViewBase
}

TensorGridValueView manages a TensorGrid view of an etensor.Tensor

func (*TensorGridValueView) ConfigWidget

func (vv *TensorGridValueView) ConfigWidget(widg gi.Node2D)

func (*TensorGridValueView) HasAction

func (vv *TensorGridValueView) HasAction() bool

func (*TensorGridValueView) UpdateWidget

func (vv *TensorGridValueView) UpdateWidget()

func (*TensorGridValueView) WidgetType

func (vv *TensorGridValueView) WidgetType() reflect.Type

type TensorLayout

type TensorLayout struct {
	OddRow  bool `` /* 255-byte string literal not displayed */
	TopZero bool `` /* 181-byte string literal not displayed */
	Image   bool `` /* 201-byte string literal not displayed */
}

TensorLayout are layout options for displaying tensors

type TensorValueView

type TensorValueView struct {
	giv.ValueViewBase
}

TensorValueView presents a button that pulls up the TensorView viewer for an etensor.Tensor

func (*TensorValueView) Activate

func (vv *TensorValueView) Activate(vp *gi.Viewport2D, recv ki.Ki, dlgFunc ki.RecvFunc)

func (*TensorValueView) ConfigWidget

func (vv *TensorValueView) ConfigWidget(widg gi.Node2D)

func (*TensorValueView) HasAction

func (vv *TensorValueView) HasAction() bool

func (*TensorValueView) UpdateWidget

func (vv *TensorValueView) UpdateWidget()

func (*TensorValueView) WidgetType

func (vv *TensorValueView) WidgetType() reflect.Type

type TensorView

type TensorView struct {
	giv.SliceViewBase
	Tensor etensor.Tensor `desc:"the tensor that we're a view of"`
	TsrLay TensorLayout   `desc:"layout config of the tensor"`
	NCols  int            `inactive:"+" desc:"number of columns in table (as of last update)"`
}

etview.TensorView provides a GUI interface for etable.Tensor's using a tabular rows-and-columns interface

func AddNewTensorView

func AddNewTensorView(parent ki.Ki, name string) *TensorView

AddNewTensorView adds a new tableview to given parent node, with given name.

func (*TensorView) Config

func (tv *TensorView) Config()

Config configures the view

func (*TensorView) ConfigSliceGrid

func (tv *TensorView) ConfigSliceGrid()

ConfigSliceGrid configures the SliceGrid for the current slice this is only called by global Config and updates are guarded by that

func (*TensorView) ConfigToolbar

func (tv *TensorView) ConfigToolbar()

ConfigToolbar configures the toolbar actions

func (*TensorView) CopySelToMime

func (tv *TensorView) CopySelToMime() mimedata.Mimes

CopySelToMime copies selected rows to mime data

func (*TensorView) GridLayout

func (tv *TensorView) GridLayout() *gi.Layout

GridLayout returns the SliceGrid grid-layout widget, with grid and scrollbar

func (*TensorView) IsConfiged

func (tv *TensorView) IsConfiged() bool

IsConfiged returns true if the widget is fully configured

func (*TensorView) ItemCtxtMenu

func (tv *TensorView) ItemCtxtMenu(idx int)

func (*TensorView) Layout2D

func (tv *TensorView) Layout2D(parBBox image.Rectangle, iter int) bool

func (*TensorView) LayoutHeader

func (tv *TensorView) LayoutHeader()

LayoutHeader updates the header layout based on field widths

func (*TensorView) LayoutSliceGrid

func (tv *TensorView) LayoutSliceGrid() bool

LayoutSliceGrid does the proper layout of slice grid depending on allocated size returns true if UpdateSliceGrid should be called after this

func (*TensorView) PasteAssign

func (tv *TensorView) PasteAssign(md mimedata.Mimes, idx int)

PasteAssign assigns mime data (only the first one!) to this idx

func (*TensorView) PasteAtIdx

func (tv *TensorView) PasteAtIdx(md mimedata.Mimes, idx int)

PasteAtIdx inserts object(s) from mime data at (before) given slice index

func (*TensorView) RowFirstVisWidget

func (tv *TensorView) RowFirstVisWidget(row int) (*gi.WidgetBase, bool)

RowFirstVisWidget returns the first visible widget for given row (could be index or not) -- false if out of range

func (*TensorView) RowGrabFocus

func (tv *TensorView) RowGrabFocus(row int) *gi.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 (*TensorView) RowWidgetNs

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

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

func (*TensorView) ScrollBar

func (tv *TensorView) ScrollBar() *gi.ScrollBar

ScrollBar returns the SliceGrid scrollbar

func (*TensorView) SelectRowWidgets

func (tv *TensorView) SelectRowWidgets(row int, sel bool)

SelectRowWidgets sets the selection state of given row of widgets

func (*TensorView) SetTensor

func (tv *TensorView) SetTensor(tsr etensor.Tensor, tmpSave giv.ValueView)

SetTensor sets the source tensor that we are viewing

func (*TensorView) SliceDeleteAt

func (tv *TensorView) SliceDeleteAt(idx int, doupdt bool)

SliceDeleteAt deletes element at given index from slice -- doupdt means call UpdateSliceGrid to update display

func (*TensorView) SliceFrame

func (tv *TensorView) SliceFrame() *gi.Frame

SliceFrame returns the outer frame widget, which contains all the header, fields and values

func (*TensorView) SliceGrid

func (tv *TensorView) SliceGrid() *gi.Frame

SliceGrid returns the SliceGrid grid frame widget, which contains all the fields and values, within SliceFrame

func (*TensorView) SliceHeader

func (tv *TensorView) SliceHeader() *gi.ToolBar

SliceHeader returns the Toolbar header for slice grid

func (*TensorView) SliceNewAt

func (tv *TensorView) SliceNewAt(idx int)

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

func (*TensorView) StyleRow

func (tv *TensorView) StyleRow(svnp reflect.Value, widg gi.Node2D, idx, fidx int, vv giv.ValueView)

func (*TensorView) ToolBar

func (tv *TensorView) ToolBar() *gi.ToolBar

ToolBar returns the toolbar widget

func (*TensorView) UpdateSliceGrid

func (tv *TensorView) UpdateSliceGrid()

UpdateSliceGrid updates grid display -- robust to any time calling

func (*TensorView) UpdtSliceSize

func (tv *TensorView) UpdtSliceSize() int

Jump to

Keyboard shortcuts

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