12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- import { mathUtil } from "../Util/MathUtil";
- import { textService } from "../Service/TextService";
- import { listenLayer } from "../ListenLayer";
- import Settings from "../Settings";
- import { dataService } from "../Service/DataService";
- import { lineService } from "../Service/LineService";
- import { pointService } from "../Service/PointService";
- import VectorCategory from "../enum/VectorCategory";
- export default class LocationModeControl {
- constructor() {}
- //设置直角定位法
- setAngle() {
- let selectBasePoint = this.isFocusBasePoint();
- if (selectBasePoint) {
- let points = dataService.getPoints();
- for (let i = 0; i < points.length; ++i) {
- let point = dataService.getPoint(points[i].vectorId);
- if (point.getCategory() == VectorCategory.Point.fixPoint) {
- this.setSingleFixPointByAngle(
- point.vectorId,
- selectBasePoint.vectorId
- );
- }
- }
- }
- }
- //对一个点进行直角定位法
- //生成两条定位线和一条辅助线
- setSingleFixPointByAngle(fixPointId, basePointId) {
- let fixPoint = dataService.getPoint(fixPointId);
- let basePoint = dataService.getPoint(basePointId);
- let baseLine = dataService.getLine(Settings.baseLineId);
- let startPoint = dataService.getPoint(baseLine.startId);
- let endPoint = dataService.getPoint(baseLine.endId);
- let baseLineGeometry = mathUtil.createLine1(startPoint, endPoint);
- let vLine = mathUtil.getVerticalLine(baseLineGeometry, fixPoint);
- let join = mathUtil.getJoinLinePoint(basePoint, vLine);
- join = pointService.create(join);
- let locationLineByFixPoint = lineService.createByPointId(
- fixPointId,
- join.vectorId,
- VectorCategory.Line.LocationLineByFixPoint
- );
- let locationLineByBasePoint = mathUtil.getVerticalLine(vLine, basePoint);
- join = mathUtil.getIntersectionPoint(locationLineByBasePoint, vLine);
- join = pointService.create(join);
- locationLineByBasePoint = lineService.createByPointId(
- basePointId,
- join.vectorId,
- VectorCategory.Line.LocationLineByBasePoint
- );
- let guideLocationLine = lineService.createByPointId(
- fixPointId,
- join.vectorId,
- VectorCategory.Line.GuideLocationLine
- );
- }
- /******************************************************************************************************************************************************/
- //设置综合定位法
- setAll() {}
- /******************************************************************************************************************************************************/
- isFocusBasePoint() {
- if (Settings.selectBasePointId) {
- let point = dataService.getPoint(Settings.selectBasePointId);
- if (point.getCategory() == VectorCategory.Point.BasePoint) {
- return point;
- }
- }
- return null;
- }
- }
- const locationModeControl = new LocationModeControl();
- export { locationModeControl };
|