|
@@ -43,149 +43,28 @@ export default class Draw {
|
|
|
this.context.restore();
|
|
|
}
|
|
|
|
|
|
- // setSVGAttr(svgId,width,height){
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
- drawWall(vector, styleType) {
|
|
|
- let start = dataService.getPoint(vector.start);
|
|
|
- let end = dataService.getPoint(vector.end);
|
|
|
-
|
|
|
- let points = [];
|
|
|
- points.push(start);
|
|
|
- for (let i = 0; i < vector.children.length; ++i) {
|
|
|
- let symbol = dataService.getSymbol(vector.children[i]);
|
|
|
- points.push(symbol.startPoint);
|
|
|
- points.push(symbol.endPoint);
|
|
|
- }
|
|
|
- points.push(end);
|
|
|
-
|
|
|
- points = points.sort(sortNumber.bind(this));
|
|
|
- function sortNumber(a, b) {
|
|
|
- return mathUtil.getDistance(start, a) - mathUtil.getDistance(start, b);
|
|
|
- }
|
|
|
+ drawRoad(vector) {
|
|
|
+ let start = dataService.getPoint(vector.startId);
|
|
|
+ let end = dataService.getPoint(vector.endId);
|
|
|
|
|
|
this.context.save();
|
|
|
this.context.beginPath();
|
|
|
this.context.lineCap = "round"; //线段端点的样式
|
|
|
//this.context.lineJoin= 'miter';
|
|
|
this.context.strokeStyle = Style.Wall.strokeStyle;
|
|
|
-
|
|
|
- if (vector.out || vector.important) {
|
|
|
- this.context.lineWidth =
|
|
|
- Style.Wall.important.lineWidth * coordinate.ratio;
|
|
|
- this.context.strokeStyle = Style.Wall.important.strokeStyle;
|
|
|
- } else {
|
|
|
- this.context.lineWidth = Style.Wall.lineWidth * coordinate.ratio;
|
|
|
- this.context.strokeStyle = Style.Wall.strokeStyle;
|
|
|
- }
|
|
|
+ this.context.lineWidth = vector.width;
|
|
|
+ this.context.strokeStyle = Style.Wall.strokeStyle;
|
|
|
|
|
|
const selectItem = stateService.getSelectItem();
|
|
|
const draggingItem = stateService.getDraggingItem();
|
|
|
const focusItem = stateService.getFocusItem();
|
|
|
|
|
|
- //下载的时候,根据样式
|
|
|
- if (styleType) {
|
|
|
- if (styleType == "style-1") {
|
|
|
- if (vector.out || vector.important) {
|
|
|
- this.context.lineWidth =
|
|
|
- Style.DownLoad.style1.Wall.important.lineWidth * coordinate.ratio;
|
|
|
- this.context.strokeStyle =
|
|
|
- Style.DownLoad.style1.Wall.important.strokeStyle;
|
|
|
- } else {
|
|
|
- this.context.lineWidth =
|
|
|
- Style.DownLoad.style1.Wall.lineWidth * coordinate.ratio;
|
|
|
- this.context.strokeStyle = Style.DownLoad.style1.Wall.strokeStyle;
|
|
|
- }
|
|
|
- } else if (styleType == "style-2") {
|
|
|
- if (vector.out || vector.important) {
|
|
|
- this.context.lineWidth =
|
|
|
- Style.DownLoad.style2.Wall.important.lineWidth * coordinate.ratio;
|
|
|
- this.context.strokeStyle =
|
|
|
- Style.DownLoad.style2.Wall.important.strokeStyle;
|
|
|
- } else {
|
|
|
- this.context.lineWidth =
|
|
|
- Style.DownLoad.style2.Wall.lineWidth * coordinate.ratio;
|
|
|
- this.context.strokeStyle = Style.DownLoad.style2.Wall.strokeStyle;
|
|
|
- }
|
|
|
- } else if (styleType == "style-3") {
|
|
|
- if (vector.out || vector.important) {
|
|
|
- this.context.lineWidth =
|
|
|
- Style.DownLoad.style3.Wall.important.lineWidth * coordinate.ratio;
|
|
|
- this.context.strokeStyle =
|
|
|
- Style.DownLoad.style3.Wall.important.strokeStyle;
|
|
|
- } else {
|
|
|
- this.context.lineWidth =
|
|
|
- Style.DownLoad.style3.Wall.lineWidth * coordinate.ratio;
|
|
|
- this.context.strokeStyle = Style.DownLoad.style3.Wall.strokeStyle;
|
|
|
- }
|
|
|
- } else if (styleType == "style-4") {
|
|
|
- if (vector.out || vector.important) {
|
|
|
- this.context.lineWidth =
|
|
|
- Style.DownLoad.style4.Wall.important.lineWidth * coordinate.ratio;
|
|
|
- this.context.strokeStyle =
|
|
|
- Style.DownLoad.style4.Wall.important.strokeStyle;
|
|
|
- } else {
|
|
|
- this.context.lineWidth =
|
|
|
- Style.DownLoad.style4.Wall.lineWidth * coordinate.ratio;
|
|
|
- this.context.strokeStyle = Style.DownLoad.style4.Wall.strokeStyle;
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (selectItem && selectItem.type == VectorType.Wall) {
|
|
|
- if (vector.vectorId == selectItem.vectorId) {
|
|
|
- if (vector.out || vector.important) {
|
|
|
- this.context.strokeStyle = Style.Select.Wall_out.strokeStyle;
|
|
|
- } else {
|
|
|
- this.context.strokeStyle = Style.Select.Wall.strokeStyle;
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (draggingItem && draggingItem.type == VectorType.Wall) {
|
|
|
- if (vector.vectorId == draggingItem.vectorId) {
|
|
|
- if (vector.out || vector.important) {
|
|
|
- this.context.strokeStyle = Style.Select.Wall_out.strokeStyle;
|
|
|
- } else {
|
|
|
- this.context.strokeStyle = Style.Select.Wall.strokeStyle;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (focusItem && focusItem.type == VectorType.Wall) {
|
|
|
- if (vector.vectorId == focusItem.vectorId) {
|
|
|
- this.context.strokeStyle = Style.Focus.Wall.strokeStyle;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for (let i = 0; i < points.length - 1; i += 2) {
|
|
|
- let point1 = coordinate.getScreenXY(points[i]);
|
|
|
- let point2 = coordinate.getScreenXY(points[i + 1]);
|
|
|
- this.context.moveTo(point1.x, point1.y);
|
|
|
- this.context.lineTo(point2.x, point2.y);
|
|
|
- }
|
|
|
+ let point1 = coordinate.getScreenXY(start);
|
|
|
+ let point2 = coordinate.getScreenXY(end);
|
|
|
+ this.context.moveTo(point1.x, point1.y);
|
|
|
+ this.context.lineTo(point2.x, point2.y);
|
|
|
this.context.stroke();
|
|
|
this.context.restore();
|
|
|
-
|
|
|
- // const mid = {
|
|
|
- // x: (start.x + end.x) / 2,
|
|
|
- // y: (start.y + end.y) / 2,
|
|
|
- // }
|
|
|
- // this.drawText(mid, vector.vectorId)
|
|
|
-
|
|
|
- if (
|
|
|
- (selectItem &&
|
|
|
- selectItem.type == VectorType.Wall &&
|
|
|
- vector.vectorId == selectItem.vectorId) ||
|
|
|
- (draggingItem &&
|
|
|
- draggingItem.type == VectorType.Wall &&
|
|
|
- vector.vectorId == draggingItem.vectorId) ||
|
|
|
- (focusItem &&
|
|
|
- focusItem.type == VectorType.Wall &&
|
|
|
- vector.vectorId == focusItem.vectorId)
|
|
|
- ) {
|
|
|
- //添加测量值
|
|
|
- this.drawMeasureTxt(start, end);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
drawSpecialPoint() {
|