Changeset de0df2c in sasview


Ignore:
Timestamp:
Jul 14, 2016 11:59:05 AM (8 years ago)
Author:
lewis
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
2a7722b
Parents:
af84162
git-author:
Lewis O'Driscoll <lewis.o'driscoll@…> (07/14/16 11:38:21)
git-committer:
Lewis O'Driscoll <lewis.o'driscoll@…> (07/14/16 11:59:05)
Message:

Abstract MetadataPanel? from DetectorPanel?

Location:
src/sas/sasgui/perspectives/file_converter
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/file_converter/converter_panel.py

    raf84162 rde0df2c  
    1010from sas.sasgui.perspectives.calculator import calculator_widgets as widget 
    1111from sas.sasgui.perspectives.file_converter.converter_widgets import VectorInput 
    12 from sas.sasgui.perspectives.file_converter.detector_panel import DetectorWindow 
     12from sas.sasgui.perspectives.file_converter.meta_panels import MetadataWindow 
     13from sas.sasgui.perspectives.file_converter.meta_panels import DetectorPanel 
    1314from sas.sasgui.guiframe.events import StatusEvent 
    1415from sas.sasgui.guiframe.dataFitting import Data1D 
     
    4243        self.base = base 
    4344        self.parent = parent 
    44         self.detector_frame = None 
     45        self.meta_frames = [] 
    4546 
    4647        self.q_input = None 
     
    183184 
    184185    def show_detector_window(self, event): 
    185         if self.detector_frame is not None: 
    186             self.detector_frame.panel.on_close() 
    187             return 
    188         self.detector_frame = DetectorWindow(self.parent.manager.parent, 
    189             manager=self, detector=self.metadata['detector'][0]) 
    190         self.parent.manager.put_icon(self.detector_frame) 
    191         self.detector_frame.Show(True) 
     186        if self.meta_frames != []: 
     187            for frame in self.meta_frames: 
     188                frame.panel.on_close() 
     189        detector_frame = MetadataWindow(DetectorPanel, 
     190            parent=self.parent.manager.parent, manager=self, 
     191            metadata=self.metadata['detector'][0], title='Detector Metadata') 
     192        self.meta_frames.append(detector_frame) 
     193        self.parent.manager.put_icon(detector_frame) 
     194        detector_frame.Show(True) 
    192195 
    193196    def metadata_changed(self, event): 
  • src/sas/sasgui/perspectives/file_converter/meta_panels.py

    raf84162 rde0df2c  
    2020    FONT_VARIANT = 1 
    2121 
    22 class DetectorPanel(ScrolledPanel, PanelBase): 
     22class MetadataPanel(ScrolledPanel, PanelBase): 
    2323 
    24     def __init__(self, parent, detector, base=None, *args, **kwargs): 
     24    def __init__(self, parent, metadata, base=None, *args, **kwargs): 
    2525        ScrolledPanel.__init__(self, parent, *args, **kwargs) 
    2626        PanelBase.__init__(self) 
     
    2828        self.SetWindowVariant(variant=FONT_VARIANT) 
    2929 
    30         if detector.name is None: 
    31             detector.name = '' 
    32  
    3330        self.base = base 
    3431        self.parent = parent 
    35         self.detector = detector 
    3632        self._to_validate = [] 
    3733        self._vectors = [] 
    38  
    39         self._do_layout() 
    40         self.SetAutoLayout(True) 
    41         self.Layout() 
     34        self.metadata = metadata 
    4235 
    4336    def on_change(self, event): 
     
    4538        value = ctrl.GetValue() 
    4639        if value == '': value = None 
    47         setattr(self.detector, ctrl.GetName(), value) 
     40        setattr(self.metadata, ctrl.GetName(), value) 
    4841 
    4942    def on_close(self, event=None): 
     
    6558                    StatusEvent(status=msg, info='error')) 
    6659                return 
    67             setattr(self.detector, vector_in.GetName(), vector_in.GetValue()) 
     60            setattr(self.metadata, vector_in.GetName(), vector_in.GetValue()) 
    6861 
     62class DetectorPanel(MetadataPanel): 
     63 
     64    def __init__(self, parent, detector, base=None, *args, **kwargs): 
     65        MetadataPanel.__init__(self, parent, detector, base, *args, **kwargs) 
     66 
     67        if detector.name is None: 
     68            detector.name = '' 
     69 
     70        self._do_layout() 
     71        self.SetAutoLayout(True) 
     72        self.Layout() 
     73 
     74    def on_close(self, event=None): 
     75        MetadataPanel.on_close(self, event) 
     76 
     77        self.parent.manager.metadata['detector'] = [self.metadata] 
    6978        self.parent.on_close(event) 
    7079 
     
    140149        vbox.Add(section_sizer, flag=wx.ALL, border=10) 
    141150 
    142         name_input.SetValue(self.detector.name) 
    143         distance = self.detector.distance 
     151        name_input.SetValue(self.metadata.name) 
     152        distance = self.metadata.distance 
    144153        if distance is None: distance = '' 
    145154        elif '.' not in distance: distance += '.0' 
    146155        distance_input.SetValue(str(distance)) 
    147         offset_input.SetValue(self.detector.offset) 
    148         orientation_input.SetValue(self.detector.orientation) 
    149         pixel_input.SetValue(self.detector.pixel_size) 
    150         beam_input.SetValue(self.detector.beam_center) 
    151         slit_len = self.detector.slit_length 
     156        offset_input.SetValue(self.metadata.offset) 
     157        orientation_input.SetValue(self.metadata.orientation) 
     158        pixel_input.SetValue(self.metadata.pixel_size) 
     159        beam_input.SetValue(self.metadata.beam_center) 
     160        slit_len = self.metadata.slit_length 
    152161        if slit_len is None: slit_len = '' 
    153162        elif '.' not in slit_len: slit_len += '.0' 
     
    157166        self.SetSizer(vbox) 
    158167 
    159 class DetectorWindow(widget.CHILD_FRAME): 
     168class MetadataWindow(widget.CHILD_FRAME): 
    160169 
    161     def __init__(self, parent=None, title='Detector Metadata', base=None, 
    162         manager=None, size=(PANEL_SIZE, PANEL_SIZE*0.8), detector=None, 
     170    def __init__(self, PanelClass, parent=None, title='', base=None, 
     171        manager=None, size=(PANEL_SIZE, PANEL_SIZE*0.8), metadata=None, 
    163172         *args, **kwargs): 
    164173        kwargs['title'] = title 
     
    167176 
    168177        self.manager = manager 
    169         self.panel = DetectorPanel(self, detector, base=None) 
     178        self.panel = PanelClass(self, metadata, base=None) 
    170179        self.Bind(wx.EVT_CLOSE, self.on_close) 
    171180 
    172181    def on_close(self, event): 
    173182        if self.manager is not None: 
    174             self.manager.detector_frame = None 
    175             self.manager.metadata['detector'] = [self.panel.detector] 
     183            self.manager.meta_frames.remove(self) 
    176184        self.Destroy() 
Note: See TracChangeset for help on using the changeset viewer.