Skip to content

Graphical User Interface: Setup window

Bases: QDialog

Creates a new dialog with configuration options for the user, when is pressed the Setup > Setup devices and more menu.

Source code in GUI_A2G_MEAS.py
class SetupWindow(QDialog):
    """
    Creates a new dialog with configuration options for the user, when is pressed the ``Setup`` > ``Setup devices and more`` menu.
    """
    def __init__(self, parent=None):
        """
        Creates the PyQt5 components of the setup dialog and sets its layout with them.

        Args:
            parent (none, optional): not used. Defaults to None.
        """

        super(SetupWindow, self).__init__(parent)
        self.setWindowTitle("Setup")
        #self.setGeometry(100, 100, 300, 220)
        self.drone_static_coords_list_array = []
        self.gnd_static_coords_list_array = []

        self.droneGimbalChoiceTDMenu = QComboBox()
        self.droneGimbalChoiceTDMenu.addItems(["DJI Ronin RS2", "Gremsy H16"])

        droneGimbalChoiceLabel = QLabel("&Choose drone gimbal:")
        droneGimbalChoiceLabel.setBuddy(self.droneGimbalChoiceTDMenu)

        self.fm_droneGimbal_TDMenu = QComboBox()
        self.fm_droneGimbal_TDMenu.addItems(["Only elevation", "Only azimuth", "Elevation and azimuth"])

        fmdroneGimbalChoiceLabel = QLabel("&Choose drone gimbal following mode (if it will be used):")
        fmdroneGimbalChoiceLabel.setBuddy(self.fm_droneGimbal_TDMenu)

        self.fm_gndGimbal_TDMenu = QComboBox()
        self.fm_gndGimbal_TDMenu.addItems(["Only elevation", "Only azimuth", "Elevation and azimuth"])

        fmgndGimbalChoiceLabel = QLabel("&Choose ground gimbal following mode (if it will be used):")
        fmgndGimbalChoiceLabel.setBuddy(self.fm_gndGimbal_TDMenu)

        self.gnd_mobility_TDMenu = QComboBox()
        self.gnd_mobility_TDMenu.addItems(["Moving", "Static"])
        self.gnd_mobility_TDMenu.activated[str].connect(self.enable_gnd_coords_callback)

        gnd_mobility_label = QLabel("&Choose ground node mobility:")
        gnd_mobility_label.setBuddy(self.gnd_mobility_TDMenu)

        self.gnd_lat_textEdit = QLineEdit('')
        gnd_lat_label = QLabel("Enter lat of static (ground) node:")
        self.gnd_lon_textEdit = QLineEdit('')
        gnd_lon_label = QLabel("Enter lon of static (ground) node:")
        self.gnd_alt_textEdit = QLineEdit('')
        gnd_alt_label = QLabel("Enter altitude of static (ground) node:")

        gnd_list_coords_label = QLabel("List of static gnd coordinates:")
        self.gnd_list_coords_textEdit = QTextEdit("")
        self.gnd_list_coords_textEdit.setEnabled(False)

        self.button_add_gnd_coord = QPushButton("Add coordinate")
        self.button_add_gnd_coord.clicked.connect(self.setup_window_add_gnd_coord_callback)

        self.gnd_lat_textEdit.setEnabled(False)
        self.gnd_lon_textEdit.setEnabled(False)
        self.gnd_alt_textEdit.setEnabled(False)

        self.drone_mobility_TDMenu = QComboBox()
        self.drone_mobility_TDMenu.addItems(["Moving", "Static"])
        self.drone_mobility_TDMenu.activated[str].connect(self.enable_drone_coords_callback)

        drone_mobility_label = QLabel("&Choose drone node mobility:")
        drone_mobility_label.setBuddy(self.drone_mobility_TDMenu)

        self.drone_lat_textEdit = QLineEdit('')
        drone_lat_label = QLabel("Enter lat of static (drone) node:")
        self.drone_lon_textEdit = QLineEdit('')
        drone_lon_label = QLabel("Enter lon of static (drone) node:")
        self.drone_alt_textEdit = QLineEdit('')
        drone_alt_label = QLabel("Enter alt of static (drone) node:")

        drone_list_coords_label = QLabel("List of static drone coordinates:")
        self.drone_list_coords_textEdit = QTextEdit("")
        self.drone_list_coords_textEdit.setEnabled(False)

        self.button_add_drone_coord = QPushButton("Add coordinate")
        self.button_add_drone_coord.clicked.connect(self.setup_window_add_drone_coord_callback)

        self.drone_lat_textEdit.setEnabled(False)
        self.drone_lon_textEdit.setEnabled(False)
        self.drone_alt_textEdit.setEnabled(False)

        self.gnd_gps_att_offset_textEdit = QLineEdit('0')
        gnd_gps_att_offset_label = QLabel("Enter the heading offset for the ground gps:")

        self.ok_button = QPushButton("OK")
        self.ok_button.clicked.connect(self.accept)

        layout = QGridLayout()
        layout.addWidget(droneGimbalChoiceLabel, 0, 0, 1, 3)
        layout.addWidget(self.droneGimbalChoiceTDMenu, 0, 3, 1, 3)
        layout.addWidget(fmdroneGimbalChoiceLabel, 1, 0, 1, 3)
        layout.addWidget(self.fm_droneGimbal_TDMenu, 1, 3, 1, 3)
        layout.addWidget(fmgndGimbalChoiceLabel, 2, 0, 1, 3)
        layout.addWidget(self.fm_gndGimbal_TDMenu, 2, 3, 1, 3)

        layout.addWidget(gnd_mobility_label, 3, 0, 1, 3)
        layout.addWidget(self.gnd_mobility_TDMenu, 3, 3, 1, 3)
        layout.addWidget(gnd_lat_label, 4, 0, 1, 3)
        layout.addWidget(self.gnd_lat_textEdit, 4, 3, 1, 3)
        layout.addWidget(gnd_lon_label, 5, 0, 1, 3)
        layout.addWidget(self.gnd_lon_textEdit, 5, 3, 1, 3)
        layout.addWidget(gnd_alt_label, 6, 0, 1, 3)
        layout.addWidget(self.gnd_alt_textEdit, 6, 3, 1, 3)

        layout.addWidget(gnd_list_coords_label, 7, 0, 1, 3)
        layout.addWidget(self.button_add_gnd_coord, 8, 0, 1, 3)
        layout.addWidget(self.gnd_list_coords_textEdit, 7, 3, 2, 3)   

        layout.addWidget(drone_mobility_label, 9, 0, 1, 3)
        layout.addWidget(self.drone_mobility_TDMenu, 9, 3, 1, 3)
        layout.addWidget(drone_lat_label, 10, 0, 1, 3)
        layout.addWidget(self.drone_lat_textEdit, 10, 3, 1, 3)
        layout.addWidget(drone_lon_label, 11, 0, 1, 3)
        layout.addWidget(self.drone_lon_textEdit, 11, 3, 1, 3)
        layout.addWidget(drone_alt_label, 12, 0, 1, 3)
        layout.addWidget(self.drone_alt_textEdit, 12, 3, 1, 3)

        layout.addWidget(drone_list_coords_label, 13, 0, 1, 3)
        layout.addWidget(self.button_add_drone_coord, 14, 0, 1, 3)
        layout.addWidget(self.drone_list_coords_textEdit, 13, 3, 2, 3)        

        layout.addWidget(gnd_gps_att_offset_label, 15, 0, 1, 3)
        layout.addWidget(self.gnd_gps_att_offset_textEdit, 15, 3, 1, 3)

        layout.addWidget(self.ok_button, 16, 0, 1, 6)
        self.setLayout(layout)  

    def setup_window_add_drone_coord_callback(self):
        self.drone_static_coords_list_array.append([float(self.drone_lat_textEdit.text()), 
                                                    float(self.drone_lon_textEdit.text()), 
                                                    float(self.drone_alt_textEdit.text())])

        if (self.drone_list_coords_textEdit.toPlainText() == ""):
            newText = f"LAT: {self.drone_lat_textEdit.text()}, LON: {self.drone_lon_textEdit.text()}, ALT: {self.drone_alt_textEdit.text()}"
        else:
            newText = self.drone_list_coords_textEdit.toPlainText() + "\n" + f"LAT: {self.drone_lat_textEdit.text()}, LON: {self.drone_lon_textEdit.text()}, ALT: {self.drone_alt_textEdit.text()}"
        self.drone_list_coords_textEdit.setText(newText)

    def setup_window_add_gnd_coord_callback(self):
        self.gnd_static_coords_list_array.append([float(self.gnd_lat_textEdit.text()), 
                                                    float(self.gnd_lon_textEdit.text()), 
                                                    float(self.gnd_alt_textEdit.text())])

        if (self.gnd_list_coords_textEdit.toPlainText() == ""):
            newText = f"LAT: {self.gnd_lat_textEdit.text()}, LON: {self.gnd_lon_textEdit.text()}, ALT: {self.gnd_alt_textEdit.text()}"
        else:
            newText = self.gnd_list_coords_textEdit.toPlainText() + "\n" + f"LAT: {self.gnd_lat_textEdit.text()}, LON: {self.gnd_lon_textEdit.text()}, ALT: {self.gnd_alt_textEdit.text()}"
        self.gnd_list_coords_textEdit.setText(newText)

    def enable_gnd_coords_callback(self, myinput):
        """
        Enables the ground coordinates QLineEdits when the user inputs a ``Static`` mobility for the ground node in the Setup dialog.

        Args:
            myinput (str): ground node mobility. Either ``Static`` or ``Moving``.
        """

        if myinput == "Static":
            self.gnd_lat_textEdit.setEnabled(True)
            self.gnd_lon_textEdit.setEnabled(True)
            self.gnd_alt_textEdit.setEnabled(True)
        elif myinput == "Moving":
            self.gnd_lat_textEdit.setEnabled(False)
            self.gnd_lon_textEdit.setEnabled(False)
            self.gnd_alt_textEdit.setEnabled(False)

    def enable_drone_coords_callback(self, myinput):
        """
        Enables the drone coordinates QLineEdits when the user inputs a ``Static`` mobility for the drone node in the Setup dialog.

        Args:
            myinput (str): drone node mobility. Either ``Static`` or ``Moving``.
        """

        if myinput == "Static":
            self.drone_lat_textEdit.setEnabled(True)
            self.drone_lon_textEdit.setEnabled(True)
            self.drone_alt_textEdit.setEnabled(True)
        elif myinput == "Moving":
            self.drone_lat_textEdit.setEnabled(False)
            self.drone_lon_textEdit.setEnabled(False)
            self.drone_alt_textEdit.setEnabled(False)

