/** * 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("../BlockInsert.js"); /** * \class InsertBlock * \ingroup ecma_block * \brief This action handles the user interaction to insert a block * from the block list into the drawing. */ function InsertBlock(guiAction) { BlockInsert.call(this, guiAction); this.setUiOptions("InsertBlock.ui"); this.blockReferenceData = new RBlockReferenceData(); this.blockReferenceData.setPosition(new RVector(0.0,0.0)); this.blockReferenceData.setScaleFactors(new RVector(1.0,1.0)); this.blockReferenceData.setRotation(0.0); } InsertBlock.State = { SettingPosition : 0 }; InsertBlock.prototype = new BlockInsert(); InsertBlock.includeBasePath = includeBasePath; InsertBlock.prototype.beginEvent = function() { BlockInsert.prototype.beginEvent.call(this); var blockId = Block.getActiveBlockId(); if (blockId===RObject.INVALID_ID) { this.terminate(); return; } this.blockReferenceData.setReferencedBlockId(blockId); var i, label, edit, sep, a; var optionsToolBar = EAction.getOptionsToolBar(); // init block attribute inputs to options tool bar: var doc = this.getDocument(); if (!isNull(doc)) { var ids = doc.queryBlockEntities(blockId); var first = true; var items = []; for (i=0; i1 || bd.getRowCount()>1) { // max insertions: var max = RSettings.getPreviewEntities() / ids.length; // reduce rows: if (max<2) { bd.setColumnCount(1); bd.setRowCount(1); } else if (max