diff options
| -rw-r--r-- | compressor/compressor.go | 41 | ||||
| -rw-r--r-- | compressor/res/borgwarner/k/03.jpg | bin | 0 -> 185706 bytes | |||
| -rw-r--r-- | compressor/res/garrett/g/25-660.jpg (renamed from compressor/res/GarrettG25660.jpg) | bin | 833764 -> 833764 bytes | |||
| -rw-r--r-- | main.go | 21 | ||||
| -rw-r--r-- | ui.go | 29 |
5 files changed, 84 insertions, 7 deletions
diff --git a/compressor/compressor.go b/compressor/compressor.go index a3ac4bf..940d6fa 100644 --- a/compressor/compressor.go +++ b/compressor/compressor.go @@ -8,6 +8,7 @@ import ( ) type Compressor struct { + Name string FileName string // MinX is the distance of the y-axis from left of image in pixels. MinX int @@ -26,7 +27,23 @@ type Compressor struct { MaxPressureRatio float32 } -func GarrettG25660() Compressor { +var compressors = make(map[string]map[string]map[string]Compressor) + +func init() { + compressors["Garrett"] = make(map[string]map[string]Compressor) + compressors["Garrett"]["G"] = make(map[string]Compressor) + compressors["Garrett"]["G"]["25-660"] = garrettG25660() + + compressors["BorgWarner"] = make(map[string]map[string]Compressor) + compressors["BorgWarner"]["K"] = make(map[string]Compressor) + compressors["BorgWarner"]["K"]["03"] = borgwarnerK03() +} + +func Compressors() map[string]map[string]map[string]Compressor { + return compressors +} + +func garrettG25660() Compressor { maxFlow, err := mass.NewFlowRate( mass.Mass{70, mass.Pound}, time.Minute, @@ -34,7 +51,8 @@ func GarrettG25660() Compressor { ) util.Check(err) return Compressor{ - "compressor/res/GarrettG25660.jpg", + "Garrett G25-660", + "compressor/res/garrett/g/25-660.jpg", 204, 1885, 1665, @@ -43,3 +61,22 @@ func GarrettG25660() Compressor { 4.0, } } + +func borgwarnerK03() Compressor { + maxFlow, err := mass.NewFlowRate( + mass.Mass{0.13, mass.Kilogram}, + time.Second, + mass.KilogramsPerSecond, + ) + util.Check(err) + return Compressor{ + "BorgWarner K03", + "compressor/res/borgwarner/k/03.jpg", + 30, + 714, + 876, + 4, + maxFlow, + 2.8, + } +} diff --git a/compressor/res/borgwarner/k/03.jpg b/compressor/res/borgwarner/k/03.jpg Binary files differnew file mode 100644 index 0000000..3464331 --- /dev/null +++ b/compressor/res/borgwarner/k/03.jpg diff --git a/compressor/res/GarrettG25660.jpg b/compressor/res/garrett/g/25-660.jpg Binary files differindex aa8d12a..aa8d12a 100644 --- a/compressor/res/GarrettG25660.jpg +++ b/compressor/res/garrett/g/25-660.jpg @@ -1,6 +1,7 @@ package main import ( + "fmt" g "github.com/AllenDang/giu" "image" "image/draw" @@ -103,6 +104,7 @@ func loop() { Columns( columns()..., ), + selectCompressor(), g.Custom(compressorWidget), ) } @@ -113,10 +115,8 @@ var ( selectedCompressor compressor.Compressor ) -func init() { - selectedCompressor = compressor.GarrettG25660() - - f, err := os.Open(selectedCompressor.FileName) +func setCompressor(c compressor.Compressor) { + f, err := os.Open(c.FileName) util.Check(err) defer f.Close() @@ -127,7 +127,20 @@ func init() { m := image.NewRGBA(image.Rect(0, 0, b.Dx(), b.Dy())) draw.Draw(m, m.Bounds(), j, b.Min, draw.Src) + selectedCompressor = c compressorImage = m + + go updateCompImg() +} + +func init() { + c, ok := compressor.Compressors()["Garrett"]["G"]["25-660"] + if !ok { + fmt.Println("Garrett G25-660 not in compressor.Compressors().") + os.Exit(1) + } + + setCompressor(c) } func main() { @@ -8,6 +8,7 @@ import ( "image/draw" "strconv" + "github.com/sam-anthony/volute/compressor" "github.com/sam-anthony/volute/mass" "github.com/sam-anthony/volute/pressure" "github.com/sam-anthony/volute/temperature" @@ -272,6 +273,32 @@ func columns() []*g.TableColumnWidget { return widgets } +var compressorTree []g.Widget + +func init() { + compressors := compressor.Compressors() + for manufacturer := range compressors { + manufacturerNode := g.TreeNode(manufacturer) + for series := range compressors[manufacturer] { + seriesNode := g.TreeNode(series) + for model, c := range compressors[manufacturer][series] { + seriesNode = seriesNode.Layout( + g.Selectable(model).OnClick(func() { + go setCompressor(c) + }), + ) + } + manufacturerNode = manufacturerNode.Layout(seriesNode) + } + compressorTree = append(compressorTree, manufacturerNode) + } +} + +func selectCompressor() g.Widget { + return g.ComboCustom("Compressor", selectedCompressor.Name). + Layout(compressorTree...) +} + var updatedCompImg = make(chan image.Image) func updateCompImg() { @@ -321,7 +348,7 @@ func compressorWidget() { winWidth, winHeight := g.GetAvailableRegion() canvas.AddImage( compressorTexture, - image.Pt(0, 225), + image.Pt(0, 250), image.Pt(int(winWidth), int(winHeight)), ) } |