//////////////////////////////////////////////////////////////////////////// // System Pre-define Functions // 95099372-ef3e-11ea-9c81-bf848405c62e //Callback of data preparation stage before UI is fully loaded. function OnInitializeData(reload, preview) { PUI(()=>{ //you can access the 'ui' namespace in the parent form using the variable 'pui' here. //The 'pui' variable is valid in all functions of this document. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable. }); } //Callback after UI is fully loaded and displayed. function OnReady(reload, preview) { PUI(()=>{ //you can access the 'ui' namespace in the parent form using the variable 'pui' here. //The 'pui' variable is valid in all functions of this document. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable. }); } function OnCloseForm() { } function OnException(err) { //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok); } ////////////////////////////////////////////////////////////////////////// // Callback Functions. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7 function OnBrep(){ unit.form.mainfrm.OnSend('generateBreps'); } function OnFixed(){ unit.form.mainfrm.OnSend('constrainAdd'); } function OnArrow(){ unit.form.mainfrm.OnSend('arrowAdd'); } function OnFacePick(){ unit.form.mainfrm.OnSend('facePickup'); } function OnPick(){ unit.form.mainfrm.OnSend('solidPickup'); } function OnPostContentMenu(){ switch (ui.pb_post.content_menu) { case 1: unit.form.colorMap.Show(); break; } } function OnPost(){ ui.pb_post.content_menu = [{ name: "颜色映射表", icon: "图标", id: 1 }]; } var isShow = true; function OnShow(){ isShow = !isShow; unit.form.mainfrm.OnWindowVisible(isShow); } function OnImport(){ unit.form.tree.OnChangeMenu(4); } function OnFileContentMenu() { //打开文件 switch (ui.pb_file.content_menu) { case 11: unit.form.workArea.Show(); break; case 12: unit.form.Project.Show(); break; case 13: unit.form.WorkCondition.Show(); break; case 2: var fname = ui.OpenFolderDialog("Open WorkArea", unit.dir); unit.form.tree.OpenWorkArea(fname); break; case 3: unit.form.tree.SaveWorkArea(); break; case 61: unit.form.tree.OnChangeMenu(4); unit.form.tree.OnTopMenu(1); break; case 62: unit.form.tree.OnChangeMenu(4); unit.form.tree.OnTopMenu(2); break; case 63: unit.form.tree.OnChangeMenu(4); unit.form.tree.OnTopMenu(3); break; case 64: unit.form.tree.OnChangeMenu(4); unit.form.tree.OnTopMenu(4); break; case 65: unit.form.tree.OnChangeMenu(4); unit.form.tree.OnTopMenu(5); break; } } function OnFile() { ui.pb_file.content_menu = [{ name: "New", icon: "bar01", id: 1, children: [{ name: "WorkArea", icon: "import01", id: 11 }, { name: "Project", icon: "import02", id: 12 }, { name: "WorkCondition", icon: "import02", id: 13 }] }, { name: "Open", icon: "bar02", id: 2 }, { name: "Save", icon: "bar03", id: 3 }, { name: "Save As", icon: "bar03", id: 4 }, { name: "-" }, { name: "Subscribe", id: 5 }, { name: "-" }, { name: "Import", icon: "bar04", id: 6, children: [{ name: "Model", icon: "import01", id: 61 }, { name: "Solver Deck", icon: "import02", id: 62 }, { name: "Geometry", icon: "import03", id: 63 }, { name: "BOM", icon: "import04", id: 64 }, { name: "Connectors", icon: "import05", id: 65 }] }, { name: "Load", icon: "bar07", id: 7, children:[{ name: "Results", icon: "bar07", id: 71 }, { name: "User Profile", icon: "bar06", id: 72 }, { name: "Solver Template", id: 73 }] }, { name: "Run", icon: "Formability1", id: 8, children: [{ name: "Tcl/Tk Script", id: 81 }, { name: "Command File", id: 82 }] }, { name: "-" }, { name: "Export", icon: "bar05", id: 9, children: [{ name: "Model", id: 91 }, { name: "Solver Deck", id: 92 }, { name: "Geometry", id: 93 }, { name: "BOM", id: 94 }, { name: "Connectors", id: 95 }] }, { name: "Recent Files", id: 10 }, { name: "Recent Import", id: 11 }, { name:"-" }, { name: "Exit", id: 12 }]; } function OnTransform(idx){ unit.form.mainfrm.OnTransform(idx); } function OnPosition(index){ var id = parent.setTimeout(() => { unit.form.mainfrm.OnSend('0'); }, 100); unit.form.mainfrm.OnSend('reset'); unit.form.mainfrm.On3DPosition(index); } function OnUser(){ unit.form.user.Show(); } //The message corresponding callback executed by the docker pane. // when calling [side_pane].fireEvent(type,para) in the main form. function OnParentDockerMessage(type, para) { } ////////////////////////////////////////////////////////////////////////// // Utils Functions. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe function onDragFile(filepath) { } function PUI(cb) { if(pui){cb();} } /*Usage of BLOCK_EVENT BLOCK_EVENT(()=>{ ui.[name].[var] = ...; }); */ function BLOCK_EVENT(cb) { ui.block_event = true; cb(); ui.block_event = false; } ////////////////////////////////////////////////////////////////////////// // template codes for cw callback js. function CW_DeclareVariable(name, setter, getter) { if(typeof(__DeclareVariable) === 'function') { __DeclareVariable(name, setter, getter); } } function CW_DeclareOuterVariable(name) { if(typeof(__DeclareOuterVariable) === 'function') { __DeclareOuterVariable(name); } }