class DlgAixmHolding(QDialog):
    def __init__(self, parent = None):
        QDialog.__init__(self, parent)
        
        self.resize(290, 136);
        self.setWindowTitle("Instrument Approach Procedure (IAP)")
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed);
        sizePolicy.setHorizontalStretch(0);
        sizePolicy.setVerticalStretch(0);
        sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth());
        self.setSizePolicy(sizePolicy);
        verticalLayoutDlg = QVBoxLayout(self)
        verticalLayoutDlg.setObjectName(("verticalLayoutDlg"));

        self.groupBox = GroupBox(self)
        verticalLayoutDlg.addWidget(self.groupBox)

        self.pnlBasedOn = ComboBoxPanel(self.groupBox)
        self.pnlBasedOn.Caption = "Based On"
        self.pnlBasedOn.Button = "coordinate_capture.png"
        self.groupBox.Add = self.pnlBasedOn

        self.pnlType = ComboBoxPanel(self.groupBox)
        self.pnlType.Caption = "Type"
        self.groupBox.Add = self.pnlType

        self.txtDescription = TextBoxPanel(self.groupBox, True)
        self.txtDescription.Caption = "Description"
        self.groupBox.Add = self.txtDescription

        self.txtRemarks = TextBoxPanel(self.groupBox, True)
        self.txtRemarks.Caption = "Remarks"
        self.groupBox.Add = self.txtRemarks

        self.btnBoxOkCancel = QDialogButtonBox(self)
        self.btnBoxOkCancel.setObjectName(("btnBoxOkCancel"));
        self.btnBoxOkCancel.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok);
        self.connect(self.btnBoxOkCancel, SIGNAL("accepted()"), self.acceptDlg)
        self.connect(self.btnBoxOkCancel, SIGNAL("rejected()"), self.reject)

        self.connect(self.pnlBasedOn, SIGNAL("Event_3"), self.pnlBasedOn_Event_3)

        verticalLayoutDlg.addWidget(self.btnBoxOkCancel)


        self.data = None
        self.table = None
        self.selected = None;

        self.CaptureCoordTool = CaptureCoordinateToolUpdate(define._canvas)
        self.connect(self.CaptureCoordTool, SIGNAL("resultPointValueList"), self.resultPointValueListMethod)

    def pnlBasedOn_Event_3(self):
        CaptureCoordTool = CaptureCoordinateToolUpdate(define._canvas)
        self.connect(CaptureCoordTool, SIGNAL("resultPointValueList"), self.resultPointValueListMethod)

        define._canvas.setMapTool(self.CaptureCoordTool)

    def resultPointValueListMethod(self, resultValueList):
        if len(resultValueList) > 0:
            point3d = Point3D(float(resultValueList[1]), float(resultValueList[2]), float(resultValueList[3]))
            resultDlg, procEntityBase = DlgAixmSelectPosition.smethod_0(self, self.data, point3d, ProcEntityListType.Holding)
            if (resultDlg and procEntityBase != None):
                if (not self.pnlBasedOn.Contains(procEntityBase)):
                    self.pnlBasedOn.Add(procEntityBase);
                self.pnlBasedOn.SelectedIndex = self.pnlBasedOn.IndexOf(procEntityBase);
    def acceptDlg(self):
        selectedItem = self.pnlBasedOn.SelectedItem;
        codeTypeHoldProcAixm = self.pnlType.SelectedItem
        for row in self.table:
            flag = True;
            if (self.selected != None and row == self.selected):
                flag = False;
            if (row["basedOnEnt"] != selectedItem):
                flag = False;
            if (row["codeType"] != codeTypeHoldProcAixm):
                flag = False;
            if (not flag):
                continue;
            strS = "Cannot create a duplicate procedure entry.\n\nBased on = {0}\nType = {1}".format(self.pnlBasedOn.SelectedItem, self.pnlType.SelectedItem);
            QMessageBox.warning(self, "Error", strS);
            return;
        self.accept()
    

    def method_6(self):
        pass

    @staticmethod
    def smethod_0(dataBaseHoldings_0, dataBaseProcedureData_0, dataRow_0):
        flag = False;
        dlgAixmHolding = DlgAixmHolding()
        dlgAixmHolding.data = dataBaseProcedureData_0;
        dlgAixmHolding.table = dataBaseHoldings_0;
        dlgAixmHolding.selected = dataRow_0;
        dataBaseProcedureData_0.method_59(dlgAixmHolding.pnlBasedOn, ProcEntityListType.Holding);
        dlgAixmHolding.pnlType.Items = CodeTypeHoldProcAixm.Items;
        if (dataRow_0 != None and len(dataRow_0) > 0):
            dlgAixmHolding.pnlBasedOn.SelectedIndex = dlgAixmHolding.pnlBasedOn.IndexOf(dataRow_0["basedOnEnt"]);
            dlgAixmHolding.pnlType.SelectedIndex = dlgAixmHolding.pnlType.method_3(dataRow_0["codeType"]);
            if (dataRow_0["txtDescr"] != None):
                dlgAixmHolding.txtDescription.Value = dataRow_0["txtDescr"];
            if (dataRow_0["txtRmk"] != None):
                dlgAixmHolding.txtRemarks.Value = dataRow_0["txtRmk"];
        resultDlg = dlgAixmHolding.exec_()
        if (resultDlg == 1):
            dataRow0 = dataRow_0 == None or len(dataRow_0) == 0;
            strS = [];
            if (not dataRow0):
                for a in dataBaseHoldings_0.nameList:
                    strS.append(None)
                # str = new string[dataBaseHoldings_0.Columns.Count];
                i = 0
                for name in dataBaseHoldings_0.nameList:
                    strS[i] = dataRow_0[name]
                    i += 1
            else:
                dataRow_0 = dataBaseHoldings_0.NewRow();
            dataRow_0["basedOnEnt"] = dlgAixmHolding.pnlBasedOn.SelectedItem;
            if (dataRow0):
                dataRow_0["oldBasedOnEnt"] = dataRow_0["basedOnEnt"];
            dataRow_0["codeType"] = dlgAixmHolding.pnlType.SelectedItem;
            if (dataRow0):
                dataRow_0["oldCodeType"] = dataRow_0["codeType"];
            if (not String.IsNullOrEmpty(dlgAixmHolding.txtDescription.Value)):
                dataRow_0["txtDescr"] = dlgAixmHolding.txtDescription.Value;
            else:
                dataRow_0["txtDescr"] = None;
            if (not String.IsNullOrEmpty(dlgAixmHolding.txtRemarks.Value)):
                dataRow_0["txtRmk"] = dlgAixmHolding.txtRemarks.Value;
            else:
                dataRow_0["txtRmk"] = None;
            if (dataRow0):
                dataRow_0["procLegs"] = DataBaseProcedureLegs();
                dataRow_0["procLegsEx"] = DataBaseProcedureLegsEx();
            if (not dataRow0):
                num = 1;
                while (num < len(strS)):
                    if (not strS[num] == dataRow_0[dataRow_0.nameList[num]]):
                        dataRow_0["changed"] = "True";
                        if (dataRow0):
                            dataBaseHoldings_0.RowsAdd(dataRow_0);
                        flag = True;
                        return flag;
                    else:
                        num += 1;
            else:
                dataRow_0["new"] = "True";
            if (dataRow0):
                dataBaseHoldings_0.RowsAdd(dataRow_0);
            flag = True;
            return flag;
        return flag
