Changeset 3e001f9 in sasview for fittingview/src/sans
- Timestamp:
- Apr 6, 2013 1:36:03 PM (12 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, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 4bdd4fdb
- Parents:
- cb270ad2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fittingview/src/sans/perspectives/fitting/fitpage.py
rcb270ad2 r3e001f9 12 12 from sans.guiframe.events import StatusEvent 13 13 from sans.guiframe.events import NewPlotEvent 14 from sans.guiframe.events import PlotQrangeEvent 14 15 from sans.guiframe.dataFitting import check_data_validity 15 16 from sans.guiframe.utils import format_number … … 516 517 self.qmin = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 517 518 style=wx.TE_PROCESS_ENTER, 518 text_enter_callback=self._onQrangeEnter) 519 set_focus_callback=self.qrang_set_focus, 520 text_enter_callback=self._onQrangeEnter, 521 name='qmin') 519 522 self.qmin.SetValue(str(self.qmin_x)) 520 self.qmin.SetToolTipString("Minimun value of Q in linear scale.") 523 q_tip = "Click outside of the axes\n to remove the lines." 524 qmin_tip = "Minimun value of Q.\n" 525 qmin_tip += q_tip 526 self.qmin.SetToolTipString(qmin_tip) 521 527 522 528 self.qmax = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 523 529 style=wx.TE_PROCESS_ENTER, 524 text_enter_callback=self._onQrangeEnter) 530 set_focus_callback=self.qrang_set_focus, 531 text_enter_callback=self._onQrangeEnter, 532 name='qmax') 525 533 self.qmax.SetValue(str(self.qmax_x)) 526 self.qmax.SetToolTipString("Maximum value of Q in linear scale.") 534 qmax_tip = "Maximum value of Q.\n" 535 qmax_tip += q_tip 536 self.qmax.SetToolTipString(qmax_tip) 537 self.qmin.Bind(wx.EVT_MOUSE_EVENTS, self.qrange_click) 538 self.qmax.Bind(wx.EVT_MOUSE_EVENTS, self.qrange_click) 539 self.qmin.Bind(wx.EVT_KEY_DOWN, self.on_key) 540 self.qmax.Bind(wx.EVT_KEY_DOWN, self.on_key) 541 self.qmin.Bind(wx.EVT_TEXT, self.on_qrange_text) 542 self.qmax.Bind(wx.EVT_TEXT, self.on_qrange_text) 527 543 id = wx.NewId() 528 544 self.reset_qrange = wx.Button(self, id, 'Reset', size=(77, 20)) … … 1318 1334 wx.PostEvent(self.parent, event) 1319 1335 self.state_change = False 1320 1336 1337 def qrang_set_focus(self, event=None): 1338 """ 1339 ON Qrange focus 1340 """ 1341 if event != None: 1342 event.Skip() 1343 #tcrtl = event.GetEventObject() 1344 self._validate_qrange(self.qmin, self.qmax) 1345 1346 def qrange_click(self, event): 1347 """ 1348 On Qrange textctrl click, make the qrange lines in the plot 1349 """ 1350 if event != None: 1351 event.Skip() 1352 if self.data.__class__.__name__ == "Data2D": 1353 return 1354 is_click = event.LeftDown() 1355 if is_click: 1356 d_id = self.data.id 1357 d_group_id = self.data.group_id 1358 act_ctrl = event.GetEventObject() 1359 wx.PostEvent(self.parent.parent, 1360 PlotQrangeEvent(ctrl=[self.qmin, self.qmax], id=d_id, 1361 group_id=d_group_id, leftdown=is_click, 1362 active=act_ctrl)) 1363 1364 def on_qrange_text(self, event): 1365 """ 1366 #On q range value updated. DO not combine with qrange_click(). 1367 """ 1368 if event != None: 1369 event.Skip() 1370 if self.data.__class__.__name__ == "Data2D": 1371 return 1372 act_ctrl = event.GetEventObject() 1373 d_id = self.data.id 1374 d_group_id = self.data.group_id 1375 wx.PostEvent(self.parent.parent, 1376 PlotQrangeEvent(ctrl=[self.qmin, self.qmax], id=d_id, 1377 group_id=d_group_id, leftdown=False, 1378 active=act_ctrl)) 1379 self._validate_qrange(self.qmin, self.qmax) 1380 1381 def on_key(self, event): 1382 """ 1383 On Key down 1384 """ 1385 event.Skip() 1386 if self.data.__class__.__name__ == "Data2D": 1387 return 1388 ctrl = event.GetEventObject() 1389 try: 1390 x_data = float(ctrl.GetValue()) 1391 except: 1392 return 1393 key = event.GetKeyCode() 1394 length = len(self.data.x) 1395 indx = (numpy.abs(self.data.x - x_data)).argmin() 1396 #return array.flat[idx] 1397 if key == wx.WXK_PAGEUP or key == wx.WXK_NUMPAD_PAGEUP: 1398 indx += 1 1399 if indx >= length: 1400 indx = length - 1 1401 elif key == wx.WXK_PAGEDOWN or key == wx.WXK_NUMPAD_PAGEDOWN: 1402 indx -= 1 1403 if indx < 0: 1404 indx = 0 1405 else: 1406 return 1407 ctrl.SetValue(str(self.data.x[indx])) 1408 self._validate_qrange(self.qmin, self.qmax) 1409 1321 1410 def _onQrangeEnter(self, event): 1322 1411 """ … … 1799 1888 self._set_bookmark_flag(not self.batch_on) 1800 1889 self._keep.Enable(not self.batch_on) 1801 1802 self._set_save_flag(True)1803 self._set_preview_flag(True)1890 if self.data.is_data: 1891 self._set_save_flag(True) 1892 self._set_preview_flag(True) 1804 1893 1805 1894 self._set_smear(data)
Note: See TracChangeset
for help on using the changeset viewer.