__init__(parent=None)

Creates the PyQt5 components of the setup dialog and sets its layout with them.

Parameters:

Name Type Description Default
parent none

not used. Defaults to None.

None
Source code in GUI_A2G_MEAS.py
def __init__(self, parent=None):
    """
    Creates the PyQt5 components of the setup dialog and sets its layout with them.

    Args:
        parent (none, optional): not used. Defaults to None.
    """

    super(SetupWindow, self).__init__(parent)
    self.setWindowTitle("Setup")
    #self.setGeometry(100, 100, 300, 220)
    self.drone_static_coords_list_array = []
    self.gnd_static_coords_list_array = []

    self.droneGimbalChoiceTDMenu = QComboBox()
    self.droneGimbalChoiceTDMenu.addItems(["DJI Ronin RS2", "Gremsy H16"])

    droneGimbalChoiceLabel = QLabel("&Choose drone gimbal:")
    droneGimbalChoiceLabel.setBuddy(self.droneGimbalChoiceTDMenu)

    self.fm_droneGimbal_TDMenu = QComboBox()
    self.fm_droneGimbal_TDMenu.addItems(["Only elevation", "Only azimuth", "Elevation and azimuth"])

    fmdroneGimbalChoiceLabel = QLabel("&Choose drone gimbal following mode (if it will be used):")
    fmdroneGimbalChoiceLabel.setBuddy(self.fm_droneGimbal_TDMenu)

    self.fm_gndGimbal_TDMenu = QComboBox()
    self.fm_gndGimbal_TDMenu.addItems(["Only elevation", "Only azimuth", "Elevation and azimuth"])

    fmgndGimbalChoiceLabel = QLabel("&Choose ground gimbal following mode (if it will be used):")
    fmgndGimbalChoiceLabel.setBuddy(self.fm_gndGimbal_TDMenu)

    self.gnd_mobility_TDMenu = QComboBox()
    self.gnd_mobility_TDMenu.addItems(["Moving", "Static"])
    self.gnd_mobility_TDMenu.activated[str].connect(self.enable_gnd_coords_callback)

    gnd_mobility_label = QLabel("&Choose ground node mobility:")
    gnd_mobility_label.setBuddy(self.gnd_mobility_TDMenu)

    self.gnd_lat_textEdit = QLineEdit('')
    gnd_lat_label = QLabel("Enter lat of static (ground) node:")
    self.gnd_lon_textEdit = QLineEdit('')
    gnd_lon_label = QLabel("Enter lon of static (ground) node:")
    self.gnd_alt_textEdit = QLineEdit('')
    gnd_alt_label = QLabel("Enter altitude of static (ground) node:")

    gnd_list_coords_label = QLabel("List of static gnd coordinates:")
    self.gnd_list_coords_textEdit = QTextEdit("")
    self.gnd_list_coords_textEdit.setEnabled(False)

    self.button_add_gnd_coord = QPushButton("Add coordinate")
    self.button_add_gnd_coord.clicked.connect(self.setup_window_add_gnd_coord_callback)

    self.gnd_lat_textEdit.setEnabled(False)
    self.gnd_lon_textEdit.setEnabled(False)
    self.gnd_alt_textEdit.setEnabled(False)

    self.drone_mobility_TDMenu = QComboBox()
    self.drone_mobility_TDMenu.addItems(["Moving", "Static"])
    self.drone_mobility_TDMenu.activated[str].connect(self.enable_drone_coords_callback)

    drone_mobility_label = QLabel("&Choose drone node mobility:")
    drone_mobility_label.setBuddy(self.drone_mobility_TDMenu)

    self.drone_lat_textEdit = QLineEdit('')
    drone_lat_label = QLabel("Enter lat of static (drone) node:")
    self.drone_lon_textEdit = QLineEdit('')
    drone_lon_label = QLabel("Enter lon of static (drone) node:")
    self.drone_alt_textEdit = QLineEdit('')
    drone_alt_label = QLabel("Enter alt of static (drone) node:")

    drone_list_coords_label = QLabel("List of static drone coordinates:")
    self.drone_list_coords_textEdit = QTextEdit("")
    self.drone_list_coords_textEdit.setEnabled(False)

    self.button_add_drone_coord = QPushButton("Add coordinate")
    self.button_add_drone_coord.clicked.connect(self.setup_window_add_drone_coord_callback)

    self.drone_lat_textEdit.setEnabled(False)
    self.drone_lon_textEdit.setEnabled(False)
    self.drone_alt_textEdit.setEnabled(False)

    self.gnd_gps_att_offset_textEdit = QLineEdit('0')
    gnd_gps_att_offset_label = QLabel("Enter the heading offset for the ground gps:")

    self.ok_button = QPushButton("OK")
    self.ok_button.clicked.connect(self.accept)

    layout = QGridLayout()
    layout.addWidget(droneGimbalChoiceLabel, 0, 0, 1, 3)
    layout.addWidget(self.droneGimbalChoiceTDMenu, 0, 3, 1, 3)
    layout.addWidget(fmdroneGimbalChoiceLabel, 1, 0, 1, 3)
    layout.addWidget(self.fm_droneGimbal_TDMenu, 1, 3, 1, 3)
    layout.addWidget(fmgndGimbalChoiceLabel, 2, 0, 1, 3)
    layout.addWidget(self.fm_gndGimbal_TDMenu, 2, 3, 1, 3)

    layout.addWidget(gnd_mobility_label, 3, 0, 1, 3)
    layout.addWidget(self.gnd_mobility_TDMenu, 3, 3, 1, 3)
    layout.addWidget(gnd_lat_label, 4, 0, 1, 3)
    layout.addWidget(self.gnd_lat_textEdit, 4, 3, 1, 3)
    layout.addWidget(gnd_lon_label, 5, 0, 1, 3)
    layout.addWidget(self.gnd_lon_textEdit, 5, 3, 1, 3)
    layout.addWidget(gnd_alt_label, 6, 0, 1, 3)
    layout.addWidget(self.gnd_alt_textEdit, 6, 3, 1, 3)

    layout.addWidget(gnd_list_coords_label, 7, 0, 1, 3)
    layout.addWidget(self.button_add_gnd_coord, 8, 0, 1, 3)
    layout.addWidget(self.gnd_list_coords_textEdit, 7, 3, 2, 3)   

    layout.addWidget(drone_mobility_label, 9, 0, 1, 3)
    layout.addWidget(self.drone_mobility_TDMenu, 9, 3, 1, 3)
    layout.addWidget(drone_lat_label, 10, 0, 1, 3)
    layout.addWidget(self.drone_lat_textEdit, 10, 3, 1, 3)
    layout.addWidget(drone_lon_label, 11, 0, 1, 3)
    layout.addWidget(self.drone_lon_textEdit, 11, 3, 1, 3)
    layout.addWidget(drone_alt_label, 12, 0, 1, 3)
    layout.addWidget(self.drone_alt_textEdit, 12, 3, 1, 3)

    layout.addWidget(drone_list_coords_label, 13, 0, 1, 3)
    layout.addWidget(self.button_add_drone_coord, 14, 0, 1, 3)
    layout.addWidget(self.drone_list_coords_textEdit, 13, 3, 2, 3)        

    layout.addWidget(gnd_gps_att_offset_label, 15, 0, 1, 3)
    layout.addWidget(self.gnd_gps_att_offset_textEdit, 15, 3, 1, 3)

    layout.addWidget(self.ok_button, 16, 0, 1, 6)
    self.setLayout(layout)  

