def get_dependencies_sc(self, a_sc):
        """
        Get the s/c on which a_sc depends on (e.g. one of its trajectories depend on another s/c's given trajectory.
        :param a_sc: the s/c to which query all its dependencies s/cs.
        :return: str
        """
        sonet_log(SonetLogType.INFO, 'SonetCanvasQt.get_dependencies_sc')

        res = {}

        # It can be a list of one or two filters (e.g. Earth-Mars, or E-M + Mars-Earth).
        the_filters = a_sc.get_filter(p_get_list=True)

        for f in the_filters:
            # Get the ComplexDate filter (only consider activated ones).
            data = SonetTrajectoryFilter._get_activated_filters_of_a_given_type(f.get_data(), True, 'ComplexDate')
            n = len(data)  # LESSON LEARNED: if you put len(data) inside range(), strange things happen. :S
            if n:
                data = data.to_list()
                for row in range(n):
                    # Add all the ComplexDate filters (aka rows) of this filter.
                    complex_date_filter = data[row]
                    dependency_name = complex_date_filter[6]
                    dependency_payload = self.get_sc_payload(database.get_spacecraft(dependency_name))

                    my_trip = TripType.convert_to_str(f.get_trip_type())
                    dependency_trip = complex_date_filter[7]
                    dependency_type = self.get_dependency_type(my_trip, dependency_trip)

                    res[dependency_name] = dependency_payload + ' ' + dependency_type

        return res
    def clicked_view_mission(self):
        sonet_log(SonetLogType.INFO, 'SonetMainWindow.clicked_view_mission')
        # self.statusbar.showMessage('Not yet implemented :).', SONET_MSG_TIMEOUT)

        # self.statusbar.showMessage('Drawing the mission...', 1000)
        self.canvas_window = SonetCanvasQt(mw=self)
        self.canvas_window.init()
Esempio n. 3
0
    def get_trajectory_selection_status(self):
        """
        Getter method.
        Returns the current trajectory selection status:
        0 if no trajectory is selected.
        0.5 if 1 out of 2 trajectories are selected (for two-way spacecrafts).
        1 if all the trajectories are selected.
        :return: 0, 0.5, or 1.
        """
        if self._has_return_trajectory:
            # Two-way s/c.
            A = (self._trajectory1 is None) and (self._trajectory2 is None)
            B = (self._trajectory1 is None) or (self._trajectory2 is None)
            C = isinstance(self._trajectory1, pd.Series) and isinstance(self._trajectory2, pd.Series)
            if A:
                return 0
            elif C:
                return 1
            elif B:
                return 0.5
            else:
                sonet_log(SonetLogType.ERROR,
                          'SonetSpacecraft.get_trajectory_selection_status."Wrong trajectory type"')
                return

        else:
            # One-way s/c.
            if self._trajectory is None:
                return 0
            elif isinstance(self._trajectory, pd.Series):
                return 1
            else:
                sonet_log(SonetLogType.ERROR,
                          'SonetSpacecraft.get_trajectory_selection_status."Wrong trajectory type"')
                return
