Blame view

HHECS.Web/src/components/MapModule/flow/graph/shape.js 24.7 KB
胡菁 authored
1
import { Dom, Graph, Node } from "@antv/x6";
胡菁 authored
2
3
4
5
6
7
8
9
import {
  conveyor,
  direction,
  one_track,
  pallet,
  rgv,
  stacker,
  storage,
胡菁 authored
10
11
12
13
14
15
16
  two_track,
  point,
  point_left,
  point_up,
  point_right,
  point_down,
  charging,
胡菁 authored
17
  hoist,
18
  shuttleCar,
胡菁 authored
19
20
} from "./images";
import { basicPorts, customPorts } from "./ports";
胡菁 authored
21
胡菁 authored
22
23
export const SRM = Graph.registerNode("SRM", {
  inherit: "image",
胡菁 authored
24
25
26
27
  width: 40,
  height: 40,
  attrs: {
    image: {
胡菁 authored
28
      "xlink:href": stacker,
胡菁 authored
29
30
31
      height: 40,
      x: 0,
      y: 0,
胡菁 authored
32
33
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
胡菁 authored
34
    },
胡菁 authored
35
    imagePallet: {
胡菁 authored
36
      "xlink:href": pallet,
胡菁 authored
37
38
      height: 40,
      width: 40,
胡菁 authored
39
40
41
      class: "hide-pallet",
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
胡菁 authored
42
43
44
    },
    body: {
      // stroke: '#5F95FF',
胡菁 authored
45
      stroke: "#FF0000",
胡菁 authored
46
      strokeWidth: 3,
胡菁 authored
47
      fill: "rgba(95,149,255,0.0001)",
胡菁 authored
48
49
50
      // fill: 'rgba(255,0,0,1)',
      height: 0,
      width: 0,
胡菁 authored
51
      class: "flash-shrink-animation-close",
胡菁 authored
52
    },
胡菁 authored
53
    textCode: {
胡菁 authored
54
55
      class: "animate-text1",
      text: "",
胡菁 authored
56
      fontSize: 8,
胡菁 authored
57
58
      fill: "#000000",
      stroke: "#000000",
胡菁 authored
59
60
      strokeWidth: 1,
      x: 0,
胡菁 authored
61
62
      y: -5,
    },
胡菁 authored
63
64
65
    // text: {
    //   stroke: '#FF0000',
    //   strokeWidth: 1,
胡菁 authored
66
67
68
    //   class: 'animate-text1',
    //   text: '堆垛机',
    //   fontSize: 12,
胡菁 authored
69
70
71
    //   fill: '#FF0000',
    //   fillOpacity: 0.8,
    //   background: {
胡菁 authored
72
    //     fill: '#FFFF00',
胡菁 authored
73
    //   }
胡菁 authored
74
75
    // }
  },
胡菁 authored
76
  markup: [
胡菁 authored
77
    {
胡菁 authored
78
79
      tagName: "image",
      selector: "image",
胡菁 authored
80
81
    },
    {
胡菁 authored
82
83
      tagName: "image",
      selector: "imagePallet",
胡菁 authored
84
85
    },
    {
胡菁 authored
86
87
      tagName: "rect",
      selector: "body",
胡菁 authored
88
    },
胡菁 authored
89
    {
胡菁 authored
90
91
92
93
94
      tagName: "text",
      selector: "textCode",
    },
  ],
});
胡菁 authored
95
胡菁 authored
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
export const Hoist = Graph.registerNode("Hoist", {
  inherit: "image",
  width: 40,
  height: 40,
  attrs: {
    image: {
      "xlink:href": hoist,
      height: 40,
      x: 0,
      y: 0,
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
    },
    imagePallet: {
      "xlink:href": pallet,
      height: 40,
      width: 40,
      class: "hide-pallet",
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
    },
    body: {
      // stroke: '#5F95FF',
      stroke: "#FF0000",
      strokeWidth: 3,
      fill: "rgba(95,149,255,0.0001)",
      // fill: 'rgba(255,0,0,1)',
      height: 0,
      width: 0,
      class: "flash-shrink-animation-close",
    },
    textCode: {
      class: "animate-text1",
      text: "",
      fontSize: 8,
      fill: "#000000",
      stroke: "#000000",
      strokeWidth: 1,
      x: 0,
      y: -5,
    },
  },
  markup: [
    {
      tagName: "image",
      selector: "image",
    },
    {
      tagName: "image",
      selector: "imagePallet",
    },
    {
      tagName: "rect",
      selector: "body",
    },
    {
      tagName: "text",
      selector: "textCode",
    },
  ],
});
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
export const ShuttleCar = Graph.registerNode("ShuttleCar", {
  inherit: "image",
  width: 40,
  height: 40,
  attrs: {
    image: {
      "xlink:href": shuttleCar,
      height: 40,
      x: 0,
      y: 0,
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
    },
    imagePallet: {
      "xlink:href": pallet,
      height: 40,
      width: 40,
      class: "hide-pallet",
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
    },
    body: {
      stroke: "#FF0000",
      strokeWidth: 3,
      fill: "rgba(95,149,255,0.0001)",
      height: 0,
      width: 0,
      class: "flash-shrink-animation-close",
    },
    textCode: {
      class: "animate-text1",
      text: "",
      fontSize: 8,
      fill: "#000000",
      stroke: "#000000",
      strokeWidth: 1,
      x: 5,
      y: 20,
    },
  },
  markup: [
    {
      tagName: "image",
      selector: "image",
    },
    {
      tagName: "image",
      selector: "imagePallet",
    },
    {
      tagName: "rect",
      selector: "body",
    },
    {
      tagName: "text",
      selector: "textCode",
    },
  ],
});
胡菁 authored
218
219
export const RGV = Graph.registerNode("RGV", {
  inherit: "image",
胡菁 authored
220
221
222
223
  width: 40,
  height: 40,
  attrs: {
    image: {
胡菁 authored
224
      "xlink:href": rgv,
胡菁 authored
225
226
227
      height: 40,
      x: 0,
      y: 0,
胡菁 authored
228
229
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
胡菁 authored
230
231
    },
    imagePallet: {
胡菁 authored
232
      "xlink:href": pallet,
胡菁 authored
233
234
      height: 40,
      width: 40,
胡菁 authored
235
236
237
      class: "hide-pallet",
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
胡菁 authored
238
239
    },
    body: {
胡菁 authored
240
      stroke: "#FF0000",
胡菁 authored
241
      strokeWidth: 3,
胡菁 authored
242
      fill: "rgba(95,149,255,0.0001)",
胡菁 authored
243
244
      height: 0,
      width: 0,
胡菁 authored
245
      class: "flash-shrink-animation-close",
胡菁 authored
246
    },
胡菁 authored
247
    textCode: {
胡菁 authored
248
249
      class: "animate-text1",
      text: "",
胡菁 authored
250
      fontSize: 8,
胡菁 authored
251
252
      fill: "#000000",
      stroke: "#000000",
胡菁 authored
253
254
      strokeWidth: 1,
      x: 5,
胡菁 authored
255
256
      y: 20,
    },
胡菁 authored
257
  },
胡菁 authored
258
  markup: [
胡菁 authored
259
    {
胡菁 authored
260
261
      tagName: "image",
      selector: "image",
胡菁 authored
262
263
    },
    {
胡菁 authored
264
265
      tagName: "image",
      selector: "imagePallet",
胡菁 authored
266
267
    },
    {
胡菁 authored
268
269
      tagName: "rect",
      selector: "body",
胡菁 authored
270
    },
胡菁 authored
271
    {
胡菁 authored
272
273
274
275
276
      tagName: "text",
      selector: "textCode",
    },
  ],
});
胡菁 authored
277
胡菁 authored
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
export const Point = Graph.registerNode("Point", {
  inherit: "image",
  width: 40,
  height: 40,
  attrs: {
    image: {
      "xlink:href": point,
      height: 40,
      x: 0,
      y: 0,
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
    },
    imageLeft: {
      "xlink:href": point_left,
      height: 40,
      width: 40,
      class: "hide-pallet",
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
    },
    imageUp: {
      "xlink:href": point_up,
      height: 40,
      width: 40,
      class: "hide-pallet",
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
    },
    imageRight: {
      "xlink:href": point_right,
      height: 40,
      width: 40,
      class: "hide-pallet",
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
    },
    imageDown: {
      "xlink:href": point_down,
      height: 40,
      width: 40,
      class: "hide-pallet",
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
    },
胡菁 authored
323
    body1: {
胡菁 authored
324
      stroke: "#FF0000",
胡菁 authored
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
      fill: "#FF0000",
      strokeWidth: 1,
      // fill: "rgba(95,149,255,0.2)",
      height: 5,
      width: 5,
      x: 1,
      y: 1,
      class: "flash-shrink-animation-close",
    },
    body2: {
      stroke: "#007F19",
      fill: "#007F19",
      strokeWidth: 1,
      // fill: "rgba(95,149,255,0.0001)",
      height: 5,
      width: 5,
      x: 7.5,
      y: 0.5,
      class: "flash-shrink-animation-close",
    },
    body3: {
      stroke: "#0000FF",
      fill: "#0000FF",
      strokeWidth: 1,
      // fill: "rgba(95,149,255,0.0001)",
      height: 5,
      width: 5,
      x: 14,
      y: 0.5,
      class: "flash-shrink-animation-close",
    },
    body4: {
      stroke: "#FF9900",
      fill: "#FF9900",
      strokeWidth: 1,
      // fill: "rgba(95,149,255,0.0001)",
      height: 5,
      width: 5,
      x: 20.5,
      y: 0.5,
      class: "flash-shrink-animation-close",
    },
    body5: {
      stroke: "#4C4C4C",
      fill: "#4C4C4C",
      strokeWidth: 1,
      // fill: "rgba(95,149,255,0.0001)",
      height: 5,
      width: 5,
      x: 27,
      y: 0.5,
      class: "flash-shrink-animation-close",
    },
    body6: {
      stroke: "#FF00FF",
      fill: "#FF00FF",
      strokeWidth: 1,
      // fill: "rgba(95,149,255,0.0001)",
      height: 5,
      width: 5,
      x: 33.5,
      y: 0.5,
胡菁 authored
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
      class: "flash-shrink-animation-close",
    },
    text: {
      class: "animate-text1",
      fontSize: 12,
      // fill: '#5F95FF',
      // fill: '#0000FF',
      fill: "#5F95FF",
    },
    textCode: {
      class: "animate-text1",
      text: "",
      fontSize: 8,
      fill: "#000000",
      stroke: "#000000",
      strokeWidth: 1,
      x: 5,
      y: 20,
    },
  },
  markup: [
    {
      tagName: "image",
      selector: "image",
    },
    {
      tagName: "image",
      selector: "imageLeft",
    },
    {
      tagName: "image",
      selector: "imageUp",
    },
    {
      tagName: "image",
      selector: "imageRight",
    },
    {
      tagName: "image",
      selector: "imageDown",
    },
    {
      tagName: "rect",
胡菁 authored
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
      selector: "body1",
    },
    {
      tagName: "rect",
      selector: "body2",
    },
    {
      tagName: "rect",
      selector: "body3",
    },
    {
      tagName: "rect",
      selector: "body4",
    },
    {
      tagName: "rect",
      selector: "body5",
    },
    {
      tagName: "rect",
      selector: "body6",
胡菁 authored
451
452
453
454
455
456
457
458
459
460
461
462
463
464
    },
    {
      tagName: "text",
      selector: "text",
    },
    {
      tagName: "text",
      selector: "textCode",
    },
  ],
});

