def nominal2Layer(self):
        resultLayer = AcadHelper.createVectorLayer(
            "NominalTrack_" +
            self.surfaceType.replace(" ", "_").replace("-", "_"), QGis.Line)
        startPoint3d = self.parametersPanel.pnlRwyStart.Point3d
        derPoint3d = self.parametersPanel.pnlDer.Point3d
        bearing = MathHelper.getBearing(startPoint3d, derPoint3d)
        derPoint3d1 = MathHelper.distanceBearingPoint(derPoint3d, bearing, 100)
        derPoint3d2 = MathHelper.distanceBearingPoint(derPoint3d, bearing,
                                                      self.circleArea[0].bulge)
        geom = QgsGeometry.fromPolyline(self.area123).intersection(
            QgsGeometry.fromPolyline([derPoint3d1, derPoint3d2]))
        intersectionPoint1 = geom.asPoint()

        derPoint3d1 = MathHelper.distanceBearingPoint(derPoint3d, bearing, 100)
        bearing = MathHelper.smethod_4(bearing + math.pi)
        derPoint3d2 = MathHelper.distanceBearingPoint(
            derPoint3d, bearing,
            MathHelper.calcDistance(derPoint3d, startPoint3d) + 200)
        geom = QgsGeometry.fromPolyline(
            PolylineArea(self.area123).method_14_closed()).intersection(
                QgsGeometry.fromPolyline([derPoint3d1, derPoint3d2]))
        intersectionPoint2 = geom.asPoint()
        AcadHelper.setGeometryAndAttributesInLayer(
            resultLayer, [intersectionPoint1, derPoint3d])

        return resultLayer
    def resultSelectedFeatureByRectTasDraw(self, geom, distance,
                                           direction_bearing):
        # flag = FlightPlanBaseSimpleDlg.btnConstruct_Click(self)
        # if not flag:
        #     return
        if define._userLayers == None:
            mapUnits = define._canvas.mapUnits()
            constructionLayer = AcadHelper.createVectorLayer(
                "Lines", QGis.Line)
            AcadHelper.setGeometryAndAttributesInLayer(
                constructionLayer, geom.asPolyline(), False,
                {"Caption": str(round(distance, 4)) + "m"})

            define._userLayers = constructionLayer
            palSetting = QgsPalLayerSettings()
            palSetting.readFromLayer(constructionLayer)
            palSetting.enabled = True
            palSetting.fieldName = "Caption"
            palSetting.isExpression = True
            palSetting.placement = QgsPalLayerSettings.Line
            palSetting.placementFlags = QgsPalLayerSettings.AboveLine
            palSetting.setDataDefinedProperty(QgsPalLayerSettings.Size, True,
                                              True, '8', "")
            palSetting.writeToLayer(constructionLayer)
            QgisHelper.appendToCanvas(define._canvas, [constructionLayer],
                                      "Users layer", True)
            # self.resultLayerList = [constructionLayer]
        else:

            # constructionLayer = AcadHelper.createVectorLayer("Lines", QGis.Line)
            constructionLayer = define._userLayers
            iter = define._userLayers.getFeatures()
            equalFlag = 0
            for feat in iter:
                # AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, feat)
                if geom.equals(feat.geometry()):
                    equalFlag += 1
            if equalFlag <= 0:
                AcadHelper.setGeometryAndAttributesInLayer(
                    constructionLayer, geom.asPolyline(), False,
                    {"Caption": str(round(distance, 4)) + "m"})

            palSetting = QgsPalLayerSettings()
            palSetting.readFromLayer(constructionLayer)
            palSetting.enabled = True
            palSetting.fieldName = "Caption"
            palSetting.isExpression = True
            palSetting.placement = QgsPalLayerSettings.Line
            palSetting.placementFlags = QgsPalLayerSettings.AboveLine
            palSetting.setDataDefinedProperty(QgsPalLayerSettings.Size, True,
                                              True, '8', "")
            palSetting.writeToLayer(constructionLayer)
            # QgisHelper.appendToCanvas(define._canvas,[constructionLayer], "Users layer", True)
            # self.resultLayerList = [constructionLayer]
            QgisHelper.zoomToLayers([constructionLayer])
            define._userLayers = constructionLayer
        pass
 def imethod_1(self, layers):
     resultLayer = AcadHelper.createVectorLayer(
         "Pins Visual Segment Departure")
     AcadHelper.setGeometryAndAttributesInLayer(
         resultLayer, self.paOIS, True,
         {"Surface": PinsSurfaceType.PinsSurfaceType_OIS})
     # pointList = self.paOIS.method_14_closed()
     # resultLayer = QgisHelper.createPolylineLayer("Pins Visual Segment Departure",
     #                                               [(pointList, [("surface", PinsSurfaceType.PinsSurfaceType_OIS)])],
     #                                               [QgsField("surface", QVariant.String)])
     layers.append(resultLayer)
    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 AreaResult(self, area, rubberBand):
        if area != None:
            rubberBand.setFillColor( QColor(46, 64, 142, 100) )
            rubberBand.setBorderColor( QColor(0, 10, 238) )
            define._canvas.refresh()

            QgisHelper.ClearRubberBandInCanvas(define._canvas)
            self.complexObstacleArea.Add(area)
            self.stdItemModel.setItem(self.itemCount, QStandardItem(area.ToString()))
            # polygon  = rubberBand.asGeometry()
            # lineList = polygon.asPolygon()
            # self.resultPolylineAreaListForDrawing.append(PolylineArea(lineList[0]))
            self.itemCount += 1

            AcadHelper.setGeometryAndAttributesInLayer(self.constructionLayer, area.PreviewArea, True)
    def __init__(self, parent):
        QDialog.__init__(self, parent)
        self.ui = Ui_DlgComplexAreas()
        self.ui.setupUi(self)

        self.stdItemModel = QStandardItemModel()
        self.ui.lstAreas.setModel(self.stdItemModel)

              
        ''' buttons clicked connect '''
        self.ui.btnAddPrimaryArea.clicked.connect(self.btnAddPrimaryArea_Click)
        self.ui.btnAddSecondaryArea.clicked.connect(self.btnAddSecondaryArea_Click)
        self.ui.btnRemove.clicked.connect(self.btnRemove_Click)
        self.ui.btnCaptureTrack.clicked.connect(self.btnCaptureTrack_Click)
        self.ui.buttonBoxOkCancel.accepted.connect(self.acceptEvent)
        self.ui.buttonBoxOkCancel.rejected.connect(self.rejectedEvent)
        self.ui.txtTrack.textChanged.connect(self.txtTrack_TextChanged)
        self.ui.lstAreas.clicked.connect(self.lstAreas_Click)

        self.ui.btnCaptureTrack.clicked.connect(self.captureTrack)

        self.complexObstacleArea = ComplexObstacleArea()
        self.itemCount = 0
        self.selectedModelIndex = None
        self.resultPolylineAreaListForDrawing = []
        self.method_9()


        self.constructionLayer = AcadHelper.createVectorLayer("TempComplexObstacleAreaLayer");
        QgisHelper.appendToCanvas(define._canvas, [self.constructionLayer], "Temp")
    def btnRemove_Click(self):
        if self.selectedModelIndex != None:
            if QMessageBox.question(self, "Question", "Do you want to remove the selected item?", QMessageBox.Ok | QMessageBox.Cancel) == QMessageBox.Ok:
                n = self.selectedModelIndex.row()

                self.complexObstacleArea.pop(n)
                self.stdItemModel.removeRow(self.selectedModelIndex.row())
                self.itemCount -= 1

                self.constructionLayer = AcadHelper.createVectorLayer("TempComplexObstacleAreaLayer")
                for area in self.complexObstacleArea:
                    AcadHelper.setGeometryAndAttributesInLayer(self.constructionLayer, area.PreviewArea, True)
                QgisHelper.appendToCanvas(define._canvas, [self.constructionLayer], "Temp")
                QgisHelper.ClearRubberBandInCanvas(define._canvas)



            pass
    def imethod_2(self, layers):
        resultLayer = AcadHelper.createVectorLayer(
            "Pins Visual Segment Departure")

        if (self.paOIS.Count == 4):

            face = [
                self.paOIS[0].Position, self.paOIS[1].Position,
                self.paOIS[2].Position, self.paOIS[3].Position,
                self.paOIS[0].Position
            ]
            # resultLayer = QgisHelper.createPolylineLayer("Pins Visual Segment Departure",
            #                                              [(face, [("surface", PinsSurfaceType.PinsSurfaceType_OIS)])],
            #                                              [QgsField("surface", QVariant.String)])
            AcadHelper.setGeometryAndAttributesInLayer(
                resultLayer, face, False,
                {"Surface": PinsSurfaceType.PinsSurfaceType_OIS})

            layers.append(resultLayer)
            return

        linesList = []
        face = [
            self.paOIS[0].Position, self.paOIS[1].Position,
            self.paOIS[4].Position, self.paOIS[5].Position,
            self.paOIS[0].Position
        ]
        AcadHelper.setGeometryAndAttributesInLayer(
            resultLayer, face, False,
            {"Surface": PinsSurfaceType.PinsSurfaceType_OIS})

        linesList.append(
            (face, [("surface", PinsSurfaceType.PinsSurfaceType_OIS)]))
        face = [
            self.paOIS[1].Position, self.paOIS[2].Position,
            self.paOIS[3].Position, self.paOIS[4].Position,
            self.paOIS[1].Position
        ]
        AcadHelper.setGeometryAndAttributesInLayer(
            resultLayer, face, False,
            {"Surface": PinsSurfaceType.PinsSurfaceType_OIS})

        linesList.append(
            (face, [("surface", PinsSurfaceType.PinsSurfaceType_OIS)]))
        # resultLayer = QgisHelper.createPolylineLayer("Pins Visual Segment Departure", linesList, [QgsField("surface", QVariant.String)])
        layers.append(resultLayer)
    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
    def btnConstruct_Click(self):
        flag = FlightPlanBaseSimpleDlg.btnConstruct_Click(self)
        if not flag:
            return
        constructionLayer = AcadHelper.createVectorLayer(SurfaceTypes.DmeTolerance, QGis.Line)
        point3d1 = self.parametersPanel.pnlDME.Point3d
        circleAreaList = []
        
