Пример #1
0
 def _on_feature_status(self, feature_status):
     """
     Update the feature status dropdown with the feature status
     :param feature_status: (string) the updated feature status
     """
     self._panel.cmb_feature_status.SetValue(feature_status)
     save_features(self._tab.conf.pj_last_path,
                   self._tab_data_model.main.features)
Пример #2
0
    def test_save_read_features(self):
        feature1 = CryoFeature("Feature-1", 0, 0, 0, 10)
        feature2 = CryoFeature("Feature-2", 1e-3, 1e-3, 2e-3, 20)

        features = [feature1, feature2]
        save_features("", features)
        r_features = read_features("")
        self.assertEqual(len(features), len(r_features))
        self.assertEqual(features[0].name.value, r_features[0].name.value)
Пример #3
0
    def _on_current_feature_changes(self, feature):
        """
        Update the feature panel controls when the current feature VA is modified
        :param feature: (CryoFeature or None) the newly selected current feature
        """
        if self._feature_name_va_connector:
            self._feature_name_va_connector.disconnect()

        if self._feature_status_va_connector:
            self._feature_status_va_connector.disconnect()

        if self._feature_z_va_connector:
            self._feature_z_va_connector.disconnect()

        def enable_feature_ctrls(enable):
            self._panel.cmb_feature_status.Enable(enable)
            self._panel.ctrl_feature_z.Enable(enable)
            self._panel.btn_use_current_z.Enable(enable)
            self._panel.btn_go_to_feature.Enable(enable)

        if not feature:
            enable_feature_ctrls(False)
            self._panel.cmb_features.SetValue("No Feature Selected")
            self._panel.cmb_feature_status.SetValue("Not Selected")
            return
        save_features(self._tab.conf.pj_last_path,
                      self._tab_data_model.main.features)

        enable_feature_ctrls(True)
        # Set feature list with the current feature
        index = self._tab_data_model.main.features.value.index(feature)
        self._panel.cmb_features.SetSelection(index)

        # Disconnect and reconnect the VA connectors to the newly selected feature
        self._feature_name_va_connector = VigilantAttributeConnector(
            feature.name,
            self._panel.cmb_features,
            events=wx.EVT_TEXT_ENTER,
            va_2_ctrl=self._on_feature_name,
            ctrl_2_va=self._on_cmb_feature_name_change,
        )

        self._feature_status_va_connector = VigilantAttributeConnector(
            feature.status,
            self._panel.cmb_feature_status,
            events=wx.EVT_COMBOBOX,
            ctrl_2_va=self._on_cmb_feature_status_change,
            va_2_ctrl=self._on_feature_status)

        # TODO: check, it seems that sometimes the EVT_TEXT_ENTER is first received
        # by the VAC, before the widget itself, which prevents getting the right value.
        self._feature_z_va_connector = VigilantAttributeConnector(
            feature.pos,
            self._panel.ctrl_feature_z,
            events=wx.EVT_TEXT_ENTER,
            ctrl_2_va=self._on_ctrl_feature_z_change,
            va_2_ctrl=self._on_feature_pos)
Пример #4
0
 def _on_features_changes(self, features):
     """
     repopulate the feature list dropdown with the modified features
     :param features: list(CryoFeature) list of modified features
     """
     if not features:
         self._panel.cmb_features.Clear()
         self._on_current_feature_changes(None)
         return
     save_features(self._tab.conf.pj_last_path,
                   self._tab_data_model.main.features)
     self._panel.cmb_features.Clear()
     for i, feature in enumerate(features):
         self._panel.cmb_features.Insert(feature.name.value, i, feature)
     self._on_current_feature_changes(None)
Пример #5
0
 def _on_feature_name(self, _):
     save_features(self._tab.conf.pj_last_path,
                   self._tab_data_model.main.features)
Пример #6
0
 def _on_feature_pos(self, feature_pos):
     # Set the feature Z ctrl with the 3rd (focus) element of the feature position
     self._panel.ctrl_feature_z.SetValue(feature_pos[2])
     save_features(self._tab.conf.pj_last_path,
                   self._tab_data_model.main.features)