Hatch.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. /**
  20. * \defgroup ecma_draw_hatch Hatch Drawing Tools
  21. * \ingroup ecma_draw
  22. *
  23. * \brief This module contains ECMAScript implementations of various
  24. * hatch and fill drawing tools.
  25. */
  26. include("scripts/Draw/Draw.js");
  27. /**
  28. * \class Hatch
  29. * \brief Base class for all hatch drawing tools.
  30. * \ingroup ecma_draw_hatch
  31. */
  32. function Hatch(guiAction) {
  33. Draw.call(this, guiAction);
  34. }
  35. Hatch.prototype = new Draw();
  36. Hatch.includeBasePath = includeBasePath;
  37. Hatch.prototype.beginEvent = function() {
  38. Draw.prototype.beginEvent.call(this);
  39. if (!isNull(this.getGuiAction()) && this.getGuiAction().objectName==="HatchToolsPanelAction") {
  40. EAction.showCadToolBarPanel("HatchToolsPanel");
  41. this.terminate();
  42. }
  43. };
  44. Hatch.getMenu = function() {
  45. // var menu = EAction.getSubMenu(
  46. // Draw.getMenu(),
  47. // 20, 900,
  48. // Hatch.getTitle(),
  49. // "DrawHatchMenu",
  50. // Hatch.includeBasePath + "/Hatch.svg"
  51. // );
  52. // menu.setProperty("scriptFile", Hatch.includeBasePath + "/Hatch.js");
  53. // return menu;
  54. };
  55. Hatch.getToolBar = function() {
  56. var tb = EAction.getToolBar(Hatch.getTitle(), "HatchToolBar", Qt.TopToolBarArea, Draw.getContextMenuCategory());
  57. tb.visible = false;
  58. return tb;
  59. };
  60. Hatch.getCadToolBarPanel = function() {
  61. var mtb = Draw.getCadToolBarPanel();
  62. var actionName = "HatchToolsPanelAction";
  63. if (!isNull(mtb) && mtb.findChild(actionName)==undefined) {
  64. var action = new RGuiAction(qsTr("Hatch Tools"), mtb);
  65. action.setScriptFile(Hatch.includeBasePath + "/Hatch.js");
  66. action.objectName = actionName;
  67. action.setRequiresDocument(true);
  68. action.setIcon(Hatch.includeBasePath + "/Hatch.svg");
  69. //action.setStatusTip(qsTr("Show hatch tools"));
  70. action.setDefaultShortcut(new QKeySequence("w,x"));
  71. action.setNoState();
  72. action.setDefaultCommands(["hatchmenu"]);
  73. action.setGroupSortOrder(20);
  74. action.setSortOrder(900);
  75. action.setWidgetNames(["MainToolsPanel"]);
  76. }
  77. var tb = EAction.getCadToolBarPanel(
  78. Hatch.getTitle(),
  79. "HatchToolsPanel",
  80. true
  81. );
  82. return tb;
  83. };
  84. Hatch.getToolMatrixPanel = function() {
  85. return EAction.getToolMatrixPanel(Hatch.getTitle(), "HatchMatrixPanel", 900);
  86. };
  87. Hatch.getTitle = function() {
  88. return qsTr("&Hatch");
  89. };
  90. Hatch.prototype.getTitle = function() {
  91. return Hatch.getTitle();
  92. };
  93. Hatch.init = function() {
  94. Hatch.getMenu();
  95. Hatch.getToolBar();
  96. Hatch.getCadToolBarPanel();
  97. Hatch.getToolMatrixPanel();
  98. };