enable_drone_coords_callback(myinput)

Enables the drone coordinates QLineEdits when the user inputs a Static mobility for the drone node in the Setup dialog.

Parameters:

Name Type Description Default
myinput str

drone node mobility. Either Static or Moving.

required
Source code in GUI_A2G_MEAS.py
def enable_drone_coords_callback(self, myinput):
    """
    Enables the drone coordinates QLineEdits when the user inputs a ``Static`` mobility for the drone node in the Setup dialog.

    Args:
        myinput (str): drone node mobility. Either ``Static`` or ``Moving``.
    """

    if myinput == "Static":
        self.drone_lat_textEdit.setEnabled(True)
        self.drone_lon_textEdit.setEnabled(True)
        self.drone_alt_textEdit.setEnabled(True)
    elif myinput == "Moving":
        self.drone_lat_textEdit.setEnabled(False)
        self.drone_lon_textEdit.setEnabled(False)
        self.drone_alt_textEdit.setEnabled(False)

enable_gnd_coords_callback(myinput)

Enables the ground coordinates QLineEdits when the user inputs a Static mobility for the ground node in the Setup dialog.

Parameters:

Name Type Description Default
myinput str

ground node mobility. Either Static or Moving.

required
Source code in GUI_A2G_MEAS.py
def enable_gnd_coords_callback(self, myinput):
    """
    Enables the ground coordinates QLineEdits when the user inputs a ``Static`` mobility for the ground node in the Setup dialog.

    Args:
        myinput (str): ground node mobility. Either ``Static`` or ``Moving``.
    """

    if myinput == "Static":
        self.gnd_lat_textEdit.setEnabled(True)
        self.gnd_lon_textEdit.setEnabled(True)
        self.gnd_alt_textEdit.setEnabled(True)
    elif myinput == "Moving":
        self.gnd_lat_textEdit.setEnabled(False)
        self.gnd_lon_textEdit.setEnabled(False)
        self.gnd_alt_textEdit.setEnabled(False)