|
@@ -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);
|