/** * 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("../../WidgetFactory.js"); /** * \class HatchDialog * \brief Hatch creation or editing dialog. * \ingroup ecma_draw_hatch */ function HatchDialog() { this.dialog = undefined; } HatchDialog.basePath = includeBasePath; HatchDialog.prototype.show = function(hatchDataIn) { var doc = EAction.getDocument(); if (isNull(doc)) { return; } this.dialog = WidgetFactory.createDialog(HatchDialog.basePath, "HatchDialog.ui", EAction.getMainWindow()); var radioSolid = this.dialog.findChild("SolidFill"); var radioHatch = this.dialog.findChild("HatchPattern"); var comboPattern = this.dialog.findChild("Pattern"); var editAngle = this.dialog.findChild("Angle"); var editScale = this.dialog.findChild("Scale"); var groupPattern = this.dialog.findChild("PatternGroup"); if (radioSolid.checked) { groupPattern.enabled = false; } editAngle.valueChanged.connect(this, this.patternChanged); radioSolid.toggled.connect(this, this.patternChanged); //comboPattern["activated(QString)"].connect(this, "patternChanged"); comboPattern["currentIndexChanged(int)"].connect(this, this.patternChanged); var previewDoc = new RDocument(new RMemoryStorage(), new RSpatialIndexSimple()); //previewDoc.setMeasurement(doc.getMeasurement()); this.previewDi = new RDocumentInterface(previewDoc); this.previewDi.setNotifyListeners(false); var layout = this.dialog.findChild("PreviewLayout"); // keep this include here to make sure command line tools // can use Hatch.js without requiring a GUI: include("scripts/Widgets/AutoZoomView/AutoZoomView.js"); var view = new AutoZoomView(this.dialog); view.objectName = "PreviewView"; view.setPaintOrigin(false); layout.addWidget(view, 0, 0); view.setScene(new RGraphicsSceneQt(this.previewDi)); view.disableGestures(); view.setMargin(10); var patternNames; if (RUnit.isMetric(EAction.getDocument().getUnit())) { patternNames = RPatternListMetric.getNames(); } else { patternNames = RPatternListImperial.getNames(); } for (var i=0; i200) { data.setColor(new RColor("black")); } else { data.setColor(new RColor("white")); } data.newLoop(); var lines = [ new RLine(new RVector(0,0), new RVector(size,0)), new RLine(new RVector(size,0), new RVector(size,size)), new RLine(new RVector(size,size), new RVector(0,size)), new RLine(new RVector(0,size), new RVector(0,0)), ]; for (var i=0; i= 0x060000) { data.addBoundary(lines[i].clone()); } else { data.addBoundary(lines[i]); } } var hatch = new RHatchEntity(previewDoc, data); var op = new RAddObjectOperation(hatch, false, false); this.previewDi.applyOperation(op); this.previewDi.autoZoom(); };