Changeset 0d417ac8 in sasview for invariantview/src/sans/perspectives
- Timestamp:
- Jun 5, 2012 4:55:35 PM (13 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:
- c5d2760
- Parents:
- 075d073
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
invariantview/src/sans/perspectives/invariant/invariant_panel.py
ra1fa589 r0d417ac8 99 99 if self.parent is not None: 100 100 msg = "" 101 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info"))102 self._default_save_location = \101 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info")) 102 self._default_save_location = \ 103 103 self.parent._default_save_location 104 104 … … 199 199 return doc 200 200 201 def set_state(self, state=None,data=None):201 def set_state(self, state=None, data=None): 202 202 """ 203 203 set state when loading it from a .inv/.svs file … … 206 206 if state == None and data == None: 207 207 self.state = IState() 208 elif state == None or data == None: return 208 elif state == None or data == None: 209 return 209 210 else: 210 211 new_state = copy.deepcopy(state) … … 226 227 total_bookmark_num = self.bookmark_num + 1 227 228 228 for ind in range(1, total_bookmark_num):229 for ind in range(1, total_bookmark_num): 229 230 #bookmark_num = ind 230 231 value = self.state.bookmark_list[ind] 231 name = "%d] bookmarked at %s on %s"% (ind, value[0], value[1])232 name = "%d] bookmarked at %s on %s"% (ind, value[0], value[1]) 232 233 # append it to menu 233 234 id = wx.NewId() 234 self.popUpMenu.Append(id, name,str(''))235 self.popUpMenu.Append(id, name, str('')) 235 236 wx.EVT_MENU(self, id, self._back_to_bookmark) 236 237 wx.PostEvent(self.parent, AppendBookmarkEvent(title=name, 237 hint='', 238 hint='', 238 239 handler=self._back_to_bookmark)) 239 240 … … 315 316 def get_extrapolation_type(self, low_q, high_q): 316 317 """ 318 get extrapolation type 317 319 """ 318 320 extrapolation = None … … 337 339 def get_volume(self, inv, contrast, extrapolation): 338 340 """ 341 get volume fraction 339 342 """ 340 343 if contrast is not None: … … 355 358 def get_surface(self, inv, contrast, porod_const, extrapolation): 356 359 """ 360 get surface value 357 361 """ 358 362 if contrast is not None and porod_const is not None: … … 373 377 def get_total_qstar(self, inv, extrapolation): 374 378 """ 379 get total qstar 375 380 """ 376 381 try: … … 391 396 def get_low_qstar(self, inv, npts_low, low_q=False): 392 397 """ 398 get low qstar 393 399 """ 394 400 if low_q: … … 415 421 try: 416 422 self._manager.plot_theory(name="Low-Q extrapolation") 417 except: pass 423 except: 424 pass 418 425 419 426 def get_high_qstar(self, inv, high_q=False): 420 427 """ 428 get high qstar 421 429 """ 422 430 if high_q: … … 445 453 try: 446 454 self._manager.plot_theory(name="High-Q extrapolation") 447 except: pass 455 except: 456 pass 448 457 449 458 def get_qstar(self, inv): 450 459 """ 460 get qstar 451 461 """ 452 462 qstar, qstar_err = inv.get_qstar_with_error() … … 509 519 power_high = float(power_high) 510 520 else: 511 if high_q 521 if high_q: 512 522 #Raise error only when qstar at high q is requested 513 523 msg = "Expect float for power at high q," … … 580 590 msg = "Error occurred computing invariant: %s" % sys.exc_value 581 591 wx.PostEvent(self.parent, StatusEvent(status=msg, 582 info="warning", type="stop"))592 info="warning", type="stop")) 583 593 return 584 594 #check the type of extrapolation … … 657 667 self.Refresh() 658 668 659 def on_undo(self, event=None):669 def on_undo(self, event=None): 660 670 """ 661 671 Go back to the previous state … … 680 690 681 691 682 def on_redo(self, event=None):692 def on_redo(self, event=None): 683 693 """ 684 694 Go forward to the previous state … … 713 723 report_text_str = self.state.__str__() 714 724 report_img = self.state.image 715 report_list = [report_html_str, report_text_str,report_img]725 report_list = [report_html_str, report_text_str, report_img] 716 726 dialog = ReportDialog(report_list, None, -1, "") 717 727 dialog.ShowModal() 718 728 719 def get_state_by_num(self, state_num=None):729 def get_state_by_num(self, state_num=None): 720 730 """ 721 731 Get the state given by number … … 784 794 # get the previous state 785 795 try: 786 time,date,current_state,comp_state = self.state.bookmark_list[int(num)] 796 time,date,current_state,comp_state = \ 797 self.state.bookmark_list[int(num)] 787 798 except : 788 799 raise ValueError, "No such bookmark exists" … … 859 870 name = str(obj.GetName()) 860 871 value = str(obj.GetValue()) 861 rb_list = [['power_law_low', 'guinier'],862 ['fit_enable_low', 'fix_enable_low'],863 ['fit_enable_high', 'fix_enable_high']]872 rb_list = [['power_law_low', 'guinier'], 873 ['fit_enable_low', 'fix_enable_low'], 874 ['fit_enable_high', 'fix_enable_high']] 864 875 865 876 try: … … 886 897 self.state.saved_state['state_num'] += 1 887 898 self.state.state_num = self.state.saved_state['state_num'] 888 self.state.state_list[str(self.state.state_num)] = self.state.clone_state()#copy.deepcopy(self.state.saved_state) 899 self.state.state_list[str(self.state.state_num)] = \ 900 self.state.clone_state() 889 901 except: 890 902 pass … … 894 906 #event.Skip() 895 907 896 def _set_compute_state(self, state=None):908 def _set_compute_state(self, state=None): 897 909 """ 898 910 Notify the compute_invariant state to self.state … … 909 921 self.is_power_out = True 910 922 # Instead of changing the future, create a new future. 911 max_state_num = len(self.state.state_list) -1923 max_state_num = len(self.state.state_list) - 1 912 924 self.state.saved_state['state_num'] = max_state_num 913 925 # A new computation is also A state … … 923 935 self.state.saved_state= copy.deepcopy(temp_saved_states) 924 936 #copy.deepcopy(self.state.saved_state) 925 self.state.state_list[str(self.state.state_num)] = self.state.clone_state() 937 self.state.state_list[str(self.state.state_num)] = \ 938 self.state.clone_state() 926 939 927 940 # A computation is a new state, so delete the states with any higher 928 941 # state numbers 929 for i in range(self.state.state_num+1, len(self.state.state_list)):942 for i in range(self.state.state_num+1, len(self.state.state_list)): 930 943 try: 931 944 del (self.state.state_list[str(i)]) … … 991 1004 # text event is a new state, so delete the states with higher state_num 992 1005 # i.e., change the future 993 for i in range(int(state_num)+1, len(self.state.state_list)):1006 for i in range(int(state_num)+1, len(self.state.state_list)): 994 1007 try: 995 1008 del (self.state.state_list[str(i)]) … … 1012 1025 self.state.state_num = self.state.saved_state['state_num'] 1013 1026 #copy.deepcopy(self.state.saved_state) 1014 self.state.state_list[str(self.state.state_num)] = self.state.clone_state() 1027 self.state.state_list[str(self.state.state_num)] = \ 1028 self.state.clone_state() 1015 1029 except: 1016 1030 pass … … 1035 1049 try: 1036 1050 exec "self.state.saved_state['%s'] = '%s'" % (name, value) 1037 self.state.state_list[str(self.state.state_num)] = self.state.clone_state() 1051 self.state.state_list[str(self.state.state_num)] = \ 1052 self.state.clone_state() 1038 1053 except: 1039 1054 pass … … 1068 1083 self.Bind(wx.EVT_CONTEXT_MENU, self._on_context_menu) 1069 1084 1070 def on_bookmark(self, event):1085 def on_bookmark(self, event): 1071 1086 """ 1072 1087 Save the panel state in memory and add the list on … … 1092 1107 # append it to menu 1093 1108 id = wx.NewId() 1094 self.popUpMenu.Append(id, name,str(msg))1109 self.popUpMenu.Append(id, name, str(msg)) 1095 1110 wx.EVT_MENU(self, id, self._back_to_bookmark) 1096 1111 state = self.state.clone_state() … … 1100 1115 self.state.toXML(self, doc=None, entry_node=None) 1101 1116 1102 wx.PostEvent(self.parent, StatusEvent(status=msg,info="info"))1117 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info")) 1103 1118 wx.PostEvent(self.parent, 1104 1119 AppendBookmarkEvent(title=name, … … 1106 1121 handler=self._back_to_bookmark)) 1107 1122 1108 def _back_to_bookmark(self, event):1123 def _back_to_bookmark(self, event): 1109 1124 """ 1110 1125 Bring the panel back to the state of bookmarked requested by … … 1124 1139 current_state_num = self.state.state_num 1125 1140 self.get_bookmark_by_num(num) 1126 state_num = int(current_state_num) +11141 state_num = int(current_state_num) + 1 1127 1142 1128 1143 self.state.saved_state['state_num'] = state_num … … 1134 1149 self._info_bookmark_num(event) 1135 1150 1136 def _info_bookmark_num(self, event=None):1151 def _info_bookmark_num(self, event=None): 1137 1152 """ 1138 1153 print the bookmark number in info … … 1164 1179 """ 1165 1180 # date and time 1166 year, month, day,hour,minute,second,tda,ty,tm_isdst= time.localtime() 1167 my_time= str(hour)+":"+str(minute)+":"+str(second) 1168 date= str( month)+"/"+str(day)+"/"+str(year) 1181 year, month, day, hour, minute, second, tda, ty, tm_isdst = \ 1182 time.localtime() 1183 my_time = str(hour) + ":" + str(minute) + ":" + str(second) 1184 date = str( month) + "/" + str(day) + "/" + str(year) 1169 1185 return my_time, date 1170 1186 … … 1177 1193 path = None 1178 1194 if self.parent != None: 1179 self._default_save_location = \1195 self._default_save_location = \ 1180 1196 self.parent._default_save_location 1181 1197 if self._default_save_location == None: … … 1188 1204 self._default_save_location = os.path.dirname(path) 1189 1205 if self.parent != None: 1190 self.parent._default_save_location = \1206 self.parent._default_save_location = \ 1191 1207 self._default_save_location 1192 1208 else: … … 1200 1216 self._manager.save_file(filepath=fName, state=self.state) 1201 1217 1202 def _show_message(self, mssg='', msg='Warning'):1218 def _show_message(self, mssg='', msg='Warning'): 1203 1219 """ 1204 1220 Show warning message when resetting data … … 1221 1237 1222 1238 1223 def _on_context_menu(self, event):1239 def _on_context_menu(self, event): 1224 1240 1225 1241 pos = event.GetPosition() … … 1269 1285 self.high_extrapolation_sizer = wx.StaticBoxSizer(high_q_box, 1270 1286 wx.VERTICAL) 1271 self.high_q_sizer = wx.GridBagSizer(5, 5)1287 self.high_q_sizer = wx.GridBagSizer(5, 5) 1272 1288 #sizer to define outputs 1273 self.volume_surface_sizer = wx.GridBagSizer(5, 5)1289 self.volume_surface_sizer = wx.GridBagSizer(5, 5) 1274 1290 #Sizer related to invariant output 1275 1291 self.invariant_sizer = wx.GridBagSizer(5, 5) 1276 1292 #Sizer related to button 1277 1293 self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) 1278 self.button_sizer.SetMinSize((_STATICBOX_WIDTH, -1))1294 self.button_sizer.SetMinSize((_STATICBOX_WIDTH, -1)) 1279 1295 #Sizer related to save button 1280 1296 self.save_button_sizer = wx.BoxSizer(wx.HORIZONTAL) … … 1688 1704 invariant_total_txt = wx.StaticText(self, -1, 'Invariant Total [Q*]') 1689 1705 self.invariant_total_tcl = OutputTextCtrl(self, -1, 1690 size=(_BOX_WIDTH, -1),1706 size=(_BOX_WIDTH, -1), 1691 1707 name='invariant_total_tcl') 1692 1708 msg_hint = "Total invariant [Q*], including extrapolated regions." 1693 1709 self.invariant_total_tcl.SetToolTipString(msg_hint) 1694 1710 self.invariant_total_err_tcl = OutputTextCtrl(self, -1, 1695 size=(_BOX_WIDTH, -1),1711 size=(_BOX_WIDTH, -1), 1696 1712 name='invariant_total_err_tcl') 1697 1713 hint_msg = "Uncertainty on invariant." … … 1723 1739 contrast_txt = wx.StaticText(self, -1, 'Contrast :') 1724 1740 self.contrast_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 1725 style=0, name='contrast_tcl')1741 style=0, name='contrast_tcl') 1726 1742 wx.EVT_TEXT(self, self.contrast_tcl.GetId(), self._on_text) 1727 1743 contrast_hint_txt = "Contrast" … … 1750 1766 self.scale_tcl.SetToolTipString(scale_hint_txt) 1751 1767 self.sizer_input.AddMany([(background_txt, 0, wx.LEFT|wx.BOTTOM, 5), 1752 1753 1754 1755 1756 1757 1758 1759 1760 1768 (self.background_tcl, 0, wx.LEFT|wx.BOTTOM, 5), 1769 (background_unit_txt, 0, wx.LEFT|wx.BOTTOM, 5), 1770 (scale_txt, 0, wx.LEFT|wx.BOTTOM, 20), 1771 (self.scale_tcl, 0, wx.LEFT|wx.BOTTOM|wx.RIGHT, 5), 1772 (contrast_txt, 0, wx.LEFT|wx.BOTTOM, 5), 1773 (self.contrast_tcl, 0, wx.LEFT|wx.BOTTOM, 5), 1774 (contrast_unit_txt, 0, wx.LEFT|wx.BOTTOM, 5), 1775 (porod_const_txt, 0, wx.LEFT, 20), 1776 (self.porod_constant_tcl, 0, wx.LEFT|wx.BOTTOM|wx.RIGHT, 5)]) 1761 1777 self.inputs_sizer.Add(self.sizer_input) 1762 1778 … … 1820 1836 """ 1821 1837 """ 1822 def __init__(self, parent=None, id=1, graph=None,1823 data=None, title="Invariant", base=None):1838 def __init__(self, parent=None, id=1, graph=None, 1839 data=None, title="Invariant", base=None): 1824 1840 wx.Dialog.__init__(self, parent, id, title, size=(PANEL_WIDTH, 1825 1841 PANEL_HEIGHT))
Note: See TracChangeset
for help on using the changeset viewer.