AddCircle.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { mathUtil } from "../Util/MathUtil";
  2. import { circleService } from "../Service/CircleService";
  3. import { listenLayer } from "../ListenLayer";
  4. export default class AddCircle {
  5. constructor() {
  6. this.newCircle = null;
  7. this.center = null;
  8. }
  9. setCenter(value) {
  10. this.center = {};
  11. mathUtil.clonePoint(this.center, value);
  12. }
  13. buildCircle(position) {
  14. if (this.newCircle == null && !mathUtil.equalPoint(this.center, position)) {
  15. const radius = mathUtil.getDistance(this.center, position);
  16. this.newCircle = circleService.create(this.center, radius);
  17. }
  18. }
  19. updateCircle(position) {
  20. if (this.newCircle != null && !mathUtil.equalPoint(this.center, position)) {
  21. this.newCircle.setRadius(mathUtil.getDistance(this.center, position));
  22. }
  23. }
  24. finish(position) {
  25. if (this.newCircle != null && mathUtil.equalPoint(this.center, position)) {
  26. dataService.deleteLine(this.newLine.vectorId);
  27. }
  28. }
  29. clear() {
  30. this.newCircle = null;
  31. this.center = null;
  32. }
  33. }
  34. const addCircle = new AddCircle();
  35. export { addCircle };