Changeset 699df7f in sasview
- Timestamp:
- Jul 12, 2012 3:20:18 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:
- e95614e
- Parents:
- 4cc25e9
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
invariantview/src/sans/perspectives/invariant/invariant_panel.py
r0d417ac8 r699df7f 80 80 self._bmark = None 81 81 self.bookmark_num = 0 82 82 self.state = None 83 self.popUpMenu = None 83 84 self._set_bookmark_menu() 84 85 #Init state … … 91 92 #container of invariant value 92 93 self.inv_container = None 94 #sizers 95 self.main_sizer = None 96 self.outputs_sizer = None 97 self.data_name_boxsizer = None 98 self.hint_msg_sizer = None 99 self.data_name_sizer = None 100 self.data_range_sizer = None 101 self.sizer_input = None 102 self.inputs_sizer = None 103 self.extrapolation_sizer = None 104 self.extrapolation_range_sizer = None 105 self.extrapolation_low_high_sizer = None 106 self.low_extrapolation_sizer = None 107 self.low_q_sizer = None 108 self.high_extrapolation_sizer = None 109 self.high_q_sizer = None 110 self.volume_surface_sizer = None 111 self.invariant_sizer = None 112 self.button_sizer = None 113 self.save_button_sizer = None 114 self.hint_msg_txt = None 115 self.data_name_tcl = None 116 self.data_min_tcl = None 117 self.data_max_tcl = None 93 118 #Draw the panel 94 119 self._do_layout() … … 101 126 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info")) 102 127 self._default_save_location = \ 103 self.parent. _default_save_location128 self.parent.get_save_location() 104 129 105 130 self._set_bookmark_flag(False) … … 380 405 """ 381 406 try: 382 qstar_total, qstar_total_err = inv.get_qstar_with_error(extrapolation) 407 qstar_total, qstar_total_err = \ 408 inv.get_qstar_with_error(extrapolation) 383 409 self.invariant_total_tcl.SetValue(format_number(qstar_total)) 384 self.invariant_total_err_tcl.SetValue(format_number(qstar_total_err)) 410 self.invariant_total_err_tcl.SetValue(\ 411 format_number(qstar_total_err)) 385 412 self.inv_container.qstar_total = qstar_total 386 413 self.inv_container.qstar_total_err = qstar_total_err … … 410 437 name="Low-Q extrapolation") 411 438 except: 412 raise413 439 self.inv_container.qstar_low = "ERROR" 414 440 self.inv_container.qstar_low_err = "ERROR" … … 418 444 wx.PostEvent(self.parent, 419 445 StatusEvent(status=msg, type="stop")) 446 raise 420 447 else: 421 448 try: … … 431 458 try: 432 459 qmax_plot = Q_MAXIMUM_PLOT * max(self._data.x) 433 if qmax_plot > Q_MAXIMUM: qmax_plot = Q_MAXIMUM 460 if qmax_plot > Q_MAXIMUM: 461 qmax_plot = Q_MAXIMUM 434 462 qstar_high, qstar_high_err = inv.get_qstar_high() 435 463 self.inv_container.qstar_high = qstar_high … … 559 587 self._set_compute_state(state='compute') 560 588 self._set_bookmark_flag(True) 561 msg = "\n\nStarting a new invariant computation..."589 msg = "\n\nStarting a new invariant computation..." 562 590 wx.PostEvent(self.parent, StatusEvent(status=msg)) 563 591 … … 650 678 if self.is_power_out == True: 651 679 self.state.container = copy.deepcopy(self.inv_container) 652 self.state.timestamp = self._get_time_stamp()680 self.state.timestamp = self._get_time_stamp() 653 681 msg = self.state.__str__() 654 682 self.state.set_report_string() … … 794 822 # get the previous state 795 823 try: 796 time,date,current_state,comp_state = \ 797 self.state.bookmark_list[int(num)] 824 _, _, current_state,comp_state = self.state.bookmark_list[int(num)] 798 825 except : 799 826 raise ValueError, "No such bookmark exists" … … 882 909 # set the count part of radio button clicked 883 910 #False for the saved_state 884 for title, content in rb_list:911 for title, content in rb_list: 885 912 if name == title: 886 913 name = content … … 933 960 if state == 'compute': 934 961 temp_saved_states['compute_num'] = self.state.state_num 935 self.state.saved_state = copy.deepcopy(temp_saved_states)962 self.state.saved_state = copy.deepcopy(temp_saved_states) 936 963 #copy.deepcopy(self.state.saved_state) 937 964 self.state.state_list[str(self.state.state_num)] = \ … … 974 1001 # Put only the current state in the list 975 1002 #copy.deepcopy(self.state.saved_state) 976 self.state.state_list[str(self.state.state_num)] = self.state.clone_state() 1003 self.state.state_list[str(self.state.state_num)] = \ 1004 self.state.clone_state() 977 1005 self._set_undo_flag(False) 978 1006 self._set_redo_flag(False) … … 1016 1044 # try to add new state of the text changes in the state_list 1017 1045 try: 1018 if value.strip() == None: value = '' 1046 if value.strip() == None: 1047 value = '' 1019 1048 exec "self.state.%s = '%s'" % (name, value) 1020 1049 exec "self.state.saved_state['%s'] = '%s'" % (name, value) 1021 1050 exec "self.state.input_list['%s'] = '%s'" % (name, value) 1022 1051 if not self.is_power_out: 1023 if name != 'power_low_tcl' and name != 'power_high_tcl':1052 if name != 'power_low_tcl' and name != 'power_high_tcl': 1024 1053 self.state.saved_state['state_num'] += 1 1025 1054 self.state.state_num = self.state.saved_state['state_num'] … … 1062 1091 compute_num = self.state.saved_state['compute_num'] 1063 1092 # find values and put into the input list 1064 for key1, value1 in self.state.state_list[str(compute_num)].iteritems():1065 for key, valuein self.state.input_list.iteritems():1093 for key1, value1 in self.state.state_list[str(compute_num)].iteritems(): 1094 for key, _ in self.state.input_list.iteritems(): 1066 1095 if key == key1: 1067 self.state.input_list[key] =value11096 self.state.input_list[key] = value1 1068 1097 break 1069 1098 … … 1075 1104 self.popUpMenu = wx.Menu() 1076 1105 id = wx.NewId() 1077 self._bmark = wx.MenuItem(self.popUpMenu, id,"BookMark",1106 self._bmark = wx.MenuItem(self.popUpMenu, id, "BookMark", 1078 1107 " Bookmark the panel to recall it later") 1079 1108 self.popUpMenu.AppendItem(self._bmark) … … 1088 1117 the popup menu on bookmark context menu event 1089 1118 """ 1090 if self._data == None: return 1091 if event == None: return 1119 if self._data == None: 1120 return 1121 if event == None: 1122 return 1092 1123 self.bookmark_num += 1 1093 1124 # date and time of the event 1094 #year, month, day,hour,minute,second,tda,ty,tm_isdst= time.localtime()1095 #my_time= str(hour)+" : "+str(minute)+" : "+str(second)+" "1096 #date= str( month)+"/"+str(day)+"/"+str(year)1097 1125 my_time, date = self._get_time_stamp() 1098 state_num= self.state.state_num1126 _ = self.state.state_num 1099 1127 compute_num = self.state.saved_state['compute_num'] 1100 1128 # name and message of the bookmark list 1101 msg = "State saved at %s on %s"%(my_time, date)1129 msg = "State saved at %s on %s"% (my_time, date) 1102 1130 ## post help message for the selected model 1103 msg += " Right click on the panel to retrieve this state"1131 msg += " Right click on the panel to retrieve this state" 1104 1132 #wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 1105 name = "%d] bookmarked at %s on %s"% (self.bookmark_num, my_time, date)1133 name = "%d] bookmarked at %s on %s"% (self.bookmark_num, my_time, date) 1106 1134 1107 1135 # append it to menu … … 1131 1159 ## post help message for the selected model 1132 1160 msg = menu.GetHelpString(event.GetId()) 1133 msg += " reloaded"1161 msg += " reloaded" 1134 1162 wx.PostEvent(self.parent, StatusEvent(status = msg )) 1135 1163 1136 name = menu.GetLabel(event.GetId())1137 1138 num, time = name.split(']')1164 name = menu.GetLabel(event.GetId()) 1165 1166 num, time = name.split(']') 1139 1167 current_state_num = self.state.state_num 1140 1168 self.get_bookmark_by_num(num) … … 1155 1183 : event: popUpMenu event 1156 1184 """ 1157 if event == None: return 1185 if event == None: 1186 return 1158 1187 # get the object 1159 1188 menu = event.GetEventObject() … … 1179 1208 """ 1180 1209 # date and time 1181 year, month, day, hour, minute, second, tda, ty, tm_isdst= \1210 year, month, day, hour, minute, second, _, _, _ = \ 1182 1211 time.localtime() 1183 1212 my_time = str(hour) + ":" + str(minute) + ":" + str(second) … … 1193 1222 path = None 1194 1223 if self.parent != None: 1195 self._default_save_location = \ 1196 self.parent._default_save_location 1224 self._default_save_location = self.parent.get_save_location() 1197 1225 if self._default_save_location == None: 1198 1226 self._default_save_location = os.getcwd() … … 1238 1266 1239 1267 def _on_context_menu(self, event): 1240 1268 """ 1269 On context menu 1270 """ 1241 1271 pos = event.GetPosition() 1242 1272 pos = self.ScreenToClient(pos) … … 1254 1284 outputs_box = wx.StaticBox(self, -1, "Outputs") 1255 1285 self.outputs_sizer = wx.StaticBoxSizer(outputs_box, wx.VERTICAL) 1256 self.outputs_sizer.SetMinSize((_STATICBOX_WIDTH, -1))1286 self.outputs_sizer.SetMinSize((_STATICBOX_WIDTH, -1)) 1257 1287 #Sizer related to data 1258 1288 data_name_box = wx.StaticBox(self, -1, "I(q) Data Source") … … 1268 1298 inputs_box = wx.StaticBox(self, -1, "Customized Inputs") 1269 1299 self.inputs_sizer = wx.StaticBoxSizer(inputs_box, wx.VERTICAL) 1270 self.inputs_sizer.SetMinSize((_STATICBOX_WIDTH, -1))1300 self.inputs_sizer.SetMinSize((_STATICBOX_WIDTH, -1)) 1271 1301 #Sizer related to extrapolation 1272 1302 extrapolation_box = wx.StaticBox(self, -1, "Extrapolation") 1273 1303 self.extrapolation_sizer = wx.StaticBoxSizer(extrapolation_box, 1274 1304 wx.VERTICAL) 1275 self.extrapolation_sizer.SetMinSize((_STATICBOX_WIDTH, -1))1305 self.extrapolation_sizer.SetMinSize((_STATICBOX_WIDTH, -1)) 1276 1306 self.extrapolation_range_sizer = wx.BoxSizer(wx.HORIZONTAL) 1277 1307 self.extrapolation_low_high_sizer = wx.BoxSizer(wx.HORIZONTAL) … … 1280 1310 self.low_extrapolation_sizer = wx.StaticBoxSizer(low_q_box, wx.VERTICAL) 1281 1311 1282 self.low_q_sizer = wx.GridBagSizer(5, 5)1312 self.low_q_sizer = wx.GridBagSizer(5, 5) 1283 1313 #Sizer related to extrapolation at low q range 1284 1314 high_q_box = wx.StaticBox(self, -1, "High Q") … … 1435 1465 wx.EVT_TEXT(self, self.npts_low_tcl.GetId(), self._on_text) 1436 1466 msg_hint = "Number of Q points to consider" 1437 msg_hint += "while extrapolating the low-Q region"1467 msg_hint += "while extrapolating the low-Q region" 1438 1468 self.npts_low_tcl.SetToolTipString(msg_hint) 1439 1469 power_txt = wx.StaticText(self, -1, 'Power') … … 1446 1476 iy = 0 1447 1477 ix = 0 1448 self.low_q_sizer.Add(self.enable_low_cbox, (iy, ix), (1, 5),1478 self.low_q_sizer.Add(self.enable_low_cbox, (iy, ix), (1, 5), 1449 1479 wx.TOP|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 1450 1480 iy += 1 1451 1481 ix = 0 1452 self.low_q_sizer.Add(npts_low_txt, (iy, ix), (1, 1),1482 self.low_q_sizer.Add(npts_low_txt, (iy, ix), (1, 1), 1453 1483 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 1454 1484 ix += 1 … … 1457 1487 iy += 1 1458 1488 ix = 0 1459 self.low_q_sizer.Add(self.guinier, (iy, ix),(1,2),1489 self.low_q_sizer.Add(self.guinier, (iy, ix), (1,2), 1460 1490 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 1461 1491 iy += 1 1462 1492 ix = 0 1463 self.low_q_sizer.Add(self.power_law_low, (iy, ix), (1, 2),1493 self.low_q_sizer.Add(self.power_law_low, (iy, ix), (1, 2), 1464 1494 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 1465 1495 # Parameter controls for power law 1466 1496 ix = 1 1467 1497 iy += 1 1468 self.low_q_sizer.Add(self.fix_enable_low, (iy, ix), (1, 1),1498 self.low_q_sizer.Add(self.fix_enable_low, (iy, ix), (1, 1), 1469 1499 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1470 1500 ix += 1 1471 self.low_q_sizer.Add(self.fit_enable_low, (iy, ix),(1,1),1501 self.low_q_sizer.Add(self.fit_enable_low, (iy, ix),(1,1), 1472 1502 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1473 1503 ix = 1 1474 1504 iy += 1 1475 self.low_q_sizer.Add(power_txt, (iy, ix), (1, 1),1505 self.low_q_sizer.Add(power_txt, (iy, ix), (1, 1), 1476 1506 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1477 1507 ix += 1 … … 1540 1570 1541 1571 self.power_law_high = wx.StaticText(self, -1, 'Power Law') 1542 msg_hint = "Check to extrapolate data at high-Q"1572 msg_hint = "Check to extrapolate data at high-Q" 1543 1573 self.power_law_high.SetToolTipString(msg_hint) 1544 1574 npts_high_txt = wx.StaticText(self, -1, 'Npts') … … 1623 1653 self._layout_extrapolation_low() 1624 1654 self._layout_extrapolation_high() 1625 self.extrapolation_low_high_sizer.AddMany([(self.low_extrapolation_sizer, 1626 0, wx.LEFT|wx.BOTTOM|wx.TOP, 5), 1627 (self.high_extrapolation_sizer, 1628 0, wx.LEFT|wx.BOTTOM|wx.TOP, 5)]) 1655 self.extrapolation_low_high_sizer.AddMany(\ 1656 [(self.low_extrapolation_sizer, 1657 0, wx.LEFT|wx.BOTTOM|wx.TOP, 5), 1658 (self.high_extrapolation_sizer, 1659 0, wx.LEFT|wx.BOTTOM|wx.TOP, 5)]) 1629 1660 self.extrapolation_sizer.AddMany([(self.extrapolation_range_sizer), 1630 1661 (self.extrapolation_low_high_sizer)]) … … 1744 1775 self.contrast_tcl.SetToolTipString(contrast_hint_txt) 1745 1776 contrast_unit_txt = wx.StaticText(self, -1, '[1/A^(2)]') 1746 porod_const_txt = wx.StaticText(self, -1, 'Porod Constant:\n(optional)\n') 1777 porod_const_txt = wx.StaticText(self, -1, 1778 'Porod Constant:\n(optional)\n') 1747 1779 self.porod_constant_tcl = InvTextCtrl(self, -1, 1748 1780 size=(_BOX_WIDTH, 20), style=0, … … 1821 1853 self._layout_outputs_sizer() 1822 1854 self._layout_button() 1823 self.main_sizer.AddMany([(self.data_name_boxsizer, 0, wx.ALL, 10),1855 self.main_sizer.AddMany([(self.data_name_boxsizer, 0, wx.ALL, 10), 1824 1856 (self.outputs_sizer, 0, 1825 1857 wx.LEFT|wx.RIGHT|wx.BOTTOM, 10), … … 1835 1867 class InvariantDialog(wx.Dialog): 1836 1868 """ 1869 Invariant Dialog 1837 1870 """ 1838 1871 def __init__(self, parent=None, id=1, graph=None, … … 1846 1879 class InvariantWindow(wx.Frame): 1847 1880 """ 1881 Invariant Window 1848 1882 """ 1849 1883 def __init__(self, parent=None, id=1, graph=None, … … 1856 1890 import invariant 1857 1891 path = "C:/ECLPS/workspace/trunk/sansdataloader/test/ascii_test_3.txt" 1858 data = self.loader.load(path)1892 data = self.loader.load(path) 1859 1893 self.panel = InvariantPanel(self) 1860 1894 … … 1865 1899 1866 1900 class MyApp(wx.App): 1901 """ 1902 Test App 1903 """ 1867 1904 def OnInit(self): 1905 """ 1906 Init 1907 """ 1868 1908 wx.InitAllImageHandlers() 1869 1909 frame = InvariantWindow() -
sansguiframe/src/sans/guiframe/gui_manager.py
r88a65e2 r699df7f 597 597 """ 598 598 return self._current_perspective 599 600 def get_save_location(self): 601 """ 602 return the _default_save_location 603 """ 604 return self._default_save_location 599 605 600 606 def set_input_file(self, input_file):
Note: See TracChangeset
for help on using the changeset viewer.