/* * Copyright (c) 2011 by RibbonSoft, GmbH. All rights reserved. * * This file is part of the QCAD project. * * Licensees holding valid QCAD Professional Edition licenses * may use this file in accordance with the QCAD License * Agreement provided with the Software. * * This file is provided AS IS with NO WARRANTY OF ANY KIND, * INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE. * * See http://www.ribbonsoft.com for further details. */ include("../Draw.js"); /** * \class Image * \brief Inserts an image (bitmap) into the drawing. * \ingroup ecmaDrawImage */ function Image(guiAction) { Draw.call(this, guiAction); this.filename = undefined; this.image = undefined; this.width = undefined; this.height = undefined; this.angle = undefined; this.setUiOptions("Image.ui"); } Image.State = { SettingPosition : 0 }; Image.prototype = new Draw(); Image.includeBasePath = includeBasePath; Image.prototype.beginEvent = function() { Draw.prototype.beginEvent.call(this); this.filename = this.getFilename(); if (isNull(this.filename)) { this.terminate(); return; } this.image = new RImageEntity( this.getDocument(), new RImageData(this.filename, new RVector(0,0), new RVector(1,0), new RVector(0,1), 50, 50, 0) ); // initial size is image size in pixels (i.e. one pixel -> one unit): this.width = this.image.getPixelWidth(); this.height = this.image.getPixelHeight(); var optionsToolBar = EAction.getOptionsToolBar(); var widthEdit = optionsToolBar.findChild("Width"); var heightEdit = optionsToolBar.findChild("Height"); widthEdit.setValue(this.width); heightEdit.setValue(this.height); this.setState(Image.State.SettingPosition); }; Image.prototype.getFilename = function() { var formats = QImageReader.supportedImageFormats(); var filters = new Array(); var filterAllImages = ""; for (var i=0; i