Skip to content

Commit f804c9a

Browse files
author
zhaokai
committed
动效
1 parent d169e34 commit f804c9a

File tree

11 files changed

+268
-378
lines changed

11 files changed

+268
-378
lines changed

src/service/2DPlot/PlotCanvas.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @Author: zk
55
* @Date: 2022-05-13 10:34:57
66
* @LastEditors: zk
7-
* @LastEditTime: 2022-05-26 11:42:37
7+
* @LastEditTime: 2022-05-30 14:50:31
88
*/
99

1010
import { DrawPlotObjectFactory2D } from './Draw/DrawPlotObjectFactory2D';
@@ -183,7 +183,7 @@ export default class PlotCanvas {
183183
remove(plotObj) {
184184
const i = this.m_plotObjects.indexOf(plotObj);
185185
if (i > -1) {
186-
this.m_plotObjects.splice(i, 0);
186+
this.m_plotObjects.splice(i,1);
187187
}
188188
if (this._fabricCanvas) {
189189
this._fabricCanvas.remove(plotObj);

src/service/2DPlot/PlotCanvasGroup.js

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
* @Author: zk
55
* @Date: 2022-05-13 11:01:10
66
* @LastEditors: zk
7-
* @LastEditTime: 2022-05-27 10:56:43
7+
* @LastEditTime: 2022-05-30 16:22:23
88
*/
99

1010
import { fabric } from 'fabric';
1111
import PlotCanvas from './PlotCanvas';
12-
import PlotUtilLine from './Shapes/PlotUtilLine';
12+
import DrawTool from '../PlotBase/Draw/DrawTool';
13+
import SymbolManager from '../PlotBase/SymbolManager/SymbolManager';
14+
import { PlotObjectFactory } from './Shapes/PlotObjectFactory';
1315

1416
export const PlotCanvasGroup = fabric.util.createClass(fabric.Canvas, {
1517
selection: false,
@@ -23,8 +25,11 @@ export const PlotCanvasGroup = fabric.util.createClass(fabric.Canvas, {
2325
initialize: function (el, options) {
2426
if (!PlotCanvasGroup.instance) {
2527
this.callSuper('initialize', el, options);
26-
this._plotCanvasLayers = [];
2728
PlotCanvasGroup.instance = this;
29+
// 工具图层
30+
this._utilPlotCanvas = new PlotCanvas();
31+
this._plotCanvasLayers = [];
32+
this.addLayer(this._utilPlotCanvas);
2833
} else {
2934
return PlotCanvasGroup.instance;
3035
}
@@ -207,9 +212,6 @@ export const PlotCanvasGroup = fabric.util.createClass(fabric.Canvas, {
207212
let t = null;
208213
for (let i = 0; i < this._objects.length; i++) {
209214
const object = this._objects[i];
210-
if(!object.isExtendPlotObject){
211-
continue
212-
}
213215
const elem = object.getElement();
214216
if (elem && elem.getFeatureId() === uid) {
215217
t = object;
@@ -223,17 +225,6 @@ export const PlotCanvasGroup = fabric.util.createClass(fabric.Canvas, {
223225
layer.initCoords();
224226
});
225227
},
226-
addUtilPath(coords, options) {
227-
const plot = new PlotUtilLine({
228-
coords,
229-
canvas:this
230-
})
231-
this.add(plot);
232-
return plot;
233-
},
234-
removeUtilPath(utilPlotObject) {
235-
this.remove(utilPlotObject);
236-
},
237228
/**
238229
* @function: Module:PlotCanvasGroup.prototype._renderObjects
239230
* @description: 渲染标绘对象代码
@@ -261,6 +252,22 @@ export const PlotCanvasGroup = fabric.util.createClass(fabric.Canvas, {
261252

262253
flag && object && object.render(ctx);
263254
}
255+
},
256+
drawUtilPlotObject(id, options) {
257+
const symbol = SymbolManager.instance;
258+
const leaf = symbol.getLeafByID(id);
259+
return leaf.getElement().then((element) => {
260+
const plotObj = PlotObjectFactory.createInstance(element.type, {
261+
element,
262+
positions: options.positions,
263+
canvas: this._utilPlotCanvas
264+
});
265+
this._utilPlotCanvas.add(plotObj);
266+
return plotObj;
267+
});
268+
},
269+
removeDrawUtilPlotObject(plotObject){
270+
this._utilPlotCanvas.remove(plotObject)
264271
}
265272
});
266273

src/service/2DPlot/Shapes/PlotObject.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @Author: your name
33
* @Date: 2021-07-05 11:32:52
4-
* @LastEditTime: 2022-05-27 10:53:09
4+
* @LastEditTime: 2022-05-30 16:23:28
55
* @LastEditors: zk
66
* @Description: In User Settings Edit
77
* @FilePath: \MapGISPlot\src\js\Shapes\PlotObject.js
@@ -18,8 +18,6 @@ const PlotObject = fabric.util.createClass(fabric.Object, {
1818
this._elem.positions = options.positions || [];
1919
this.m_coordsPx = [];
2020
this._elem.propsUpdateSignal.add(this._elemPropsUpdateHandler, this);
21-
22-
this.isExtendPlotObject=true
2321
},
2422
_elemPropsUpdateHandler(event) {
2523
this.set('dirty', true);

src/service/2DPlot/Shapes/PlotUtilLine.js

Lines changed: 0 additions & 130 deletions
This file was deleted.

src/service/PlotBase/Animation/AnimationTypes/PlotBaseAnimation.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @Author: zk
44
* @Date: 2022-03-23 10:02:49
55
* @LastEditors: zk
6-
* @LastEditTime: 2022-05-26 15:09:13
6+
* @LastEditTime: 2022-05-30 14:04:17
77
*/
88
import { AnimationUtil } from '../utils/AnimationUtil';
99
import { easingFunc } from '../utils/Easing';
@@ -30,9 +30,8 @@ export default class PlotBaseAnimation {
3030
// 图层组函数
3131
this.handRefresh = options.handRefresh || function () {};
3232
this.getPlotObjectById = options.getPlotObjectById || function (uid) {};
33-
this.addUtilPath= options.addUtilPath || function (){}
34-
this.removeUtilPath= options.removeUtilPath || function(){
35-
}
33+
this.drawUtilPlotObject = options.drawUtilPlotObject ? options.drawUtilPlotObject : function () {};
34+
this.removeDrawUtilPlotObject=options.removeDrawUtilPlotObject?options.removeDrawUtilPlotObject:function(){};
3635
// 时段记录
3736
this.timeSpace = 0;
3837
// 播放历史

src/service/PlotBase/Animation/AnimationTypes/PlotExtendAnimation/PlotGrowAnimation/PlotCoordsAnimation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @Author: zk
44
* @Date: 2022-03-23 10:02:49
55
* @LastEditors: zk
6-
* @LastEditTime: 2022-05-25 11:31:15
6+
* @LastEditTime: 2022-05-27 17:30:23
77
*/
88
import Point from '../../../../../PlotUtilBase/Geometry/Point';
99
import PlotBaseAnimation from '../../PlotBaseAnimation';

0 commit comments

Comments
 (0)