Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ackley_mc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Torda, Prof. Dr. Andrew Ernest
ackley_mc
Commits
2b409335
Commit
2b409335
authored
3 years ago
by
Andrew E. Torda
Browse files
Options
Downloads
Patches
Plain Diff
Rudiments of file saving. Added build tag to turn off graphics, no_gfx.
parent
d6e384eb
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
mc_work/ToDo
+3
-2
3 additions, 2 deletions
mc_work/ToDo
ui/scrnplt.go
+81
-5
81 additions, 5 deletions
ui/scrnplt.go
ui/scrnplt_nogfx.go
+9
-0
9 additions, 0 deletions
ui/scrnplt_nogfx.go
with
93 additions
and
7 deletions
mc_work/ToDo
+
3
−
2
View file @
2b409335
For debugging without graphics,
dlv test --build-flags "-tags=no_gfx"
In dorun.go
In dorun.go
* do we have the random number seed as a settable parameter ?
* do we have the random number seed as a settable parameter ?
* make the csv files optional
* make the csv files optional
* Change the tests so all files are written to a temporary directory
Note.. Benchmarking suggests that most of the time is spent in Ackley function, and, to be exact, in the cosine and exp() function.
Note.. Benchmarking suggests that most of the time is spent in Ackley function, and, to be exact, in the cosine and exp() function.
In the plottin functions,
In the plottin functions,
...
...
This diff is collapsed.
Click to expand it.
ui/scrnplt.go
+
81
−
5
View file @
2b409335
// 25 Jan 2020
// 25 Jan 2020
// Given a buffer or two with a plot picture, send it to the screen
// Given a buffer or two with a plot picture, send it to the screen
// I think this might be better in its own package
// +build !no_gfx
package
ui
package
ui
import
(
import
(
"bytes"
"bytes"
"fmt"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/container"
// "fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/storage"
"fyne.io/fyne/v2/widget"
)
)
func
coffee
()
{
print
(
"coffee
\n
"
)
}
func
tea
()
{
print
(
"tea
\n
"
)
}
func
trydsave
(
uriwc
fyne
.
URIWriteCloser
,
err
error
)
{
uriwc
.
Write
([]
byte
(
"hello from trydsave
\n
"
))
fmt
.
Printf
(
"trydsave called with %+v %+v"
,
uriwc
,
err
)
}
func
dsave
(
parent
fyne
.
Window
)
{
filter
:=
storage
.
NewExtensionFileFilter
([]
string
{
"csv"
,
"abc"
})
t
:=
dialog
.
NewFileSave
(
trydsave
,
parent
)
t
.
SetFileName
(
"f_val.csv"
)
t
.
SetFilter
(
filter
)
t
.
Show
()
fmt
.
Println
(
"dsave called and returning"
)
}
func
stopme
()
{
print
(
"stopme
\n
"
)
}
type
fssavefunc
func
(
fyne
.
URIReadCloser
,
error
)
func
topmenu
(
parent
fyne
.
Window
)
*
fyne
.
Menu
{
ds
:=
func
()
{
dsave
(
parent
)
}
a
:=
fyne
.
NewMenuItem
(
"coffee"
,
coffee
)
b
:=
fyne
.
NewMenuItem
(
"tea"
,
tea
)
c
:=
fyne
.
NewMenuItem
(
"save func plot"
,
ds
)
d
:=
fyne
.
NewMenuItem
(
"frueh feierabend"
,
stopme
)
return
fyne
.
NewMenu
(
"a simple menu"
,
a
,
b
,
c
,
d
)
}
func
fileSaved
(
f
fyne
.
URIWriteCloser
,
w
fyne
.
Window
)
{
defer
f
.
Close
()
_
,
err
:=
f
.
Write
([]
byte
(
"Written by Fyne demo
\n
"
))
if
err
!=
nil
{
dialog
.
ShowError
(
err
,
w
)
}
err
=
f
.
Close
()
if
err
!=
nil
{
dialog
.
ShowError
(
err
,
w
)
}
fmt
.
Println
(
"Saved to..."
,
f
.
URI
())
}
func
nothing
(
...
interface
{})
{}
// buf2file takes an array of bytes and writes them to a file.
func
buf2file
(
buf
[]
byte
)
{
var
z
fyne
.
URIWriteCloser
// NewFileSave(callback func(fyne.URIWriteCloser, error), parent fyne.Window) *FileDialog
var
win
fyne
.
Window
fs
:=
widget
.
NewButton
(
"File Save"
,
func
()
{
dialog
.
ShowFileSave
(
func
(
writer
fyne
.
URIWriteCloser
,
err
error
)
{
if
err
!=
nil
{
dialog
.
ShowError
(
err
,
win
)
return
}
if
writer
==
nil
{
fmt
.
Println
(
"Cancelled"
)
return
}
fileSaved
(
writer
,
win
)
},
win
)
})
nothing
(
fs
,
z
)
}
func
breaker
(
...
interface
{})
{}
func
breaker
(
...
interface
{})
{}
func
Scrnplt
(
fdata
[]
byte
,
xdata
[]
byte
)
{
func
Scrnplt
(
fdata
[]
byte
,
xdata
[]
byte
)
{
a
:=
app
.
NewWithID
(
"ackley"
)
// Find a way to check if it is happy
a
:=
app
.
NewWithID
(
"ackley"
)
// Find a way to check if it is happy
w
:=
a
.
NewWindow
(
"container"
)
w
:=
a
.
NewWindow
(
"container"
)
w
.
SetMainMenu
(
fyne
.
NewMainMenu
(
topmenu
(
w
)))
fImage
:=
canvas
.
NewImageFromReader
(
bytes
.
NewReader
(
fdata
),
"func.png"
)
fImage
:=
canvas
.
NewImageFromReader
(
bytes
.
NewReader
(
fdata
),
"func.png"
)
fImage
.
FillMode
=
canvas
.
ImageFillContain
fImage
.
FillMode
=
canvas
.
ImageFillContain
xImage
:=
canvas
.
NewImageFromReader
(
bytes
.
NewReader
(
xdata
),
"xdata.png"
)
xImage
:=
canvas
.
NewImageFromReader
(
bytes
.
NewReader
(
xdata
),
"xdata.png"
)
xImage
.
FillMode
=
canvas
.
ImageFillContain
xImage
.
FillMode
=
canvas
.
ImageFillContain
// content := container.NewVSplit(fImage, xImage) works well
content
:=
container
.
NewGridWithRows
(
2
,
fImage
,
xImage
)
content
:=
container
.
NewGridWithRows
(
2
,
fImage
,
xImage
)
w
.
Resize
(
fyne
.
NewSize
(
500
,
3
2
0
))
w
.
Resize
(
fyne
.
NewSize
(
500
,
3
0
0
))
w
.
SetContent
(
content
)
w
.
SetContent
(
content
)
w
.
ShowAndRun
()
w
.
ShowAndRun
()
}
}
This diff is collapsed.
Click to expand it.
ui/scrnplt_nogfx.go
0 → 100644
+
9
−
0
View file @
2b409335
// +build no_gfx
//
// If we do not have graphics
package
ui
func
Scrnplt
(
fdata
[]
byte
,
xdata
[]
byte
)
{
print
(
"No graphics"
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment