def showMarkDaSoc(self):
        try:
            flag = FlightPlanBaseDlg.btnConstruct_Click(self)

            self.putDistances()

            point3dMapt = self.parametersPanel.pnlMaPtPosition.Point3d
            socLayer = AcadHelper.createVectorLayer(
                "SOC_MAPt_" + self.surfaceType, QGis.Point)
            AcadHelper.setGeometryAndAttributesInLayer(socLayer,
                                                       self.socPoint3d, False,
                                                       {"Caption": "SOC"})
            AcadHelper.setGeometryAndAttributesInLayer(socLayer, point3dMapt,
                                                       False,
                                                       {"Caption": "MAPt"})

            QgisHelper.appendToCanvas(define._canvas, [socLayer],
                                      self.surfaceType)

            palSetting = QgsPalLayerSettings()
            palSetting.readFromLayer(socLayer)
            palSetting.enabled = True
            palSetting.fieldName = "Caption"
            palSetting.isExpression = True
            palSetting.placement = QgsPalLayerSettings.AroundPoint
            palSetting.setDataDefinedProperty(QgsPalLayerSettings.Size, True,
                                              True, '8', "")
            palSetting.writeToLayer(socLayer)

            self.resultLayerList = [socLayer]

            return socLayer
        except:
            pass
    def resultPointValueListMethod(self, resultValueList):
        flag = FlightPlanBaseDlg.btnConstruct_Click(self)
        if not flag:
            return
        point  = Point3D()
        try:
            point = Point3D(float(resultValueList[1]), float(resultValueList[2]), float(resultValueList[3]))
        except:
            return
        if (not self.flagP):
            mapUnits = define._canvas.mapUnits()
            self.constructionLayer = AcadHelper.createVectorLayer(self.surfaceType)

            self.point3dP = point.smethod_167(0);
            self.origin1P = self.method_31(self.polylineP, self.originP, self.point3dP, self.numP, self.metresP, self.speedP, self.num2P, self.orientationTypeP);
            AcadHelper.setGeometryAndAttributesInLayer(self.constructionLayer, self.polylineP)
            QgisHelper.appendToCanvas(define._canvas, [self.constructionLayer], self.surfaceType)

            # polyline.Draw();
        else:

            mapUnits = define._canvas.mapUnits()
            self.constructionLayer = AcadHelper.createVectorLayer(self.surfaceType)
            self.originP = point.smethod_167(0);
            self.polylineP, self.origin1P = self.method_30(self.originP, self.numP, self.metresP, self.speedP, self.num2P, self.orientationTypeP);
            AcadHelper.setGeometryAndAttributesInLayer(self.constructionLayer, self.polylineP)
            QgisHelper.appendToCanvas(define._canvas, [self.constructionLayer], self.surfaceType)
            # AcadHelper.smethod_18(transaction, blockTableRecord, polyline, constructionLayer);
        self.flagP = not self.flagP;
        self.resultLayerList = [self.constructionLayer]
        if (not self.flagP):
            define._messageLabel.setText(Prompts.SECOND_POSITION_FINISH);
        else:
            define._messageLabel.setText(Prompts.POSITION_FINISH)
        pass
    def btnConstruct_Click(self):
        flag = FlightPlanBaseDlg.btnConstruct_Click(self)
        if not flag:
            return
        try:
            self.method_27(True)
            if (self.ui.cmbSegmentType.SelectedIndex != 0):
                self.pinSVisualSegmentDepManouvering = PinSVisualSegmentDepManouvering(
                    self)
            else:
                self.pinSVisualSegmentDepManouvering = PinSVisualSegmentDepDirect(
                    self)

            layersList = []
            if self.ui.cmbConstructionType.SelectedItem != ConstructionType.Construct2D:
                self.pinSVisualSegmentDepManouvering.imethod_2(layersList)
            else:
                self.pinSVisualSegmentDepManouvering.imethod_1(layersList)

            QgisHelper.appendToCanvas(define._canvas, layersList,
                                      SurfaceTypes.PinSVisualSegmentDep)
            QgisHelper.zoomToLayers(layersList)
            self.resultLayerList = layersList
            self.ui.btnEvaluate.setEnabled(True)
        except UserWarning as e:
            QMessageBox.warning(self, "Error", e.message)
    def btnConstruct_Click(self):
        flag = FlightPlanBaseDlg.btnConstruct_Click(self)
        if not flag:
            return
        value = Speed(float(self.parametersPanel.txtIas.text()),SpeedUnits.KTS);
        if (self.parametersPanel.chbDeparture.isChecked()):
            value = value + (value / 10);
        altitude = Altitude(float(self.parametersPanel.txtAltitudeFt.text()), AltitudeUnits.FT);
        value1 = float(self.parametersPanel.txtIsa.text());
        num1 = float (self.parametersPanel.txtBankAngle.text());
        self.speedP = self.parametersPanel.pnlWind.Value;
        self.num2P = Unit.ConvertDegToRad(float(self.parametersPanel.txtTrackRadial.Value));
        self.orientationTypeP = self.parametersPanel.cmbOrientation.currentText();
        speed1 = Speed.smethod_0(value, value1, altitude);
        numList = []
        distance = Distance.smethod_1(speed1, num1, numList);
        self.numP = numList[0]
        self.metresP = distance.Metres;

        self.originP = Point3D.get_Origin();
        self.point3dP = Point3D.get_Origin();
        self.origin1P = Point3D.get_Origin();
        self.polylineP = PolylineArea();
        self.flagP = True;


        define._canvas.setMapTool(self.CaptureCoordTool)
    def btnConstruct_Click(self):
        flag = FlightPlanBaseDlg.btnConstruct_Click(self)
        if not flag:
            return
        # self.parametersPanel.txtRadius.setText("")

        point3dCollection = None;
        point3dCollection1 = None;
        polylineArea = None;
        polylineArea1 = None;
        polylineArea2 = None;

        point3dArrayResult = []

        mapUnits = define._canvas.mapUnits()
        constructionLayer = None


        result, point3dCollection, point3dCollection1, polylineArea, polylineArea1, polylineArea2 = self.method_34()
        if result:
            point3dCollection2 = [];
            if (point3dCollection != None and len(point3dCollection) > 0):
                point3dCollection2.append(point3dCollection[0]);
            for point3d in point3dCollection1:
                point3dCollection2.append(point3d);
            if (point3dCollection != None and len(point3dCollection) > 0):
                point3dCollection2.append(point3dCollection[3]);
            # point3dCollection2.pop(3)
            # point3dCollection2.pop(3)
            # point3dArrayResult.append(polylineArea1.method_14_closed())
            # point3dArrayResult.append(polylineArea2.method_14_closed())
            point3dArrayResult.append(PolylineArea(point3dCollection2))

            self.area123 = point3dCollection2
            self.circleArea = polylineArea

            nominalPointTest1 = point3dCollection2[2]
            nominalPointTest2 = point3dCollection2[3]
            self.nominalPoint = MathHelper.distanceBearingPoint(nominalPointTest1, MathHelper.getBearing(nominalPointTest1, nominalPointTest2), MathHelper.calcDistance(nominalPointTest1, nominalPointTest2) / 2)
            # if polylineArea.isCircle:
            #     self.parametersPanel.txtRadius.setText(str(polylineArea.Radius()))
            point3dArrayResult.append(polylineArea)

        if not len(point3dArrayResult) > 0 :
            return
        constructionLayer = AcadHelper.createVectorLayer(self.surfaceType, QGis.Line)
        for point3dArray in point3dArrayResult:
            AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, point3dArray, True)
        nominalTrackLayer = self.nominal2Layer()
        QgisHelper.appendToCanvas(define._canvas, [constructionLayer, nominalTrackLayer], self.surfaceType)
        self.resultLayerList = [constructionLayer, nominalTrackLayer]
        QgisHelper.zoomToLayers(self.resultLayerList)
        self.ui.btnEvaluate.setEnabled(True)
 def btnConstruct_Click(self):
     flag = FlightPlanBaseDlg.btnConstruct_Click(self)
     if not flag:
         return
    def showMarkDaSoc(self):
        try:
            flag = FlightPlanBaseDlg.btnConstruct_Click(self)
            # if not flag:
            #     return
            point3dThr = self.parametersPanel.pnlThrPosition.Point3d
            point3dFaf = self.parametersPanel.pnlFapPosition.Point3d
            inboundTrackRad = Unit.ConvertDegToRad(self.parametersPanel.pnlInboundTrack.Value)#MathHelper.getBearing(point3dFaf, point3dThr)
            inboundTrack180Rad = MathHelper.smethod_4(inboundTrackRad + math.pi)
            estimatedAltitdeMeters = self.parametersPanel.pnlEstimatedAltitude.Value.Metres
            thrAltitudeMeters = self.parametersPanel.pnlThrPosition.Altitude().Metres
            heightLossAltitudeMeters = self.parametersPanel.pnlHeightLoss.Value.Metres
            rdhAltitudeMeters = self.parametersPanel.pnlRDH.Value.Metres
            vpa = Unit.ConvertDegToRad(self.getVPA())
            xz = self.parametersPanel.pnlDistXz.Value.Metres
            socThrDistMeters = ((estimatedAltitdeMeters - thrAltitudeMeters - heightLossAltitudeMeters) / math.tan(vpa)) + xz
            daThrDistMeters = (estimatedAltitdeMeters - thrAltitudeMeters - rdhAltitudeMeters) / math.tan(vpa)

            sockBearing = inboundTrackRad
            # if socThrDistMeters < 0:
            #     sockBearing = inboundTrack180Rad
            #     socThrDistMeters = math.fabs(socThrDistMeters)
            # else:
            #     sockBearing = inboundTrackRad
            daBearing = inboundTrack180Rad
            # if daThrDistMeters < 0:
            #     daBearing = inboundTrackRad
            #     daThrDistMeters = math.fabs(daThrDistMeters)
            # else:
            #     daBearing = inboundTrack180Rad
            self.socPoint3d = MathHelper.distanceBearingPoint(point3dThr, sockBearing, -socThrDistMeters).smethod_167(self.calcSocAltitude())
            self.daPoint3d = MathHelper.distanceBearingPoint(point3dThr, daBearing, daThrDistMeters)

            daSocLayer = AcadHelper.createVectorLayer("DA_SOC_" + self.surfaceType, QGis.Point)
            AcadHelper.setGeometryAndAttributesInLayer(daSocLayer, self.socPoint3d, False, {"Caption":"SOC"})
            AcadHelper.setGeometryAndAttributesInLayer(daSocLayer, self.daPoint3d, False, {"Caption":"DA"})

            QgisHelper.appendToCanvas(define._canvas, [daSocLayer], self.surfaceType)

            palSetting = QgsPalLayerSettings()
            palSetting.readFromLayer(daSocLayer)
            palSetting.enabled = True
            palSetting.fieldName = "Caption"
            palSetting.isExpression = True
            palSetting.placement = QgsPalLayerSettings.AroundPoint
            palSetting.setDataDefinedProperty(QgsPalLayerSettings.Size, True, True, '8', "")
            palSetting.writeToLayer(daSocLayer)

            QgisHelper.zoomToLayers([daSocLayer])
            self.resultLayerList = [daSocLayer]

            # # show SOC Mark
            # point3d = MathHelper.distanceBearingPoint(self.socPoint3d, Unit.ConvertDegToRad(450) - 0, 100)
            # point3d1 = MathHelper.distanceBearingPoint(self.socPoint3d, Unit.ConvertDegToRad(450) - math.pi / 2, 100)
            # point3d2 = MathHelper.distanceBearingPoint(self.socPoint3d, Unit.ConvertDegToRad(450) - math.pi, 100)
            # point3d3 = MathHelper.distanceBearingPoint(self.socPoint3d, Unit.ConvertDegToRad(450) - (math.pi * 3) / 2 , 100)
            #
            # if self.socRubber == None:
            #     self.socRubber = QgsRubberBand(define._canvas, QGis.Line)
            #     self.socRubber.setColor(Qt.yellow)
            # else:
            #     self.socRubber.reset(QGis.Line)
            # self.socRubber.addGeometry(QgsGeometry.fromPolyline([point3d, point3d2]), None)
            # self.socRubber.addGeometry(QgsGeometry.fromPolyline([point3d1, point3d3]), None)
            # circle = MathHelper.constructCircle(self.socPoint3d, 100, 16)
            # self.socRubber.addGeometry(QgsGeometry.fromPolyline(circle), None)
            # self.socRubber.show()
            #
            # self.socAnnotation.setMapPosition(self.socPoint3d)
            # self.socAnnotation.show()
            #
            # # show DA Mark
            # point3d = MathHelper.distanceBearingPoint(self.daPoint3d, Unit.ConvertDegToRad(450) - 0, 100)
            # point3d1 = MathHelper.distanceBearingPoint(self.daPoint3d, Unit.ConvertDegToRad(450) - math.pi / 2, 100)
            # point3d2 = MathHelper.distanceBearingPoint(self.daPoint3d, Unit.ConvertDegToRad(450) - math.pi, 100)
            # point3d3 = MathHelper.distanceBearingPoint(self.daPoint3d, Unit.ConvertDegToRad(450) - (math.pi * 3) / 2 , 100)
            #
            # if self.daRubber == None:
            #     self.daRubber = QgsRubberBand(define._canvas, QGis.Line)
            #     self.daRubber.setColor(Qt.yellow)
            # else:
            #     self.daRubber.reset(QGis.Line)
            # self.daRubber.addGeometry(QgsGeometry.fromPolyline([point3d, point3d2]), None)
            # self.daRubber.addGeometry(QgsGeometry.fromPolyline([point3d1, point3d3]), None)
            # circle = MathHelper.constructCircle(self.daPoint3d, 100, 16)
            # self.daRubber.addGeometry(QgsGeometry.fromPolyline(circle), None)
            # self.daRubber.show()
            #
            # self.daAnnotation.setMapPosition(self.daPoint3d)
            # self.daAnnotation.show()

            self.putDistances()
            return daSocLayer
        except:
            pass
    def btnConstruct_Click(self):
        flag = FlightPlanBaseDlg.btnConstruct_Click(self)
        if not flag:
            return
        mapUnits = define._canvas.mapUnits()
        constructionLayer = None

        polylines = self.method_36(True)
        pollineAreaLineList, polylineAreaArcList, centerPolylineArea = self.method_36_Construct(
            True)
        if (self.parametersPanel.cmbConstruction.currentText() !=
                ConstructionType.Construct3D):
            constructionLayer = AcadHelper.createVectorLayer(
                self.surfaceType, QGis.Line)
            AcadHelper.setGeometryAndAttributesInLayer(constructionLayer,
                                                       centerPolylineArea,
                                                       True)
            for polrlineArea in pollineAreaLineList:
                AcadHelper.setGeometryAndAttributesInLayer(
                    constructionLayer, polrlineArea)
            for polrlineArea in polylineAreaArcList:
                AcadHelper.setGeometryAndAttributesInLayer(
                    constructionLayer, polrlineArea)

        else:
            constructionLayer = AcadHelper.createVectorLayer(
                self.surfaceType, QGis.Polygon)
            # if define._mapCrs == None:
            #     if mapUnits == QGis.Meters:
            #         constructionLayer = QgsVectorLayer("polygon?crs=EPSG:32633", self.surfaceType, "memory")
            #     else:
            #         constructionLayer = QgsVectorLayer("polygon?crs=EPSG:4326", self.surfaceType, "memory")
            # else:
            #     constructionLayer = QgsVectorLayer("polygon?crs=%s"%define._mapCrs.authid (), self.surfaceType, "memory")
            # constructionLayer.startEditing()
            count = len(polylines)
            num = 0.1 * count
            altitude = Altitude(float(self.parametersPanel.txtAltitude.text()),
                                AltitudeUnits.FT)
            value = Altitude(float(self.parametersPanel.txtMoc.text()),
                             AltitudeUnits.M)
            metres = altitude.Metres - value.Metres
            for i in range(count):
                AcadHelper.setGeometryAndAttributesInLayer(
                    constructionLayer, polylines[len(polylines) - 1 - i], True)


