From 2a6a686034e8df404e25cc67c902d397c26d33c1 Mon Sep 17 00:00:00 2001 From: Kirill Vasin Date: Fri, 15 Nov 2024 20:02:44 +0100 Subject: [PATCH] added palette --- Kernel/Wizard.wl | 83 ++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 12 +++++++ 2 files changed, 95 insertions(+) diff --git a/Kernel/Wizard.wl b/Kernel/Wizard.wl index 164df91..bd08f7d 100644 --- a/Kernel/Wizard.wl +++ b/Kernel/Wizard.wl @@ -17,6 +17,89 @@ TDSWizard::usage = "TDSWizard" Begin["`Private`"] +toStringHeld[expr_] := StringDrop[StringDrop[ToString[Hold[expr], InputForm], 5],-1] +SetAttributes[toStringHeld, HoldFirst]; + +TDSPalette := CellPrint[toStringHeld @ With[{parent = CurrentWindow["Origin"]}, + { + { + EventHandler[InputButton["TDTrace"], Function[Null, + With[{selected = FrontFetchAsync[FrontEditorSelected["Get"], "Window"->parent]}, + Then[selected, Function[string, + If[TrueQ[StringLength[StringTrim[string]] > 0], + FrontSubmit[FrontEditorSelected["Set", "TDTrace[QuantityArray["<>StringTrim[string]<>", {\"Picoseconds\", 1}]]"], "Window"->parent] + , + FrontSubmit[FrontEditorSelected["Set", "TDTrace[QuantityArray[(*BB[*)( )(*,*)(*\"1:eJxTTMoPSmNkYGAoZgESHvk5KRAeB5AILqnMSXXKr0hjgskHleakFnMBGU6JydnpRfmleSlpzDDlQe5Ozvk5+UVFDGDwwR6dwcAAAAHdFiw=\"*)(*]BB*), {\"Picoseconds\", 1}]]"], "Window"->parent] + ] + ]] + ] + + ]], + Item[" Transform list of tds-data to TDTrace", FontSize->8] + }, + + { + EventHandler[InputButton["TransmissionObject"], Function[Null, + With[{selected = FrontFetchAsync[FrontEditorSelected["Get"], "Window"->parent]}, + Then[selected, Function[string, + If[TrueQ[StringLength[StringTrim[string]] > 0], + FrontSubmit[FrontEditorSelected["Set", "TransmissionObject["<>StringTrim[string]<>", \"Thickness\"->Quantity[(*BB[*)( )(*,*)(*\"1:eJxTTMoPSmNkYGAoZgESHvk5KRAeB5AILqnMSXXKr0hjgskHleakFnMBGU6JydnpRfmleSlpzDDlQe5Ozvk5+UVFDGDwwR6dwcAAAAHdFiw=\"*)(*]BB*), \"Millimeters\"]]"], "Window"->parent] + , + FrontSubmit[FrontEditorSelected["Set", "TransmissionObject[(*BB[*)(sample)(*,*)(*\"1:eJxTTMoPSmNkYGAoZgESHvk5KRAeB5AILqnMSXXKr0hjgskHleakFnMBGU6JydnpRfmleSlpzDDlQe5Ozvk5+UVFDGDwwR6dwcAAAAHdFiw=\"*)(*]BB*), (*BB[*)(reference)(*,*)(*\"1:eJxTTMoPSmNkYGAoZgESHvk5KRAeB5AILqnMSXXKr0hjgskHleakFnMBGU6JydnpRfmleSlpzDDlQe5Ozvk5+UVFDGDwwR6dwcAAAAHdFiw=\"*)(*]BB*), \"Thickness\"->Quantity[(*BB[*)( )(*,*)(*\"1:eJxTTMoPSmNkYGAoZgESHvk5KRAeB5AILqnMSXXKr0hjgskHleakFnMBGU6JydnpRfmleSlpzDDlQe5Ozvk5+UVFDGDwwR6dwcAAAAHdFiw=\"*)(*]BB*), \"Millimeters\"]]"], "Window"->parent] + ] + ]] + ] + ]], + Item[" Calculates transmission based on two TDTraces", FontSize->8] + }, + + { + EventHandler[InputButton["TransmissionUnwrap"], Function[Null, + With[{selected = FrontFetchAsync[FrontEditorSelected["Get"], "Window"->parent]}, + Then[selected, Function[string, + If[TrueQ[StringLength[StringTrim[string]] > 0], + FrontSubmit[FrontEditorSelected["Set", "TransmissionUnwrap["<>StringTrim[string]<>", \"Basic\"]"], "Window"->parent] + , + FrontSubmit[FrontEditorSelected["Set", "TransmissionUnwrap[(*BB[*)( )(*,*)(*\"1:eJxTTMoPSmNkYGAoZgESHvk5KRAeB5AILqnMSXXKr0hjgskHleakFnMBGU6JydnpRfmleSlpzDDlQe5Ozvk5+UVFDGDwwR6dwcAAAAHdFiw=\"*)(*]BB*), \"Basic\"]"], "Window"->parent] + ] + ]] + ] + ]], + Item[" Unwraps phase of transmission", FontSize->8] + }, + + { + EventHandler[InputButton["MaterialParameters"], Function[Null, + With[{selected = FrontFetchAsync[FrontEditorSelected["Get"], "Window"->parent]}, + Then[selected, Function[string, + If[TrueQ[StringLength[StringTrim[string]] > 0], + FrontSubmit[FrontEditorSelected["Set", "MaterialParameters["<>StringTrim[string]<>"]"], "Window"->parent] + , + FrontSubmit[FrontEditorSelected["Set", "MaterialParameters[(*BB[*)( )(*,*)(*\"1:eJxTTMoPSmNkYGAoZgESHvk5KRAeB5AILqnMSXXKr0hjgskHleakFnMBGU6JydnpRfmleSlpzDDlQe5Ozvk5+UVFDGDwwR6dwcAAAAHdFiw=\"*)(*]BB*)]"], "Window"->parent] + ] + ]] + ] + ]], + Item[" Calculates material parameters from transmission", FontSize->8] + }, + + { + EventHandler[InputButton["TDSWizard"], Function[Null, + FrontSubmit[FrontEditorSelected["Set", "TDSWizard[]"], "Window"->parent] + ]], + Item[" Helper widgets", FontSize->8] + } + } // Grid +], "Target"->_]; + +TDSWizard[] := Column[Join[ + {Item["The following options are available:", FontSize->10, Background->LightGreen ]}, + Table[Item["TDSWizard["<>SymbolName[i]<>"][...]", FontSize->10], {i, { + TransmissionObject, + TransmissionUnwrap, + MaterialParameters + }}] +] ] TDSWizard[TransmissionUnwrap][t_TransmissionObject] := TDSWizard[TransmissionUnwrap, Method->Automatic][t] TDSWizard[TransmissionUnwrap][{t__TransmissionObject}] := TDSWizard[TransmissionUnwrap, Method->Automatic][{t}] diff --git a/README.md b/README.md index e280b4b..4c27c9d 100644 --- a/README.md +++ b/README.md @@ -380,7 +380,19 @@ this function will group them by `Phase` arrays (comparison by the internal refe This also takes advantage of non-blocking execution model of OpenCL and loads all data at once. +### Palette +Shows all symbols used in the library (will be shown in a new window) + +```mathematica +TDSPalette[] +``` + ### Time-Domain Wizards + +```mathematica +TDSWizard[] +``` + The general interface is ```mathematica