Esempio n. 4
0
    def set_trajectory(self, a_trajectory=None, a_index=False, a_is_incoming_trajectory=False):
        """
        Setter method.
        Sets the trajectories fields for a given s/c, the a_is_incoming_trajectory paramenter controls whether
        we are setting the outgoing or incoming trajectory, in case the s/c has both. It's a bit weird but...

        @param a_is_incoming_trajectory: flag to control which trajectory are we setting.
        @param a_trajectory: Pandas Series representing a pcp row.
        @param a_index: the position of the pcp row.
        """
        # Check.
        if not (isinstance(a_trajectory, pd.Series) or isinstance(a_trajectory, list) or (a_index != None)):
            if a_trajectory is None:
                sonet_log(SonetLogType.INFO, 'SonetSpacecraft.set_trajectory."No trajectory selected"')
                self._p_main_window.statusbar.showMessage('No trajectory selected.', SONET_MSG_TIMEOUT)
                return
            else:
                sonet_log(SonetLogType.ERROR, 'SonetSpacecraft.set_trajectory."Wrong trajectory type"')
                self._p_main_window.statusbar.showMessage('UUups. Internal error, check debug log.')
                return False

        if self._has_return_trajectory:
            # Two-way s/c.
            if a_is_incoming_trajectory:
                self._trajectory2 = a_trajectory
                self._trajectory2_index = a_index
            else:
                self._trajectory1 = a_trajectory
                self._trajectory1_index = a_index
        else:
            # One-way s/c.
            self._trajectory = a_trajectory
            self._trajectory_index = a_index

        return True
    def clicked_select_trajectory(self, p_called_from_pcp_viewer=False, p_pcp_viewer_selected_trajectory=None, p_idx=None):
        """
        Gets the current selection for the current selected s/c and stores it inside the s/c.
        If no selection, displays a msg in the main window status bar.
        It also informs to the user, by updating the relevant widgets.
        Update: Refactored to include also the possibility to be called from clicked_pcp_viewer.
        Update: Refactored to include also the possibility to be called by passing directly the df index.
        """
        sonet_log(SonetLogType.INFO, 'SonetMainWindow.clicked_select_trajectory')

        # Get the current selected s/c.
        idx = self.sonet_mission_tree_qlv.currentIndex().row()
        sc = self._list_model.get_spacecraft(a_row=idx)

        # Check
        if sc is None:
            sonet_log(SonetLogType.INFO, 'SonetMainWindow.clicked_select_trajectory."No s/c selected"')
            self.statusbar.showMessage('No s/c selected.', SONET_MSG_TIMEOUT)
            return False

        # Set the selected trajectory within the s/c.
        the_selected_trajectory: pd.Series
        the_selected_trajectory, idx, is_incoming_trajectory = self.get_selected_trajectory(p_called_from_pcp_viewer, p_pcp_viewer_selected_trajectory, p_idx=p_idx)
        sc.set_trajectory(the_selected_trajectory, idx, a_is_incoming_trajectory=is_incoming_trajectory)

        # Update the trajectory label & progress bar.
        status = sc.get_trajectory_selection_status()
        self.update_trajectory_label_and_progress_bar(status)
        force_table_view_update()
        # Force focus on main window.
        self.raise_()
    def clicked_unselect_trajectory(self):
        """
        Gets the current selected s/c and resets its selected trajectory, if any.
        If no selection, displays a msg in the main window status bar.
        It also informs to the user, by updating the relevant widgets.
        """
        sonet_log(SonetLogType.INFO, 'SonetMainWindow.clicked_unselect_trajectory')

        # Get the current selected s/c.
        index = self.sonet_mission_tree_qlv.currentIndex().row()
        sc = self._list_model.get_spacecraft(a_row=index)

        # Check
        if sc is None:
            sonet_log(SonetLogType.INFO, 'SonetMainWindow.clicked_unselect_trajectory."No s/c selected"')
            self.statusbar.showMessage('No s/c selected.', SONET_MSG_TIMEOUT)
            return

        # Reset the selected trajectory, if any.
        sc.reset_trajectory(p_all_trajectories=False,
                            p_trajectory=self.sonet_pcp_tabs_qtw.currentIndex())

        # Update the trajectory label & progress bar.
        status = sc.get_trajectory_selection_status()
        self.update_trajectory_label_and_progress_bar(status)
        force_table_view_update()
        # Force focus on main window.
        self.raise_()
Esempio n. 7
0
    def set_filters(self):
        """
        Method for constructing a SonetSpacecraft object. The spacecraft has one filter per trajectory.
        TODO: Bad practice - defining instance attributes outside the class constructor.
        :return: True if everything was ok, false otherwise.
        """
        sonet_log(SonetLogType.INFO, 'SonetSpacecraft.set_filters')

        has_return_trajectory = self._has_return_trajectory

        # Type check.
        if not isinstance(has_return_trajectory, bool):
            return False

        if has_return_trajectory:
            # Two way trip.
            self._pcp_filter1 = SonetTrajectoryFilter(self, TripType.OUTGOING)
            self._pcp_filter2 = SonetTrajectoryFilter(self, TripType.INCOMING)

            self._trajectory1 = None
            self._trajectory2 = None

            self._trajectory1_index = QModelIndex()
            self._trajectory2_index = QModelIndex()

        else:
            # One way trip.
            self._pcp_filter = SonetTrajectoryFilter(self, TripType.OUTGOING)

            self._trajectory = None
            self._trajectory_index = QModelIndex()

        return True