#                 polygon1 = QgsGeometry.fromPolygon([polylines[i].method_14_closed(6)])
#                 polygonNew = polygon1
#                 if (i > 0):
#                     metres1 = altitude.Metres
# #                     value = self.pnlMoc.Value;
#                     metres = metres1 - num * value.Metres
#                     num = num - 0.1
#                 if (i > 0):
#                     polygon0 = QgsGeometry.fromPolygon([polylines[i - 1].method_14_closed(6)])
#                     polygonNew = polygon1.difference(polygon0)
#                 feature = QgsFeature()
#                 feature.setGeometry(polygonNew)
#                 constructionLayer.addFeature(feature)
#             constructionLayer.commitChanges()
        QgisHelper.appendToCanvas(define._canvas, [constructionLayer],
                                  SurfaceTypes.HoldingRnp)
        self.resultLayerList = [constructionLayer]
        self.ui.btnEvaluate.setEnabled(True)
    def method_28_BD(self):
        point3d = None
        point3d1 = None
        self.surfaceType = SurfaceTypes.GeoDetermineBD
        flag = FlightPlanBaseDlg.btnConstruct_Click(self)
        if not flag:
            return
        if define._units == QGis.Meters:
            point3d0 = self.parametersPanel.pnlStartPosBD.Point3d
            point3dF0 = self.parametersPanel.pnlFinishPosBD.Point3d

            point3d = QgisHelper.CrsTransformPoint(point3d0.get_X(),
                                                   point3d0.get_Y(),
                                                   define._latLonCrs,
                                                   define._xyCrs)
            point3d1 = QgisHelper.CrsTransformPoint(point3dF0.get_X(),
                                                    point3dF0.get_Y(),
                                                    define._latLonCrs,
                                                    define._xyCrs)
        else:
            point3d = self.parametersPanel.pnlStartPosBD.Point3d
            point3d1 = self.parametersPanel.pnlFinishPosBD.Point3d

        constructionLayer = None
        mapUnits = define._canvas.mapUnits()
        if self.parametersPanel.chbMarkPointsBD.isChecked():
            constructionLayer = AcadHelper.createVectorLayer(
                SurfaceTypes.GeoDetermineBD + "_MarkPoint", QGis.Point)
            AcadHelper.setGeometryAndAttributesInLayer(constructionLayer,
                                                       point3d)
            AcadHelper.setGeometryAndAttributesInLayer(constructionLayer,
                                                       point3d1)

            # if mapUnits == QGis.Meters:
            #     constructionLayer = QgsVectorLayer("point?crs=%s"%define._xyCrs.authid (), SurfaceTypes.GeoDetermineBD + "_MarkPoint", "memory")
            # else:
            #     constructionLayer = QgsVectorLayer("point?crs=%s"%define._latLonCrs.authid (), SurfaceTypes.GeoDetermineBD + " MarkPoint", "memory")
            #
            # shpPath = ""
            # if define.obstaclePath != None:
            #     shpPath = define.obstaclePath
            # elif define.xmlPath != None:
            #     shpPath = define.xmlPath
            # else:
            #     shpPath = define.appPath
            # er = QgsVectorFileWriter.writeAsVectorFormat(constructionLayer, shpPath + "/" + QString(SurfaceTypes.GeoDetermineBD).replace(" ", "") + "_MarkPoint" + ".shp", "utf-8", constructionLayer.crs())
            # constructionLayer = QgsVectorLayer(shpPath + "/" + QString(SurfaceTypes.GeoDetermineBD).replace(" ", "") + "_MarkPoint" + ".shp", SurfaceTypes.GeoDetermineBD + " MarkPoint", "ogr")
            #
            # constructionLayer.startEditing()
            #
            #
            # feature = QgsFeature()
            # feature.setGeometry(QgsGeometry.fromPoint(point3d))
            # constructionLayer.addFeature(feature)
            # feature.setGeometry(QgsGeometry.fromPoint(point3d1))
            # constructionLayer.addFeature(feature)
            # constructionLayer.commitChanges()
            QgisHelper.appendToCanvas(define._canvas, [constructionLayer],
                                      SurfaceTypes.GeoDetermineBD)
            self.resultLayerList.append(constructionLayer)
        if self.parametersPanel.chbDrawLineBD.isChecked():
            constructionLayer = AcadHelper.createVectorLayer(
                SurfaceTypes.GeoDetermineBD + "_Line", QGis.Line)
            AcadHelper.setGeometryAndAttributesInLayer(constructionLayer,
                                                       [point3d, point3d1])
            QgisHelper.appendToCanvas(define._canvas, [constructionLayer],
                                      SurfaceTypes.GeoDetermineBD)
            self.resultLayerList.append(constructionLayer)
    def btnConstruct_Click(self):
        flag = FlightPlanBaseDlg.btnConstruct_Click(self)
        if not flag:
            return
        mapUnits = define._canvas.mapUnits()
        constructionLayer = None

        polylines = self.method_36(True)

        if (self.parametersPanel.cmbConstruction.currentText() !=
                ConstructionType.Construct3D):
            constructionLayer = AcadHelper.createVectorLayer(
                self.surfaceType, QGis.Line)
            for polylineArea1 in polylines:
                AcadHelper.setGeometryAndAttributesInLayer(
                    constructionLayer, polylineArea1, True)
        else:
            constructionLayer = AcadHelper.createVectorLayer(
                self.surfaceType, QGis.Polygon)
            # if define._mapCrs == None:
            #     if mapUnits == QGis.Meters:
            #         constructionLayer = QgsVectorLayer("polygon?crs=EPSG:32633", self.surfaceType, "memory")
            #     else:
            #         constructionLayer = QgsVectorLayer("polygon?crs=EPSG:4326", self.surfaceType, "memory")
            # else:
            #     constructionLayer = QgsVectorLayer("polygon?crs=%s"%define._mapCrs.authid (), self.surfaceType, "memory")
            #
            # shpPath = ""
            # if define.obstaclePath != None:
            #     shpPath = define.obstaclePath
            # elif define.xmlPath != None:
            #     shpPath = define.xmlPath
            # else:
            #     shpPath = define.appPath
            # er = QgsVectorFileWriter.writeAsVectorFormat(constructionLayer, shpPath + "/" + QString(self.surfaceType).replace(" ", "") + ".shp", "utf-8", constructionLayer.crs())
            # constructionLayer = QgsVectorLayer(shpPath + "/" + QString(self.surfaceType).replace(" ", "") + ".shp", self.surfaceType, "ogr")
            #
            # constructionLayer.startEditing()
            count = len(polylines)
            num = 0.1 * count
            altitude = Altitude(float(self.parametersPanel.txtAltitude.text()),
                                AltitudeUnits.FT)
            value = Altitude(float(self.parametersPanel.txtMoc.text()),
                             AltitudeUnits.M)
            metres = altitude.Metres - value.Metres
            for i in range(count):
                polygon1 = QgsGeometry.fromPolygon(
                    [polylines[i].method_14_closed()])
                polygonNew = polygon1
                if (i > 0):
                    metres1 = altitude.Metres
                    #                     value = self.pnlMoc.Value;
                    metres = metres1 - num * value.Metres
                    num = num - 0.1
