DXFImport.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  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/Edit/Paste/Paste.js");
  20. include("scripts/EAction.js");
  21. include("scripts/simple.js");
  22. /**
  23. * \class ImportFile
  24. * \brief Inserts a file into the drawing.
  25. * The target point is specified by the user.
  26. * \ingroup ecma_edit
  27. */
  28. function DXFImport(guiAction, fileName) {
  29. Paste.call(this, guiAction);
  30. this.sourceDocument = new RDocument(new RMemoryStorage(), createSpatialIndex());
  31. this.sourceDi = new RDocumentInterface(this.sourceDocument);
  32. this.sourceDi.setNotifyListeners(false);
  33. // unit tests pass file name directly to action:
  34. this.fileName = fileName;
  35. this.blockName = undefined;
  36. this.asBlock = false;
  37. this.newLayerData = new Array();
  38. this.newPointEntityData = new Array();
  39. this.newLineEntityData = new Array();
  40. this.newArcEntityData = new Array();
  41. this.newCircleEntityData = new Array();
  42. this.newPolylineEntityData = new Array();
  43. this.newBlockEntityData = new Array();
  44. this.newTextEntityData = new Array();
  45. this.newScaleData = new Array();
  46. this.ratio = 1.0;
  47. this.LayerNum = 1;
  48. // this.setUiOptions(DXFImport.includeBasePath + "/DXFImport.ui");
  49. }
  50. DXFImport.prototype = new Paste();
  51. DXFImport.includeBasePath = includeBasePath;
  52. DXFImport.prototype.beginEvent = function () {
  53. //Paste.prototype.beginEvent.call(this);
  54. var fileDialogInfo;
  55. if (!isNull(this.fileName)) {
  56. fileDialogInfo = [this.fileName, ""];
  57. }
  58. else {
  59. fileDialogInfo = this.getFileName();
  60. }
  61. // workaround for Qt keyboard focus bug:
  62. var appWin = RMainWindowQt.getMainWindow();
  63. if (!isNull(appWin)) {
  64. appWin.activateWindow();
  65. appWin.raise();
  66. appWin.setFocus(Qt.OtherFocusReason);
  67. }
  68. if (isNull(fileDialogInfo)) {
  69. destr(this.sourceDi);
  70. this.sourceDi = undefined;
  71. this.terminate();
  72. return;
  73. }
  74. // var ok = this.readTxt(fileDialogInfo[0]);
  75. try {
  76. // 只再平面上加载
  77. var di = getAssignDocumentInterface(1); // this.sourceDi; // this.getDocumentInterface();
  78. var file = di.importFile(fileDialogInfo[0], fileDialogInfo[1], false);
  79. di.regenerateScenes();
  80. di.autoZoom();
  81. if (file !== RDocumentInterface.IoErrorNoError) {
  82. EAction.handleUserWarning(qsTr("Error while importing file %1").arg(fileDialogInfo[0]));
  83. if (!isNull(this.sourceDi)) {
  84. destr(this.sourceDi);
  85. this.sourceDi = undefined;
  86. }
  87. this.terminate();
  88. }
  89. //if (this.sourceDi.importFile(fileDialogInfo[0], fileDialogInfo[1], false) !== RDocumentInterface.IoErrorNoError) {
  90. // EAction.handleUserWarning(qsTr("Error while importing file %1").arg(fileDialogInfo[0]));
  91. // if (!isNull(this.sourceDi)) {
  92. // destr(this.sourceDi);
  93. // this.sourceDi = undefined;
  94. // }
  95. // this.terminate();
  96. // return;
  97. //}
  98. var entities = this.sourceDocument.queryAllEntities(false, false, RS.EntityImage);
  99. for (var i = 0; i < entities.length; i++) {
  100. var entityId = entities[i];
  101. if (-1==this.newScaleData.indexOf(entityId)) {
  102. var direct = this.sourceDocument.queryEntityDirect(entityId);
  103. var scale = direct.scale(new RVector(0.001, 0.001), new RVector(0, 0));
  104. this.newScaleData.push(entityId);
  105. }
  106. }
  107. return;
  108. } catch (error) {
  109. EAction.handleUserWarning("error: " + error.toString());
  110. }
  111. };
  112. DXFImport.prototype.finishEvent = function () {
  113. if (!isNull(this.sourceDi)) {
  114. destr(this.sourceDi);
  115. }
  116. Paste.prototype.finishEvent.call(this);
  117. };
  118. DXFImport.prototype.initOperation = function (op) {
  119. if (this.asBlock && !isNull(this.blockName) && this.blockName.length > 0) {
  120. op.setBlockName(this.blockName);
  121. }
  122. // op.setCopyAllLayers(true);
  123. // op.setCopyEmptyBlocks(true);
  124. };
  125. DXFImport.prototype.getFileName = function () {
  126. var appWin = EAction.getMainWindow();
  127. // if(RSettings.getStringValue("OpenProject/Current","") == ""){
  128. // QMessageBox.critical(appWin,
  129. // qsTr("提示"),
  130. // qsTr("请先选择工程路径"));
  131. // return;
  132. // }
  133. var lastOpenFileDir = RSettings.getStringValue("OpenProject/Current", RSettings.getDocumentsLocation());
  134. var filterAll = qsTr("地形文件") + " (*.dxf);";
  135. var fileDialog = new QFileDialog(appWin, qsTr("请选择地形文件"), lastOpenFileDir, "");
  136. fileDialog.setNameFilters([filterAll]);
  137. fileDialog.selectNameFilter(filterAll);
  138. fileDialog.setOption(QFileDialog.DontUseNativeDialog, getDontUseNativeDialog());
  139. if (!isNull(QFileDialog.DontUseCustomDirectoryIcons)) {
  140. fileDialog.setOption(QFileDialog.DontUseCustomDirectoryIcons, true);
  141. }
  142. fileDialog.fileMode = QFileDialog.ExistingFiles;
  143. fileDialog.setLabelText(QFileDialog.FileType, qsTr("Format:"));
  144. if (!fileDialog.exec()) {
  145. destr(fileDialog);
  146. EAction.activateMainWindow();
  147. return undefined;
  148. }
  149. var fileNames = fileDialog.selectedFiles();
  150. if (fileNames.length === 0) {
  151. destr(fileDialog);
  152. EAction.activateMainWindow();
  153. return undefined;
  154. }
  155. var fileName = fileNames[0];
  156. var suffix = new QFileInfo(fileName).suffix();
  157. suffix = suffix.toUpperCase();
  158. var imageFormats = QImageReader.supportedImageFormats();
  159. for (var i = 0; i < imageFormats.length; i++) {
  160. var format = imageFormats[i];
  161. if (suffix === format.toString().toUpperCase()) {
  162. include("scripts/Draw/Image/Image.js");
  163. var imageAction = new Image();
  164. imageAction.fileName = fileName;
  165. this.getDocumentInterface(0).queueAction(imageAction);
  166. this.terminate();
  167. return;
  168. }
  169. }
  170. var nameFilter = fileDialog.selectedNameFilter();
  171. destr(fileDialog);
  172. EAction.activateMainWindow();
  173. //this.blockName = new QFileInfo(fileNames[0]).baseName();
  174. //RSettings.setValue("ImportFile/BlockName", new QFileInfo(fileNames[0]).baseName());
  175. var optionsToolBar = EAction.getOptionsToolBar();
  176. if (!isNull(optionsToolBar)) {
  177. var leBlockName = optionsToolBar.findChild("BlockName");
  178. if (!isNull(leBlockName)) {
  179. var blockName = new QFileInfo(fileNames[0]).completeBaseName();
  180. blockName = RDxfServices.getSafeBlockName(blockName);
  181. leBlockName.text = blockName;
  182. }
  183. }
  184. return [fileNames[0], nameFilter];
  185. };
  186. DXFImport.prototype.slotAsBlockChanged = function (value) {
  187. this.asBlock = value;
  188. this.updatePreview(true);
  189. };
  190. DXFImport.prototype.slotBlockNameChanged = function (value) {
  191. this.blockName = value;
  192. this.updatePreview(true);
  193. };
  194. DXFImport.prototype.readTxt = function (file) {
  195. var reader = new QFile(file);
  196. var flags = makeQIODeviceOpenMode(QIODevice.ReadOnly, QIODevice.Text);
  197. if (!reader.open(flags)) {
  198. EAction.handleUserWarning("cannot open file: " + file);
  199. return false;
  200. }
  201. var pLineNo = 0;
  202. //每次都去文件中的一行,然后输出读取到的字符串lyz
  203. var ts = new QTextStream(reader);
  204. setUtf8Codec(ts);
  205. do {
  206. var code = ts.readLine().trim();
  207. var value = ts.readLine().trim();
  208. //var textLine = ts.readLine().trim();
  209. // EAction.handleUserWarning(textLine);
  210. code = code.replace(/[\t]+/g, " ").replace(/[\s]+/g, " ");
  211. code = code.replace(/\r\n/g, "");
  212. value = value.replace(/[\t]+/g, " ").replace(/[\s]+/g, " ");
  213. value = value.replace(/\r\n/g, "");
  214. // EAction.handleUserMessage(textLine2);
  215. // var code = parseInt(textLine.substring(0, 3));
  216. // var value = textLine.substring(3).trim();
  217. //读取图层数据 liyz
  218. if (code == '2' && value == 'LAYER') {
  219. //EAction.handleUserWarning('Layer Info...............................');
  220. var LayerName = '';
  221. var LayerColor = '';
  222. var LayerLineType = '';
  223. var LayerLineWidth = '';
  224. do {
  225. code = ts.readLine().trim();
  226. value = ts.readLine().trim();
  227. code = code.replace(/[\t]+/g, " ").replace(/[\s]+/g, " ");
  228. code = code.replace(/\r\n/g, "");
  229. value = value.replace(/[\t]+/g, " ").replace(/[\s]+/g, " ");
  230. value = value.replace(/\r\n/g, "");
  231. if (code == '2') {
  232. LayerName = value;
  233. }
  234. else if (code == '62') {
  235. LayerColor = value;
  236. }
  237. else if (code == '6') {
  238. LayerLineType = value;
  239. }
  240. else if (code == '370') {
  241. LayerLineWidth = value;
  242. this.newLayerData.push([LayerName, LayerColor, LayerLineType, LayerLineWidth]);
  243. // EAction.handleUserWarning(LayerName + ', ' + LayerColor + ', ' + LayerLineType+ ', ' +LayerLineWidth);
  244. }
  245. } while (!ts.atEnd() && value != 'ENDTAB' && value != 'ENDSEC' && value != 'EOF');
  246. }
  247. //读取点数据 liyz
  248. if (code == '0' && value == 'POINT') {
  249. //EAction.handleUserWarning('Point Info...............................');
  250. var POINT_X = '';
  251. var POINT_Y = '';
  252. var POINT_Layer = '';
  253. do {
  254. code = ts.readLine().trim();
  255. value = ts.readLine().trim();
  256. code = code.replace(/[\t]+/g, " ").replace(/[\s]+/g, " ");
  257. code = code.replace(/\r\n/g, "");
  258. value = value.replace(/[\t]+/g, " ").replace(/[\s]+/g, " ");
  259. value = value.replace(/\r\n/g, "");
  260. if (code == '8') {
  261. POINT_Layer = value;
  262. }
  263. else if (code == '10') {
  264. POINT_X = value;
  265. }
  266. else if (code == '20') {
  267. POINT_Y = value;
  268. this.newPointEntityData.push([parseFloat(POINT_X), parseFloat(POINT_Y), POINT_Layer]);
  269. // EAction.handleUserWarning(POINT_X + ', ' + POINT_Y + ', ' + POINT_Layer);
  270. break;
  271. }
  272. } while (!ts.atEnd() && code != '0' && value != 'ENDSEC' && value != 'EOF');
  273. }
  274. //读取线数据 liyz
  275. if (code == '0' && value == 'LINE') {
  276. // EAction.handleUserWarning('Line Info...............................');
  277. var StartPOINT_X = '';
  278. var StartPOINT_Y = '';
  279. var EndPOINT_X = '';
  280. var EndPOINT_Y = '';
  281. var Line_Layer = '';
  282. do {
  283. code = ts.readLine().trim();
  284. value = ts.readLine().trim();
  285. code = code.replace(/[\t]+/g, " ").replace(/[\s]+/g, " ");
  286. code = code.replace(/\r\n/g, "");
  287. value = value.replace(/[\t]+/g, " ").replace(/[\s]+/g, " ");
  288. value = value.replace(/\r\n/g, "");
  289. //EAction.handleUserMessage(code);
  290. //EAction.handleUserMessage(value);
  291. if (code == '8') {
  292. Line_Layer = value;
  293. }
  294. else if (code == '10') {
  295. StartPOINT_X = value;
  296. }
  297. else if (code == '20') {
  298. StartPOINT_Y = value;
  299. }
  300. else if (code == '11') {
  301. EndPOINT_X = value;
  302. }
  303. else if (code == '21') {
  304. EndPOINT_Y = value;
  305. this.newLineEntityData.push([parseFloat(StartPOINT_X), parseFloat(StartPOINT_Y), parseFloat(EndPOINT_X), parseFloat(EndPOINT_Y), Line_Layer]);
  306. //EAction.handleUserWarning(StartPOINT_X + ', ' + StartPOINT_Y + ', ' + EndPOINT_X + ', ' + EndPOINT_Y + ', ' + Line_Layer);
  307. break;
  308. }
  309. } while (!ts.atEnd() && code != '0' && value != 'ENDSEC' && value != 'EOF');
  310. }
  311. //读取圆数据 liyz
  312. if (code == '0' && value == 'CIRCLE') {
  313. // EAction.handleUserWarning('Circle Info...............................');
  314. var CirclePOINT_X = '';
  315. var CirclePOINT_Y = '';
  316. var Circle_R = '';
  317. var Circle_Layer = '';
  318. do {
  319. code = ts.readLine().trim();
  320. value = ts.readLine().trim();
  321. code = code.replace(/[\t]+/g, " ").replace(/[\s]+/g, " ");
  322. code = code.replace(/\r\n/g, "");
  323. value = value.replace(/[\t]+/g, " ").replace(/[\s]+/g, " ");
  324. value = value.replace(/\r\n/g, "");
  325. //EAction.handleUserMessage(code);
  326. //EAction.handleUserMessage(value);
  327. if (code == '8') {
  328. Circle_Layer = value;
  329. }
  330. else if (code == '10') {
  331. CirclePOINT_X = value;
  332. }
  333. else if (code == '20') {
  334. CirclePOINT_Y = value;
  335. }
  336. else if (code == '40') {
  337. Circle_R = value;
  338. this.newCircleEntityData.push([parseFloat(CirclePOINT_X), parseFloat(CirclePOINT_Y), parseFloat(Circle_R), Circle_Layer]);
  339. //EAction.handleUserWarning(CirclePOINT_X + ', ' + CirclePOINT_Y + ', ' + Circle_R + ', ' + Circle_Layer);
  340. break;
  341. }
  342. } while (!ts.atEnd() && code != '0' && value != 'ENDSEC' && value != 'EOF');
  343. }
  344. //读取弧数据 liyz
  345. if (code == '0' && value == 'ARC') {
  346. // EAction.handleUserWarning('Arc Info...............................');
  347. var ArcPOINT_X = '';
  348. var ArcPOINT_Y = '';
  349. var Arc_R = '';
  350. var Arc_StartAngle = '';
  351. var Arc_EndAngle = '';
  352. var Arc_Layer = '';
  353. do {
  354. code = ts.readLine().trim();
  355. value = ts.readLine().trim();
  356. code = code.replace(/[\t]+/g, " ").replace(/[\s]+/g, " ");
  357. code = code.replace(/\r\n/g, "");
  358. value = value.replace(/[\t]+/g, " ").replace(/[\s]+/g, " ");
  359. value = value.replace(/\r\n/g, "");
  360. //EAction.handleUserMessage(code);
  361. //EAction.handleUserMessage(value);
  362. if (code == '8') {
  363. Arc_Layer = value;
  364. }
  365. else if (code == '10') {
  366. ArcPOINT_X = value;
  367. }
  368. else if (code == '20') {
  369. ArcPOINT_Y = value;
  370. }
  371. else if (code == '40') {
  372. Arc_R = value;
  373. }
  374. else if (code == '50') {
  375. Arc_StartAngle = value;
  376. }
  377. else if (code == '51') {
  378. Arc_EndAngle = value;
  379. this.newArcEntityData.push([parseFloat(ArcPOINT_X), parseFloat(ArcPOINT_Y), parseFloat(Arc_R), parseFloat(Arc_StartAngle), parseFloat(Arc_EndAngle), Arc_Layer]);
  380. //EAction.handleUserWarning(ArcPOINT_X + ', ' + ArcPOINT_Y + ', ' + Arc_R + ', ' + Arc_StartAngle + ', ' + Arc_EndAngle + ', ' + Arc_Layer);
  381. break;
  382. }
  383. } while (!ts.atEnd() && code != '0' && value != 'ENDSEC' && value != 'EOF');
  384. }
  385. //读取多线段数据 liyz
  386. if (code == '0' && value == 'LWPOLYLINE') {
  387. // EAction.handleUserWarning('Polyline Info...............................');
  388. var PolyPOINT_X = '';
  389. var PolyPOINT_Y = '';
  390. var PolyPOINT_Num = 0;
  391. var Poly_Layer = '';
  392. var TempPolyLineData = new Array();
  393. do {
  394. code = ts.readLine().trim();
  395. value = ts.readLine().trim();
  396. code = code.replace(/[\t]+/g, " ").replace(/[\s]+/g, " ");
  397. code = code.replace(/\r\n/g, "");
  398. value = value.replace(/[\t]+/g, " ").replace(/[\s]+/g, " ");
  399. value = value.replace(/\r\n/g, "");
  400. //EAction.handleUserWarning(code);
  401. //EAction.handleUserWarning(value);
  402. if (code == '8') {
  403. Poly_Layer = value;
  404. }
  405. else if (code == '90') {
  406. PolyPOINT_Num = parseInt(value);
  407. //EAction.handleUserWarning(PolyPOINT_Num.toString());
  408. }
  409. else if (code == '10') {
  410. PolyPOINT_X = value;
  411. }
  412. else if (code == '20') {
  413. PolyPOINT_Y = value;
  414. TempPolyLineData.push([parseFloat(PolyPOINT_X), parseFloat(PolyPOINT_Y)]);
  415. }
  416. if (TempPolyLineData.length == PolyPOINT_Num && PolyPOINT_Num > 0) {
  417. this.newPolylineEntityData.push([TempPolyLineData, Poly_Layer]);
  418. // EAction.handleUserWarning(TempPolyLineData.toString());
  419. break;
  420. }
  421. } while (!ts.atEnd() && code != '0' && value != 'ENDSEC' && value != 'EOF');
  422. }
  423. //读取块数据 liyz
  424. if (code == '0' && value == 'BLOCK') {
  425. // EAction.handleUserWarning('Block Info...............................');
  426. var BlockName = '';
  427. var Block_X = '';
  428. var Block_Y = '';
  429. var BlockLayer = '';
  430. do {
  431. code = ts.readLine().trim();
  432. value = ts.readLine().trim();
  433. code = code.replace(/[\t]+/g, " ").replace(/[\s]+/g, " ");
  434. code = code.replace(/\r\n/g, "");
  435. value = value.replace(/[\t]+/g, " ").replace(/[\s]+/g, " ");
  436. value = value.replace(/\r\n/g, "");
  437. if (code == '8') {
  438. BlockLayer = value;
  439. }
  440. else if (code == '2') {
  441. BlockName = value;
  442. }
  443. else if (code == '10') {
  444. Block_X = value;
  445. }
  446. else if (code == '20') {
  447. Block_Y = value;
  448. this.newBlockEntityData.push([BlockName, parseFloat(Block_X), parseFloat(Block_Y), BlockLayer]);
  449. //EAction.handleUserWarning(BlockName + ', ' + Block_X + ', ' + Block_Y+ ', ' +BlockLayer);
  450. }
  451. } while (!ts.atEnd() && value != 'ENDBLK' && value != 'ENDSEC' && value != 'EOF');
  452. }
  453. //读文本数据 liyz
  454. if (code == '0' && value == 'TEXT') {
  455. EAction.handleUserWarning('TEXT Info...............................');
  456. var TextName = '';
  457. var Text_X = '';
  458. var Text_Y = '';
  459. var Text_Hight = 0.0;
  460. // var Text_angle = 0.0;
  461. //var Text_font = '';
  462. var TextLayer = '';
  463. do {
  464. code = ts.readLine().trim();
  465. value = ts.readLine().trim();
  466. code = code.replace(/[\t]+/g, " ").replace(/[\s]+/g, " ");
  467. code = code.replace(/\r\n/g, "");
  468. value = value.replace(/[\t]+/g, " ").replace(/[\s]+/g, " ");
  469. value = value.replace(/\r\n/g, "");
  470. if (code == '8') {
  471. TextLayer = value;
  472. }
  473. else if (code == '10') {
  474. Text_X = value;
  475. }
  476. else if (code == '20') {
  477. Text_Y = value;
  478. }
  479. else if (code == '40') {
  480. Text_Hight = value;
  481. }
  482. else if (code == '1') {
  483. TextName = value;
  484. this.newTextEntityData.push([TextName, parseFloat(Text_X), parseFloat(Text_Y), parseFloat(Text_Hight), TextLayer]);
  485. EAction.handleUserWarning(TextName + ', ' + Text_X + ', ' + Text_Y + ', ' + Text_Hight + ', ' + TextLayer);
  486. break;
  487. }
  488. } while (!ts.atEnd() && value != 'ENDBLK' && value != 'ENDSEC' && value != 'EOF');
  489. }
  490. pLineNo++;
  491. }
  492. while (!ts.atEnd());
  493. //EAction.handleUserMessage(this.newLayerData.toString());
  494. //EAction.handleUserMessage(this.newPointEntityData.toString());
  495. //EAction.handleUserMessage(this.newLineEntityData.toString());
  496. //EAction.handleUserMessage(this.newCircleEntityData.toString());
  497. //EAction.handleUserMessage(this.newArcEntityData.toString());
  498. this.applyOperation();
  499. reader.close();
  500. return true;
  501. }
  502. DXFImport.prototype.applyOperation = function (preview) {
  503. var LineColor = new RColor(105, 105, 105);
  504. var PointColor = new RColor(255, 0, 0);
  505. var CircleColor = new RColor(255, 255, 255);
  506. var ArcColor = new RColor(0, 255, 0);
  507. //添加图层 liyz
  508. for (var i = 0; i < this.newLayerData.length; i++) {
  509. addLayerToView(this.newLayerData[i][0], null/*this.newLayerData[i][1]*/, this.newLayerData[i][2], parseInt(this.newLayerData[i][3]), 1);
  510. //addLayerToView(this.newLayerData[i][0], null, null, null, 0);
  511. }
  512. //绘制点 liyz
  513. for (var i = 0; i < this.newPointEntityData.length; i++) {
  514. addPointToView(this.newPointEntityData[i][0], this.newPointEntityData[i][1], 1);
  515. }
  516. //绘制线 liyz
  517. for (var i = 0; i < this.newLineEntityData.length; i++) {
  518. addLineToView(this.newLineEntityData[i][0], this.newLineEntityData[i][1], this.newLineEntityData[i][2], this.newLineEntityData[i][3], 1);
  519. }
  520. //绘制多线段 liyz
  521. for (var i = 0; i < this.newPolylineEntityData.length; i++) {
  522. addPolylinetoView(this.newPolylineEntityData[i][0], false, false, 1, LineColor);
  523. }
  524. //绘制圆 liyz
  525. for (var i = 0; i < this.newCircleEntityData.length; i++) {
  526. addCircleToView(this.newCircleEntityData[i][0], this.newCircleEntityData[i][1], this.newCircleEntityData[i][2], 1, CircleColor);
  527. }
  528. //绘制弧 liyz
  529. for (var i = 0; i < this.newArcEntityData.length; i++) {
  530. addArctoView(this.newArcEntityData[i][0], this.newArcEntityData[i][1], this.newArcEntityData[i][2],
  531. this.newArcEntityData[i][3], this.newArcEntityData[i][4], false, 1, ArcColor);
  532. }
  533. //绘制文字 liyz
  534. for (var i = 0; i < this.newTextEntityData.length; i++) {
  535. addSimpleTextToView(this.newTextEntityData[i][0], this.newTextEntityData[i][1], this.newTextEntityData[i][2],
  536. this.newTextEntityData[i][3], null, null, null, null, null, null, 1);
  537. }
  538. var di = getAssignDocumentInterface(1);
  539. if (!isNull(di)) {
  540. // di.regenerateScenes();
  541. di.autoZoom();
  542. }
  543. return true;
  544. }