export const Station = Graph.registerNode("Station", {
  inherit: "image",
胡菁 authored
465
466
467
468
  width: 60,
  height: 60,
  attrs: {
    image: {
胡菁 authored
469
      "xlink:href": conveyor,
胡菁 authored
470
471
472
      height: 60,
      x: 0,
      y: 0,
胡菁 authored
473
474
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
胡菁 authored
475
    },
胡菁 authored
476
    imagePallet: {
胡菁 authored
477
      "xlink:href": pallet,
胡菁 authored
478
479
      height: 40,
      width: 40,
胡菁 authored
480
481
482
      class: "hide-pallet",
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
胡菁 authored
483
    },
胡菁 authored
484
    body: {
胡菁 authored
485
      stroke: "#FF0000",
胡菁 authored
486
      strokeWidth: 3,
胡菁 authored
487
      fill: "rgba(95,149,255,0.0001)",
胡菁 authored
488
489
      height: 0,
      width: 0,
胡菁 authored
490
      class: "flash-shrink-animation-close",
胡菁 authored
491
492
    },
    text: {
胡菁 authored
493
      class: "animate-text1",
胡菁 authored
494
495
      fontSize: 12,
      // fill: '#5F95FF',
胡菁 authored
496
      // fill: '#0000FF',
胡菁 authored
497
      fill: "#5F95FF",
胡菁 authored
498
499
    },
    textCode: {
胡菁 authored
500
501
      class: "animate-text1",
      text: "",
胡菁 authored
502
      fontSize: 8,
胡菁 authored
503
504
      fill: "#000000",
      stroke: "#000000",
胡菁 authored
505
506
      strokeWidth: 1,
      x: 15,
胡菁 authored
507
508
      y: 20,
    },
胡菁 authored
509
510
511
  },
  markup: [
    {
胡菁 authored
512
513
      tagName: "image",
      selector: "image",
胡菁 authored
514
515
    },
    {
胡菁 authored
516
517
      tagName: "image",
      selector: "imagePallet",
胡菁 authored
518
519
    },
    {
胡菁 authored
520
521
      tagName: "rect",
      selector: "body",
胡菁 authored
522
523
    },
    {
胡菁 authored
524
525
      tagName: "rect",
      selector: "textBackground",
胡菁 authored
526
527
    },
    {
胡菁 authored
528
529
      tagName: "text",
      selector: "text",
胡菁 authored
530
531
    },
    {
胡菁 authored
532
533
534
535
536
      tagName: "text",
      selector: "textCode",
    },
  ],
});
胡菁 authored
537
胡菁 authored
538
539
export const Station_D = Graph.registerNode("Station-D", {
  inherit: "image",
胡菁 authored
540
541
542
543
  width: 60,
  height: 60,
  attrs: {
    image: {
胡菁 authored
544
      "xlink:href": direction,
胡菁 authored
545
546
547
      height: 60,
      x: 0,
      y: 0,
胡菁 authored
548
549
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
胡菁 authored
550
    },
胡菁 authored
551
    imagePallet: {
胡菁 authored
552
      "xlink:href": pallet,
胡菁 authored
553
554
      height: 40,
      width: 40,
胡菁 authored
555
556
557
      class: "hide-pallet",
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
胡菁 authored
558
    },
胡菁 authored
559
    body: {
胡菁 authored
560
      stroke: "#FF0000",
胡菁 authored
561
      strokeWidth: 3,
胡菁 authored
562
      fill: "rgba(95,149,255,0.0001)",
胡菁 authored
563
564
      height: 0,
      width: 0,
胡菁 authored
565
      class: "flash-shrink-animation-close",
胡菁 authored
566
567
    },
    text: {
胡菁 authored
568
569
      class: "animate-text1",
      text: "",
胡菁 authored
570
571
      fontSize: 12,
      // fill: '#5F95FF',
胡菁 authored
572
      // fill: '#0000FF',
胡菁 authored
573
      fill: "#5F95FF",
胡菁 authored
574
575
    },
    textCode: {
胡菁 authored
576
577
      class: "animate-text1",
      text: "",
胡菁 authored
578
      fontSize: 8,
胡菁 authored
579
580
      fill: "#000000",
      stroke: "#000000",
胡菁 authored
581
582
      strokeWidth: 1,
      x: 2,
胡菁 authored
583
584
      y: 20,
    },
胡菁 authored
585
586
587
  },
  markup: [
    {
胡菁 authored
588
589
      tagName: "image",
      selector: "image",
胡菁 authored
590
591
    },
    {
胡菁 authored
592
593
      tagName: "image",
      selector: "imagePallet",
胡菁 authored
594
595
    },
    {
胡菁 authored
596
597
      tagName: "rect",
      selector: "body",
胡菁 authored
598
599
    },
    {
胡菁 authored
600
601
      tagName: "text",
      selector: "text",
胡菁 authored
602
603
    },
    {
胡菁 authored
604
605
606
607
608
      tagName: "text",
      selector: "textCode",
    },
  ],
});
胡菁 authored
609
胡菁 authored
610
611
export const Storage = Graph.registerNode("Storage", {
  inherit: "image",
胡菁 authored
612
613
614
  width: 60,
  height: 60,
  attrs: {
胡菁 authored
615
    image: {
胡菁 authored
616
      "xlink:href": storage,
胡菁 authored
617
618
619
      height: 60,
      x: 0,
      y: 0,
胡菁 authored
620
621
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
胡菁 authored
622
    },
胡菁 authored
623
    body: {
胡菁 authored
624
      stroke: "#5F95FF",
胡菁 authored
625
      strokeWidth: 1,
胡菁 authored
626
      fill: "rgba(95,149,255,0.05)",
王平 authored
627
      height: 40,
胡菁 authored
628
      width: 40,
胡菁 authored
629
630
    },
    text: {
胡菁 authored
631
632
      class: "animate-text1",
      text: "1",
胡菁 authored
633
      fontSize: 12,
胡菁 authored
634
      fill: "#5F95FF",
胡菁 authored
635
      // fill: '#0000FF',
胡菁 authored
636
    },
胡菁 authored
637
638
639
  },
  markup: [
    {
胡菁 authored
640
641
      tagName: "image",
      selector: "image",
胡菁 authored
642
    },
胡菁 authored
643
    {
胡菁 authored
644
645
      tagName: "rect",
      selector: "body",
胡菁 authored
646
    },
胡菁 authored
647
    {
胡菁 authored
648
649
650
651
652
      tagName: "text",
      selector: "text",
    },
  ],
});
胡菁 authored
653
胡菁 authored
654
655
export const Charging = Graph.registerNode("Charging", {
  inherit: "image",
胡菁 authored
656
657
658
659
  width: 40,
  height: 40,
  attrs: {
    image: {
胡菁 authored
660
      "xlink:href": charging,
胡菁 authored
661
662
663
      height: 40,
      x: 0,
      y: 0,
胡菁 authored
664
665
666
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
    },
胡菁 authored
667
668
669
  },
  markup: [
    {
胡菁 authored
670
671
672
673
674
      tagName: "image",
      selector: "image",
    },
  ],
});
胡菁 authored
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
export const Pallet = Graph.registerNode("Pallet", {
  inherit: "image",
  width: 40,
  height: 40,
  attrs: {
    image: {
      "xlink:href": pallet,
      height: 40,
      x: 0,
      y: 0,
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
    },
  },
  markup: [
    {
      tagName: "image",
      selector: "image",
    },
  ],
});
胡菁 authored
698
699
export const OneTrack = Graph.registerNode("OneTrack", {
  inherit: "image",
胡菁 authored
700
701
702
703
  width: 40,
  height: 40,
  attrs: {
    image: {
胡菁 authored
704
      "xlink:href": one_track,
胡菁 authored
705
706
707
      height: 40,
      x: 0,
      y: 0,
胡菁 authored
708
709
710
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
    },
胡菁 authored
711
712
713
  },
  markup: [
    {
胡菁 authored
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
      tagName: "image",
      selector: "image",
    },
  ],
});

