123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520 |
- ////////////////////////////////////////////////////////////////////////////
- // 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.
-
- });
- control(true);
- controls(true);
- //ui.stack_constraint.index = 1;
-
- //ui.stack_menu.index = 3;
- }
- //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 OnModify(){
- if(ui.limit_constraint.index === 0 && ui.constraint_type.index === 0) {
- let Load = {
- "constraint":"固定支撑",
- "约束类型":ui.constraint_type.value,
- "固定支撑属性xd":ui.con_xn.value,
- "固定支撑属性xr":ui.con_xr.value,
- "固定支撑属性yd":ui.con_yn.value,
- "固定支撑属性yr":ui.con_yr.value,
- "固定支撑属性zd":ui.con_zn.value,
- "固定支撑属性zr":ui.con_zr.value
- };
- unit.form.tree.ModifyConstraint(Load);
- }
- if(ui.limit_constraint.index ===1 && ui.misConstraints.index === 0 ) {
- let Load = {
- "constraint":"梁",
- "非约束类型":ui.misConstraints.value,
- "梁约束位置xDirection":ui.pb_xDiration.value,
- "梁约束位置yDirection":ui.pb_yDiration.value,
- "梁约束位置zDirection":ui.pb_zDiration.value,
- "梁约束位置xCoord":ui.pb_xCoord.value,
- "梁约束位置yCoord":ui.pb_yCoord.value,
- "梁约束位置zCoord":ui.pb_zCoord.value,
- "梁约束参数半径":ui.rad.value,
- "梁约束参数长度":ui.pb_length.value,
- "梁约束参数个数":ui.pb_size.value,
- "弹性模量":ui.m.value,
- "泊松比":ui.poi.value,
- "梁节点大小半径":ui.pb_node_size.value,
- "R":ui.R.value,
- "G":ui.G.value,
- "B":ui.B.value
- };
- unit.form.tree.ModifyConstraint(Load);
- }
- if(ui.limit_constraint.index ===1 && ui.misConstraints.index === 1 ) {
- let Load = {
- "constraint":"弹簧",
- "非约束类型":ui.misConstraints.value,
- "起点x":ui.pb_x.value,
- "起点y":ui.pb_y.value,
- "起点z":ui.pb_z.value,
- "终点x":ui.pb_X.value,
- "终点y":ui.pb_Y.value,
- "终点z":ui.pb_Z.value,
- "弹簧刚度x":ui.stiffness_x.value,
- "弹簧刚度y":ui.stiffness_y.value,
- "弹簧刚度z":ui.stiffness_z.value,
- "R":ui.R.value,
- "G":ui.G.value,
- "B":ui.B.value
- };
- unit.form.tree.ModifyConstraint(Load);
- }
- if(ui.limit_constraint.index ===1 && ui.misConstraints.index === 2 ) {
- let Load = {
- "constraint":"连接",
- "非约束类型":ui.misConstraints.value,
- "起点x":ui.pb_xn.value,
- "起点y":ui.pb_yn.value,
- "起点z":ui.pb_zn.value,
- "终点x":ui.pb_xr.value,
- "终点y":ui.pb_yr.value,
- "终点z":ui.pb_zr.value,
- "R":ui.pb_con_r.value,
- "G":ui.pb_con_g.value,
- "B":ui.pb_con_b.value
- };
- unit.form.tree.ModifyConstraint(Load);
- }
- }
- function OnChangeBeam(){
- if(parseFloat(ui.pb_length.value) <= 0 || parseFloat(ui.rad.value) <= 0 || parseFloat(ui.m.value) <= 0 || parseFloat(ui.poi.value) <= 0 || parseFloat(ui.rad.value) <= 0){
- unit.form.mainfrm.OnChangePicture(3, 3);
- //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: red;font-size:20px;">非常抱歉,您输入的数据不在参数范围内!</h4>');
- unit.form.mainfrm.OnCueline('您输入的数据不在参数范围内!', 'red');
- }else{
- unit.form.mainfrm.OnChangePicture(3, 2);
- //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: Blue;font-size:20px;">恭喜您,您输入了正确的数据!</h4>');
- unit.form.mainfrm.OnCueline('您输入了正确的数据!', 'blue');
- }
- }
- function OnFix(){
- var strss = 'fixHighLight ' + ui.con_xn.value + ' ' + ui.con_yn.value + ' ' + ui.con_zn.value + ' ' + ui.con_xr.value + ' ' + ui.con_yr.value + ' ' + ui.con_zr.value;
- unit.form.mainfrm.OnSend(strss);
- unit.form.mainfrm.OnChangePicture(3 );2;
- //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">恭喜您完成了固定支撑属性的添加,请用鼠标右键选中需要施加约束的物体并按快捷键T或者t进行添加!</h4>');
- let Load = {
- "constraint":"固定支撑",
- "约束类型":ui.constraint_type.value,
- "固定支撑属性xd":ui.con_xn.value,
- "固定支撑属性xr":ui.con_xr.value,
- "固定支撑属性yd":ui.con_yn.value,
- "固定支撑属性yr":ui.con_yr.value,
- "固定支撑属性zd":ui.con_zn.value,
- "固定支撑属性zr":ui.con_zr.value
- };
- unit.form.tree.CreateBoundary(Load);
- unit.form.mainfrm.OnCueline('您完成了固定支撑属性的添加,请用鼠标右键选中需要施加约束的物体并按快捷键T或者t进行添加!', 'green');
- }
- function OnBeam2(){
- unit.form.mainfrm.OnSend('beamHightLight2 ' + ui.m_seg.value + ' ' + ui.m_len.value + ' ' + ui.m_radius.value + ' ' + ui.m_mat.value + ' ' + ui.m_poi.value + ' ' + ui.m_R.value + ' '+ ui.m_G.value + ' ' + ui.m_B.value + ' ' + ui.m_ras.value);
- model.clearStr();
- unit.form.mainfrm.OnChangePicture(3, 2);
- //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">恭喜成功做好了不均匀梁的添加!</h4>');
- unit.form.mainfrm.OnCueline('您成功做好了不均匀梁的添加!', 'green');
- }
- function OnConnect(){
- var str = 'connects ' + ui.pb_start_x.value + ' ' + ui.pb_start_y.value + ' ' + ui.pb_start_z.value + ' ' + ui.pb_end_x.value + ' ' + ui.pb_end_y.value + ' ' + ui.pb_end_z.value + ' ' + ui.pb_start_mes.value + ui.pb_end_mes.value + ui.pb_con_r.value + ' ' + ui.pb_con_g.value + ' ' + ui.pb_con_b.value + ' ' + ui.pb_xn.value + ' ' + ui.pb_yn.value + ' ' + ui.pb_zn.value + ' ' + ui.pb_xr.value + ' ' + ui.pb_yr.value + ' ' + ui.pb_zr.value;
-
- unit.form.mainfrm.OnSend(str);
-
- unit.form.mainfrm.OnChangePicture(3, 2);
- //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">恭喜成功地做好了连接!</h4>');
-
- let Load = {
- "constraint":"连接",
- "非约束类型":ui.misConstraints.value,
- "起点x":ui.pb_xn.value,
- "起点y":ui.pb_yn.value,
- "起点z":ui.pb_zn.value,
- "终点x":ui.pb_xr.value,
- "终点y":ui.pb_yr.value,
- "终点z":ui.pb_zr.value,
- "R":ui.pb_con_r.value,
- "G":ui.pb_con_g.value,
- "B":ui.pb_con_b.value
- };
- unit.form.tree.CreateBoundary(Load);
- unit.form.mainfrm.OnCueline('您成功地做好了连接!', 'green');
- }
- function onEndMessage(){
- controls(false);
- }
- function onStartMessage(){
- controls(true);
- }
- function controls(idx){
- ui.pb_start_message.enable = !idx;
- ui.pb_start_mes.enable = !idx;
- ui.pb_start_x.enable = idx;
- ui.pb_start_y.enable = idx;
- ui.pb_start_z.enable = idx;
-
- ui.pb_end_message.enable = idx;
- ui.pb_end_mes.enable = idx;
- ui.pb_end_x.enable = !idx;
- ui.pb_end_y.enable = !idx;
- ui.pb_end_z.enable = !idx;
-
- if(idx === true){
- model.setStartEnd(0);
- }
- if(idx === false){
- model.setStartEnd(1);
- }
- }
- function OnChangeValue(){
- ui.pb_pass.enable = false;
- }
- function OnReturn(){
- unit.form.mainfrm.menu(4);
- }
- function OnFile(){
- ui.pb_pass.enable = true;
- model.setCon(1);
-
- if(ui.stack_menu.index === 0){
- let id = parent.setTimeout(() => {
- unit.form.mainfrm.OnSend('0');
- }, 100);
- unit.form.mainfrm.OnSend('beamSave ' + model.getCurrentDirectory());
- }
- if(ui.stack_menu.index === 1){
- let id = parent.setTimeout(() => {
- unit.form.mainfrm.OnSend('0');
- }, 100);
- unit.form.mainfrm.OnSend('springSave ' + model.getCurrentDirectory());
- }
- }
- function OnSpring(){
-
- unit.form.mainfrm.OnSend('springHightLight ' + ui.pb_x.value + ' ' + ui.pb_y.value + ' ' + ui.pb_z.value + ' ' + ui.pb_X.value + ' ' + ui.pb_Y.value + ' ' + ui.pb_Z.value + ' ' + ui.stiffness_x.value + ' ' + ui.stiffness_y.value + ' ' + ui.stiffness_z.value + ' ' + ui.pb_R.value + ' ' + ui.pb_G.value + ' ' + ui.pb_B.value + ' ' + ui.pb_type1.value + ui.pb_type2.value);
-
- unit.form.mainfrm.OnChangePicture(3, 2);
- //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">恭喜您完成了弹簧约束的添加!</h4>');
-
- let Load = {
- "constraint":"弹簧",
- "非约束类型":ui.misConstraints.value,
- "起点x":ui.pb_x.value,
- "起点y":ui.pb_y.value,
- "起点z":ui.pb_z.value,
- "终点x":ui.pb_X.value,
- "终点y":ui.pb_Y.value,
- "终点z":ui.pb_Z.value,
- "弹簧刚度x":ui.stiffness_x.value,
- "弹簧刚度y":ui.stiffness_y.value,
- "弹簧刚度z":ui.stiffness_z.value,
- "R":ui.R.value,
- "G":ui.G.value,
- "B":ui.B.value
- };
- unit.form.tree.CreateBoundary(Load);
- unit.form.mainfrm.OnCueline('您完成了弹簧约束的添加!', 'green');
- }
- function OnBeam(){
-
- unit.form.mainfrm.OnSend('beamHightLight ' + 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 + ' ' + ui.rad.value + ' ' + ui.m.value + ' ' + ui.poi.value + ' ' + ui.R.value + ' '+ ui.G.value + ' ' + ui.B.value + ' ' + ui.pb_node_size.value);
-
- unit.form.mainfrm.OnChangePicture(3, 2);
- //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">恭喜您完成了梁约束的添加!</h4>');
- let Load = {
- "constraint":"梁",
- "非约束类型":ui.misConstraints.value,
- "梁约束位置xDirection":ui.pb_xDiration.value,
- "梁约束位置yDirection":ui.pb_yDiration.value,
- "梁约束位置zDirection":ui.pb_zDiration.value,
- "梁约束位置xCoord":ui.pb_xCoord.value,
- "梁约束位置yCoord":ui.pb_yCoord.value,
- "梁约束位置zCoord":ui.pb_zCoord.value,
- "梁约束参数半径":ui.rad.value,
- "梁约束参数长度":ui.pb_length.value,
- "梁约束参数个数":ui.pb_size.value,
- "弹性模量":ui.m.value,
- "泊松比":ui.poi.value,
- "梁节点大小半径":ui.pb_node_size.value,
- "R":ui.R.value,
- "G":ui.G.value,
- "B":ui.B.value
- };
- unit.form.tree.CreateBoundary(Load);
- unit.form.mainfrm.OnCueline('您完成了梁约束的添加!', 'green');
- }
- function control(idx){
- ui.pb_start.enable = !idx;
- ui.pb_x.enable = idx;
- ui.pb_y.enable = idx;
- ui.pb_z.enable = idx;
-
- ui.pb_end.enable = idx;
- ui.pb_X.enable = !idx;
- ui.pb_Y.enable = !idx;
- ui.pb_Z.enable = !idx;
-
- if(idx === true){
- model.setStartEnd(0);
- }
- if(idx === false){
- model.setStartEnd(1);
- }
- }
- function OnEed(){
- control(false);
- }
- function OnStart(){
- control(true);
- }
- function OnChangeMenu(){
- ui.stack_menu.index = parseFloat(ui.misConstraints.index);
- console.log(ui.no_limit_constraint.index === 1);
- //console.log(ui.limit_constraint.index);
- if(ui.stack_menu.index === 3){
- model.setBeam(true);
- }else{
- model.setBeam(false);
- }
- }
- function OnChangeConstraint(){
-
- ui.stack_constraint.index = ui.limit_constraint.index;
- /*if(parseFloat(idx) === 1){
- unit.form.mainfrm.OnChangePicture(3, 1);
- unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: Blue;font-size:20px;">注意事项:弹簧单元的起点和终点需要自动添加,鼠标右键选中起始/终止点,点击按钮(在窗口左侧倒数第5个按钮)添加即可将坐标导入!</h4>');
- }else if(parseFloat(idx) === 2){
- unit.form.mainfrm.OnChangePicture(3, 1);
- unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: Blue;font-size:20px;">注意事项:连接单元的起点和终点需要自动添加,鼠标右键选中起始/终止点,点击按钮(在窗口左侧倒数第5个按钮)添加即可将坐标导入!</h4>');
- }else if(parseFloat(idx) === 3){
- unit.form.mainfrm.OnChangePicture(3, 1);
- unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: Blue;font-size:20px;">注意事项:非均匀梁的各个节点需要用鼠标右键拾取后点击H或h进行保存,梁上的各个点需要在一条直线上!</h4>');
- }*/
- if(parseFloat(idx) === 1){
- unit.form.mainfrm.OnChangePicture(3, 1);
- unit.form.mainfrm.OnCueline('注意事项:弹簧单元的起点和终点需要自动添加,鼠标右键选中起始/终止点,点击按钮(在窗口左侧倒数第3个按钮)添加即可将坐标导入!', 'blue');
- }else if(parseFloat(idx) === 2){
- unit.form.mainfrm.OnChangePicture(3, 1);
- unit.form.mainfrm.OnCueline('注意事项:连接单元的起点和终点需要自动添加,鼠标右键选中起始/终止点,点击按钮(在窗口左侧倒数第3个按钮)添加即可将坐标导入!', 'blue');
- }else if(parseFloat(idx) === 3){
- unit.form.mainfrm.OnChangePicture(3, 1);
- unit.form.mainfrm.OnCueline('注意事项:非均匀梁的各个节点需要用鼠标右键拾取后点击H或h进行保存,梁上的各个点需要在一条直线上!', 'blue');
- }
- }
- function ChangeRadiobutton(idx) {
- ui.limit_constraint.index = parseFloat(idx);
- }
- //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("pb_x",
- val => {
- ui.pb_x.value = val;
- ui.pb_start_x.value = val;
- }, () => {});
-
- CW_DeclareVariable("pb_y",
- val => {
- ui.pb_y.value = val;
- ui.pb_start_y.value = val;
- }, () => {});
- CW_DeclareVariable("pb_z",
- val => {
- ui.pb_z.value = val;
- ui.pb_start_z.value = val;
- }, () => {});
-
- CW_DeclareVariable("pb_X",
- val => {
- ui.pb_X.value = val;
- ui.pb_end_x.value = val;
- }, () => {});
-
- CW_DeclareVariable("pb_Y",
- val => {
- ui.pb_Y.value = val;
- ui.pb_end_y.value = val;
- }, () => {});
- CW_DeclareVariable("pb_Z",
- val => {
- ui.pb_Z.value = val;
- ui.pb_end_z.value = val;
- }, () => {});
- CW_DeclareVariable("listbox",
- val => {
- ui.listbox.list = [
- val
- ];
- }, () => {});
-
- CW_DeclareVariable("start_mes",
- val => {
- ui.pb_type1.value = val;
- ui.pb_start_mes.value = val;
- }, () => {});
-
- CW_DeclareVariable("end_mes",
- val => {
- ui.pb_type2.value = val;
- ui.pb_end_mes.value = val;
- }, () => {});
-
- CW_DeclareVariable("change1",
- val => {
- ui.stack_constraint.index = val;
- }, () => {});
-
- CW_DeclareVariable("change2",
- val => {
- ui.stack_menu.index = val;
- ui.misConstraints.index = val;
- }, () => {});
- CW_DeclareVariable("setConstraint0",
- val => {
- ui.con_xn.value = val["固定支撑属性xd"];
- ui.con_xr.value = val["固定支撑属性xr"];
- ui.con_yn.value = val["固定支撑属性yd"];
- ui.con_yr.value = val["固定支撑属性yr"];
- ui.con_zn.value = val["固定支撑属性zd"];
- ui.con_zr.value = val["固定支撑属性zr"];
- }, () => {});
- CW_DeclareVariable("setConstraint1",
- val => {
- ui.pb_xDiration.value = val["梁约束位置xDirection"];
- ui.pb_yDiration.value = val["梁约束位置yDirection"];
- ui.pb_zDiration.value = val["梁约束位置zDirection"];
- ui.pb_xCoord.value = val["梁约束位置xCoord"];
- ui.pb_yCoord.value = val["梁约束位置yCoord"];
- ui.pb_zCoord.value = val["梁约束位置zCoord"];
- ui.rad.value = val["梁约束参数半径"];
- ui.pb_length.value = val["梁约束参数长度"];
- ui.pb_size.value = val["梁约束参数个数"];
- ui.m.value = val["弹性模量"];
- ui.poi.value = val["泊松比"];
- ui.pb_node_size.value = val["梁节点大小半径"];
- ui.R.value = val.R;
- ui.G.value = val.G;
- ui.B.value = val.B;
- }, () => {});
- CW_DeclareVariable("setConstraint2",
- val => {
- ui.pb_x.value = val["起点x"];
- ui.pb_y.value = val["起点y"];
- ui.pb_z.value = val["起点z"];
- ui.pb_X.value = val["终点x"];
- ui.pb_Y.value = val["终点y"];
- ui.pb_Z.value = val["终点z"];
- ui.stiffness_x.value = val["弹簧刚度x"];
- ui.stiffness_y.value = val["弹簧刚度y"];
- ui.stiffness_z.value = val["弹簧刚度z"];
- ui.pb_R.value = val.R;
- ui.pb_G.value = val.G;
- ui.pb_B.value = val.B;
- }, () => {});
- CW_DeclareVariable("setConstraint3",
- val => {
- ui.pb_xn.value = val["起点x"];
- ui.pb_yn.value = val["起点y"];
- ui.pb_zn.value = val["起点z"];
- ui.pb_xr.value = val["终点x"];
- ui.pb_yr.value = val["终点y"];
- ui.pb_zr.value = val["终点z"];
- ui.pb_con_r.value = val.R;
- ui.pb_con_g.value = val.G;
- ui.pb_con_b.value = val.B;
- }, () => {});
- 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);
- }
- }
|