/** * 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/Draw/Dimension/Dimension.js"); /** * \class DimAngular * \brief Draw angular dimension. * The first entity is a line or arc. If the first entity is a line, * a second entity has to be chosen which is also a line. * If using max angle, this action creates a 3 point angular dimension. * \ingroup ecma_draw_dimension */ function DimAngular(guiAction) { Dimension.call(this, guiAction); // for common dimension data (set by options toolbar in Dimension class) this.data = new RDimensionData(); //this.data2L = new RDimAngular2LData(); //this.data3P = new RDimAngular3PData(); this.dimArcPosition = RVector.invalid; this.firstEntity = undefined; this.firstShape = undefined; this.secondEntity = undefined; this.secondShape = undefined; this.useMaxAngle = false; this.setUiOptions(["../Dimension.ui", "DimAngular.ui"], false); } DimAngular.prototype = new Dimension(); DimAngular.State = { SettingFirstEntity : 0, SettingSecondEntity : 1, SettingDimPos : 2 }; DimAngular.prototype.beginEvent = function() { Dimension.prototype.beginEvent.call(this); this.setState(DimAngular.State.SettingFirstEntity); }; DimAngular.prototype.setState = function(state) { Dimension.prototype.setState.call(this, state); this.setCrosshairCursor(); var appWin = RMainWindowQt.getMainWindow(); switch (this.state) { case DimAngular.State.SettingFirstEntity: this.getDocumentInterface().setClickMode(RAction.PickEntity); // this.data2L.setExtensionLine1Start(RVector.invalid); // this.data2L.setExtensionLine1End(RVector.invalid); // this.data2L.setExtensionLine2Start(RVector.invalid); // this.data2L.setExtensionLine2End(RVector.invalid); // this.data2L.setDimArcPosition(RVector.invalid); this.firstEntity = undefined; this.firstShape = undefined; this.secondEntity = undefined; this.secondShape = undefined; this.dimArcPosition = RVector.invalid; var trFirstEntity = qsTr("Arc or first of two lines"); this.setLeftMouseTip(trFirstEntity); this.setCommandPrompt(trFirstEntity); this.setRightMouseTip(EAction.trCancel); break; case DimAngular.State.SettingSecondEntity: this.getDocumentInterface().setClickMode(RAction.PickEntity); // this.data2L.setExtensionLine2Start(RVector.invalid); // this.data2L.setExtensionLine2End(RVector.invalid); // this.data2L.setDimArcPosition(RVector.invalid); this.secondEntity = undefined; this.secondShape = undefined; this.dimArcPosition = RVector.invalid; var trSecondEntity = qsTr("Second line"); this.setLeftMouseTip(trSecondEntity); this.setCommandPrompt(trSecondEntity); this.setRightMouseTip(EAction.trBack); break; case DimAngular.State.SettingDimPos: this.getDocumentInterface().setClickMode(RAction.PickCoordinate); //this.data2L.setDefinitionPoint(RVector.invalid); var trDimPos = qsTr("Dimension arc location"); this.setCommandPrompt(trDimPos); this.setLeftMouseTip(trDimPos); this.setRightMouseTip(EAction.trBack); break; } EAction.showSnapTools(); }; DimAngular.prototype.escapeEvent = function() { switch (this.state) { case DimAngular.State.SettingFirstEntity: EAction.prototype.escapeEvent.call(this); break; case DimAngular.State.SettingSecondEntity: this.setState(DimAngular.State.SettingFirstEntity); break; case DimAngular.State.SettingDimPos: if (isArcShape(this.firstShape)) { this.setState(DimAngular.State.SettingFirstEntity); } else { this.setState(DimAngular.State.SettingSecondEntity); } break; } }; DimAngular.prototype.initUiOptions = function(resume, optionsToolBar) { Dimension.prototype.initUiOptions.call(this, resume, optionsToolBar); var widgetNames = [ "ScaleAction", "ScaleLabelAction", "ScaleSeparatorAction", "AutoScaleAction" ]; for (var i=0; i