|
|
@@ -46,11 +46,12 @@ FileZDM.prototype.applyOperation = function () {
|
|
|
if (this.newEntityData[i][2] == 1) {
|
|
|
addPolylinetoView(TempLineData, false, false, 0, PDColor);
|
|
|
// 计算斜率
|
|
|
- var pdAngle = (this.newEntityData[i + 1][1] - this.newEntityData[i][1]) / (this.newEntityData[i + 1][0] - this.newEntityData[i][0]);
|
|
|
+ // var pdAngle = (this.newEntityData[i + 1][1] - this.newEntityData[i][1]) / (this.newEntityData[i + 1][0] - this.newEntityData[i][0]);
|
|
|
+ var pdAngle = (this.csvCoor[c + 1][1] - this.csvCoor[c][1]) / (this.csvCoor[c + 1][0] - this.csvCoor[c][0]);
|
|
|
// 计算长度
|
|
|
- var pdLen = sqrt((this.newEntityData[i + 1][1] - this.newEntityData[i][1]) * (this.newEntityData[i + 1][1] - this.newEntityData[i][1]) + (this.newEntityData[i + 1][0] - this.newEntityData[i][0]) * (this.newEntityData[i + 1][0] - this.newEntityData[i][0]));
|
|
|
+ // var pdLen = sqrt((this.newEntityData[i + 1][1] - this.newEntityData[i][1]) * (this.newEntityData[i + 1][1] - this.newEntityData[i][1]) + (this.newEntityData[i + 1][0] - this.newEntityData[i][0]) * (this.newEntityData[i + 1][0] - this.newEntityData[i][0]));
|
|
|
addSimpleTextToView((round(pdAngle * 100 * 1000) / 1000).toString(), [(this.newEntityData[i + 1][0] + this.newEntityData[i][0]) / 2 - 2, (this.newEntityData[i + 1][1] + this.newEntityData[i][1]) / 2 + 9], 7, rad2deg(pdAngle), "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
|
|
|
- addSimpleTextToView((round(this.csvCoor[c+1][0]-this.csvCoor[c][0])).toString(), [(this.newEntityData[i + 1][0] + this.newEntityData[i][0]) / 2 - 2, (this.newEntityData[i + 1][1] + this.newEntityData[i][1]) / 2 - 2], 7, rad2deg(pdAngle), "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
|
|
|
+ addSimpleTextToView((round(this.csvCoor[c + 1][0] - this.csvCoor[c][0])).toString(), [(this.newEntityData[i + 1][0] + this.newEntityData[i][0]) / 2 - 2, (this.newEntityData[i + 1][1] + this.newEntityData[i][1]) / 2 - 2], 7, rad2deg(pdAngle), "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
|
|
|
c++;
|
|
|
// addSimpleTextToView((round(pdLen * 1000) / 1000).toString(), [(this.newEntityData[i + 1][0] + this.newEntityData[i][0]) / 2 - 2, (this.newEntityData[i + 1][1] + this.newEntityData[i][1]) / 2 - 2], 7, rad2deg(pdAngle), "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
|
|
|
} else if (this.newEntityData[i][2] == 2) {
|
|
|
@@ -258,16 +259,46 @@ FileZDM.prototype.applyRadius = function (startPoint, space) {
|
|
|
}
|
|
|
}
|
|
|
FileZDM.prototype.applySlope = function (startPoint, space) {
|
|
|
+ // 节点的数组
|
|
|
+ var array = this.csvCoor;
|
|
|
+ // 上一个节点的坐标
|
|
|
var lastPoint = undefined;
|
|
|
- for (var i = 0; i < this.newFZEntityData.length; i += 3) {
|
|
|
- if (i + 1 < this.newFZEntityData.length && this.newFZEntityData[i + 1][2] == 2) {
|
|
|
- addLineToView([lastPoint[0], lastPoint[1]], [startPoint[0], startPoint[1]], 0);
|
|
|
- if (lastPoint && this.newFZEntityData[i + 1][1] > lastPoint[1]) {
|
|
|
- addLineToView([lastPoint[0], startPoint[1] - space], [this.newFZEntityData[i + 1][0], startPoint[1]], 0);
|
|
|
- } else if (lastPoint) {
|
|
|
- addLineToView([lastPoint[0], startPoint[1]], [this.newFZEntityData[i + 1][0], startPoint[1] - space], 0);
|
|
|
- }
|
|
|
- lastPoint = this.newFZEntityData[i + 1];
|
|
|
+ var yMax = startPoint[1];
|
|
|
+ var yMin = startPoint[1] - space;
|
|
|
+ for (var i = 0; i < array.length; i++) {
|
|
|
+ var item = array[i];
|
|
|
+ if (i == 0) {
|
|
|
+ // 第一次进来
|
|
|
+ lastPoint = item;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ var textAngle = undefined;
|
|
|
+ var revers = 1;
|
|
|
+ if (lastPoint && item[1] > lastPoint[1]) {
|
|
|
+ addLineToView([lastPoint[0] / this.ratio, yMin], [item[0] / this.ratio, yMax], 0);
|
|
|
+ textAngle = Math.atan((yMax - yMin) / ((item[0] - lastPoint[0]) / this.ratio));
|
|
|
+ revers = 1;
|
|
|
+ } else if (lastPoint && item[1] <= lastPoint[1]) {
|
|
|
+ addLineToView([lastPoint[0] / this.ratio, yMax], [item[0] / this.ratio, yMin], 0);
|
|
|
+ textAngle = Math.atan((yMin - yMax) / ((item[0] - lastPoint[0]) / this.ratio));
|
|
|
+ revers = -1;
|
|
|
+ }
|
|
|
+ // 计算斜率
|
|
|
+ var angle = (item[1] - lastPoint[1]) / (item[0] - lastPoint[0]);
|
|
|
+ var x = (lastPoint[0] + (item[0] - lastPoint[0]) * 1 / 2) / this.ratio;
|
|
|
+ var y = yMax - space * 1 / 2;
|
|
|
+
|
|
|
+ if (revers == 1) {
|
|
|
+ addSimpleTextToView((round(angle * 100 * 1000) / 1000).toString(), [x - 2, y + 8], 7, rad2deg(textAngle || 0), "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
|
|
|
+ addSimpleTextToView((round((item[0] - lastPoint[0]) * 1000) / 1000).toString(), [x - 2, y - 4], 7, rad2deg(textAngle || 0), "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
|
|
|
+ } else {
|
|
|
+ addSimpleTextToView((round(angle * 1000) / 1000).toString(), [x + 2, y + 8], 7, rad2deg(textAngle || 0), "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
|
|
|
+ addSimpleTextToView((round((item[0] - lastPoint[0]) * 1000) / 1000).toString(), [x - 2, y - 4], 7, rad2deg(textAngle || 0), "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
|
|
|
}
|
|
|
+ // 绘画竖线
|
|
|
+ addLineToView([item[0] / this.ratio, yMax], [item[0] / this.ratio, yMin], 0);
|
|
|
+ addSimpleTextToView("+" + (round((item[0]) * 1000) / 1000).toString(), [item[0] / this.ratio - 10, y - 25], 7, 90, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
|
|
|
+ addSimpleTextToView((round((item[1] - lastPoint[1]) * 1000) / 1000).toString(), [item[0] / this.ratio + 6, y - 25], 7, 90, "Standard", RS.VAlignTop, RS.HAlignLeft, false, false, 0);
|
|
|
+ lastPoint = item;
|
|
|
}
|
|
|
}
|