export const TwoTrack = Graph.registerNode("TwoTrack", {
  inherit: "image",
  width: 40,
  height: 40,
  attrs: {
    image: {
      "xlink:href": two_track,
      height: 40,
      x: 0,
      y: 0,
      preserveAspectRatio: "none",
      "vector-effect": "non-scaling-stroke",
    },
  },
  markup: [
    {
      tagName: "image",
      selector: "image",
    },
  ],
});
胡菁 authored
741
胡菁 authored
742
743
744
745
746
747
export const Text = Graph.registerNode("Text", {
  inherit: "rect",
  width: 200,
  height: 60,
  attrs: {
    body: {
748
749
750
      //   stroke: "#5F95FF",
      strokeWidth: 0,
      fill: "rgba(95,149,255,0)",
胡菁 authored
751
752
    },
    text: {
753
      class: "animate-text2",
胡菁 authored
754
      text: "44444",
755
      fontSize: 22,
胡菁 authored
756
757
758
      fill: "#5F95FF",
    },
    // text2: {
759
760
761
762
    //   class: "animate-text2",
    //   text: "AntV X6",
    //   fontSize: 32,
    // },
胡菁 authored
763
764
765
766
767
768
769
770
771
772
773
  },
  markup: [
    {
      tagName: "rect",
      selector: "body",
    },
    {
      tagName: "text",
      selector: "text",
    },
    // {
774
775
776
    //   tagName: "text",
    //   selector: "text2",
    // },
胡菁 authored
777
778
779
  ],
});
胡菁 authored
780
// 基础节点
胡菁 authored
781
782
export const FlowChartRect = Graph.registerNode("flow-chart-rect", {
  inherit: "rect",
胡菁 authored
783
784
785
786
  width: 80,
  height: 42,
  attrs: {
    body: {
胡菁 authored
787
      stroke: "#5F95FF",
胡菁 authored
788
      strokeWidth: 1,
胡菁 authored
789
      fill: "#ffffff",
胡菁 authored
790
791
    },
    fo: {
胡菁 authored
792
793
      refWidth: "100%",
      refHeight: "100%",
胡菁 authored
794
795
796
797
    },
    foBody: {
      xmlns: Dom.ns.xhtml,
      style: {
胡菁 authored
798
799
800
801
802
803
804
805
806
807
        width: "100%",
        height: "100%",
        display: "flex",
        justifyContent: "center",
        alignItems: "center",
      },
    },
    "edit-text": {
      contenteditable: "true",
      class: "x6-edit-text",
胡菁 authored
808
      style: {
胡菁 authored
809
810
        width: "100%",
        textAlign: "center",
胡菁 authored
811
        fontSize: 12,
胡菁 authored
812
813
        color: "rgba(0,0,0,0.85)",
      },
胡菁 authored
814
815
816
    },
    text: {
      fontSize: 12,
胡菁 authored
817
818
      fill: "#080808",
    },
胡菁 authored
819
820
821
  },
  markup: [
    {
胡菁 authored
822
823
      tagName: "rect",
      selector: "body",
胡菁 authored
824
825
    },
    {
胡菁 authored
826
827
828
      tagName: "text",
      selector: "text",
    },
胡菁 authored
829
    // 不让双击编辑文本
胡菁 authored
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
    // {
    //   tagName: 'foreignObject',
    //   selector: 'fo',
    //   children: [
    //     {
    //       ns: Dom.ns.xhtml,
    //       tagName: 'body',
    //       selector: 'foBody',
    //       children: [
    //         {
    //           tagName: 'div',
    //           selector: 'edit-text'
    //         }
    //       ]
    //     }
    //   ]
    // }
  ],
胡菁 authored
848
849
  ports: { ...basicPorts },
});
胡菁 authored
850
// 组合节点
胡菁 authored
851
852
export const FlowChartImageRect = Graph.registerNode("flow-chart-image-rect", {
  inherit: "rect",
胡菁 authored
853
854
855
856
  width: 200,
  height: 60,
  attrs: {
    body: {
胡菁 authored
857
      stroke: "#5F95FF",
胡菁 authored
858
      strokeWidth: 1,
胡菁 authored
859
      fill: "rgba(95,149,255,0.05)",
胡菁 authored
860
861
    },
    image: {
胡菁 authored
862
863
      "xlink:href":
        "https://gw.alipayobjects.com/zos/antfincdn/FLrTNDvlna/antv.png",
胡菁 authored
864
865
866
      width: 16,
      height: 16,
      x: 12,
胡菁 authored
867
      y: 12,
胡菁 authored
868
869
    },
    title: {
胡菁 authored
870
      text: "Node",
胡菁 authored
871
872
      refX: 40,
      refY: 14,
胡菁 authored
873
      fill: "rgba(0,0,0,0.85)",
胡菁 authored
874
      fontSize: 12,
胡菁 authored
875
      "text-anchor": "start",
胡菁 authored
876
877
    },
    text: {
胡菁 authored
878
      text: "this is content text",
胡菁 authored
879
880
881
      refX: 40,
      refY: 38,
      fontSize: 12,
胡菁 authored
882
883
884
      fill: "rgba(0,0,0,0.6)",
      "text-anchor": "start",
    },
胡菁 authored
885
886
887
  },
  markup: [
    {
胡菁 authored
888
889
      tagName: "rect",
      selector: "body",
胡菁 authored
890
891
    },
    {
胡菁 authored
892
893
      tagName: "image",
      selector: "image",
胡菁 authored
894
895
    },
    {
胡菁 authored
896
897
      tagName: "text",
      selector: "title",
胡菁 authored
898
899
    },
    {
胡菁 authored
900
901
902
      tagName: "text",
      selector: "text",
    },
胡菁 authored
903
  ],
胡菁 authored
904
905
  ports: { ...basicPorts },
});
胡菁 authored
906
胡菁 authored
907
908
export const FlowChartTitleRect = Graph.registerNode("flow-chart-title-rect", {
  inherit: "rect",
胡菁 authored
909
910
911
912
  width: 200,
  height: 68,
  attrs: {
    body: {
胡菁 authored
913
      stroke: "#5F95FF",
胡菁 authored
914
      strokeWidth: 1,
胡菁 authored
915
      fill: "rgba(95,149,255,0.05)",
胡菁 authored
916
917
    },
    head: {
胡菁 authored
918
919
      refWidth: "100%",
      stroke: "transparent",
胡菁 authored
920
      height: 28,
胡菁 authored
921
      fill: "rgb(95,149,255)",
胡菁 authored
922
923
    },
    image: {
胡菁 authored
924
925
      "xlink:href":
        "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAVCAYAAAAAY20CAAAJD0lEQVRIiV1XWXMU5xU9vffMSCPNjNCMVnbEIgG2cQpTIcaRUxW/UVR+Q/KYn4D4EY6f8563+MkJMTaJi0AEEhUsoRgZJKQZSWiZRTO9d+rcnh4raWhNL9937z3nrq188cUfoKkadF2HqqqIEQGxAiiQ+4P9faytrcee50FVFcRxjDCKMDg4iMmJiU903XgQhqE85z/wb/KDOI4QBmFXnAooMaAoFA3+VRReyQ65VhWVr7G910B9dxczzceIfQdr47MojB2HqcSIohiKyrXJXl1VNaiaioNGHe1WGxG1d403DA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ZXT7xsYG1tbW0Go1RRmN5J50COMzvuM+GnX5yhUxgmuYP/PzT8V7586dk7XUQSJSMClZpVJJ2K3VauIdeob608rW19cnZ35gAEOlEkxdh65p2g9MoNQgMsdfCqUyCrhz5w5u3rwp11yXsp+GA5+nbqURY2Njso6yGBYp0OnpaYyPj8skSq+wafE5CaFMgqQchiz3ERTv6eGzZ8+K7Ew2K3JLhaIMmLppGIuFYlFmoMPDw54hqXE8qJQsHDX46KF0Z3MaQcX0BO9JDD1JwyuVipz0NNeQEHri5MmTYiD1ci3Pa9euYWZmRp5RDtknONrAKOHZ398P13MZWsbf04rDBUR9FEB6TcHpkXbq/z8og55L537uoRFXrlwR2SdOnJB3NOj27dtJaewSln4o8Z5hwuskqTXZy9lL49m9lzzIZqHXW4dv/vHddwrZUrvdFQr+J0Ti3hitdEeHtAT9tBbdqpAe0qyiWJqdaRpfj41P3Mrm+nr7k/ziZ2ZKTNxLVILhDMRvknQi4HpOtCwKHN8FDHMg6Byitt6BnbVlwdHQOWrf0aP3CXhkTeqVLuReBeHHS6FQvLdT3bi1u12VhtcjqTuKpMBFd4+gLpm972XKZqjybwKq1Wrhv83+VyBYZY9VAAAAAElFTkSuQmCC",
胡菁 authored
926
927
      height: 16,
      x: 6,
胡菁 authored
928
      y: 6,
胡菁 authored
929
930
    },
    title: {
胡菁 authored
931
      text: "Node",
胡菁 authored
932
933
      refX: 30,
      refY: 9,
胡菁 authored
934
      fill: "#ffffff",
胡菁 authored
935
      fontSize: 12,
胡菁 authored
936
      "text-anchor": "start",
胡菁 authored
937
938
    },
    text: {
胡菁 authored
939
      text: "this is content text",
胡菁 authored
940
941
942
      refX: 8,
      refY: 45,
      fontSize: 12,
胡菁 authored
943
944
945
      fill: "rgba(0,0,0,0.6)",
      "text-anchor": "start",
    },
胡菁 authored
946
947
948
  },
  markup: [
    {
胡菁 authored
949
950
      tagName: "rect",
      selector: "body",
胡菁 authored
951
952
    },
    {
胡菁 authored
953
954
      tagName: "rect",
      selector: "head",
胡菁 authored
955
956
    },
    {
胡菁 authored
957
958
      tagName: "image",
      selector: "image",
胡菁 authored
959
960
    },
    {
胡菁 authored
961
962
      tagName: "text",
      selector: "title",
胡菁 authored
963
964
    },
    {
胡菁 authored
965
966
967
      tagName: "text",
      selector: "text",
    },
胡菁 authored
968
  ],
胡菁 authored
969
970
  ports: { ...basicPorts },
});
胡菁 authored
971
胡菁 authored
972
export const FlowChartAnimateText = Graph.registerNode(
胡菁 authored
973
  "flow-chart-animate-text",
胡菁 authored
974
  {
胡菁 authored
975
    inherit: "rect",
胡菁 authored
976
977
978
979
    width: 200,
    height: 60,
    attrs: {
      body: {
胡菁 authored
980
        stroke: "#5F95FF",
胡菁 authored
981
        strokeWidth: 1,
胡菁 authored
982
        fill: "rgba(95,149,255,0.05)",
胡菁 authored
983
984
      },
      text1: {
胡菁 authored
985
986
        class: "animate-text1",
        text: "|||||||||||||",
胡菁 authored
987
        fontSize: 50,
胡菁 authored
988
989
        fill: "#5F95FF",
      },
胡菁 authored
990
991
992
993
994
995
996
997
      // text2: {
      //   class: 'animate-text2',
      //   text: 'AntV X6',
      //   fontSize: 32
      // }
    },
    markup: [
      {
胡菁 authored
998
999
        tagName: "rect",
        selector: "body",
胡菁 authored
1000
1001
      },
      {
胡菁 authored
1002
1003
1004
        tagName: "text",
        selector: "text1",
      },
胡菁 authored
1005
1006
1007
1008
      // {
      //   tagName: 'text',
      //   selector: 'text2'
      // }
胡菁 authored
1009
    ],
胡菁 authored
1010
  }
胡菁 authored
1011
);
胡菁 authored
1012
1013

