-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsld-viewer.ts
91 lines (74 loc) · 1.9 KB
/
sld-viewer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { LitElement, css, html } from 'lit';
import { customElement, property, query } from 'lit/decorators.js';
import { attributes, svgNs, xlinkNs } from './foundation/sldUtil.js';
import { sldSvg } from './foundation/sldSvg.js';
@customElement('sld-viewer')
export class SldViewer extends LitElement {
@property({ attribute: false })
substation!: Element;
@property({ type: Number })
gridSize!: number;
@query('svg#sldContainer')
sld!: SVGGraphicsElement;
@query('#container') container!: HTMLDivElement;
@property({ attribute: false })
parent?: Element;
@property({ attribute: false })
linked: Element[] = [];
@property({ attribute: false })
unmapped: Element[] = [];
render() {
const {
dim: [w, h],
} = attributes(this.substation);
return html`<div id="container">
<svg
xmlns="${svgNs}"
xmlns:xlink="${xlinkNs}"
viewBox="0 0 ${w} ${h}"
width="${w * this.gridSize}"
height="${h * this.gridSize}"
id="sldContainer"
stroke-width="0.06"
fill="none"
>
${sldSvg(this.substation, {
gridSize: this.gridSize,
editMode: true,
parent: this.parent,
linked: this.linked,
unmapped: this.unmapped,
})}
</svg>
</div>`;
}
static styles = css`
#container {
width: 100%;
height: 80vh;
overflow: scroll;
background-color: white;
}
g.equipment:not(.linked):not(.source):not(.selsource) {
opacity: 0.2;
}
g.label:not(.ied):not(.linked):not(.source):not(.selsource) {
opacity: 0.2;
}
.filter.box > mwc-textfield {
padding: 10px;
}
.linked > rect {
fill: red;
opacity: 0.1;
}
.unmapped > rect {
fill: var(--oscd-secondary);
opacity: 0.1;
}
.parent > rect {
fill: var(--oscd-primary);
opacity: 0.1;
}
`;
}