@visactor/vrender-core 0.17.0 → 0.17.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/cjs/graphic/bounds.d.ts +2 -2
  2. package/cjs/graphic/bounds.js +8 -10
  3. package/cjs/graphic/bounds.js.map +1 -1
  4. package/cjs/graphic/graphic-creator.d.ts +24 -36
  5. package/cjs/graphic/graphic-creator.js +16 -99
  6. package/cjs/graphic/graphic-creator.js.map +1 -1
  7. package/cjs/graphic/index.d.ts +1 -0
  8. package/cjs/graphic/index.js +6 -5
  9. package/cjs/graphic/index.js.map +1 -1
  10. package/cjs/index.d.ts +15 -0
  11. package/cjs/index.js +8 -1
  12. package/cjs/index.js.map +1 -1
  13. package/cjs/render/contributions/render/arc-module.d.ts +2 -0
  14. package/cjs/render/contributions/render/arc-module.js +17 -0
  15. package/cjs/render/contributions/render/arc-module.js.map +1 -0
  16. package/cjs/render/contributions/render/arc3d-module.d.ts +2 -0
  17. package/cjs/render/contributions/render/arc3d-module.js +15 -0
  18. package/cjs/render/contributions/render/arc3d-module.js.map +1 -0
  19. package/cjs/render/contributions/render/area-module.d.ts +2 -0
  20. package/cjs/render/contributions/render/area-module.js +18 -0
  21. package/cjs/render/contributions/render/area-module.js.map +1 -0
  22. package/cjs/render/contributions/render/circle-module.d.ts +2 -0
  23. package/cjs/render/contributions/render/circle-module.js +17 -0
  24. package/cjs/render/contributions/render/circle-module.js.map +1 -0
  25. package/cjs/render/contributions/render/draw-interceptor.d.ts +0 -2
  26. package/cjs/render/contributions/render/draw-interceptor.js +2 -2
  27. package/cjs/render/contributions/render/draw-interceptor.js.map +1 -1
  28. package/cjs/render/contributions/render/glyph-module.d.ts +2 -0
  29. package/cjs/render/contributions/render/glyph-module.js +15 -0
  30. package/cjs/render/contributions/render/glyph-module.js.map +1 -0
  31. package/cjs/render/contributions/render/image-module.d.ts +2 -0
  32. package/cjs/render/contributions/render/image-module.js +16 -0
  33. package/cjs/render/contributions/render/image-module.js.map +1 -0
  34. package/cjs/render/contributions/render/line-module.d.ts +2 -0
  35. package/cjs/render/contributions/render/line-module.js +17 -0
  36. package/cjs/render/contributions/render/line-module.js.map +1 -0
  37. package/cjs/render/contributions/render/module.js +2 -37
  38. package/cjs/render/contributions/render/module.js.map +1 -1
  39. package/cjs/render/contributions/render/path-module.d.ts +2 -0
  40. package/cjs/render/contributions/render/path-module.js +17 -0
  41. package/cjs/render/contributions/render/path-module.js.map +1 -0
  42. package/cjs/render/contributions/render/polygon-module.d.ts +2 -0
  43. package/cjs/render/contributions/render/polygon-module.js +16 -0
  44. package/cjs/render/contributions/render/polygon-module.js.map +1 -0
  45. package/cjs/render/contributions/render/pyramid3d-module.d.ts +2 -0
  46. package/cjs/render/contributions/render/pyramid3d-module.js +15 -0
  47. package/cjs/render/contributions/render/pyramid3d-module.js.map +1 -0
  48. package/cjs/render/contributions/render/rect-module.d.ts +2 -0
  49. package/cjs/render/contributions/render/rect-module.js +17 -0
  50. package/cjs/render/contributions/render/rect-module.js.map +1 -0
  51. package/cjs/render/contributions/render/rect3d-module.d.ts +2 -0
  52. package/cjs/render/contributions/render/rect3d-module.js +15 -0
  53. package/cjs/render/contributions/render/rect3d-module.js.map +1 -0
  54. package/cjs/render/contributions/render/richtext-module.d.ts +2 -0
  55. package/cjs/render/contributions/render/richtext-module.js +15 -0
  56. package/cjs/render/contributions/render/richtext-module.js.map +1 -0
  57. package/cjs/render/contributions/render/symbol-module.d.ts +2 -0
  58. package/cjs/render/contributions/render/symbol-module.js +17 -0
  59. package/cjs/render/contributions/render/symbol-module.js.map +1 -0
  60. package/cjs/render/contributions/render/text-module.d.ts +2 -0
  61. package/cjs/render/contributions/render/text-module.js +16 -0
  62. package/cjs/render/contributions/render/text-module.js.map +1 -0
  63. package/dist/index.js +1888 -1825
  64. package/dist/index.min.js +1 -1
  65. package/es/graphic/bounds.d.ts +2 -2
  66. package/es/graphic/bounds.js +6 -8
  67. package/es/graphic/bounds.js.map +1 -1
  68. package/es/graphic/graphic-creator.d.ts +24 -36
  69. package/es/graphic/graphic-creator.js +14 -125
  70. package/es/graphic/graphic-creator.js.map +1 -1
  71. package/es/graphic/index.d.ts +1 -0
  72. package/es/graphic/index.js +2 -0
  73. package/es/graphic/index.js.map +1 -1
  74. package/es/index.d.ts +15 -0
  75. package/es/index.js +30 -0
  76. package/es/index.js.map +1 -1
  77. package/es/render/contributions/render/arc-module.d.ts +2 -0
  78. package/es/render/contributions/render/arc-module.js +21 -0
  79. package/es/render/contributions/render/arc-module.js.map +1 -0
  80. package/es/render/contributions/render/arc3d-module.d.ts +2 -0
  81. package/es/render/contributions/render/arc3d-module.js +13 -0
  82. package/es/render/contributions/render/arc3d-module.js.map +1 -0
  83. package/es/render/contributions/render/area-module.d.ts +2 -0
  84. package/es/render/contributions/render/area-module.js +23 -0
  85. package/es/render/contributions/render/area-module.js.map +1 -0
  86. package/es/render/contributions/render/circle-module.d.ts +2 -0
  87. package/es/render/contributions/render/circle-module.js +21 -0
  88. package/es/render/contributions/render/circle-module.js.map +1 -0
  89. package/es/render/contributions/render/draw-interceptor.d.ts +0 -2
  90. package/es/render/contributions/render/draw-interceptor.js +4 -4
  91. package/es/render/contributions/render/draw-interceptor.js.map +1 -1
  92. package/es/render/contributions/render/glyph-module.d.ts +2 -0
  93. package/es/render/contributions/render/glyph-module.js +13 -0
  94. package/es/render/contributions/render/glyph-module.js.map +1 -0
  95. package/es/render/contributions/render/image-module.d.ts +2 -0
  96. package/es/render/contributions/render/image-module.js +20 -0
  97. package/es/render/contributions/render/image-module.js.map +1 -0
  98. package/es/render/contributions/render/line-module.d.ts +2 -0
  99. package/es/render/contributions/render/line-module.js +16 -0
  100. package/es/render/contributions/render/line-module.js.map +1 -0
  101. package/es/render/contributions/render/module.js +3 -70
  102. package/es/render/contributions/render/module.js.map +1 -1
  103. package/es/render/contributions/render/path-module.d.ts +2 -0
  104. package/es/render/contributions/render/path-module.js +21 -0
  105. package/es/render/contributions/render/path-module.js.map +1 -0
  106. package/es/render/contributions/render/polygon-module.d.ts +2 -0
  107. package/es/render/contributions/render/polygon-module.js +20 -0
  108. package/es/render/contributions/render/polygon-module.js.map +1 -0
  109. package/es/render/contributions/render/pyramid3d-module.d.ts +2 -0
  110. package/es/render/contributions/render/pyramid3d-module.js +13 -0
  111. package/es/render/contributions/render/pyramid3d-module.js.map +1 -0
  112. package/es/render/contributions/render/rect-module.d.ts +2 -0
  113. package/es/render/contributions/render/rect-module.js +21 -0
  114. package/es/render/contributions/render/rect-module.js.map +1 -0
  115. package/es/render/contributions/render/rect3d-module.d.ts +2 -0
  116. package/es/render/contributions/render/rect3d-module.js +13 -0
  117. package/es/render/contributions/render/rect3d-module.js.map +1 -0
  118. package/es/render/contributions/render/richtext-module.d.ts +2 -0
  119. package/es/render/contributions/render/richtext-module.js +13 -0
  120. package/es/render/contributions/render/richtext-module.js.map +1 -0
  121. package/es/render/contributions/render/symbol-module.d.ts +2 -0
  122. package/es/render/contributions/render/symbol-module.js +21 -0
  123. package/es/render/contributions/render/symbol-module.js.map +1 -0
  124. package/es/render/contributions/render/text-module.d.ts +2 -0
  125. package/es/render/contributions/render/text-module.js +20 -0
  126. package/es/render/contributions/render/text-module.js.map +1 -0
  127. package/package.json +6 -4
package/dist/index.js CHANGED
@@ -12082,7 +12082,7 @@
12082
12082
  const SYMBOL_NUMBER_TYPE = genNumberType();
12083
12083
  const TEXT_NUMBER_TYPE = genNumberType();
12084
12084
  const GraphicService = Symbol.for('GraphicService');
12085
- const GraphicCreator = Symbol.for('GraphicCreator');
12085
+ const GraphicCreator$1 = Symbol.for('GraphicCreator');
12086
12086
  const SVG_ATTRIBUTE_MAP = {
12087
12087
  'stroke-linecap': 'lineCap',
12088
12088
  'stroke-linejoin': 'lineJoin',
@@ -17136,6 +17136,58 @@
17136
17136
  }
17137
17137
  Pyramid3d.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
17138
17138
 