# #                 polylines[i].set_Elevation(metres);
#                 DBObjectCollection dBObjectCollection = new DBObjectCollection();
# #                 dBObjectCollection.Add(polylines[i]);
#                 Autodesk.AutoCAD.DatabaseServices.Region item = Autodesk.AutoCAD.DatabaseServices.Region.CreateFromCurves(dBObjectCollection).get_Item(0) as Autodesk.AutoCAD.DatabaseServices.Region;
#                 item.SetDatabaseDefaults();
                if (i > 0):
                    polygon0 = QgsGeometry.fromPolygon(
                        [polylines[i - 1].method_14_closed()])
                    polygonNew = polygon1.difference(polygon0)
                AcadHelper.setGeometryAndAttributesInLayer(
                    constructionLayer, PolylineArea(polygonNew.asPolygon()[0]))
            #     feature = QgsFeature()
            #     feature.setGeometry(polygonNew)
            #     constructionLayer.addFeature(feature)
            # constructionLayer.commitChanges()
        QgisHelper.appendToCanvas(define._canvas, [constructionLayer],
                                  SurfaceTypes.HoldingRnp)
        self.resultLayerList = [constructionLayer]
        self.ui.btnEvaluate.setEnabled(True)
    def btnConstruct_Click(self):
        flag = FlightPlanBaseDlg.btnConstruct_Click(self)

        if not flag:
            return

        if not self.method_27():
            return

        holdingTemplate = HoldingTemplate(
            self.parametersPanel.pnlNavAid.Point3d,
            float(self.parametersPanel.txtTrack.Value),
            self.parametersPanel.txtIas.Value,
            self.parametersPanel.txtAltitude.Value,
            Speed(float(self.parametersPanel.pnlWind.speedBox.text())),
            float(self.parametersPanel.txtIsa.Value),
            float(self.parametersPanel.txtTime.Value),
            self.parametersPanel.cmbOrientation.SelectedItem)
        polylineArea2 = self.method_35()
        polylineAreaTemp = holdingTemplate.vmethod_0(
            polylineArea2, self.parametersPanel.chbIntercept.Checked,
            self.parametersPanel.chbSectors12.Checked)
        polylineArea3 = polylineAreaTemp[0]

        polyline = PolylineArea.smethod_131(holdingTemplate.Nominal)
        resultPolylineAreaList = []

        if (self.parametersPanel.cmbConstruction.SelectedIndex == 0):
            constructionLayer = AcadHelper.createVectorLayer(self.surfaceType)
            resultPolylineAreaList.append(polylineArea3)
            resultPolylineAreaList.append(
                PolylineArea.smethod_136(polylineArea2, True))
            if (self.parametersPanel.cmbUsedFor.SelectedIndex == 1
                    or self.parametersPanel.chbCatH.Checked):
                for entity in HoldingTemplateBase.smethod_2(
                        polylineArea3,
                        Distance(2.5, DistanceUnits.NM) if
                    (self.parametersPanel.cmbUsedFor.SelectedIndex
                     == 1) else Distance(2, DistanceUnits.NM)):
                    resultPolylineAreaList.append(entity)
            else:
                for entity1 in HoldingTemplateBase.smethod_1(
                        polylineArea3, True):
                    resultPolylineAreaList.append(entity1)
            if self.parametersPanel.cmbOrientation.SelectedIndex == 0:
                polyline[0].bulge = -1
                polyline[2].bulge = -1
            else:
                polyline[0].bulge = 1
                polyline[2].bulge = 1

            resultPolylineAreaList.append(polyline)
            resultPolylineList = []

            for polylineArea in resultPolylineAreaList:
                AcadHelper.setGeometryAndAttributesInLayer(
                    constructionLayer, polylineArea, True)

            QgisHelper.appendToCanvas(define._canvas, [constructionLayer],
                                      self.surfaceType, True)
            QgisHelper.zoomToLayers([constructionLayer])
            self.resultLayerList = [constructionLayer]
        else:
            constructionLayer = AcadHelper.createVectorLayer(
                self.surfaceType, QGis.Polygon)
            geometryList = []
            if (self.parametersPanel.cmbUsedFor.SelectedIndex == 1):
                distance = Distance(2.5, DistanceUnits.NM) if (
                    self.parametersPanel.cmbUsedFor.SelectedIndex
                    == 1) else Distance(2, DistanceUnits.NM)
                polylineArea, polylineArea1 = HoldingTemplateBase.smethod_4(
                    polylineArea3, self.parametersPanel.txtAltitude.Value,
                    self.parametersPanel.txtMoc.Value, distance)
                geometryList = QgisHelper.smethod_146(
                    polylineArea.method_15(True),
                    polylineArea1.method_15(True))
            else:
                geometryList = HoldingTemplateBase.smethod_3(
                    polylineArea3, self.parametersPanel.txtAltitude.Value,
                    self.parametersPanel.txtMoc.Value)

            i = 0
            for entity2 in geometryList:
                i += 1
                AcadHelper.setGeometryAndAttributesInLayer(
                    constructionLayer,
                    PolylineArea(geometryList[len(geometryList) -
                                              i].asPolygon()[0]))

            AcadHelper.setGeometryAndAttributesInLayer(constructionLayer,
                                                       polyline, True)

            QgisHelper.appendToCanvas(define._canvas, [constructionLayer],
                                      self.surfaceType, True)
            QgisHelper.zoomToLayers([constructionLayer])
            self.resultLayerList = [constructionLayer]
        self.ui.btnEvaluate.setEnabled(True)
        pass
