Changeset af84162 in sasview
- Timestamp:
- Jul 14, 2016 11:00:04 AM (8 years ago)
- 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 10:55:32)
- git-committer:
- Lewis O'Driscoll <lewis.o'driscoll@…> (07/14/16 11:00:04)
- 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 10 10 from sas.sasgui.perspectives.calculator import calculator_widgets as widget 11 11 from sas.sasgui.perspectives.file_converter.converter_widgets import VectorInput 12 from sas.sasgui.perspectives.file_converter.detector_panel import DetectorWindow 12 13 from sas.sasgui.guiframe.events import StatusEvent 13 14 from sas.sasgui.guiframe.dataFitting import Data1D … … 41 42 self.base = base 42 43 self.parent = parent 44 self.detector_frame = None 43 45 44 46 self.q_input = None … … 180 182 return True 181 183 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) 182 192 183 193 def metadata_changed(self, event): … … 282 292 "Detector:") 283 293 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) 284 297 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 += 1294 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 += 1305 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 += 1315 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 += 1327 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 += 1336 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 += 1344 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)352 298 353 299 metadata_pane.SetSizer(metadata_grid) -
src/sas/sasgui/perspectives/file_converter/converter_widgets.py
rc9a519f raf84162 25 25 self.control_name = control_name 26 26 self._callback = callback 27 self._name = control_name 28 27 29 self.labels = labels 28 30 self.z_enabled = z_enabled … … 40 42 return self._sizer 41 43 44 def GetName(self): 45 return self._name 46 42 47 def GetValue(self): 43 48 """ … … 48 53 v = Vector() 49 54 if not self.Validate(): return v 50 for direction, control in self._inputs :55 for direction, control in self._inputs.iteritems(): 51 56 try: 52 57 value = float(control.GetValue()) … … 57 62 return v 58 63 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 59 72 def Validate(self): 60 73 """ 61 74 Validate the contents of the inputs 62 75 63 :return control_valid: Whether or not the inputs are valid64 :return invalid_c ontrol: Thecontrol that is not valid76 :return all_valid: Whether or not the inputs are valid 77 :return invalid_ctrl: A control that is not valid 65 78 (or None if all are valid) 66 79 """ 80 all_valid = True 81 invalid_ctrl = None 67 82 for control in self._inputs.values(): 68 83 if control.GetValue() == '': continue … … 70 85 control_valid = check_float(control) 71 86 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 74 90 75 91 … … 85 101 x_input.Bind(wx.EVT_TEXT, self._callback) 86 102 87 self._sizer.AddSpacer((1 5, -1))103 self._sizer.AddSpacer((10, -1)) 88 104 89 105 y_label = wx.StaticText(self.parent, -1, self.labels[1], … … 97 113 98 114 if self.z_enabled: 99 self._sizer.AddSpacer((1 5, -1))115 self._sizer.AddSpacer((10, -1)) 100 116 101 117 z_label = wx.StaticText(self.parent, -1, self.labels[2],
Note: See TracChangeset
for help on using the changeset viewer.