// 自定义 系统设计图
胡菁 authored
1014
export const FlowChartImageRectCustom = Graph.registerNode(
胡菁 authored
1015
  "flow-chart-image-rect-custom",
胡菁 authored
1016
  {
胡菁 authored
1017
    inherit: "rect",
胡菁 authored
1018
1019
1020
1021
    width: 80,
    height: 80,
    markup: [
      {
胡菁 authored
1022
1023
        tagName: "rect",
        selector: "body",
胡菁 authored
1024
1025
      },
      {
胡菁 authored
1026
        tagName: "image",
胡菁 authored
1027
1028
      },
      {
胡菁 authored
1029
1030
1031
        tagName: "text",
        selector: "label",
      },
胡菁 authored
1032
1033
1034
1035
    ],
    attrs: {
      body: {
        // 节点线的颜色
胡菁 authored
1036
        stroke: "transparent",
胡菁 authored
1037
        // 背景填充色
胡菁 authored
1038
        fill: "transparent",
胡菁 authored
1039
1040
1041
1042
1043
1044
      },
      // 自定义图片
      image: {
        width: 60,
        height: 60,
        refX: 0,
胡菁 authored
1045
        refY: 0,
胡菁 authored
1046
1047
1048
1049
      },
      label: {
        refX: 3,
        refY: 2,
胡菁 authored
1050
1051
        textAnchor: "left",
        textVerticalAnchor: "top",
胡菁 authored
1052
        fontSize: 12,
胡菁 authored
1053
        fill: "black",
胡菁 authored
1054
      },
胡菁 authored
1055
1056
1057
      "edit-text": {
        contenteditable: "true",
        class: "x6-edit-text",
胡菁 authored
1058
        style: {
胡菁 authored
1059
1060
          width: "100%",
          textAlign: "center",
胡菁 authored
1061
          fontSize: 12,
胡菁 authored
1062
1063
          color: "rgba(0,0,0,0.85)",
        },
胡菁 authored
1064
1065
      },
      text: {
胡菁 authored
1066
        fontSize: 12,
胡菁 authored
1067
1068
        fill: "#080808",
      },
胡菁 authored
1069
    },
胡菁 authored
1070
    ports: { ...customPorts },
胡菁 authored
1071
  }
胡菁 authored
1072
);
胡菁 authored
1073
1074
1075

