geometry_facecenter_pane.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. ////////////////////////////////////////////////////////////////////////////
  2. // System Pre-define Functions
  3. // 95099372-ef3e-11ea-9c81-bf848405c62e
  4. //Callback of data preparation stage before UI is fully loaded.
  5. function OnInitializeData(reload, preview) {
  6. PUI(()=>{
  7. //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
  8. //The 'pui' variable is valid in all functions of this document.
  9. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
  10. });
  11. }
  12. //Callback after UI is fully loaded and displayed.
  13. function OnReady(reload, preview) {
  14. PUI(()=>{
  15. //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
  16. //The 'pui' variable is valid in all functions of this document.
  17. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
  18. });
  19. }
  20. function OnCloseForm() {
  21. }
  22. function OnException(err) {
  23. //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok);
  24. }
  25. //////////////////////////////////////////////////////////////////////////
  26. // Callback Functions.
  27. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
  28. function OnGetFaceName(){
  29. const str = unit.form.mainfrm.OnGetFaceName();
  30. // 匹配type对应内容的正则表达式,以type:开头,后面跟着非冒号的内容直到遇到空格或者字符串结束
  31. const typeRegex = /type:([^point]+)/;
  32. // 匹配center坐标对应内容的正则表达式
  33. //const centerRegex = /point:([\d. ]+)/;
  34. const typeMatch = str.match(typeRegex);
  35. const typeInfo = typeMatch? typeMatch[1] : null;
  36. const match = str.match(/point:([-\d.]+)\s+([-\d.]+)\s+([-\d.]+)/);
  37. const centerCoords = match.slice(1, 4);
  38. ui.type1.value = typeInfo;
  39. ui.x1.value = centerCoords[0];
  40. ui.y1.value = centerCoords[1];
  41. ui.z1.value = centerCoords[2];
  42. }
  43. function OnCenz(){
  44. if(ui.pbc_z.value <= 0){
  45. unit.form.mainfrm.OnChangePicture(1, 3);
  46. unit.form.mainfrm.OnCueline('您输入的参数不符合常理,请您重新输入!!!', 'red');
  47. }
  48. if(ui.pbc_z.value > 0){
  49. unit.form.mainfrm.OnChangePicture(1, 1);
  50. unit.form.mainfrm.OnCueline('您输入了正确的数据!', 'green');
  51. }
  52. }
  53. function OnCeny(){
  54. if(ui.pbc_y.value <= 0){
  55. unit.form.mainfrm.OnChangePicture(1, 3);
  56. unit.form.mainfrm.OnCueline('您输入的参数不符合常理,请您重新输入!!!', 'red');
  57. }
  58. if(ui.pbc_y.value > 0){
  59. unit.form.mainfrm.OnChangePicture(1, 1);
  60. unit.form.mainfrm.OnCueline('您输入了正确的数据!', 'green');
  61. }
  62. }
  63. function OnCenx(){
  64. if(ui.pbc_x.value <= 0){
  65. unit.form.mainfrm.OnChangePicture(1, 3);
  66. unit.form.mainfrm.OnCueline('您输入的参数不符合常理,请您重新输入!!!', 'red');
  67. }
  68. if(ui.pbc_x.value > 0){
  69. unit.form.mainfrm.OnChangePicture(1, 1);
  70. unit.form.mainfrm.OnCueline('您输入了正确的数据!', 'green');
  71. }
  72. }
  73. function OnDetermine(){
  74. if(!model.global_ctrl[0] || !model.global_ctrl[1] || !model.global_ctrl[2] || !model.global_ctrl[3]) {
  75. unit.form.mainfrm.OnCueline('未满足创建条件', 'red');
  76. return;
  77. }
  78. let workcondition_index = model.acax_app.view.GetCurrentWorkConditionIndex();
  79. let temp = unit.form.tree.GetCurUniqueName();
  80. let name = temp;
  81. //判断是否为空
  82. let j = 0;
  83. let i = 0;
  84. if(model.acax_app.view.GetProperty(workcondition_index) === undefined || model.acax_app.view.GetProperty(workcondition_index).point === undefined) {
  85. name = name + " P 0 0";
  86. }else{
  87. let point_arr = Object.keys(model.acax_app.view.GetProperty(workcondition_index).point);
  88. name = name + " P 0 " + point_arr.length;
  89. while(1){
  90. for( i = 0;i < point_arr.length;++i) {
  91. if(model.acax_app.view.GetProperty(workcondition_index).point[point_arr[i]].name === name) {
  92. ++j;
  93. name = temp + " P 0 " + point_arr.length + j;
  94. break;
  95. }
  96. }
  97. if(i === point_arr.length) {
  98. break;
  99. }
  100. }
  101. }
  102. //unit.form.mainfrm.OnSetPoints(ui.pb_x.value, ui.pb_y.value, ui.pb_z.value, ui.pb_radius.value, name);
  103. unit.form.mainfrm.OnSetPoints(ui.x1.value, ui.y1.value, ui.z1.value, ui.radius.value, name);
  104. //++i;
  105. let node ={
  106. "x":ui.x1.value,
  107. "y":ui.y1.value,
  108. "z":ui.z1.value,
  109. "radius":ui.radius.value,
  110. "name":name
  111. };
  112. unit.form.tree.SetPoint(node);
  113. unit.form.mainfrm.OnCueline('创建成功', 'green');
  114. unit.form.mainfrm.OnChangePicture(1, 2);
  115. }
  116. function OnReturn(){
  117. unit.form.mainfrm.menu(0);
  118. }
  119. //The message corresponding callback executed by the docker pane.
  120. // when calling [side_pane].fireEvent(type,para) in the main form.
  121. function OnParentDockerMessage(type, para) {
  122. }
  123. //////////////////////////////////////////////////////////////////////////
  124. // Utils Functions.
  125. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  126. function onDragFile(filepath) {
  127. }
  128. function PUI(cb) {
  129. if(pui){cb();}
  130. }
  131. /*Usage of BLOCK_EVENT
  132. BLOCK_EVENT(()=>{
  133. ui.[name].[var] = ...;
  134. });
  135. */
  136. function BLOCK_EVENT(cb) {
  137. ui.block_event = true;
  138. cb();
  139. ui.block_event = false;
  140. }
  141. //////////////////////////////////////////////////////////////////////////
  142. // template codes for cw callback js.
  143. function CW_DeclareVariable(name, setter, getter) {
  144. if(typeof(__DeclareVariable) === 'function') {
  145. __DeclareVariable(name, setter, getter);
  146. }
  147. }
  148. function CW_DeclareOuterVariable(name) {
  149. if(typeof(__DeclareOuterVariable) === 'function') {
  150. __DeclareOuterVariable(name);
  151. }
  152. }