|
@@ -484,75 +484,31 @@ export default class Draw {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- this.context.moveTo(points[0].x, points[0].y);
|
|
|
- for (let i = 1; i < points.length; ++i) {
|
|
|
- this.context.lineTo(points[i].x, points[i].y);
|
|
|
- }
|
|
|
- this.context.closePath();
|
|
|
- this.context.stroke();
|
|
|
- if (fillFlag) {
|
|
|
- this.context.fill();
|
|
|
- }
|
|
|
- this.context.restore();
|
|
|
- }
|
|
|
-
|
|
|
- drawCircleGeo(geometry) {
|
|
|
- let radius =
|
|
|
- (geometry.radius * coordinate.res * coordinate.zoom) /
|
|
|
- Constant.defaultZoom;
|
|
|
- const twoPi = Math.PI * 2;
|
|
|
- const pt = coordinate.getScreenXY(geometry.center);
|
|
|
-
|
|
|
- this.context.save();
|
|
|
- this.context.strokeStyle = Style.Circle.strokeStyle;
|
|
|
-
|
|
|
- const selectItem = stateService.getSelectItem();
|
|
|
- const draggingItem = stateService.getDraggingItem();
|
|
|
- const focusItem = stateService.getFocusItem();
|
|
|
- let fillFlag = false;
|
|
|
-
|
|
|
- if (selectItem && selectItem.type == VectorType.Circle) {
|
|
|
- if (geometry.vectorId == selectItem.vectorId) {
|
|
|
- if (selectItem.selectIndex == SelectState.All) {
|
|
|
- this.context.strokeStyle = Style.Select.Circle.strokeStyle;
|
|
|
- this.context.fillStyle = Style.Select.Circle.fillStyle;
|
|
|
- fillFlag = true;
|
|
|
- this.drawRec(geometry.points);
|
|
|
- } else if (selectItem.selectIndex.indexOf(SelectState.Vertex) > -1) {
|
|
|
- this.context.strokeStyle = Style.Select.Circle.strokeStyle;
|
|
|
- let vertexIndex = selectItem.selectIndex.replace(
|
|
|
- SelectState.Vertex + "_",
|
|
|
- ""
|
|
|
- );
|
|
|
- this.drawCircle({
|
|
|
- x: geometry.points[vertexIndex].x,
|
|
|
- y: geometry.points[vertexIndex].y,
|
|
|
- name: ElementEvents.StartAddWall,
|
|
|
- });
|
|
|
- this.drawRec(geometry.points);
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (draggingItem && draggingItem.type == VectorType.Circle) {
|
|
|
- if (geometry.vectorId == draggingItem.vectorId) {
|
|
|
- if (draggingItem.selectIndex == SelectState.All) {
|
|
|
- this.context.strokeStyle = Style.Select.Circle.strokeStyle;
|
|
|
- this.context.fillStyle = Style.Select.Circle.fillStyle;
|
|
|
- fillFlag = true;
|
|
|
- this.drawRec(geometry.points);
|
|
|
- } else if (draggingItem.selectIndex.indexOf(SelectState.Vertex) > -1) {
|
|
|
- this.context.strokeStyle = Style.Select.Circle.strokeStyle;
|
|
|
- let vertexIndex = draggingItem.selectIndex.replace(
|
|
|
- SelectState.Vertex + "_",
|
|
|
- ""
|
|
|
- );
|
|
|
- this.drawCircle({
|
|
|
- x: geometry.points[vertexIndex].x,
|
|
|
- y: geometry.points[vertexIndex].y,
|
|
|
- name: ElementEvents.StartAddWall,
|
|
|
- });
|
|
|
- this.drawRec(geometry.points);
|
|
|
+ drawCustomImage(geometry){
|
|
|
+ if(geometry.url != null){
|
|
|
+ const pt = coordinate.getScreenXY(geometry.center)
|
|
|
+ this.context.save()
|
|
|
+ if(geometry.image == null)
|
|
|
+ {
|
|
|
+ var img = new Image()
|
|
|
+ img.src = geometry.url;
|
|
|
+ img.crossOrigin=""
|
|
|
+ img.onload = function () {
|
|
|
+ this.context.drawImage(img, pt.x-img.width/2, pt.y-img.height/2, img.width, img.height)
|
|
|
+ }.bind(this)
|
|
|
+ geometry.image = img;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ if(geometry.hasOwnProperty('width')){
|
|
|
+ this.context.drawImage(geometry.image, pt.x-geometry.width/2, pt.y-geometry.height/2, geometry.width, geometry.height)
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ this.context.drawImage(geometry.image, pt.x-geometry.width/2, pt.y-geometry.height/2, geometry.image.width, geometry.image.height)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ this.context.restore()
|
|
|
}
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
if (focusItem && focusItem.type == VectorType.Circle) {
|