Sidebar-Engine.js 2.52 KB

(function () {
	// Adds Atlassian shapes
	// engine 发动机
	Sidebar.prototype.addEnginePalette = function () {
		const { COMPONENT_TYPE } = this.enumCellBasicAttribute
		const { DEFAULT } = this.enumComponentType
		const gn = 'mxgraph.engine';
		const dt = 'engine';
		const label = '发动机'
		const width = 66;
		const height = 74;
		const staticPath = `${Proxy_Prefix}/img/lib/thingskit/`
		const prefix = 'image;image=img/lib/thingskit/'
		const defaultStyle = ';imageAspect=0;'
		this.setCurrentSearchEntryLibrary(dt);

		// 自定义属性
		const cellAttribute = {
			[COMPONENT_TYPE]: DEFAULT
		}

		const graphPathLib = [
			{ name: '3-D 发动机.svg', path: 'engine/3-D 发动机.svg' },
			{ name: '伺服电机.svg', path: 'engine/伺服电机.svg' },
			{ name: '伺服电机2.svg', path: 'engine/伺服电机2.svg' },
			{ name: '促动器.svg', path: 'engine/促动器.svg' },
			{ name: '减速器.svg', path: 'engine/减速器.svg' },
			{ name: '制动马达.svg', path: 'engine/制动马达.svg' },
			{ name: '发动机 1.svg', path: 'engine/发动机 1.svg' },
			{ name: '发动机 2.svg', path: 'engine/发动机 2.svg' },
			{ name: '发动机 3.svg', path: 'engine/发动机 3.svg' },
			{ name: '发动机 4.svg', path: 'engine/发动机 4.svg' },
			{ name: '工业标准发动机.svg', path: 'engine/工业标准发动机.svg' },
			{ name: '无刷电机.svg', path: 'engine/无刷电机.svg' },
			{ name: '智能马达.svg', path: 'engine/智能马达.svg' },
			{ name: '步进电机驱动器.svg', path: 'engine/步进电机驱动器.svg' },
			{ name: '气压制动器.svg', path: 'engine/气压制动器.svg' },
			{ name: '简单马达.svg', path: 'engine/简单马达.svg' },
			{ name: '轴角编码器.svg', path: 'engine/轴角编码器.svg' },
			{ name: '防爆电动机.svg', path: 'engine/防爆电动机.svg' },
		]

		const lib = graphPathLib.map(item => {
			item.staticPath = staticPath + item.path
			return item
		})

		const fns = graphPathLib.map(item => {
			return this.addEntry(this.getTagsForStencil(gn, item.name, dt).join(' '), mxUtils.bind(this, function () {
				const cell = new mxCell('', new mxGeometry(0, 0, width, height), `${prefix}${item.path}${defaultStyle}`);
				cell.setVertex(true)
				this.setCellAttributes(cell, cellAttribute)
				return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, item.name);
			}));
		})

		this.setVariableImageLib(dt, label, lib)

		this.addPaletteFunctions(dt, label, false, fns);

		this.setCurrentSearchEntryLibrary();
	};
})();