qml

package
v0.0.0-...-f96ffc0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2015 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package qml implements a GUI interface and plotting functions using the go QML bindings.

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultFontName  = "NimbusSanL-Bold"
	DefaultFontScale = 14
)
View Source
var DefaultColors = []color.RGBA{
	rgb(255, 255, 0),
	rgb(0, 255, 255),
	rgb(255, 105, 180),
	rgb(0, 255, 0),
	rgb(0, 0, 255),
	rgb(255, 0, 0),
	rgb(255, 0, 255),
}

Functions

func Color

func Color(i int) color.RGBA

Color returns the ith default color

func MainLoop

func MainLoop(ctrl *Ctrl)

MainLoop function is called to draw the scene, it does not return. ctrl is the control structure used for sending events and plts is a list of plots to display.

Types

type Axis

type Axis struct {
	Title     string
	FloatZero bool
	// contains filtered or unexported fields
}

Axis type represents the axis for the plot

type Config

type Config struct {
	Model string
	// contains filtered or unexported fields
}

Config type manages updating the config settings

func (*Config) Default

func (c *Config) Default(model string)

Set default config settings

func (*Config) Load

func (c *Config) Load(model string)

Load config settings from disk

func (*Config) Print

func (c *Config) Print()

func (*Config) Save

func (c *Config) Save(model string)

Save current config settings to disk

func (*Config) Set

func (c *Config) Set(key, value string)

Set config value from GUI

func (*Config) Update

func (c *Config) Update()

Update display of config settings

type Ctrl

type Ctrl struct {
	WG sync.WaitGroup
	// contains filtered or unexported fields
}

Ctrl type is used for communication with the gui

func NewCtrl

func NewCtrl(cfg *network.Config, net *network.Network, testData *network.Data, dataSets []string, selected string, plots []*Plot) *Ctrl

func (*Ctrl) Done

func (c *Ctrl) Done()

Callback when run is completed

func (*Ctrl) NextEvent

func (c *Ctrl) NextEvent(running bool) Event

Get next event from channel, if running is set then auto step

func (*Ctrl) Refresh

func (c *Ctrl) Refresh(cfg *network.Config, net *network.Network, testData *network.Data)

Callback to refresh the plot when selecting a new dataset

func (*Ctrl) Select

func (c *Ctrl) Select(model string)

Choose new data set

func (*Ctrl) Send

func (c *Ctrl) Send(typ, arg string)

Send user input invent

func (*Ctrl) SetRun

func (c *Ctrl) SetRun(run int)

Callback to set run number

type Event

type Event struct {
	Typ string
	Arg string
}

type Font

type Font struct {
	// contains filtered or unexported fields
}

A Font allows rendering of text to an OpenGL context.

func (*Font) DrawText

func (f *Font) DrawText(gl *GL.GL, xpos, ypos, angle float32, str string) error

DrawText method draws the given string at the specified coordinates.

func (*Font) Height

func (f *Font) Height() int

Height method returns font height in points

func (*Font) Size

func (f *Font) Size(s string) (w int)

Size method returns the horizontal size of string in points

type Histogram

type Histogram struct {
	Fill bool
	// contains filtered or unexported fields
}

Histogram plotter represents a histogram plot.

func NewHistogram

func NewHistogram(pts XYer, name string) *Histogram

NewHistogram function creates a histogram plot with the given data

func (Histogram) DataRange

func (pt Histogram) DataRange() (min, max Point)

DataRange method gives the x and y range

func (Histogram) DrawLegend

func (pt Histogram) DrawLegend(gl *GL.GL, ps *Plots)

DrawLegend method draws the legend at the current screen position.

func (Histogram) LegendSize

func (pt Histogram) LegendSize(ps *Plots) (w, h float32)

LegendSize method returns the size of the legend on screen.

func (*Histogram) Plot

func (h *Histogram) Plot(gl *GL.GL, p *Plot)

Plot method implements the plotter interface

func (*Histogram) Refresh

func (h *Histogram) Refresh()

Refresh method is called to update the data

func (*Histogram) Scaled

func (h *Histogram) Scaled() bool

func (Histogram) SetColor

func (pt Histogram) SetColor(c color.RGBA)

func (Histogram) SetName

func (pt Histogram) SetName(n string)

type Line

type Line struct {
	Width float32
	// contains filtered or unexported fields
}

Line plotter represents a line plot.

func NewLine

func NewLine(pts XYer, name string) *Line

NewLine function creates a new line with the given data

func (Line) DataRange

func (pt Line) DataRange() (min, max Point)

DataRange method gives the x and y range

func (Line) DrawLegend

func (pt Line) DrawLegend(gl *GL.GL, ps *Plots)

DrawLegend method draws the legend at the current screen position.

func (Line) LegendSize

