SnapDistance.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * Copyright (c) 2011-2018 by Andrew Mustun. All rights reserved.
  3. *
  4. * This file is part of the QCAD project.
  5. *
  6. * QCAD is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * QCAD is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with QCAD.
  18. */
  19. include("scripts/Snap/Snap.js");
  20. include("../../WidgetFactory.js");
  21. /**
  22. * RSnap implementation. Extends RSnapDistance with an options toolbar which
  23. * allows the user to enter the snap distance.
  24. */
  25. function RSnapDistanceExtension() {
  26. RSnapDistance.call(this);
  27. this.action = new EAction(
  28. RGuiAction.getByScriptFile("scripts/Snap/SnapDistance/SnapDistance.js")
  29. );
  30. this.action.setUiOptions(SnapDistance.includeBasePath + "/SnapDistance.ui");
  31. var snap = this;
  32. this.action.slotDistanceChanged = function(value) {
  33. snap.setDistance(value);
  34. };
  35. }
  36. RSnapDistanceExtension.prototype = new RSnapDistance();
  37. RSnapDistanceExtension.prototype.showUiOptions = function() {
  38. this.action.showUiOptions(false);
  39. };
  40. RSnapDistanceExtension.prototype.hideUiOptions = function() {
  41. this.action.hideUiOptions();
  42. };
  43. /**
  44. * \class SnapDistance
  45. * \ingroup ecma_snap
  46. * \brief Snap to point with distance from end point.
  47. */
  48. function SnapDistance(guiAction) {
  49. Snap.call(this, guiAction);
  50. }
  51. SnapDistance.prototype = new Snap();
  52. SnapDistance.includeBasePath = includeBasePath;
  53. SnapDistance.prototype.beginEvent = function() {
  54. Snap.prototype.beginEvent.call(this);
  55. var s = new RSnapDistanceExtension();
  56. this.getDocumentInterface().setSnap(s);
  57. this.terminate();
  58. };