Beispiel #12
0
    def btnConstruct_Click(
            self):  ### ---------------  Import  ---------------------###

        return FlightPlanBaseDlg.btnConstruct_Click(self)
    def btnConstruct_Click(self):
        flag = FlightPlanBaseDlg.btnConstruct_Click(self)
        if not flag:
            return
        self.complexObstacleArea = ComplexObstacleArea()
        num = None;
        num1 = None;
        num2 = None;
        num3 = None;
        line = None;
#         if (!AcadHelper.Ready)
#         {
#             return;
#         }
#         if (!self.method_27(true))
#         {
#             return;
#         }
        constructionLayer = None;
        nominalTrackLayer = None;
        mapUnits = define._canvas.mapUnits()
        
        point3d = self.parametersPanel.pnlNavAid.Point3d;
        metres = Altitude(float(self.parametersPanel.txtStartAltitude.text())).Metres;
        metres1 = Altitude(float(self.parametersPanel.txtPrimaryMOC.text())).Metres;
        percent = float(self.parametersPanel.txtAltitudeChange.text());
        num4 = Unit.ConvertDegToRad(float(self.parametersPanel.txtTrackRadial.Value));
        metres2 = Distance(float(self.parametersPanel.txtDistStart.text()), DistanceUnits.NM).Metres;
        metres3 = Distance(float(self.parametersPanel.txtDistFinish.text()), DistanceUnits.NM).Metres;

        nominalTrackLayer = AcadHelper.createNominalTrackLayer([MathHelper.distanceBearingPoint(point3d, num4, metres2), MathHelper.distanceBearingPoint(point3d, num4, metres3)], None, "memory", "NominalTrack_" + self.surfaceType.replace(" ", "_").replace("-", "_"))

        if (self.parametersPanel.cmbNavAidType.SelectedIndex != 0):
            num = Unit.ConvertDegToRad(6.2);
            num1 = Unit.ConvertDegToRad(6.9);
            num2 = Unit.ConvertDegToRad(10.3);
        else:
            num = Unit.ConvertDegToRad(4.5);
            num1 = Unit.ConvertDegToRad(5.2);
            num2 = Unit.ConvertDegToRad(7.8);
        if (self.parametersPanel.cmbNavAidType.SelectedIndex != 0):
            num3 = 2315 if(self.parametersPanel.cmbToleranceType.currentIndex() != 2 or not self.parametersPanel.chbOverhead.isChecked()) else 4630;
        else:
            num3 = 1900 if(self.parametersPanel.cmbToleranceType.currentIndex() != 2 or not self.parametersPanel.chbOverhead.isChecked()) else 3704;
        num5 = num4 + num;
        num6 = num4 - num;
        num7 = num4 + num1;
        num8 = num4 - num1;
        num9 = num4 + num2;
        num10 = num4 - num2;
        num11 = num4 + Unit.ConvertDegToRad(90);
        num12 = num4 - Unit.ConvertDegToRad(90);
        num13 = metres2 / math.cos(num);
        num14 = metres2 / math.cos(num1);
        num15 = metres2 / math.cos(num2);
        num16 = metres3 / math.cos(num);
        num17 = metres3 / math.cos(num1);
        num18 = metres3 / math.cos(num2);
        point3d1 = MathHelper.distanceBearingPoint(point3d, num4, metres2);
        point3d2 = MathHelper.distanceBearingPoint(point3d, num4, metres3);
        point3d3 = MathHelper.distanceBearingPoint(point3d, num12, num3);
        point3d4 = MathHelper.distanceBearingPoint(point3d, num11, num3);
        point3d5 = MathHelper.distanceBearingPoint(point3d4, num9, num15);
        point3d6 = MathHelper.distanceBearingPoint(point3d3, num10, num15);
        num19 = MathHelper.calcDistance(point3d1, point3d5) / 2;
        point3d7 = MathHelper.distanceBearingPoint(point3d1, num12, num19);
        point3d8 = MathHelper.distanceBearingPoint(point3d1, num11, num19);
        point3d9 = MathHelper.distanceBearingPoint(point3d3, num10, num18);
        point3d10 = MathHelper.distanceBearingPoint(point3d4, num9, num18);
        num20 = MathHelper.calcDistance(point3d2, point3d10) / 2;
        point3d11 = MathHelper.distanceBearingPoint(point3d2, num12, num20);
        point3d12 = MathHelper.distanceBearingPoint(point3d2, num11, num20);
        
        resultPoint3dArrayList = []
        
        
        if (self.parametersPanel.cmbToleranceType.currentIndex() == 0):
            resultPoint3dArrayList.append([point3d1, point3d2])
            resultPoint3dArrayList.append([MathHelper.distanceBearingPoint(point3d, num5, num16), MathHelper.distanceBearingPoint(point3d, num5, num13)])
            resultPoint3dArrayList.append([MathHelper.distanceBearingPoint(point3d, num5, num13), MathHelper.distanceBearingPoint(point3d, num6, num13)]);
            resultPoint3dArrayList.append([MathHelper.distanceBearingPoint(point3d, num6, num13), MathHelper.distanceBearingPoint(point3d, num6, num16)]);
            resultPoint3dArrayList.append([MathHelper.distanceBearingPoint(point3d, num6, num16), MathHelper.distanceBearingPoint(point3d, num5, num16)]);

            polylineArea0 = PolylineArea([MathHelper.distanceBearingPoint(point3d, num5, num16), MathHelper.distanceBearingPoint(point3d, num5, num13), MathHelper.distanceBearingPoint(point3d, num6, num13), MathHelper.distanceBearingPoint(point3d, num6, num16), MathHelper.distanceBearingPoint(point3d, num6, num16), MathHelper.distanceBearingPoint(point3d, num5, num16)])
            self.complexObstacleArea.Add(PrimaryObstacleArea(polylineArea0))
        elif (self.parametersPanel.cmbToleranceType.currentIndex() == 1):
            resultPoint3dArrayList.append([point3d1, point3d2]);
            resultPoint3dArrayList.append([MathHelper.distanceBearingPoint(point3d, num7, num17), MathHelper.distanceBearingPoint(point3d, num7, num14)]);
            resultPoint3dArrayList.append([MathHelper.distanceBearingPoint(point3d, num7, num14), MathHelper.distanceBearingPoint(point3d, num8, num14)]);
            resultPoint3dArrayList.append([MathHelper.distanceBearingPoint(point3d, num8, num14), MathHelper.distanceBearingPoint(point3d, num8, num17)]);
            resultPoint3dArrayList.append([MathHelper.distanceBearingPoint(point3d, num8, num17), MathHelper.distanceBearingPoint(point3d, num7, num17)]);
            polylineArea0 = PolylineArea([MathHelper.distanceBearingPoint(point3d, num7, num17), MathHelper.distanceBearingPoint(point3d, num7, num14), MathHelper.distanceBearingPoint(point3d, num8, num14), MathHelper.distanceBearingPoint(point3d, num8, num17), MathHelper.distanceBearingPoint(point3d, num8, num17), MathHelper.distanceBearingPoint(point3d, num7, num17)])
            self.complexObstacleArea.Add(PrimaryObstacleArea(polylineArea0))
        elif (self.parametersPanel.cmbToleranceType.currentIndex() == 2):
            if (self.parametersPanel.cmbConstructionType.currentText() != ConstructionType.Construct2D):
                num21 = metres - metres1;
                num22 = percent / 100;
                num23 = num21 + (metres3 - metres2) * num22;
                num24 = metres + (metres3 - metres2) * num22;
                point3d5 = point3d5.smethod_167(metres);
                point3d6 = point3d6.smethod_167(metres);
                point3d9 = point3d9.smethod_167(num24);
                point3d10 = point3d10.smethod_167(num24);
                point3d8 = point3d8.smethod_167(num21);
                point3d12 = point3d12.smethod_167(num23);
                point3d7 = point3d7.smethod_167(num21);
                point3d11 = point3d11.smethod_167(num23);
                point3d1 = point3d1.smethod_167(metres);
                point3d2 = point3d2.smethod_167(num24);
                resultPoint3dArrayList.append([point3d8, point3d5, point3d10, point3d12]);
                resultPoint3dArrayList.append([point3d8, point3d12, point3d11, point3d7]);
                resultPoint3dArrayList.append([point3d7, point3d11, point3d9, point3d6]);

                self.complexObstacleArea.Add(PrimaryObstacleArea(PolylineArea([point3d8, point3d12, point3d11, point3d7, point3d8])))
                self.complexObstacleArea.Add(SecondaryObstacleArea(point3d8, point3d5, point3d10, point3d12))
                self.complexObstacleArea.Add(SecondaryObstacleArea(point3d7, point3d11, point3d9, point3d6))
            else:
                resultPoint3dArrayList.append([point3d1, point3d2]);