#         length = self.groundDistance.Metres / 5
# #         rectangle = QgsRectangle(point3d1.get_X() - length / 2, point3d1.get_Y() - length / 2, point3d1.get_X() + length / 2, point3d1.get_Y() + length / 2,)
#         point1 = Point3D(point3d1.get_X() - length / 2, point3d1.get_Y() + length / 2)
#         point2 = Point3D(point3d1.get_X() - length / 2, point3d1.get_Y() - length / 2)
        captionCircleLine = []
        centerPoint = None
        radius = 0.0
        arc = None;
        resultPoint3dArrayList = []
        if (self.groundDistance.Metres > 0):
            metres = self.dmeTolerance.valueMetres / 1.7;
            if (self.parametersPanel.cmbConstructionType.currentIndex() != 0):
                num1 = Unit.ConvertDegToRad(float(self.parametersPanel.pnlRadial.Value));
                num2 = math.asin(min([1 / self.groundDistance.NauticalMiles, 1]));
                num3 = num1 + num2
                num4 = num1 - num2
                # arc = PolylineArea()
                # arc.Add(PolylineAreaPoint(point3d1, self.groundDistance.Metres))
                arc = MathHelper.constructArc(point3d1, self.groundDistance.Metres, num3, num4, 30);
                point3d = MathHelper.distanceBearingPoint(point3d1, num1, self.groundDistance.Metres);
                
                captionCircleLine = [MathHelper.distanceBearingPoint(point3d, MathHelper.getBearing(point3d, point3d1) + math.pi / 2, self.groundDistance.Metres / 20), MathHelper.distanceBearingPoint(point3d, MathHelper.getBearing(point3d, point3d1) - math.pi / 2, self.groundDistance.Metres / 20)]
                num = -num1;
                if (self.parametersPanel.chbDrawRadial.isChecked()):
                    line = PolylineArea([point3d1, point3d]);
                    resultPoint3dArrayList.append([point3d1, point3d])
