Projection.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  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_projection Projection Tools
  21. * \ingroup ecma_modify
  22. *
  23. * \brief This module contains ECMAScript implementations of various projection (isometric, orthographic) tools.
  24. */
  25. include("scripts/Modify/Explode/Explode.js");
  26. include("scripts/Modify/Transform.js");
  27. include("scripts/ShapeAlgorithms.js");
  28. /**
  29. * \class Projection
  30. * \brief Base class for all projection tools.
  31. * \ingroup ecma_projection
  32. */
  33. function Projection(guiAction) {
  34. Transform.call(this, guiAction);
  35. this.rotation = 0.0;
  36. this.copies = 1;
  37. this.referencePoint = undefined;
  38. this.targetPoint = undefined;
  39. // inheriting classes set this to true if projected entities have to be
  40. // segmented into line segments:
  41. this.segmentation = false;
  42. this.segmentLength = 1.0;
  43. this.retainTexts = false;
  44. // force flat projection (for aux constructions):
  45. this.flat = false;
  46. }
  47. Projection.prototype = new Transform();
  48. Projection.includeBasePath = includeBasePath;
  49. Projection.State = {
  50. SettingReferencePoint : 0,
  51. SettingTargetPoint : 1
  52. };
  53. Projection.getMenu = function() {
  54. // var menu = EAction.getSubMenu(
  55. // Modify.getMenu(),
  56. // 14800, 100,
  57. // Projection.getTitle(),
  58. // "ModifyProjectionMenu",
  59. // Projection.includeBasePath + "/Projection.svg"
  60. // );
  61. // menu.setProperty("scriptFile", Projection.includeBasePath + "/Projection.js");
  62. // return menu;
  63. };
  64. Projection.getToolBar = function() {
  65. var tb = EAction.getToolBar(Projection.getTitle(), "ProjectionToolBar");
  66. tb.visible = false;
  67. return tb;
  68. };
  69. Projection.getCadToolBarPanel = function() {
  70. var mtb = Draw.getCadToolBarPanel();
  71. var actionName = "ProjectionToolsPanelAction";
  72. if (!isNull(mtb) && isNull(mtb.findChild(actionName))) {
  73. var action = new RGuiAction(qsTr("Projection Tools"), mtb);
  74. action.setScriptFile(Projection.includeBasePath + "/Projection.js");
  75. action.objectName = actionName;
  76. action.setRequiresDocument(true);
  77. action.setIcon(Projection.includeBasePath + "/Projection.svg");
  78. //action.setStatusTip(qsTr("Show projection tools"));
  79. action.setDefaultShortcut(new QKeySequence("w,j"));
  80. action.setNoState();
  81. action.setDefaultCommands(["projectmenu"]);
  82. action.setGroupSortOrder(50);
  83. action.setSortOrder(100);
  84. action.setWidgetNames(["MainToolsPanel"]);
  85. }
  86. var tb = EAction.getCadToolBarPanel(Projection.getTitle(), "ProjectionToolsPanel", true);
  87. return tb;
  88. };
  89. Projection.getToolMatrixPanel = function() {
  90. return EAction.getToolMatrixPanel(Projection.getTitle(), "ProjectionMatrixPanel", 3500);
  91. };
  92. Projection.getTitle = function() {
  93. return qsTr("&Projection");
  94. };
  95. Projection.prototype.getTitle = function() {
  96. return Projection.getTitle();
  97. };
  98. Projection.prototype.beginEvent = function() {
  99. Transform.prototype.beginEvent.call(this);
  100. // show projection tools panel:
  101. if (!isNull(this.getGuiAction()) && this.getGuiAction().objectName==="ProjectionToolsPanelAction") {
  102. EAction.showCadToolBarPanel("ProjectionToolsPanel");
  103. this.terminate();
  104. return;
  105. }
  106. // start tool:
  107. if (!this.verifySelection()) {
  108. this.terminate();
  109. return;
  110. }
  111. this.setState(Projection.State.SettingReferencePoint);
  112. };
  113. Projection.prototype.setState = function(state) {
  114. Transform.prototype.setState.call(this, state);
  115. this.getDocumentInterface().setClickMode(RAction.PickCoordinate);
  116. this.setCrosshairCursor();
  117. var appWin = RMainWindowQt.getMainWindow();
  118. switch (this.state) {
  119. case Projection.State.SettingReferencePoint:
  120. this.referencePoint = undefined;
  121. this.targetPoint = undefined;
  122. var trReferencePoint = qsTr("Reference point");
  123. this.setCommandPrompt(trReferencePoint);
  124. this.setLeftMouseTip(trReferencePoint);
  125. this.setRightMouseTip(EAction.trCancel);
  126. break;
  127. case Projection.State.SettingTargetPoint:
  128. this.targetPoint = undefined;
  129. var trTargetPoint = qsTr("Target point");
  130. this.setCommandPrompt(trTargetPoint);
  131. this.setLeftMouseTip(trTargetPoint);
  132. this.setRightMouseTip(EAction.trBack);
  133. break;
  134. }
  135. EAction.showSnapTools();
  136. };
  137. Projection.prototype.escapeEvent = function() {
  138. switch (this.state) {
  139. case Projection.State.SettingReferencePoint:
  140. Transform.prototype.escapeEvent.call(this);
  141. break;
  142. case Projection.State.SettingTargetPoint:
  143. this.setState(Projection.State.SettingReferencePoint);
  144. break;
  145. }
  146. };
  147. Projection.prototype.pickCoordinate = function(event, preview) {
  148. var di = this.getDocumentInterface();
  149. switch (this.state) {
  150. case Projection.State.SettingReferencePoint:
  151. this.referencePoint = event.getModelPosition();
  152. this.clearCache();
  153. if (preview) {
  154. this.updatePreview();
  155. }
  156. else {
  157. di.setRelativeZero(this.referencePoint);
  158. this.setState(Projection.State.SettingTargetPoint);
  159. }
  160. break;
  161. case Projection.State.SettingTargetPoint:
  162. this.targetPoint = event.getModelPosition();
  163. if (preview) {
  164. this.updatePreview();
  165. }
  166. else {
  167. var op = this.getOperation(false);
  168. if (!isNull(op)) {
  169. di.applyOperation(op);
  170. }
  171. di.setRelativeZero(this.targetPoint);
  172. }
  173. break;
  174. }
  175. };
  176. Projection.prototype.getOperation = function(preview) {
  177. if (this.state===Projection.State.SettingReferencePoint) {
  178. return undefined;
  179. }
  180. if (isNull(this.referencePoint) || isNull(this.targetPoint)) {
  181. return undefined;
  182. }
  183. return Transform.prototype.getOperation.call(this, preview, false, true);
  184. };
  185. Projection.prototype.preTransform = function(entity) {
  186. // move original entity to neutral position:
  187. entity.move(this.referencePoint.getNegated());
  188. // rotate entity:
  189. entity.rotate(RMath.deg2rad(this.rotation));
  190. };
  191. Projection.prototype.postTransform = function(entity) {
  192. };
  193. /**
  194. * Callback function for Transform.getOperation. Generic for all projections.
  195. * \param k Ignored
  196. * \param rec Recursive call (don't call preTransform to move / rotate)
  197. */
  198. Projection.prototype.transform = function(entity, k, op, preview, flags, rec) {
  199. if (isNull(rec)) {
  200. rec = false;
  201. }
  202. var i, shapes;
  203. if (rec!==true) {
  204. this.preTransform(entity);
  205. }
  206. var explode = false;
  207. if (this.retainTexts && isTextBasedEntity(entity)) {
  208. if (isAttributeEntity(entity)) {
  209. explode = true;
  210. }
  211. else {
  212. // don't explode text, only project position:
  213. var e = entity.clone();
  214. e.setSelected(false);
  215. var p = e.getAlignmentPoint();
  216. var ph = p.operator_add(new RVector(0,e.getTextHeight()));
  217. //qDebug("p before:", p);
  218. //qDebug("ph before:", ph);
  219. //qDebug("ap:", e.getAlignmentPoint());
  220. this.project(p);
  221. this.project(ph);
  222. // project height:
  223. //qDebug("p after:", p);
  224. //qDebug("ph after:", ph);
  225. //e.setPosition(p);
  226. e.setAlignmentPoint(p);
  227. e.setTextHeight(p.getDistanceTo(ph));
  228. flags = flags | RAddObjectsOperation.UseAttributes;
  229. op.addObject(e, flags);
  230. return;
  231. }
  232. }
  233. // explode block reference to keep attributes (colors, etc.):
  234. if (isBlockReferenceEntity(entity)) {
  235. explode = true;
  236. }
  237. if (explode) {
  238. // explode attributes to texts
  239. // explode block reference
  240. var explodedEntities = Explode.explodeEntity(entity);
  241. if (!isNull(explodedEntities)) {
  242. for (i=0; i<explodedEntities.length; i++) {
  243. var explodedEntity = explodedEntities[i];
  244. if (isEntity(explodedEntity)) {
  245. this.transform(explodedEntity, k, op, preview, flags, true);
  246. }
  247. else {
  248. qWarning("shape in exploded block");
  249. }
  250. }
  251. }
  252. return;
  253. }
  254. shapes = entity.getShapes();
  255. this.addTransformedShapes(entity, shapes, op, preview, flags);
  256. // text data that is part of this entity (dimension label):
  257. if (isDimensionEntity(entity) && isFunction(entity.getTextData)) {
  258. var textData = entity.getTextData();
  259. var painterPaths = textData.getPainterPaths(false);
  260. for (i=0; i<painterPaths.length; i++) {
  261. if (painterPaths[i].getFeatureSize()<0.0) {
  262. continue;
  263. }
  264. shapes = painterPaths[i].getShapes();
  265. this.addTransformedShapes(entity, shapes, op, preview, flags);
  266. }
  267. }
  268. };
  269. /**
  270. * Adds the projected shapes of the given entity to the given operation.
  271. *
  272. * \param entity REntity Original (unprojected) entity (used to copy attributes
  273. * to new shapes).
  274. * \param shapes Array The transformed shapes
  275. * \param op RAddObjectsOperation Operation
  276. */
  277. Projection.prototype.addTransformedShapes = function(entity, shapes, op, preview, flags) {
  278. var i, s, n;
  279. if (isHatchEntity(entity) && entity.isSolid()) {
  280. var hd = entity.getData();
  281. hd.clearBoundary();
  282. hd.newLoop();
  283. for (i=0; i<shapes.length; i++) {
  284. s = this.projectShape(getPtr(shapes[i]), preview);
  285. for (n=0; n<s.length; n++) {
  286. if (isNull(s[n])) {
  287. debugger;
  288. }
  289. if (isPolylineShape(s[n])) {
  290. s[n].simplify(0.001);
  291. }
  292. if (RSettings.getQtVersion() >= 0x060000) {
  293. hd.addBoundary(s[n].clone(), true);
  294. }
  295. else {
  296. hd.addBoundary(s[n], true);
  297. }
  298. }
  299. }
  300. var e = entity.clone();
  301. e.setData(hd);
  302. e.setSelected(false);
  303. // for (i=0; i<hd.getLoopCount(); i++) {
  304. // s = hd.getLoopBoundary(i);
  305. // qDebug("hatch boundary:", s);
  306. // }
  307. //e.getData().getDocument().getStorage().setObjectId(e, RObject.INVALID_ID);
  308. flags = flags | RAddObjectsOperation.UseAttributes | RAddObjectsOperation.ForceNew;
  309. //flags = flags | RAddObjectsOperation.UseAttributes;
  310. op.addObject(e, flags);
  311. return;
  312. }
  313. for (i=0; i<shapes.length; i++) {
  314. if (isNull(shapes[i])) {
  315. continue;
  316. }
  317. s = this.projectShape(getPtr(shapes[i]), preview);
  318. for (n=0; n<s.length; n++) {
  319. if (isNull(s[n])) {
  320. debugger;
  321. }
  322. var e = shapeToEntity(entity.getDocument(), s[n]);
  323. if (isNull(e)) {
  324. continue;
  325. }
  326. e.copyAttributesFrom(entity);
  327. //e.move(this.targetPoint);
  328. flags = flags | RAddObjectsOperation.UseAttributes;
  329. op.addObject(e, flags);
  330. }
  331. }
  332. };
  333. /**
  334. * Reimplemented by inheriting classes to trim the given unprojected shape
  335. * to the projectable area.
  336. *
  337. * Default implementation returns the original shape (no trimming).
  338. *
  339. * \param shape RShape Shape to trim (normalized).
  340. */
  341. Projection.prototype.trimShape = function(shape) {
  342. return [shape];
  343. };
  344. /**
  345. * Reimplemented by inheriting classes.
  346. *
  347. * Default implementation does nothing (no projection).
  348. *
  349. * \param p Vector to transform in normalized coordinates, relative to the
  350. * chosen reference point.
  351. */
  352. Projection.prototype.project = function(p) {
  353. return;
  354. }
  355. /**
  356. * Can be reimplemented to return true if the transformation flips
  357. * entities (mirroring). This means that arcs have to be reversed.
  358. */
  359. Projection.prototype.isFlip = function() {
  360. return false;
  361. }
  362. /**
  363. * Projection of the given shape. The shape uses coordinates relative to
  364. * the chosen reference point.
  365. *
  366. * \return Array of new projected shapes.
  367. */
  368. Projection.prototype.projectShape = function(shape, preview, trim, rec) {
  369. var p, p2, i, k, s, ret;
  370. if (isNull(trim)) {
  371. trim = true;
  372. }
  373. if (isNull(rec)) {
  374. rec = false;
  375. }
  376. // trim shape and project resulting segments:
  377. if (trim===true && (isPointShape(shape) || isLineShape(shape) || isArcShape(shape))) {
  378. var trimmedShapes = this.trimShape(shape);
  379. ret = [];
  380. for (k=0; k<trimmedShapes.length; k++) {
  381. shape = trimmedShapes[k];
  382. s = this.projectShape(shape, preview, false);
  383. ret = ret.concat(s);
  384. }
  385. return ret;
  386. }
  387. if (this.segmentation && !this.flat) {
  388. // If segmentation is on, split up lines and arcs into polylines
  389. // with the given segment length. All other shapes are split up into
  390. // lines and arcs.
  391. if (isLineShape(shape) || isArcShape(shape)) {
  392. ret = [];
  393. // switch off segmentation for polyline segments:
  394. this.segmentation = false;
  395. var l = shape.getLength();
  396. var numSegments = 16;
  397. if (!preview && this.segmentLength>RS.PointTolerance) {
  398. numSegments = Math.ceil(l/this.segmentLength);
  399. }
  400. if (numSegments>1000) {
  401. // avoid huge number of segments / crash:
  402. numSegments = 1000;
  403. }
  404. var polyline = ShapeAlgorithms.lineOrArcToPolyline(shape, numSegments);
  405. var projectedPls = this.projectShape(polyline, preview, trim, true);
  406. if (projectedPls.length>0) {
  407. var projectedPl = projectedPls[0];
  408. if (!isNull(projectedPl)) {
  409. projectedPl.simplify(0.01);
  410. ret.push(projectedPl);
  411. }
  412. }
  413. this.segmentation = true;
  414. return ret;
  415. }
  416. if (isXLineShape(shape) || isRayShape(shape)) {
  417. return [];
  418. }
  419. }
  420. if (isPointShape(shape)) {
  421. p = shape.getPosition();
  422. this.project(p);
  423. shape.setPosition(p);
  424. return [ shape ];
  425. }
  426. if (isLineShape(shape)) {
  427. p = shape.getStartPoint();
  428. this.project(p);
  429. shape.setStartPoint(p);
  430. p = shape.getEndPoint();
  431. this.project(p);
  432. shape.setEndPoint(p);
  433. return [ shape ];
  434. }
  435. if (isXLineShape(shape) || isRayShape(shape)) {
  436. p = shape.getBasePoint();
  437. this.project(p);
  438. p2 = shape.getSecondPoint();
  439. this.project(p2);
  440. shape.setBasePoint(p);
  441. shape.setSecondPoint(p2);
  442. return [ shape ];
  443. }
  444. if (isArcShape(shape)) {
  445. var self=this;
  446. // TODO: use RShape::transformArc
  447. // make RShapeTransformation scriptable
  448. // override RShapeTransformation::transform
  449. var ellipse = ShapeAlgorithms.transformArc(shape,
  450. function(p) {
  451. self.project(p);
  452. }
  453. );
  454. if (ellipse.isValid()) {
  455. return [ ellipse ];
  456. }
  457. else {
  458. return [];
  459. }
  460. }
  461. if (isCircleShape(shape)) {
  462. var arc = new RArc(shape.getCenter(), shape.getRadius(), 0.0, Math.PI*2);
  463. return this.projectShape(arc, preview, trim);
  464. }
  465. if (isEllipseShape(shape)) {
  466. if (shape.isCircular()) {
  467. // ellipse is a full circle:
  468. if (shape.isFullEllipse()) {
  469. var circle = new RCircle(shape.getCenter(), shape.getMajorRadius());
  470. return this.projectShape(circle, preview, trim);
  471. }
  472. // ellipse is a circular arc:
  473. else {
  474. var arc = new RArc(shape.getCenter(),
  475. shape.getMajorRadius(),
  476. shape.getStartAngle(),
  477. shape.getEndAngle(),
  478. shape.isReversed());
  479. return this.projectShape(arc, preview, trim);
  480. }
  481. }
  482. // create polyline from ellipse:
  483. var ple = ShapeAlgorithms.approximateEllipse(shape, 16);
  484. return this.projectShape(ple, preview, trim);
  485. }
  486. if (isTriangleShape(shape)) {
  487. for (i=0; i<3; ++i) {
  488. p = shape.getCorner(i);
  489. this.project(p);
  490. shape.setCorner(i, p);
  491. }
  492. return [ shape ];
  493. }
  494. if (isSplineShape(shape)) {
  495. shape = ShapeAlgorithms.splineToLineOrArc(shape, 0.01);
  496. if (!isSplineShape(shape)) {
  497. return this.projectShape(shape, preview, trim);
  498. }
  499. var segmentation = this.segmentation;
  500. this.segmentation = false;
  501. var segments = preview ? 4 : -1;
  502. var pls = shape.toPolyline(segments);
  503. // var shapes = shape.getExploded(segments);
  504. // var pls = new RPolyline();
  505. // for (i=0; i<shapes.length; i++) {
  506. // s = getPtr(shapes[i]);
  507. // pls.appendShape(s);
  508. // }
  509. ret = this.projectShape(pls, preview, trim);
  510. this.segmentation = segmentation;
  511. return ret;
  512. }
  513. if (isPolylineShape(shape)) {
  514. if (!rec) {
  515. // remove duplicate vertices (zero length segments):
  516. shape.normalize(RS.PointTolerance);
  517. }
  518. // add polyline, split up at arcs that are projected into ellipses and
  519. // at gaps caused by trimming:
  520. ret = [];
  521. var pl = new RPolyline();
  522. var segmentCount = shape.countSegments();
  523. var addPl = false;
  524. // project each segment individually:
  525. for (i=0; i<segmentCount; i++) {
  526. s = getPtr(shape.getSegmentAt(i));
  527. s = this.projectShape(s, preview, trim, true);
  528. // iterate through projected shapes (trimming might lead to gaps):
  529. for (k=0; k<s.length; k++) {
  530. var seg = s[k];
  531. if (isFunction(seg.data)) {
  532. seg = getPtr(seg);
  533. }
  534. var gotGap = pl.countVertices()>0 &&
  535. !pl.getEndPoint().equalsFuzzy(seg.getStartPoint());
  536. // s is a line or polyline that connets to the polyline we have:
  537. if (!gotGap && (isLineShape(seg) || isPolylineShape(seg))) {
  538. if (seg.getLength()>RS.PointTolerance) {
  539. pl.appendShape(seg);
  540. }
  541. }
  542. // s is an ellipse:
  543. var gotEllipse = isEllipseShape(seg);
  544. // reached last segment of current polyline:
  545. if (i===segmentCount-1 || gotEllipse || gotGap) {
  546. if (pl.countVertices()===1) {
  547. // don't add polyline for one single shape:
  548. ret.push(pl.getSegmentAt(0));
  549. }
  550. else if (pl.countVertices()>0) {
  551. ret.push(pl);
  552. addPl = false;
  553. }
  554. if (gotEllipse) {
  555. if (seg.isValid()) {
  556. ret.push(seg);
  557. }
  558. pl = new RPolyline();
  559. }
  560. else if (gotGap){
  561. pl = new RPolyline();
  562. //qDebug("seg:", seg);
  563. pl.appendShape(seg);
  564. addPl = true;
  565. }
  566. }
  567. }
  568. }
  569. if (addPl && pl.countVertices()>0) {
  570. ret.push(pl);
  571. }
  572. // set global width if polyline has uniform global semgent width:
  573. var gotGlobalWidth = false;
  574. var startWidths = shape.getStartWidths();
  575. var endWidths = shape.getEndWidths();
  576. if (startWidths.length>0 && endWidths.length>0) {
  577. if (startWidths[0]>RS.PointTolerance) {
  578. startWidths.sortNumerical();
  579. endWidths.sortNumerical();
  580. if (RMath.fuzzyCompare(startWidths[0], startWidths[startWidths.length-1]) &&
  581. RMath.fuzzyCompare(endWidths[0], endWidths[endWidths.length-1]) &&
  582. RMath.fuzzyCompare(startWidths[0], endWidths[0])) {
  583. // got global polyline width:
  584. gotGlobalWidth = true;
  585. for (i=0; i<ret.length; i++) {
  586. if (isPolylineShape(ret[i])) {
  587. ret[i].setGlobalWidth(startWidths[0]);
  588. }
  589. }
  590. }
  591. }
  592. }
  593. // set pl segment widths if there's no segmentation and the number of segments match:
  594. if (ret.length===1 && isPolylineShape(ret[0])) {
  595. if (!gotGlobalWidth && !this.segmentation && shape.countSegments()===ret[0].countSegments()) {
  596. for (i=0; i<shape.countVertices(); i++) {
  597. ret[0].setStartWidthAt(i, shape.getStartWidthAt(i));
  598. ret[0].setEndWidthAt(i, shape.getEndWidthAt(i));
  599. }
  600. }
  601. }
  602. return ret;
  603. }
  604. return [];
  605. };
  606. Projection.prototype.slotRotateCCW = function() {
  607. this.rotation += 90;
  608. this.clearCache();
  609. this.updatePreview(true);
  610. };
  611. Projection.prototype.slotRotateCW = function() {
  612. this.rotation -= 90;
  613. this.clearCache();
  614. this.updatePreview(true);
  615. };
  616. Projection.prototype.slotSegmentLengthChanged = function(l) {
  617. this.segmentLength = l;
  618. this.clearCache();
  619. this.updatePreview(true);
  620. };
  621. Projection.prototype.slotRetainTextsChanged = function(v) {
  622. this.retainTexts = v;
  623. this.clearCache();
  624. this.updatePreview(true);
  625. };
  626. Projection.init = function() {
  627. Projection.getMenu();
  628. Projection.getToolBar();
  629. Projection.getCadToolBarPanel();
  630. Projection.getToolMatrixPanel();
  631. };