#                 AcadHelper.smethod_18(transaction, blockTableRecord, line, constructionLayer);
                resultPoint3dArrayList.append([point3d6, point3d5]);
#                 AcadHelper.smethod_18(transaction, blockTableRecord, line, constructionLayer);
                resultPoint3dArrayList.append([point3d5, point3d10]);
#                 AcadHelper.smethod_18(transaction, blockTableRecord, line, constructionLayer);
                resultPoint3dArrayList.append([point3d10, point3d9]);
#                 AcadHelper.smethod_18(transaction, blockTableRecord, line, constructionLayer);
                resultPoint3dArrayList.append([point3d9, point3d6]);
#                 AcadHelper.smethod_18(transaction, blockTableRecord, line, constructionLayer);
                resultPoint3dArrayList.append([point3d7, point3d11]);
#                 AcadHelper.smethod_18(transaction, blockTableRecord, line, constructionLayer);
                resultPoint3dArrayList.append([point3d8, point3d12]);
#                 AcadHelper.smethod_18(transaction, blockTableRecord, line, constructionLayer);
                num21 = metres - metres1;
                num22 = percent / 100;
                num23 = num21 + (metres3 - metres2) * num22;
                num24 = metres + (metres3 - metres2) * num22;
                point3d5 = point3d5.smethod_167(0);
                point3d6 = point3d6.smethod_167(0);
                point3d9 = point3d9.smethod_167(0);
                point3d10 = point3d10.smethod_167(0);
                point3d8 = point3d8.smethod_167(0);
                point3d12 = point3d12.smethod_167(0);
                point3d7 = point3d7.smethod_167(0);
                point3d11 = point3d11.smethod_167(0);
                point3d1 = point3d1.smethod_167(0);
                point3d2 = point3d2.smethod_167(0);
                # resultPoint3dArrayList.append([point3d8, point3d5, point3d10, point3d12]);
                # resultPoint3dArrayList.append([point3d8, point3d12, point3d11, point3d7]);
                # resultPoint3dArrayList.append([point3d7, point3d11, point3d9, point3d6]);

                self.complexObstacleArea.Add(PrimaryObstacleArea(PolylineArea([point3d8, point3d12, point3d11, point3d7, point3d8])))
                self.complexObstacleArea.Add(SecondaryObstacleArea(point3d12, point3d8, point3d10, point3d5, MathHelper.getBearing(point3d8, point3d12)))
                self.complexObstacleArea.Add(SecondaryObstacleArea(point3d11, point3d7, point3d9, point3d6, MathHelper.getBearing(point3d7, point3d11)))
        if self.parametersPanel.cmbConstructionType.currentText() == ConstructionType.Construct2D:
            constructionLayer = AcadHelper.createVectorLayer(self.surfaceType)
            for point3dArray in resultPoint3dArrayList:
                AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, point3dArray)
        else:
            constructionLayer = AcadHelper.createVectorLayer(self.surfaceType, QGis.Polygon)
            # if define._mapCrs == None:
            #     if mapUnits == QGis.Meters:
            #         constructionLayer = QgsVectorLayer("polygon?crs=EPSG:32633", self.surfaceType, "memory")
            #     else:
            #         constructionLayer = QgsVectorLayer("polygon?crs=EPSG:4326", self.surfaceType, "memory")
            # else:
            #     constructionLayer = QgsVectorLayer("polygon?crs=%s"%define._mapCrs.authid (), self.surfaceType, "memory")
            # constructionLayer.startEditing()
            for point3dArray in resultPoint3dArrayList:
                AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, PolylineArea(point3dArray).method_14_closed())
            #     polygon = QgsGeometry.fromPolygon([point3dArray])
            #     feature = QgsFeature()
            #     feature.setGeometry(polygon)
            #     constructionLayer.addFeature(feature)
            # constructionLayer.commitChanges()
        QgisHelper.appendToCanvas(define._canvas, [constructionLayer, nominalTrackLayer], self.surfaceType)
        self.resultLayerList = [constructionLayer, nominalTrackLayer]
        QgisHelper.zoomToLayers(self.resultLayerList)
        self.ui.btnEvaluate.setEnabled(True)
        self.manualEvent(self.parametersPanel.cmbSelectionMode.currentIndex())