#                     AcadHelper.smethod_18(transaction, blockTableRecord, line, constructionLayer);
            else:
                arc = MathHelper.constructCircle(point3d1, self.groundDistance.Metres, 50);
                circleAreaList.append(PolylineArea(None, point3d1, self.groundDistance.Metres))
                centerPoint = point3d1
                radius = self.groundDistance.Metres
                point3d = MathHelper.distanceBearingPoint(point3d1, 0, self.groundDistance.Metres);
                
                length = self.groundDistance.Metres / 5
#                 rectangle = QgsRectangle(point3d1.get_X() - length / 2, point3d1.get_Y() - length / 2, point3d1.get_X() + length / 2, point3d1.get_Y() + length / 2,)
                point1 = MathHelper.distanceBearingPoint(point3d, Unit.ConvertDegToRad(270), length / 4)#Point3D(point3d.get_X() - length / 4, point3d.get_Y())
                point2 = MathHelper.distanceBearingPoint(point3d, Unit.ConvertDegToRad(90), length / 4)#Point3D(point3d.get_X() + length / 4, point3d.get_Y())
                captionCircleLine = [point1, point2]
                num = 0;
            resultPoint3dArrayList.append(arc)
#             AcadHelper.smethod_18(transaction, blockTableRecord, arc, constructionLayer);
            if (self.parametersPanel.chbWriteText.isChecked()):
                nauticalMiles = self.groundDistance.NauticalMiles;
