LocationModeControl.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import { mathUtil } from "../Util/MathUtil";
  2. import { textService } from "../Service/TextService";
  3. import { listenLayer } from "../ListenLayer";
  4. import Settings from "../Settings";
  5. import { dataService } from "../Service/DataService";
  6. import { lineService } from "../Service/LineService";
  7. import { pointService } from "../Service/PointService";
  8. import VectorCategory from "../enum/VectorCategory";
  9. export default class LocationModeControl {
  10. constructor() {}
  11. //设置直角定位法
  12. setAngle() {
  13. let selectBasePoint = this.isFocusBasePoint();
  14. if (selectBasePoint) {
  15. let points = dataService.getPoints();
  16. for (let i = 0; i < points.length; ++i) {
  17. let point = dataService.getPoint(points[i].vectorId);
  18. if (point.getCategory() == VectorCategory.Point.fixPoint) {
  19. this.setSingleFixPointByAngle(
  20. point.vectorId,
  21. selectBasePoint.vectorId
  22. );
  23. }
  24. }
  25. }
  26. }
  27. //对一个点进行直角定位法
  28. //生成两条定位线和一条辅助线
  29. setSingleFixPointByAngle(fixPointId, basePointId) {
  30. let fixPoint = dataService.getPoint(fixPointId);
  31. let basePoint = dataService.getPoint(basePointId);
  32. let baseLine = dataService.getLine(Settings.baseLineId);
  33. let startPoint = dataService.getPoint(baseLine.startId);
  34. let endPoint = dataService.getPoint(baseLine.endId);
  35. let baseLineGeometry = mathUtil.createLine1(startPoint, endPoint);
  36. let vLine = mathUtil.getVerticalLine(baseLineGeometry, fixPoint);
  37. let join = mathUtil.getJoinLinePoint(basePoint, vLine);
  38. join = pointService.create(join);
  39. let locationLineByFixPoint = lineService.createByPointId(
  40. fixPointId,
  41. join.vectorId,
  42. VectorCategory.Line.LocationLineByFixPoint
  43. );
  44. let locationLineByBasePoint = mathUtil.getVerticalLine(vLine, basePoint);
  45. join = mathUtil.getIntersectionPoint(locationLineByBasePoint, vLine);
  46. join = pointService.create(join);
  47. locationLineByBasePoint = lineService.createByPointId(
  48. basePointId,
  49. join.vectorId,
  50. VectorCategory.Line.LocationLineByBasePoint
  51. );
  52. let guideLocationLine = lineService.createByPointId(
  53. fixPointId,
  54. join.vectorId,
  55. VectorCategory.Line.GuideLocationLine
  56. );
  57. }
  58. /******************************************************************************************************************************************************/
  59. //设置综合定位法
  60. setAll() {}
  61. /******************************************************************************************************************************************************/
  62. isFocusBasePoint() {
  63. if (Settings.selectBasePointId) {
  64. let point = dataService.getPoint(Settings.selectBasePointId);
  65. if (point.getCategory() == VectorCategory.Point.BasePoint) {
  66. return point;
  67. }
  68. }
  69. return null;
  70. }
  71. }
  72. const locationModeControl = new LocationModeControl();
  73. export { locationModeControl };