123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330 |
- ////////////////////////////////////////////////////////////////////////////
- // 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.
-
- });
- controlAuto(true);
- control(true);
- }
- //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);
- }
- var myStressArray = [];
- //////////////////////////////////////////////////////////////////////////
- // Callback Functions.
- // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
- var beamPicker = false;
- function OnBeamPicker(){
- pickPeiDian = !pickPeiDian;
- if (pickPeiDian === true) {
- var id = parent.setTimeout(() => {
- unit.form.mainfrm.OnSend('arrowOpen');
- }, 100);
- var id = parent.setTimeout(() => {
- unit.form.mainfrm.OnSend('0');
- }, 200);
- unit.form.mainfrm.OnSend('peidianPicker 2 ' + model.getCurrentDirectory() + '/data/faceID/pei.txt' + ' ' + (parseInt(ui.pb_BeamID.value) - 1));
- ui.pb_BeamPick.valid = true;
- }
- if (pickPeiDian === false) {
- var id = parent.setTimeout(() => {
- unit.form.mainfrm.OnSend('0');
- }, 100);
- unit.form.mainfrm.OnSend('arrowClose');
- ui.pb_BeamPick.valid = false;
- }
- }
- var pickPeiDian = false;
- function OnPeidianPicker() {
- pickPeiDian = !pickPeiDian;
- if (pickPeiDian === true) {
- var id = parent.setTimeout(() => {
- unit.form.mainfrm.OnSend('arrowOpen');
- }, 100);
- var id = parent.setTimeout(() => {
- unit.form.mainfrm.OnSend('0');
- }, 200);
- unit.form.mainfrm.OnSend('peidianPicker 1 ' + model.getCurrentDirectory() + '/data/faceID/pei.txt' + ' 0');
- ui.pb_peidian.valid = true;
- }
- if (pickPeiDian === false) {
- var id = parent.setTimeout(() => {
- unit.form.mainfrm.OnSend('0');
- }, 100);
- unit.form.mainfrm.OnSend('arrowClose');
- ui.pb_peidian.valid = false;
- }
- }
- function OnHand(){
- controlAuto(false);
- }
- function controlAuto(idx){
- ui.pb_peidian.enable = idx;
- ui.pb_BeamID.enable = idx;
- ui.pb_BeamPick.enable = idx;
- //ui.pb_start.enable = idx;
- //ui.pb_end.enable = idx;
- ui.pb_startID.visible = idx;
- ui.pb_endID.visible = idx;
- ui.pb_Auto.enable = !idx;
- ui.pb_hand.enable = idx;
-
- if(idx === true){
- ui.pb_judge.value = 1;
- model.setJudge(1);
- }
- if(idx === false){
- ui.pb_judge.value = 0;
- model.setJudge(0);
- }
-
- }
- function OnAuto(){
- controlAuto(true);
- }
- function OnDeleteFixFace() {
-
- var str = myStressArray[parseFloat(ui.listbox.index)];
- var str1 = str.split(',');
-
- var id = parent.setTimeout(() => {
- unit.form.mainfrm.OnSend('0');
- }, 100);
- unit.form.mainfrm.OnSend('showSpring ' + (parseInt(str1[0]) - 1) + ' 0 1 0 0' );
-
- myStressArray.splice(parseFloat(ui.listbox.index), 1);
- ui.listbox.list = [
- myStressArray
- ];
- }
- function OnAddFixFace() {
- //unit.form.mainfrm.OnChangeWindows(2);
-
- ui.pb_ID.value = parseInt(ui.pb_ID.value) + 1;
-
- if( ui.pb_judge.value === '0'){
- var value = ui.pb_ID.value + ',*,' + parseFloat(ui.pb_x.value) + ',' + parseFloat(ui.pb_y.value) + ',' + parseFloat(ui.pb_z.value) + ',' + parseFloat(ui.pb_X.value) + ',' + parseFloat(ui.pb_Y.value)+ ',' + parseFloat(ui.pb_Z.value) + ',' + ui.pb_springStiffness.value;
- }
-
- if( ui.pb_judge.value === '1'){
- var value = ui.pb_ID.value + ',' + parseFloat(ui.pb_startID.value) + ',' + parseFloat(ui.pb_x.value) + ',' + parseFloat(ui.pb_y.value) + ',' + parseFloat(ui.pb_z.value) + ',' + parseFloat(ui.pb_endID.value) + ',' + parseFloat(ui.pb_X.value) + ',' + parseFloat(ui.pb_Y.value)+ ',' + parseFloat(ui.pb_Z.value) + ',' + ui.pb_springStiffness.value;
- }
-
- var id = parent.setTimeout(() => {
- unit.form.mainfrm.OnSend('0');
- }, 100);
- unit.form.mainfrm.OnSend('springLine ' + parseFloat(ui.pb_x.value) + ' ' + parseFloat(ui.pb_y.value) + ' ' + parseFloat(ui.pb_z.value) + ' ' + parseFloat(ui.pb_X.value) + ' ' + parseFloat(ui.pb_Y.value) + ' ' + parseFloat(ui.pb_Z.value));
-
- myStressArray.push(value);
- ui.listbox.list = [
- myStressArray
- ];
-
- }
- function control(idx){
- ui.pb_start.enable = !idx;
- ui.pb_startPoint.enable = idx;
- ui.pb_x.enable = idx;
- ui.pb_y.enable = idx;
- ui.pb_z.enable = idx;
-
- ui.pb_end.enable = idx;
- ui.pb_endPoint.enable = !idx;
- ui.pb_X.enable = !idx;
- ui.pb_Y.enable = !idx;
- ui.pb_Z.enable = !idx;
-
- if(idx === true){
- ui.pb_StartEnd.value = 0;
- model.setStartEnd(0);
- }
- if(idx === false){
- ui.pb_StartEnd.value = 1;
- model.setStartEnd(1);
- }
- }
- function OnEed(){
- control(false);
- }
- function OnStart(){
- control(true);
- }
- function OnLoad(){
- /*
- var id = parent.setTimeout(() => {
- unit.form.mainfrm.OnSend('0');
- }, 100);
- unit.form.mainfrm.OnSend('line ' + ui.pb_x.value + ' ' + ui.pb_y.value + ' ' + ui.pb_z.value + ' ' + ui.pb_X.value + ' ' + ui.pb_Y.value + ' ' + ui.pb_Z.value);*/
-
- var value = '';
- for (var i = 0; i < myStressArray.length; i++) {
- var str = myStressArray[i].split(',');
- value += '* ' + str[1] + ' ' + str[5] + '\n' +
- '# ' + str[9] + '\n';
- }
- model.write(value, model.getCurrentDirectory() + '/data/spring/spring.txt');
- }
- //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
- var arrayPoint = [];
- CW_DeclareVariable("message",
- val => {
- //console.log(val + '\n');
- console.log(val[0]);
- var arrayPoint = [];
- arrayPoint = val;
- if(ui.pb_judge.value === 0) {
- //var str = val.split(' ');
- if(ui.pb_StartEnd.value === 0){
- ui.pb_x.value = arrayPoint[0];
- ui.pb_y.value = arrayPoint[1];
- ui.pb_z.value = arrayPoint[2];
- }
- if(ui.pb_StartEnd.value === 1){
- ui.pb_X.value = arrayPoint[0];
- ui.pb_Y.value = arrayPoint[1];
- ui.pb_Z.value = arrayPoint[2];
- }
- }
- if(ui.pb_judge.value === 1) {
- var str = val.split(' ');
- if(ui.pb_StartEnd.value === 0){
- ui.pb_x.value = str[0];
- ui.pb_y.value = str[1];
- ui.pb_z.value = str[2];
- ui.pb_startID.value = str[3];
- }
- if(ui.pb_StartEnd.value === 1){
- ui.pb_X.value = str[0];
- ui.pb_Y.value = str[1];
- ui.pb_Z.value = str[2];
- ui.pb_endID.value = str[3];
- }
- }
- }, () => {});
- CW_DeclareVariable("pb_x",
- val => {
- ui.pb_x.value = val;
- }, () => {});
-
- CW_DeclareVariable("pb_y",
- val => {
- ui.pb_y.value = val;
- }, () => {});
- CW_DeclareVariable("pb_z",
- val => {
- ui.pb_z.value = val;
- }, () => {});
-
- CW_DeclareVariable("pb_startID",
- val => {
- ui.pb_startID.value = val;
- }, () => {});
-
- CW_DeclareVariable("pb_X",
- val => {
- ui.pb_X.value = val;
- }, () => {});
-
- CW_DeclareVariable("pb_Y",
- val => {
- ui.pb_Y.value = val;
- }, () => {});
- CW_DeclareVariable("pb_Z",
- val => {
- ui.pb_Z.value = val;
- }, () => {});
-
- CW_DeclareVariable("pb_endID",
- val => {
- ui.pb_endID.value = val;
- }, () => {});
-
- CW_DeclareVariable("beam",
- val => {
- ui.pb_BeamID.list = val;
- }, () => {});
- 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);
- }
- }
|