Changeset af84162 in sasview for src/sas


Ignore:
Timestamp:
Jul 14, 2016 9:00:04 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:
de0df2c
Parents:
3331e11
git-author:
Lewis O'Driscoll <lewis.o'driscoll@…> (07/14/16 08:55:32)
git-committer:
Lewis O'Driscoll <lewis.o'driscoll@…> (07/14/16 09:00:04)
Message:

Move detector metadata input to its own window

Location:
src/sas/sasgui/perspectives/file_converter
Files:
1 added
2 edited

Legend:

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

    r3331e11 raf84162  
    1010from sas.sasgui.perspectives.calculator import calculator_widgets as widget 
    1111from sas.sasgui.perspectives.file_converter.converter_widgets import VectorInput 
     12from sas.sasgui.perspectives.file_converter.detector_panel import DetectorWindow 
    1213from sas.sasgui.guiframe.events import StatusEvent 
    1314from sas.sasgui.guiframe.dataFitting import Data1D 
     
    4142        self.base = base 
    4243        self.parent = parent 
     44        self.detector_frame = None 
    4345 
    4446        self.q_input = None 
     
    180182        return True 
    181183 
     184    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) 
    182192 
    183193    def metadata_changed(self, event): 
     
    282292            "Detector:") 
    283293        metadata_grid.Add(detector_label, (y, 0), (1,1), wx.ALL | wx.EXPAND, 5) 
     294        detector_btn = wx.Button(metadata_pane, -1, "Enter Detector Metadata") 
     295        metadata_grid.Add(detector_btn, (y, 1), (1,1), wx.ALL | wx.EXPAND, 5) 
     296        detector_btn.Bind(wx.EVT_BUTTON, self.show_detector_window) 
    284297        y += 1 
    285  
    286         name_label = wx.StaticText(metadata_pane, -1, "Name: ") 
    287         metadata_grid.Add(name_label, (y, 1), (1,1)) 
    288  
    289         name_input = wx.TextCtrl(metadata_pane, 
    290             name="detector_name", size=(_STATICBOX_WIDTH-80-55, -1)) 
    291         metadata_grid.Add(name_input, (y, 2), (1,1)) 
    292         name_input.Bind(wx.EVT_TEXT, self.metadata_changed) 
    293         y += 1 
    294  
    295         distance_label = wx.StaticText(metadata_pane, -1, 
    296             "Distance (mm): ") 
    297         metadata_grid.Add(distance_label, (y, 1), (1,1)) 
    298  
    299         distance_input = wx.TextCtrl(metadata_pane, -1, 
    300             name="detector_distance", size=(50,-1)) 
    301         metadata_grid.Add(distance_input, (y,2), (1,1)) 
    302         self.to_validate.append(distance_input) 
    303         distance_input.Bind(wx.EVT_TEXT, self.metadata_changed) 
    304         y += 1 
    305  
    306         offset_label = wx.StaticText(metadata_pane, -1, 
    307             "Offset (m): ") 
    308         metadata_grid.Add(offset_label, (y,1), (1,1)) 
    309  
    310         offset_input = VectorInput(metadata_pane, "detector_offset", 
    311             callback=self.metadata_changed) 
    312         self.to_validate.append(offset_input) 
    313         metadata_grid.Add(offset_input.GetSizer(), (y,2), (1,1), wx.BOTTOM, 5) 
    314         y += 1 
    315  
    316         orientation_label = wx.StaticText(metadata_pane, -1, 
    317             u"Orientation (\xb0): ") 
    318         metadata_grid.Add(orientation_label, (y, 1), (1, 1)) 
    319  
    320         orientation_input = VectorInput(metadata_pane, "detector_orientation", 
    321             callback=self.metadata_changed, z_enabled=True, 
    322             labels=["Roll: ", "Pitch: ", "Yaw: "]) 
    323         self.to_validate.append(orientation_input) 
    324         metadata_grid.Add(orientation_input.GetSizer(), 
    325             (y,2), (1,1), wx.BOTTOM, 5) 
    326         y += 1 
    327  
    328         pixel_label = wx.StaticText(metadata_pane, -1, "Pixel Size (mm): ") 
    329         metadata_grid.Add(pixel_label, (y,1), (1,1)) 
    330  
    331         pixel_input = VectorInput(metadata_pane, "detector_pixel_size", 
    332              callback=self.metadata_changed) 
    333         self.to_validate.append(pixel_input) 
    334         metadata_grid.Add(pixel_input.GetSizer(), (y,2), (1,1), wx.BOTTOM, 5) 
    335         y += 1 
    336  
    337         beam_label = wx.StaticText(metadata_pane, -1, "Beam Center (mm): ") 
    338         metadata_grid.Add(beam_label, (y,1), (1,1)) 
    339         beam_input = VectorInput(metadata_pane, "detector_beam_center", 
    340             callback=self.metadata_changed) 
    341         self.to_validate.append(beam_input) 
    342         metadata_grid.Add(beam_input.GetSizer(), (y,2), (1,1), wx.BOTTOM, 5) 
    343         y += 1 
    344  
    345         slit_label = wx.StaticText(metadata_pane, -1, "Slit Length (mm): ") 
    346         metadata_grid.Add(slit_label, (y,1), (1,1)) 
    347         slit_input = wx.TextCtrl(metadata_pane, -1, size=(50,-1), 
    348             name="detector_slit_length") 
    349         self.to_validate.append(slit_input) 
    350         slit_input.Bind(wx.EVT_TEXT, self.metadata_changed) 
    351         metadata_grid.Add(slit_input, (y,2), (1,1), wx.BOTTOM, 5) 
    352298 
    353299        metadata_pane.SetSizer(metadata_grid) 
  • src/sas/sasgui/perspectives/file_converter/converter_widgets.py

    rc9a519f raf84162  
    2525        self.control_name = control_name 
    2626        self._callback = callback 
     27        self._name = control_name 
     28 
    2729        self.labels = labels 
    2830        self.z_enabled = z_enabled 
     
    4042        return self._sizer 
    4143 
     44    def GetName(self): 
     45        return self._name 
     46 
    4247    def GetValue(self): 
    4348        """ 
     
    4853        v = Vector() 
    4954        if not self.Validate(): return v 
    50         for direction, control in self._inputs: 
     55        for direction, control in self._inputs.iteritems(): 
    5156            try: 
    5257                value = float(control.GetValue()) 
     
    5762        return v 
    5863 
     64    def SetValue(self, vector): 
     65        directions = ['x', 'y'] 
     66        if self.z_enabled: directions.append('z') 
     67        for direction in directions: 
     68            value = getattr(vector, direction) 
     69            if value is None: value = '' 
     70            self._inputs[direction].SetValue(str(value)) 
     71 
    5972    def Validate(self): 
    6073        """ 
    6174        Validate the contents of the inputs 
    6275 
    63         :return control_valid: Whether or not the inputs are valid 
    64         :return invalid_control: The control that is not valid 
     76        :return all_valid: Whether or not the inputs are valid 
     77        :return invalid_ctrl: A control that is not valid 
    6578            (or None if all are valid) 
    6679        """ 
     80        all_valid = True 
     81        invalid_ctrl = None 
    6782        for control in self._inputs.values(): 
    6883            if control.GetValue() == '': continue 
     
    7085            control_valid = check_float(control) 
    7186            if not control_valid: 
    72                 return False, control 
    73         return True, None 
     87                all_valid = False 
     88                invalid_ctrl = control 
     89        return all_valid, invalid_ctrl 
    7490 
    7591 
     
    85101        x_input.Bind(wx.EVT_TEXT, self._callback) 
    86102 
    87         self._sizer.AddSpacer((15, -1)) 
     103        self._sizer.AddSpacer((10, -1)) 
    88104 
    89105        y_label = wx.StaticText(self.parent, -1, self.labels[1], 
     
    97113 
    98114        if self.z_enabled: 
    99             self._sizer.AddSpacer((15, -1)) 
     115            self._sizer.AddSpacer((10, -1)) 
    100116 
    101117            z_label = wx.StaticText(self.parent, -1, self.labels[2], 
Note: See TracChangeset for help on using the changeset viewer.