/** * Copyright (c) 2011-2018 by Andrew Mustun. All rights reserved. * * This file is part of the QCAD project. * * QCAD is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * QCAD is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with QCAD. */ include("scripts/Modify/Modify.js"); include("scripts/ShapeAlgorithms.js"); function Explode(guiAction) { Modify.call(this, guiAction); } Explode.prototype = new Modify(); Explode.getPreferencesCategory = function() { return [qsTr("Modify"), qsTr("Explode")]; }; Explode.initPreferences = function(pageWidget, calledByPrefDialog, document) { var widgets = getWidgets(pageWidget); if (!RTextBasedData.hasProxy()) { // remove MultilineTextToSimpleText option: widgets["MultilineTextToSimpleText"].visible = false; } if (!RSpline.hasProxy()) { widgets["SplineTolerance"].visible = false; widgets["SplineTolerance_Label"].visible = false; widgets["SplinesToLineSegments"].visible = false; widgets["Indent"].destroy(); pageWidget.findChild("GridLayout").addWidget(widgets["SplineSegments_Label"], 2, 0, 1, 2); } else { widgets["SplinesToLineSegments"].toggled.connect(function(state) { widgets["SplineSegments"].enabled = state; widgets["SplineSegments_Label"].enabled = state; }); widgets["SplineSegments"].enabled = widgets["SplinesToLineSegments"].checked; widgets["SplineSegments_Label"].enabled = widgets["SplinesToLineSegments"].checked; } }; Explode.prototype.beginEvent = function() { Modify.prototype.beginEvent.call(this); var di = this.getDocumentInterface(); Explode.explodeSelection(di, this.getToolTitle()); this.terminate(); }; /** * Explodes all selected entities. * \param di Document interface * \param toolTitle Tool title used for undo/redo information. */ Explode.explodeSelection = function(di, toolTitle) { var document = di.getDocument(); var storage = document.getStorage(); var ids = document.querySelectedEntities(); var i, k, e, n; var polyline, shapes; var options = {}; options["splineTolerance"] = RSettings.getDoubleValue("Explode/SplineTolerance", 0.01); options["splineSegments"] = RSettings.getIntValue("Explode/SplineSegments", 64); options["ellipseSegments"] = RSettings.getIntValue("Explode/EllipseSegments", 32); options["splinesToLineSegments"] = RSettings.getBoolValue("Explode/SplinesToLineSegments", false); options["textToPolylines"] = RSettings.getBoolValue("Explode/TextToPolylines", true); options["multilineTextToSimpleText"] = RSettings.getBoolValue("Explode/MultilineTextToSimpleText", true); // ExplodeDialog.ui is out of use. // CVH added circle preference to PreferencesPage.ui: var excludeCircles = !(RSettings.getBoolValue("Explode/CirclesToPolylines", true)); var op = new RAddObjectsOperation(); if (!isNull(toolTitle)) { op.setText(toolTitle); } // map old block reference IDs to block reference entities: var blockReferenceMap = {}; // list of attribute entities: var attributeEntities = []; for (i=0; i0) { op = new RAddObjectsOperation(); //op.setTransactionGroup(doc.getTransactionGroup()); if (!isNull(toolTitle)) { op.setText(toolTitle); } // fix attribute links to block references: for (i=0; i1 || rightPl.countSegments()>1) { else if (!leftPl.isEmpty()) { //ret.push(pls[k]); if (!rightPl.isEmpty()) { ret.push(new RLine(leftPl.getStartPoint(), rightPl.getStartPoint())); } ret.push(leftPl); if (!rightPl.isEmpty()) { ret.push(rightPl); ret.push(new RLine(leftPl.getEndPoint(), rightPl.getEndPoint())); } first = true; if (!isNull(lastSegment)) { ret.push(lastSegment); lastSegment = undefined; prevLeftPl = undefined; prevRightPl = undefined; } continue; } } if (!isNull(lastSegment)) { ret.push(lastSegment); } } else { var polySegments = polyline.getExploded(); if (polySegments.length>0) { for (k=0; k1 || data.getRowCount()>1) { for (col=0; col