예제 #2
0
class DlgAixmProcLegsEx(QDialog):
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)

        self.resize(290, 136)
        self.setWindowTitle("Procedure Legs (AIXM 4.5+)")
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(sizePolicy)
        verticalLayoutDlg = QVBoxLayout(self)
        verticalLayoutDlg.setObjectName(("verticalLayoutDlg"))

        self.gbAll = GroupBox(self, "HL")
        self.gbAll.Caption = "Legs"
        verticalLayoutDlg.addWidget(self.gbAll)

        self.trvLegs = QTreeView(self.gbAll)
        self.trvLegsStdModel = StandardItemModel()
        self.trvLegs.setModel(self.trvLegsStdModel)
        self.gbAll.Add = self.trvLegs

        self.flowLayoutPanel1 = Frame(self.gbAll)
        self.gbAll.Add = self.flowLayoutPanel1

        self.btnAdd = QPushButton(self.flowLayoutPanel1)
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/add.png"), QIcon.Normal, QIcon.Off)
        self.btnAdd.setIcon(icon)
        self.flowLayoutPanel1.Add = self.btnAdd

        self.btnRemove = QPushButton(self.flowLayoutPanel1)
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/remove.png"), QIcon.Normal, QIcon.Off)
        self.btnRemove.setIcon(icon)
        self.flowLayoutPanel1.Add = self.btnRemove

        self.btnMoveUp = QPushButton(self.flowLayoutPanel1)
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/up.png"), QIcon.Normal, QIcon.Off)
        self.btnMoveUp.setIcon(icon)
        self.flowLayoutPanel1.Add = self.btnMoveUp

        self.btnMoveDown = QPushButton(self.flowLayoutPanel1)
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/down.png"), QIcon.Normal, QIcon.Off)
        self.btnMoveDown.setIcon(icon)
        self.flowLayoutPanel1.Add = self.btnMoveDown

        self.scrollBox = Frame(self.gbAll)
        self.gbAll.Add = self.scrollBox

        self.gbPosition = GroupBox(self.scrollBox)
        self.gbPosition.Caption = "Fix"
        self.scrollBox.Add = self.gbPosition

        self.cmbPosUid = ComboBoxPanel(self.gbPosition)
        self.cmbPosUid.Caption = "Position"
        self.cmbPosUid.Button = "coordinate_capture.png"
        self.gbPosition.Add = self.cmbPosUid

        self.gbAttributes = GroupBox(self.scrollBox)
        self.gbAttributes.Caption = "Attributes"
        self.scrollBox.Add = self.gbAttributes

        self.pnlPathType = ComboBoxPanel(self.gbAttributes)
        self.pnlPathType.Caption = "Path Type"
        self.gbAttributes.Add = self.pnlPathType

        self.pnlLegType = ComboBoxPanel(self.gbAttributes)
        self.pnlLegType.Caption = "Leg Type"
        self.gbAttributes.Add = self.pnlLegType

        self.cmbCenUid = ComboBoxPanel(self.gbAttributes)
        self.cmbCenUid.Caption = "Center"
        self.cmbCenUid.Button = "coordinate_capture.png"
        self.gbAttributes.Add = self.cmbCenUid

        self.pnlFlyBy = ComboBoxPanel(self.gbAttributes)
        self.pnlFlyBy.Caption = "Fly-By"
        self.gbAttributes.Add = self.pnlFlyBy

        self.pnlMinAlt = AltitudeBoxPanel(self.gbAttributes)
        self.pnlMinAlt.CaptionUnits = "ft"
        self.pnlMinAlt.Caption = "Minimum Altitude"
        self.gbAttributes.Add = self.pnlMinAlt

        self.pnlSegLength = DistanceBoxPanel(self.gbAttributes,
                                             DistanceUnits.NM)
        self.pnlSegLength.Caption = "Segment Length"
        self.gbAttributes.Add = self.pnlSegLength

        self.pnlCourse = TrackRadialBoxPanel(self.gbAttributes)
        self.pnlCourse.Caption = "Course"
        self.gbAttributes.Add = self.pnlCourse

        self.pnlLegVOR = Frame(self.gbAttributes)
        self.gbAttributes.Add = self.pnlLegVOR

        f1 = Frame(self.pnlLegVOR, "HL")
        self.pnlLegVOR.Add = f1

        self.cmbLegVor = ComboBoxPanel(f1)
        self.cmbLegVor.Caption = "VOR / Radial (" + define._degreeStr + ")"
        f1.Add = self.cmbLegVor

        self.txtLegRadial = TrackRadialBoxPanel(f1)
        self.txtLegRadial.Caption = ""
        self.txtLegRadial.LabelWidth = 0
        f1.Add = self.txtLegRadial

        f2 = Frame(self.pnlLegVOR, "HL")
        self.pnlLegVOR.Add = f2

        self.cmbLegBackVor = ComboBoxPanel(f2)
        self.cmbLegBackVor.Caption = "Reverse VOR / Radial (" + define._degreeStr + ")"
        f2.Add = self.cmbLegBackVor

        self.txtLegBackRadial = TrackRadialBoxPanel(f2)
        self.txtLegBackRadial.Caption = ""
        self.txtLegBackRadial.LabelWidth = 0
        f2.Add = self.txtLegBackRadial

        self.pnlPointType = ComboBoxPanel(self.gbAttributes)
        self.pnlPointType.Caption = "Point Type"
        self.gbAttributes.Add = self.pnlPointType

        self.pnlRepPointType = ComboBoxPanel(self.gbAttributes)
        self.pnlRepPointType.Caption = "Reporting Point Type"
        self.gbAttributes.Add = self.pnlRepPointType

        self.pnlPointVor = Frame(self.gbAttributes)
        self.gbAttributes.Add = self.pnlPointVor

        frame1 = Frame(self.pnlPointVor, "HL")
        self.pnlPointVor.Add = frame1

        self.cmbPointVor = ComboBoxPanel(frame1)
        self.cmbPointVor.Caption = "Point VOR / Radial (" + define._degreeStr + ")"
        frame1.Add = self.cmbPointVor

        self.txtPointRadial = TrackRadialBoxPanel(frame1)
        self.txtPointRadial.Caption = ""
        self.txtPointRadial.LabelWidth = 0
        frame1.Add = self.txtPointRadial

        frame2 = Frame(self.pnlPointVor, "HL")
        self.pnlPointVor.Add = frame2

        self.cmbPointDme1 = ComboBoxPanel(frame2)
        self.cmbPointDme1.Caption = "Point 1. DME / Distance (nm)"
        frame2.Add = self.cmbPointDme1

        self.txtPointDme1 = DistanceBoxPanel(frame2, DistanceUnits.NM)
        self.txtPointDme1.Caption = ""
        self.txtPointDme1.LabelWidth = 0
        frame2.Add = self.txtPointDme1

        frame3 = Frame(self.pnlPointVor, "HL")
        self.pnlPointVor.Add = frame3

        self.cmbPointDme2 = ComboBoxPanel(frame3)
        self.cmbPointDme2.Caption = "Point 2. DME / Distance (nm)"
        frame3.Add = self.cmbPointDme2

        self.txtPointDme2 = DistanceBoxPanel(frame3, DistanceUnits.NM)
        self.txtPointDme2.Caption = ""
        self.txtPointDme2.LabelWidth = 0
        frame3.Add = self.txtPointDme2

        self.txtFlyDuration = TextBoxPanel(self.pnlPointVor, True)
        self.txtFlyDuration.Caption = "Flying Time Duration"
        self.pnlPointVor.Add = self.txtFlyDuration

        self.txtRemarks = TextBoxPanel(self.pnlPointVor, True)
        self.txtRemarks.Caption = "Remarks"
        self.pnlPointVor.Add = self.txtRemarks

        self.btnBoxOkCancel = QDialogButtonBox(self)
        self.btnBoxOkCancel.setObjectName(("btnBoxOkCancel"))
        self.btnBoxOkCancel.setStandardButtons(QDialogButtonBox.Cancel
                                               | QDialogButtonBox.Ok)
        self.connect(self.btnBoxOkCancel, SIGNAL("accepted()"), self.acceptDlg)
        self.connect(self.btnBoxOkCancel, SIGNAL("rejected()"), self.reject)

        self.btnAdd.clicked.connect(self.btnAdd_Click)
        self.btnMoveDown.clicked.connect(self.btnMoveDown_Click)
        self.btnMoveUp.clicked.connect(self.btnMoveUp_Click)
        self.btnRemove.clicked.connect(self.btnRemove_Click)

        verticalLayoutDlg.addWidget(self.btnBoxOkCancel)

        self.trvLegs.pressed.connect(self.trvLegs_pressed)

        self.data = None
        self.legs = None
        self.aerodrome = None
        self.magnVar = 0.0

        self.trvLegs.setHeaderHidden(True)

        self.pnlPointType.Items = ["IAF", "IF", "FAF", "FAP", "MAPt", "TP"]

        for value in CodeLegTypeAixm.Items:
            self.pnlLegType.Add(value)

        for value in CodePathTypeAixm.Items:
            self.pnlPathType.Add(value)

        for value in CodeRepAtcAixm.Items:
            self.pnlRepPointType.Add(value)

        for value in CodeTypeFlyByAixm.Items:
            self.pnlFlyBy.Add(value)
        self.method_6()

        self.connect(self.txtRemarks, SIGNAL("Event_0"),
                     self.txtRemarks_Event_0)
        self.connect(self.txtPointDme2, SIGNAL("Event_0"),
                     self.txtPointDme2_Event_0)
        self.connect(self.cmbPointDme2, SIGNAL("Event_0"),
                     self.cmbPointDme2_Event_0)
        self.connect(self.txtPointDme1, SIGNAL("Event_0"),
                     self.txtPointDme1_Event_0)
        self.connect(self.cmbPointDme1, SIGNAL("Event_0"),
                     self.cmbPointDme1_Event_0)
        self.connect(self.cmbPointVor, SIGNAL("Event_0"),
                     self.cmbPointVor_Event_0)
        self.connect(self.txtPointRadial, SIGNAL("Event_0"),
                     self.txtPointRadial_Event_0)
        self.connect(self.txtFlyDuration, SIGNAL("Event_0"),
                     self.txtFlyDuration_Event_0)
        self.connect(self.pnlRepPointType, SIGNAL("Event_0"),
                     self.pnlRepPointType_Event_0)

        self.connect(self.pnlPointType, SIGNAL("Event_0"),
                     self.pnlPointType_Event_0)

        self.connect(self.txtLegBackRadial, SIGNAL("Event_0"),
                     self.txtLegBackRadial_Event_0)

        self.connect(self.cmbLegBackVor, SIGNAL("Event_0"),
                     self.cmbLegBackVor_Event_0)

        self.connect(self.cmbLegVor, SIGNAL("Event_0"), self.cmbLegVor_Event_0)

        self.connect(self.txtLegRadial, SIGNAL("Event_0"),
                     self.txtLegRadial_Event_0)

        self.connect(self.pnlCourse, SIGNAL("Event_0"), self.pnlCourse_Event_0)

        self.connect(self.pnlSegLength, SIGNAL("Event_0"),
                     self.pnlSegLength_Event_0)

        self.connect(self.pnlMinAlt, SIGNAL("Event_0"), self.pnlMinAlt_Event_0)

        self.connect(self.pnlFlyBy, SIGNAL("Event_0"), self.pnlFlyBy_Event_0)

        self.connect(self.cmbCenUid, SIGNAL("Event_0"), self.cmbCenUid_Event_0)

        self.connect(self.pnlLegType, SIGNAL("Event_0"),
                     self.pnlLegType_Event_0)

        self.connect(self.pnlPathType, SIGNAL("Event_0"),
                     self.pnlPathType_Event_0)

        self.connect(self.cmbPosUid, SIGNAL("Event_0"), self.cmbPosUid_Event_0)
        self.connect(self.cmbCenUid, SIGNAL("Event_3"), self.method_14)
        self.connect(self.cmbPosUid, SIGNAL("Event_3"), self.method_13)

        # self.cmbCenter.imageButton.clicked.connect(self.method_14)
        # self.cmbFixPos.imageButton.clicked.connect(self.method_13)
    def btnAdd_Click(self):
        if (len(self.trvLegs.selectedIndexes()) == 0 and not self.method_5()):
            return
        listInsertPosition = ListInsertPosition.Append
        resultDlg, listInsertPosition = DlgAixmInsertLeg.smethod_0(
            listInsertPosition)
        if (self.trvLegsStdModel.rowCount() > 0 and not resultDlg):
            return
        count = self.trvLegsStdModel.rowCount()
        if (listInsertPosition == ListInsertPosition.Before):
            count = self.trvLegs.selectedIndexes()[0].row()
        elif (listInsertPosition == ListInsertPosition.After):
            count = self.trvLegs.selectedIndexes()[0].row() + 1
        self.trvLegsStdModel.setItem(
            self.trvLegsStdModel.rowCount(),
            QStandardItem(str(self.trvLegsStdModel.rowCount() + 1)))
        self.legs.insert(count, DataBaseProcedureLegEx())
        self.trvLegs.setCurrentIndex(self.trvLegsStdModel.index(count, 0))
        self.trvLegs_pressed()

    def btnMoveDown_Click(self):
        if (len(self.trvLegs.selectedIndexes()) == 0):
            return
        index = self.trvLegs.selectedIndexes()[0].row()
        item = self.legs[index]
        self.legs.pop(index)
        self.legs.insert(index + 1, item)
        self.trvLegs.setCurrentIndex(self.trvLegsStdModel.index(index + 1, 0))
        self.trvLegs_pressed()

    def btnMoveUp_Click(self):
        if (len(self.trvLegs.selectedIndexes()) == 0):
            return
        index = self.trvLegs.selectedIndexes()[0].row()
        item = self.legs[index]
        self.legs.pop(index)
        self.legs.insert(index - 1, item)
        self.trvLegs.setCurrentIndex(self.trvLegsStdModel.index(index - 1, 0))
        self.trvLegs_pressed()

    def btnRemove_Click(self):
        item = None
        if (len(self.trvLegs.selectedIndexes()) == 0):
            return
        if (QMessageBox.question(
                self, "Question",
                "Are you sure you want to delete the selected procedure leg?",
                QMessageBox.Yes | QMessageBox.No) == QMessageBox.Yes):
            index = self.trvLegs.selectedIndexes()[0].row()
            self.legs.pop(index)
            self.trvLegsStdModel.takeRow(self.trvLegsStdModel.rowCount() - 1)
            if (index >= self.trvLegsStdModel.rowCount() - 1):
                index -= 1
            # treeView = self.trvLegs;
            # if (index >= 0):
            if self.trvLegsStdModel.rowCount() > 0 and index < 0:
                index = 0
            self.trvLegs.setCurrentIndex(self.trvLegsStdModel.index(index, 0))

            self.trvLegs_pressed()

    def cmbPosUid_Event_0(self):
        self.txtFlyDuration_TextChanged(self.cmbPosUid)

    def txtRemarks_Event_0(self):
        self.txtFlyDuration_TextChanged(self.txtRemarks)

    def txtPointDme2_Event_0(self):
        self.txtFlyDuration_TextChanged(self.txtPointDme2)

    def cmbPointDme2_Event_0(self):
        self.txtFlyDuration_TextChanged(self.cmbPointDme2)

    def txtPointDme1_Event_0(self):
        self.txtFlyDuration_TextChanged(self.txtPointDme1)

    def cmbPointDme1_Event_0(self):
        self.txtFlyDuration_TextChanged(self.cmbPointDme1)

    def cmbPointVor_Event_0(self):
        self.txtFlyDuration_TextChanged(self.cmbPointVor)

    def txtPointRadial_Event_0(self):
        self.txtFlyDuration_TextChanged(self.txtPointRadial)

    def txtFlyDuration_Event_0(self):
        self.txtFlyDuration_TextChanged(self.txtFlyDuration)

    def pnlRepPointType_Event_0(self):
        self.txtFlyDuration_TextChanged(self.pnlRepPointType)

    def pnlPointType_Event_0(self):
        self.txtFlyDuration_TextChanged(self.pnlPointType)

    def txtLegBackRadial_Event_0(self):
        self.txtFlyDuration_TextChanged(self.txtLegBackRadial)

    def cmbLegBackVor_Event_0(self):
        self.txtFlyDuration_TextChanged(self.cmbLegBackVor)

    def cmbLegVor_Event_0(self):
        self.txtFlyDuration_TextChanged(self.cmbLegVor)

    def txtLegRadial_Event_0(self):
        self.txtFlyDuration_TextChanged(self.txtLegRadial)

    def pnlCourse_Event_0(self):
        self.txtFlyDuration_TextChanged(self.pnlCourse)

    def pnlSegLength_Event_0(self):
        self.txtFlyDuration_TextChanged(self.pnlSegLength)

    def pnlMinAlt_Event_0(self):
        self.txtFlyDuration_TextChanged(self.pnlMinAlt)

    def pnlFlyBy_Event_0(self):
        self.txtFlyDuration_TextChanged(self.pnlFlyBy)

    def cmbCenUid_Event_0(self):
        self.txtFlyDuration_TextChanged(self.cmbCenUid)

    def pnlLegType_Event_0(self):
        self.txtFlyDuration_TextChanged(self.pnlLegType)

    def pnlPathType_Event_0(self):
        self.txtFlyDuration_TextChanged(self.pnlPathType)

    def trvLegs_pressed(self):
        self.method_6()
        self.method_8()

    def acceptDlg(self):
        self.legs.refresh()
        QObject.emit(self, SIGNAL("DlgAixmProcLegs_Smethod_0_Event"),
                     self.legs, self.data)
        self.accept()

    def method_6(self):
        self.btnOK = self.btnBoxOkCancel.button(QDialogButtonBox.Ok)
        self.btnOK.setEnabled(len(self.trvLegs.selectedIndexes()) > 0)
        self.btnRemove.setEnabled(len(self.trvLegs.selectedIndexes()) > 0)
        self.btnMoveUp.setEnabled(
            (len(self.trvLegs.selectedIndexes()) > 0
             and self.trvLegs.selectedIndexes()[0].row() != 0) and True
            or False)
        self.btnMoveDown.setEnabled(
            (len(self.trvLegs.selectedIndexes()) <= 0
             or self.trvLegsStdModel.rowCount() <= 0) and False
            or ((len(self.trvLegs.selectedIndexes()) > 0)
                and self.trvLegs.selectedIndexes()[0].row() <
                self.trvLegsStdModel.rowCount() - 1))

    def method_7(self):
        for i in range(self.legs.Count):
            num = i + 1
            self.trvLegsStdModel.setItem(i, QStandardItem(str(num)))
        self.method_6()

    def method_8(self):
        if (self.trvLegs.selectedIndexes() == None
                or len(self.trvLegs.selectedIndexes()) == 0):
            self.scrollBox.Enabled = False
            self.cmbPosUid.SelectedIndex = -1
            self.pnlPathType.SelectedIndex = -1
            self.pnlLegType.SelectedIndex = -1
            self.cmbCenUid.SelectedIndex = -1
            self.pnlFlyBy.SelectedIndex = -1
            self.pnlMinAlt.Value = None
            self.pnlSegLength.Value = None
            self.pnlCourse.Value = None
            self.cmbLegVor.SelectedIndex = -1
            self.txtLegRadial.Value = 0
            self.cmbLegBackVor.SelectedIndex = -1
            self.txtLegBackRadial.Value = 0
            self.pnlPointType.Value = ""
            self.pnlRepPointType.SelectedIndex = -1
            self.cmbPointVor.SelectedIndex = -1
            self.txtPointRadial.Value = 0
            self.cmbPointDme1.SelectedIndex = -1
            self.txtPointDme1.Value = None
            self.cmbPointDme2.SelectedIndex = -1
            self.txtPointDme2.Value = None
            self.txtFlyDuration.Value = ""
            self.txtRemarks.Value = ""
            return
        self.scrollBox.Enabled = True
        item = self.legs[self.trvLegs.selectedIndexes()[0].row()]
        if (item.PointEnt == None):
            self.cmbPosUid.SelectedIndex = -1
        else:
            self.cmbPosUid.SelectedIndex = self.cmbPosUid.IndexOf(
                item.PointEnt)
        self.pnlPathType.SelectedIndex = self.method_10(
            self.pnlPathType.Items, item.CodePathType)
        self.pnlLegType.SelectedIndex = self.method_10(self.pnlLegType.Items,
                                                       item.CodeLegType)
        if (item.CodeLegType != CodeLegTypeAixm.CCA):
            if (item.CodeLegType == CodeLegTypeAixm.CWA):
                if (item.CenterEnt == None):
                    self.cmbCenUid.SelectedIndex = -1
                else:
                    self.cmbCenUid.SelectedIndex = self.cmbCenUid.IndexOf(
                        item.CenterEnt)
                self.cmbCenUid.Visible = True
            else:
                self.cmbCenUid.SelectedIndex = -1
                self.cmbCenUid.Visible = False
                # goto Label0;
        else:
            # Label2:
            if (item.CenterEnt == None):
                self.cmbCenUid.SelectedIndex = -1
            else:
                self.cmbCenUid.SelectedIndex = self.cmbCenUid.IndexOf(
                    item.CenterEnt)
            self.cmbCenUid.Visible = True

    # Label0:
        self.pnlFlyBy.SelectedIndex = self.method_10(self.pnlFlyBy.Items,
                                                     item.CodeFlyBy)
        self.pnlMinAlt.Value = item.ValMinAlt
        self.pnlSegLength.Value = item.ValDist
        self.pnlCourse.Value = item.ValCourse
        if (item.VorUidLeg == None):
            self.cmbLegVor.SelectedIndex = -1
        else:
            self.cmbLegVor.SelectedIndex = self.cmbLegVor.IndexOf(
                item.VorUidLeg)
        self.txtLegRadial.Value = item.ValLegRadial
        if (item.VorUidLegBack == None):
            self.cmbLegBackVor.SelectedIndex = -1
        else:
            self.cmbLegBackVor.SelectedIndex = self.cmbLegBackVor.IndexOf(
                item.VorUidLegBack)
        self.txtLegBackRadial.Value = item.ValLegRadialBack
        self.pnlPointType.Value = item.CodePointType
        self.pnlRepPointType.SelectedIndex = self.method_10(
            self.pnlRepPointType.Items, item.CodeRepAtc)
        if (item.VorUidPoint == None):
            self.cmbPointVor.SelectedIndex = -1
        else:
            self.cmbPointVor.SelectedIndex = self.cmbPointVor.IndexOf(
                item.VorUidPoint)
        self.txtPointRadial.Value = item.ValPointRadial
        if (item.UidPointDist1 == None):
            self.cmbPointDme1.SelectedIndex = -1
        else:
            self.cmbPointDme1.SelectedIndex = self.cmbPointDme1.IndexOf(
                item.UidPointDist1)
        self.txtPointDme1.Value = item.ValPointDist1
        if (item.UidPointDist2 == None):
            self.cmbPointDme2.SelectedIndex = -1
        else:
            self.cmbPointDme2.SelectedIndex = self.cmbPointDme2.IndexOf(
                item.UidPointDist2)
        self.txtPointDme2.Value = item.ValPointDist2
        self.txtFlyDuration.Value = item.ValDur
        self.txtRemarks.Value = item.TxtRmk

    def method_9(self, ilist_0, string_0):
        for i in range(len(ilist_0)):
            if (String.StartsWith(ilist_0[i], string_0)):
                return i
        return -1

    def method_10(self, ilist_0, string_0):
        for i in range(len(ilist_0)):
            if (String.Equals(ilist_0[i], string_0)):
                return i
        return -1

    def txtFlyDuration_TextChanged(self, sender):
        if (self.trvLegs.selectedIndexes() == None
                or len(self.trvLegs.selectedIndexes()) == 0):
            return
        item = self.legs[self.trvLegs.selectedIndexes()[0].row()]
        if (sender == self.cmbPosUid):
            item.PointEnt = self.cmbPosUid.SelectedItem
            return
        if (sender == self.pnlPathType):
            item.CodePathType = self.pnlPathType.SelectedItem
            return
        if (sender == self.pnlLegType):
            item.CodeLegType = self.pnlLegType.SelectedItem
            self.cmbCenUid.Visible = (
                item.CodeLegType == CodeLegTypeAixm.CCA
            ) and True or item.CodeLegType == CodeLegTypeAixm.CWA
            return
        if (sender == self.cmbCenUid):
            item.CenterEnt = self.cmbCenUid.SelectedItem
            return
        if (sender == self.pnlFlyBy):
            item.CodeFlyBy = self.pnlFlyBy.SelectedItem
            return
        if (sender == self.pnlMinAlt):
            item.ValMinAlt = self.pnlMinAlt.Value
            return
        if (sender == self.pnlSegLength):
            item.ValDist = self.pnlSegLength.Value
            return
        if (sender == self.pnlCourse):
            item.ValCourse = self.pnlCourse.Value
            return
        if (sender == self.cmbLegVor):
            item.VorUidLeg = self.cmbLegVor.SelectedItem
            return
        if (sender == self.txtLegRadial):
            item.ValLegRadial = self.txtLegRadial.Value
            return
        if (sender == self.cmbLegBackVor):
            item.VorUidLegBack = self.cmbLegBackVor.SelectedItem
            return
        if (sender == self.txtLegBackRadial):
            item.ValLegRadialBack = self.txtLegBackRadial.Value
            return
        if (sender == self.pnlPointType):
            item.CodePointType = self.pnlPointType.SelectedItem
            return
        if (sender == self.pnlRepPointType):
            item.CodeRepAtc = self.pnlRepPointType.SelectedItem
            return
        if (sender == self.cmbPointVor):
            item.VorUidPoint = self.cmbPointVor.SelectedItem
            return
        if (sender == self.txtPointRadial):
            item.ValPointRadial = self.txtPointRadial.Value
            return
        if (sender == self.cmbPointDme1):
            item.UidPointDist1 = self.cmbPointDme1.SelectedItem
            return
        if (sender == self.txtPointDme1):
            item.ValPointDist1 = self.txtPointDme1.Value
            return
        if (sender == self.cmbPointDme2):
            item.UidPointDist2 = self.cmbPointDme2.SelectedItem
            return
        if (sender == self.txtPointDme2):
            item.ValPointDist2 = self.txtPointDme2.Value
            return
        if (sender == self.txtFlyDuration):
            item.ValDur = self.txtFlyDuration.Value
            return
        if (sender == self.txtRemarks):
            item.TxtRmk = self.txtRemarks.Value

    def method_13(self):
        point3d = None
        procEntityBase = None
        selectTool = DlgAixmSelectPosition.smethod_0(
            self.data, point3d, ProcEntityListType.FixesEx)
        QObject.connect(selectTool,
                        SIGNAL("DlgAixmSelectPosition_Smethod_0_Event"),
                        self.method_13_Event)

    def method_13_Event(self, flag, procEntityBase):
        # flag, procEntityBase = DlgAixmSelectPosition.smethod_0(self.data, point3d, ProcEntityListType.Fixes)
        if (flag and procEntityBase != None):
            if (not self.cmbPosUid.Contains(procEntityBase)):
                self.cmbPosUid.Add(procEntityBase)
            self.cmbPosUid.SelectedIndex = self.cmbPosUid.IndexOf(
                procEntityBase)
            self.txtFlyDuration_TextChanged(self.cmbPosUid)

    def method_14(self):
        point3d = None
        procEntityBase = None
        selectTool = DlgAixmSelectPosition.smethod_0(
            self.data, point3d, ProcEntityListType.CentersEx)
        QObject.connect(selectTool,
                        SIGNAL("DlgAixmSelectPosition_Smethod_0_Event"),
                        self.method_14_Event)

    def method_14_Event(self, flag, procEntityBase):
        # flag, procEntityBase = DlgAixmSelectPosition.smethod_0(self.data, point3d, ProcEntityListType.Centers)
        if (flag and procEntityBase != None):
            if (not self.cmbCenUid.Contains(procEntityBase)):
                self.cmbCenUid.Add(procEntityBase)
            self.cmbCenUid.SelectedIndex = self.cmbCenUid.IndexOf(
                procEntityBase)
            self.txtFlyDuration_TextChanged(self.cmbCenUid)

    @staticmethod
    def smethod_0(parent, dataBaseProcedureLegsEx_0, dataBaseProcedureData_0,
                  procEntityAHP_0):
        flag = False
        dlgAixmProcLegsEx = DlgAixmProcLegsEx(parent)
        dlgAixmProcLegsEx.legs = dataBaseProcedureLegsEx_0
        dlgAixmProcLegsEx.data = dataBaseProcedureData_0
        if (procEntityAHP_0 != None):
            dlgAixmProcLegsEx.aerodrome = procEntityAHP_0
            dlgAixmProcLegsEx.magnVar = procEntityAHP_0.ValMagVar
        dataBaseProcedureData_0.method_59(dlgAixmProcLegsEx.cmbPosUid,
                                          ProcEntityListType.FixesEx)
        dataBaseProcedureData_0.method_59(dlgAixmProcLegsEx.cmbCenUid,
                                          ProcEntityListType.CentersEx)
        dataBaseProcedureData_0.method_59(dlgAixmProcLegsEx.cmbLegVor,
                                          ProcEntityListType.VORs)
        dataBaseProcedureData_0.method_59(dlgAixmProcLegsEx.cmbLegBackVor,
                                          ProcEntityListType.VORs)
        dataBaseProcedureData_0.method_59(dlgAixmProcLegsEx.cmbPointVor,
                                          ProcEntityListType.VORs)
        dataBaseProcedureData_0.method_59(dlgAixmProcLegsEx.cmbPointDme1,
                                          ProcEntityListType.DMEs)
        dataBaseProcedureData_0.method_59(dlgAixmProcLegsEx.cmbPointDme2,
                                          ProcEntityListType.DMEs)
        if (len(dlgAixmProcLegsEx.legs) == 0):
            dlgAixmProcLegsEx.legs.append(DataBaseProcedureLegEx())

        dlgAixmProcLegsEx.method_7()
        if dlgAixmProcLegsEx.trvLegsStdModel.rowCount() > 0:
            dlgAixmProcLegsEx.trvLegs.setCurrentIndex(
                dlgAixmProcLegsEx.trvLegsStdModel.index(0, 0))
            dlgAixmProcLegsEx.method_6()
        dlgAixmProcLegsEx.method_8()
        dlgAixmProcLegsEx.show()
        return dlgAixmProcLegsEx
