取消部分组件的颜色参数化
This commit is contained in:
parent
099309ade9
commit
b0598c3502
@ -16,6 +16,7 @@
|
|||||||
--instance-color: #CB81DA;
|
--instance-color: #CB81DA;
|
||||||
--instance-fill-color: rgba(203, 129, 218, 0.1);
|
--instance-fill-color: rgba(203, 129, 218, 0.1);
|
||||||
--wire-color: var(--foreground);
|
--wire-color: var(--foreground);
|
||||||
|
--cross-dot-color: var(--foreground);
|
||||||
--port-color: rgb(70, 70, 222);
|
--port-color: rgb(70, 70, 222);
|
||||||
--port-fill-color: rgba(70, 70, 222, 0.1);
|
--port-fill-color: rgba(70, 70, 222, 0.1);
|
||||||
|
|
||||||
|
@ -25,6 +25,12 @@ export const colorManager = reactive({
|
|||||||
type: 'instance',
|
type: 'instance',
|
||||||
label: t('common.instance'),
|
label: t('common.instance'),
|
||||||
color: 'white',
|
color: 'white',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 3,
|
||||||
|
type: 'cross-dot',
|
||||||
|
label: t('cross-dot'),
|
||||||
|
color: 'white'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
101
src/hook/render/cross-dot.js
Normal file
101
src/hook/render/cross-dot.js
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
import * as d3 from 'd3';
|
||||||
|
import { globalSetting } from '../global';
|
||||||
|
import { NetlistRender } from '.';
|
||||||
|
|
||||||
|
export class CrossDotRender {
|
||||||
|
/**
|
||||||
|
* @param {d3.Selection} selection
|
||||||
|
* @param {NetlistRender} rootRender
|
||||||
|
*/
|
||||||
|
constructor(selection, rootRender) {
|
||||||
|
this.parentSelection = selection;
|
||||||
|
this.rootRender = rootRender;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {BasicD3DataItem[]}
|
||||||
|
*/
|
||||||
|
this.data = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description id 到管理数据项的映射
|
||||||
|
* @type {Map<string, BasicD3ManagmentItem[]>}
|
||||||
|
*/
|
||||||
|
this.id2manager = rootRender.id2manager;
|
||||||
|
|
||||||
|
this.crossId = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 将 elknode 关于 module connection 的数据添加为 d3 数据项目
|
||||||
|
* @param {ElkPort} cellPort 连接点对象
|
||||||
|
* @param {ElkNode} node 当前的实体(port/例化模块/器件)
|
||||||
|
*/
|
||||||
|
addAsD3DataItem(cellPort, node) {
|
||||||
|
this.data.push({
|
||||||
|
id: this.crossId,
|
||||||
|
x: cellPort.x + node.x,
|
||||||
|
y: cellPort.y + node.y + 0.5, // 0.5 是为了线宽
|
||||||
|
width: cellPort.width,
|
||||||
|
height: cellPort.height,
|
||||||
|
text: '',
|
||||||
|
r: 3.5
|
||||||
|
});
|
||||||
|
|
||||||
|
this.crossId ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const data = this.data;
|
||||||
|
const id2manager = this.id2manager;
|
||||||
|
const _this = this;
|
||||||
|
|
||||||
|
let connectionSelections = this.parentSelection.selectAll('circle')
|
||||||
|
.data(data)
|
||||||
|
.enter()
|
||||||
|
.append('circle')
|
||||||
|
.attr('cx', data => data.x)
|
||||||
|
.attr('cy', data => data.y)
|
||||||
|
.attr('width', data => data.width)
|
||||||
|
.attr('height', data => data.height)
|
||||||
|
|
||||||
|
if (globalSetting.renderAnimation) {
|
||||||
|
connectionSelections = connectionSelections
|
||||||
|
.transition()
|
||||||
|
.duration(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
connectionSelections
|
||||||
|
.attr('fill', 'var(--cross-dot-color)')
|
||||||
|
.attr('r', d => d.r)
|
||||||
|
.each(function (data) {
|
||||||
|
const selection = d3.select(this);
|
||||||
|
const manager = _this.createDataManager(selection, data);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.selections = connectionSelections;
|
||||||
|
return connectionSelections;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {d3.Selection} selection
|
||||||
|
* @param {BasicD3DataItem} data
|
||||||
|
* @returns {BasicD3ManagmentItem}
|
||||||
|
*/
|
||||||
|
createDataManager(selection, data) {
|
||||||
|
const id2manager = this.id2manager;
|
||||||
|
// connection 不需要拖拽上下文
|
||||||
|
const managerItem = {
|
||||||
|
data,
|
||||||
|
selection,
|
||||||
|
type: 'connection'
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!id2manager.has(data.id)) {
|
||||||
|
id2manager.set(data.id, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
id2manager.get(data.id).push(managerItem);
|
||||||
|
return managerItem;
|
||||||
|
}
|
||||||
|
}
|
@ -57,7 +57,6 @@ export class InstantiationRender {
|
|||||||
name: node.name,
|
name: node.name,
|
||||||
width: node.width,
|
width: node.width,
|
||||||
height: node.height,
|
height: node.height,
|
||||||
fill: 'var(--instance-fill-color)',
|
|
||||||
text: node.renderName,
|
text: node.renderName,
|
||||||
portnames,
|
portnames,
|
||||||
rx: 3,
|
rx: 3,
|
||||||
@ -202,7 +201,7 @@ export class InstantiationRender {
|
|||||||
.duration(1000)
|
.duration(1000)
|
||||||
.attr('fill', d => {
|
.attr('fill', d => {
|
||||||
const children = d._self.children || [];
|
const children = d._self.children || [];
|
||||||
return children.length > 0 ? 'rgba(203, 129, 218, 0.1)' : d.fill;
|
return children.length > 0 ? 'rgba(203, 129, 218, 0.1)' : 'var(--instance-fill-color)';
|
||||||
})
|
})
|
||||||
.attr('stroke', 'var(--instance-color)')
|
.attr('stroke', 'var(--instance-color)')
|
||||||
.attr('stroke-width', 2);
|
.attr('stroke-width', 2);
|
||||||
@ -211,7 +210,7 @@ export class InstantiationRender {
|
|||||||
instances
|
instances
|
||||||
.attr('fill', d => {
|
.attr('fill', d => {
|
||||||
const children = d._self.children || [];
|
const children = d._self.children || [];
|
||||||
return children.length > 0 ? 'rgba(203, 129, 218, 0.1)' : d.fill;
|
return children.length > 0 ? 'rgba(203, 129, 218, 0.1)' : 'var(--instance-fill-color)';
|
||||||
})
|
})
|
||||||
.attr('stroke', 'var(--instance-color)')
|
.attr('stroke', 'var(--instance-color)')
|
||||||
.attr('stroke-width', 2)
|
.attr('stroke-width', 2)
|
||||||
|
@ -36,7 +36,6 @@ export class PortRender {
|
|||||||
y: node.y,
|
y: node.y,
|
||||||
width: node.width,
|
width: node.width,
|
||||||
height: node.height,
|
height: node.height,
|
||||||
fill: 'var(--port-fill-color)',
|
|
||||||
text: node.renderName,
|
text: node.renderName,
|
||||||
rx: 3,
|
rx: 3,
|
||||||
ry: 3
|
ry: 3
|
||||||
@ -59,7 +58,7 @@ export class PortRender {
|
|||||||
let ports = portSelections.append('rect')
|
let ports = portSelections.append('rect')
|
||||||
.attr('width', data => data.width)
|
.attr('width', data => data.width)
|
||||||
.attr('height', data => data.height)
|
.attr('height', data => data.height)
|
||||||
.attr('fill', d => d.fill);
|
.attr('fill', 'var(--port-fill-color)');
|
||||||
|
|
||||||
let texts = portSelections.append('text')
|
let texts = portSelections.append('text')
|
||||||
.attr('x', data => data.width / 2) // 文本的 x 坐标(居中)
|
.attr('x', data => data.width / 2) // 文本的 x 坐标(居中)
|
||||||
|
@ -37,8 +37,7 @@ export class WireRender {
|
|||||||
y1: points[i].y,
|
y1: points[i].y,
|
||||||
x2: points[i + 1].x,
|
x2: points[i + 1].x,
|
||||||
y2: points[i + 1].y,
|
y2: points[i + 1].y,
|
||||||
strokeWidth: 2,
|
strokeWidth: 2
|
||||||
color: 'var(--wire-color)'
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,7 +55,7 @@ export class WireRender {
|
|||||||
.attr('y1', data => data.y1)
|
.attr('y1', data => data.y1)
|
||||||
.attr('x2', data => data.x2)
|
.attr('x2', data => data.x2)
|
||||||
.attr('y2', data => data.y2)
|
.attr('y2', data => data.y2)
|
||||||
.attr('stroke', data => data.color);
|
.attr('stroke', 'var(--wire-color)');
|
||||||
|
|
||||||
if (globalSetting.renderAnimation) {
|
if (globalSetting.renderAnimation) {
|
||||||
lineSelections = lineSelections
|
lineSelections = lineSelections
|
||||||
|
@ -23,5 +23,6 @@
|
|||||||
"common.line": "خط",
|
"common.line": "خط",
|
||||||
"common.port": "المنفذ",
|
"common.port": "المنفذ",
|
||||||
"common.instance": "تجهيز الوحدة",
|
"common.instance": "تجهيز الوحدة",
|
||||||
"setting.general-color-setting": "إعدادات الألوان العامة"
|
"setting.general-color-setting": "إعدادات الألوان العامة",
|
||||||
|
"cross-dot": "تقاطع"
|
||||||
}
|
}
|
@ -23,5 +23,6 @@
|
|||||||
"common.line": "Linie",
|
"common.line": "Linie",
|
||||||
"common.port": "Port",
|
"common.port": "Port",
|
||||||
"common.instance": "Modul instanziieren",
|
"common.instance": "Modul instanziieren",
|
||||||
"setting.general-color-setting": "Allgemeine Farbeinstellungen"
|
"setting.general-color-setting": "Allgemeine Farbeinstellungen",
|
||||||
|
"cross-dot": "Kreuzung"
|
||||||
}
|
}
|
@ -23,5 +23,6 @@
|
|||||||
"common.line": "line",
|
"common.line": "line",
|
||||||
"common.port": "Port",
|
"common.port": "Port",
|
||||||
"common.instance": "Instantiate module",
|
"common.instance": "Instantiate module",
|
||||||
"setting.general-color-setting": "General Color Settings"
|
"setting.general-color-setting": "General Color Settings",
|
||||||
|
"cross-dot": "Intersection"
|
||||||
}
|
}
|
@ -23,5 +23,6 @@
|
|||||||
"common.line": "ligne",
|
"common.line": "ligne",
|
||||||
"common.port": "Port",
|
"common.port": "Port",
|
||||||
"common.instance": "Instancier le module",
|
"common.instance": "Instancier le module",
|
||||||
"setting.general-color-setting": "Paramètres de couleur généraux"
|
"setting.general-color-setting": "Paramètres de couleur généraux",
|
||||||
|
"cross-dot": "Intersection"
|
||||||
}
|
}
|
@ -23,5 +23,6 @@
|
|||||||
"common.line": "線",
|
"common.line": "線",
|
||||||
"common.port": "ポート",
|
"common.port": "ポート",
|
||||||
"common.instance": "モジュールのインスタンス化",
|
"common.instance": "モジュールのインスタンス化",
|
||||||
"setting.general-color-setting": "一般的な色設定"
|
"setting.general-color-setting": "一般的な色設定",
|
||||||
|
"cross-dot": "交差点"
|
||||||
}
|
}
|
@ -23,5 +23,6 @@
|
|||||||
"common.line": "선",
|
"common.line": "선",
|
||||||
"common.port": "포트",
|
"common.port": "포트",
|
||||||
"common.instance": "모듈 인스턴스화",
|
"common.instance": "모듈 인스턴스화",
|
||||||
"setting.general-color-setting": "일반 색상 설정"
|
"setting.general-color-setting": "일반 색상 설정",
|
||||||
|
"cross-dot": "교차로"
|
||||||
}
|
}
|
@ -23,5 +23,6 @@
|
|||||||
"common.line": "линия",
|
"common.line": "линия",
|
||||||
"common.port": "Порт",
|
"common.port": "Порт",
|
||||||
"common.instance": "Создание экземпляра модуля",
|
"common.instance": "Создание экземпляра модуля",
|
||||||
"setting.general-color-setting": "Общие настройки цвета"
|
"setting.general-color-setting": "Общие настройки цвета",
|
||||||
|
"cross-dot": "Перекресток"
|
||||||
}
|
}
|
@ -23,5 +23,6 @@
|
|||||||
"common.line": "线",
|
"common.line": "线",
|
||||||
"common.port": "端口",
|
"common.port": "端口",
|
||||||
"common.instance": "例化模块",
|
"common.instance": "例化模块",
|
||||||
"setting.general-color-setting": "通用颜色设置"
|
"setting.general-color-setting": "通用颜色设置",
|
||||||
|
"cross-dot": "交叉点"
|
||||||
}
|
}
|
@ -23,5 +23,6 @@
|
|||||||
"common.line": "線",
|
"common.line": "線",
|
||||||
"common.port": "端口",
|
"common.port": "端口",
|
||||||
"common.instance": "實例化模組",
|
"common.instance": "實例化模組",
|
||||||
"setting.general-color-setting": "通用顏色設定"
|
"setting.general-color-setting": "通用顏色設定",
|
||||||
|
"cross-dot": "交叉點"
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user