123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- ////////////////////////////////////////////////////////////////////////////
- // 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.
-
- });
- force_fixed(true);
- ui.pb_addPoint.enable = false;
- }
- //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 = [];
- var myArray = [];
- //////////////////////////////////////////////////////////////////////////
- // Callback Functions.
- // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
- function OnAddPoint(){
- ui.pb_point.value = parseInt(ui.pb_point.value) + 1;
- var str = myStressArray[parseInt(ui.listbox.index)].split(',');
- if(ui.pb_judge.value === '1'){
-
- var id = parent.setTimeout(() => {
- unit.form.mainfrm.OnSend('0');
- }, 100);
- unit.form.mainfrm.OnSend('arrowBeam ' + ui.pb_force_xd.value + ' ' + (parseFloat(ui.pb_force_xd.value)) + ' ' + ui.pb_force_yd.value + ' ' + ui.pb_force_zd.value);
-
- var value = ui.pb_point.value + ',' + '*' + ',' + parseFloat(ui.pb_force_id.value) + ',' + parseFloat(ui.pb_force_xd.value) + ',' + parseFloat(ui.pb_force_yd.value) + ',' + parseFloat(ui.pb_force_zd.value) + ',' + parseFloat(ui.pb_force_xr.value) + ',' + parseFloat(ui.pb_force_yr.value) + ',' + parseFloat(ui.pb_force_zr.value) + ',' + str[0];
- }
- if(ui.pb_judge.value === '0'){
-
- var id = parent.setTimeout(() => {
- unit.form.mainfrm.OnSend('0');
- }, 100);
- unit.form.mainfrm.OnSend('fixBeam 1');
-
- var value = ui.pb_point.value + ',' + '#' + ',' + parseFloat(ui.pb_fix_id.value) + ',' + parseFloat(ui.pb_fix_xd.value) + ',' + parseFloat(ui.pb_fix_yd.value) + ',' + parseFloat(ui.pb_fix_zd.value) + ',' + parseFloat(ui.pb_fix_xr.value) + ',' + parseFloat(ui.pb_fix_yr.value) + ',' + parseFloat(ui.pb_fix_zr.value) + ',' + str[0];
- }
- myArray.push(value);
- ui.pointbox.list = [
- myArray
- ];
-
- ui.pb_addPoint.enable = false;
- }
- function OnForce(){
- force_fixed(true);
- ui.pb_addPoint.enable = true;
- }
- function force_fixed(idx){
- if(idx){
- ui.pb_judge.value = 1;
- }else{
- ui.pb_judge.value = 0;
- }
-
- ui.pb_force.valid = idx;
- ui.pb_force_id.enable = idx;
- ui.pb_force_xd.enable = idx;
- ui.pb_force_yd.enable = idx;
- ui.pb_force_zd.enable = idx;
- ui.pb_force_xr.enable = idx;
- ui.pb_force_yr.enable = idx;
- ui.pb_force_zr.enable = idx;
-
- ui.pb_fix.valid = !idx;
- ui.pb_fix_id.enable = !idx;
- ui.pb_fix_xd.enable = !idx;
- ui.pb_fix_yd.enable = !idx;
- ui.pb_fix_zd.enable = !idx;
- ui.pb_fix_xr.enable = !idx;
- ui.pb_fix_yr.enable = !idx;
- ui.pb_fix_zr.enable = !idx;
- }
- function OnFixed(){
- force_fixed(false);
- ui.pb_addPoint.enable = true;
- }
- function OnShowPoint(){
- 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('showPoint ' + (parseInt(str1[0]) - 1) + ' 1 0 0 1');
- }
- function OnLineGenerate(){
- ui.pb_add.enable = true;
- var id = parent.setTimeout(() => {
- unit.form.mainfrm.OnSend('0');
- }, 100);
- unit.form.mainfrm.OnSend('beamMesh ' + ui.pb_size.value + ' ' + ui.pb_length.value + ' ' + ui.pb_xDiration.value + ' ' + ui.pb_yDiration.value + ' ' + ui.pb_zDiration.value + ' ' + ui.pb_xCoord.value + ' ' + ui.pb_yCoord.value + ' ' + ui.pb_zCoord.value);
- }
- var pick = false;
- function OnPickUp() {
- pick = !pick;
- if (pick === true) {
- var id = parent.setTimeout(() => {
- unit.form.mainfrm.OnSend('0');
- }, 100);
- unit.form.mainfrm.OnSend('arrowOpen');
- ui.pb_pick.valid = true;
- }
- if (pick === false) {
- var id = parent.setTimeout(() => {
- unit.form.mainfrm.OnSend('0');
- }, 100);
- unit.form.mainfrm.OnSend('arrowClose');
- ui.pb_pick.valid = false;
- }
- }
- function OnReturnMenu(){
- unit.form.mainfrm.menu(5);
- }
- function OnYes() {
- ui.pb_pass.enable = true;
- var str = myStressArray[parseFloat(ui.listbox.index)];
- var str1 = str.split(',');
- var str2 = str1[0];
- str1 = str1.join(' ');
- model.write(str1, model.getCurrentDirectory() + '/data/restraint/restrant' + str2 + '.txt');
- }
- 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('closeBeam ' + (parseInt(str1[0]) - 1) + ' 0 1 0 0' );
- myStressArray.splice(parseFloat(ui.listbox.index), 1);
- ui.listbox.list = [
- myStressArray
- ];
- unit.form.mainfrm.OnDeleteBeam(parseFloat(ui.listbox.index));
- }
- function OnAddFixFace() {
- unit.form.mainfrm.OnChangeWindows(2);
- var id = parent.setTimeout(() => {
- unit.form.mainfrm.OnSend('0');
- }, 100);
- var id = parent.setTimeout(() => {
- if(ui.message.value === 'add line'){
- ui.pb_ID.value = parseInt(ui.pb_ID.value) + 1;
-
- var value = ui.pb_ID.value + ',' + parseFloat(ui.pb_xDiration.value) + ',' + parseFloat(ui.pb_yDiration.value) + ',' + parseFloat(ui.pb_zDiration.value) + ',' + parseFloat(ui.pb_xCoord.value) + ',' + parseFloat(ui.pb_yCoord.value) + ',' + parseFloat(ui.pb_zCoord.value) + ',' + parseFloat(ui.pb_zhijing.value)+ ',' + parseFloat(ui.pb_length.value) + ',' + parseFloat(ui.pb_size.value) + ',' + parseFloat(ui.pb_m.value) + ',' + parseFloat(ui.pb_poi.value);
- myStressArray.push(value);
- ui.listbox.list = [
- myStressArray
- ];
-
- ui.pb_add.enable = false;
- unit.form.mainfrm.OnGetBeam(ui.pb_ID.value);
- }
- }, 110);
- unit.form.mainfrm.OnSend('showBeam');
-
- /*
- ui.pb_ID.value = parseInt(ui.pb_ID.value) + 1;
-
- var value = ui.pb_ID.value + ',' + parseFloat(ui.pb_xDiration.value) + ',' + parseFloat(ui.pb_yDiration.value) + ',' + parseFloat(ui.pb_zDiration.value) + ',' + parseFloat(ui.pb_xCoord.value) + ',' + parseFloat(ui.pb_yCoord.value) + ',' + parseFloat(ui.pb_zCoord.value) + ',' + parseFloat(ui.pb_zhijing.value)+ ',' + parseFloat(ui.pb_length.value) + ',' + parseFloat(ui.pb_size.value) + ',' + parseFloat(ui.pb_m.value) + ',' + parseFloat(ui.pb_poi.value);
- myStressArray.push(value);
- ui.listbox.list = [
- myStressArray
- ];
-
- ui.pb_add.enable = false;*/
- }
- function OnLoad(){
- var value = '';
- for (var i = 0; i < myStressArray.length; i++) {
- var str = myStressArray[i].split(',');
- value += '* ' + str[7] + ' ' + str[8] + ' ' + str[9] + '\n'
- + '# ' + str[10] + ' ' + str[11] + '\n'
- + '$ ' + str[1] + ' ' + str[2] + ' ' + str[3] + ' ' + str[4] + ' ' + str[5] + ' ' + str[6] + '\n';
- }
- model.write(value, model.getCurrentDirectory() + '/data/beam/beam.txt');
-
- var value1 = '';
- var value2 = '';
- for (var i = 0; i < myArray.length; i++) {
- var str = myArray[i].split(',');
- if(str[1] === '*'){
- value1 += '* ' + str[2] + ' ' + str[3] + ' ' + str[4] + ' ' + str[5] + ' ' + str[6] + ' ' + str[7] + ' ' + str[8] + ' ' + str[9] + '\n';
- }
- if(str[1] === '#'){
- value2 += '* ' + str[2] + ' ' + str[3] + ' ' + str[4] + ' ' + str[5] + ' ' + str[6] + ' ' + str[7] + ' ' + str[8] + ' ' + str[9] + '\n';
- }
- }
- model.write(value1, model.getCurrentDirectory() + '/data/beam/beam_force.txt');
- model.write(value2, model.getCurrentDirectory() + '/data/beam/beam_fix.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
- CW_DeclareVariable("ID",
- val => {
- ui.pb_fix_id.value = val;
- ui.pb_force_id.value = val;
- }, () => {});
-
- CW_DeclareVariable("message",
- val => {
- ui.message.value = 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);
- }
- }
|