123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- 1;////////////////////////////////////////////////////////////////////////////
- // 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 cutLineEqually(startX, startY, startZ, endX, endY, endZ, numSegments) {
- const segments = [];
- const deltaX = (endX - startX) / numSegments;
- const deltaY = (endY - startY) / numSegments;
- const deltaZ = (endZ - startZ) / numSegments;
- for (let i = 1; i < numSegments; i++) {
- const x = startX + i * deltaX;
- const y = startY + i * deltaY;
- const z = startZ + i * deltaZ;
- segments.push({ x, y, z });
- }
- return segments;
- }
- function OnRet(){
- unit.form.mainfrm.menu(0);
- }
- function OnDetermin(){
- //unit.form.mainfrm.OnSend('addLinePoints ' + ui.x1.value + ' ' + ui.y1.value + ' ' + ui.z1.value + ' '+ ui.x2.value + ' '+ ui.y2.value + ' '+ ui.z2.value + ' '+ ui.pb_s.value);
-
- if(!model.global_ctrl[0] || !model.global_ctrl[1] || !model.global_ctrl[2] || !model.global_ctrl[3]) {
- unit.form.mainfrm.OnCueline('未满足创建条件', 'red');
- return;
- }
-
- const result = cutLineEqually(ui.x1.value, ui.y1.value, ui.z1.value, ui.x2.value, ui.y2.value, ui.z2.value, parseInt(ui.pb_s.value) + 1);
- for (let k = 0; k < result.length; k++) {
-
- let workcondition_index = model.acax_app.view.GetCurrentWorkConditionIndex();
- let temp = unit.form.tree.GetCurUniqueName();
- let name = temp;
- //判断是否为空
- let j = 0;
- let i = 0;
- if(model.acax_app.view.GetProperty(workcondition_index) === undefined || model.acax_app.view.GetProperty(workcondition_index).point === undefined) {
- name = name + " P 0 0";
- }else{
- let point_arr = Object.keys(model.acax_app.view.GetProperty(workcondition_index).point);
- name = name + " P 0 " + point_arr.length;
- while(1){
- for( i = 0;i < point_arr.length;++i) {
- if(model.acax_app.view.GetProperty(workcondition_index).point[point_arr[i]].name === name) {
- ++j;
- name = temp + " P 0 " + point_arr.length + j;
-
- break;
- }
- }
- if(i === point_arr.length) {
- break;
- }
- }
-
- }
- unit.form.mainfrm.OnSetPoints(result[k].x, result[k].y, result[k].z, ui.radius.value, name);
- // unit.form.mainfrm.OnSetPoints(ui.x1.value, ui.y1.value, ui.z1.value, ui.radius.value, name);
- let node ={
- "x":result[k].x,
- "y":result[k].y,
- "z":result[k].z,
- "radius": ui.radius.value,
- "name":name
- };
-
- unit.form.tree.SetPoint(node);
-
- }
- unit.form.mainfrm.OnCueline('创建成功', 'green');
-
- }
- function OnReturn(){
- unit.form.mainfrm.menu(0);
- }
- function OnDetermine(){
- unit.form.mainfrm.OnSend('addLinePoints2 ' + + ui.x1_1.value + ' ' + ui.y1_1.value + ' ' + ui.z1_1.value + ' '+ ui.x2_2.value + ' '+ ui.y2_2.value + ' '+ ui.z2_2.value + ' '+ ui.pb_n.value);
- //unit.form.mainfrm.OnCueline('第一个参数为空', 'red');
- //unit.form.mainfrm.OnChangePicture(1, 2);
- }
- function OnNode(){
- ui.select_stk.index = 1;
- }
- function OnSegment(){
- ui.select_stk.index = 0;
- }
- //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);
- }
- }
|