123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378 |
- ////////////////////////////////////////////////////////////////////////////
- // 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.
-
- });
- ui.light.valid = true;
- }
- //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 OnZhenDongMenu(){
- switch (ui.pb_zhendong.content_menu) {
- case 1:
- unit.form.mainfrm.OnChangeValue(6);
- unit.form.mainfrm.OnChangeIndex(3);
- break;
- case 2:
- unit.form.mainfrm.OnChangeValue(6);
- unit.form.mainfrm.OnChangeIndex(3);
- break;
- case 4:
- unit.form.result_ZhenDong.Show();
- break;
- case 5:
- unit.form.result_ZhenDongYueShu.Show();
- break;
- }
- }
- function OnZhenDong(){
- ui.pb_zhendong.content_menu = [{
- name: "自由振动",
- id: 1
- }, {
- name: "约束振动",
- id: 2
- }, {
- name: "任意激励",
- id: 3
- }];
- }
- function OnMoTaiMenu(){
- switch (ui.motai.content_menu) {
- case 1:
- unit.form.physicsCreate2.Show();
- break;
- case 2:
- unit.form.createAnsys.Show();
- break;
- case 3:
- unit.form.mainfrm.OnCueline("求解中...", "blue");
- parent.setTimeout(() => {
- unit.form.mainfrm.OnCueline("求解成功!", "green");
- }, 20000);
- break;
- case 4:
- unit.form.result_ModelAnsys.Show();
- break;
- }
- }
- function OnMoTai(){
- ui.motai.content_menu = [{
- name: "创建分析类型",
- id: 1
- }, {
- name: "创建分析步",
- id: 2
- }, {
- name: "求解",
- id: 3
- }, {
- name: "结果",
- id: 4
- }];
- }
- var isLisght = true;
- function OnLight(){
- isLisght = !isLisght;
- ui.light.valid = isLisght;
- unit.form.mainfrm.OnLight(isLisght);
- }
- function OnCanvasContentMenu(){
-
- if(ui.view.content_menu === 1){
- OnTransform(1);
- }
-
- if(ui.view.content_menu === 2){
- OnTransform(2);
- }
-
- if(ui.view.content_menu === 3){
- OnPosition(1);
- }
-
- if(ui.view.content_menu === 4){
- OnPosition(2);
- }
-
- if(ui.view.content_menu === 5){
- OnPosition(6);
- }
-
- if(ui.view.content_menu === 6){
- OnPosition(5);
- }
-
- if(ui.view.content_menu === 7){
- OnPosition(3);
- }
-
- if(ui.view.content_menu === 8){
- OnPosition(4);
- }
- }
- function OnCanvasRightClick(){
- ui.view.content_menu = [
- {
- name: '旋转',
- icon: 'bar10',
- id: 1
- },
- {
- name: '平移',
- icon: 'bar11',
- id: 2
- },
- {
- name: '-'
- },
- {
- name: 'YOX',
- icon: 'bar19',
- id: 3
- },
- {
- name: 'XOY',
- icon: 'bar20',
- id: 4
- },
- {
- name: 'ZOX',
- icon: 'bar21',
- id: 5
- },
- {
- name: 'XOZ',
- icon: 'bar22',
- id: 6
- },
- {
- name: 'ZOY',
- icon: 'bar23',
- id: 7
- },
- {
- name: 'YOZ',
- icon: 'bar24',
- id: 8
- }
-
- ];
- }
- function OnBrep(){
- unit.form.mainfrm.OnSend('generateBreps');
- }
- function OnFixed(){
- unit.form.mainfrm.OnSend('constrainAdd');
- }
- function OnArrow(){
- unit.form.mainfrm.OnSend('arrowAdd');
- }
- function OnFacePick(){
- unit.form.mainfrm.OnSend('facePickup');
- }
- function OnPick(){
- unit.form.mainfrm.OnSend('solidPickup');
- }
- function OnPostContentMenu(){
- switch (ui.pb_post.content_menu) {
- case 1:
- unit.form.colorMap.Show();
- break;
- }
- }
- function OnPost(){
- ui.pb_post.content_menu = [{
- name: "颜色映射表",
- icon: "图标",
- id: 1
- }];
- }
- var isShow = true;
- function OnShow(){
- isShow = !isShow;
-
- unit.form.mainfrm.OnWindowVisible(isShow);
- }
- function OnImport(){
- unit.form.tree.OnChangeMenu(1);
- }
- function OnFileContentMenu() {
- //打开文件
- switch (ui.pb_file.content_menu) {
- case 11:
- unit.form.workArea.Show();
- break;
- case 12:
- unit.form.Project.Show();
- break;
- case 13:
- unit.form.WorkCondition.Show();
- break;
- case 2:
- var fname = ui.OpenFolderDialog("Open WorkArea", unit.dir);
-
- unit.form.tree.OpenWorkArea(fname);
- break;
- case 3:
- unit.form.tree.SaveWorkArea();
- break;
- case 61:
- unit.form.tree.OnChangeMenu(1);
- unit.form.tree.OnTopMenu(1);
- break;
- case 62:
- unit.form.tree.OnChangeMenu(1);
- unit.form.tree.OnTopMenu(2);
- break;
- case 63:
- unit.form.tree.OnChangeMenu(1);
- unit.form.tree.OnTopMenu(3);
- break;
- case 64:
- unit.form.tree.OnChangeMenu(1);
- unit.form.tree.OnTopMenu(4);
- break;
- case 65:
- unit.form.tree.OnChangeMenu(1);
- unit.form.tree.OnTopMenu(5);
- break;
- }
- }
- function OnFile() {
- ui.pb_file.content_menu = [{
- name: "新建",
- icon: "bar01",
- id: 1,
- children: [{
- name: "工作区",
- icon: "import01",
- id: 11
- }, {
- name: "工程",
- icon: "import02",
- id: 12
- }, {
- name: "工况",
- icon: "import02",
- id: 13
- }]
- }, {
- name: "打开",
- icon: "bar02",
- id: 2
- }, {
- name: "导入",
- icon: "bar04",
- id: 6,
- children: [{
- name: "几何文件",
- icon: "import03",
- id: 63
- }]
- }];
- }
- function OnTransform(idx){
- unit.form.mainfrm.OnTransform(idx);
- }
- function OnPosition(index){
- unit.form.mainfrm.On3DPosition(index);
- }
- function OnUser(){
- unit.form.user.Show();
- }
- //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);
- }
- }
|