#                 DBText dBText = AcadHelper.smethod_138(string.Format("{0} DME", nauticalMiles.ToString("0.#")), point3d, metres, 1);
#                 dBText.set_Rotation(num);
#                 AcadHelper.smethod_18(transaction, blockTableRecord, dBText, constructionLayer);
        if (self.parametersPanel.chbDrawDmeTol.isVisible() and self.parametersPanel.chbDrawDmeTol.isChecked() and self.dmeTolerance.IsValid() and arc != None):
            offsetCurf = QgisHelper.offsetCurve(arc, self.dmeTolerance.Metres)
            if self.parametersPanel.cmbConstructionType.currentIndex() == 0:
                circleAreaList.append(PolylineArea(None, centerPoint, radius + self.dmeTolerance.Metres))
            if (self.parametersPanel.cmbConstructionType.currentIndex() == 0):
                endPoint = offsetCurf[0]
                offsetCurf.append(endPoint)
            resultPoint3dArrayList.append(offsetCurf)
#             foreach (Entity offsetCurf in arc.GetOffsetCurves(self.dmeTolerance.Metres))
#             {
#                 AcadHelper.smethod_19(transaction, blockTableRecord, offsetCurf, constructionLayer, 5);
#             }
            entity = QgisHelper.offsetCurve(arc, -(self.dmeTolerance.Metres + self.slantTolerance.Metres))
            if self.parametersPanel.cmbConstructionType.currentIndex() == 0:
                circleAreaList.append(PolylineArea(None, centerPoint, radius -(self.dmeTolerance.Metres + self.slantTolerance.Metres)))
            if (self.parametersPanel.cmbConstructionType.currentIndex() == 0):
                endPoint = entity[0]
                entity.append(endPoint)
            resultPoint3dArrayList.append(entity)
#             foreach (Entity entity in arc.GetOffsetCurves(-(self.dmeTolerance.Metres + self.slantTolerance.Metres)))
#             {
#                 AcadHelper.smethod_19(transaction, blockTableRecord, entity, constructionLayer, 5);
#             }
#         }
        if (self.parametersPanel.chbDrawSlantTol.isVisible() and self.parametersPanel.chbDrawSlantTol.isChecked() and self.slantTolerance.IsValid() and arc != None):
            offsetCurf1 = QgisHelper.offsetCurve(arc, -self.slantTolerance.Metres)
            if self.parametersPanel.cmbConstructionType.currentIndex() == 0:
                circleAreaList.append(PolylineArea(None, centerPoint, radius -self.slantTolerance.Metres))
            if (self.parametersPanel.cmbConstructionType.currentIndex() == 0):
                endPoint = offsetCurf1[0]
                offsetCurf1.append(endPoint)
            resultPoint3dArrayList.append(offsetCurf1)
#             foreach (Entity offsetCurf1 in arc.GetOffsetCurves(-self.slantTolerance.Metres))
#             {
#                 AcadHelper.smethod_19(transaction, blockTableRecord, offsetCurf1, constructionLayer, 2);
#             }
#         }
        if (self.parametersPanel.chbInsertSymbol.isChecked()):
            length = self.groundDistance.Metres / 5
            rectangle = QgsRectangle(point3d1.get_X() - length / 2, point3d1.get_Y() - length / 2, point3d1.get_X() + length / 2, point3d1.get_Y() + length / 2,)
            point1 = MathHelper.distanceBearingPoint(point3d1, Unit.ConvertDegToRad(315), length / 2)#Point3D(point3d1.get_X() - length / 2, point3d1.get_Y() + length / 2)
            point2 = MathHelper.distanceBearingPoint(point3d1, Unit.ConvertDegToRad(225), length / 2)#Point3D(point3d1.get_X() - length / 2, point3d1.get_Y() - length / 2)
            point3 = MathHelper.distanceBearingPoint(point3d1, Unit.ConvertDegToRad(135), length / 2)#Point3D(point3d1.get_X() + length / 2, point3d1.get_Y() - length / 2)
            point4 = MathHelper.distanceBearingPoint(point3d1, Unit.ConvertDegToRad(45), length / 2)#Point3D(point3d1.get_X() + length / 2, point3d1.get_Y() + length / 2)
            resultPoint3dArrayList.append([point1, point2, point3, point4, point1])
