Arc.js 3.1 KB

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