lzy 3 months ago
parent
commit
497b697d71
7 changed files with 60 additions and 11 deletions
  1. 1 1
      data/work1/proj.db.json
  2. 1 1
      data/work2/proj.db.json
  3. 1 1
      data/work4/proj.db.json
  4. 3 2
      js/mainfrm_pane.js
  5. 52 4
      js/tree_pane.js
  6. 1 1
      viewProp.db.json
  7. 1 1
      workArea.cfg.json

File diff suppressed because it is too large
+ 1 - 1
data/work1/proj.db.json


File diff suppressed because it is too large
+ 1 - 1
data/work2/proj.db.json


File diff suppressed because it is too large
+ 1 - 1
data/work4/proj.db.json


+ 3 - 2
js/mainfrm_pane.js

@@ -192,8 +192,9 @@ function RenameTreeNode(Idx) {
         }
 }
 //点亮面
-function LightFace(id) {
-        ui.canvas.view([ui.canvas.generateKey(2025, parseInt(id))]).setColor(1.0, 0.0, 0.0);
+function LightFace(id, rgb) {
+        let r_id =  findRIdById(model.acax_app.model.project.GetModel().pro_model, id);
+        ui.canvas.view([ui.canvas.generateKey(2025, parseInt(r_id))]).setColor(parseFloat(rgb.r)/255, parseFloat(rgb.g)/255, parseFloat(rgb.b)/255);
 }
 function OnInitializeData(reload, preview) {
         //model.ide_info(model.uuid().length);

+ 52 - 4
js/tree_pane.js

@@ -904,11 +904,34 @@ function OnClickTree(id, column, text){
         }        
         if(column === 1) {
                 var clr = ui.ColorDialog(text);
+                let cut_project_index = model.acax_app.view.GetCurrentProjectIndex();
+                let temp = model.acax_app.view.GetProperty(cut_project_index);
+                temp.color[id] = clr;
+                model.acax_app.view.SetProperty(cut_project_index, temp);
+                let rgb = hexToRgb(clr);
+                unit.form.mainfrm.LightFace(id, rgb);
                 if(clr) {
                         ui.tree_Model.column = [column, clr];
                 }
         }
 }
+//16进制转rgb
+function hexToRgb(hex) {
+        // 去掉前缀 #(如果有)
+        hex = hex.replace(/^#/, '');
+
+        // 如果是简写形式(#RGB),将其转换为完整形式(#RRGGBB)
+        if (hex.length === 3) {
+                hex = hex.split('').map(char => char + char).join('');
+        }
+
+        // 解析 RGB 颜色值
+        const r = parseInt(hex.slice(0, 2), 16);
+        const g = parseInt(hex.slice(2, 4), 16);
+        const b = parseInt(hex.slice(4, 6), 16);
+
+        return { r, g, b };
+}
 //切换约束面板
 function ChangeConstraint(constraint_name, prop) {
         let constraint = {
@@ -1523,10 +1546,10 @@ function SetModelColor(Idx) {
         if(model_prop === undefined) {
                 model_prop = {};
                 model_prop.color = model_color;
-                model.acax_app.view.SetProperty(cut_workcondition_index, model_prop);
+                model.acax_app.view.SetProperty(cut_project_index, model_prop);
         }else{
                 model_prop.color = model_color;
-                model.acax_app.view.SetProperty(cut_workcondition_index, model_prop);
+                model.acax_app.view.SetProperty(cut_project_index, model_prop);
         }
         console.log(model.acax_app.view.GetProperty(cut_project_index));
 }
@@ -1550,17 +1573,42 @@ function assignColorsToTree(tree, idColorMap) {
         // 返回更新后的树
         return tree;
 }
+//找记录颜色和生成颜色不同的键值对
+function findDifferences(oldMap, newMap) {
+        const differences = {};
+
+        for (const key in oldMap) {
+                if (oldMap[key] !== newMap[key]) {
+                        differences[key] = newMap[key];
+                }
+        }
+
+        return differences;
+}
 //导入模型树节点
 function OnTree(Idx){     
        
         //console.log(JSON.stringify(Idx, null, 2));
         let tree_color = [];
         updateJsonNodes(Idx);
+        
         //模型树颜色
         let cut_project_index = model.acax_app.view.GetCurrentProjectIndex();
-        if(model.acax_app.view.GetProperty(cut_project_index) !== undefined && model.acax_app.view.GetProperty(cut_project_index).color !== undefined) {
+        if(model.acax_app.view.GetProperty(cut_project_index) !== undefined ) {
                 //获取工程中的模型颜色,为树赋颜色
-                assignColorsToTree(Idx, model.acax_app.view.GetProperty(cut_project_index).color);
+                if(model.acax_app.view.GetProperty(cut_project_index).color!==undefined ) {
+                        let old_map = getTreeIdColorMap(Idx);
+                        console.log(old_map);
+                        console.log( model.acax_app.view.GetProperty(cut_project_index).color);
+                        let difference = findDifferences(old_map, model.acax_app.view.GetProperty(cut_project_index).color);
+                        console.log(difference);
+                        let dif_key = Object.keys(difference);
+                        for(let i = 0;i < dif_key.length;++i) {
+                                let rgb = hexToRgb(difference[dif_key[i]]);
+                                unit.form.mainfrm.LightFace(dif_key[i], rgb);
+                        }
+                        assignColorsToTree(Idx, model.acax_app.view.GetProperty(cut_project_index).color);
+                }
                 
         }else{
                 SetModelColor(Idx);

File diff suppressed because it is too large
+ 1 - 1
viewProp.db.json


+ 1 - 1
workArea.cfg.json

@@ -1 +1 @@
-{"current":0,"list":["D:/dcip1/comx_sdk.node/unit/hypermesh/data/work1","D:\\dcip1\\comx_sdk.node\\unit\\hypermesh\\data\\work2","D:\\dcip1\\comx_sdk.node\\unit\\hypermesh\\data\\work3","D:\\dcip1\\comx_sdk.node\\unit\\hypermesh\\data\\work4"]}
+{"current":3,"list":["D:/dcip1/comx_sdk.node/unit/hypermesh/data/work1","D:\\dcip1\\comx_sdk.node\\unit\\hypermesh\\data\\work2","D:\\dcip1\\comx_sdk.node\\unit\\hypermesh\\data\\work3","D:\\dcip1\\comx_sdk.node\\unit\\hypermesh\\data\\work4"]}