diff --git a/examples/bpc_sliced.omp b/examples/bpc_sliced.omp new file mode 100644 index 0000000..5aa3583 --- /dev/null +++ b/examples/bpc_sliced.omp @@ -0,0 +1,172 @@ +( + setf *om-current-persistent* + ( + om-load-patch1 "Patch 2" + ( + quote + ( + ( + let + ( + ( + box + ( + om-load-editor-box1 "BPC" + ( + quote bpc + ) + ( + quote + ( + ( + om-load-inputfun + ( + quote input-funbox + ) + "object" "self" nil + ) + ( + om-load-inputfun + ( + quote input-funbox + ) + "X coordinates (list)" "x-points" + ( + list 0 100 + ) + ) + ( + om-load-inputfun + ( + quote input-funbox + ) + "Y coordinates (list)" "y-points" + ( + list 0 100 + ) + ) + ( + om-load-inputfun + ( + quote input-funbox + ) + "precision + ( + integer + ) [0 - 10]" "decimals" 0 + ) + ) + ) + ( + om-make-point 151 96 + ) + ( + om-make-point 40 60 + ) + ( + let + ( + ( + newobj + ( + when + ( + find-class + ( + quote bpc + ) + nil + ) + ( + let + ( + ( + newbpf + ( + simple-bpf-from-list + ( + quote + ( + -1 99 70 + ) + ) + ( + quote + ( + 0 100 65 + ) + ) + ( + quote bpc + ) + 0 + ) + ) + ) + ( + setf + ( + bpfcolor newbpf + ) + ( + om-make-color 0 0 0 + ) + ) + ( + set-name newbpf "BPC" + ) + newbpf + ) + ) + ) + ) + ( + when newobj + ) + newobj + ) + "x" nil + ( + pairlis + ( + quote + ( + picture winpos winsize + ) + ) + ( + list nil + ( + om-make-point 0 0 + ) + ( + om-make-point 1900 1006 + ) + ) + ) + nil nil nil nil + ) + ) + ) + ( + when + ( + fboundp + ( + quote set-active + ) + ) + ( + set-active box nil + ) + ) + box + ) + ) + ) + ( + quote nil + ) + nil 6.19 + ) +) diff --git a/pkg/types/omp/bpc.go b/pkg/types/omp/bpc.go index 39a8cbd..a363567 100644 --- a/pkg/types/omp/bpc.go +++ b/pkg/types/omp/bpc.go @@ -6,4 +6,6 @@ type BPC struct { func (s BPC) Init() { -} \ No newline at end of file +} + +// InitPatch() diff --git a/pkg/types/omp/header.go b/pkg/types/omp/header.go index 00b08e4..4f4adc5 100644 --- a/pkg/types/omp/header.go +++ b/pkg/types/omp/header.go @@ -4,6 +4,8 @@ type Header struct { Data []byte } + +//TODO: It must be create dynamically for different kinds of entities (patch, maquette, etc) func (h *Header) Init() { h.Data = []byte(`; OM File Header - Saved 2022/12/29 14:43:16 ; (6.19 :patc (om-make-point 10 10) (om-make-point 50 50) (om-make-point 500 400) "" 183 0 "2022/12/29 14:43:16" "2022/12/29 14:43:16") diff --git a/pkg/types/omp/omp.go b/pkg/types/omp/omp.go index 1c176a6..0bbd093 100644 --- a/pkg/types/omp/omp.go +++ b/pkg/types/omp/omp.go @@ -1,6 +1,9 @@ package omp -import "bytes" +import ( + "bytes" + "fmt" +) type OMP struct { Header Header @@ -12,12 +15,14 @@ func (s OMP) Build() []byte { buff.Write(s.Header.GetData()) buff.Write(s.Data.GetIntro()) buff.Write(s.Data.GetLibFor()) + buff.Write(s.Data.GetOMCurrentPersistent()) return buff.Bytes() } type Data struct { Intro []byte LibFor []byte + CurrentPersistent []byte } func (s *Data) GetIntro() []byte { @@ -35,3 +40,11 @@ func (s *Data) GetLibFor() []byte { func (s *Data) SetLibFor() { s.LibFor = []byte("(load-lib-for (quote nil))") } + +func (s *Data) SetOMCurrentPersistent(kind string, name string) { + s.CurrentPersistent = []byte(fmt.Sprintf("(setf *om-current-persistent* (%s \"%s\" (quote nil) (quote nil) nil 6.19))", kind, name)) +} + +func (s *Data) GetOMCurrentPersistent() []byte{ + return s.CurrentPersistent +} diff --git a/pkg/types/omp/omp_test.go b/pkg/types/omp/omp_test.go index 9453daf..4caf384 100644 --- a/pkg/types/omp/omp_test.go +++ b/pkg/types/omp/omp_test.go @@ -8,12 +8,13 @@ import ( const ompExample = `; OM File Header - Saved 2022/12/29 14:43:16 ; (6.19 :patc (om-make-point 10 10) (om-make-point 50 50) (om-make-point 500 400) "" 183 0 "2022/12/29 14:43:16" "2022/12/29 14:43:16") ; End File Header -(in-package :om)(load-lib-for (quote nil))` +(in-package :om)(load-lib-for (quote nil))(setf *om-current-persistent* (om-load-patch1 "Test Patch" (quote nil) (quote nil) nil 6.19))` func TestOmpBuilder(t *testing.T) { header := &omp.OMP{} header.Data.SetIntro() header.Data.SetLibFor() + header.Data.SetOMCurrentPersistent("om-load-patch1", "Test Patch") header.Header.Init() str := string(header.Build()) if str != ompExample {