ShapeRectangleSize.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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("../Shape.js");
  20. include("../../DrawBasedOnRectangleSize.js");
  21. /**
  22. * \class ShapeRectangleSize
  23. * \brief Rectangle from point and size.
  24. * \ingroup ecma_draw_shape
  25. */
  26. function ShapeRectangleSize(guiAction) {
  27. DrawBasedOnRectangleSize.call(this, guiAction);
  28. this.createPolyline = false;
  29. this.fill = false;
  30. this.roundCorners = false;
  31. this.radius = 1.0;
  32. this.includeBasePath = ShapeRectangleSize.includeBasePath;
  33. this.dialogUiFile = "ShapeRectangleSizeDialog.ui";
  34. this.setUiOptions(["../Shape.ui", "ShapeRectangleSize.ui"]);
  35. }
  36. ShapeRectangleSize.prototype = new DrawBasedOnRectangleSize();
  37. ShapeRectangleSize.includeBasePath = includeBasePath;
  38. ShapeRectangleSize.prototype.getShapes = function(corners) {
  39. return Shape.getShapes(this, corners);
  40. };
  41. ShapeRectangleSize.prototype.slotCreatePolylineChanged = function(checked) {
  42. Shape.slotCreatePolylineChanged(this, checked);
  43. };
  44. ShapeRectangleSize.prototype.slotFillChanged = function(checked) {
  45. Shape.slotFillChanged(this, checked);
  46. };
  47. ShapeRectangleSize.prototype.slotRoundCornersChanged = function(checked) {
  48. Shape.slotRoundCornersChanged(this, checked);
  49. };
  50. ShapeRectangleSize.prototype.slotRadiusChanged = function(v) {
  51. Shape.slotRadiusChanged(this, v);
  52. };
  53. ShapeRectangleSize.prototype.initUiOptions = function(resume, optionsToolBar) {
  54. DrawBasedOnRectangleSize.prototype.initUiOptions.call(this, resume, optionsToolBar);
  55. var w;
  56. this.createPolyline = RSettings.getBoolValue(this.settingsGroup + "/CreatePolyline", false);
  57. this.fill = RSettings.getBoolValue(this.settingsGroup + "/Fill", false);
  58. this.roundCorners = RSettings.getBoolValue(this.settingsGroup + "/RoundCorners", false);
  59. this.radius = RSettings.getDoubleValue(this.settingsGroup + "/Radius", 1.0);
  60. w = optionsToolBar.findChild("CreatePolyline");
  61. if (!isNull(w)) {
  62. w.checked = this.createPolyline;
  63. }
  64. w = optionsToolBar.findChild("Fill");
  65. if (!isNull(w)) {
  66. w.checked = this.fill;
  67. }
  68. w = optionsToolBar.findChild("RoundCorners");
  69. if (!isNull(w)) {
  70. w.checked = this.roundCorners;
  71. }
  72. w = optionsToolBar.findChild("Radius");
  73. if (!isNull(w)) {
  74. w.setValue(this.radius);
  75. }
  76. };
  77. ShapeRectangleSize.prototype.hideUiOptions = function(saveToSettings) {
  78. DrawBasedOnRectangleSize.prototype.hideUiOptions.call(this, saveToSettings);
  79. RSettings.setValue(this.settingsGroup + "/CreatePolyline", this.createPolyline);
  80. RSettings.setValue(this.settingsGroup + "/Fill", this.fill);
  81. RSettings.setValue(this.settingsGroup + "/RoundCorners", this.roundCorners);
  82. RSettings.setValue(this.settingsGroup + "/Radius", this.radius);
  83. };
  84. ShapeRectangleSize.prototype.getOperation = function(preview) {
  85. var op = DrawBasedOnRectangleSize.prototype.getOperation.call(this, preview);
  86. if (!isNull(op)) {
  87. var shapes = this.getShapes(this.corners);
  88. Shape.complementOperation(this, this.getDocument(), op, shapes);
  89. }
  90. return op;
  91. };