-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
108 lines (90 loc) · 3.13 KB
/
main.go
File metadata and controls
108 lines (90 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//go:generate fyne bundle -o data.go Icon.png
// Package main implements a drawing application that converts drawings to matrices
// The application supports both standard CSV format and MATLAB compatible format
// for saving the drawn patterns and their corresponding labels.
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
"strconv"
)
// Options stores the global application settings
var Options struct {
FlatMatrix bool // Whether to flatten the matrix when saving
MatlabSaveFormat bool // Whether to save in MATLAB compatible format
DotMFileWithVariable bool // Whether to save array in variable for matlab in .m file
MatrixCol int // Number of columns in the output matrix
MatrixRow int // Number of rows in the output matrix
SettingsSaved bool // Whether settings have been Saved and locked
OneHotEncodingSave bool // Whether to save target to one-hot-encoding format
}
var (
mainApp = app.New()
Application struct {
mainWindow fyne.Window
paintWindow fyne.Window
paintObject *PaintWidget
}
)
// main initializes and runs the Draw2Matrix application
func main() {
// Initialize application and main window
window := mainApp.NewWindow("Draw2Matrix")
Application.mainWindow = window
mainApp.Settings().SetTheme(theme.LightTheme())
// Initialize default application options
Options.FlatMatrix = false // Default to flat matrix output
Options.MatlabSaveFormat = false // Default to MATLAB format
Options.MatrixRow = 20
Options.MatrixCol = 20
// Initialize UI components
paint := NewPaintWidget()
paintWindow := NewPaintWindow(mainApp, paint)
Application.paintWindow = paintWindow
Application.paintObject = paint
refreshBtn.Importance = widget.HighImportance
savePath.SetPlaceHolder("Directory path For save file")
dataFileEntry.SetPlaceHolder("Data file name")
dataFileEntry.SetText("data")
targetFileEntry.SetPlaceHolder("Target file name")
targetFileEntry.SetText("target")
targetFileEntry.Disable()
input.SetPlaceHolder("Enter Label")
input.Validator = labelValidator
exportBtn.Importance = widget.MediumImportance
matlabSaveCheck.Checked = false
flatMatrixCheck.Checked = false
dotMFileWithVariableCheck.Disable()
rowInput.SetPlaceHolder("Rows")
rowInput.SetText(strconv.Itoa(Options.MatrixRow))
rowInput.Validator = rowValidator
colInput.SetPlaceHolder("Columns")
colInput.SetText(strconv.Itoa(Options.MatrixCol))
colInput.Validator = colValidator
counterLabel.SetText("0")
addBtn.Importance = widget.MediumImportance
addAndClearPaintBtn.Importance = widget.DangerImportance
// Main content with padding
content := container.NewBorder(
nil,
container.NewPadded(bottomContainer),
nil,
nil,
nil,
)
// Set window content and size
window.SetContent(content)
window.SetMaster()
window.Resize(fyne.NewSize(800, 500))
window.CenterOnScreen()
// Configure application lifecycle handlers
// OnStarted: Initialize matrix display
mainApp.Lifecycle().SetOnStarted(onStartedApplication)
// Start the application
window.Show()
paintWindow.Show()
mainApp.Run()
}