Example #1
0
 def initialize(self, *, load_plug_ins=True, use_root_dir=True):
     super().initialize()
     # configure app data
     if load_plug_ins:
         logging.info("Launch time " + str(datetime.datetime.now()))
         logging.info("Python version " +
                      str(sys.version.replace('\n', '')))
         logging.info("User interface class " + type(self.ui).__name__ +
                      " / " + type(self.ui.proxy).__name__)
         logging.info("Qt version " + self.ui.get_qt_version())
         app_data_file_path = self.ui.get_configuration_location(
         ) / pathlib.Path("nionswift_appdata.json")
         ApplicationData.set_file_path(app_data_file_path)
         logging.info("Application data: " + str(app_data_file_path))
         PlugInManager.load_plug_ins(
             self,
             get_root_dir() if use_root_dir else None)
         color_maps_dir = self.ui.get_configuration_location(
         ) / pathlib.Path("Color Maps")
         if color_maps_dir.exists():
             logging.info("Loading color maps from " + str(color_maps_dir))
             ColorMaps.load_color_maps(color_maps_dir)
         else:
             logging.info("NOT Loading color maps from " +
                          str(color_maps_dir) + " (missing)")
Example #2
0
    def test_session_panel_controller_notifies_fields_changed(self):
        session_panel_controller = SessionPanel.SessionPanelController()
        fields = dict()

        def fields_changed(d):
            fields.update(d)

        session_panel_controller.on_fields_changed = fields_changed

        ApplicationData.get_session_metadata_model(
        ).microscopist = "Ned Flanders"
        ApplicationData.get_session_metadata_model().site = "Earth"

        self.assertEqual({
            "microscopist": "Ned Flanders",
            "site": "Earth"
        }, fields)
Example #3
0
 def initialize(self, *, load_plug_ins=True, use_root_dir=True):
     # configure the event loop object
     logger = logging.getLogger()
     old_level = logger.level
     logger.setLevel(logging.INFO)
     self.__event_loop = asyncio.new_event_loop()  # outputs a debugger message!
     logger.setLevel(old_level)
     # configure app data
     if load_plug_ins:
         logging.info("Python version " + str(sys.version.replace('\n', '')))
         logging.info("User interface class " + type(self.ui).__name__ + " / " + type(self.ui.proxy).__name__)
         app_data_file_path = self.ui.get_configuration_location() / pathlib.Path("nionswift_appdata.json")
         ApplicationData.set_file_path(app_data_file_path)
         logging.info("Application data: " + str(app_data_file_path))
         PlugInManager.load_plug_ins(self, get_root_dir() if use_root_dir else None)
         color_maps_dir = self.ui.get_configuration_location() / pathlib.Path("Color Maps")
         if color_maps_dir.exists():
             logging.info("Loading color maps from " + str(color_maps_dir))
             ColorMaps.load_color_maps(color_maps_dir)
         else:
             logging.info("NOT Loading color maps from " + str(color_maps_dir) + " (missing)")
Example #4
0
 def __create_data_item(self, data_metadata: DataAndMetadata.DataMetadata,
                        title: str) -> DataItem.DataItem:
     data_shape = data_metadata.data_shape
     data_descriptor = data_metadata.data_descriptor
     large_format = bool(
         numpy.prod(data_shape, dtype=numpy.int64) > 2048**2 * 10)
     data_item = DataItem.DataItem(large_format=large_format)
     data_item.title = title
     self.__document_model.append_data_item(data_item)
     data_item.reserve_data(data_shape=data_shape,
                            data_dtype=numpy.dtype(numpy.float32),
                            data_descriptor=data_descriptor)
     data_item.session_metadata = ApplicationData.get_session_metadata_dict(
     )
     return data_item
Example #5
0
 def set_field(self, field_id: str, value: str) -> None:
     setattr(ApplicationData.get_session_metadata_model(), field_id, value)
Example #6
0
 def field_values(self):
     return ApplicationData.get_session_metadata_model().to_dict_value()
Example #7
0
 def __init__(self):
     self.__property_changed_listener = ApplicationData.get_session_metadata_model(
     ).property_changed_event.listen(self.__property_changed)
     self.on_fields_changed = None
Example #8
0
 def field_values(self) -> StructuredModel.DictValue:
     return ApplicationData.get_session_metadata_model().to_dict_value()
Example #9
0
 def __init__(self) -> None:
     self.__property_changed_listener = ApplicationData.get_session_metadata_model(
     ).property_changed_event.listen(self.__property_changed)
     self.on_fields_changed: typing.Optional[typing.Callable[
         [StructuredModel.DictValue], None]] = None