CloseProject.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. include("scripts/library.js");
  20. include("scripts/File/File.js");
  21. include("scripts/Layer/Layer.js");
  22. /**
  23. * \class NewFile
  24. * \brief Creates a new document.
  25. * \ingroup ecma_file
  26. */
  27. function CloseProject(guiAction) {
  28. File.call(this, guiAction);
  29. }
  30. CloseProject.prototype = new File();
  31. CloseProject.includeBasePath = includeBasePath;
  32. /**
  33. * \param isOpen True if new is called from a file open function.
  34. */
  35. CloseProject.prototype.beginEvent = function () {
  36. var appWin = EAction.getMainWindow();
  37. var prjName = RSettings.getStringValue("OpenProject/Current", "");
  38. RSettings.setValue("OpenProject/Current", "");
  39. QMessageBox.information(appWin, qsTr("提示"), qsTr("已关闭工程:" + prjName));
  40. RSettings.setValue("OpenDisplayFile/PMFile", "");
  41. RSettings.setValue("OpenDisplayFile/ZDMFile", "");
  42. // 删除全部的PM
  43. var di1 = getAssignDocumentInterface(1);
  44. var document1 = getAssignDocument(1);
  45. var ids = document1.queryAllEntities();
  46. var op = new RDeleteObjectsOperation();
  47. for (i = 0; i < ids.length; i++) {
  48. var id = ids[i];
  49. op.deleteObject(document1.queryEntity(id));
  50. }
  51. di1.applyOperation(op);
  52. di1.clearPreview();
  53. di1.repaintViews();
  54. // 删除图层
  55. // Layer.removeAll(di1);
  56. // 删除全部的ZDM
  57. var di0 = getAssignDocumentInterface(0);
  58. var document0 = getAssignDocument(0);
  59. var ids0 = document0.queryAllEntities();
  60. var op0 = new RDeleteObjectsOperation();
  61. for (i = 0; i < ids0.length; i++) {
  62. var id = ids0[i];
  63. op0.deleteObject(document0.queryEntity(id));
  64. }
  65. di0.applyOperation(op0);
  66. di0.clearPreview();
  67. di0.repaintViews();
  68. // 删除图层
  69. // Layer.removeAll(di0);
  70. return;
  71. };