|
@@ -35,7 +35,11 @@ const help = {
|
|
setVectorStyle(ctx, vector, geoType = vector.geoType) {
|
|
setVectorStyle(ctx, vector, geoType = vector.geoType) {
|
|
const styles = help.getVectorStyle(vector, geoType);
|
|
const styles = help.getVectorStyle(vector, geoType);
|
|
for (const style in styles) {
|
|
for (const style in styles) {
|
|
- ctx[style] = styles[style];
|
|
|
|
|
|
+ if (typeof styles[style] === "function") {
|
|
|
|
+ styles[style](ctx, vector)
|
|
|
|
+ } else {
|
|
|
|
+ ctx[style] = styles[style];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return styles;
|
|
return styles;
|
|
},
|
|
},
|
|
@@ -136,24 +140,21 @@ export default class Draw {
|
|
}
|
|
}
|
|
|
|
|
|
drawRoad(vector, isTemp) {
|
|
drawRoad(vector, isTemp) {
|
|
- if (vector.display && vector.midDivide && vector?.midDivideWidth) {
|
|
|
|
|
|
+ if (vector.display) {
|
|
const ctx = this.context;
|
|
const ctx = this.context;
|
|
- const startScreen = coordinate.getScreenXY(vector.midDivide.start);
|
|
|
|
- const endScreen = coordinate.getScreenXY(vector.midDivide.end);
|
|
|
|
- const draw = () => {
|
|
|
|
|
|
+ const draw = (midDivide) => {
|
|
|
|
+ const startScreen = coordinate.getScreenXY(midDivide.start);
|
|
|
|
+ const endScreen = coordinate.getScreenXY(midDivide.end);
|
|
ctx.beginPath();
|
|
ctx.beginPath();
|
|
ctx.moveTo(startScreen.x, startScreen.y);
|
|
ctx.moveTo(startScreen.x, startScreen.y);
|
|
ctx.lineTo(endScreen.x, endScreen.y);
|
|
ctx.lineTo(endScreen.x, endScreen.y);
|
|
ctx.stroke();
|
|
ctx.stroke();
|
|
- };
|
|
|
|
|
|
+ }
|
|
|
|
|
|
ctx.save();
|
|
ctx.save();
|
|
- const vectorStyle = help.setVectorStyle(ctx, vector);
|
|
|
|
- ctx.lineWidth = vector.midDivideWidth;
|
|
|
|
- draw();
|
|
|
|
- ctx.strokeStyle = Style.bgColor;
|
|
|
|
- ctx.lineWidth = vector.midDivideWidth - vectorStyle.realLineWidth;
|
|
|
|
- draw();
|
|
|
|
|
|
+ help.setVectorStyle(ctx, vector);
|
|
|
|
+ vector.midDivide.leftMidDivide && draw(vector.midDivide.leftMidDivide);
|
|
|
|
+ vector.midDivide.rightMidDivide && draw(vector.midDivide.rightMidDivide);
|
|
ctx.restore();
|
|
ctx.restore();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -354,22 +355,22 @@ export default class Draw {
|
|
this.drawPoint(vector);
|
|
this.drawPoint(vector);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ drawCircle(element) {
|
|
|
|
+ this.drawPoint({
|
|
|
|
+ ...element.center,
|
|
|
|
+ radius: element.radius,
|
|
|
|
+ geoType: element.geoType
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
drawPoint(vector) {
|
|
drawPoint(vector) {
|
|
const pt = coordinate.getScreenXY({x: vector.x, y: vector.y});
|
|
const pt = coordinate.getScreenXY({x: vector.x, y: vector.y});
|
|
const ctx = this.context;
|
|
const ctx = this.context;
|
|
- const draw = () => {
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- help.setVectorStyle(ctx, vector, vector.geoType || "Point");
|
|
|
|
|
|
+ const style = help.setVectorStyle(ctx, vector, vector.geoType || "Point");
|
|
|
|
+ const radius = (vector.radius || style.radius) * coordinate.ratio
|
|
|
|
+ ctx.save()
|
|
ctx.beginPath();
|
|
ctx.beginPath();
|
|
- ctx.arc(
|
|
|
|
- pt.x,
|
|
|
|
- pt.y,
|
|
|
|
- Style.Point.radius * coordinate.ratio,
|
|
|
|
- 0,
|
|
|
|
- Math.PI * 2,
|
|
|
|
- true
|
|
|
|
- );
|
|
|
|
|
|
+ ctx.arc(pt.x, pt.y, radius, 0, Math.PI * 2, true);
|
|
ctx.stroke();
|
|
ctx.stroke();
|
|
ctx.fill();
|
|
ctx.fill();
|
|
ctx.restore();
|
|
ctx.restore();
|
|
@@ -398,35 +399,6 @@ export default class Draw {
|
|
ctx.restore();
|
|
ctx.restore();
|
|
}
|
|
}
|
|
|
|
|
|
- drawCircle(element) {
|
|
|
|
- let radius = null;
|
|
|
|
- const twoPi = Math.PI * 2;
|
|
|
|
- const pt = coordinate.getScreenXY(element);
|
|
|
|
- this.context.save();
|
|
|
|
- if (element.name == ElementEvents.AddingPoint) {
|
|
|
|
- radius = Style.Element.AddingPoint.radius * coordinate.ratio;
|
|
|
|
- this.context.strokeStyle = Style.Element.AddingPoint.strokeStyle;
|
|
|
|
- this.context.fillStyle = Style.Element.AddingPoint.fillStyle;
|
|
|
|
- } else if (element.name == ElementEvents.StartSymbolPoints) {
|
|
|
|
- radius = Style.Element.StartSymbolPoints.radius * coordinate.ratio;
|
|
|
|
- this.context.strokeStyle = Style.Element.StartSymbolPoints.strokeStyle;
|
|
|
|
- this.context.fillStyle = Style.Element.StartSymbolPoints.fillStyle;
|
|
|
|
- } else if (element.name == ElementEvents.EndSymbolPoints) {
|
|
|
|
- radius = Style.Element.EndSymbolPoints.radius * coordinate.ratio;
|
|
|
|
- this.context.strokeStyle = Style.Element.EndSymbolPoints.strokeStyle;
|
|
|
|
- this.context.fillStyle = Style.Element.EndSymbolPoints.fillStyle;
|
|
|
|
- } else if (element.name == "pano") {
|
|
|
|
- radius = Style.Pano.radius * coordinate.ratio;
|
|
|
|
- this.context.strokeStyle = Style.Pano.strokeStyle;
|
|
|
|
- this.context.fillStyle = Style.Pano.fillStyle;
|
|
|
|
- this.context.lineWidth = Style.Pano.lineWidth;
|
|
|
|
- }
|
|
|
|
- this.context.beginPath();
|
|
|
|
- this.context.arc(pt.x, pt.y, radius, 0, twoPi, true);
|
|
|
|
- this.context.stroke();
|
|
|
|
- this.context.fill();
|
|
|
|
- this.context.restore();
|
|
|
|
- }
|
|
|
|
|
|
|
|
drawLine(element) {
|
|
drawLine(element) {
|
|
const start = element.getType === VectorType.Line
|
|
const start = element.getType === VectorType.Line
|