Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
R
road-demo
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
王健
road-demo
Commits
f3835a7d
提交
f3835a7d
authored
1月 04, 2022
作者:
许言琪
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 添加缩放比
上级
22a68623
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
139 行增加
和
88 行删除
+139
-88
drawing.vue
src/components/drawing.vue
+139
-88
没有找到文件。
src/components/drawing.vue
浏览文件 @
f3835a7d
...
...
@@ -5,13 +5,7 @@
-->
<
template
>
<div
class=
"drawing"
>
<div
id=
"canvas"
class=
"canvas"
:style=
"
{
height: boxHeight + rulerHeight + 'px',
}"
>
</div>
<div
id=
"canvas"
class=
"canvas"
></div>
<el-row>
<el-row
class=
"control-btn"
>
<el-button
type=
"primary"
@
click=
"roadDrawer = true"
...
...
@@ -42,7 +36,7 @@
<el-drawer
title=
"道路信息"
:visible
.
sync=
"roadDrawer"
:wrapperClosable=
"
fals
e"
:wrapperClosable=
"
tru
e"
direction=
"rtl"
>
<div
class=
"plan"
>
...
...
@@ -54,37 +48,42 @@
<el-form-item
label=
"路线名称"
prop=
"roadName"
>
{{
diseaseForm
.
roadName
}}
</el-form-item>
<el-form-item
label=
"行驶方向"
prop=
"direction"
>
<el-select
v-model=
"diseaseForm.direction"
placeholder=
"请选择"
>
<el-option
v-for=
"item in directionOptions"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item
label=
"起点名称"
prop=
"startStake"
>
<el-input
v-model=
"diseaseForm.startStake"
></el-input>
</el-form-item>
<el-form-item
label=
"止点桩号"
prop=
"endStake"
>
<el-input
v-model=
"diseaseForm.endStake"
></el-input>
</el-form-item>
<el-form-item
label=
"路线长度"
prop=
"roadLength"
>
<el-input
v-model=
"diseaseForm.roadLength"
>
<template
slot=
"append"
>
m
</
template
></el-input
>
</el-form-item>
<el-form-item
label=
"全幅宽度"
prop=
"roadWidth"
>
<el-input
v-model=
"diseaseForm.roadWidth"
>
<template
slot=
"append"
>
m
</
template
></el-input
>
</el-form-item>
<el-form-item
label=
"路线长度"
prop=
"roadLength"
>
{{ roadLength }} m
</el-form-item>
<el-form-item
label=
"半幅宽度"
prop=
"roadWidth"
>
{{ diseaseForm.roadWidth / 2 }} m
</el-form-item>
<el-form-item
label=
"是否保持缩放比"
label-width=
"110px"
prop=
"endStake"
>
<el-select
v-model=
"scale"
placeholder=
"请选择"
@
change=
"scaleChange"
>
<el-option
v-for=
"item in scaleOptions"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button
type=
"primary"
@
click=
"onSubmit"
>
生成
</el-button>
...
...
@@ -99,7 +98,7 @@
title=
"病害信息"
:visible
.
sync=
"diseaseDrawer"
direction=
"rtl"
:wrapperClosable=
"
fals
e"
:wrapperClosable=
"
tru
e"
>
<div
class=
"plan"
>
<el-card
class=
"box-card"
>
...
...
@@ -123,6 +122,17 @@
</el-option>
</el-select>
</el-form-item>
<el-form-item
label=
"行驶方向"
prop=
"direction"
>
<el-select
v-model=
"diseaseForm.direction"
placeholder=
"请选择"
>
<el-option
v-for=
"item in directionOptions"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item
label=
"病害类型"
prop=
"diseaseType"
>
<el-select
v-model=
"diseaseForm.diseaseType"
placeholder=
"请选择"
>
<el-option
...
...
@@ -148,7 +158,7 @@
<el-form-item
label=
"病害桩号"
prop=
"stake"
>
<el-input
v-model=
"diseaseForm.stake"
></el-input>
</el-form-item>
<el-form-item
label=
"距
分割
线"
prop=
"distance"
>
<el-form-item
label=
"距
中心
线"
prop=
"distance"
>
<el-input
v-model=
"diseaseForm.distance"
>
<
template
slot=
"append"
>
m
</
template
></el-input
>
...
...
@@ -189,6 +199,18 @@ export default {
rulerSeparateHeight
:
30
,
// 左边标尺间隔多少厘米
leftRuler
:
50
,
// 病害大小展示是否成正比,100为正常比例,10为视觉比例
scale
:
10
,
scaleOptions
:
[
{
label
:
"是"
,
value
:
10
,
},
{
label
:
"否"
,
value
:
100
,
},
],
diseaseDrawer
:
false
,
diseaseForm
:
{
roadName
:
"G205 山深线"
,
...
...
@@ -366,7 +388,7 @@ export default {
},
// 画布宽度
boxWidth
()
{
return
Number
(
this
.
diseaseForm
.
roadLength
)
+
this
.
boxPadding
*
2
;
return
Number
(
this
.
roadLength
)
*
10
+
this
.
boxPadding
*
2
;
},
// 画布高度
boxHeight
()
{
...
...
@@ -452,9 +474,8 @@ export default {
},
mounted
()
{
this
.
initCanvas
();
this
.
drawDisease
();
new
paper
.
Point
(
50
,
0
).
angle
;
new
paper
.
Point
(
40
,
100
).
angle
;
this
.
drawDisease
(
this
.
diseaseForm
);
this
.
diseaseList
.
push
(
JSON
.
parse
(
JSON
.
stringify
(
this
.
diseaseForm
)));
},
methods
:
{
/** 初始化 */
...
...
@@ -486,50 +507,42 @@ export default {
path
.
add
(
new
Point
(
0
,
this
.
boxHeight
+
this
.
rulerHeight
));
path
.
closed
=
true
;
// 左距离尺,上行
const
leftRuler
=
Math
.
ceil
(
(
this
.
boxHeight
-
this
.
rulerHeight
)
/
this
.
leftRuler
);
let
path1Segments
=
[];
path1Segments
.
push
([
20
,
this
.
rulerHeight
]);
path1Segments
.
push
([
10
,
this
.
rulerHeight
]);
new
paper
.
PointText
({
point
:
[
10
,
this
.
rulerHeight
-
5
],
content
:
"1cm"
,
fillColor
:
"black"
,
fontFamily
:
"Courier New"
,
fontSize
:
11
,
});
for
(
let
index
=
1
;
index
<
leftRuler
+
1
;
index
++
)
{
path1Segments
.
push
([
10
,
this
.
leftRuler
*
index
+
this
.
rulerHeight
]);
path1Segments
.
push
([
20
,
this
.
leftRuler
*
index
+
this
.
rulerHeight
+
0.1
,
]);
path1Segments
.
push
([
10
,
this
.
leftRuler
*
index
+
this
.
rulerHeight
+
0.1
,
]);
new
paper
.
PointText
({
point
:
[
10
,
this
.
leftRuler
*
index
+
this
.
rulerHeight
-
5
],
content
:
index
*
this
.
leftRuler
+
"cm"
,
fillColor
:
"black"
,
fontFamily
:
"Courier New"
,
fontSize
:
11
,
});
}
0.1
;
let
path1
=
new
paper
.
Path
({
segments
:
path1Segments
,
});
path1
.
strokeColor
=
"black"
;
// 左距离尺,下行
// let path2 = new paper.Path({
// segments: [
// [10, this.roadHalfWidth],
// [10, this.boxHeight],
// ],
// const leftRuler = Math.ceil(
// (this.boxHeight - this.rulerHeight) / this.leftRuler
// );
// let path1Segments = [];
// path1Segments.push([20, this.rulerHeight]);
// path1Segments.push([10, this.rulerHeight]);
// new paper.PointText({
// point: [10, this.rulerHeight - 5],
// content: "1cm",
// fillColor: "black",
// fontFamily: "Courier New",
// fontSize: 11,
// });
// path2.strokeColor = "black";
// for (let index = 1; index
<
leftRuler
+
1
;
index
++
)
{
// path1Segments.push([10, this.leftRuler * index + this.rulerHeight]);
// path1Segments.push([
// 20,
// this.leftRuler * index + this.rulerHeight + 0.1,
// ]);
// path1Segments.push([
// 10,
// this.leftRuler * index + this.rulerHeight + 0.1,
// ]);
// new paper.PointText({
// point: [10, this.leftRuler * index + this.rulerHeight - 5],
// content: index * this.leftRuler + "cm",
// fillColor: "black",
// fontFamily: "Courier New",
// fontSize: 11,
// });
// }
// 0.1;
// let path1 = new paper.Path({
// segments: path1Segments,
// });
// path1.strokeColor = "black";
},
/** 绘制中间线 */
drawCenterLine
()
{
...
...
@@ -587,26 +600,36 @@ export default {
/**
* 绘制病害
*/
drawDisease
()
{
drawDisease
(
form
)
{
console
.
log
(
form
);
if
(
!
form
)
{
return
false
;
}
// 距离中间线多少米
let
distance
=
this
.
diseaseF
orm
.
distance
;
let
distance
=
f
orm
.
distance
;
// 桩号
let
stake
=
this
.
diseaseF
orm
.
stake
;
let
stake
=
f
orm
.
stake
;
// 病害长度
let
diseaseLength
=
this
.
diseaseF
orm
.
diseaseLength
;
let
diseaseLength
=
f
orm
.
diseaseLength
;
// 病害宽度
let
diseaseWidth
=
this
.
diseaseF
orm
.
diseaseWidth
;
let
diseaseWidth
=
f
orm
.
diseaseWidth
;
// 病害在canvas上的位置
const
x
=
(
Number
(
stake
)
-
Number
(
this
.
diseaseForm
.
startStake
))
*
10000
+
this
.
boxPadding
;
(
Number
(
stake
)
-
Number
(
form
.
startStake
))
*
10000
+
this
.
boxPadding
;
let
y
=
this
.
roadHalfWidth
+
distance
*
100
;
const
width
=
diseaseLength
*
10
;
const
height
=
diseaseWidth
*
100
;
if
(
this
.
diseaseForm
.
direction
==
"上行"
)
{
const
height
=
diseaseWidth
*
this
.
scale
;
if
(
form
.
direction
==
"上行"
)
{
console
.
log
(
this
.
roadHalfWidth
-
distance
*
100
);
console
.
log
(
this
.
roadHalfWidth
);
console
.
log
(
distance
);
if
(
this
.
scale
===
10
)
{
y
=
this
.
roadHalfWidth
-
distance
*
100
-
height
;
}
else
{
y
=
this
.
roadHalfWidth
-
distance
*
100
-
diseaseWidth
*
100
;
}
}
let
rectangle
=
new
paper
.
Rectangle
({
x
,
y
,
...
...
@@ -617,7 +640,7 @@ export default {
path
.
strokeColor
=
"black"
;
this
.
drawInterferenceLine
(
rectangle
,
4
);
// 病害宽度
new
paper
.
PointText
({
point
:
rectangle
.
rightCenter
,
content
:
`
${
diseaseWidth
}
m`
,
...
...
@@ -625,15 +648,32 @@ export default {
fontFamily
:
"Courier New"
,
fontSize
:
14
,
});
// 病害长度
new
paper
.
PointText
({
point
:
rectangle
.
top
Center
,
point
:
rectangle
.
bottom
Center
,
content
:
`
${
diseaseLength
}
m`
,
fillColor
:
"black"
,
fontFamily
:
"Courier New"
,
fontSize
:
14
,
});
this
.
diseaseList
.
push
(
this
.
diseaseForm
);
// 病害距离中间距离
if
(
form
.
direction
==
"上行"
)
{
new
paper
.
PointText
({
point
:
rectangle
.
topCenter
,
content
:
`左
${
form
.
distance
}
m`
,
fillColor
:
"black"
,
fontFamily
:
"Courier New"
,
fontSize
:
11
,
});
}
else
{
new
paper
.
PointText
({
point
:
rectangle
.
topCenter
,
content
:
`右
${
form
.
distance
}
m`
,
fillColor
:
"black"
,
fontFamily
:
"Courier New"
,
fontSize
:
11
,
});
}
},
/** 绘制网格 */
drawInterferenceLine
(
rectangle
,
lineType
)
{
...
...
@@ -695,7 +735,18 @@ export default {
},
// 添加病害
addDisease
()
{
this
.
drawDisease
();
this
.
drawDisease
(
this
.
diseaseForm
);
this
.
diseaseList
.
push
(
JSON
.
parse
(
JSON
.
stringify
(
this
.
diseaseForm
)));
},
/** 缩放比 */
scaleChange
()
{
paper
.
remove
();
this
.
canvas
.
remove
();
this
.
initCanvas
();
this
.
diseaseList
.
forEach
((
item
)
=>
{
this
.
drawDisease
(
item
);
});
},
/** 桩号转换 */
transformStakeString
(
stake
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论