Esempio n. 8
0
    def get_trajectory_selected(self, p_get_trajectories=False):
        """
        Returns a list with the current selected trajectories.

        @return: ['Earth - Mars'] or ['Earth - Mars', 'Mars - Earth']
        :rtype: list
        """
        sonet_log(SonetLogType.INFO, 'SonetSpacecraft.get_trajectory_selected')

        if p_get_trajectories:
            the_selected_trajectories = {}
        else:
            the_selected_trajectories = []

        if self._has_return_trajectory:
            # Two-way s/c.
            if self._trajectory1 is not None:
                if p_get_trajectories:
                    the_selected_trajectories['Earth - Mars'] = self._trajectory1
                else:
                    the_selected_trajectories.append('Earth - Mars')
            if self._trajectory2 is not None:
                if p_get_trajectories:
                    the_selected_trajectories['Mars - Earth'] = self._trajectory2
                else:
                    the_selected_trajectories.append('Mars - Earth')
        else:
            # One-way s/c.
            if self._trajectory is not None:
                if p_get_trajectories:
                    the_selected_trajectories['Earth - Mars'] = self._trajectory
                else:
                    the_selected_trajectories.append('Earth - Mars')

        return the_selected_trajectories
Esempio n. 9
0
    def get_filter_data(self, p_get_dataframe_copy=False):
        """
        Getter method.
        It's not the same to return a dataframe and a dataframe.copy(). get_dataframe_copy controls if we are getting
        the pointers to the original dataframes or copies of them.
         - If I return a dataframe, I am returning a pointer to the original dataframe, so all modifications are going
         to affect to the original dataframe.
         - If I return a dataframe copy, I am returning a new dataframe, so all modifications are not going to affect to
         the original dataframe.
         :param p_get_dataframe_copy: bool representing if we want original dataframes or copies.
        :return: a pandas dataframe or a list of them.
        :rtype: DataFrame
        :rtype: list
        """
        # Type check.
        if not isinstance(self._has_return_trajectory, bool):
            sonet_log(SonetLogType.ERROR, 'SonetSpacecraft.get_filter_data."Bad constructed S/C"')
            return False  # _has_return_trajectory should be bool, if not, there's some error.

        if self._has_return_trajectory:
            # If there are both outgoing and incoming trajectories, we return a list with both filter's dataframes.
            if p_get_dataframe_copy:
                return [self._pcp_filter1.get_data().copy(), self._pcp_filter2.get_data().copy()]
            else:
                return [self._pcp_filter1.get_data(), self._pcp_filter2.get_data()]
        else:
            # In case the spacecraft has no return trajectory, we just get the filter dataframe of the outgoing one.
            if p_get_dataframe_copy:
                return self._pcp_filter.get_data().copy()
            else:
                return self._pcp_filter.get_data()
    def get_sc_payload(self, a_sc):
        sonet_log(SonetLogType.INFO, 'SonetCanvasQt.get_sc_payload')

        sc_payload = SpacecraftType.get_str(a_sc.get_type())
        # Add a '*' if the s/c has also Earth-Mars trajectory.
        if a_sc.get_has_return_trajectory():
            sc_payload = sc_payload + '*'
        return sc_payload
    def reset_model(self):
        """
        Reset the table model.
        """
        sonet_log(SonetLogType.INFO, 'TableModel.reset_model')

        self.beginResetModel()
        self._data = None
        self.endResetModel()
        return True
    def expand_tree_widget(self, p_tw='All'):
        sonet_log(SonetLogType.INFO, 'SonetCanvasQt.expand_tree_widget')

        # For the selected tree widgets.
        tree_widgets = self.get_tree_widgets(p_tw)

        # Expand their items.
        for tw in tree_widgets:
            for item in SonetCanvasQt.iter_tree_widget(tw):
                item.setExpanded(True)
    def resize_columns_to_contents(self, p_tw='All'):
        sonet_log(SonetLogType.INFO, 'SonetCanvasQt.resize_columns_to_contents')

        # For the selected tree widgets.
        tree_widgets = self.get_tree_widgets(p_tw)

        # Resize their columns to the contents.
        for tw in tree_widgets:
            n_cols = tw.columnCount()
            for col in range(n_cols):
                tw.resizeColumnToContents(col)
    def fill_tree_widget_sc_info(self, a_sc: SonetSpacecraft):
        sonet_log(SonetLogType.INFO, 'SonetCanvasQt.fill_tree_widget_sc_info')

        self.treeW_sc_info_filter.setHeaderLabels(['S/C', ''])

        tw_item_sc = QTreeWidgetItem(self.treeW_sc_info_filter, [a_sc.get_name(), self.get_sc_payload(a_sc)])

        tw_item_sc_dependencies = QTreeWidgetItem(tw_item_sc, ['Dependencies', ''])
        self.fill_dependencies(tw_item_sc_dependencies, a_sc)

        tw_item_sc_dependents = QTreeWidgetItem(tw_item_sc, ['Dependents', ''])
        self.fill_dependents(tw_item_sc_dependents, a_sc)
    def fill_dependents(self, a_tw_dependents_root, a_sc):
        """
        Add the items which depend on a_sc.
        :param a_tw_dependents_root: dependents item root.
        :param a_sc: s/c
        """
        sonet_log(SonetLogType.INFO, 'SonetCanvasQt.fill_dependents')

        sc_dependents = self.get_dependents_sc(a_sc)

        for dependent in sc_dependents:
            new_item = QTreeWidgetItem(a_tw_dependents_root, [dependent, sc_dependents.get(dependent)])
    def fill_dependencies(self, a_tw_dependencies_root, a_sc):
        """
        Add the items which a_sc depends on.
        :param a_tw_dependencies_root: dependencies item root.
        :param a_sc: s/c
        """
        sonet_log(SonetLogType.INFO, 'SonetCanvasQt.fill_dependencies')

        sc_dependencies = self.get_dependencies_sc(a_sc)

        for dependency in sc_dependencies:
            new_item = QTreeWidgetItem(a_tw_dependencies_root, [dependency, sc_dependencies.get(dependency)])