#             Symbol symbol = new Symbol(SymbolType.Dme);
#             AcadHelper.smethod_57(transaction, blockTableRecord, symbol.BlockName, symbol.BlockFileName, point3d1, new Scale3d(1), 0, constructionLayer, None);
#         }

        for point3dArray in resultPoint3dArrayList:
            if (self.parametersPanel.cmbConstructionType.currentIndex() != 0):
                bulge = MathHelper.smethod_60(point3dArray[0], point3dArray[int(len(point3dArray)/2)], point3dArray[len(point3dArray)-1])
                AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, point3dArray, False, {"Bulge":bulge})
        if self.parametersPanel.cmbConstructionType.currentIndex() == 0:
            for area in circleAreaList:
                AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, area)
            if self.parametersPanel.chbInsertSymbol.isChecked():
                AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, [point1, point2, point3, point4, point1])

        
        if (self.parametersPanel.chbWriteText.isChecked()):
            AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, captionCircleLine, False, {"Caption":"3DME"} )
        
        palSetting = QgsPalLayerSettings()
        palSetting.readFromLayer(constructionLayer)
        palSetting.enabled = True
        palSetting.fieldName = "Caption"
        palSetting.isExpression = True
        palSetting.placement = QgsPalLayerSettings.Line
        palSetting.placementFlags = QgsPalLayerSettings.AboveLine
        palSetting.setDataDefinedProperty(QgsPalLayerSettings.Size, True, True, '12', "")
        palSetting.writeToLayer(constructionLayer)
        
        QgisHelper.appendToCanvas(define._canvas, [constructionLayer], self.surfaceType, True)
        QgisHelper.zoomToLayers([constructionLayer])
        self.resultLayerList = [constructionLayer]
    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())
    def DrawCanvas(self):
        qgsLayerTreeView = define._mLayerTreeView
        groupName = self.surfaceType
        layerTreeModel = qgsLayerTreeView.layerTreeModel()
        layerTreeGroup = layerTreeModel.rootGroup()
        rowCount = layerTreeModel.rowCount()
        groupExisting = False
        if rowCount > 0:
            for i in range(rowCount):
                qgsLayerTreeNode = layerTreeModel.index2node(layerTreeModel.index(i, 0))
                if qgsLayerTreeNode.nodeType() == 0:
                    qgsLayerTreeNode._class_ =  QgsLayerTreeGroup
                    if isinstance(qgsLayerTreeNode, QgsLayerTreeGroup) and qgsLayerTreeNode.name() == groupName:
                        groupExisting = True

        if groupExisting:
            if len(self.resultLayerList) > 0:
                QgisHelper.removeFromCanvas(define._canvas, self.resultLayerList)
                self.resultLayerList = []
            else:
                QtGui.QMessageBox.warning(self, "Warning", "Please remove \"" + self.surfaceType + "\" layer group from LayerTreeView.")
                return

        constructionLayer = AcadHelper.createVectorLayer(self.surfaceType);
        if self.comboBox.currentIndex() == ProtectionAreaType.Primary or self.comboBox.currentIndex() == ProtectionAreaType.Secondary:
            AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, self.area.PreviewArea, True)

        elif self.comboBox.currentIndex() == ProtectionAreaType.PrimaryAndSecondary:
            AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, self.area.primaryArea.PreviewArea, True)
            AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, self.area.secondaryArea1.PreviewArea, True)
            AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, self.area.secondaryArea2.PreviewArea, True)
        else:

            for obstacleArea in self.area:
                AcadHelper.setGeometryAndAttributesInLayer(constructionLayer, obstacleArea.PreviewArea, True)
        QgisHelper.appendToCanvas(define._canvas, [constructionLayer], self.surfaceType)
        self.resultLayerList = [constructionLayer]
Exemple #13
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