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