123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312 |
- ////////////////////////////////////////////////////////////////////////////
- // 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);
- }
- }
|