Zoom.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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_view_zoom Zoom Tools
  21. * \ingroup ecma_scripts
  22. *
  23. * \brief This module contains ECMAScript implementations of various
  24. * zoom tools.
  25. */
  26. include("scripts/EAction.js");
  27. /**
  28. * \class Zoom
  29. * \brief Base class for all zoom tools.
  30. * \ingroup ecma_view_zoom
  31. */
  32. function Zoom(guiAction) {
  33. EAction.call(this, guiAction);
  34. }
  35. Zoom.prototype = new EAction();
  36. Zoom.includeBasePath = includeBasePath;
  37. Zoom.prototype.beginEvent = function() {
  38. EAction.prototype.beginEvent.call(this);
  39. if (!isNull(this.getGuiAction()) && this.getGuiAction().objectName==="ZoomToolsPanelAction") {
  40. EAction.showCadToolBarPanel("ZoomToolsPanel");
  41. this.terminate();
  42. }
  43. };
  44. Zoom.getMenu = function() {
  45. var menu = EAction.getSubMenu(View.getMenu(), 3300, 100, qsTr("Zoom"), "ZoomMenu");
  46. menu.setProperty("scriptFile", Zoom.includeBasePath + "/Zoom.js");
  47. return menu;
  48. };
  49. Zoom.getToolBar = function() {
  50. //return EAction.getToolBar(Zoom.getTitle(), "ViewToolBar", undefined, undefined, View.getToolBar());
  51. return View.getToolBar();
  52. };
  53. Zoom.getCadToolBarPanel = function() {
  54. var mtb = EAction.getMainCadToolBarPanel();
  55. var actionName = "ZoomToolsPanelAction";
  56. if (!isNull(mtb) && mtb.findChild(actionName)==undefined) {
  57. var action = new RGuiAction(qsTr("Zoom Tools"), mtb);
  58. action.setScriptFile(Zoom.includeBasePath + "/Zoom.js");
  59. action.objectName = actionName;
  60. action.setRequiresDocument(false);
  61. action.setIcon(Zoom.includeBasePath + "/Zoom.svg");
  62. //action.setStatusTip(qsTr("Show zoom tools"));
  63. action.setDefaultShortcut(new QKeySequence("w,z"));
  64. action.setNoState();
  65. action.setDefaultCommands(["zoommenu"]);
  66. action.setGroupSortOrder(10);
  67. action.setSortOrder(350);
  68. action.setWidgetNames(["!MainToolsPanel"]);
  69. }
  70. var tb = EAction.getCadToolBarPanel(
  71. Zoom.getTitle(),
  72. "ZoomToolsPanel",
  73. true
  74. );
  75. return tb;
  76. };
  77. Zoom.getToolMatrixPanel = function() {
  78. RSettings.setValue("Zoom/VisibleInMatrixPanel", false, false);
  79. return EAction.getToolMatrixPanel(Zoom.getTitle(), "ZoomMatrixPanel", 30);
  80. };
  81. Zoom.getTitle = function() {
  82. return qsTr("&Zoom");
  83. };
  84. Zoom.prototype.getTitle = function() {
  85. return Zoom.getTitle();
  86. };
  87. Zoom.init = function() {
  88. Zoom.getMenu();
  89. Zoom.getToolBar();
  90. Zoom.getCadToolBarPanel();
  91. Zoom.getToolMatrixPanel();
  92. };