////////////////////////////////////////////////////////////////////////////
// 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('
非常抱歉,您输入的数据不在参数范围内!
');
unit.form.mainfrm.OnCueline('您输入的数据不在参数范围内!', 'red');
}else{
unit.form.mainfrm.OnChangePicture(3, 2);
//unit.form.mainfrm.OnCueline('恭喜您,您输入了正确的数据!
');
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('恭喜您完成了固定支撑属性的添加,请用鼠标右键选中需要施加约束的物体并按快捷键T或者t进行添加!
');
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('恭喜成功做好了不均匀梁的添加!
');
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('恭喜成功地做好了连接!
');
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('恭喜您完成了弹簧约束的添加!
');
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('恭喜您完成了梁约束的添加!
');
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('注意事项:弹簧单元的起点和终点需要自动添加,鼠标右键选中起始/终止点,点击按钮(在窗口左侧倒数第5个按钮)添加即可将坐标导入!
');
}else if(parseFloat(idx) === 2){
unit.form.mainfrm.OnChangePicture(3, 1);
unit.form.mainfrm.OnCueline('注意事项:连接单元的起点和终点需要自动添加,鼠标右键选中起始/终止点,点击按钮(在窗口左侧倒数第5个按钮)添加即可将坐标导入!
');
}else if(parseFloat(idx) === 3){
unit.form.mainfrm.OnChangePicture(3, 1);
unit.form.mainfrm.OnCueline('注意事项:非均匀梁的各个节点需要用鼠标右键拾取后点击H或h进行保存,梁上的各个点需要在一条直线上!
');
}*/
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);
}
}