Beispiel #14
0
    def btnConstruct_Click(self):
        flag = FlightPlanBaseDlg.btnConstruct_Click(self)
        if not flag:
            return
        if not self.method_27():
            return
        holdingTemplate = HoldingTemplate(
            self.parametersPanel.pnlNavAid.Point3d,
            float(self.parametersPanel.txtTrack.Value),
            self.parametersPanel.txtIas.Value,
            self.parametersPanel.txtAltitude.Value,
            Speed(float(self.parametersPanel.pnlWind.speedBox.text())),
            float(self.parametersPanel.txtIsa.Value),
            float(self.parametersPanel.txtTime.Value),
            self.parametersPanel.cmbOrientation.SelectedItem)
        polylineArea2 = self.method_35()
        polylineAreaTemp = holdingTemplate.vmethod_0(
            polylineArea2, self.parametersPanel.chbIntercept.Checked,
            self.parametersPanel.chbSectors12.Checked)
        polylineArea3 = polylineAreaTemp[0]

        polyline = PolylineArea.smethod_131(holdingTemplate.Nominal)
        resultPolylineAreaList = []

        if (self.parametersPanel.cmbConstruction.SelectedIndex == 0):
            constructionLayer = AcadHelper.createVectorLayer(self.surfaceType)
            resultPolylineAreaList.append(polylineArea3)
            resultPolylineAreaList.append(
                PolylineArea.smethod_136(polylineArea2, True))
            if (self.parametersPanel.cmbUsedFor.SelectedIndex == 1
                    or self.parametersPanel.chbCatH.Checked):
                for entity in HoldingTemplateBase.smethod_2(
                        polylineArea3,
                        Distance(2.5, DistanceUnits.NM) if
                    (self.parametersPanel.cmbUsedFor.SelectedIndex
                     == 1) else Distance(2, DistanceUnits.NM)):
                    resultPolylineAreaList.append(entity)
            else:
                for entity1 in HoldingTemplateBase.smethod_1(
                        polylineArea3, True):
                    resultPolylineAreaList.append(entity1)
            if self.parametersPanel.cmbOrientation.SelectedIndex == 0:
                polyline[0].bulge = -1
                polyline[2].bulge = -1
            else:
                polyline[0].bulge = 1
                polyline[2].bulge = 1
            resultPolylineAreaList.append(polyline)
            resultPolylineList = []
            for polylineArea in resultPolylineAreaList:
                AcadHelper.setGeometryAndAttributesInLayer(
                    constructionLayer, polylineArea, True)
            #     point3dCollection = []
            #     for polylineAreaPoint in polylineArea:
            #
            #         point3dCollection.append(polylineAreaPoint.Position)
            #     resultPolylineList.append((point3dCollection, []))
            # constructionLayer = QgisHelper.createPolylineLayer(self.surfaceType, resultPolylineList)
            QgisHelper.appendToCanvas(define._canvas, [constructionLayer],
                                      self.surfaceType, True)
            QgisHelper.zoomToLayers([constructionLayer])
            self.resultLayerList = [constructionLayer]
        else:
            #             polyline.set_Elevation(self.pnlAltitude.Value.Metres);
            #             polyline.set_Thickness(-self.pnlMoc.Value.Metres);
            constructionLayer = AcadHelper.createVectorLayer(
                self.surfaceType, QGis.Polygon)
            # mapUnits = define._canvas.mapUnits()
            # constructionLayer = None
            # if define._mapCrs == None:
            #     if mapUnits == QGis.Meters:
            #         constructionLayer = QgsVectorLayer("polygon?crs=EPSG:32633", self.surfaceType, "memory")
            #     else:
            #         constructionLayer = QgsVectorLayer("polygon?crs=EPSG:4326", self.surfaceType, "memory")
            # else:
            #     constructionLayer = QgsVectorLayer("polygon?crs=%s"%define._mapCrs.authid (), self.surfaceType, "memory")
            # shpPath = ""
            # if define.obstaclePath != None:
            #     shpPath = define.obstaclePath
            # elif define.xmlPath != None:
            #     shpPath = define.xmlPath
            # else:
            #     shpPath = define.appPath
            # er = QgsVectorFileWriter.writeAsVectorFormat(constructionLayer, shpPath + "/" + QString(self.surfaceType).replace(" ", "") + ".shp", "utf-8", constructionLayer.crs())
            # constructionLayer = QgsVectorLayer(shpPath + "/" + QString(self.surfaceType).replace(" ", "") + ".shp", self.surfaceType, "ogr")
            #
            #
            # constructionLayer.startEditing()
            geometryList = []
            if (self.parametersPanel.cmbUsedFor.SelectedIndex == 1):
                distance = Distance(2.5, DistanceUnits.NM) if (
                    self.parametersPanel.cmbUsedFor.SelectedIndex
                    == 1) else Distance(2, DistanceUnits.NM)
                polylineArea, polylineArea1 = HoldingTemplateBase.smethod_4(
                    polylineArea3, self.parametersPanel.txtAltitude.Value,
                    self.parametersPanel.txtMoc.Value, distance)
                #                 point3dCollection = polylineArea.method_15(False)
                #                 point3dCollection1 = polylineArea1.method_15(False)
                geometryList = QgisHelper.smethod_146(
                    polylineArea.method_15(True),
                    polylineArea1.method_15(True))

            else:
                geometryList = HoldingTemplateBase.smethod_3(
                    polylineArea3, self.parametersPanel.txtAltitude.Value,
                    self.parametersPanel.txtMoc.Value)

            # feature = QgsFeature()
            # feature.setGeometry(QgsGeometry.fromPolygon([polyline.method_14_closed()]))
            # constructionLayer.addFeature(feature)
            i = 0
            for entity2 in geometryList:
                i += 1
                AcadHelper.setGeometryAndAttributesInLayer(
                    constructionLayer,
                    PolylineArea(geometryList[len(geometryList) -
                                              i].asPolygon()[0]))
                # feature = QgsFeature()
                # feature.setGeometry(entity2)
                # constructionLayer.addFeature(feature)
            AcadHelper.setGeometryAndAttributesInLayer(constructionLayer,
                                                       polyline, True)

            # constructionLayer.commitChanges()
            QgisHelper.appendToCanvas(define._canvas, [constructionLayer],
                                      self.surfaceType, True)
            QgisHelper.zoomToLayers([constructionLayer])
            self.resultLayerList = [constructionLayer]
        self.ui.btnEvaluate.setEnabled(True)
        #                     AcadHelper.smethod_18(transaction, blockTableRecord, entity2, constructionLayer);
        pass