func (pt Line) LegendSize(ps *Plots) (w, h float32)

LegendSize method returns the size of the legend on screen.

func (*Line) Plot

func (l *Line) Plot(gl *GL.GL, p *Plot)

Plot method implements the plotter interface

func (*Line) Refresh

func (l *Line) Refresh()

Refresh method is called to update the data

func (Line) Scaled

func (pt Line) Scaled() bool

func (Line) SetColor

func (pt Line) SetColor(c color.RGBA)

func (Line) SetName

func (pt Line) SetName(n string)

type Network

type Network struct {
	qml.Object

	Background color.RGBA
	Color      color.RGBA
	// contains filtered or unexported fields
}

Network type is used to visualise the neural net.

func (*Network) Compact

func (n *Network) Compact(on bool)

Enable compact view

func (*Network) Distort

func (n *Network) Distort(on bool, mode int)

Apply distortion to the image

func (*Network) Filter

func (n *Network) Filter(on bool, val int)

Filter to only show errors

func (*Network) First

func (n *Network) First()

Step to first entry in test set

func (*Network) Next

func (n *Network) Next()

Step to next entry in test set

func (*Network) Paint

func (n *Network) Paint(paint *qml.Painter)

Paint method draws the network.

func (*Network) Prev

func (n *Network) Prev()

Step to previous entry in test set

func (*Network) Run

func (n *Network) Run(offset int)

Run network. Step to next data entry if filter is not matched.

type Plot

type Plot struct {
	Name     string
	Title    string
	Xaxis    *Axis
	Yaxis    *Axis
	Legend   Position
	Plotters []Plotter
}

Plot type represents one of the plots

func NewPlot

func NewPlot(name, title string, plt ...Plotter) *Plot

NewPlot function creates a new plot with default settings

func (*Plot) Add

func (p *Plot) Add(plt ...Plotter)

Add method adds elements to the plot

func (*Plot) Clear

func (p *Plot) Clear()

Clear method removes all the ploters from the plot

func (*Plot) Trans

func (p *Plot) Trans(x0, y0 float32) (x1, y1 float32)

Trans method converts from plot to screen coordinates

type Plots

type Plots struct {
	qml.Object
	Grid       bool
	Background color.RGBA
	Color      color.RGBA
	GridColor  color.RGBA
	// contains filtered or unexported fields
}

Plots type is a QML plotting component.

func (*Plots) Paint

func (ps *Plots) Paint(paint *qml.Painter)

Paint method draws the plot.

func (*Plots) Select

func (ps *Plots) Select(i int)

Switch the plot to display

func (*Plots) TextHeight

func (ps *Plots) TextHeight() float32

returns height of the current font in model coords

func (*Plots) TextWidth

func (ps *Plots) TextWidth(s string) float32

returns the width of string in model coords

type Plotter

type Plotter interface {
	Refresh()
	Plot(gl *GL.GL, p *Plot)
	LegendSize(ps *Plots) (x, y float32)
	DrawLegend(gl *GL.GL, ps *Plots)
	DataRange() (min, max Point)
	SetColor(c color.RGBA)
	SetName(n string)
	Scaled() bool
}

Plotter interface type is a plottable data set.

type Point

type Point struct {
	X, Y float32
}

func NewPoint

func NewPoint(x, y float32) Point

type Points

type Points struct {
	PointSize  float32
	DrawErrors bool
	// contains filtered or unexported fields
}

Points plotter represents an xy scatter plot

func NewPoints

func NewPoints(xpts, ypts XYer, name string) *Points

NewPoints function creates a new scatter plot

func (Points) DataRange

func (pt Points) DataRange() (min, max Point)

DataRange method gives the x and y range

func (Points) DrawLegend

func (pt Points) DrawLegend(gl *GL.GL, ps *Plots)

DrawLegend method draws the legend at the current screen position.

func (Points) LegendSize

func (pt Points) LegendSize(ps *Plots) (w, h float32)

LegendSize method returns the size of the legend on screen.

func (*Points) Plot

func (d *Points) Plot(gl *GL.GL, p *Plot)

Plot method implements the plotter interface

func (*Points) Refresh

func (d *Points) Refresh()

Refresh method is called to update the data

func (Points) Scaled

func (pt Points) Scaled() bool

func (Points) SetColor

func (pt Points) SetColor(c color.RGBA)

func (Points) SetName

func (pt Points) SetName(n string)

type Position

type Position int
const (
	TopRight Position = iota
	TopLeft
	BottomRight
	BottomLeft
)

type XYer

type XYer interface {
	Len() int
	BinWidth() float32
	XY(i int) (x, y float32)
	XYErr(i int) (x, y, yerr float32)
	DataRange() (xmin, ymin, xmax, ymax float32)
	Lock()
	Unlock()
}

Jump to

Keyboard shortcuts

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