Draw.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 Drawing Tools
  21. * \ingroup ecma_scripts
  22. *
  23. * \brief This module contains ECMAScript implementations of the
  24. * various drawing tools.
  25. */
  26. include("scripts/EAction.js");
  27. /**
  28. * \class Draw
  29. * \brief Base class for all drawing tools.
  30. */
  31. function Draw(guiAction) {
  32. EAction.call(this, guiAction);
  33. }
  34. Draw.prototype = new EAction();
  35. Draw.includeBasePath = includeBasePath;
  36. Draw.getMenu = function() {
  37. // var menu = EAction.getMenu(Draw.getTitle(), "DrawMenu");
  38. // menu.setProperty("scriptFile", Draw.includeBasePath + "/Draw.js");
  39. // return menu;
  40. };
  41. Draw.getToolBar = function() {
  42. var tb = EAction.getToolBar(Draw.getTitle(), "DrawToolBar", Qt.TopToolBarArea, Draw.getContextMenuCategory());
  43. tb.visible = false;
  44. return tb;
  45. };
  46. Draw.getCadToolBarPanel = function() {
  47. return EAction.getMainCadToolBarPanel();
  48. };
  49. Draw.getToolMatrixPanel = function() {
  50. return EAction.getToolMatrixPanel(Draw.getTitle(), "DrawMatrixPanel", 2000);
  51. };
  52. Draw.getContextMenuCategory = function() {
  53. return [qsTr("Draw")];
  54. };
  55. Draw.getTitle = function() {
  56. return qsTr("&Draw");
  57. };
  58. Draw.prototype.getTitle = function() {
  59. return Draw.getTitle();
  60. };
  61. Draw.init = function() {
  62. Draw.getMenu();
  63. Draw.getToolBar();
  64. Draw.getCadToolBarPanel();
  65. Draw.getToolMatrixPanel();
  66. // add action for the sake of configurability (tool preferences):
  67. var appWin = EAction.getMainWindow();
  68. var action = new RGuiAction(qsTr("Drawing Tools"), appWin);
  69. action.setScriptFile(Draw.includeBasePath + "/Draw.js");
  70. action.setGroupSortOrder(5);
  71. action.setSortOrder(100);
  72. action.setWidgetNames([]);
  73. };