class DlgAixmProcLegs(QDialog):
    def __init__(self, parent = None):
        QDialog.__init__(self, parent)
        
        self.resize(290, 136);
        self.setWindowTitle("Procedure Legs (AIXM 4.5)")
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed);
        sizePolicy.setHorizontalStretch(0);
        sizePolicy.setVerticalStretch(0);
        sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth());
        self.setSizePolicy(sizePolicy);
        verticalLayoutDlg = QVBoxLayout(self)
        verticalLayoutDlg.setObjectName(("verticalLayoutDlg"));

        self.gbAll = GroupBox(self, "HL")
        self.gbAll.Caption = "Legs"
        verticalLayoutDlg.addWidget(self.gbAll)

        self.trvLegs = QTreeView(self.gbAll)
        self.trvLegsStdModel = StandardItemModel()
        self.trvLegs.setModel(self.trvLegsStdModel)
        self.gbAll.Add = self.trvLegs

        self.flowLayoutPanel1 = Frame(self.gbAll)
        self.gbAll.Add = self.flowLayoutPanel1

        self.btnAdd = QPushButton(self.flowLayoutPanel1)
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/add.png"), QIcon.Normal, QIcon.Off)
        self.btnAdd.setIcon(icon)
        self.flowLayoutPanel1.Add = self.btnAdd

        self.btnRemove = QPushButton(self.flowLayoutPanel1)
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/remove.png"), QIcon.Normal, QIcon.Off)
        self.btnRemove.setIcon(icon)
        self.flowLayoutPanel1.Add = self.btnRemove

        self.btnMoveUp = QPushButton(self.flowLayoutPanel1)
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/up.png"), QIcon.Normal, QIcon.Off)
        self.btnMoveUp.setIcon(icon)
        self.flowLayoutPanel1.Add = self.btnMoveUp

        self.btnMoveDown = QPushButton(self.flowLayoutPanel1)
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/down.png"), QIcon.Normal, QIcon.Off)
        self.btnMoveDown.setIcon(icon)
        self.flowLayoutPanel1.Add = self.btnMoveDown

        self.scrollBox = Frame(self.gbAll)
        self.gbAll.Add = self.scrollBox

        self.gbFix = GroupBox(self.scrollBox)
        self.gbFix.Caption = "Fix"
        self.scrollBox.Add = self.gbFix

        self.cmbFixPos = ComboBoxPanel(self.gbFix)
        self.cmbFixPos.Caption = "Position"
        self.cmbFixPos.Button = "coordinate_capture.png"
        self.gbFix.Add = self.cmbFixPos

        self.pnlCodeRoleFix = ComboBoxPanel(self.gbFix)
        self.pnlCodeRoleFix.Caption = "Type"
        self.gbFix.Add = self.pnlCodeRoleFix

        self.gbAttributes = GroupBox(self.scrollBox)
        self.gbAttributes.Caption = "Attributes"
        self.scrollBox.Add = self.gbAttributes

        self.cmbRecommendedEnt = ComboBoxPanel(self.gbAttributes)
        self.cmbRecommendedEnt.Caption = "Recommended Navigational Aid"
        self.gbAttributes.Add = self.cmbRecommendedEnt

        self.pnlCodePhase = ComboBoxPanel(self.gbAttributes)
        self.pnlCodePhase.Caption = "Fligh Phase"
        self.gbAttributes.Add = self.pnlCodePhase

        self.pnlCodeType = ComboBoxPanel(self.gbAttributes)
        self.pnlCodeType.Caption = "Leg Type"
        self.gbAttributes.Add = self.pnlCodeType

        self.pnlLegVOR = Frame(self.gbAttributes, "HL")
        self.gbAttributes.Add = self.pnlLegVOR

        self.cmbCodeTypeCourse = ComboBoxPanel(self.pnlLegVOR)
        self.cmbCodeTypeCourse.Caption = "Course Angle (" + define._degreeStr + ")"
        self.pnlLegVOR.Add = self.cmbCodeTypeCourse

        self.txtValCourse = TrackRadialBoxPanel(self.pnlLegVOR)
        self.txtValCourse.LabelWidth = 0
        self.pnlLegVOR.Add = self.txtValCourse

        self.pnlCodeDirTurn = ComboBoxPanel(self.gbAttributes)
        self.pnlCodeDirTurn.Caption = "Turn Direction"
        self.gbAttributes.Add = self.pnlCodeDirTurn

        self.pnlTurnValid = ComboBoxPanel(self.gbAttributes)
        self.pnlTurnValid.Caption = "Fly-By"
        self.gbAttributes.Add = self.pnlTurnValid

        self.cmbCenter = ComboBoxPanel(self.gbAttributes)
        self.cmbCenter.Caption = "Center"
        self.cmbCenter.Button = "coordinate_capture.png"
        self.gbAttributes.Add = self.cmbCenter

        self.pnlValBankAngle = NumberBoxPanel(self.gbAttributes)
        self.pnlValBankAngle.Caption = "Bank Angle (" + define._degreeStr + ")"
        self.gbAttributes.Add = self.pnlValBankAngle

        self.pnlCodeDescrDistVer = ComboBoxPanel(self.gbAttributes)
        self.pnlCodeDescrDistVer.Caption = "Altitude Interpretation"
        self.gbAttributes.Add = self.pnlCodeDescrDistVer

        self.pnlVerDistLower = Frame(self.gbAttributes, "HL")
        self.gbAttributes.Add = self.pnlVerDistLower

        self.cmbDistVerLower = ComboBoxPanel(self.pnlVerDistLower)
        self.cmbDistVerLower.CaptionUnits = "ft"
        self.cmbDistVerLower.Caption = "Lower Altitude Limit"
        self.pnlVerDistLower.Add = self.cmbDistVerLower

        self.txtDistVerLower = AltitudeBoxPanel(self.pnlVerDistLower)
        self.txtDistVerLower.CaptionUnits = "ft"
        self.txtDistVerLower.LabelWidth = 0
        self.pnlVerDistLower.Add = self.txtDistVerLower

        self.pnlDistVerUpper = Frame(self.gbAttributes, "HL")
        self.gbAttributes.Add = self.pnlDistVerUpper

        self.cmbDistVerUpper = ComboBoxPanel(self.pnlDistVerUpper)
        self.cmbDistVerUpper.CaptionUnits = "ft"
        self.cmbDistVerUpper.Caption = "Upper Altitude Limit"
        self.pnlDistVerUpper.Add = self.cmbDistVerUpper

        self.txtDistVerUpper = AltitudeBoxPanel(self.pnlDistVerUpper)
        self.txtDistVerUpper.CaptionUnits = "ft"
        self.txtDistVerUpper.LabelWidth = 0
        self.pnlDistVerUpper.Add = self.txtDistVerUpper

        self.pnlValVerAngle = NumberBoxPanel(self.gbAttributes)
        self.pnlValVerAngle.Caption = "Climb / Descent Angle [+/-] (" + define._degreeStr + ")"
        self.gbAttributes.Add = self.pnlValVerAngle

        self.tableLayoutPanel2 = Frame(self.gbAttributes, "HL")
        self.gbAttributes.Add = self.tableLayoutPanel2

        self.cmbCodeSpeedRef = ComboBoxPanel(self.tableLayoutPanel2)
        self.cmbCodeSpeedRef.CaptionUnits = "kts"
        self.cmbCodeSpeedRef.Caption = "Speed Restriction"
        self.tableLayoutPanel2.Add = self.cmbCodeSpeedRef

        self.txtValSpeed = SpeedBoxPanel(self.tableLayoutPanel2)
        self.txtValSpeed.LabelWidth = 0
        self.tableLayoutPanel2.Add = self.txtValSpeed

        self.pnlValDist = DistanceBoxPanel(self.gbAttributes, DistanceUnits.NM)
        self.pnlValDist.Caption = "Segment Length"
        self.pnlValDist.Button = None
        self.gbAttributes.Add = self.pnlValDist

        self.pnlValDur = NumberBoxPanel(self.gbAttributes)
        self.pnlValDur.CaptionUnits = "min"
        self.pnlValDur.Caption = "Duration"
        self.gbAttributes.Add = self.pnlValDur

        self.pnlCodeRepAtc = ComboBoxPanel(self.gbAttributes)
        self.pnlCodeRepAtc.Caption = "ATC Reporting"
        self.gbAttributes.Add = self.pnlCodeRepAtc

        self.pnlValTheta = TrackRadialBoxPanel(self.gbAttributes)
        self.pnlValTheta.Caption = "Magnetic Bearing / Radial from Recommended Nav. Aid"
        self.pnlValTheta.LabelWidth = 350
        self.gbAttributes.Add = self.pnlValTheta

        self.pnlValRho = DistanceBoxPanel(self.gbAttributes, DistanceUnits.NM)
        self.pnlValRho.Caption = "Distance from Recommended Nav. Aid"
        self.pnlValRho.LabelWidth = 350
        self.gbAttributes.Add = self.pnlValRho

        self.txtRemarks = TextBoxPanel(self.gbAttributes, True)
        self.txtRemarks.Caption = "Remarks"
        self.gbAttributes.Add = self.txtRemarks

        self.btnBoxOkCancel = QDialogButtonBox(self)
        self.btnBoxOkCancel.setObjectName(("btnBoxOkCancel"));
        self.btnBoxOkCancel.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok);
        self.connect(self.btnBoxOkCancel, SIGNAL("accepted()"), self.acceptDlg)
        self.connect(self.btnBoxOkCancel, SIGNAL("rejected()"), self.reject)



        verticalLayoutDlg.addWidget(self.btnBoxOkCancel)

        self.trvLegs.pressed.connect(self.trvLegs_pressed)

        self.data = None
        self.legs = None
        self.aerodrome = None;
        self.magnVar = 0.0



        for value in CodeIapFixAixm.Items:
            self.pnlCodeRoleFix.Add(value);
        for codeTypeProcPathAixm in CodeTypeProcPathAixm.Items:
            self.pnlCodeType.Add(codeTypeProcPathAixm);
        for codePhaseProcAixm in CodePhaseProcAixm.Items:
            self.pnlCodePhase.Add(codePhaseProcAixm);
        for codeTypeCourseAixm in CodeTypeCourseAixm.Items:
            self.cmbCodeTypeCourse.Add(codeTypeCourseAixm);
        for codeDirTurnAixm in CodeDirTurnAixm.Items:
            self.pnlCodeDirTurn.Add(codeDirTurnAixm);
        for codeDescrDistVerAixm in CodeDescrDistVerAixm.Items:
            self.pnlCodeDescrDistVer.Add(codeDescrDistVerAixm);
        for codeDistVerAixm in CodeDistVerAixm.Items:
            self.cmbDistVerLower.Add(codeDistVerAixm);
        for value1 in CodeDistVerAixm.Items:
            self.cmbDistVerUpper.Add(value1);
        for codeSpeedRefAixm in CodeSpeedRefAixm.Items:
            self.cmbCodeSpeedRef.Add(codeSpeedRefAixm);
        for codeTypeFlyByAixm in CodeTypeFlyByAixm.Items:
            self.pnlTurnValid.Add(codeTypeFlyByAixm);
        for codeRepAtcAixm in CodeRepAtcAixm.Items:
            self.pnlCodeRepAtc.Add(codeRepAtcAixm);
        self.method_6()

        self.connect(self.pnlValRho, SIGNAL("Event_0"), self.pnlValRho_Event_0)
        self.connect(self.pnlValTheta, SIGNAL("Event_0"), self.pnlValTheta_Event_0)
        self.connect(self.pnlCodeRepAtc, SIGNAL("Event_0"), self.pnlCodeRepAtc_Event_0)
        self.connect(self.pnlValDur, SIGNAL("Event_0"), self.pnlValDur_Event_0)
        self.connect(self.pnlValDist, SIGNAL("Event_0"), self.pnlValDist_Event_0)
        self.connect(self.cmbCodeSpeedRef, SIGNAL("Event_0"), self.cmbCodeSpeedRef_Event_0)
        self.connect(self.txtValSpeed, SIGNAL("Event_0"), self.txtValSpeed_Event_0)
        self.connect(self.txtDistVerUpper, SIGNAL("Event_0"), self.txtDistVerUpper_Event_0)
        self.connect(self.cmbDistVerUpper, SIGNAL("Event_0"), self.cmbDistVerUpper_Event_0)
        self.connect(self.txtDistVerLower, SIGNAL("Event_0"), self.txtDistVerLower_Event_0)

        self.connect(self.cmbDistVerLower, SIGNAL("Event_0"), self.cmbDistVerLower_Event_0)
        self.connect(self.pnlValBankAngle, SIGNAL("Event_0"), self.pnlValBankAngle_Event_0)
        self.connect(self.cmbCenter, SIGNAL("Event_0"), self.cmbCenter_Event_0)
        self.connect(self.pnlTurnValid, SIGNAL("Event_0"), self.pnlTurnValid_Event_0)
        self.connect(self.pnlCodeDirTurn, SIGNAL("Event_0"), self.pnlCodeDirTurn_Event_0)
        self.connect(self.cmbCodeTypeCourse, SIGNAL("Event_0"), self.cmbCodeTypeCourse_Event_0)
        self.connect(self.txtValCourse, SIGNAL("Event_0"), self.txtValCourse_Event_0)
        self.connect(self.pnlCodeType, SIGNAL("Event_0"), self.pnlCodeType_Event_0)
        self.connect(self.pnlCodePhase, SIGNAL("Event_0"), self.pnlCodePhase_Event_0)
        self.connect(self.pnlCodeRoleFix, SIGNAL("Event_0"), self.pnlCodeRoleFix_Event_0)
        self.connect(self.txtRemarks, SIGNAL("Event_0"), self.txtRemarks_Event_0)
        self.connect(self.cmbRecommendedEnt, SIGNAL("Event_0"), self.cmbRecommendedEnt_Event_0)

        self.connect(self.cmbFixPos, SIGNAL("Event_0"), self.cmbFixPos_Event_0)
        self.connect(self.cmbCenter, SIGNAL("Event_3"), self.method_14)
        self.connect(self.cmbFixPos, SIGNAL("Event_3"), self.method_13)

        self.btnAdd.clicked.connect(self.btnAdd_Click)
        self.btnMoveDown.clicked.connect(self.btnMoveDown_Click)
        self.btnMoveUp.clicked.connect(self.btnMoveUp_Click)
        self.btnRemove.clicked.connect(self.btnRemove_Click)

        self.trvLegs.setHeaderHidden(True)

        if self.trvLegsStdModel.rowCount() > 0:
            self.trvLegs.setCurrentIndex(self.trvLegsStdModel.index(0,0))
            self.method_8()
        # rootModelIndex = self.trvLegs.rootIndex()
        # rootItem = self.trvLegsStdModel.itemFromIndex(rootModelIndex)
        # rootItem.setText("Legs")
    def btnAdd_Click(self):
        if (len(self.trvLegs.selectedIndexes()) == 0 and not self.method_5()):
            return;
        listInsertPosition = ListInsertPosition.Append;
        resultDlg, listInsertPosition = DlgAixmInsertLeg.smethod_0(listInsertPosition)
        if (self.trvLegsStdModel.rowCount() > 0 and not resultDlg):
            return;
        count = self.trvLegsStdModel.rowCount()
        if (listInsertPosition == ListInsertPosition.Before):
            count = self.trvLegs.selectedIndexes()[0].row();
        elif (listInsertPosition == ListInsertPosition.After):
            count = self.trvLegs.selectedIndexes()[0].row() + 1;
        self.trvLegsStdModel.setItem(self.trvLegsStdModel.rowCount(), QStandardItem(str(self.trvLegsStdModel.rowCount() + 1)));
        self.legs.insert(count, DataBaseProcedureLeg());
        self.trvLegs.setCurrentIndex(self.trvLegsStdModel.index(count, 0))
        self.trvLegs_pressed()
    def btnMoveDown_Click(self):
        if (len(self.trvLegs.selectedIndexes()) == 0):
            return;
        index = self.trvLegs.selectedIndexes()[0].row();
        item = self.legs[index];
        self.legs.pop(index);
        self.legs.insert(index + 1, item);
        self.trvLegs.setCurrentIndex(self.trvLegsStdModel.index(index + 1, 0))
        self.trvLegs_pressed()
    def btnMoveUp_Click(self):
        if (len(self.trvLegs.selectedIndexes()) == 0):
            return;
        index = self.trvLegs.selectedIndexes()[0].row();
        item = self.legs[index];
        self.legs.pop(index);
        self.legs.insert(index - 1, item);
        self.trvLegs.setCurrentIndex(self.trvLegsStdModel.index(index - 1, 0))
        self.trvLegs_pressed()
    def btnRemove_Click(self):
        item = None;
        if (len(self.trvLegs.selectedIndexes()) == 0):
            return;
        if (QMessageBox.question(self, "Question", "Are you sure you want to delete the selected procedure leg?", QMessageBox.Yes | QMessageBox.No) == QMessageBox.Yes):
            index = self.trvLegs.selectedIndexes()[0].row();
            self.legs.pop(index);
            self.trvLegsStdModel.takeRow(self.trvLegsStdModel.rowCount() - 1);
            if (index >= self.trvLegsStdModel.rowCount() - 1):
                index -= 1;
            # treeView = self.trvLegs;
            # if (index >= 0):
            if self.trvLegsStdModel.rowCount() > 0 and index < 0:
                index = 0
            self.trvLegs.setCurrentIndex(self.trvLegsStdModel.index(index, 0))

            self.trvLegs_pressed()
    def cmbRecommendedEnt_Event_0(self):
        self.method_10(self.cmbRecommendedEnt)
    def txtRemarks_Event_0(self):
        self.method_10(self.txtRemarks)
    def cmbFixPos_Event_0(self):
        self.method_10(self.cmbFixPos)
    def cmbDistVerLower_Event_0(self):
        self.method_10(self.cmbDistVerLower)
    def pnlValBankAngle_Event_0(self):
        self.method_10(self.pnlValBankAngle)
    def cmbCenter_Event_0(self):
        self.method_10(self.cmbCenter)
    def pnlTurnValid_Event_0(self):
        self.method_10(self.pnlTurnValid)
    def pnlCodeDirTurn_Event_0(self):
        self.method_10(self.pnlCodeDirTurn)
    def cmbCodeTypeCourse_Event_0(self):
        self.method_10(self.cmbCodeTypeCourse)
    def txtValCourse_Event_0(self):
        self.method_10(self.txtValCourse)
    def pnlCodeType_Event_0(self):
        self.method_10(self.pnlCodeType)
    def pnlCodePhase_Event_0(self):
        self.method_10(self.pnlCodePhase)
    def pnlCodeRoleFix_Event_0(self):
        self.method_10(self.pnlCodeRoleFix)
    def txtDistVerLower_Event_0(self):
        self.method_10(self.txtDistVerLower)
    def cmbDistVerUpper_Event_0(self):
        self.method_10(self.cmbDistVerUpper)
    def txtDistVerUpper_Event_0(self):
        self.method_10(self.txtDistVerUpper)
    def txtValSpeed_Event_0(self):
        self.method_10(self.txtValSpeed)
    def cmbCodeSpeedRef_Event_0(self):
        self.method_10(self.cmbCodeSpeedRef)
    def pnlValDist_Event_0(self):
        self.method_10(self.pnlValDist)
    def pnlValDur_Event_0(self):
        self.method_10(self.pnlValDur)
    def pnlCodeRepAtc_Event_0(self):
        self.method_10(self.pnlCodeRepAtc)
    def pnlValTheta_Event_0(self):
        self.method_10(self.pnlValTheta)
    def pnlValRho_Event_0(self):
        self.method_10(self.pnlValRho)
    def trvLegs_pressed(self):
        self.method_6()
        self.method_8()
    def acceptDlg(self):
        self.legs.refresh()
        QObject.emit(self, SIGNAL("DlgAixmProcLegs_Smethod_0_Event"), self.legs, self.data)
        self.accept()
    
    def method_5(self):
        pass
    def method_6(self):
        self.btnOK = self.btnBoxOkCancel.button(QDialogButtonBox.Ok)
        self.btnOK.setEnabled(len(self.trvLegs.selectedIndexes()) > 0)
        self.btnRemove.setEnabled(len(self.trvLegs.selectedIndexes()) > 0);
        self.btnMoveUp.setEnabled((len(self.trvLegs.selectedIndexes()) > 0 and self.trvLegs.selectedIndexes()[0].row() != 0) and True or False);
        self.btnMoveDown.setEnabled((len(self.trvLegs.selectedIndexes()) <=  0 or self.trvLegsStdModel.rowCount() <= 0) and False or ((len(self.trvLegs.selectedIndexes()) >  0) and self.trvLegs.selectedIndexes()[0].row() < self.trvLegsStdModel.rowCount() - 1));
	
    def method_7(self):
        for i in range(self.legs.Count):
            num = i + 1;
            self.trvLegsStdModel.setItem(i, QStandardItem(str(num)));
        self.method_6()
        # if (self.trvLegsStdModel.rowCount() > 0):
        #     self.trvLegs.setCurrentIndex() = self.trvLegs.Nodes[0];
    def method_8(self):
        if (len(self.trvLegs.selectedIndexes()) <= 0):
            self.scrollBox.Enabled = False;
            self.cmbFixPos.SelectedIndex = -1;
            self.pnlCodeRoleFix.SelectedIndex = -1;
            self.cmbRecommendedEnt.SelectedIndex = -1;
            self.pnlCodePhase.SelectedIndex = -1;
            self.pnlCodeType.SelectedIndex = -1;
            self.cmbCodeTypeCourse.SelectedIndex = -1;
            self.txtValCourse.Value = 0;
            self.pnlCodeDirTurn.SelectedIndex = -1;
            self.cmbCenter.SelectedIndex = -1;
            self.pnlTurnValid.SelectedIndex = -1;
            self.pnlValBankAngle.Value = 0;
            self.pnlCodeDescrDistVer.SelectedIndex = -1;
            self.cmbDistVerLower.SelectedIndex = -1;
            self.txtDistVerLower.Value = None;
            self.cmbDistVerUpper.SelectedIndex = -1;
            self.txtDistVerUpper.Value = None;
            self.pnlValVerAngle.Value = None;
            self.cmbCodeSpeedRef.SelectedIndex = -1;
            self.txtValSpeed.Value = None;
            self.pnlValDist.Value = None;
            self.pnlValDur.Value = 0;
            self.pnlCodeRepAtc.SelectedIndex = -1;
            self.pnlValTheta.Value = 0;
            self.pnlValRho.Value = None;
            self.txtRemarks.Value = ""
            return;
        self.scrollBox.Enabled = True;
        item = self.legs[self.trvLegs.selectedIndexes()[0].row()];
        if (item.PointEnt == None):
            self.cmbFixPos.SelectedIndex = -1;
        else:
            self.cmbFixPos.SelectedIndex = self.cmbFixPos.IndexOf(item.PointEnt);
        self.pnlCodeRoleFix.SelectedIndex = self.method_9(self.pnlCodeRoleFix.Items, item.CodeRoleFix);
        if (item.RecommendedEnt == None):
            self.cmbRecommendedEnt.SelectedIndex = -1;
        else:
            self.cmbRecommendedEnt.SelectedIndex = self.cmbRecommendedEnt.IndexOf(item.RecommendedEnt);
        self.pnlCodePhase.SelectedIndex = self.method_9(self.pnlCodePhase.Items, item.CodePhase);
        self.pnlCodeType.SelectedIndex = self.method_9(self.pnlCodeType.Items, item.CodeType);
        self.cmbCodeTypeCourse.SelectedIndex = self.method_9(self.cmbCodeTypeCourse.Items, item.CodeTypeCourse);
        self.txtValCourse.Value = item.ValCourse;
        self.pnlCodeDirTurn.SelectedIndex = self.method_9(self.pnlCodeDirTurn.Items, item.CodeDirTurn);
        if (item.CenterEnt == None):
            self.cmbCenter.SelectedIndex = -1;
        else:
            self.cmbCenter.SelectedIndex = self.cmbCenter.IndexOf(item.CenterEnt);
        self.pnlTurnValid.SelectedIndex = self.method_9(self.pnlTurnValid.Items, item.CodeTurnValid)
        self.pnlValBankAngle.Value = item.ValBankAngle;
        self.pnlCodeDescrDistVer.SelectedIndex = self.method_9(self.pnlCodeDescrDistVer.Items, item.CodeDescrDistVer)
        self.cmbDistVerLower.SelectedIndex = self.method_9(self.cmbDistVerLower.Items, item.CodeDistVerLower)
        self.txtDistVerLower.Value = item.ValDistVerLower;
        self.cmbDistVerUpper.SelectedIndex = self.method_9(self.cmbDistVerUpper.Items, item.CodeDistVerUpper)
        self.txtDistVerUpper.Value = item.ValDistVerUpper;
        self.pnlValVerAngle.Value = item.ValVerAngle;
        self.cmbCodeSpeedRef.SelectedIndex = self.method_9(self.cmbCodeSpeedRef.Items, item.CodeSpeedRef)
        self.txtValSpeed.Value = item.ValSpeedLimit;
        self.pnlValDist.Value = item.ValDist;
        self.pnlValDur.Value = item.ValDur;
        self.pnlCodeRepAtc.SelectedIndex = self.method_9(self.pnlCodeRepAtc.Items, item.CodeRepAtc)
        self.pnlValTheta.Value = item.ValTheta;
        self.pnlValRho.Value = item.ValRho;
        self.txtRemarks.Value = item.TxtRmk;
        self.method_6()

    def method_9(self, ilist_0, string_0):
        for i in range(len(ilist_0)):
            if (ilist_0[i] == string_0):
                return i;
        return -1;
    def method_10(self, sender):
        if (len(self.trvLegs.selectedIndexes()) == 0):
            return;
        item = self.legs[self.trvLegs.selectedIndexes()[0].row()];
        if (sender == self.cmbFixPos):
            item.PointEnt = self.cmbFixPos.SelectedItem;
        if (sender == self.pnlCodeRoleFix):
            item.CodeRoleFix = self.pnlCodeRoleFix.SelectedItem;
        if (sender == self.cmbRecommendedEnt):
            item.RecommendedEnt = self.cmbRecommendedEnt.SelectedItem
        if (sender == self.pnlCodePhase):
            item.CodePhase = self.pnlCodePhase.SelectedItem
        if (sender == self.pnlCodeType):
            item.CodeType = self.pnlCodeType.SelectedItem
        if (sender == self.cmbCodeTypeCourse):
            item.CodeTypeCourse = self.cmbCodeTypeCourse.SelectedItem
        if (sender == self.txtValCourse):
            item.ValCourse = self.txtValCourse.Value;
        if (sender == self.pnlCodeDirTurn):
            item.CodeDirTurn = self.pnlCodeDirTurn.SelectedItem
        if (sender == self.cmbCenter):
            item.CenterEnt = self.cmbCenter.SelectedItem;
            return;
        if (sender == self.pnlTurnValid):
            item.CodeTurnValid = self.pnlTurnValid.SelectedItem
            return;
        if (sender == self.pnlValBankAngle):
            item.ValBankAngle = self.pnlValBankAngle.Value;
            return;
        if (sender == self.pnlCodeDescrDistVer):
            item.CodeDescrDistVer = self.pnlTurnValid.SelectedItem
            return;
        if (sender == self.cmbDistVerLower):
            item.CodeDistVerLower = self.cmbDistVerLower.SelectedItem
            return;
        if (sender == self.txtDistVerLower):
            item.ValDistVerLower = self.txtDistVerLower.Value;
            return;
        if (sender == self.cmbDistVerUpper):
            item.CodeDistVerUpper = self.cmbDistVerUpper.SelectedItem
            return;
        if (sender == self.txtDistVerUpper):
            item.ValDistVerUpper = self.txtDistVerUpper.Value;
            return;
        if (sender == self.pnlValVerAngle):
            item.ValVerAngle = self.pnlValVerAngle.Value;
            return;
        if (sender == self.cmbCodeSpeedRef):
            item.CodeSpeedRef = self.cmbCodeSpeedRef.SelectedItem
            return;
        if (sender == self.txtValSpeed):
            item.ValSpeedLimit = self.txtValSpeed.Value;
            return;
        if (sender == self.pnlValDist):
            item.ValDist = self.pnlValDist.Value;
            return;
        if (sender == self.pnlValDur):
            item.ValDur = self.pnlValDur.Value;
            return;
        if (sender == self.pnlCodeRepAtc):
            item.CodeRepAtc = self.pnlCodeRepAtc.SelectedItem
            return;
        if (sender == self.pnlValTheta):
            item.ValTheta = self.pnlValTheta.Value;
            return;
        if (sender == self.pnlValRho):
            item.ValRho = self.pnlValRho.Value;
            return;
        if (sender == self.txtRemarks):
            item.TxtRmk = self.txtRemarks.Value;
    def method_13(self):
        point3d = None;
        procEntityBase = None;
        selectTool = DlgAixmSelectPosition.smethod_0(self.data, point3d, ProcEntityListType.Fixes)
        QObject.connect(selectTool, SIGNAL("DlgAixmSelectPosition_Smethod_0_Event"), self.method_13_Event)
    def method_13_Event(self, flag, procEntityBase):
        # flag, procEntityBase = DlgAixmSelectPosition.smethod_0(self.data, point3d, ProcEntityListType.Fixes)
        if (flag and procEntityBase != None):
            if (not self.cmbFixPos.Contains(procEntityBase)):
                self.cmbFixPos.Add(procEntityBase);
            self.cmbFixPos.SelectedIndex = self.cmbFixPos.IndexOf(procEntityBase);
            self.method_10(self.cmbFixPos);

    def method_14(self):
        point3d = None;
        procEntityBase = None;
        selectTool = DlgAixmSelectPosition.smethod_0(self.data, point3d, ProcEntityListType.Centers)
        QObject.connect(selectTool, SIGNAL("DlgAixmSelectPosition_Smethod_0_Event"), self.method_14_Event)
    def method_14_Event(self, flag, procEntityBase):
        # flag, procEntityBase = DlgAixmSelectPosition.smethod_0(self.data, point3d, ProcEntityListType.Centers)
        if (flag and procEntityBase != None):
            if (not self.cmbCenter.Contains(procEntityBase)):
                self.cmbCenter.Add(procEntityBase);
            self.cmbCenter.SelectedIndex = self.cmbCenter.IndexOf(procEntityBase);
            self.method_10(self.cmbCenter);
    @staticmethod
    def smethod_0(parent, dataBaseProcedureLegs_0, dataBaseProcedureData_0, procEntityAHP_0):
        flag = False
        dlgAixmProcLeg = DlgAixmProcLegs(parent)
        dlgAixmProcLeg.legs = dataBaseProcedureLegs_0;
        dlgAixmProcLeg.data = dataBaseProcedureData_0;
        if (procEntityAHP_0 != None):
            dlgAixmProcLeg.aerodrome = procEntityAHP_0;
            dlgAixmProcLeg.magnVar = procEntityAHP_0.ValMagVar;
        dataBaseProcedureData_0.method_59(dlgAixmProcLeg.cmbFixPos, ProcEntityListType.Fixes);
        dataBaseProcedureData_0.method_59(dlgAixmProcLeg.cmbCenter, ProcEntityListType.Centers);
        dataBaseProcedureData_0.method_59(dlgAixmProcLeg.cmbRecommendedEnt, ProcEntityListType.RecommendedNavAids);
        if (dlgAixmProcLeg.legs.Count == 0):
            dlgAixmProcLeg.legs.Add(DataBaseProcedureLeg());

        dlgAixmProcLeg.method_7()
        if dlgAixmProcLeg.trvLegsStdModel.rowCount() > 0:
            dlgAixmProcLeg.trvLegs.setCurrentIndex(dlgAixmProcLeg.trvLegsStdModel.index(0,0))
            dlgAixmProcLeg.method_6()

        dlgAixmProcLeg.method_8();
        dlgAixmProcLeg.show()
        return dlgAixmProcLeg