mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-01-25 15:08:11 +00:00
AreaTool
This commit is contained in:
parent
9db2f239ad
commit
021a1fbb3e
@ -963,5 +963,6 @@
|
||||
"Backup Database": "备份数据库",
|
||||
"Backup database successfully!": "备份数据库成功!",
|
||||
"mongodump.exe is not existed.": "mongodump.exe不存在。",
|
||||
"Backing up, please wait.": "正在备份,请稍后。"
|
||||
"Backing up, please wait.": "正在备份,请稍后。",
|
||||
"Start area measurement.": "开始面积测量。"
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
import { ToolbarSeparator, IconButton } from '../../third_party';
|
||||
import DistanceTool from '../tools/DistanceTool';
|
||||
import AreaTool from '../tools/AreaTool';
|
||||
|
||||
/**
|
||||
* 测量工具
|
||||
@ -18,6 +19,7 @@ class MeasureTools extends React.Component {
|
||||
this.handleMeasureDistance = this.handleMeasureDistance.bind(this);
|
||||
this.handleEndMeasureDistance = this.handleEndMeasureDistance.bind(this);
|
||||
this.handleMeasureArea = this.handleMeasureArea.bind(this);
|
||||
this.handleEndMeasureArea = this.handleEndMeasureArea.bind(this);
|
||||
this.handleMeasureAngle = this.handleMeasureAngle.bind(this);
|
||||
}
|
||||
|
||||
@ -70,7 +72,21 @@ class MeasureTools extends React.Component {
|
||||
// --------------------------- 面积测量 -------------------------------------
|
||||
|
||||
handleMeasureArea() {
|
||||
if (this.areaTool === undefined) {
|
||||
this.areaTool = new AreaTool();
|
||||
this.areaTool.on(`end.${this.id}`, this.handleEndMeasureArea);
|
||||
}
|
||||
this.areaTool.start();
|
||||
this.setState({
|
||||
areaToolEnabled: true
|
||||
});
|
||||
app.toast(_t('Start area measurement.'));
|
||||
}
|
||||
|
||||
handleEndMeasureArea() {
|
||||
this.setState({
|
||||
areaToolEnabled: false
|
||||
});
|
||||
}
|
||||
|
||||
// --------------------------- 角度测量 ---------------------------------------
|
||||
|
||||
@ -2,7 +2,7 @@ import BaseTool from './BaseTool';
|
||||
import UnscaledText from '../../object/text/UnscaledText';
|
||||
|
||||
/**
|
||||
* 距离测量工具
|
||||
* 面积测量工具
|
||||
*/
|
||||
class AreaTool extends BaseTool {
|
||||
constructor() {
|
||||
@ -105,7 +105,7 @@ class AreaTool extends BaseTool {
|
||||
dist += Math.sqrt(
|
||||
(this.positions[i] - this.positions[i - 3]) ** 2,
|
||||
(this.positions[i + 1] - this.positions[i - 2]) ** 2,
|
||||
(this.positions[i + 2] - this.positions[i - 1]) ** 2,
|
||||
(this.positions[i + 2] - this.positions[i - 1]) ** 2
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user