// 节点组
export class NodeGroup extends Node {
胡菁 authored
1076
  collapsed = true;
胡菁 authored
1077
1078

  postprocess() {
胡菁 authored
1079
    this.toggleCollapse(true);
胡菁 authored
1080
1081
1082
  }

  isCollapsed() {
胡菁 authored
1083
    return this.collapsed;
胡菁 authored
1084
1085
1086
  }

  toggleCollapse(collapsed) {
胡菁 authored
1087
    const target = collapsed == null ? !this.collapsed : collapsed;
胡菁 authored
1088
    if (target) {
胡菁 authored
1089
1090
      this.attr("buttonSign", { d: "M 1 5 9 5 M 5 1 5 9" });
      this.resize(200, 40);
胡菁 authored
1091
    } else {
胡菁 authored
1092
1093
      this.attr("buttonSign", { d: "M 2 5 8 5" });
      this.resize(240, 240);
胡菁 authored
1094
    }
胡菁 authored
1095
    this.collapsed = target;
胡菁 authored
1096
1097
1098
1099
  }
}

NodeGroup.config({
胡菁 authored
1100
  shape: "rect",
胡菁 authored
1101
1102
  markup: [
    {
胡菁 authored
1103
1104
      tagName: "rect",
      selector: "body",
胡菁 authored
1105
1106
    },
    {
胡菁 authored
1107
1108
      tagName: "image",
      selector: "image",
胡菁 authored
1109
1110
    },
    {
胡菁 authored
1111
1112
      tagName: "text",
      selector: "text",
胡菁 authored
1113
1114
    },
    {
胡菁 authored
1115
1116
      tagName: "g",
      selector: "buttonGroup",
胡菁 authored
1117
1118
      children: [
        {
胡菁 authored
1119
1120
          tagName: "rect",
          selector: "button",
胡菁 authored
1121
          attrs: {
胡菁 authored
1122
1123
            "pointer-events": "visiblePainted",
          },
胡菁 authored
1124
1125
        },
        {
胡菁 authored
1126
1127
          tagName: "path",
          selector: "buttonSign",
胡菁 authored
1128
          attrs: {
胡菁 authored
1129
1130
1131
1132
1133
1134
            fill: "none",
            "pointer-events": "none",
          },
        },
      ],
    },
胡菁 authored
1135
1136
1137
  ],
  attrs: {
    body: {
胡菁 authored
1138
1139
      refWidth: "100%",
      refHeight: "100%",
胡菁 authored
1140
      strokeWidth: 1,
胡菁 authored
1141
1142
      fill: "rgba(95,149,255,0.05)",
      stroke: "#5F95FF",
胡菁 authored
1143
1144
    },
    image: {
胡菁 authored
1145
1146
      "xlink:href":
        "https://gw.alipayobjects.com/mdn/rms_0b51a4/afts/img/A*X4e0TrDsEiIAAAAAAAAAAAAAARQnAQ",
胡菁 authored
1147
1148
1149
      width: 16,
      height: 16,
      x: 8,
胡菁 authored
1150
      y: 12,
胡菁 authored
1151
1152
1153
    },
    text: {
      fontSize: 12,
胡菁 authored
1154
      fill: "rgba(0,0,0,0.85)",
胡菁 authored
1155
      refX: 30,
胡菁 authored
1156
      refY: 15,
胡菁 authored
1157
1158
    },
    buttonGroup: {
胡菁 authored
1159
      refX: "100%",
胡菁 authored
1160
      refX2: -25,
胡菁 authored
1161
      refY: 13,
胡菁 authored
1162
1163
1164
1165
1166
1167
    },
    button: {
      height: 14,
      width: 16,
      rx: 2,
      ry: 2,
胡菁 authored
1168
1169
1170
1171
      fill: "#f5f5f5",
      stroke: "#ccc",
      cursor: "pointer",
      event: "node:collapse",
胡菁 authored
1172
1173
1174
1175
    },
    buttonSign: {
      refX: 3,
      refY: 2,
胡菁 authored
1176
1177
1178
1179
      stroke: "#808080",
    },
  },
});
胡菁 authored
1180
胡菁 authored
1181
Graph.registerNode("groupNode", NodeGroup);