17139
+ class ShadowRoot extends Group {
17140
+ constructor(graphic) {
17141
+ super({ x: 0, y: 0 });
17142
+ this.type = 'shadowroot';
17143
+ this.shadowHost = graphic;
17144
+ }
17145
+ addUpdateBoundTag() {
17146
+ super.addUpdateBoundTag();
17147
+ if (this.shadowHost) {
17148
+ this.shadowHost.addUpdateBoundTag();
17149
+ }
17150
+ }
17151
+ addUpdateShapeAndBoundsTag() {
17152
+ super.addUpdateShapeAndBoundsTag();
17153
+ if (this.shadowHost) {
17154
+ this.shadowHost.addUpdateBoundTag();
17155
+ }
17156
+ }
17157
+ tryUpdateGlobalTransMatrix(clearTag = true) {
17158
+ if (this.shouldUpdateGlobalMatrix()) {
17159
+ const m = this.transMatrix;
17160
+ if (!this._globalTransMatrix) {
17161
+ this._globalTransMatrix = m.clone();
17162
+ }
17163
+ else {
17164
+ this._globalTransMatrix.setValue(m.a, m.b, m.c, m.d, m.e, m.f);
17165
+ }
17166
+ this.doUpdateGlobalMatrix();
17167
+ clearTag && this.clearUpdateGlobalPositionTag();
17168
+ }
17169
+ return this._globalTransMatrix;
17170
+ }
17171
+ doUpdateGlobalMatrix() {
17172
+ if (this.shadowHost) {
17173
+ const parentMatrix = this.shadowHost.globalTransMatrix;
17174
+ this._globalTransMatrix.multiply(parentMatrix.a, parentMatrix.b, parentMatrix.c, parentMatrix.d, parentMatrix.e, parentMatrix.f);
17175
+ }
17176
+ }
17177
+ tryUpdateGlobalAABBBounds() {
17178
+ if (!this._globalAABBBounds) {
17179
+ this._globalAABBBounds = this._AABBBounds.clone();
17180
+ }
17181
+ else {
17182
+ this._globalAABBBounds.setValue(this._AABBBounds.x1, this._AABBBounds.y1, this._AABBBounds.x2, this._AABBBounds.y2);
17183
+ }
17184
+ if (this.shadowHost) {
17185
+ this._globalAABBBounds.transformWithMatrix(this.shadowHost.globalTransMatrix);
17186
+ }
17187
+ return this._globalAABBBounds;
17188
+ }
17189
+ }
17190
+
17139
17191
  class DefaultOuterBorderBoundsContribution {
17140
17192
  updateBounds(attribute, theme, aabbBounds, graphic) {
17141
17193
  const { outerBorder, shadowBlur = theme.shadowBlur } = attribute;
@@ -18249,143 +18301,41 @@
18249
18301
  };
18250
18302
  exports.DefaultGraphicService = __decorate([
18251
18303
  injectable(),
18252
- __param(0, inject(GraphicCreator)),
18304
+ __param(0, inject(GraphicCreator$1)),
18253
18305
  __metadata("design:paramtypes", [Object])
18254
18306
  ], exports.DefaultGraphicService);
18255
18307
 
18256
- class ShadowRoot extends Group {
18257
- constructor(graphic) {
18258
- super({ x: 0, y: 0 });
18259
- this.type = 'shadowroot';
18260
- this.shadowHost = graphic;
18261
- }
18262
- addUpdateBoundTag() {
18263
- super.addUpdateBoundTag();
18264
- if (this.shadowHost) {
18265
- this.shadowHost.addUpdateBoundTag();
18266
- }
18267
- }
18268
- addUpdateShapeAndBoundsTag() {
18269
- super.addUpdateShapeAndBoundsTag();
18270
- if (this.shadowHost) {
18271
- this.shadowHost.addUpdateBoundTag();
18272
- }
18273
- }
18274
- tryUpdateGlobalTransMatrix(clearTag = true) {
18275
- if (this.shouldUpdateGlobalMatrix()) {
18276
- const m = this.transMatrix;
18277
- if (!this._globalTransMatrix) {
18278
- this._globalTransMatrix = m.clone();
18279
- }
18280
- else {
18281
- this._globalTransMatrix.setValue(m.a, m.b, m.c, m.d, m.e, m.f);
18282
- }
18283
- this.doUpdateGlobalMatrix();
18284
- clearTag && this.clearUpdateGlobalPositionTag();
18285
- }
18286
- return this._globalTransMatrix;
18308
+ class GraphicCreator {
18309
+ constructor() {
18310
+ this.store = new Map();
18287
18311
  }
18288
- doUpdateGlobalMatrix() {
18289
- if (this.shadowHost) {
18290
- const parentMatrix = this.shadowHost.globalTransMatrix;
18291
- this._globalTransMatrix.multiply(parentMatrix.a, parentMatrix.b, parentMatrix.c, parentMatrix.d, parentMatrix.e, parentMatrix.f);
18292
- }
18312
+ RegisterGraphicCreator(name, cb) {
18313
+ this.store.set(name, cb);
18314
+ this[name] = cb;
18293
18315
  }
18294
- tryUpdateGlobalAABBBounds() {
18295
- if (!this._globalAABBBounds) {
18296
- this._globalAABBBounds = this._AABBBounds.clone();
18297
- }
18298
- else {
18299
- this._globalAABBBounds.setValue(this._AABBBounds.x1, this._AABBBounds.y1, this._AABBBounds.x2, this._AABBBounds.y2);
18300
- }
18301
- if (this.shadowHost) {
18302
- this._globalAABBBounds.transformWithMatrix(this.shadowHost.globalTransMatrix);
18316
+ CreateGraphic(name, params) {
18317
+ const cb = this.store.get(name);
18318
+ if (!cb) {
18319
+ return null;
18303
18320
  }
18304
- return this._globalAABBBounds;
18321
+ return cb(params);
18305
18322
  }
18306
18323
  }
18324
+ const graphicCreator = new GraphicCreator();
18307
18325
 
18308
- function createArc(attributes) {
18309
- return new Arc(attributes);
18310
- }
18311
- function createArc3d(attributes) {
18312
- return new Arc3d(attributes);
18313
- }
18314
- function createPyramid3d(attributes) {
18315
- return new Pyramid3d(attributes);
18316
- }
18317
- function createArea(attributes) {
18318
- return new Area(attributes);
18319
- }
18320
- function createCircle(attributes) {
18321
- return new Circle(attributes);
18322
- }
18323
- function createGroup(attributes) {
18324
- return new Group(attributes);
18325
- }
18326
- function createLine(attributes) {
18327
- return new Line$1(attributes);
18328
- }
18329
- function createPath(attributes) {
18330
- return new Path(attributes);
18331
- }
18332
- function createRect(attributes) {
18333
- return new Rect(attributes);
18334
- }
18335
- function createRect3d(attributes) {
18336
- return new Rect3d(attributes);
18337
- }
18338
- function createGlyph(attributes) {
18339
- return new Glyph(attributes);
18340
- }
18341
- function createText(attributes) {
18342
- return new Text(attributes);
18343
- }
18344
- function createWrapText(attributes) {
18345
- return new WrapText(attributes);
18346
- }
18347
- function createSymbol(attributes) {
18348
- return new Symbol$1(attributes);
18349
- }
18350
- function createImage(attributes) {
18351
- return new Image(attributes);
18352
- }
18353
- function createPolygon(attributes) {
18354
- return new Polygon(attributes);
18355
- }
18356
- function createShadowRoot(graphic) {
18357
- return new ShadowRoot(graphic);
18358
- }
18359
- function createRichText(attributes) {
18360
- return new RichText(attributes);
18361
- }
18362
- const graphicCreator = {
18363
- arc: createArc,
18364
- area: createArea,
18365
- circle: createCircle,
18366
- group: createGroup,
18367
- image: createImage,
18368
- line: createLine,
18369
- path: createPath,
18370
- rect: createRect,
18371
- rect3d: createRect3d,
18372
- symbol: createSymbol,
18373
- text: createText,
18374
- richtext: createRichText,
18375
- polygon: createPolygon,
18376
- shadowRoot: createShadowRoot,
18377
- wrapText: createWrapText
18378
- };
18379
-
18380
- const text = createText({
18381
- text: ''
18382
- });
18326
+ let text;
18383
18327
  function getTextBounds(params) {
18328
+ if (!text) {
18329
+ text = graphicCreator.CreateGraphic('text', {});
18330
+ }
18384
18331
  text.setAttributes(params);
18385
18332
  return text.AABBBounds;
18386
18333
  }
18387
- const richText = createRichText({});
18334
+ let richText;
18388
18335
  function getRichTextBounds(params) {
18336
+ if (!richText) {
18337
+ richText = graphicCreator.CreateGraphic('text', {});
18338
+ }
18389
18339
  richText.setAttributes(params);
18390
18340
  return richText.AABBBounds;
18391
18341
  }
@@ -22009,7 +21959,7 @@
22009
21959
 
22010
21960
  var graphicModule = new ContainerModule(bind => {
22011
21961
  bind(GraphicService).to(exports.DefaultGraphicService).inSingletonScope();
22012
- bind(GraphicCreator).toConstantValue(graphicCreator);
21962
+ bind(GraphicCreator$1).toConstantValue(graphicCreator);
22013
21963
  });
22014
21964
 
22015
21965
  const AutoEnablePlugins = Symbol.for('AutoEnablePlugins');
@@ -22491,11 +22441,6 @@
22491
22441
  class DebugDrawItemInterceptorContribution {
22492
22442
  constructor() {
22493
22443
  this.order = 1;
22494
- this.interceptors = [
22495
- new ShadowRootDrawItemInterceptorContribution(),
22496
- new Canvas3DDrawItemInterceptor(),
22497
- new InteractiveDrawItemInterceptorContribution()
22498
- ];
22499
22444
  }
22500
22445
  afterDrawItem(graphic, renderService, drawContext, drawContribution, params) {
22501
22446
  if (graphic.attribute._debug_bounds) {
@@ -22625,7 +22570,7 @@
22625
22570
  var _a;
22626
22571
  let group = interactiveLayer.getElementById('_interactive_group');
22627
22572
  if (!group) {
22628
- group = createGroup({});
22573
+ group = graphicCreator.CreateGraphic('group', {});
22629
22574
  group.id = '_interactive_group';
22630
22575
  interactiveLayer.add(group);
22631
22576
  }
@@ -23599,1068 +23544,459 @@
23599
23544
  __metadata("design:paramtypes", [Array, Object, Object, Object])
23600
23545
  ], DefaultIncrementalDrawContribution);
23601
23546
 
23602
- let DefaultCanvasRect3dRender = class DefaultCanvasRect3dRender extends BaseRender {
23547
+ var renderModule = new ContainerModule(bind => {
23548
+ bind(DefaultBaseBackgroundRenderContribution).toSelf().inSingletonScope();
23549
+ bind(DefaultBaseTextureRenderContribution).toSelf().inSingletonScope();
23550
+ bind(DrawContribution).to(DefaultDrawContribution);
23551
+ bind(IncrementalDrawContribution).to(DefaultIncrementalDrawContribution);
23552
+ bind(GroupRender).to(DefaultCanvasGroupRender).inSingletonScope();
23553
+ bind(GraphicRender).toService(GroupRender);
23554
+ bindContributionProvider(bind, GroupRenderContribution);
23555
+ bind(exports.DefaultBaseInteractiveRenderContribution).toSelf().inSingletonScope();
23556
+ bindContributionProvider(bind, InteractiveSubRenderContribution);
23557
+ bindContributionProvider(bind, GraphicRender);
23558
+ bind(CommonDrawItemInterceptorContribution).toSelf().inSingletonScope();
23559
+ bind(DrawItemInterceptor).toService(CommonDrawItemInterceptorContribution);
23560
+ bindContributionProvider(bind, DrawItemInterceptor);
23561
+ });
23562
+
23563
+ function load(container) {
23564
+ container.load(renderModule);
23565
+ }
23566
+
23567
+ container.load(coreModule);
23568
+ container.load(graphicModule);
23569
+ container.load(renderModule$1);
23570
+ container.load(pickModule);
23571
+ container.load(pluginModule);
23572
+ load$1(container);
23573
+ load(container);
23574
+ const vglobal = container.get(VGlobal);
23575
+ application.global = vglobal;
23576
+ const graphicUtil = container.get(GraphicUtil);
23577
+ application.graphicUtil = graphicUtil;
23578
+ const transformUtil = container.get(TransformUtil);
23579
+ application.transformUtil = transformUtil;
23580
+ const graphicService = container.get(GraphicService);
23581
+ application.graphicService = graphicService;
23582
+ const layerService = container.get(LayerService);
23583
+ application.layerService = layerService;
23584
+
23585
+ class AutoRenderPlugin {
23603
23586
  constructor() {
23604
- super(...arguments);
23605
- this.type = 'rect3d';
23606
- this.numberType = RECT3D_NUMBER_TYPE;
23587
+ this.name = 'AutoRenderPlugin';
23588
+ this.activeEvent = 'onRegister';
23589
+ this._uid = Generator.GenAutoIncrementId();
23590
+ this.key = this.name + this._uid;
23607
23591
  }
23608
- drawShape(rect, context, x, y, drawContext, params, fillCb, strokeCb) {
23609
- var _a;
23610
- const rectAttribute = getTheme(rect, params === null || params === void 0 ? void 0 : params.theme).rect3d;
23611
- const { fill = rectAttribute.fill, stroke = rectAttribute.stroke, width = rectAttribute.width, height = rectAttribute.height, opacity = rectAttribute.opacity, fillOpacity = rectAttribute.fillOpacity, lineWidth = rectAttribute.lineWidth, strokeOpacity = rectAttribute.strokeOpacity, visible = rectAttribute.visible } = rect.attribute;
23612
- const z = (_a = this.z) !== null && _a !== void 0 ? _a : 0;
23613
- const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill);
23614
- const sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height);
23615
- const doFill = runFill(fill);
23616
- const doStroke = runStroke(stroke, lineWidth);
23617
- if (!(rect.valid && visible)) {
23618
- return;
23619
- }
23620
- if (!(doFill || doStroke)) {
23621
- return;
23622
- }
23623
- if (!(fVisible || sVisible || fillCb || strokeCb)) {
23624
- return;
23625
- }
23626
- const { light, camera } = drawContext.stage || {};
23627
- const face3d = rect.findFace();
23628
- if (fill !== false) {
23629
- context.setCommonStyle(rect, rect.attribute, x, y, rectAttribute);
23630
- let fc = fill;
23631
- if (typeof fc !== 'string') {
23632
- fc = 'black';
23592
+ activate(context) {
23593
+ this.pluginService = context;
23594
+ application.graphicService.hooks.onAttributeUpdate.tap(this.key, graphic => {
23595
+ if (graphic.glyphHost) {
23596
+ graphic = graphic.glyphHost;
23597
+ }
23598
+ if (graphic.stage === context.stage && graphic.stage != null) {
23599
+ graphic.stage.renderNextFrame();
23633
23600
  }
23634
- this.fill(x, y, z, face3d, fc, context, light, fillCb);
23635
- }
23636
- if (stroke !== false) {
23637
- context.setStrokeStyle(rect, rect.attribute, x, y, rectAttribute);
23638
- this.stroke(x, y, z, face3d, context);
23639
- }
23640
- }
23641
- stroke(x, y, z, face3d, context) {
23642
- const vertices = face3d.vertices;
23643
- face3d.edges.forEach(edge => {
23644
- const p1 = vertices[edge[0]];
23645
- const v1 = {
23646
- x: x + p1[0],
23647
- y: y + p1[1],
23648
- z: z + p1[2]
23649
- };
23650
- const p2 = vertices[edge[1]];
23651
- const v2 = {
23652
- x: x + p2[0],
23653
- y: y + p2[1],
23654
- z: z + p2[2]
23655
- };
23656
- context.beginPath();
23657
- context.moveTo(v1.x, v1.y, v1.z);
23658
- context.lineTo(v2.x, v2.y, v2.z);
23659
- context.stroke();
23660
23601
  });
23661
- }
23662
- fill(x, y, z, face3d, fillColor, context, light, fillCb) {
23663
- const rgbArray = ColorStore.Get(fillColor, exports.ColorType.Color255);
23664
- const vertices = face3d.vertices;
23665
- const viewdVerticesZ = vertices.map(v => {
23666
- return context.view(v[0], v[1], v[2])[2];
23602
+ application.graphicService.hooks.onSetStage.tap(this.key, graphic => {
23603
+ if (graphic.glyphHost) {
23604
+ graphic = graphic.glyphHost;
23605
+ }
23606
+ if (graphic.stage === context.stage && graphic.stage != null) {
23607
+ graphic.stage.renderNextFrame();
23608
+ }
23667
23609
  });
23668
- const sortFace = [];
23669
- face3d.polygons.forEach((p, i) => {
23670
- sortFace.push({
23671
- faceIdx: i,
23672
- polygon: p
23610
+ }
23611
+ deactivate(context) {
23612
+ application.graphicService.hooks.onAttributeUpdate.taps =
23613
+ application.graphicService.hooks.onAttributeUpdate.taps.filter(item => {
23614
+ return item.name !== this.key;
23673
23615
  });
23674
- const { polygon, normal } = p;
23675
- const z1 = viewdVerticesZ[polygon[0]];
23676
- const z2 = viewdVerticesZ[polygon[1]];
23677
- const z3 = viewdVerticesZ[polygon[2]];
23678
- const z4 = viewdVerticesZ[polygon[3]];
23679
- p.ave_z = z1 + z2 + z3 + z4;
23680
- });
23681
- sortFace.sort((a, b) => b.polygon.ave_z - a.polygon.ave_z);
23682
- sortFace.forEach(item => {
23683
- const { polygon, normal } = item.polygon;
23684
- const p1 = vertices[polygon[0]];
23685
- const p2 = vertices[polygon[1]];
23686
- const p3 = vertices[polygon[2]];
23687
- const p4 = vertices[polygon[3]];
23688
- const v1 = {
23689
- x: x + p1[0],
23690
- y: y + p1[1],
23691
- z: z + p1[2]
23692
- };
23693
- const v2 = {
23694
- x: x + p2[0],
23695
- y: y + p2[1],
23696
- z: z + p2[2]
23697
- };
23698
- const v3 = {
23699
- x: x + p3[0],
23700
- y: y + p3[1],
23701
- z: z + p3[2]
23702
- };
23703
- const v4 = {
23704
- x: x + p4[0],
23705
- y: y + p4[1],
23706
- z: z + p4[2]
23707
- };
23708
- context.beginPath();
23709
- context.moveTo(v1.x, v1.y, v1.z);
23710
- context.lineTo(v2.x, v2.y, v2.z);
23711
- context.lineTo(v3.x, v3.y, v3.z);
23712
- context.lineTo(v4.x, v4.y, v4.z);
23713
- context.closePath();
23714
- if (fillCb) {
23715
- fillCb(context, null, null);
23716
- }
23717
- else {
23718
- context.fillStyle = light ? light.computeColor(normal, rgbArray) : fillColor;
23719
- context.fill();
23720
- }
23616
+ application.graphicService.hooks.onSetStage.taps = application.graphicService.hooks.onSetStage.taps.filter(item => {
23617
+ return item.name !== this.key;
23721
23618
  });
23722
23619
  }
23723
- draw(rect, renderService, drawContext) {
23724
- const rectAttribute = getTheme(rect).rect;
23725
- this._draw(rect, rectAttribute, false, drawContext);
23726
- }
23727
- };
23728
- DefaultCanvasRect3dRender = __decorate([
23729
- injectable()
23730
- ], DefaultCanvasRect3dRender);
23620
+ }
23731
23621
 
23732
- let DefaultCanvasRichTextRender = class DefaultCanvasRichTextRender extends BaseRender {
23622
+ class ViewTransform3dPlugin {
23733
23623
  constructor() {
23734
- super();
23735
- this.numberType = RICHTEXT_NUMBER_TYPE;
23736
- this.builtinContributions = [defaultTextBackgroundRenderContribution];
23737
- this.init();
23738
- }
23739
- drawShape(richtext, context, x, y, drawContext) {
23740
- const richtextAttribute = getTheme(richtext).richtext;
23741
- const { strokeOpacity = richtextAttribute.strokeOpacity, opacity = richtextAttribute.opacity, fillOpacity = richtextAttribute.fillOpacity, visible = richtextAttribute.visible } = richtext.attribute;
23742
- if (!(richtext.valid && visible)) {
23743
- return;
23744
- }
23745
- const fVisible = fillVisible(opacity, fillOpacity, true);
23746
- const sVisible = fillVisible(opacity, strokeOpacity, true);
23747
- if (!fVisible) {
23748
- return;
23749
- }
23750
- context.translate(x, y);
23751
- this.beforeRenderStep(richtext, context, x, y, fVisible, sVisible, fVisible, sVisible, richtextAttribute, drawContext);
23752
- const frame = richtext.getFrameCache();
23753
- frame.draw(context, this.drawIcon);
23754
- this.afterRenderStep(richtext, context, x, y, fVisible, sVisible, fVisible, sVisible, richtextAttribute, drawContext);
23755
- }
23756
- drawIcon(icon, context, x, y, baseline) {
23757
- var _a;
23758
- const richtextIconAttribute = getTheme(icon).richtextIcon;
23759
- const { width = richtextIconAttribute.width, height = richtextIconAttribute.height, opacity = richtextIconAttribute.opacity, image: url, backgroundFill = richtextIconAttribute.backgroundFill, backgroundFillOpacity = richtextIconAttribute.backgroundFillOpacity, backgroundStroke = richtextIconAttribute.backgroundStroke, backgroundStrokeOpacity = richtextIconAttribute.backgroundStrokeOpacity, backgroundRadius = richtextIconAttribute.backgroundRadius, margin } = icon.attribute;
23760
- const { backgroundWidth = width, backgroundHeight = height } = icon.attribute;
23761
- if (margin) {
23762
- x += icon._marginArray[3];
23763
- y += icon._marginArray[0];
23764
- }
23765
- if (icon._hovered) {
23766
- const expandX = (backgroundWidth - width) / 2;
23767
- const expandY = (backgroundHeight - height) / 2;
23768
- if (backgroundRadius === 0) {
23769
- context.beginPath();
23770
- context.rect(x - expandX, y - expandY, backgroundWidth, backgroundHeight);
23624
+ this.name = 'ViewTransform3dPlugin';
23625
+ this.activeEvent = 'onRegister';
23626
+ this._uid = Generator.GenAutoIncrementId();
23627
+ this.key = this.name + this._uid;
23628
+ this.onMouseDown = (e) => {
23629
+ if (!this.option3d) {
23630
+ this.option3d = this.pluginService.stage.option3d;
23771
23631
  }
23772
- else {
23773
- context.beginPath();
23774
- createRectPath(context, x - expandX, y - expandY, backgroundWidth, backgroundHeight, backgroundRadius);
23632
+ if (!this.option3d) {
23633
+ return;
23775
23634
  }
23776
- if (backgroundFill) {
23777
- context.globalAlpha = backgroundFillOpacity;
23778
- context.fillStyle = backgroundFill;
23779
- context.fill();
23635
+ this.mousedown = true;
23636
+ this.pageX = e.page.x;
23637
+ this.pageY = e.page.y;
23638
+ };
23639
+ this.onMouseUp = (e) => {
23640
+ if (!this.option3d) {
23641
+ this.option3d = this.pluginService.stage.option3d;
23780
23642
  }
23781
- if (backgroundStroke) {
23782
- context.globalAlpha = backgroundStrokeOpacity;
23783
- context.strokeStyle = backgroundStroke;
23784
- context.stroke();
23643
+ if (!this.option3d) {
23644
+ return;
23785
23645
  }
23786
- }
23787
- const res = url && ((_a = icon === null || icon === void 0 ? void 0 : icon.resources) === null || _a === void 0 ? void 0 : _a.get(url));
23788
- if (!res || res.state !== 'success') {
23789
- return;
23790
- }
23791
- context.globalAlpha = opacity;
23792
- context.drawImage(res.data, x, y, width, height);
23646
+ this.mousedown = false;
23647
+ };
23648
+ this.onMouseMove = (e) => {
23649
+ var _a, _b;
23650
+ const stage = this.pluginService.stage;
23651
+ if (!this.option3d) {
23652
+ this.option3d = stage.option3d;
23653
+ }
23654
+ if (!this.option3d) {
23655
+ return;
23656
+ }
23657
+ if (this.mousedown) {
23658
+ if (!this.pageX || !this.pageY) {
23659
+ this.pageX = e.page.x;
23660
+ this.pageY = e.page.y;
23661
+ }
23662
+ else {
23663
+ const deltaX = e.page.x - this.pageX;
23664
+ const deltaY = e.page.y - this.pageY;
23665
+ this.pageX = e.page.x;
23666
+ this.pageY = e.page.y;
23667
+ const angle1 = deltaX / 100;
23668
+ const angle2 = deltaY / 100;
23669
+ this.option3d.alpha = ((_a = this.option3d.alpha) !== null && _a !== void 0 ? _a : 0) + angle1;
23670
+ this.option3d.beta = ((_b = this.option3d.beta) !== null && _b !== void 0 ? _b : 0) + angle2;
23671
+ stage.set3dOptions(this.option3d);
23672
+ stage.renderNextFrame();
23673
+ }
23674
+ }
23675
+ };
23793
23676
  }
23794
- draw(richtext, renderService, drawContext) {
23795
- const richtextAttribute = getTheme(richtext).richtext;
23796
- this._draw(richtext, richtextAttribute, false, drawContext);
23677
+ activate(context) {
23678
+ this.pluginService = context;
23679
+ const stage = context.stage;
23680
+ this.option3d = stage.option3d;
23681
+ stage.addEventListener('mousedown', this.onMouseDown);
23682
+ stage.addEventListener('mouseup', this.onMouseUp);
23683
+ stage.addEventListener('mousemove', this.onMouseMove);
23797
23684
  }
23798
- };
23799
- DefaultCanvasRichTextRender = __decorate([
23800
- injectable(),
23801
- __metadata("design:paramtypes", [])
23802
- ], DefaultCanvasRichTextRender);
23685
+ deactivate(context) {
23686
+ const stage = context.stage;
23687
+ stage.removeEventListener('mousedown', this.onMouseDown);
23688
+ stage.removeEventListener('mouseup', this.onMouseUp);
23689
+ stage.removeEventListener('mousemove', this.onMouseMove);
23690
+ }
23691
+ }
23803
23692
 
23804
- let DefaultCanvasGlyphRender = class DefaultCanvasGlyphRender {
23693
+ class IncrementalAutoRenderPlugin {
23805
23694
  constructor() {
23806
- this.numberType = GLYPH_NUMBER_TYPE;
23695
+ this.name = 'IncrementalAutoRenderPlugin';
23696
+ this.activeEvent = 'onRegister';
23697
+ this.nextFrameRenderGroupSet = new Set();
23698
+ this.willNextFrameRender = false;
23699
+ this.nextUserParams = {};
23700
+ this._uid = Generator.GenAutoIncrementId();
23701
+ this.key = this.name + this._uid;
23807
23702
  }
23808
- drawShape(glyph, context, x, y, drawContext, params, fillCb, strokeCb) {
23809
- if (!drawContext.drawContribution) {
23810
- return;
23811
- }
23812
- glyph.getSubGraphic().forEach(item => {
23813
- const renderer = drawContext.drawContribution.getRenderContribution(item);
23814
- if (renderer && renderer.drawShape) {
23815
- renderer.drawShape(item, context, x, y, drawContext, params, fillCb, strokeCb);
23703
+ activate(context) {
23704
+ this.pluginService = context;
23705
+ application.graphicService.hooks.onAddIncremental.tap(this.key, (graphic, group, stage) => {
23706
+ if (graphic.glyphHost) {
23707
+ graphic = graphic.glyphHost;
23708
+ }
23709
+ if (graphic.stage === context.stage && graphic.stage != null) {
23710
+ this.nextUserParams.startAtId = group._uid;
23711
+ this.renderNextFrame(group);
23712
+ }
23713
+ });
23714
+ application.graphicService.hooks.onClearIncremental.tap(this.key, (group, stage) => {
23715
+ if (group.stage === context.stage && group.stage != null) {
23716
+ this.nextUserParams.startAtId = group._uid;
23717
+ this.nextUserParams.restartIncremental = true;
23718
+ this.renderNextFrame(group);
23816
23719
  }
23817
23720
  });
23818
23721
  }
23819
- draw(glyph, renderService, drawContext, params) {
23820
- const { context } = drawContext;
23821
- if (!context) {
23822
- return;
23823
- }
23824
- context.highPerformanceSave();
23825
- if (!drawContext.drawContribution) {
23826
- return;
23827
- }
23828
- const glyphTheme = getTheme(glyph);
23829
- const subGraphic = glyph.getSubGraphic();
23830
- subGraphic.length &&
23831
- subGraphic.forEach(g => {
23832
- drawContext.drawContribution.renderItem(g, drawContext, { theme: glyphTheme });
23722
+ deactivate(context) {
23723
+ application.graphicService.hooks.onAddIncremental.taps =
23724
+ application.graphicService.hooks.onAddIncremental.taps.filter(item => {
23725
+ return item.name !== this.key;
23726
+ });
23727
+ application.graphicService.hooks.onClearIncremental.taps =
23728
+ application.graphicService.hooks.onClearIncremental.taps.filter(item => {
23729
+ return item.name !== this.key;
23833
23730
  });
23834
- context.highPerformanceRestore();
23835
23731
  }
23836
- };
23837
- DefaultCanvasGlyphRender = __decorate([
23838
- injectable()
23839
- ], DefaultCanvasGlyphRender);
23840
-
23841
- function drawArcPath(arc, context, cx, cy, z, outerRadius, innerRadius) {
23842
- const { startAngle, endAngle } = arc.getParsedAngle();
23843
- const deltaAngle = vutils.abs(endAngle - startAngle);
23844
- const clockwise = endAngle > startAngle;
23845
- let collapsedToLine = false;
23846
- if (outerRadius < innerRadius) {
23847
- const temp = outerRadius;
23848
- outerRadius = innerRadius;
23849
- innerRadius = temp;
23732
+ renderNextFrame(group) {
23733
+ this.nextFrameRenderGroupSet.add(group);
23734
+ if (!this.willNextFrameRender) {
23735
+ this.willNextFrameRender = true;
23736
+ application.global.getRequestAnimationFrame()(() => {
23737
+ this._doRenderInThisFrame();
23738
+ this.willNextFrameRender = false;
23739
+ });
23740
+ }
23850
23741
  }
23851
- if (outerRadius <= vutils.epsilon) {
23852
- context.moveTo(cx, cy, z);
23742
+ _doRenderInThisFrame() {
23743
+ const stage = this.pluginService.stage;
23744
+ if (this.nextFrameRenderGroupSet.size) {
23745
+ this.nextFrameRenderGroupSet.forEach(group => {
23746
+ const layer = group.layer;
23747
+ if (!layer || !group.layer.subLayers) {
23748
+ return;
23749
+ }
23750
+ const subLayer = group.layer.subLayers.get(group._uid);
23751
+ if (!subLayer || !subLayer.drawContribution) {
23752
+ return;
23753
+ }
23754
+ subLayer.drawContribution.draw(stage.renderService, Object.assign({ x: stage.x, y: stage.y, width: layer.viewWidth, height: layer.viewHeight, stage,
23755
+ layer, clear: 'transparent', renderService: stage.renderService, updateBounds: false, startAtId: group._uid, context: subLayer.layer.getNativeHandler().getContext() }, this.nextUserParams));
23756
+ });
23757
+ this.nextUserParams = {};
23758
+ this.nextFrameRenderGroupSet.clear();
23759
+ }
23853
23760
  }
23854
- else if (deltaAngle >= vutils.pi2 - vutils.epsilon) {
23855
- context.moveTo(cx + outerRadius * vutils.cos(startAngle), cy + outerRadius * vutils.sin(startAngle), z);
23856
- context.arc(cx, cy, outerRadius, startAngle, endAngle, !clockwise, z);
23857
- if (innerRadius > vutils.epsilon) {
23858
- context.moveTo(cx + innerRadius * vutils.cos(endAngle), cy + innerRadius * vutils.sin(endAngle), z);
23859
- context.arc(cx, cy, innerRadius, endAngle, startAngle, clockwise, z);
23761
+ }
23762
+
23763
+ class HtmlAttributePlugin {
23764
+ constructor() {
23765
+ this.name = 'HtmlAttributePlugin';
23766
+ this.activeEvent = 'onRegister';
23767
+ this._uid = Generator.GenAutoIncrementId();
23768
+ this.key = this.name + this._uid;
23769
+ }
23770
+ activate(context) {
23771
+ this.pluginService = context;
23772
+ context.stage.hooks.afterRender.tap(this.key, stage => {
23773
+ if (!(stage && stage === this.pluginService.stage)) {
23774
+ return;
23775
+ }
23776
+ this.drawHTML(context.stage.renderService);
23777
+ });
23778
+ application.graphicService.hooks.onRelease.tap(this.key, graphic => {
23779
+ this.removeDom(graphic);
23780
+ });
23781
+ }
23782
+ deactivate(context) {
23783
+ context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter(item => {
23784
+ return item.name !== this.key;
23785
+ });
23786
+ }
23787
+ drawHTML(renderService) {
23788
+ if (application.global.env === 'browser') {
23789
+ renderService.renderTreeRoots
23790
+ .sort((a, b) => {
23791
+ var _a, _b;
23792
+ return ((_a = a.attribute.zIndex) !== null && _a !== void 0 ? _a : DefaultAttribute.zIndex) - ((_b = b.attribute.zIndex) !== null && _b !== void 0 ? _b : DefaultAttribute.zIndex);
23793
+ })
23794
+ .forEach(group => {
23795
+ this.renderGroupHTML(group);
23796
+ });
23860
23797
  }
23861
23798
  }
23862
- else {
23863
- const { outerDeltaAngle, innerDeltaAngle, outerStartAngle, outerEndAngle, innerEndAngle, innerStartAngle } = arc.getParsePadAngle(startAngle, endAngle);
23864
- const xors = outerRadius * vutils.cos(outerStartAngle);
23865
- const yors = outerRadius * vutils.sin(outerStartAngle);
23866
- const xire = innerRadius * vutils.cos(innerEndAngle);
23867
- const yire = innerRadius * vutils.sin(innerEndAngle);
23868
- if (outerDeltaAngle < 0.001) {
23869
- collapsedToLine = true;
23799
+ renderGroupHTML(group) {
23800
+ this.renderGraphicHTML(group);
23801
+ group.forEachChildren((g) => {
23802
+ if (g.isContainer) {
23803
+ this.renderGroupHTML(g);
23804
+ }
23805
+ else {
23806
+ this.renderGraphicHTML(g);
23807
+ }
23808
+ });
23809
+ }
23810
+ removeDom(graphic) {
23811
+ if (graphic.bindDom && graphic.bindDom.size) {
23812
+ graphic.bindDom.forEach(item => {
23813
+ item.dom && item.dom.parentElement.removeChild(item.dom);
23814
+ });
23815
+ graphic.bindDom.clear();
23816
+ }
23817
+ }
23818
+ renderGraphicHTML(graphic) {
23819
+ const { html } = graphic.attribute;
23820
+ if (!html) {
23821
+ if (graphic.bindDom && graphic.bindDom.size) {
23822
+ graphic.bindDom.forEach(item => {
23823
+ item.dom && item.dom.parentElement.removeChild(item.dom);
23824
+ });
23825
+ graphic.bindDom.clear();
23826
+ }
23827
+ return;
23828
+ }
23829
+ const stage = graphic.stage;
23830
+ if (!stage) {
23831
+ return;
23832
+ }
23833
+ const { dom, container, width, height, style, anchorType = 'boundsLeftTop' } = html;
23834
+ if (!graphic.bindDom) {
23835
+ graphic.bindDom = new Map();
23836
+ }
23837
+ const lastDom = graphic.bindDom.get(dom);
23838
+ if (lastDom && !(container && container !== lastDom.container)) {
23839
+ return;
23840
+ }
23841
+ graphic.bindDom.forEach(({ wrapGroup }) => {
23842
+ application.global.removeDom(wrapGroup);
23843
+ });
23844
+ let nativeDom;
23845
+ if (typeof dom === 'string') {
23846
+ nativeDom = new DOMParser().parseFromString(dom, 'text/html').firstChild;
23870
23847
  }
23871
23848
  else {
23872
- context.moveTo(cx + xors, cy + yors, z);
23873
- context.arc(cx, cy, outerRadius, outerStartAngle, outerEndAngle, !clockwise, z);
23849
+ nativeDom = dom;
23874
23850
  }
23875
- if (!(innerRadius > vutils.epsilon) || innerDeltaAngle < 0.001) {
23876
- context.lineTo(cx + xire, cy + yire, z);
23877
- collapsedToLine = true;
23851
+ let nativeContainer;
23852
+ const _container = container || (stage.params.enableHtmlAttribute === true ? null : stage.params.enableHtmlAttribute);
23853
+ if (_container) {
23854
+ if (typeof _container === 'string') {
23855
+ nativeContainer = application.global.getElementById(_container);
23856
+ }
23857
+ else {
23858
+ nativeContainer = _container;
23859
+ }
23878
23860
  }
23879
23861
  else {
23880
- context.lineTo(cx + xire, cy + yire, z);
23881
- context.arc(cx, cy, innerRadius, innerEndAngle, innerStartAngle, clockwise, z);
23862
+ nativeContainer = graphic.stage.window.getContainer();
23882
23863
  }
23883
- }
23884
- context.closePath();
23885
- return collapsedToLine;
23886
- }
23887
- function drawInnerOuterArcPath(arc, context, cx, cy, z1, z2, radius, getParsePadAngle) {
23888
- const { startAngle, endAngle } = arc.getParsedAngle();
23889
- const deltaAngle = vutils.abs(endAngle - startAngle);
23890
- const clockwise = endAngle > startAngle;
23891
- let collapsedToLine = false;
23892
- if (radius <= vutils.epsilon) {
23893
- context.moveTo(cx, cy, z1);
23894
- }
23895
- else if (deltaAngle >= vutils.pi2 - vutils.epsilon) {
23896
- context.moveTo(cx + radius * vutils.cos(startAngle), cy + radius * vutils.sin(startAngle), z1);
23897
- context.arc(cx, cy, radius, startAngle, endAngle, !clockwise, z1);
23898
- context.lineTo(cx + radius * vutils.cos(endAngle), cy + radius * vutils.sin(endAngle), z2);
23899
- context.arc(cx, cy, radius, endAngle, startAngle, clockwise, z2);
23900
- }
23901
- else {
23902
- const { innerouterDeltaAngle, innerouterStartAngle, innerouterEndAngle } = getParsePadAngle(startAngle, endAngle);
23903
- const xors = radius * vutils.cos(innerouterStartAngle);
23904
- const yors = radius * vutils.sin(innerouterStartAngle);
23905
- const xore = radius * vutils.cos(innerouterEndAngle);
23906
- const yore = radius * vutils.sin(innerouterEndAngle);
23907
- if (innerouterDeltaAngle < 0.001) {
23908
- collapsedToLine = true;
23864
+ const wrapGroup = application.global.createDom({ tagName: 'div', width, height, style, parent: nativeContainer });
23865
+ if (wrapGroup) {
23866
+ wrapGroup.appendChild(nativeDom);
23867
+ graphic.bindDom.set(dom, { dom: nativeDom, container, wrapGroup: wrapGroup });
23868
+ }
23869
+ wrapGroup.style.pointerEvents = 'none';
23870
+ if (!wrapGroup.style.position) {
23871
+ wrapGroup.style.position = 'absolute';
23872
+ nativeContainer.style.position = 'relative';
23873
+ }
23874
+ let left = 0;
23875
+ let top = 0;
23876
+ if (anchorType === 'position') {
23877
+ const matrix = graphic.transMatrix;
23878
+ left = matrix.e;
23879
+ top = matrix.f;
23909
23880
  }
23910
23881
  else {
23911
- context.moveTo(cx + xors, cy + yors, z1);
23912
- context.arc(cx, cy, radius, innerouterStartAngle, innerouterEndAngle, !clockwise, z1);
23913
- context.lineTo(cx + xore, cy + yore, z2);
23914
- context.arc(cx, cy, radius, innerouterEndAngle, innerouterStartAngle, clockwise, z2);
23882
+ const b = graphic.AABBBounds;
23883
+ left = b.x1;
23884
+ top = b.y1;
23915
23885
  }
23886
+ const containerTL = application.global.getElementTopLeft(nativeContainer, false);
23887
+ const windowTL = stage.window.getTopLeft(false);
23888
+ const offsetX = left + windowTL.left - containerTL.left;
23889
+ const offsetTop = top + windowTL.top - containerTL.top;
23890
+ wrapGroup.style.left = `${offsetX}px`;
23891
+ wrapGroup.style.top = `${offsetTop}px`;
23916
23892
  }
23917
- context.closePath();
23918
- return collapsedToLine;
23919
23893
  }
23920
- let DefaultCanvasArc3DRender = class DefaultCanvasArc3DRender extends BaseRender {
23894
+
23895
+ const globalBounds = new vutils.AABBBounds();
23896
+ class DirtyBoundsPlugin {
23921
23897
  constructor() {
23922
- super(...arguments);
23923
- this.numberType = ARC3D_NUMBER_TYPE;
23898
+ this.name = 'DirtyBoundsPlugin';
23899
+ this.activeEvent = 'onRegister';
23900
+ this._uid = Generator.GenAutoIncrementId();
23901
+ this.key = this.name + this._uid;
23924
23902
  }
23925
- drawShape(arc, context, x, y, drawContext, params, fillCb, strokeCb) {
23926
- var _a;
23927
- const arcAttribute = getTheme(arc, params === null || params === void 0 ? void 0 : params.theme).arc;
23928
- const { fill = arcAttribute.fill } = arc.attribute;
23929
- const data = this.valid(arc, arcAttribute, fillCb, strokeCb);
23930
- if (!data) {
23931
- return;
23932
- }
23933
- const { fVisible, sVisible, doFill, doStroke } = data;
23934
- const z = (_a = this.z) !== null && _a !== void 0 ? _a : 0;
23935
- const { outerRadius = arcAttribute.outerRadius, innerRadius = arcAttribute.innerRadius, height = 10 } = arc.attribute;
23936
- const rgbArray = ColorStore.Get(fill, exports.ColorType.Color255);
23937
- const { light } = drawContext.stage || {};
23938
- const face = drawContext.hack_pieFace;
23939
- const z_face = {
23940
- top: z,
23941
- bottom: z + height
23942
- };
23943
- const n_face = {
23944
- top: [0, 1, 0],
23945
- bottom: [0, -1, 0],
23946
- outside: [1, 0, -1],
23947
- inside: [1, 0, -1]
23948
- };
23949
- if (face === 'bottom' || face === 'top') {
23950
- context.beginPath();
23951
- drawArcPath(arc, context, x, y, z_face[face], outerRadius, innerRadius);
23952
- context.setShadowBlendStyle && context.setShadowBlendStyle(arc, arc.attribute, arcAttribute);
23953
- if (doFill) {
23954
- if (fillCb) {
23955
- fillCb(context, arc.attribute, arcAttribute);
23956
- }
23957
- else if (fVisible) {
23958
- context.setCommonStyle(arc, arc.attribute, x, y, arcAttribute);
23959
- context.fillStyle = light ? light.computeColor(n_face[face], rgbArray) : fill;
23960
- context.fill();
23961
- }
23903
+ activate(context) {
23904
+ this.pluginService = context;
23905
+ context.stage.hooks.afterRender.tap(this.key, stage => {
23906
+ if (!(stage && stage === this.pluginService.stage)) {
23907
+ return;
23962
23908
  }
23963
- if (doStroke) {
23964
- if (strokeCb) {
23965
- strokeCb(context, arc.attribute, arcAttribute);
23966
- }
23967
- else if (sVisible) {
23968
- context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute);
23969
- context.stroke();
23970
- }
23909
+ stage.dirtyBounds.clear();
23910
+ });
23911
+ application.graphicService.hooks.beforeUpdateAABBBounds.tap(this.key, (graphic, stage, willUpdate, bounds) => {
23912
+ if (graphic.glyphHost) {
23913
+ graphic = graphic.glyphHost;
23971
23914
  }
23972
- }
23973
- else if (face === 'outside' || face === 'inside') {
23974
- if (face === 'inside') {
23975
- context.save();
23976
- context.beginPath();
23977
- context.arc(x, y, innerRadius, 0, vutils.pi2, true, z_face.top);
23978
- context.clip();
23915
+ if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {
23916
+ return;
23979
23917
  }
23980
- context.beginPath();
23981
- drawInnerOuterArcPath(arc, context, x, y, z_face.top, z_face.bottom, face === 'outside' ? outerRadius : innerRadius, (startAngle, endAngle) => {
23982
- const { outerDeltaAngle, innerDeltaAngle, outerStartAngle, outerEndAngle, innerEndAngle, innerStartAngle } = arc.getParsePadAngle(startAngle, endAngle);
23983
- if (face === 'outside') {
23984
- return {
23985
- innerouterDeltaAngle: outerDeltaAngle,
23986
- innerouterEndAngle: outerEndAngle,
23987
- innerouterStartAngle: outerStartAngle
23988
- };
23989
- }
23990
- return {
23991
- innerouterDeltaAngle: innerDeltaAngle,
23992
- innerouterEndAngle: innerEndAngle,
23993
- innerouterStartAngle: innerStartAngle
23994
- };
23995
- });
23996
- context.setShadowBlendStyle && context.setShadowBlendStyle(arc, arc.attribute, arcAttribute);
23997
- if (doFill) {
23998
- if (fillCb) {
23999
- fillCb(context, arc.attribute, arcAttribute);
24000
- }
24001
- else if (fVisible) {
24002
- context.setCommonStyle(arc, arc.attribute, x, y, arcAttribute);
24003
- context.fillStyle = light ? light.computeColor(n_face[face], rgbArray) : fill;
24004
- context.fill();
24005
- }
23918
+ if (graphic.isContainer && !graphic.shouldSelfChangeUpdateAABBBounds()) {
23919
+ return;
24006
23920
  }
24007
- if (doStroke) {
24008
- if (strokeCb) {
24009
- strokeCb(context, arc.attribute, arcAttribute);
24010
- }
24011
- else if (sVisible) {
24012
- context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute);
24013
- context.stroke();
24014
- }
23921
+ if (willUpdate) {
23922
+ globalBounds.setValue(bounds.x1, bounds.y1, bounds.x2, bounds.y2);
23923
+ stage.dirty(globalBounds, graphic.parent && graphic.parent.globalTransMatrix);
24015
23924
  }
24016
- if (face === 'inside') {
24017
- context.restore();
23925
+ });
23926
+ application.graphicService.hooks.afterUpdateAABBBounds.tap(this.key, (graphic, stage, bounds, params, selfChange) => {
23927
+ if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {
23928
+ return;
24018
23929
  }
24019
- }
23930
+ if (graphic.isContainer && !selfChange) {
23931
+ return;
23932
+ }
23933
+ stage.dirty(params.globalAABBBounds);
23934
+ });
23935
+ application.graphicService.hooks.onRemove.tap(this.key, (graphic) => {
23936
+ const stage = graphic.stage;
23937
+ if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {
23938
+ return;
23939
+ }
23940
+ if (stage) {
23941
+ stage.dirty(graphic.globalAABBBounds);
23942
+ }
23943
+ });
24020
23944
  }
24021
- draw(arc, renderService, drawContext, params) {
24022
- const arcAttribute = getTheme(arc, params === null || params === void 0 ? void 0 : params.theme).arc;
24023
- this._draw(arc, arcAttribute, false, drawContext, params);
23945
+ deactivate(context) {
23946
+ application.graphicService.hooks.beforeUpdateAABBBounds.taps =
23947
+ application.graphicService.hooks.beforeUpdateAABBBounds.taps.filter(item => {
23948
+ return item.name !== this.key;
23949
+ });
23950
+ application.graphicService.hooks.afterUpdateAABBBounds.taps =
23951
+ application.graphicService.hooks.afterUpdateAABBBounds.taps.filter(item => {
23952
+ return item.name !== this.key;
23953
+ });
23954
+ context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter(item => {
23955
+ return item.name !== this.key;
23956
+ });
23957
+ application.graphicService.hooks.onRemove.taps = application.graphicService.hooks.onRemove.taps.filter(item => {
23958
+ return item.name !== this.key;
23959
+ });
24024
23960
  }
24025
- };
24026
- DefaultCanvasArc3DRender = __decorate([
24027
- injectable()
24028
- ], DefaultCanvasArc3DRender);
23961
+ }
24029
23962
 
24030
- let DefaultCanvasPyramid3dRender = class DefaultCanvasPyramid3dRender extends BaseRender {
23963
+ const _tempBounds = new vutils.AABBBounds();
23964
+ class FlexLayoutPlugin {
24031
23965
  constructor() {
24032
- super(...arguments);
24033
- this.type = 'pyramid3d';
24034
- this.numberType = PYRAMID3D_NUMBER_TYPE;
23966
+ this.name = 'FlexLayoutPlugin';
23967
+ this.activeEvent = 'onRegister';
23968
+ this.id = Generator.GenAutoIncrementId();
23969
+ this.key = this.name + this.id;
23970
+ this.tempBounds = new vutils.AABBBounds();
24035
23971
  }
24036
- drawShape(pyramid3d, context, x, y, drawContext, params, fillCb, strokeCb) {
24037
- var _a;
24038
- const pyramidAttribute = getTheme(pyramid3d, params === null || params === void 0 ? void 0 : params.theme).polygon;
24039
- const { fill = pyramidAttribute.fill, stroke = pyramidAttribute.stroke, face = [true, true, true, true, true, true] } = pyramid3d.attribute;
24040
- const z = (_a = this.z) !== null && _a !== void 0 ? _a : 0;
24041
- const data = this.valid(pyramid3d, pyramidAttribute, fillCb, strokeCb);
24042
- if (!data) {
23972
+ tryLayout(graphic) {
23973
+ const p = graphic.parent;
23974
+ if (!p || !graphic.needUpdateLayout()) {
24043
23975
  return;
24044
23976
  }
24045
- const { light, camera } = drawContext.stage || {};
24046
- const face3d = pyramid3d.findFace();
24047
- if (fill !== false) {
24048
- context.setCommonStyle(pyramid3d, pyramid3d.attribute, x, y, pyramidAttribute);
24049
- let fc = fill;
24050
- if (typeof fc !== 'string') {
24051
- fc = 'black';
24052
- }
24053
- this.fill(x, y, z, face3d, face, fc, context, light, camera, pyramid3d, pyramidAttribute, fillCb);
24054
- }
24055
- if (stroke !== false) {
24056
- context.setStrokeStyle(pyramid3d, pyramid3d.attribute, x, y, pyramidAttribute);
24057
- this.stroke(x, y, z, face3d, context);
23977
+ const theme = getTheme(p).group;
23978
+ const { display = theme.display } = p.attribute;
23979
+ if (display !== 'flex') {
23980
+ return;
24058
23981
  }
24059
- }
24060
- stroke(x, y, z, face3d, context) {
24061
- const vertices = face3d.vertices;
24062
- face3d.edges.forEach(p => {
24063
- const p1 = vertices[p[0]];
24064
- const p2 = vertices[p[1]];
24065
- const v1 = {
24066
- x: x + p1[0],
24067
- y: y + p1[1],
24068
- z: z + p1[2]
24069
- };
24070
- const v2 = {
24071
- x: x + p2[0],
24072
- y: y + p2[1],
24073
- z: z + p2[2]
24074
- };
24075
- context.beginPath();
24076
- context.moveTo(v1.x, v1.y, v1.z);
24077
- context.lineTo(v2.x, v2.y, v2.z);
24078
- context.stroke();
24079
- });
24080
- }
24081
- fill(x, y, z, face3d, faces, fillColor, context, light, camera, pyramid3d, pyramid3dAttribute, fillCb) {
24082
- const rgbArray = ColorStore.Get(fillColor, exports.ColorType.Color255);
24083
- const vertices = face3d.vertices;
24084
- const viewdVerticesZ = vertices.map(v => {
24085
- return context.view(v[0], v[1], v[2])[2];
24086
- });
24087
- const sortFace = [];
24088
- face3d.polygons.forEach((p, i) => {
24089
- if (!faces[i]) {
24090
- return;
24091
- }
24092
- sortFace.push({
24093
- faceIdx: i,
24094
- polygon: p
24095
- });
24096
- const { polygon, normal } = p;
24097
- const z1 = viewdVerticesZ[polygon[0]];
24098
- const z2 = viewdVerticesZ[polygon[1]];
24099
- const z3 = viewdVerticesZ[polygon[2]];
24100
- const z4 = viewdVerticesZ[polygon[3]];
24101
- p.ave_z = z1 + z2 + z3 + z4;
24102
- });
24103
- sortFace.sort((a, b) => b.polygon.ave_z - a.polygon.ave_z);
24104
- sortFace.forEach(item => {
24105
- const { polygon, normal } = item.polygon;
24106
- const p1 = vertices[polygon[0]];
24107
- const p2 = vertices[polygon[1]];
24108
- const p3 = vertices[polygon[2]];
24109
- const p4 = vertices[polygon[3]];
24110
- const v1 = {
24111
- x: x + p1[0],
24112
- y: y + p1[1],
24113
- z: z + p1[2]
24114
- };
24115
- const v2 = {
24116
- x: x + p2[0],
24117
- y: y + p2[1],
24118
- z: z + p2[2]
24119
- };
24120
- const v3 = {
24121
- x: x + p3[0],
24122
- y: y + p3[1],
24123
- z: z + p3[2]
24124
- };
24125
- const v4 = {
24126
- x: x + p4[0],
24127
- y: y + p4[1],
24128
- z: z + p4[2]
24129
- };
24130
- context.beginPath();
24131
- context.moveTo(v1.x, v1.y, v1.z);
24132
- context.lineTo(v2.x, v2.y, v2.z);
24133
- context.lineTo(v3.x, v3.y, v3.z);
24134
- context.lineTo(v4.x, v4.y, v4.z);
24135
- context.closePath();
24136
- if (fillCb) {
24137
- fillCb(context, pyramid3d.attribute, pyramid3dAttribute);
23982
+ const { flexDirection = theme.flexDirection, flexWrap = theme.flexWrap, justifyContent = theme.justifyContent, alignItems = theme.alignItems, alignContent = theme.alignContent, clip = theme.clip } = p.attribute;
23983
+ let childrenWidth = 0;
23984
+ let childrenHeight = 0;
23985
+ let boundsLegal = 0;
23986
+ p.forEachChildren((child) => {
23987
+ const bounds = child.AABBBounds;
23988
+ if (flexDirection === 'column' || flexDirection === 'column-reverse') {
23989
+ childrenHeight += bounds.height();
23990
+ childrenWidth = Math.max(childrenWidth, bounds.width());
24138
23991
  }
24139
23992
  else {
24140
- context.fillStyle = light ? light.computeColor(normal, rgbArray) : fillColor;
24141
- context.fill();
23993
+ childrenWidth += bounds.width();
23994
+ childrenHeight = Math.max(childrenHeight, bounds.height());
24142
23995
  }
24143
- });
24144
- }
24145
- draw(pyramid3d, renderService, drawContext) {
24146
- const pyramid3dAttribute = getTheme(pyramid3d).polygon;
24147
- this._draw(pyramid3d, pyramid3dAttribute, false, drawContext);
24148
- }
24149
- };
24150
- DefaultCanvasPyramid3dRender = __decorate([
24151
- injectable()
24152
- ], DefaultCanvasPyramid3dRender);
24153
-
24154
- var renderModule = new ContainerModule(bind => {
24155
- bind(DefaultBaseBackgroundRenderContribution).toSelf().inSingletonScope();
24156
- bind(DefaultBaseTextureRenderContribution).toSelf().inSingletonScope();
24157
- bind(DrawContribution).to(DefaultDrawContribution);
24158
- bind(IncrementalDrawContribution).to(DefaultIncrementalDrawContribution);
24159
- bind(exports.DefaultCanvasCircleRender).toSelf().inSingletonScope();
24160
- bind(CircleRender).to(exports.DefaultCanvasCircleRender).inSingletonScope();
24161
- bind(GraphicRender).toService(CircleRender);
24162
- bindContributionProvider(bind, CircleRenderContribution);
24163
- bind(exports.DefaultCanvasRectRender).toSelf().inSingletonScope();
24164
- bind(RectRender).to(exports.DefaultCanvasRectRender).inSingletonScope();
24165
- bind(GraphicRender).toService(RectRender);
24166
- bind(Rect3DRender).to(DefaultCanvasRect3dRender).inSingletonScope();
24167
- bind(GraphicRender).toService(Rect3DRender);
24168
- bindContributionProvider(bind, RectRenderContribution);
24169
- bind(TextRender).to(exports.DefaultCanvasTextRender).inSingletonScope();
24170
- bind(GraphicRender).toService(TextRender);
24171
- bindContributionProvider(bind, TextRenderContribution);
24172
- bind(exports.DefaultCanvasPathRender).toSelf().inSingletonScope();
24173
- bind(PathRender).to(exports.DefaultCanvasPathRender).inSingletonScope();
24174
- bind(GraphicRender).toService(PathRender);
24175
- bindContributionProvider(bind, PathRenderContribution);
24176
- bind(exports.DefaultCanvasSymbolRender).toSelf().inSingletonScope();
24177
- bind(SymbolRender).to(exports.DefaultCanvasSymbolRender).inSingletonScope();
24178
- bind(GraphicRender).toService(SymbolRender);
24179
- bindContributionProvider(bind, SymbolRenderContribution);
24180
- bind(exports.DefaultCanvasArcRender).toSelf().inSingletonScope();
24181
- bind(ArcRender).to(exports.DefaultCanvasArcRender).inSingletonScope();
24182
- bind(GraphicRender).toService(ArcRender);
24183
- bind(Arc3dRender).to(DefaultCanvasArc3DRender).inSingletonScope();
24184
- bind(GraphicRender).toService(Arc3dRender);
24185
- bindContributionProvider(bind, ArcRenderContribution);
24186
- bind(exports.DefaultCanvasLineRender).toSelf().inSingletonScope();
24187
- bind(LineRender).to(exports.DefaultCanvasLineRender).inSingletonScope();
24188
- bind(GraphicRender).toService(LineRender);
24189
- bind(DefaultIncrementalCanvasLineRender).toSelf().inSingletonScope();
24190
- bind(DefaultIncrementalCanvasAreaRender).toSelf().inSingletonScope();
24191
- bind(exports.DefaultCanvasAreaRender).toSelf().inSingletonScope();
24192
- bind(AreaRender).to(exports.DefaultCanvasAreaRender).inSingletonScope();
24193
- bind(GraphicRender).toService(AreaRender);
24194
- bindContributionProvider(bind, AreaRenderContribution);
24195
- bind(GroupRender).to(DefaultCanvasGroupRender).inSingletonScope();
24196
- bind(GraphicRender).toService(GroupRender);
24197
- bindContributionProvider(bind, GroupRenderContribution);
24198
- bind(PolygonRender).to(exports.DefaultCanvasPolygonRender).inSingletonScope();
24199
- bind(GraphicRender).toService(PolygonRender);
24200
- bindContributionProvider(bind, PolygonRenderContribution);
24201
- bind(GlyphRender).to(DefaultCanvasGlyphRender).inSingletonScope();
24202
- bind(GraphicRender).toService(GlyphRender);
24203
- bind(ImageRender).to(exports.DefaultCanvasImageRender).inSingletonScope();
24204
- bind(GraphicRender).toService(ImageRender);
24205
- bindContributionProvider(bind, ImageRenderContribution);
24206
- bind(RichTextRender).to(DefaultCanvasRichTextRender).inSingletonScope();
24207
- bind(GraphicRender).toService(RichTextRender);
24208
- bind(Pyramid3dRender).to(DefaultCanvasPyramid3dRender).inSingletonScope();
24209
- bind(GraphicRender).toService(Pyramid3dRender);
24210
- bind(exports.DefaultBaseInteractiveRenderContribution).toSelf().inSingletonScope();
24211
- bind(TextRenderContribution).toService(exports.DefaultBaseInteractiveRenderContribution);
24212
- bind(ArcRenderContribution).toService(exports.DefaultBaseInteractiveRenderContribution);
24213
- bind(PathRenderContribution).toService(exports.DefaultBaseInteractiveRenderContribution);
24214
- bind(SymbolRenderContribution).toService(exports.DefaultBaseInteractiveRenderContribution);
24215
- bind(RectRenderContribution).toService(exports.DefaultBaseInteractiveRenderContribution);
24216
- bind(ImageRenderContribution).toService(exports.DefaultBaseInteractiveRenderContribution);
24217
- bind(CircleRenderContribution).toService(exports.DefaultBaseInteractiveRenderContribution);
24218
- bind(AreaRenderContribution).toService(exports.DefaultBaseInteractiveRenderContribution);
24219
- bind(PolygonRenderContribution).toService(exports.DefaultBaseInteractiveRenderContribution);
24220
- bindContributionProvider(bind, InteractiveSubRenderContribution);
24221
- bindContributionProvider(bind, GraphicRender);
24222
- bind(CommonDrawItemInterceptorContribution).toSelf().inSingletonScope();
24223
- bind(DrawItemInterceptor).toService(CommonDrawItemInterceptorContribution);
24224
- bindContributionProvider(bind, DrawItemInterceptor);
24225
- });
24226
-
24227
- function load(container) {
24228
- container.load(renderModule);
24229
- }
24230
-
24231
- container.load(coreModule);
24232
- container.load(graphicModule);
24233
- container.load(renderModule$1);
24234
- container.load(pickModule);
24235
- container.load(pluginModule);
24236
- load$1(container);
24237
- load(container);
24238
- const vglobal = container.get(VGlobal);
24239
- application.global = vglobal;
24240
- const graphicUtil = container.get(GraphicUtil);
24241
- application.graphicUtil = graphicUtil;
24242
- const transformUtil = container.get(TransformUtil);
24243
- application.transformUtil = transformUtil;
24244
- const graphicService = container.get(GraphicService);
24245
- application.graphicService = graphicService;
24246
- const layerService = container.get(LayerService);
24247
- application.layerService = layerService;
24248
-
24249
- class AutoRenderPlugin {
24250
- constructor() {
24251
- this.name = 'AutoRenderPlugin';
24252
- this.activeEvent = 'onRegister';
24253
- this._uid = Generator.GenAutoIncrementId();
24254
- this.key = this.name + this._uid;
24255
- }
24256
- activate(context) {
24257
- this.pluginService = context;
24258
- application.graphicService.hooks.onAttributeUpdate.tap(this.key, graphic => {
24259
- if (graphic.glyphHost) {
24260
- graphic = graphic.glyphHost;
24261
- }
24262
- if (graphic.stage === context.stage && graphic.stage != null) {
24263
- graphic.stage.renderNextFrame();
24264
- }
24265
- });
24266
- application.graphicService.hooks.onSetStage.tap(this.key, graphic => {
24267
- if (graphic.glyphHost) {
24268
- graphic = graphic.glyphHost;
24269
- }
24270
- if (graphic.stage === context.stage && graphic.stage != null) {
24271
- graphic.stage.renderNextFrame();
24272
- }
24273
- });
24274
- }
24275
- deactivate(context) {
24276
- application.graphicService.hooks.onAttributeUpdate.taps =
24277
- application.graphicService.hooks.onAttributeUpdate.taps.filter(item => {
24278
- return item.name !== this.key;
24279
- });
24280
- application.graphicService.hooks.onSetStage.taps = application.graphicService.hooks.onSetStage.taps.filter(item => {
24281
- return item.name !== this.key;
24282
- });
24283
- }
24284
- }
24285
-
24286
- class ViewTransform3dPlugin {
24287
- constructor() {
24288
- this.name = 'ViewTransform3dPlugin';
24289
- this.activeEvent = 'onRegister';
24290
- this._uid = Generator.GenAutoIncrementId();
24291
- this.key = this.name + this._uid;
24292
- this.onMouseDown = (e) => {
24293
- if (!this.option3d) {
24294
- this.option3d = this.pluginService.stage.option3d;
24295
- }
24296
- if (!this.option3d) {
24297
- return;
24298
- }
24299
- this.mousedown = true;
24300
- this.pageX = e.page.x;
24301
- this.pageY = e.page.y;
24302
- };
24303
- this.onMouseUp = (e) => {
24304
- if (!this.option3d) {
24305
- this.option3d = this.pluginService.stage.option3d;
24306
- }
24307
- if (!this.option3d) {
24308
- return;
24309
- }
24310
- this.mousedown = false;
24311
- };
24312
- this.onMouseMove = (e) => {
24313
- var _a, _b;
24314
- const stage = this.pluginService.stage;
24315
- if (!this.option3d) {
24316
- this.option3d = stage.option3d;
24317
- }
24318
- if (!this.option3d) {
24319
- return;
24320
- }
24321
- if (this.mousedown) {
24322
- if (!this.pageX || !this.pageY) {
24323
- this.pageX = e.page.x;
24324
- this.pageY = e.page.y;
24325
- }
24326
- else {
24327
- const deltaX = e.page.x - this.pageX;
24328
- const deltaY = e.page.y - this.pageY;
24329
- this.pageX = e.page.x;
24330
- this.pageY = e.page.y;
24331
- const angle1 = deltaX / 100;
24332
- const angle2 = deltaY / 100;
24333
- this.option3d.alpha = ((_a = this.option3d.alpha) !== null && _a !== void 0 ? _a : 0) + angle1;
24334
- this.option3d.beta = ((_b = this.option3d.beta) !== null && _b !== void 0 ? _b : 0) + angle2;
24335
- stage.set3dOptions(this.option3d);
24336
- stage.renderNextFrame();
24337
- }
24338
- }
24339
- };
24340
- }
24341
- activate(context) {
24342
- this.pluginService = context;
24343
- const stage = context.stage;
24344
- this.option3d = stage.option3d;
24345
- stage.addEventListener('mousedown', this.onMouseDown);
24346
- stage.addEventListener('mouseup', this.onMouseUp);
24347
- stage.addEventListener('mousemove', this.onMouseMove);
24348
- }
24349
- deactivate(context) {
24350
- const stage = context.stage;
24351
- stage.removeEventListener('mousedown', this.onMouseDown);
24352
- stage.removeEventListener('mouseup', this.onMouseUp);
24353
- stage.removeEventListener('mousemove', this.onMouseMove);
24354
- }
24355
- }
24356
-
24357
- class IncrementalAutoRenderPlugin {
24358
- constructor() {
24359
- this.name = 'IncrementalAutoRenderPlugin';
24360
- this.activeEvent = 'onRegister';
24361
- this.nextFrameRenderGroupSet = new Set();
24362
- this.willNextFrameRender = false;
24363
- this.nextUserParams = {};
24364
- this._uid = Generator.GenAutoIncrementId();
24365
- this.key = this.name + this._uid;
24366
- }
24367
- activate(context) {
24368
- this.pluginService = context;
24369
- application.graphicService.hooks.onAddIncremental.tap(this.key, (graphic, group, stage) => {
24370
- if (graphic.glyphHost) {
24371
- graphic = graphic.glyphHost;
24372
- }
24373
- if (graphic.stage === context.stage && graphic.stage != null) {
24374
- this.nextUserParams.startAtId = group._uid;
24375
- this.renderNextFrame(group);
24376
- }
24377
- });
24378
- application.graphicService.hooks.onClearIncremental.tap(this.key, (group, stage) => {
24379
- if (group.stage === context.stage && group.stage != null) {
24380
- this.nextUserParams.startAtId = group._uid;
24381
- this.nextUserParams.restartIncremental = true;
24382
- this.renderNextFrame(group);
24383
- }
24384
- });
24385
- }
24386
- deactivate(context) {
24387
- application.graphicService.hooks.onAddIncremental.taps =
24388
- application.graphicService.hooks.onAddIncremental.taps.filter(item => {
24389
- return item.name !== this.key;
24390
- });
24391
- application.graphicService.hooks.onClearIncremental.taps =
24392
- application.graphicService.hooks.onClearIncremental.taps.filter(item => {
24393
- return item.name !== this.key;
24394
- });
24395
- }
24396
- renderNextFrame(group) {
24397
- this.nextFrameRenderGroupSet.add(group);
24398
- if (!this.willNextFrameRender) {
24399
- this.willNextFrameRender = true;
24400
- application.global.getRequestAnimationFrame()(() => {
24401
- this._doRenderInThisFrame();
24402
- this.willNextFrameRender = false;
24403
- });
24404
- }
24405
- }
24406
- _doRenderInThisFrame() {
24407
- const stage = this.pluginService.stage;
24408
- if (this.nextFrameRenderGroupSet.size) {
24409
- this.nextFrameRenderGroupSet.forEach(group => {
24410
- const layer = group.layer;
24411
- if (!layer || !group.layer.subLayers) {
24412
- return;
24413
- }
24414
- const subLayer = group.layer.subLayers.get(group._uid);
24415
- if (!subLayer || !subLayer.drawContribution) {
24416
- return;
24417
- }
24418
- subLayer.drawContribution.draw(stage.renderService, Object.assign({ x: stage.x, y: stage.y, width: layer.viewWidth, height: layer.viewHeight, stage,
24419
- layer, clear: 'transparent', renderService: stage.renderService, updateBounds: false, startAtId: group._uid, context: subLayer.layer.getNativeHandler().getContext() }, this.nextUserParams));
24420
- });
24421
- this.nextUserParams = {};
24422
- this.nextFrameRenderGroupSet.clear();
24423
- }
24424
- }
24425
- }
24426
-
24427
- class HtmlAttributePlugin {
24428
- constructor() {
24429
- this.name = 'HtmlAttributePlugin';
24430
- this.activeEvent = 'onRegister';
24431
- this._uid = Generator.GenAutoIncrementId();
24432
- this.key = this.name + this._uid;
24433
- }
24434
- activate(context) {
24435
- this.pluginService = context;
24436
- context.stage.hooks.afterRender.tap(this.key, stage => {
24437
- if (!(stage && stage === this.pluginService.stage)) {
24438
- return;
24439
- }
24440
- this.drawHTML(context.stage.renderService);
24441
- });
24442
- application.graphicService.hooks.onRelease.tap(this.key, graphic => {
24443
- this.removeDom(graphic);
24444
- });
24445
- }
24446
- deactivate(context) {
24447
- context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter(item => {
24448
- return item.name !== this.key;
24449
- });
24450
- }
24451
- drawHTML(renderService) {
24452
- if (application.global.env === 'browser') {
24453
- renderService.renderTreeRoots
24454
- .sort((a, b) => {
24455
- var _a, _b;
24456
- return ((_a = a.attribute.zIndex) !== null && _a !== void 0 ? _a : DefaultAttribute.zIndex) - ((_b = b.attribute.zIndex) !== null && _b !== void 0 ? _b : DefaultAttribute.zIndex);
24457
- })
24458
- .forEach(group => {
24459
- this.renderGroupHTML(group);
24460
- });
24461
- }
24462
- }
24463
- renderGroupHTML(group) {
24464
- this.renderGraphicHTML(group);
24465
- group.forEachChildren((g) => {
24466
- if (g.isContainer) {
24467
- this.renderGroupHTML(g);
24468
- }
24469
- else {
24470
- this.renderGraphicHTML(g);
24471
- }
24472
- });
24473
- }
24474
- removeDom(graphic) {
24475
- if (graphic.bindDom && graphic.bindDom.size) {
24476
- graphic.bindDom.forEach(item => {
24477
- item.dom && item.dom.parentElement.removeChild(item.dom);
24478
- });
24479
- graphic.bindDom.clear();
24480
- }
24481
- }
24482
- renderGraphicHTML(graphic) {
24483
- const { html } = graphic.attribute;
24484
- if (!html) {
24485
- if (graphic.bindDom && graphic.bindDom.size) {
24486
- graphic.bindDom.forEach(item => {
24487
- item.dom && item.dom.parentElement.removeChild(item.dom);
24488
- });
24489
- graphic.bindDom.clear();
24490
- }
24491
- return;
24492
- }
24493
- const stage = graphic.stage;
24494
- if (!stage) {
24495
- return;
24496
- }
24497
- const { dom, container, width, height, style, anchorType = 'boundsLeftTop' } = html;
24498
- if (!graphic.bindDom) {
24499
- graphic.bindDom = new Map();
24500
- }
24501
- const lastDom = graphic.bindDom.get(dom);
24502
- if (lastDom && !(container && container !== lastDom.container)) {
24503
- return;
24504
- }
24505
- graphic.bindDom.forEach(({ wrapGroup }) => {
24506
- application.global.removeDom(wrapGroup);
24507
- });
24508
- let nativeDom;
24509
- if (typeof dom === 'string') {
24510
- nativeDom = new DOMParser().parseFromString(dom, 'text/html').firstChild;
24511
- }
24512
- else {
24513
- nativeDom = dom;
24514
- }
24515
- let nativeContainer;
24516
- const _container = container || (stage.params.enableHtmlAttribute === true ? null : stage.params.enableHtmlAttribute);
24517
- if (_container) {
24518
- if (typeof _container === 'string') {
24519
- nativeContainer = application.global.getElementById(_container);
24520
- }
24521
- else {
24522
- nativeContainer = _container;
24523
- }
24524
- }
24525
- else {
24526
- nativeContainer = graphic.stage.window.getContainer();
24527
- }
24528
- const wrapGroup = application.global.createDom({ tagName: 'div', width, height, style, parent: nativeContainer });
24529
- if (wrapGroup) {
24530
- wrapGroup.appendChild(nativeDom);
24531
- graphic.bindDom.set(dom, { dom: nativeDom, container, wrapGroup: wrapGroup });
24532
- }
24533
- wrapGroup.style.pointerEvents = 'none';
24534
- if (!wrapGroup.style.position) {
24535
- wrapGroup.style.position = 'absolute';
24536
- nativeContainer.style.position = 'relative';
24537
- }
24538
- let left = 0;
24539
- let top = 0;
24540
- if (anchorType === 'position') {
24541
- const matrix = graphic.transMatrix;
24542
- left = matrix.e;
24543
- top = matrix.f;
24544
- }
24545
- else {
24546
- const b = graphic.AABBBounds;
24547
- left = b.x1;
24548
- top = b.y1;
24549
- }
24550
- const containerTL = application.global.getElementTopLeft(nativeContainer, false);
24551
- const windowTL = stage.window.getTopLeft(false);
24552
- const offsetX = left + windowTL.left - containerTL.left;
24553
- const offsetTop = top + windowTL.top - containerTL.top;
24554
- wrapGroup.style.left = `${offsetX}px`;
24555
- wrapGroup.style.top = `${offsetTop}px`;
24556
- }
24557
- }
24558
-
24559
- const globalBounds = new vutils.AABBBounds();
24560
- class DirtyBoundsPlugin {
24561
- constructor() {
24562
- this.name = 'DirtyBoundsPlugin';
24563
- this.activeEvent = 'onRegister';
24564
- this._uid = Generator.GenAutoIncrementId();
24565
- this.key = this.name + this._uid;
24566
- }
24567
- activate(context) {
24568
- this.pluginService = context;
24569
- context.stage.hooks.afterRender.tap(this.key, stage => {
24570
- if (!(stage && stage === this.pluginService.stage)) {
24571
- return;
24572
- }
24573
- stage.dirtyBounds.clear();
24574
- });
24575
- application.graphicService.hooks.beforeUpdateAABBBounds.tap(this.key, (graphic, stage, willUpdate, bounds) => {
24576
- if (graphic.glyphHost) {
24577
- graphic = graphic.glyphHost;
24578
- }
24579
- if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {
24580
- return;
24581
- }
24582
- if (graphic.isContainer && !graphic.shouldSelfChangeUpdateAABBBounds()) {
24583
- return;
24584
- }
24585
- if (willUpdate) {
24586
- globalBounds.setValue(bounds.x1, bounds.y1, bounds.x2, bounds.y2);
24587
- stage.dirty(globalBounds, graphic.parent && graphic.parent.globalTransMatrix);
24588
- }
24589
- });
24590
- application.graphicService.hooks.afterUpdateAABBBounds.tap(this.key, (graphic, stage, bounds, params, selfChange) => {
24591
- if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {
24592
- return;
24593
- }
24594
- if (graphic.isContainer && !selfChange) {
24595
- return;
24596
- }
24597
- stage.dirty(params.globalAABBBounds);
24598
- });
24599
- application.graphicService.hooks.onRemove.tap(this.key, (graphic) => {
24600
- const stage = graphic.stage;
24601
- if (!(stage && stage === this.pluginService.stage && stage.renderCount)) {
24602
- return;
24603
- }
24604
- if (stage) {
24605
- stage.dirty(graphic.globalAABBBounds);
24606
- }
24607
- });
24608
- }
24609
- deactivate(context) {
24610
- application.graphicService.hooks.beforeUpdateAABBBounds.taps =
24611
- application.graphicService.hooks.beforeUpdateAABBBounds.taps.filter(item => {
24612
- return item.name !== this.key;
24613
- });
24614
- application.graphicService.hooks.afterUpdateAABBBounds.taps =
24615
- application.graphicService.hooks.afterUpdateAABBBounds.taps.filter(item => {
24616
- return item.name !== this.key;
24617
- });
24618
- context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter(item => {
24619
- return item.name !== this.key;
24620
- });
24621
- application.graphicService.hooks.onRemove.taps = application.graphicService.hooks.onRemove.taps.filter(item => {
24622
- return item.name !== this.key;
24623
- });
24624
- }
24625
- }
24626
-
24627
- const _tempBounds = new vutils.AABBBounds();
24628
- class FlexLayoutPlugin {
24629
- constructor() {
24630
- this.name = 'FlexLayoutPlugin';
24631
- this.activeEvent = 'onRegister';
24632
- this.id = Generator.GenAutoIncrementId();
24633
- this.key = this.name + this.id;
24634
- this.tempBounds = new vutils.AABBBounds();
24635
- }
24636
- tryLayout(graphic) {
24637
- const p = graphic.parent;
24638
- if (!p || !graphic.needUpdateLayout()) {
24639
- return;
24640
- }
24641
- const theme = getTheme(p).group;
24642
- const { display = theme.display } = p.attribute;
24643
- if (display !== 'flex') {
24644
- return;
24645
- }
24646
- const { flexDirection = theme.flexDirection, flexWrap = theme.flexWrap, justifyContent = theme.justifyContent, alignItems = theme.alignItems, alignContent = theme.alignContent, clip = theme.clip } = p.attribute;
24647
- let childrenWidth = 0;
24648
- let childrenHeight = 0;
24649
- let boundsLegal = 0;
24650
- p.forEachChildren((child) => {
24651
- const bounds = child.AABBBounds;
24652
- if (flexDirection === 'column' || flexDirection === 'column-reverse') {
24653
- childrenHeight += bounds.height();
24654
- childrenWidth = Math.max(childrenWidth, bounds.width());
24655
- }
24656
- else {
24657
- childrenWidth += bounds.width();
24658
- childrenHeight = Math.max(childrenHeight, bounds.height());
24659
- }
24660
- boundsLegal += bounds.x1;
24661
- boundsLegal += bounds.y1;
24662
- boundsLegal += bounds.x2;
24663
- boundsLegal += bounds.y2;
23996
+ boundsLegal += bounds.x1;
23997
+ boundsLegal += bounds.y1;
23998
+ boundsLegal += bounds.x2;
23999
+ boundsLegal += bounds.y2;
24664
24000
  });
24665
24001
  if (!isFinite(boundsLegal)) {
24666
24002
  return;
@@ -26076,802 +25412,1531 @@
26076
25412
  getLineDash() {
26077
25413
  return [];
26078
25414
  }
26079
- isPointInPath(x, y) {
26080
- this.matrix.transformPoint({ x, y }, globalPoint);
26081
- return contain(this.path.commandList, globalPoint.x, globalPoint.y);
25415
+ isPointInPath(x, y) {
25416
+ this.matrix.transformPoint({ x, y }, globalPoint);
25417
+ return contain(this.path.commandList, globalPoint.x, globalPoint.y);
25418
+ }
25419
+ isPointInStroke(x, y) {
25420
+ if (!this.lineWidth) {
25421
+ return false;
25422
+ }
25423
+ this.matrix.transformPoint({ x, y }, globalPoint);
25424
+ const lineWidth = getScaledStroke(this, this.lineWidth, this.dpr);
25425
+ return containStroke(this.path.commandList, lineWidth, globalPoint.x, globalPoint.y);
25426
+ }
25427
+ measureText(text) {
25428
+ throw new Error('不支持measureText');
25429
+ }
25430
+ putImageData(imagedata, dx, dy) {
25431
+ throw new Error('不支持measureText');
25432
+ }
25433
+ setLineDash(segments) {
25434
+ return;
25435
+ }
25436
+ stroke(path) {
25437
+ return;
25438
+ }
25439
+ strokeRect(x, y, width, height) {
25440
+ this.path.rect(x, y, width, height);
25441
+ }
25442
+ strokeText(text, x, y) {
25443
+ return;
25444
+ }
25445
+ drawImage() {
25446
+ return;
25447
+ }
25448
+ setCommonStyle(params, attribute, offsetX, offsetY, defaultParams) {
25449
+ return;
25450
+ }
25451
+ _setCommonStyle(params, offsetX, offsetY, defaultParams) {
25452
+ return;
25453
+ }
25454
+ setStrokeStyle(params, attribute, offsetX, offsetY, defaultParams) {
25455
+ return;
25456
+ }
25457
+ _setStrokeStyle(params, offsetX, offsetY, defaultParams) {
25458
+ return;
25459
+ }
25460
+ setTextStyleWithoutAlignBaseline(params, defaultParams) {
25461
+ return;
25462
+ }
25463
+ setTextStyle(params, defaultParams) {
25464
+ return;
25465
+ }
25466
+ draw() {
25467
+ return;
25468
+ }
25469
+ clearMatrix(setTransform = true, dpr = this.dpr) {
25470
+ this.setTransformFromMatrix(initMatrix, setTransform, dpr);
25471
+ }
25472
+ onlyTranslate(dpr = this.dpr) {
25473
+ return this.matrix.a === dpr && this.matrix.b === 0 && this.matrix.c === 0 && this.matrix.d === dpr;
25474
+ }
25475
+ release(...params) {
25476
+ this.stack.forEach(m => matrixAllocate.free(m));
25477
+ this.stack.length = 0;
25478
+ return;
25479
+ }
25480
+ };
25481
+ exports.EmptyContext2d = __decorate([
25482
+ injectable(),
25483
+ __metadata("design:paramtypes", [Object, Number])
25484
+ ], exports.EmptyContext2d);
25485
+
25486
+ const DefaultConfig = {
25487
+ WIDTH: 500,
25488
+ HEIGHT: 500,
25489
+ DPR: 1
25490
+ };
25491
+ exports.BaseCanvas = class BaseCanvas {
25492
+ get displayWidth() {
25493
+ return this._pixelWidth / this._dpr;
25494
+ }
25495
+ get displayHeight() {
25496
+ return this._pixelHeight / this._dpr;
25497
+ }
25498
+ get id() {
25499
+ return this._id;
25500
+ }
25501
+ get x() {
25502
+ return this._x;
25503
+ }
25504
+ set x(_x) {
25505
+ this._x = _x;
25506
+ }
25507
+ get y() {
25508
+ return this._y;
25509
+ }
25510
+ set y(_y) {
25511
+ this._y = _y;
25512
+ }
25513
+ get nativeCanvas() {
25514
+ return this._nativeCanvas;
25515
+ }
25516
+ get width() {
25517
+ return this._pixelWidth;
25518
+ }
25519
+ set width(width) {
25520
+ this._pixelWidth = width;
25521
+ this._displayWidth = width / (this._dpr || 1);
25522
+ }
25523
+ get height() {
25524
+ return this._pixelHeight;
25525
+ }
25526
+ set height(height) {
25527
+ this._pixelHeight = height;
25528
+ this._displayHeight = height / (this._dpr || 1);
25529
+ }
25530
+ getContext(str) {
25531
+ return this._context;
25532
+ }
25533
+ get visiable() {
25534
+ return this._visiable;
25535
+ }
25536
+ set visiable(visiable) {
25537
+ this._visiable = visiable;
25538
+ visiable ? this.show() : this.hide();
25539
+ }
25540
+ get dpr() {
25541
+ return this._dpr;
25542
+ }
25543
+ set dpr(dpr) {
25544
+ this._dpr = dpr;
25545
+ this.resize(this._displayWidth, this._displayHeight);
25546
+ }
25547
+ constructor(params) {
25548
+ var _a;
25549
+ const { nativeCanvas, width = DefaultConfig.WIDTH, height = DefaultConfig.HEIGHT, dpr = DefaultConfig.DPR, x, y, id, canvasControled = true } = params;
25550
+ const offsetX = 0;
25551
+ const offsetY = 0;
25552
+ this._x = x !== null && x !== void 0 ? x : offsetX;
25553
+ this._y = y !== null && y !== void 0 ? y : offsetY;
25554
+ this._pixelWidth = width * dpr;
25555
+ this._pixelHeight = height * dpr;
25556
+ this._visiable = params.visiable !== false;
25557
+ this.controled = canvasControled;
25558
+ this._displayWidth = width;
25559
+ this._displayHeight = height;
25560
+ this._dpr = dpr;
25561
+ this._nativeCanvas = nativeCanvas;
25562
+ this._id = (_a = nativeCanvas.id) !== null && _a !== void 0 ? _a : id;
25563
+ if (id) {
25564
+ nativeCanvas.id = id;
25565
+ }
25566
+ this.init(params);
25567
+ }
25568
+ getNativeCanvas() {
25569
+ return this._nativeCanvas;
25570
+ }
25571
+ hide() {
25572
+ return;
25573
+ }
25574
+ show() {
25575
+ return;
25576
+ }
25577
+ applyPosition() {
25578
+ return;
25579
+ }
25580
+ resetStyle(params) {
25581
+ return;
25582
+ }
25583
+ resize(width, height) {
25584
+ return;
25585
+ }
25586
+ toDataURL(mimeType, quality) {
25587
+ return '';
25588
+ }
25589
+ readPixels(x, y, w, h) {
25590
+ return this._context.getImageData(x, y, w, h);
25591
+ }
25592
+ convertToBlob(options) {
25593
+ throw new Error('暂未实现');
25594
+ }
25595
+ transferToImageBitmap() {
25596
+ throw new Error('暂未实现');
25597
+ }
25598
+ release(...params) {
25599
+ if (this.controled) {
25600
+ this._nativeCanvas.parentElement && this._nativeCanvas.parentElement.removeChild(this._nativeCanvas);
25601
+ }
25602
+ }
25603
+ };
25604
+ exports.BaseCanvas.env = 'browser';
25605
+ exports.BaseCanvas = __decorate([
25606
+ injectable(),
25607
+ __metadata("design:paramtypes", [Object])
25608
+ ], exports.BaseCanvas);
25609
+
25610
+ exports.BaseEnvContribution = class BaseEnvContribution {
25611
+ configure(service, ...p) {
25612
+ if (service.env === this.type) {
25613
+ service.setActiveEnvContribution(this);
25614
+ }
25615
+ }
25616
+ getNativeAABBBounds(dom) {
25617
+ return new vutils.AABBBounds();
25618
+ }
25619
+ removeDom(dom) {
25620
+ return false;
25621
+ }
25622
+ createDom(params) {
25623
+ return null;
25624
+ }
25625
+ getDynamicCanvasCount() {
25626
+ return 999;
25627
+ }
25628
+ getStaticCanvasCount() {
25629
+ return 999;
25630
+ }
25631
+ getElementById(str) {
25632
+ return document.getElementById(str);
25633
+ }
25634
+ getRootElement() {
25635
+ return document.body;
26082
25636
  }
26083
- isPointInStroke(x, y) {
26084
- if (!this.lineWidth) {
26085
- return false;
26086
- }
26087
- this.matrix.transformPoint({ x, y }, globalPoint);
26088
- const lineWidth = getScaledStroke(this, this.lineWidth, this.dpr);
26089
- return containStroke(this.path.commandList, lineWidth, globalPoint.x, globalPoint.y);
25637
+ loadJson(url) {
25638
+ const jsonPromise = fetch(url).then(data => data.json());
25639
+ jsonPromise
25640
+ .then(json => {
25641
+ return {
25642
+ data: json,
25643
+ state: 'success'
25644
+ };
25645
+ })
25646
+ .catch(() => {
25647
+ return {
25648
+ data: null,
25649
+ state: 'fail'
25650
+ };
25651
+ });
25652
+ return jsonPromise;
26090
25653
  }
26091
- measureText(text) {
26092
- throw new Error('不支持measureText');
25654
+ loadArrayBuffer(url) {
25655
+ const arrayBufferPromise = fetch(url).then(data => data.arrayBuffer());
25656
+ return arrayBufferPromise
25657
+ .then((arrayBuffer) => {
25658
+ return {
25659
+ data: arrayBuffer,
25660
+ loadState: 'success'
25661
+ };
25662
+ })
25663
+ .catch(() => {
25664
+ return {
25665
+ data: null,
25666
+ loadState: 'fail'
25667
+ };
25668
+ });
26093
25669
  }
26094
- putImageData(imagedata, dx, dy) {
26095
- throw new Error('不支持measureText');
25670
+ loadBlob(url) {
25671
+ const blobPromise = fetch(url).then(data => data.blob());
25672
+ return blobPromise
25673
+ .then((blob) => {
25674
+ return {
25675
+ data: blob,
25676
+ loadState: 'success'
25677
+ };
25678
+ })
25679
+ .catch(() => {
25680
+ return {
25681
+ data: null,
25682
+ loadState: 'fail'
25683
+ };
25684
+ });
26096
25685
  }
26097
- setLineDash(segments) {
26098
- return;
25686
+ getElementTop(dom, baseWindow) {
25687
+ return 0;
26099
25688
  }
26100
- stroke(path) {
26101
- return;
25689
+ getElementLeft(dom, baseWindow) {
25690
+ return 0;
26102
25691
  }
26103
- strokeRect(x, y, width, height) {
26104
- this.path.rect(x, y, width, height);
25692
+ getElementTopLeft(dom, baseWindow) {
25693
+ return { top: 0, left: 0 };
26105
25694
  }
26106
- strokeText(text, x, y) {
26107
- return;
25695
+ };
25696
+ exports.BaseEnvContribution = __decorate([
25697
+ injectable()
25698
+ ], exports.BaseEnvContribution);
25699
+
25700
+ exports.BaseWindowHandlerContribution = class BaseWindowHandlerContribution {
25701
+ constructor() {
25702
+ this._uid = Generator.GenAutoIncrementId();
26108
25703
  }
26109
- drawImage() {
26110
- return;
25704
+ onChange(cb) {
25705
+ this._onChangeCb = cb;
26111
25706
  }
26112
- setCommonStyle(params, attribute, offsetX, offsetY, defaultParams) {
26113
- return;
25707
+ configure(window, global) {
25708
+ if (global.env === this.type) {
25709
+ window.setWindowHandler(this);
25710
+ }
26114
25711
  }
26115
- _setCommonStyle(params, offsetX, offsetY, defaultParams) {
26116
- return;
25712
+ release(...params) {
25713
+ this.releaseWindow();
26117
25714
  }
26118
- setStrokeStyle(params, attribute, offsetX, offsetY, defaultParams) {
26119
- return;
25715
+ isVisible(bbox) {
25716
+ return true;
26120
25717
  }
26121
- _setStrokeStyle(params, offsetX, offsetY, defaultParams) {
25718
+ onVisibleChange(cb) {
26122
25719
  return;
26123
25720
  }
26124
- setTextStyleWithoutAlignBaseline(params, defaultParams) {
26125
- return;
25721
+ getTopLeft(baseWindow) {
25722
+ return {
25723
+ top: 0,
25724
+ left: 0
25725
+ };
26126
25726
  }
26127
- setTextStyle(params, defaultParams) {
26128
- return;
25727
+ };
25728
+ exports.BaseWindowHandlerContribution = __decorate([
25729
+ injectable(),
25730
+ __metadata("design:paramtypes", [])
25731
+ ], exports.BaseWindowHandlerContribution);
25732
+
25733
+ exports.DefaultPickService = class DefaultPickService {
25734
+ constructor(pickItemInterceptorContributions) {
25735
+ this.pickItemInterceptorContributions = pickItemInterceptorContributions;
25736
+ this.type = 'default';
25737
+ this.global = application.global;
26129
25738
  }
26130
- draw() {
26131
- return;
25739
+ _init() {
25740
+ this.InterceptorContributions = this.pickItemInterceptorContributions
25741
+ .getContributions()
25742
+ .sort((a, b) => a.order - b.order);
26132
25743
  }
26133
- clearMatrix(setTransform = true, dpr = this.dpr) {
26134
- this.setTransformFromMatrix(initMatrix, setTransform, dpr);
25744
+ pick(graphics, point, params) {
25745
+ let result = {
25746
+ graphic: null,
25747
+ group: null
25748
+ };
25749
+ params.pickerService = this;
25750
+ let offsetX = 0;
25751
+ let offsetY = 0;
25752
+ if (params && params.bounds) {
25753
+ if (!params.bounds.contains(point.x, point.y)) {
25754
+ return result;
25755
+ }
25756
+ offsetX = params.bounds.x1;
25757
+ offsetY = params.bounds.y1;
25758
+ }
25759
+ if (this.pickContext) {
25760
+ this.pickContext.inuse = true;
25761
+ }
25762
+ params.pickContext = this.pickContext;
25763
+ this.pickContext && this.pickContext.clearMatrix(true, 1);
25764
+ const parentMatrix = new vutils.Matrix(1, 0, 0, 1, offsetX, offsetY);
25765
+ let group;
25766
+ for (let i = graphics.length - 1; i >= 0; i--) {
25767
+ if (graphics[i].isContainer) {
25768
+ result = this.pickGroup(graphics[i], point, parentMatrix, params);
25769
+ }
25770
+ else {
25771
+ result = this.pickItem(graphics[i], point, parentMatrix, params);
25772
+ }
25773
+ if (result.graphic) {
25774
+ break;
25775
+ }
25776
+ if (!group) {
25777
+ group = result.group;
25778
+ }
25779
+ }
25780
+ if (!result.graphic) {
25781
+ result.group = group;
25782
+ }
25783
+ if (this.pickContext) {
25784
+ this.pickContext.inuse = false;
25785
+ }
25786
+ if (result.graphic) {
25787
+ let g = result.graphic;
25788
+ while (g.parent) {
25789
+ g = g.parent;
25790
+ }
25791
+ if (g.shadowHost) {
25792
+ result.params = {
25793
+ shadowTarget: result.graphic
25794
+ };
25795
+ result.graphic = g.shadowHost;
25796
+ }
25797
+ }
25798
+ return result;
26135
25799
  }
26136
- onlyTranslate(dpr = this.dpr) {
26137
- return this.matrix.a === dpr && this.matrix.b === 0 && this.matrix.c === 0 && this.matrix.d === dpr;
25800
+ containsPoint(graphic, point, params) {
25801
+ var _a;
25802
+ return !!((_a = this.pickItem(graphic, point, null, params !== null && params !== void 0 ? params : { pickContext: this.pickContext, pickerService: this })) === null || _a === void 0 ? void 0 : _a.graphic);
25803
+ }
25804
+ pickGroup(group, point, parentMatrix, params) {
25805
+ let result = {
25806
+ group: null,
25807
+ graphic: null
25808
+ };
25809
+ if (group.attribute.visibleAll === false) {
25810
+ return result;
25811
+ }
25812
+ const context = params.pickContext;
25813
+ const lastMatrix = context.modelMatrix;
25814
+ if (context.camera) {
25815
+ const m = group.transMatrix;
25816
+ const matrix = mat4Allocate.allocate();
25817
+ mat3Tomat4(matrix, m);
25818
+ if (lastMatrix) {
25819
+ if (matrix) {
25820
+ const m = mat4Allocate.allocate();
25821
+ context.modelMatrix = multiplyMat4Mat4(m, lastMatrix, matrix);
25822
+ mat4Allocate.free(matrix);
25823
+ }
25824
+ }
25825
+ else {
25826
+ mat3Tomat4(matrix, group.globalTransMatrix);
25827
+ context.modelMatrix = matrix;
25828
+ }
25829
+ }
25830
+ if (this.InterceptorContributions.length) {
25831
+ for (let i = 0; i < this.InterceptorContributions.length; i++) {
25832
+ const drawContribution = this.InterceptorContributions[i];
25833
+ if (drawContribution.beforePickItem) {
25834
+ const result = drawContribution.beforePickItem(group, this, point, params, { parentMatrix });
25835
+ if (result) {
25836
+ if (context.modelMatrix !== lastMatrix) {
25837
+ mat4Allocate.free(context.modelMatrix);
25838
+ }
25839
+ context.modelMatrix = lastMatrix;
25840
+ return result;
25841
+ }
25842
+ }
25843
+ }
25844
+ }
25845
+ const transMatrix = group.transMatrix;
25846
+ const currentGroupMatrix = matrixAllocate.allocateByObj(parentMatrix);
25847
+ const newPoint = new vutils.Point(point.x, point.y);
25848
+ currentGroupMatrix.transformPoint(newPoint, newPoint);
25849
+ const insideGroup = group.AABBBounds.containsPoint(newPoint);
25850
+ if (!insideGroup && !group.stage.camera) {
25851
+ return result;
25852
+ }
25853
+ const pickedItem = this.pickItem(group, newPoint.clone(), parentMatrix, params);
25854
+ if (pickedItem && pickedItem.graphic) {
25855
+ result.graphic = pickedItem.graphic;
25856
+ result.params = pickedItem.params;
25857
+ }
25858
+ const groupPicked = group.attribute.pickable !== false && insideGroup;
25859
+ currentGroupMatrix.multiply(transMatrix.a, transMatrix.b, transMatrix.c, transMatrix.d, transMatrix.e, transMatrix.f);
25860
+ if (group.attribute.childrenPickable !== false && !(pickedItem && pickedItem.graphic)) {
25861
+ foreach(group, DefaultAttribute.zIndex, (graphic) => {
25862
+ if (graphic.isContainer) {
25863
+ const newPoint = new vutils.Point(point.x, point.y);
25864
+ const theme = getTheme(group).group;
25865
+ const { scrollX = theme.scrollX, scrollY = theme.scrollY } = group.attribute;
25866
+ newPoint.x -= scrollX;
25867
+ newPoint.y -= scrollY;
25868
+ result = this.pickGroup(graphic, newPoint, currentGroupMatrix, params);
25869
+ }
25870
+ else {
25871
+ const newPoint = new vutils.Point(point.x, point.y);
25872
+ currentGroupMatrix.transformPoint(newPoint, newPoint);
25873
+ const theme = getTheme(group).group;
25874
+ const { scrollX = theme.scrollX, scrollY = theme.scrollY } = group.attribute;
25875
+ newPoint.x -= scrollX;
25876
+ newPoint.y -= scrollY;
25877
+ const pickedItem = this.pickItem(graphic, newPoint, parentMatrix, params);
25878
+ if (pickedItem && pickedItem.graphic) {
25879
+ result.graphic = pickedItem.graphic;
25880
+ result.params = pickedItem.params;
25881
+ }
25882
+ }
25883
+ return !!result.graphic || !!result.group;
25884
+ }, true, !!context.camera);
25885
+ }
25886
+ if (context.modelMatrix !== lastMatrix) {
25887
+ mat4Allocate.free(context.modelMatrix);
25888
+ }
25889
+ context.modelMatrix = lastMatrix;
25890
+ if (!result.graphic && !result.group && groupPicked && !group.stage.camera) {
25891
+ result.group = group;
25892
+ }
25893
+ matrixAllocate.free(currentGroupMatrix);
25894
+ return result;
26138
25895
  }
26139
- release(...params) {
26140
- this.stack.forEach(m => matrixAllocate.free(m));
26141
- this.stack.length = 0;
26142
- return;
25896
+ selectPicker(graphic) {
25897
+ const picker = this.pickerMap.get(graphic.numberType);
25898
+ if (!picker) {
25899
+ return null;
25900
+ }
25901
+ return picker;
26143
25902
  }
26144
25903
  };
26145
- exports.EmptyContext2d = __decorate([
25904
+ exports.DefaultPickService = __decorate([
26146
25905
  injectable(),
26147
- __metadata("design:paramtypes", [Object, Number])
26148
- ], exports.EmptyContext2d);
25906
+ __param(0, inject(ContributionProvider)),
25907
+ __param(0, named(PickItemInterceptor)),
25908
+ __metadata("design:paramtypes", [Object])
25909
+ ], exports.DefaultPickService);
26149
25910
 
26150
- const DefaultConfig = {
26151
- WIDTH: 500,
26152
- HEIGHT: 500,
26153
- DPR: 1
26154
- };
26155
- exports.BaseCanvas = class BaseCanvas {
26156
- get displayWidth() {
26157
- return this._pixelWidth / this._dpr;
26158
- }
26159
- get displayHeight() {
26160
- return this._pixelHeight / this._dpr;
26161
- }
26162
- get id() {
26163
- return this._id;
26164
- }
26165
- get x() {
26166
- return this._x;
26167
- }
26168
- set x(_x) {
26169
- this._x = _x;
26170
- }
26171
- get y() {
26172
- return this._y;
26173
- }
26174
- set y(_y) {
26175
- this._y = _y;
26176
- }
26177
- get nativeCanvas() {
26178
- return this._nativeCanvas;
26179
- }
26180
- get width() {
26181
- return this._pixelWidth;
26182
- }
26183
- set width(width) {
26184
- this._pixelWidth = width;
26185
- this._displayWidth = width / (this._dpr || 1);
26186
- }
26187
- get height() {
26188
- return this._pixelHeight;
26189
- }
26190
- set height(height) {
26191
- this._pixelHeight = height;
26192
- this._displayHeight = height / (this._dpr || 1);
26193
- }
26194
- getContext(str) {
26195
- return this._context;
26196
- }
26197
- get visiable() {
26198
- return this._visiable;
25911
+ exports.DefaultGlobalPickerService = class DefaultGlobalPickerService {
25912
+ constructor() {
25913
+ this.global = application.global;
25914
+ this.global.hooks.onSetEnv.tap('global-picker-service', (lastEnv, env, global) => {
25915
+ this.configure(global, env);
25916
+ });
25917
+ this.configure(this.global, this.global.env);
26199
25918
  }
26200
- set visiable(visiable) {
26201
- this._visiable = visiable;
26202
- visiable ? this.show() : this.hide();
25919
+ configure(global, env) {
26203
25920
  }
26204
- get dpr() {
26205
- return this._dpr;
25921
+ pick(graphics, point, params) {
25922
+ let result = {
25923
+ graphic: null,
25924
+ group: null
25925
+ };
25926
+ const parentMatrix = new vutils.Matrix(1, 0, 0, 1, 0, 0);
25927
+ let group;
25928
+ for (let i = 0; i < graphics.length; i++) {
25929
+ if (graphics[i].isContainer) {
25930
+ result = this.pickGroup(graphics[i], point, parentMatrix, params);
25931
+ }
25932
+ else {
25933
+ const data = this.pickItem(graphics[i], point, parentMatrix, params);
25934
+ if (data) {
25935
+ result.graphic = data.graphic;
25936
+ result.params = data.params;
25937
+ }
25938
+ }
25939
+ if (result.graphic) {
25940
+ break;
25941
+ }
25942
+ if (!group) {
25943
+ group = result.group;
25944
+ }
25945
+ }
25946
+ if (!result.graphic) {
25947
+ result.group = group;
25948
+ }
25949
+ if (result.graphic) {
25950
+ let g = result.graphic;
25951
+ while (g.parent) {
25952
+ g = g.parent;
25953
+ }
25954
+ if (g.shadowHost) {
25955
+ result.params = {
25956
+ shadowTarget: result.graphic
25957
+ };
25958
+ result.graphic = g.shadowHost;
25959
+ }
25960
+ }
25961
+ return result;
26206
25962
  }
26207
- set dpr(dpr) {
26208
- this._dpr = dpr;
26209
- this.resize(this._displayWidth, this._displayHeight);
25963
+ containsPoint(graphic, point, params) {
25964
+ return !!this.pickItem(graphic, point, null, params);
26210
25965
  }
26211
- constructor(params) {
26212
- var _a;
26213
- const { nativeCanvas, width = DefaultConfig.WIDTH, height = DefaultConfig.HEIGHT, dpr = DefaultConfig.DPR, x, y, id, canvasControled = true } = params;
26214
- const offsetX = 0;
26215
- const offsetY = 0;
26216
- this._x = x !== null && x !== void 0 ? x : offsetX;
26217
- this._y = y !== null && y !== void 0 ? y : offsetY;
26218
- this._pixelWidth = width * dpr;
26219
- this._pixelHeight = height * dpr;
26220
- this._visiable = params.visiable !== false;
26221
- this.controled = canvasControled;
26222
- this._displayWidth = width;
26223
- this._displayHeight = height;
26224
- this._dpr = dpr;
26225
- this._nativeCanvas = nativeCanvas;
26226
- this._id = (_a = nativeCanvas.id) !== null && _a !== void 0 ? _a : id;
26227
- if (id) {
26228
- nativeCanvas.id = id;
25966
+ pickGroup(group, point, parentMatrix, params) {
25967
+ let result = {
25968
+ group: null,
25969
+ graphic: null
25970
+ };
25971
+ if (group.attribute.visibleAll === false) {
25972
+ return result;
26229
25973
  }
26230
- this.init(params);
26231
- }
26232
- getNativeCanvas() {
26233
- return this._nativeCanvas;
25974
+ const transMatrix = group.transMatrix;
25975
+ const newPoint = new vutils.Point(point.x, point.y);
25976
+ parentMatrix.transformPoint(newPoint, newPoint);
25977
+ const insideGroup = group.AABBBounds.containsPoint(newPoint);
25978
+ if (!insideGroup) {
25979
+ return result;
25980
+ }
25981
+ const groupPicked = group.attribute.pickable !== false && insideGroup;
25982
+ parentMatrix.multiply(transMatrix.a, transMatrix.b, transMatrix.c, transMatrix.d, transMatrix.e, transMatrix.f);
25983
+ if (group.attribute.childrenPickable !== false) {
25984
+ group.forEachChildren((graphic) => {
25985
+ if (graphic.isContainer) {
25986
+ result = this.pickGroup(graphic, point, parentMatrix, params);
25987
+ }
25988
+ else {
25989
+ const newPoint = new vutils.Point(point.x, point.y);
25990
+ parentMatrix.transformPoint(newPoint, newPoint);
25991
+ const data = this.pickItem(graphic, newPoint, parentMatrix, params);
25992
+ if (data) {
25993
+ result.graphic = data.graphic;
25994
+ result.params = data.params;
25995
+ }
25996
+ }
25997
+ return !!result.graphic || !!result.group;
25998
+ });
25999
+ }
26000
+ if (!result.graphic && !result.group && groupPicked) {
26001
+ result.group = group;
26002
+ }
26003
+ return result;
26234
26004
  }
26235
- hide() {
26236
- return;
26005
+ pickItem(graphic, point, parentMatrix, params) {
26006
+ if (graphic.attribute.pickable === false) {
26007
+ return null;
26008
+ }
26009
+ if (graphic.AABBBounds.containsPoint(point)) {
26010
+ return {
26011
+ graphic: graphic
26012
+ };
26013
+ }
26014
+ return null;
26237
26015
  }
26238
- show() {
26239
- return;
26016
+ };
26017
+ exports.DefaultGlobalPickerService = __decorate([
26018
+ injectable(),
26019
+ __metadata("design:paramtypes", [])
26020
+ ], exports.DefaultGlobalPickerService);
26021
+
26022
+ class DefaultGraphicAllocate {
26023
+ constructor() {
26024
+ this.pools = [];
26240
26025
  }
26241
- applyPosition() {
26242
- return;
26026
+ free(d) {
26027
+ this.pools.push(d);
26243
26028
  }
26244
- resetStyle(params) {
26245
- return;
26029
+ get length() {
26030
+ return this.pools.length;
26246
26031
  }
26247
- resize(width, height) {
26248
- return;
26032
+ release(...params) {
26033
+ this.pools = [];
26249
26034
  }
26250
- toDataURL(mimeType, quality) {
26251
- return '';
26035
+ }
26036
+ class DefaultRectAllocate extends DefaultGraphicAllocate {
26037
+ allocate(attribute) {
26038
+ if (!this.pools.length) {
26039
+ return application.graphicService.creator.rect(attribute);
26040
+ }
26041
+ const g = this.pools.pop();
26042
+ g.initAttributes(attribute);
26043
+ return g;
26252
26044
  }
26253
- readPixels(x, y, w, h) {
26254
- return this._context.getImageData(x, y, w, h);
26045
+ allocateByObj(rect) {
26046
+ if (!this.pools.length) {
26047
+ return application.graphicService.creator.rect(rect.attribute);
26048
+ }
26049
+ const g = this.pools.pop();
26050
+ g.initAttributes(rect.attribute);
26051
+ return g;
26255
26052
  }
26256
- convertToBlob(options) {
26257
- throw new Error('暂未实现');
26053
+ }
26054
+ const defaultRectAllocate = new DefaultRectAllocate();
26055
+ class DefaultArcAllocate extends DefaultGraphicAllocate {
26056
+ allocate(attribute) {
26057
+ if (!this.pools.length) {
26058
+ return application.graphicService.creator.arc(attribute);
26059
+ }
26060
+ const g = this.pools.pop();
26061
+ g.initAttributes(attribute);
26062
+ return g;
26258
26063
  }
26259
- transferToImageBitmap() {
26260
- throw new Error('暂未实现');
26064
+ allocateByObj(arc) {
26065
+ if (!this.pools.length) {
26066
+ return application.graphicService.creator.arc(arc.attribute);
26067
+ }
26068
+ const g = this.pools.pop();
26069
+ g.initAttributes(arc.attribute);
26070
+ return g;
26261
26071
  }
26262
- release(...params) {
26263
- if (this.controled) {
26264
- this._nativeCanvas.parentElement && this._nativeCanvas.parentElement.removeChild(this._nativeCanvas);
26072
+ }
26073
+ const defaultArcAllocate = new DefaultArcAllocate();
26074
+ class DefaultAreaAllocate extends DefaultGraphicAllocate {
26075
+ allocate(attribute) {
26076
+ if (!this.pools.length) {
26077
+ return application.graphicService.creator.area(attribute);
26265
26078
  }
26079
+ const g = this.pools.pop();
26080
+ g.initAttributes(attribute);
26081
+ return g;
26266
26082
  }
26267
- };
26268
- exports.BaseCanvas.env = 'browser';
26269
- exports.BaseCanvas = __decorate([
26270
- injectable(),
26271
- __metadata("design:paramtypes", [Object])
26272
- ], exports.BaseCanvas);
26273
-
26274
- exports.BaseEnvContribution = class BaseEnvContribution {
26275
- configure(service, ...p) {
26276
- if (service.env === this.type) {
26277
- service.setActiveEnvContribution(this);
26083
+ allocateByObj(area) {
26084
+ if (!this.pools.length) {
26085
+ return application.graphicService.creator.area(area.attribute);
26278
26086
  }
26087
+ const g = this.pools.pop();
26088
+ g.initAttributes(area.attribute);
26089
+ return g;
26279
26090
  }
26280
- getNativeAABBBounds(dom) {
26281
- return new vutils.AABBBounds();
26091
+ }
26092
+ const defaultAreaAllocate = new DefaultAreaAllocate();
26093
+ class DefaultCircleAllocate extends DefaultGraphicAllocate {
26094
+ allocate(attribute) {
26095
+ if (!this.pools.length) {
26096
+ return application.graphicService.creator.circle(attribute);
26097
+ }
26098
+ const g = this.pools.pop();
26099
+ g.initAttributes(attribute);
26100
+ return g;
26282
26101
  }
26283
- removeDom(dom) {
26284
- return false;
26102
+ allocateByObj(area) {
26103
+ if (!this.pools.length) {
26104
+ return application.graphicService.creator.circle(area.attribute);
26105
+ }
26106
+ const g = this.pools.pop();
26107
+ g.initAttributes(area.attribute);
26108
+ return g;
26285
26109
  }
26286
- createDom(params) {
26287
- return null;
26110
+ }
26111
+ const defaultCircleAllocate = new DefaultCircleAllocate();
26112
+ class DefaultLineAllocate extends DefaultGraphicAllocate {
26113
+ allocate(attribute) {
26114
+ if (!this.pools.length) {
26115
+ return application.graphicService.creator.line(attribute);
26116
+ }
26117
+ const g = this.pools.pop();
26118
+ g.initAttributes(attribute);
26119
+ return g;
26288
26120
  }
26289
- getDynamicCanvasCount() {
26290
- return 999;
26121
+ allocateByObj(line) {
26122
+ if (!this.pools.length) {
26123
+ return application.graphicService.creator.line(line.attribute);
26124
+ }
26125
+ const g = this.pools.pop();
26126
+ g.initAttributes(line.attribute);
26127
+ return g;
26291
26128
  }
26292
- getStaticCanvasCount() {
26293
- return 999;
26129
+ }
26130
+ const defaultLineAllocate = new DefaultLineAllocate();
26131
+ class DefaultPathAllocate extends DefaultGraphicAllocate {
26132
+ allocate(attribute) {
26133
+ if (!this.pools.length) {
26134
+ return application.graphicService.creator.path(attribute);
26135
+ }
26136
+ const g = this.pools.pop();
26137
+ g.initAttributes(attribute);
26138
+ return g;
26294
26139
  }
26295
- getElementById(str) {
26296
- return document.getElementById(str);
26140
+ allocateByObj(path) {
26141
+ if (!this.pools.length) {
26142
+ return application.graphicService.creator.path(path.attribute);
26143
+ }
26144
+ const g = this.pools.pop();
26145
+ g.initAttributes(path.attribute);
26146
+ return g;
26297
26147
  }
26298
- getRootElement() {
26299
- return document.body;
26148
+ }
26149
+ const defaultPathAllocate = new DefaultPathAllocate();
26150
+ class DefaultSymbolAllocate extends DefaultGraphicAllocate {
26151
+ allocate(attribute) {
26152
+ if (!this.pools.length) {
26153
+ return application.graphicService.creator.symbol(attribute);
26154
+ }
26155
+ const g = this.pools.pop();
26156
+ g.initAttributes(attribute);
26157
+ return g;
26300
26158
  }
26301
- loadJson(url) {
26302
- const jsonPromise = fetch(url).then(data => data.json());
26303
- jsonPromise
26304
- .then(json => {
26305
- return {
26306
- data: json,
26307
- state: 'success'
26308
- };
26309
- })
26310
- .catch(() => {
26311
- return {
26312
- data: null,
26313
- state: 'fail'
26314
- };
26315
- });
26316
- return jsonPromise;
26159
+ allocateByObj(symbol) {
26160
+ if (!this.pools.length) {
26161
+ return application.graphicService.creator.symbol(symbol.attribute);
26162
+ }
26163
+ const g = this.pools.pop();
26164
+ g.initAttributes(symbol.attribute);
26165
+ return g;
26317
26166
  }
26318
- loadArrayBuffer(url) {
26319
- const arrayBufferPromise = fetch(url).then(data => data.arrayBuffer());
26320
- return arrayBufferPromise
26321
- .then((arrayBuffer) => {
26322
- return {
26323
- data: arrayBuffer,
26324
- loadState: 'success'
26325
- };
26326
- })
26327
- .catch(() => {
26328
- return {
26329
- data: null,
26330
- loadState: 'fail'
26331
- };
26332
- });
26167
+ }
26168
+ const defaultSymbolAllocate = new DefaultSymbolAllocate();
26169
+ class DefaultTextAllocate extends DefaultGraphicAllocate {
26170
+ allocate(attribute) {
26171
+ if (!this.pools.length) {
26172
+ return application.graphicService.creator.text(attribute);
26173
+ }
26174
+ const g = this.pools.pop();
26175
+ g.initAttributes(attribute);
26176
+ return g;
26333
26177
  }
26334
- loadBlob(url) {
26335
- const blobPromise = fetch(url).then(data => data.blob());
26336
- return blobPromise
26337
- .then((blob) => {
26338
- return {
26339
- data: blob,
26340
- loadState: 'success'
26341
- };
26342
- })
26343
- .catch(() => {
26344
- return {
26345
- data: null,
26346
- loadState: 'fail'
26347
- };
26348
- });
26178
+ allocateByObj(text) {
26179
+ if (!this.pools.length) {
26180
+ return application.graphicService.creator.text(text.attribute);
26181
+ }
26182
+ const g = this.pools.pop();
26183
+ g.initAttributes(text.attribute);
26184
+ return g;
26349
26185
  }
26350
- getElementTop(dom, baseWindow) {
26351
- return 0;
26186
+ }
26187
+ const defaultTextAllocate = new DefaultTextAllocate();
26188
+ class DefaultGraphicMemoryManager {
26189
+ constructor() {
26190
+ this.map = {
26191
+ text: defaultTextAllocate,
26192
+ symbol: defaultSymbolAllocate
26193
+ };
26352
26194
  }
26353
- getElementLeft(dom, baseWindow) {
26354
- return 0;
26195
+ gc(g) {
26196
+ if (g.isContainer) {
26197
+ g.forEachChildren(i => this.gc(i));
26198
+ }
26199
+ else {
26200
+ this.gcItem(g);
26201
+ }
26355
26202
  }
26356
- getElementTopLeft(dom, baseWindow) {
26357
- return { top: 0, left: 0 };
26203
+ gcItem(g) {
26204
+ const allocate = this.map[g.type];
26205
+ if (allocate) {
26206
+ allocate.free(g);
26207
+ }
26358
26208
  }
26359
- };
26360
- exports.BaseEnvContribution = __decorate([
26361
- injectable()
26362
- ], exports.BaseEnvContribution);
26209
+ }
26210
+ const defaultGraphicMemoryManager = new DefaultGraphicMemoryManager();
26363
26211
 
26364
- exports.BaseWindowHandlerContribution = class BaseWindowHandlerContribution {
26365
- constructor() {
26366
- this._uid = Generator.GenAutoIncrementId();
26367
- }
26368
- onChange(cb) {
26369
- this._onChangeCb = cb;
26212
+ let loadArcModule = false;
26213
+ const arcModule = new ContainerModule(bind => {
26214
+ if (loadArcModule) {
26215
+ return;
26370
26216
  }
26371
- configure(window, global) {
26372
- if (global.env === this.type) {
26373
- window.setWindowHandler(this);
26374
- }
26217
+ loadArcModule = true;
26218
+ bind(exports.DefaultCanvasArcRender).toSelf().inSingletonScope();
26219
+ bind(ArcRender).to(exports.DefaultCanvasArcRender).inSingletonScope();
26220
+ bind(GraphicRender).toService(ArcRender);
26221
+ bind(ArcRenderContribution).toService(exports.DefaultBaseInteractiveRenderContribution);
26222
+ bindContributionProvider(bind, ArcRenderContribution);
26223
+ });
26224
+
26225
+ let loadRectModule = false;
26226
+ const rectModule = new ContainerModule(bind => {
26227
+ if (loadRectModule) {
26228
+ return;
26375
26229
  }
26376
- release(...params) {
26377
- this.releaseWindow();
26230
+ loadRectModule = true;
26231
+ bind(exports.DefaultCanvasRectRender).toSelf().inSingletonScope();
26232
+ bind(RectRender).to(exports.DefaultCanvasRectRender).inSingletonScope();
26233
+ bind(GraphicRender).toService(RectRender);
26234
+ bind(RectRenderContribution).toService(exports.DefaultBaseInteractiveRenderContribution);
26235
+ bindContributionProvider(bind, RectRenderContribution);
26236
+ });
26237
+
26238
+ let loadLineModule = false;
26239
+ const lineModule = new ContainerModule(bind => {
26240
+ if (loadLineModule) {
26241
+ return;
26378
26242
  }
26379
- isVisible(bbox) {
26380
- return true;
26243
+ loadLineModule = true;
26244
+ bind(exports.DefaultCanvasLineRender).toSelf().inSingletonScope();
26245
+ bind(DefaultIncrementalCanvasLineRender).toSelf().inSingletonScope();
26246
+ bind(LineRender).to(exports.DefaultCanvasLineRender).inSingletonScope();
26247
+ bind(GraphicRender).toService(LineRender);
26248
+ });
26249
+
26250
+ let loadAreaModule = false;
26251
+ const areaModule = new ContainerModule(bind => {
26252
+ if (loadAreaModule) {
26253
+ return;
26381
26254
  }
26382
- onVisibleChange(cb) {
26255
+ loadAreaModule = true;
26256
+ bind(exports.DefaultCanvasAreaRender).toSelf().inSingletonScope();
26257
+ bind(AreaRender).to(exports.DefaultCanvasAreaRender).inSingletonScope();
26258
+ bind(GraphicRender).toService(AreaRender);
26259
+ bind(AreaRenderContribution).toService(exports.DefaultBaseInteractiveRenderContribution);
26260
+ bindContributionProvider(bind, AreaRenderContribution);
26261
+ bind(DefaultIncrementalCanvasAreaRender).toSelf().inSingletonScope();
26262
+ });
26263
+
26264
+ let loadSymbolModule = false;
26265
+ const symbolModule = new ContainerModule(bind => {
26266
+ if (loadSymbolModule) {
26383
26267
  return;
26384
26268
  }
26385
- getTopLeft(baseWindow) {
26386
- return {
26387
- top: 0,
26388
- left: 0
26389
- };
26269
+ loadSymbolModule = true;
26270
+ bind(exports.DefaultCanvasSymbolRender).toSelf().inSingletonScope();
26271
+ bind(SymbolRender).to(exports.DefaultCanvasSymbolRender).inSingletonScope();
26272
+ bind(GraphicRender).toService(SymbolRender);
26273
+ bind(SymbolRenderContribution).toService(exports.DefaultBaseInteractiveRenderContribution);
26274
+ bindContributionProvider(bind, SymbolRenderContribution);
26275
+ });
26276
+
26277
+ let loadCircleModule = false;
26278
+ const circleModule = new ContainerModule(bind => {
26279
+ if (loadCircleModule) {
26280
+ return;
26390
26281
  }
26391
- };
26392
- exports.BaseWindowHandlerContribution = __decorate([
26393
- injectable(),
26394
- __metadata("design:paramtypes", [])
26395
- ], exports.BaseWindowHandlerContribution);
26282
+ loadCircleModule = true;
26283
+ bind(exports.DefaultCanvasCircleRender).toSelf().inSingletonScope();
26284
+ bind(CircleRender).to(exports.DefaultCanvasCircleRender).inSingletonScope();
26285
+ bind(GraphicRender).toService(CircleRender);
26286
+ bind(CircleRenderContribution).toService(exports.DefaultBaseInteractiveRenderContribution);
26287
+ bindContributionProvider(bind, CircleRenderContribution);
26288
+ });
26396
26289
 
26397
- exports.DefaultPickService = class DefaultPickService {
26398
- constructor(pickItemInterceptorContributions) {
26399
- this.pickItemInterceptorContributions = pickItemInterceptorContributions;
26400
- this.type = 'default';
26401
- this.global = application.global;
26290
+ let loadTextModule = false;
26291
+ const textModule = new ContainerModule(bind => {
26292
+ if (loadTextModule) {
26293
+ return;
26402
26294
  }
26403
- _init() {
26404
- this.InterceptorContributions = this.pickItemInterceptorContributions
26405
- .getContributions()
26406
- .sort((a, b) => a.order - b.order);
26295
+ loadTextModule = true;
26296
+ bind(TextRender).to(exports.DefaultCanvasTextRender).inSingletonScope();
26297
+ bind(GraphicRender).toService(TextRender);
26298
+ bind(TextRenderContribution).toService(exports.DefaultBaseInteractiveRenderContribution);
26299
+ bindContributionProvider(bind, TextRenderContribution);
26300
+ });
26301
+
26302
+ let loadPathModule = false;
26303
+ const pathModule = new ContainerModule(bind => {
26304
+ if (loadPathModule) {
26305
+ return;
26407
26306
  }
26408
- pick(graphics, point, params) {
26409
- let result = {
26410
- graphic: null,
26411
- group: null
26412
- };
26413
- params.pickerService = this;
26414
- let offsetX = 0;
26415
- let offsetY = 0;
26416
- if (params && params.bounds) {
26417
- if (!params.bounds.contains(point.x, point.y)) {
26418
- return result;
26419
- }
26420
- offsetX = params.bounds.x1;
26421
- offsetY = params.bounds.y1;
26422
- }
26423
- if (this.pickContext) {
26424
- this.pickContext.inuse = true;
26425
- }
26426
- params.pickContext = this.pickContext;
26427
- this.pickContext && this.pickContext.clearMatrix(true, 1);
26428
- const parentMatrix = new vutils.Matrix(1, 0, 0, 1, offsetX, offsetY);
26429
- let group;
26430
- for (let i = graphics.length - 1; i >= 0; i--) {
26431
- if (graphics[i].isContainer) {
26432
- result = this.pickGroup(graphics[i], point, parentMatrix, params);
26433
- }
26434
- else {
26435
- result = this.pickItem(graphics[i], point, parentMatrix, params);
26436
- }
26437
- if (result.graphic) {
26438
- break;
26439
- }
26440
- if (!group) {
26441
- group = result.group;
26442
- }
26443
- }
26444
- if (!result.graphic) {
26445
- result.group = group;
26446
- }
26447
- if (this.pickContext) {
26448
- this.pickContext.inuse = false;
26449
- }
26450
- if (result.graphic) {
26451
- let g = result.graphic;
26452
- while (g.parent) {
26453
- g = g.parent;
26454
- }
26455
- if (g.shadowHost) {
26456
- result.params = {
26457
- shadowTarget: result.graphic
26458
- };
26459
- result.graphic = g.shadowHost;
26460
- }
26461
- }
26462
- return result;
26307
+ loadPathModule = true;
26308
+ bind(exports.DefaultCanvasPathRender).toSelf().inSingletonScope();
26309
+ bind(PathRender).to(exports.DefaultCanvasPathRender).inSingletonScope();
26310
+ bind(GraphicRender).toService(PathRender);
26311
+ bind(PathRenderContribution).toService(exports.DefaultBaseInteractiveRenderContribution);
26312
+ bindContributionProvider(bind, PathRenderContribution);
26313
+ });
26314
+
26315
+ let loadPolygonModule = false;
26316
+ const polygonModule = new ContainerModule(bind => {
26317
+ if (loadPolygonModule) {
26318
+ return;
26463
26319
  }
26464
- containsPoint(graphic, point, params) {
26465
- var _a;
26466
- return !!((_a = this.pickItem(graphic, point, null, params !== null && params !== void 0 ? params : { pickContext: this.pickContext, pickerService: this })) === null || _a === void 0 ? void 0 : _a.graphic);
26320
+ loadPolygonModule = true;
26321
+ bind(PolygonRender).to(exports.DefaultCanvasPolygonRender).inSingletonScope();
26322
+ bind(GraphicRender).toService(PolygonRender);
26323
+ bind(PolygonRenderContribution).toService(exports.DefaultBaseInteractiveRenderContribution);
26324
+ bindContributionProvider(bind, PolygonRenderContribution);
26325
+ });
26326
+
26327
+ let DefaultCanvasGlyphRender = class DefaultCanvasGlyphRender {
26328
+ constructor() {
26329
+ this.numberType = GLYPH_NUMBER_TYPE;
26467
26330
  }
26468
- pickGroup(group, point, parentMatrix, params) {
26469
- let result = {
26470
- group: null,
26471
- graphic: null
26472
- };
26473
- if (group.attribute.visibleAll === false) {
26474
- return result;
26475
- }
26476
- const context = params.pickContext;
26477
- const lastMatrix = context.modelMatrix;
26478
- if (context.camera) {
26479
- const m = group.transMatrix;
26480
- const matrix = mat4Allocate.allocate();
26481
- mat3Tomat4(matrix, m);
26482
- if (lastMatrix) {
26483
- if (matrix) {
26484
- const m = mat4Allocate.allocate();
26485
- context.modelMatrix = multiplyMat4Mat4(m, lastMatrix, matrix);
26486
- mat4Allocate.free(matrix);
26487
- }
26488
- }
26489
- else {
26490
- mat3Tomat4(matrix, group.globalTransMatrix);
26491
- context.modelMatrix = matrix;
26492
- }
26331
+ drawShape(glyph, context, x, y, drawContext, params, fillCb, strokeCb) {
26332
+ if (!drawContext.drawContribution) {
26333
+ return;
26493
26334
  }
26494
- if (this.InterceptorContributions.length) {
26495
- for (let i = 0; i < this.InterceptorContributions.length; i++) {
26496
- const drawContribution = this.InterceptorContributions[i];
26497
- if (drawContribution.beforePickItem) {
26498
- const result = drawContribution.beforePickItem(group, this, point, params, { parentMatrix });
26499
- if (result) {
26500
- if (context.modelMatrix !== lastMatrix) {
26501
- mat4Allocate.free(context.modelMatrix);
26502
- }
26503
- context.modelMatrix = lastMatrix;
26504
- return result;
26505
- }
26506
- }
26335
+ glyph.getSubGraphic().forEach(item => {
26336
+ const renderer = drawContext.drawContribution.getRenderContribution(item);
26337
+ if (renderer && renderer.drawShape) {
26338
+ renderer.drawShape(item, context, x, y, drawContext, params, fillCb, strokeCb);
26507
26339
  }
26508
- }
26509
- const transMatrix = group.transMatrix;
26510
- const currentGroupMatrix = matrixAllocate.allocateByObj(parentMatrix);
26511
- const newPoint = new vutils.Point(point.x, point.y);
26512
- currentGroupMatrix.transformPoint(newPoint, newPoint);
26513
- const insideGroup = group.AABBBounds.containsPoint(newPoint);
26514
- if (!insideGroup && !group.stage.camera) {
26515
- return result;
26516
- }
26517
- const pickedItem = this.pickItem(group, newPoint.clone(), parentMatrix, params);
26518
- if (pickedItem && pickedItem.graphic) {
26519
- result.graphic = pickedItem.graphic;
26520
- result.params = pickedItem.params;
26521
- }
26522
- const groupPicked = group.attribute.pickable !== false && insideGroup;
26523
- currentGroupMatrix.multiply(transMatrix.a, transMatrix.b, transMatrix.c, transMatrix.d, transMatrix.e, transMatrix.f);
26524
- if (group.attribute.childrenPickable !== false && !(pickedItem && pickedItem.graphic)) {
26525
- foreach(group, DefaultAttribute.zIndex, (graphic) => {
26526
- if (graphic.isContainer) {
26527
- const newPoint = new vutils.Point(point.x, point.y);
26528
- const theme = getTheme(group).group;
26529
- const { scrollX = theme.scrollX, scrollY = theme.scrollY } = group.attribute;
26530
- newPoint.x -= scrollX;
26531
- newPoint.y -= scrollY;
26532
- result = this.pickGroup(graphic, newPoint, currentGroupMatrix, params);
26533
- }
26534
- else {
26535
- const newPoint = new vutils.Point(point.x, point.y);
26536
- currentGroupMatrix.transformPoint(newPoint, newPoint);
26537
- const theme = getTheme(group).group;
26538
- const { scrollX = theme.scrollX, scrollY = theme.scrollY } = group.attribute;
26539
- newPoint.x -= scrollX;
26540
- newPoint.y -= scrollY;
26541
- const pickedItem = this.pickItem(graphic, newPoint, parentMatrix, params);
26542
- if (pickedItem && pickedItem.graphic) {
26543
- result.graphic = pickedItem.graphic;
26544
- result.params = pickedItem.params;
26545
- }
26546
- }
26547
- return !!result.graphic || !!result.group;
26548
- }, true, !!context.camera);
26549
- }
26550
- if (context.modelMatrix !== lastMatrix) {
26551
- mat4Allocate.free(context.modelMatrix);
26552
- }
26553
- context.modelMatrix = lastMatrix;
26554
- if (!result.graphic && !result.group && groupPicked && !group.stage.camera) {
26555
- result.group = group;
26556
- }
26557
- matrixAllocate.free(currentGroupMatrix);
26558
- return result;
26340
+ });
26559
26341
  }
26560
- selectPicker(graphic) {
26561
- const picker = this.pickerMap.get(graphic.numberType);
26562
- if (!picker) {
26563
- return null;
26342
+ draw(glyph, renderService, drawContext, params) {
26343
+ const { context } = drawContext;
26344
+ if (!context) {
26345
+ return;
26564
26346
  }
26565
- return picker;
26347
+ context.highPerformanceSave();
26348
+ if (!drawContext.drawContribution) {
26349
+ return;
26350
+ }
26351
+ const glyphTheme = getTheme(glyph);
26352
+ const subGraphic = glyph.getSubGraphic();
26353
+ subGraphic.length &&
26354
+ subGraphic.forEach(g => {
26355
+ drawContext.drawContribution.renderItem(g, drawContext, { theme: glyphTheme });
26356
+ });
26357
+ context.highPerformanceRestore();
26566
26358
  }
26567
26359
  };
26568
- exports.DefaultPickService = __decorate([
26569
- injectable(),
26570
- __param(0, inject(ContributionProvider)),
26571
- __param(0, named(PickItemInterceptor)),
26572
- __metadata("design:paramtypes", [Object])
26573
- ], exports.DefaultPickService);
26360
+ DefaultCanvasGlyphRender = __decorate([
26361
+ injectable()
26362
+ ], DefaultCanvasGlyphRender);
26574
26363
 
26575
- exports.DefaultGlobalPickerService = class DefaultGlobalPickerService {
26364
+ let loadGlyphModule = false;
26365
+ const glyphModule = new ContainerModule(bind => {
26366
+ if (loadGlyphModule) {
26367
+ return;
26368
+ }
26369
+ loadGlyphModule = true;
26370
+ bind(GlyphRender).to(DefaultCanvasGlyphRender).inSingletonScope();
26371
+ bind(GraphicRender).toService(GlyphRender);
26372
+ });
26373
+
26374
+ let DefaultCanvasRichTextRender = class DefaultCanvasRichTextRender extends BaseRender {
26576
26375
  constructor() {
26577
- this.global = application.global;
26578
- this.global.hooks.onSetEnv.tap('global-picker-service', (lastEnv, env, global) => {
26579
- this.configure(global, env);
26580
- });
26581
- this.configure(this.global, this.global.env);
26376
+ super();
26377
+ this.numberType = RICHTEXT_NUMBER_TYPE;
26378
+ this.builtinContributions = [defaultTextBackgroundRenderContribution];
26379
+ this.init();
26582
26380
  }
26583
- configure(global, env) {
26381
+ drawShape(richtext, context, x, y, drawContext) {
26382
+ const richtextAttribute = getTheme(richtext).richtext;
26383
+ const { strokeOpacity = richtextAttribute.strokeOpacity, opacity = richtextAttribute.opacity, fillOpacity = richtextAttribute.fillOpacity, visible = richtextAttribute.visible } = richtext.attribute;
26384
+ if (!(richtext.valid && visible)) {
26385
+ return;
26386
+ }
26387
+ const fVisible = fillVisible(opacity, fillOpacity, true);
26388
+ const sVisible = fillVisible(opacity, strokeOpacity, true);
26389
+ if (!fVisible) {
26390
+ return;
26391
+ }
26392
+ context.translate(x, y);
26393
+ this.beforeRenderStep(richtext, context, x, y, fVisible, sVisible, fVisible, sVisible, richtextAttribute, drawContext);
26394
+ const frame = richtext.getFrameCache();
26395
+ frame.draw(context, this.drawIcon);
26396
+ this.afterRenderStep(richtext, context, x, y, fVisible, sVisible, fVisible, sVisible, richtextAttribute, drawContext);
26584
26397
  }
26585
- pick(graphics, point, params) {
26586
- let result = {
26587
- graphic: null,
26588
- group: null
26589
- };
26590
- const parentMatrix = new vutils.Matrix(1, 0, 0, 1, 0, 0);
26591
- let group;
26592
- for (let i = 0; i < graphics.length; i++) {
26593
- if (graphics[i].isContainer) {
26594
- result = this.pickGroup(graphics[i], point, parentMatrix, params);
26398
+ drawIcon(icon, context, x, y, baseline) {
26399
+ var _a;
26400
+ const richtextIconAttribute = getTheme(icon).richtextIcon;
26401
+ const { width = richtextIconAttribute.width, height = richtextIconAttribute.height, opacity = richtextIconAttribute.opacity, image: url, backgroundFill = richtextIconAttribute.backgroundFill, backgroundFillOpacity = richtextIconAttribute.backgroundFillOpacity, backgroundStroke = richtextIconAttribute.backgroundStroke, backgroundStrokeOpacity = richtextIconAttribute.backgroundStrokeOpacity, backgroundRadius = richtextIconAttribute.backgroundRadius, margin } = icon.attribute;
26402
+ const { backgroundWidth = width, backgroundHeight = height } = icon.attribute;
26403
+ if (margin) {
26404
+ x += icon._marginArray[3];
26405
+ y += icon._marginArray[0];
26406
+ }
26407
+ if (icon._hovered) {
26408
+ const expandX = (backgroundWidth - width) / 2;
26409
+ const expandY = (backgroundHeight - height) / 2;
26410
+ if (backgroundRadius === 0) {
26411
+ context.beginPath();
26412
+ context.rect(x - expandX, y - expandY, backgroundWidth, backgroundHeight);
26595
26413
  }
26596
26414
  else {
26597
- const data = this.pickItem(graphics[i], point, parentMatrix, params);
26598
- if (data) {
26599
- result.graphic = data.graphic;
26600
- result.params = data.params;
26601
- }
26415
+ context.beginPath();
26416
+ createRectPath(context, x - expandX, y - expandY, backgroundWidth, backgroundHeight, backgroundRadius);
26602
26417
  }
26603
- if (result.graphic) {
26604
- break;
26418
+ if (backgroundFill) {
26419
+ context.globalAlpha = backgroundFillOpacity;
26420
+ context.fillStyle = backgroundFill;
26421
+ context.fill();
26605
26422
  }
26606
- if (!group) {
26607
- group = result.group;
26423
+ if (backgroundStroke) {
26424
+ context.globalAlpha = backgroundStrokeOpacity;
26425
+ context.strokeStyle = backgroundStroke;
26426
+ context.stroke();
26608
26427
  }
26609
26428
  }
26610
- if (!result.graphic) {
26611
- result.group = group;
26612
- }
26613
- if (result.graphic) {
26614
- let g = result.graphic;
26615
- while (g.parent) {
26616
- g = g.parent;
26617
- }
26618
- if (g.shadowHost) {
26619
- result.params = {
26620
- shadowTarget: result.graphic
26621
- };
26622
- result.graphic = g.shadowHost;
26623
- }
26429
+ const res = url && ((_a = icon === null || icon === void 0 ? void 0 : icon.resources) === null || _a === void 0 ? void 0 : _a.get(url));
26430
+ if (!res || res.state !== 'success') {
26431
+ return;
26624
26432
  }
26625
- return result;
26433
+ context.globalAlpha = opacity;
26434
+ context.drawImage(res.data, x, y, width, height);
26626
26435
  }
26627
- containsPoint(graphic, point, params) {
26628
- return !!this.pickItem(graphic, point, null, params);
26436
+ draw(richtext, renderService, drawContext) {
26437
+ const richtextAttribute = getTheme(richtext).richtext;
26438
+ this._draw(richtext, richtextAttribute, false, drawContext);
26629
26439
  }
26630
- pickGroup(group, point, parentMatrix, params) {
26631
- let result = {
26632
- group: null,
26633
- graphic: null
26634
- };
26635
- if (group.attribute.visibleAll === false) {
26636
- return result;
26440
+ };
26441
+ DefaultCanvasRichTextRender = __decorate([
26442
+ injectable(),
26443
+ __metadata("design:paramtypes", [])
26444
+ ], DefaultCanvasRichTextRender);
26445
+
26446
+ let loadRichtextModule = false;
26447
+ const richtextModule = new ContainerModule(bind => {
26448
+ if (loadRichtextModule) {
26449
+ return;
26450
+ }
26451
+ loadRichtextModule = true;
26452
+ bind(RichTextRender).to(DefaultCanvasRichTextRender).inSingletonScope();
26453
+ bind(GraphicRender).toService(RichTextRender);
26454
+ });
26455
+
26456
+ let loadImageModule = false;
26457
+ const imageModule = new ContainerModule(bind => {
26458
+ if (loadImageModule) {
26459
+ return;
26460
+ }
26461
+ loadImageModule = true;
26462
+ bind(ImageRender).to(exports.DefaultCanvasImageRender).inSingletonScope();
26463
+ bind(GraphicRender).toService(ImageRender);
26464
+ bind(ImageRenderContribution).toService(exports.DefaultBaseInteractiveRenderContribution);
26465
+ bindContributionProvider(bind, ImageRenderContribution);
26466
+ });
26467
+
26468
+ let DefaultCanvasRect3dRender = class DefaultCanvasRect3dRender extends BaseRender {
26469
+ constructor() {
26470
+ super(...arguments);
26471
+ this.type = 'rect3d';
26472
+ this.numberType = RECT3D_NUMBER_TYPE;
26473
+ }
26474
+ drawShape(rect, context, x, y, drawContext, params, fillCb, strokeCb) {
26475
+ var _a;
26476
+ const rectAttribute = getTheme(rect, params === null || params === void 0 ? void 0 : params.theme).rect3d;
26477
+ const { fill = rectAttribute.fill, stroke = rectAttribute.stroke, width = rectAttribute.width, height = rectAttribute.height, opacity = rectAttribute.opacity, fillOpacity = rectAttribute.fillOpacity, lineWidth = rectAttribute.lineWidth, strokeOpacity = rectAttribute.strokeOpacity, visible = rectAttribute.visible } = rect.attribute;
26478
+ const z = (_a = this.z) !== null && _a !== void 0 ? _a : 0;
26479
+ const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill);
26480
+ const sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height);
26481
+ const doFill = runFill(fill);
26482
+ const doStroke = runStroke(stroke, lineWidth);
26483
+ if (!(rect.valid && visible)) {
26484
+ return;
26637
26485
  }
26638
- const transMatrix = group.transMatrix;
26639
- const newPoint = new vutils.Point(point.x, point.y);
26640
- parentMatrix.transformPoint(newPoint, newPoint);
26641
- const insideGroup = group.AABBBounds.containsPoint(newPoint);
26642
- if (!insideGroup) {
26643
- return result;
26486
+ if (!(doFill || doStroke)) {
26487
+ return;
26644
26488
  }
26645
- const groupPicked = group.attribute.pickable !== false && insideGroup;
26646
- parentMatrix.multiply(transMatrix.a, transMatrix.b, transMatrix.c, transMatrix.d, transMatrix.e, transMatrix.f);
26647
- if (group.attribute.childrenPickable !== false) {
26648
- group.forEachChildren((graphic) => {
26649
- if (graphic.isContainer) {
26650
- result = this.pickGroup(graphic, point, parentMatrix, params);
26651
- }
26652
- else {
26653
- const newPoint = new vutils.Point(point.x, point.y);
26654
- parentMatrix.transformPoint(newPoint, newPoint);
26655
- const data = this.pickItem(graphic, newPoint, parentMatrix, params);
26656
- if (data) {
26657
- result.graphic = data.graphic;
26658
- result.params = data.params;
26659
- }
26660
- }
26661
- return !!result.graphic || !!result.group;
26662
- });
26489
+ if (!(fVisible || sVisible || fillCb || strokeCb)) {
26490
+ return;
26663
26491
  }
26664
- if (!result.graphic && !result.group && groupPicked) {
26665
- result.group = group;
26492
+ const { light, camera } = drawContext.stage || {};
26493
+ const face3d = rect.findFace();
26494
+ if (fill !== false) {
26495
+ context.setCommonStyle(rect, rect.attribute, x, y, rectAttribute);
26496
+ let fc = fill;
26497
+ if (typeof fc !== 'string') {
26498
+ fc = 'black';
26499
+ }
26500
+ this.fill(x, y, z, face3d, fc, context, light, fillCb);
26666
26501
  }
26667
- return result;
26668
- }
26669
- pickItem(graphic, point, parentMatrix, params) {
26670
- if (graphic.attribute.pickable === false) {
26671
- return null;
26502
+ if (stroke !== false) {
26503
+ context.setStrokeStyle(rect, rect.attribute, x, y, rectAttribute);
26504
+ this.stroke(x, y, z, face3d, context);
26672
26505
  }
26673
- if (graphic.AABBBounds.containsPoint(point)) {
26674
- return {
26675
- graphic: graphic
26506
+ }
26507
+ stroke(x, y, z, face3d, context) {
26508
+ const vertices = face3d.vertices;
26509
+ face3d.edges.forEach(edge => {
26510
+ const p1 = vertices[edge[0]];
26511
+ const v1 = {
26512
+ x: x + p1[0],
26513
+ y: y + p1[1],
26514
+ z: z + p1[2]
26515
+ };
26516
+ const p2 = vertices[edge[1]];
26517
+ const v2 = {
26518
+ x: x + p2[0],
26519
+ y: y + p2[1],
26520
+ z: z + p2[2]
26521
+ };
26522
+ context.beginPath();
26523
+ context.moveTo(v1.x, v1.y, v1.z);
26524
+ context.lineTo(v2.x, v2.y, v2.z);
26525
+ context.stroke();
26526
+ });
26527
+ }
26528
+ fill(x, y, z, face3d, fillColor, context, light, fillCb) {
26529
+ const rgbArray = ColorStore.Get(fillColor, exports.ColorType.Color255);
26530
+ const vertices = face3d.vertices;
26531
+ const viewdVerticesZ = vertices.map(v => {
26532
+ return context.view(v[0], v[1], v[2])[2];
26533
+ });
26534
+ const sortFace = [];
26535
+ face3d.polygons.forEach((p, i) => {
26536
+ sortFace.push({
26537
+ faceIdx: i,
26538
+ polygon: p
26539
+ });
26540
+ const { polygon, normal } = p;
26541
+ const z1 = viewdVerticesZ[polygon[0]];
26542
+ const z2 = viewdVerticesZ[polygon[1]];
26543
+ const z3 = viewdVerticesZ[polygon[2]];
26544
+ const z4 = viewdVerticesZ[polygon[3]];
26545
+ p.ave_z = z1 + z2 + z3 + z4;
26546
+ });
26547
+ sortFace.sort((a, b) => b.polygon.ave_z - a.polygon.ave_z);
26548
+ sortFace.forEach(item => {
26549
+ const { polygon, normal } = item.polygon;
26550
+ const p1 = vertices[polygon[0]];
26551
+ const p2 = vertices[polygon[1]];
26552
+ const p3 = vertices[polygon[2]];
26553
+ const p4 = vertices[polygon[3]];
26554
+ const v1 = {
26555
+ x: x + p1[0],
26556
+ y: y + p1[1],
26557
+ z: z + p1[2]
26676
26558
  };
26677
- }
26678
- return null;
26559
+ const v2 = {
26560
+ x: x + p2[0],
26561
+ y: y + p2[1],
26562
+ z: z + p2[2]
26563
+ };
26564
+ const v3 = {
26565
+ x: x + p3[0],
26566
+ y: y + p3[1],
26567
+ z: z + p3[2]
26568
+ };
26569
+ const v4 = {
26570
+ x: x + p4[0],
26571
+ y: y + p4[1],
26572
+ z: z + p4[2]
26573
+ };
26574
+ context.beginPath();
26575
+ context.moveTo(v1.x, v1.y, v1.z);
26576
+ context.lineTo(v2.x, v2.y, v2.z);
26577
+ context.lineTo(v3.x, v3.y, v3.z);
26578
+ context.lineTo(v4.x, v4.y, v4.z);
26579
+ context.closePath();
26580
+ if (fillCb) {
26581
+ fillCb(context, null, null);
26582
+ }
26583
+ else {
26584
+ context.fillStyle = light ? light.computeColor(normal, rgbArray) : fillColor;
26585
+ context.fill();
26586
+ }
26587
+ });
26588
+ }
26589
+ draw(rect, renderService, drawContext) {
26590
+ const rectAttribute = getTheme(rect).rect;
26591
+ this._draw(rect, rectAttribute, false, drawContext);
26679
26592
  }
26680
26593
  };
26681
- exports.DefaultGlobalPickerService = __decorate([
26682
- injectable(),
26683
- __metadata("design:paramtypes", [])
26684
- ], exports.DefaultGlobalPickerService);
26594
+ DefaultCanvasRect3dRender = __decorate([
26595
+ injectable()
26596
+ ], DefaultCanvasRect3dRender);
26685
26597
 
26686
- class DefaultGraphicAllocate {
26687
- constructor() {
26688
- this.pools = [];
26689
- }
26690
- free(d) {
26691
- this.pools.push(d);
26598
+ let loadRect3dModule = false;
26599
+ const rect3dModule = new ContainerModule(bind => {
26600
+ if (loadRect3dModule) {
26601
+ return;
26692
26602
  }
26693
- get length() {
26694
- return this.pools.length;
26603
+ loadRect3dModule = true;
26604
+ bind(Rect3DRender).to(DefaultCanvasRect3dRender).inSingletonScope();
26605
+ bind(GraphicRender).toService(Rect3DRender);
26606
+ });
26607
+
26608
+ function drawArcPath(arc, context, cx, cy, z, outerRadius, innerRadius) {
26609
+ const { startAngle, endAngle } = arc.getParsedAngle();
26610
+ const deltaAngle = vutils.abs(endAngle - startAngle);
26611
+ const clockwise = endAngle > startAngle;
26612
+ let collapsedToLine = false;
26613
+ if (outerRadius < innerRadius) {
26614
+ const temp = outerRadius;
26615
+ outerRadius = innerRadius;
26616
+ innerRadius = temp;
26695
26617
  }
26696
- release(...params) {
26697
- this.pools = [];
26618
+ if (outerRadius <= vutils.epsilon) {
26619
+ context.moveTo(cx, cy, z);
26698
26620
  }
26699
- }
26700
- class DefaultRectAllocate extends DefaultGraphicAllocate {
26701
- allocate(attribute) {
26702
- if (!this.pools.length) {
26703
- return application.graphicService.creator.rect(attribute);
26621
+ else if (deltaAngle >= vutils.pi2 - vutils.epsilon) {
26622
+ context.moveTo(cx + outerRadius * vutils.cos(startAngle), cy + outerRadius * vutils.sin(startAngle), z);
26623
+ context.arc(cx, cy, outerRadius, startAngle, endAngle, !clockwise, z);
26624
+ if (innerRadius > vutils.epsilon) {
26625
+ context.moveTo(cx + innerRadius * vutils.cos(endAngle), cy + innerRadius * vutils.sin(endAngle), z);
26626
+ context.arc(cx, cy, innerRadius, endAngle, startAngle, clockwise, z);
26704
26627
  }
26705
- const g = this.pools.pop();
26706
- g.initAttributes(attribute);
26707
- return g;
26708
26628
  }
26709
- allocateByObj(rect) {
26710
- if (!this.pools.length) {
26711
- return application.graphicService.creator.rect(rect.attribute);
26629
+ else {
26630
+ const { outerDeltaAngle, innerDeltaAngle, outerStartAngle, outerEndAngle, innerEndAngle, innerStartAngle } = arc.getParsePadAngle(startAngle, endAngle);
26631
+ const xors = outerRadius * vutils.cos(outerStartAngle);
26632
+ const yors = outerRadius * vutils.sin(outerStartAngle);
26633
+ const xire = innerRadius * vutils.cos(innerEndAngle);
26634
+ const yire = innerRadius * vutils.sin(innerEndAngle);
26635
+ if (outerDeltaAngle < 0.001) {
26636
+ collapsedToLine = true;
26712
26637
  }
26713
- const g = this.pools.pop();
26714
- g.initAttributes(rect.attribute);
26715
- return g;
26716
- }
26717
- }
26718
- const defaultRectAllocate = new DefaultRectAllocate();
26719
- class DefaultArcAllocate extends DefaultGraphicAllocate {
26720
- allocate(attribute) {
26721
- if (!this.pools.length) {
26722
- return application.graphicService.creator.arc(attribute);
26638
+ else {
26639
+ context.moveTo(cx + xors, cy + yors, z);
26640
+ context.arc(cx, cy, outerRadius, outerStartAngle, outerEndAngle, !clockwise, z);
26723
26641
  }
26724
- const g = this.pools.pop();
26725
- g.initAttributes(attribute);
26726
- return g;
26727
- }
26728
- allocateByObj(arc) {
26729
- if (!this.pools.length) {
26730
- return application.graphicService.creator.arc(arc.attribute);
26642
+ if (!(innerRadius > vutils.epsilon) || innerDeltaAngle < 0.001) {
26643
+ context.lineTo(cx + xire, cy + yire, z);
26644
+ collapsedToLine = true;
26645
+ }
26646
+ else {
26647
+ context.lineTo(cx + xire, cy + yire, z);
26648
+ context.arc(cx, cy, innerRadius, innerEndAngle, innerStartAngle, clockwise, z);
26731
26649
  }
26732
- const g = this.pools.pop();
26733
- g.initAttributes(arc.attribute);
26734
- return g;
26735
26650
  }
26651
+ context.closePath();
26652
+ return collapsedToLine;
26736
26653
  }
26737
- const defaultArcAllocate = new DefaultArcAllocate();
26738
- class DefaultAreaAllocate extends DefaultGraphicAllocate {
26739
- allocate(attribute) {
26740
- if (!this.pools.length) {
26741
- return application.graphicService.creator.area(attribute);
26742
- }
26743
- const g = this.pools.pop();
26744
- g.initAttributes(attribute);
26745
- return g;
26654
+ function drawInnerOuterArcPath(arc, context, cx, cy, z1, z2, radius, getParsePadAngle) {
26655
+ const { startAngle, endAngle } = arc.getParsedAngle();
26656
+ const deltaAngle = vutils.abs(endAngle - startAngle);
26657
+ const clockwise = endAngle > startAngle;
26658
+ let collapsedToLine = false;
26659
+ if (radius <= vutils.epsilon) {
26660
+ context.moveTo(cx, cy, z1);
26746
26661
  }
26747
- allocateByObj(area) {
26748
- if (!this.pools.length) {
26749
- return application.graphicService.creator.area(area.attribute);
26750
- }
26751
- const g = this.pools.pop();
26752
- g.initAttributes(area.attribute);
26753
- return g;
26662
+ else if (deltaAngle >= vutils.pi2 - vutils.epsilon) {
26663
+ context.moveTo(cx + radius * vutils.cos(startAngle), cy + radius * vutils.sin(startAngle), z1);
26664
+ context.arc(cx, cy, radius, startAngle, endAngle, !clockwise, z1);
26665
+ context.lineTo(cx + radius * vutils.cos(endAngle), cy + radius * vutils.sin(endAngle), z2);
26666
+ context.arc(cx, cy, radius, endAngle, startAngle, clockwise, z2);
26754
26667
  }
26755
- }
26756
- const defaultAreaAllocate = new DefaultAreaAllocate();
26757
- class DefaultCircleAllocate extends DefaultGraphicAllocate {
26758
- allocate(attribute) {
26759
- if (!this.pools.length) {
26760
- return application.graphicService.creator.circle(attribute);
26668
+ else {
26669
+ const { innerouterDeltaAngle, innerouterStartAngle, innerouterEndAngle } = getParsePadAngle(startAngle, endAngle);
26670
+ const xors = radius * vutils.cos(innerouterStartAngle);
26671
+ const yors = radius * vutils.sin(innerouterStartAngle);
26672
+ const xore = radius * vutils.cos(innerouterEndAngle);
26673
+ const yore = radius * vutils.sin(innerouterEndAngle);
26674
+ if (innerouterDeltaAngle < 0.001) {
26675
+ collapsedToLine = true;
26761
26676
  }
26762
- const g = this.pools.pop();
26763
- g.initAttributes(attribute);
26764
- return g;
26765
- }
26766
- allocateByObj(area) {
26767
- if (!this.pools.length) {
26768
- return application.graphicService.creator.circle(area.attribute);
26677
+ else {
26678
+ context.moveTo(cx + xors, cy + yors, z1);
26679
+ context.arc(cx, cy, radius, innerouterStartAngle, innerouterEndAngle, !clockwise, z1);
26680
+ context.lineTo(cx + xore, cy + yore, z2);
26681
+ context.arc(cx, cy, radius, innerouterEndAngle, innerouterStartAngle, clockwise, z2);
26769
26682
  }
26770
- const g = this.pools.pop();
26771
- g.initAttributes(area.attribute);
26772
- return g;
26773
26683
  }
26684
+ context.closePath();
26685
+ return collapsedToLine;
26774
26686
  }
26775
- const defaultCircleAllocate = new DefaultCircleAllocate();
26776
- class DefaultLineAllocate extends DefaultGraphicAllocate {
26777
- allocate(attribute) {
26778
- if (!this.pools.length) {
26779
- return application.graphicService.creator.line(attribute);
26687
+ let DefaultCanvasArc3DRender = class DefaultCanvasArc3DRender extends BaseRender {
26688
+ constructor() {
26689
+ super(...arguments);
26690
+ this.numberType = ARC3D_NUMBER_TYPE;
26691
+ }
26692
+ drawShape(arc, context, x, y, drawContext, params, fillCb, strokeCb) {
26693
+ var _a;
26694
+ const arcAttribute = getTheme(arc, params === null || params === void 0 ? void 0 : params.theme).arc;
26695
+ const { fill = arcAttribute.fill } = arc.attribute;
26696
+ const data = this.valid(arc, arcAttribute, fillCb, strokeCb);
26697
+ if (!data) {
26698
+ return;
26699
+ }
26700
+ const { fVisible, sVisible, doFill, doStroke } = data;
26701
+ const z = (_a = this.z) !== null && _a !== void 0 ? _a : 0;
26702
+ const { outerRadius = arcAttribute.outerRadius, innerRadius = arcAttribute.innerRadius, height = 10 } = arc.attribute;
26703
+ const rgbArray = ColorStore.Get(fill, exports.ColorType.Color255);
26704
+ const { light } = drawContext.stage || {};
26705
+ const face = drawContext.hack_pieFace;
26706
+ const z_face = {
26707
+ top: z,
26708
+ bottom: z + height
26709
+ };
26710
+ const n_face = {
26711
+ top: [0, 1, 0],
26712
+ bottom: [0, -1, 0],
26713
+ outside: [1, 0, -1],
26714
+ inside: [1, 0, -1]
26715
+ };
26716
+ if (face === 'bottom' || face === 'top') {
26717
+ context.beginPath();
26718
+ drawArcPath(arc, context, x, y, z_face[face], outerRadius, innerRadius);
26719
+ context.setShadowBlendStyle && context.setShadowBlendStyle(arc, arc.attribute, arcAttribute);
26720
+ if (doFill) {
26721
+ if (fillCb) {
26722
+ fillCb(context, arc.attribute, arcAttribute);
26723
+ }
26724
+ else if (fVisible) {
26725
+ context.setCommonStyle(arc, arc.attribute, x, y, arcAttribute);
26726
+ context.fillStyle = light ? light.computeColor(n_face[face], rgbArray) : fill;
26727
+ context.fill();
26728
+ }
26729
+ }
26730
+ if (doStroke) {
26731
+ if (strokeCb) {
26732
+ strokeCb(context, arc.attribute, arcAttribute);
26733
+ }
26734
+ else if (sVisible) {
26735
+ context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute);
26736
+ context.stroke();
26737
+ }
26738
+ }
26739
+ }
26740
+ else if (face === 'outside' || face === 'inside') {
26741
+ if (face === 'inside') {
26742
+ context.save();
26743
+ context.beginPath();
26744
+ context.arc(x, y, innerRadius, 0, vutils.pi2, true, z_face.top);
26745
+ context.clip();
26746
+ }
26747
+ context.beginPath();
26748
+ drawInnerOuterArcPath(arc, context, x, y, z_face.top, z_face.bottom, face === 'outside' ? outerRadius : innerRadius, (startAngle, endAngle) => {
26749
+ const { outerDeltaAngle, innerDeltaAngle, outerStartAngle, outerEndAngle, innerEndAngle, innerStartAngle } = arc.getParsePadAngle(startAngle, endAngle);
26750
+ if (face === 'outside') {
26751
+ return {
26752
+ innerouterDeltaAngle: outerDeltaAngle,
26753
+ innerouterEndAngle: outerEndAngle,
26754
+ innerouterStartAngle: outerStartAngle
26755
+ };
26756
+ }
26757
+ return {
26758
+ innerouterDeltaAngle: innerDeltaAngle,
26759
+ innerouterEndAngle: innerEndAngle,
26760
+ innerouterStartAngle: innerStartAngle
26761
+ };
26762
+ });
26763
+ context.setShadowBlendStyle && context.setShadowBlendStyle(arc, arc.attribute, arcAttribute);
26764
+ if (doFill) {
26765
+ if (fillCb) {
26766
+ fillCb(context, arc.attribute, arcAttribute);
26767
+ }
26768
+ else if (fVisible) {
26769
+ context.setCommonStyle(arc, arc.attribute, x, y, arcAttribute);
26770
+ context.fillStyle = light ? light.computeColor(n_face[face], rgbArray) : fill;
26771
+ context.fill();
26772
+ }
26773
+ }
26774
+ if (doStroke) {
26775
+ if (strokeCb) {
26776
+ strokeCb(context, arc.attribute, arcAttribute);
26777
+ }
26778
+ else if (sVisible) {
26779
+ context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute);
26780
+ context.stroke();
26781
+ }
26782
+ }
26783
+ if (face === 'inside') {
26784
+ context.restore();
26785
+ }
26780
26786
  }
26781
- const g = this.pools.pop();
26782
- g.initAttributes(attribute);
26783
- return g;
26784
26787
  }
26785
- allocateByObj(line) {
26786
- if (!this.pools.length) {
26787
- return application.graphicService.creator.line(line.attribute);
26788
- }
26789
- const g = this.pools.pop();
26790
- g.initAttributes(line.attribute);
26791
- return g;
26788
+ draw(arc, renderService, drawContext, params) {
26789
+ const arcAttribute = getTheme(arc, params === null || params === void 0 ? void 0 : params.theme).arc;
26790
+ this._draw(arc, arcAttribute, false, drawContext, params);
26792
26791
  }
26793
- }
26794
- const defaultLineAllocate = new DefaultLineAllocate();
26795
- class DefaultPathAllocate extends DefaultGraphicAllocate {
26796
- allocate(attribute) {
26797
- if (!this.pools.length) {
26798
- return application.graphicService.creator.path(attribute);
26799
- }
26800
- const g = this.pools.pop();
26801
- g.initAttributes(attribute);
26802
- return g;
26792
+ };
26793
+ DefaultCanvasArc3DRender = __decorate([
26794
+ injectable()
26795
+ ], DefaultCanvasArc3DRender);
26796
+
26797
+ let loadArc3dModule = false;
26798
+ const arc3dModule = new ContainerModule(bind => {
26799
+ if (loadArc3dModule) {
26800
+ return;
26803
26801
  }
26804
- allocateByObj(path) {
26805
- if (!this.pools.length) {
26806
- return application.graphicService.creator.path(path.attribute);
26807
- }
26808
- const g = this.pools.pop();
26809
- g.initAttributes(path.attribute);
26810
- return g;
26802
+ loadArc3dModule = true;
26803
+ bind(Arc3dRender).to(DefaultCanvasArc3DRender).inSingletonScope();
26804
+ bind(GraphicRender).toService(Arc3dRender);
26805
+ });
26806
+
26807
+ let DefaultCanvasPyramid3dRender = class DefaultCanvasPyramid3dRender extends BaseRender {
26808
+ constructor() {
26809
+ super(...arguments);
26810
+ this.type = 'pyramid3d';
26811
+ this.numberType = PYRAMID3D_NUMBER_TYPE;
26811
26812
  }
26812
- }
26813
- const defaultPathAllocate = new DefaultPathAllocate();
26814
- class DefaultSymbolAllocate extends DefaultGraphicAllocate {
26815
- allocate(attribute) {
26816
- if (!this.pools.length) {
26817
- return application.graphicService.creator.symbol(attribute);
26813
+ drawShape(pyramid3d, context, x, y, drawContext, params, fillCb, strokeCb) {
26814
+ var _a;
26815
+ const pyramidAttribute = getTheme(pyramid3d, params === null || params === void 0 ? void 0 : params.theme).polygon;
26816
+ const { fill = pyramidAttribute.fill, stroke = pyramidAttribute.stroke, face = [true, true, true, true, true, true] } = pyramid3d.attribute;
26817
+ const z = (_a = this.z) !== null && _a !== void 0 ? _a : 0;
26818
+ const data = this.valid(pyramid3d, pyramidAttribute, fillCb, strokeCb);
26819
+ if (!data) {
26820
+ return;
26818
26821
  }
26819
- const g = this.pools.pop();
26820
- g.initAttributes(attribute);
26821
- return g;
26822
- }
26823
- allocateByObj(symbol) {
26824
- if (!this.pools.length) {
26825
- return application.graphicService.creator.symbol(symbol.attribute);
26822
+ const { light, camera } = drawContext.stage || {};
26823
+ const face3d = pyramid3d.findFace();
26824
+ if (fill !== false) {
26825
+ context.setCommonStyle(pyramid3d, pyramid3d.attribute, x, y, pyramidAttribute);
26826
+ let fc = fill;
26827
+ if (typeof fc !== 'string') {
26828
+ fc = 'black';
26829
+ }
26830
+ this.fill(x, y, z, face3d, face, fc, context, light, camera, pyramid3d, pyramidAttribute, fillCb);
26826
26831
  }
26827
- const g = this.pools.pop();
26828
- g.initAttributes(symbol.attribute);
26829
- return g;
26830
- }
26831
- }
26832
- const defaultSymbolAllocate = new DefaultSymbolAllocate();
26833
- class DefaultTextAllocate extends DefaultGraphicAllocate {
26834
- allocate(attribute) {
26835
- if (!this.pools.length) {
26836
- return application.graphicService.creator.text(attribute);
26832
+ if (stroke !== false) {
26833
+ context.setStrokeStyle(pyramid3d, pyramid3d.attribute, x, y, pyramidAttribute);
26834
+ this.stroke(x, y, z, face3d, context);
26837
26835
  }
26838
- const g = this.pools.pop();
26839
- g.initAttributes(attribute);
26840
- return g;
26841
26836
  }
26842
- allocateByObj(text) {
26843
- if (!this.pools.length) {
26844
- return application.graphicService.creator.text(text.attribute);
26845
- }
26846
- const g = this.pools.pop();
26847
- g.initAttributes(text.attribute);
26848
- return g;
26837
+ stroke(x, y, z, face3d, context) {
26838
+ const vertices = face3d.vertices;
26839
+ face3d.edges.forEach(p => {
26840
+ const p1 = vertices[p[0]];
26841
+ const p2 = vertices[p[1]];
26842
+ const v1 = {
26843
+ x: x + p1[0],
26844
+ y: y + p1[1],
26845
+ z: z + p1[2]
26846
+ };
26847
+ const v2 = {
26848
+ x: x + p2[0],
26849
+ y: y + p2[1],
26850
+ z: z + p2[2]
26851
+ };
26852
+ context.beginPath();
26853
+ context.moveTo(v1.x, v1.y, v1.z);
26854
+ context.lineTo(v2.x, v2.y, v2.z);
26855
+ context.stroke();
26856
+ });
26849
26857
  }
26850
- }
26851
- const defaultTextAllocate = new DefaultTextAllocate();
26852
- class DefaultGraphicMemoryManager {
26853
- constructor() {
26854
- this.map = {
26855
- text: defaultTextAllocate,
26856
- symbol: defaultSymbolAllocate
26857
- };
26858
+ fill(x, y, z, face3d, faces, fillColor, context, light, camera, pyramid3d, pyramid3dAttribute, fillCb) {
26859
+ const rgbArray = ColorStore.Get(fillColor, exports.ColorType.Color255);
26860
+ const vertices = face3d.vertices;
26861
+ const viewdVerticesZ = vertices.map(v => {
26862
+ return context.view(v[0], v[1], v[2])[2];
26863
+ });
26864
+ const sortFace = [];
26865
+ face3d.polygons.forEach((p, i) => {
26866
+ if (!faces[i]) {
26867
+ return;
26868
+ }
26869
+ sortFace.push({
26870
+ faceIdx: i,
26871
+ polygon: p
26872
+ });
26873
+ const { polygon, normal } = p;
26874
+ const z1 = viewdVerticesZ[polygon[0]];
26875
+ const z2 = viewdVerticesZ[polygon[1]];
26876
+ const z3 = viewdVerticesZ[polygon[2]];
26877
+ const z4 = viewdVerticesZ[polygon[3]];
26878
+ p.ave_z = z1 + z2 + z3 + z4;
26879
+ });
26880
+ sortFace.sort((a, b) => b.polygon.ave_z - a.polygon.ave_z);
26881
+ sortFace.forEach(item => {
26882
+ const { polygon, normal } = item.polygon;
26883
+ const p1 = vertices[polygon[0]];
26884
+ const p2 = vertices[polygon[1]];
26885
+ const p3 = vertices[polygon[2]];
26886
+ const p4 = vertices[polygon[3]];
26887
+ const v1 = {
26888
+ x: x + p1[0],
26889
+ y: y + p1[1],
26890
+ z: z + p1[2]
26891
+ };
26892
+ const v2 = {
26893
+ x: x + p2[0],
26894
+ y: y + p2[1],
26895
+ z: z + p2[2]
26896
+ };
26897
+ const v3 = {
26898
+ x: x + p3[0],
26899
+ y: y + p3[1],
26900
+ z: z + p3[2]
26901
+ };
26902
+ const v4 = {
26903
+ x: x + p4[0],
26904
+ y: y + p4[1],
26905
+ z: z + p4[2]
26906
+ };
26907
+ context.beginPath();
26908
+ context.moveTo(v1.x, v1.y, v1.z);
26909
+ context.lineTo(v2.x, v2.y, v2.z);
26910
+ context.lineTo(v3.x, v3.y, v3.z);
26911
+ context.lineTo(v4.x, v4.y, v4.z);
26912
+ context.closePath();
26913
+ if (fillCb) {
26914
+ fillCb(context, pyramid3d.attribute, pyramid3dAttribute);
26915
+ }
26916
+ else {
26917
+ context.fillStyle = light ? light.computeColor(normal, rgbArray) : fillColor;
26918
+ context.fill();
26919
+ }
26920
+ });
26858
26921
  }
26859
- gc(g) {
26860
- if (g.isContainer) {
26861
- g.forEachChildren(i => this.gc(i));
26862
- }
26863
- else {
26864
- this.gcItem(g);
26865
- }
26922
+ draw(pyramid3d, renderService, drawContext) {
26923
+ const pyramid3dAttribute = getTheme(pyramid3d).polygon;
26924
+ this._draw(pyramid3d, pyramid3dAttribute, false, drawContext);
26866
26925
  }
26867
- gcItem(g) {
26868
- const allocate = this.map[g.type];
26869
- if (allocate) {
26870
- allocate.free(g);
26871
- }
26926
+ };
26927
+ DefaultCanvasPyramid3dRender = __decorate([
26928
+ injectable()
26929
+ ], DefaultCanvasPyramid3dRender);
26930
+
26931
+ let loadPyramid3dModule = false;
26932
+ const pyramid3dModule = new ContainerModule(bind => {
26933
+ if (loadPyramid3dModule) {
26934
+ return;
26872
26935
  }
26873
- }
26874
- const defaultGraphicMemoryManager = new DefaultGraphicMemoryManager();
26936
+ loadPyramid3dModule = true;
26937
+ bind(Pyramid3dRender).to(DefaultCanvasPyramid3dRender).inSingletonScope();
26938
+ bind(GraphicRender).toService(Pyramid3dRender);
26939
+ });
26875
26940
 
26876
26941
  exports.ACustomAnimate = ACustomAnimate;
26877
26942
  exports.ARC3D_NUMBER_TYPE = ARC3D_NUMBER_TYPE;
@@ -26987,7 +27052,7 @@
26987
27052
  exports.GlyphRender = GlyphRender;
26988
27053
  exports.Graphic = Graphic;
26989
27054
  exports.GraphicAnimate = GraphicAnimate;
26990
- exports.GraphicCreator = GraphicCreator;
27055
+ exports.GraphicCreator = GraphicCreator$1;
26991
27056
  exports.GraphicPicker = GraphicPicker;
26992
27057
  exports.GraphicRender = GraphicRender;
26993
27058
  exports.GraphicService = GraphicService;
@@ -27062,6 +27127,7 @@
27062
27127
  exports.SVG_PARSE_ATTRIBUTE_MAP_KEYS = SVG_PARSE_ATTRIBUTE_MAP_KEYS;
27063
27128
  exports.SYMBOL_NUMBER_TYPE = SYMBOL_NUMBER_TYPE;
27064
27129
  exports.SegContext = SegContext;
27130
+ exports.ShadowRoot = ShadowRoot;
27065
27131
  exports.SplitRectAfterRenderContribution = SplitRectAfterRenderContribution;
27066
27132
  exports.SplitRectBeforeRenderContribution = SplitRectBeforeRenderContribution;
27067
27133
  exports.Stage = Stage;
@@ -27094,6 +27160,9 @@
27094
27160
  exports.alignSubpath = alignSubpath;
27095
27161
  exports.application = application;
27096
27162
  exports.applyTransformOnBezierCurves = applyTransformOnBezierCurves;
27163
+ exports.arc3dModule = arc3dModule;
27164
+ exports.arcModule = arcModule;
27165
+ exports.areaModule = areaModule;
27097
27166
  exports.bezier = bezier;
27098
27167
  exports.bezierCurversToPath = bezierCurversToPath;
27099
27168
  exports.binarySplitPolygon = binarySplitPolygon;
@@ -27108,35 +27177,18 @@
27108
27177
  exports.canvasAllocate = canvasAllocate;
27109
27178
  exports.centroidOfSubpath = centroidOfSubpath;
27110
27179
  exports.circleBounds = circleBounds;
27180
+ exports.circleModule = circleModule;
27111
27181
  exports.clock = clock;
27112
27182
  exports.cloneGraphic = cloneGraphic;
27113
27183
  exports.colorEqual = colorEqual;
27114
27184
  exports.colorStringInterpolationToStr = colorStringInterpolationToStr;
27115
27185
  exports.container = container;
27116
27186
  exports.cornerTangents = cornerTangents;
27117
- exports.createArc = createArc;
27118
- exports.createArc3d = createArc3d;
27119
- exports.createArea = createArea;
27120
- exports.createCircle = createCircle;
27121
27187
  exports.createColor = createColor;
27122
27188
  exports.createConicalGradient = createConicalGradient;
27123
- exports.createGlyph = createGlyph;
27124
- exports.createGroup = createGroup;
27125
- exports.createImage = createImage;
27126
- exports.createLine = createLine;
27127
27189
  exports.createMat4 = createMat4;
27128
- exports.createPath = createPath;
27129
- exports.createPolygon = createPolygon;
27130
- exports.createPyramid3d = createPyramid3d;
27131
- exports.createRect = createRect;
27132
- exports.createRect3d = createRect3d;
27133
27190
  exports.createRectPath = createRectPath;
27134
- exports.createRichText = createRichText;
27135
- exports.createShadowRoot = createShadowRoot;
27136
27191
  exports.createStage = createStage;
27137
- exports.createSymbol = createSymbol;
27138
- exports.createText = createText;
27139
- exports.createWrapText = createWrapText;
27140
27192
  exports.cubicCalc = cubicCalc;
27141
27193
  exports.cubicLength = cubicLength;
27142
27194
  exports.cubicPointAt = cubicPointAt;
@@ -27206,9 +27258,11 @@
27206
27258
  exports.getTheme = getTheme;
27207
27259
  exports.getThemeFromGroup = getThemeFromGroup;
27208
27260
  exports.globalTheme = globalTheme;
27261
+ exports.glyphModule = glyphModule;
27209
27262
  exports.graphicCreator = graphicCreator;
27210
27263
  exports.graphicService = graphicService;
27211
27264
  exports.graphicUtil = graphicUtil;
27265
+ exports.imageModule = imageModule;
27212
27266
  exports.incrementalAddTo = incrementalAddTo;
27213
27267
  exports.inject = inject;
27214
27268
  exports.injectable = injectable;
@@ -27224,6 +27278,7 @@
27224
27278
  exports.isTransformKey = isTransformKey;
27225
27279
  exports.isXML = isXML;
27226
27280
  exports.layerService = layerService;
27281
+ exports.lineModule = lineModule;
27227
27282
  exports.lookAt = lookAt;
27228
27283
  exports.mat3Tomat4 = mat3Tomat4;
27229
27284
  exports.mat4Allocate = mat4Allocate;
@@ -27241,6 +27296,7 @@
27241
27296
  exports.parsePadding = parsePadding;
27242
27297
  exports.parseStroke = parseStroke;
27243
27298
  exports.parseSvgPath = parseSvgPath;
27299
+ exports.pathModule = pathModule;
27244
27300
  exports.pathToBezierCurves = pathToBezierCurves;
27245
27301
  exports.point = point$2;
27246
27302
  exports.pointEqual = pointEqual;
@@ -27248,12 +27304,17 @@
27248
27304
  exports.pointInterpolationHighPerformance = pointInterpolationHighPerformance;
27249
27305
  exports.pointsEqual = pointsEqual;
27250
27306
  exports.pointsInterpolation = pointsInterpolation;
27307
+ exports.polygonModule = polygonModule;
27308
+ exports.pyramid3dModule = pyramid3dModule;
27251
27309
  exports.rafBasedSto = rafBasedSto;
27310
+ exports.rect3dModule = rect3dModule;
27252
27311
  exports.rectFillVisible = rectFillVisible;
27312
+ exports.rectModule = rectModule;
27253
27313
  exports.rectStrokeVisible = rectStrokeVisible;
27254
27314
  exports.recursiveCallBinarySplit = recursiveCallBinarySplit;
27255
27315
  exports.renderCommandList = renderCommandList;
27256
27316
  exports.rewriteProto = rewriteProto;
27317
+ exports.richtextModule = richtextModule;
27257
27318
  exports.rotateX = rotateX;
27258
27319
  exports.rotateY = rotateY;
27259
27320
  exports.runFill = runFill;
@@ -27274,9 +27335,11 @@
27274
27335
  exports.splitToGrids = splitToGrids;
27275
27336
  exports.strCommandMap = strCommandMap;
27276
27337
  exports.strokeVisible = strokeVisible;
27338
+ exports.symbolModule = symbolModule;
27277
27339
  exports.textDrawOffsetX = textDrawOffsetX;
27278
27340
  exports.textDrawOffsetY = textDrawOffsetY;
27279
27341
  exports.textLayoutOffsetY = textLayoutOffsetY;
27342
+ exports.textModule = textModule;
27280
27343
  exports.transformKeys = transformKeys;
27281
27344
  exports.transformMat4 = transformMat4;
27282
27345
  exports.transformUtil = transformUtil;