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