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