Esempio n. 17
0
    def __init__(self, a_spacecraft_name=None, a_spacecraft_type_crew=None, a_spacecraft_type_return=None, ap_main_window=None):
        sonet_log(SonetLogType.INFO, 'SonetSpacecraft.__init__')

        # Instance members
        self._p_main_window = ap_main_window
        self._spacecraft_type = None
        self._has_return_trajectory = None

        self.set_spacecraft_name(a_spacecraft_name)
        self.set_spacecraft_type(a_spacecraft_type_crew)
        self.set_has_return_trajectory(a_spacecraft_type_return)
        self.set_filters()
    def init(self):
        sonet_log(SonetLogType.INFO, 'SonetCanvasQt.init')

        # Align the window position with the main window.
        new_pos = self.mw.pos()
        new_pos.setX(new_pos.x() + self.mw.width())
        new_pos.setY(self.mw.y())
        self.move(new_pos)

        # Widgets settings.

        # Connect the main window list click event to the canvas window.
        self.mw.sonet_mission_tree_qlv.clicked.connect(self.clicked_sc)
    def fill_tree_widget_trajectories_filter(self, a_sc: SonetSpacecraft):
        sonet_log(SonetLogType.INFO, 'SonetCanvasQt.fill_tree_widget_trajectories_filter')

        self.treeW_trajectories_filter.setHeaderLabels(['Trip', 'Filter Type', 'Filter'])

        if a_sc.get_has_return_trajectory():
            tw_item_earth_mars = QTreeWidgetItem(self.treeW_trajectories_filter, ['Earth - Mars', '', ''])
            self.fill_filter(a_sc, 'Earth - Mars', tw_item_earth_mars)

            tw_item_mars_earth = QTreeWidgetItem(self.treeW_trajectories_filter, ['Mars - Earth', '', ''])
            self.fill_filter(a_sc, 'Mars - Earth', tw_item_mars_earth)
        else:
            tw_item_earth_mars = QTreeWidgetItem(self.treeW_trajectories_filter, ['Earth - Mars', '', ''])
            self.fill_filter(a_sc, 'Earth - Mars', tw_item_earth_mars)
    def clicked_pcp_viewer(self):
        """
        When user clicks over 'PCP Viewer' btn, the current pcp being displayed should be sent to matlab and a contour
        plot generated.
        The user selects the desired trajectory, and when closing the window, the selected trajectory appears selected
        back in the python app.
        """
        sonet_log(SonetLogType.INFO, 'SonetMainWindow.clicked_pcp_viewer')
        # self.statusbar.showMessage('Not yet implemented :).', SONET_MSG_TIMEOUT)

        # Get the current displayed pcp, as dataframe.
        df = self.sonet_pcp_tabs_qtw.currentWidget().children()[1].model()._data

        # Check.
        if df is None:
            self.statusbar.showMessage('No PCP selected.', SONET_MSG_TIMEOUT)
            return
        elif df.empty:
            self.statusbar.showMessage('No PCP selected.', SONET_MSG_TIMEOUT)
            return

        # Save it to a temporary mat file, which is read by matlab.
        if self.sonet_pcp_tabs_qtw.currentWidget().objectName() == 'sonet_pcp_table_transit_1':
            departure_planet = 'Earth'
            arrival_planet = 'Mars'
        else:
            departure_planet = 'Mars'
            arrival_planet = 'Earth'

        mat_file = SONET_DATA_DIR + 'pcp_viewer_tmp.mat'
        savemat(mat_file, {'departure_planet': departure_planet,
                           'arrival_planet': arrival_planet,
                           'jd0': QDate.toJulianDay(df.iloc[0].DepDates),
                           'cal0': [df.iloc[0].DepDates.year(), df.iloc[0].DepDates.month(), df.iloc[0].DepDates.day()],
                           'departure_dates': df.DepDates.apply(QDate.toJulianDay).tolist(),
                           'arrival_dates': df.ArrivDates.apply(QDate.toJulianDay).tolist(),
                           'm_departure_dates': df.attrs['m_departure_dates'], # This are the original dep dates in the mat file, before filtering trajectories by max dvt.
                           'tofs': df.tof.tolist(),
                           'm_tofs': df.attrs['m_tofs'], # This are the original dep dates in the mat file, before filtering trajectories by max dvt.
                           'dvd': df.dvd.tolist(),
                           'dva': df.dva.tolist(),
                           'dvt': df.dvt.tolist(),
                           'theta': df.theta.tolist()})  # In degrees!

        # Read mat file with matlab, display pcp plot, and return last selected trajectory when closed the app.
        selected_trajectory = matlab_engine.PCP_Viewer(mat_file, nargout=1)
        self.clicked_select_trajectory(p_called_from_pcp_viewer=True, p_pcp_viewer_selected_trajectory=int(selected_trajectory))

        print(df.iloc[int(selected_trajectory)])
    def __init__(self, a_parent, a_trip_type=TripType.NA):
        """
        :param a_parent: pointer to the parent, a s/c to which pertains this filter.
        :param a_trip_type: the type of trip to which apply this filter, OUTGOING|INCOMING.
        """
        self._data = pd.DataFrame(columns=['Status', 'Type', 'Filter'])

        if not TripType.is_valid(a_trip_type):
            sonet_log(
                SonetLogType.ERROR,
                'SonetTrajectoryFilter.__init__."Wrong TripType passed as argument"'
            )

        self._p_the_spacecraft = a_parent
        self._trip_type = a_trip_type
    def fill_tree_widget_active_trips(self, a_sc: SonetSpacecraft):
        sonet_log(SonetLogType.INFO, 'SonetCanvasQt.fill_tree_widget_active_trips')

        selected_trajectories = a_sc.get_trajectory_selected(p_get_trajectories=True)

        self.treeW_active_trips.setHeaderLabels(['Trip', 'DepDates', 'ArrivDates','tof', 'dvt'])
        if a_sc.get_has_return_trajectory():
            tw_item_earth_mars = QTreeWidgetItem(self.treeW_active_trips, ['Earth - Mars', '', '', '', ''])
            self.fill_active_trips(a_sc, 'Earth - Mars', tw_item_earth_mars)

            tw_item_mars_earth = QTreeWidgetItem(self.treeW_active_trips, ['Mars - Earth', '', '', '', ''])
            self.fill_active_trips(a_sc, 'Mars - Earth', tw_item_mars_earth)
        else:
            tw_item_earth_mars = QTreeWidgetItem(self.treeW_active_trips, ['Earth - Mars', '', '', '', ''])
            self.fill_active_trips(a_sc, 'Earth - Mars', tw_item_earth_mars)
    def clicked_sc(self, a_index):
        sonet_log(SonetLogType.INFO, 'SonetCanvasQt.clicked_sc')

        sc: SonetSpacecraft = self.mw.get_list_model().get_spacecraft(a_index=a_index)

        if a_index.row() is -1:
            sonet_log(SonetLogType.INFO, 'SonetCanvasQt.clicked_sc."No s/c selected"')
            return

        # Update the tree widgets.
        self.clear_tree_view(p_tw='All')
        self.fill_tree_widget_sc_info(sc)
        self.fill_tree_widget_trajectories_filter(sc)
        self.fill_tree_widget_active_trips(sc)

        self.post_actions()
    def get_dependency_type(self, a_sc_trip: str, a_dependency_trip: str):
        sonet_log(SonetLogType.INFO, 'SonetCanvasQt.get_dependency_type')

        res = ''

        if a_sc_trip == 'Earth - Mars':
            res = res + '>'
        elif a_sc_trip == 'Mars - Earth':
            res = res + '<'

        if a_dependency_trip == 'Earth - Mars':
            res = res + '>'
        elif a_dependency_trip == 'Mars - Earth':
            res = res + '<'

        return '(' + res + ')'
    def get_tree_widgets(self, p_tw='All'):
        sonet_log(SonetLogType.INFO, 'SonetCanvasQt.get_tree_widgets')

        res = []

        if p_tw == 'All':
            res.append(self.treeW_sc_info_filter)
            res.append(self.treeW_trajectories_filter)
            res.append(self.treeW_active_trips)
        elif p_tw == 'S/C Info':
            res.append(self.treeW_sc_info_filter)
        elif p_tw == 'Trajectories Filter':
            res.append(self.treeW_trajectories_filter)
        elif p_tw == 'Active Trips':
            res.append(self.treeW_active_trips)

        return res
    def clicked_new_spacecraft(self):
        """
        This method is called when clicking over 'Add SonetSpacecraft' QPushButton, it creates a new SonetSpacecraft.
        :rtype: bool
        """
        sonet_log(SonetLogType.INFO, 'SonetMainWindow.clicked_new_spacecraft')

        db = database.db

        # Create new SonetSpacecraft.

        # Get the widgets values.
        spacecraft_type_crew = self.sonet_spacecraft_type_qcmb.currentText()
        spacecraft_type_return = self.sonet_spacecraft_type_has_return_trajectory_qcmb.currentText()
        spacecraft_name = self.sonet_sc_name_le.text()

        # If the input s/c name is empty, popup a msg and exit.
        if spacecraft_name == '':
            popup_msg(window_title='Empty s/c name',
                      icon=QMessageBox.Information,
                      text='Please, select a different s/c name.',
                      info_text='')
            return False

        # If the input s/c name is already in the db, popup a msg and exit.
        if spacecraft_name in db:
            popup_msg(window_title='Duplicated s/c name',
                      icon=QMessageBox.Information,
                      text='Please, select a different s/c name.',
                      info_text='')
            return False

        # Create the s/c. The ap_main_window parameter is to pass a pointer to the main window to the s/c, so she can access
        # to main window's methods and properties.
        db[spacecraft_name] = SonetSpacecraft(spacecraft_name, spacecraft_type_crew, spacecraft_type_return, ap_main_window=main_window)

        # Update list model
        lm = self.get_list_model()
        lm.update()

        msg = ('Created Spacecraft ' + spacecraft_name
                  + ' (' + spacecraft_type_crew + ', ' + spacecraft_type_return + ')')
        sonet_log(SonetLogType.INFO, 'SonetMainWindow.clicked_new_spacecraft."' + msg + '"')

        return True
    def set_model_data(self, a_the_spacecraft=None, a_the_filtered_dataframe=None):
        """
        Set the table model's internal _data, stored as dataframe.
        """
        sonet_log(SonetLogType.INFO, 'TableModel.set_model_data."' + str(self._trip_type) + '"')

        if type(a_the_filtered_dataframe) == bool \
            or a_the_spacecraft is None \
                or  a_the_filtered_dataframe is None:
            sonet_log(SonetLogType.ERROR,'SonetMainWindow.TableModel.set_model_data."Wrong arguments type"')
            return
        # The spacecraft which owns the data.
        self._spacecraft = a_the_spacecraft

        # The data.
        self.beginResetModel()
        self._data = a_the_filtered_dataframe.reset_index(drop=True)
        self.endResetModel()
    def clear_tree_view(self, p_tw='All'):
        """
        Clear the all the tree widgets (p_tw='All') or a specific one.

        :param p_tw: 'All'|'S/C Info'|'Trajectories Filter'|'Active Trips'
        """
        sonet_log(SonetLogType.INFO, 'SonetCanvasQt.clear_tree_view')

        if p_tw == 'All':
            self.treeW_sc_info_filter.clear()
            self.treeW_trajectories_filter.clear()
            self.treeW_active_trips.clear()
        elif p_tw == 'S/C Info':
            self.treeW_sc_info_filter.clear()
        elif p_tw == 'Trajectories Filter':
            self.treeW_trajectories_filter.clear()
        elif p_tw == 'Active Trips':
            self.treeW_active_trips.clear()
    def clicked_pcp_manager(self):
        sonet_log(SonetLogType.INFO, 'SonetMainWindow.clicked_pcp_manager')

        pcp_manager_window = SonetPCPManagerQt(self, p_main_window=self, p_mat_eng=matlab_engine)
        pcp_manager_window.exec_()

        # Update the trajectory label & progress bar.
        sc = self._list_model.get_spacecraft(self.sonet_mission_tree_qlv.currentIndex())
        if sc is None:
            sonet_log(SonetLogType.INFO, 'SonetMainWindow.clicked_pcp_manager."No s/c selected"')
            # self.statusbar.showMessage('Not yet implemented :).', SONET_MSG_TIMEOUT)
            return

        status = sc.get_trajectory_selection_status()
        self.update_trajectory_label_and_progress_bar(status)
        self.update_trajectory_selection_in_table_view(sc)
        force_table_view_update()
        # Force focus on main window.
        self.raise_()
    def set_data(self, a_data: pd.DataFrame) -> bool:
        """
        Setter method.

        :param a_data: the filter to be applied.
        """

        sonet_log(SonetLogType.INFO, 'SonetTrajectoryFilter.set_data')

        # Check that input is a pandas DataFrame.
        if not isinstance(a_data, pd.DataFrame):
            sonet_log(SonetLogType.ERROR,
                      'SonetTrajectoryFilter.set_data."Wrong input type"')
            return

        # Check columns.
        if not list(a_data.columns) == ['Status', 'Type', 'Filter']:
            sonet_log(SonetLogType.ERROR,
                      'SonetTrajectoryFilter.set_data."Wrong filter columns"')
            return

        # If the filter is the same, do not apply it.
        if a_data.equals(self._data):
            return
        else:
            # If not, set the new filter
            self._data = a_data.copy()

            # And reset the current selected trajectory for this trip.
            self._p_the_spacecraft.reset_trajectory(
                p_all_trajectories=False, p_trajectory=self._trip_type)
            return