Changeset cb69775 in sasview for invariantview
- Timestamp:
- Feb 14, 2011 3:10:50 PM (14 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:
- 20b228a0
- Parents:
- cadd049e
- Location:
- invariantview/perspectives/invariant
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
invariantview/perspectives/invariant/invariant.py
r75fbd17 rcb69775 215 215 216 216 217 def clear_panel(self): 218 self.invariant_panel.clear_panel() 219 217 220 def compute_helper(self, data): 218 221 """ … … 256 259 if datainfo.__class__.__name__ == 'list': 257 260 data = datainfo[0] 261 else: 262 data = datainfo 258 263 if data is None: 259 264 msg = "invariant.set_state: datainfo parameter cannot" … … 265 270 data.name = name 266 271 data.filename = name 267 #datainfo = self.parent.create_gui_data(datainfo,None)272 data = self.parent.create_gui_data(data,None) 268 273 #self.__data = datainfo 269 274 #self.__data.group_id = data.filename … … 273 278 reset=True, title=self.__data.title)) 274 279 #temp_state = copy.deepcopy(state) 275 temp_state = self.state_reader.get_state()280 #temp_state = self.state_reader.get_state() 276 281 # set state 277 282 self.invariant_panel.is_state_data = True … … 281 286 self.on_perspective(event=None) 282 287 # Load the invariant states 283 self.temp_state = temp_state284 self.invariant_panel.set_state(state= temp_state,data=self.__data)288 self.temp_state = state 289 self.invariant_panel.set_state(state=state,data=self.__data) 285 290 286 291 except: -
invariantview/perspectives/invariant/invariant_panel.py
r27f3831 rcb69775 13 13 from sans.guiframe.utils import check_float 14 14 from sans.guiframe.events import StatusEvent 15 from sans.guiframe.events import AppendBookmarkEvent 15 16 from .invariant_details import InvariantDetailsPanel 16 17 from .invariant_details import InvariantContainer … … 80 81 self.bookmark_num = 0 81 82 82 self._set_bookmark_menu()83 #self._set_bookmark_menu() 83 84 #Init state 84 85 self.set_state() … … 101 102 ## Default file location for save 102 103 self._default_save_location = os.getcwd() 103 104 def err_check_on_data(self): 105 """ 106 Check if data is valid for further computation 107 """ 108 flag = False 109 self.hint_msg_txt.SetLabel('') 110 #edit the panel 111 if self._data is not None: 112 if len(self._data.x[self._data.x==0]) > 0: 113 flag = True 114 msg = "Invariant: one of your q-values is zero. " 115 msg += "Delete that entry before proceeding" 116 self.hint_msg_txt.SetLabel(msg) 117 wx.PostEvent(self.parent, StatusEvent(status=msg, 118 info="warning", 119 type="stop")) 120 return flag 121 104 self._set_bookmark_flag(False) 105 122 106 def get_data(self): 123 107 """ … … 137 121 #edit the panel 138 122 if self._data is not None: 139 self.err_check_on_data()140 123 self.get_state_by_num(0) 141 124 data_name = self._data.name … … 196 179 num = self.state.saved_state['state_num'] 197 180 if num > 0 : 198 self._undo_enable()199 181 self._set_undo_flag(True) 200 182 if num < len(state.state_list) - 1: 201 self._redo_enable()202 183 self._set_redo_flag(True) 203 184 … … 225 206 self.is_state_data = False 226 207 227 def clear_panel(self , format='.svs'):208 def clear_panel(self): 228 209 """ 229 210 Clear panel to defaults, used by set_state of manager 230 211 """ 231 if format == '.svs':232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 212 213 self._data = None 214 # default data testctrl 215 self.hint_msg_txt.SetLabel('') 216 data_name = '' 217 data_qmin = '' 218 data_qmax = '' 219 self.data_name_tcl.SetValue(str(data_name)) 220 self.data_min_tcl.SetValue(str(data_qmin)) 221 self.data_max_tcl.SetValue(str(data_qmax)) 222 #reset output textctrl 223 self._reset_output() 224 #reset panel 225 self.reset_panel() 226 #reset state w/o data 227 self.set_state() 228 # default flags for state 229 self.new_state = False 230 self.is_state_data = False 231 self.is_power_out = False 251 232 252 233 def get_background(self): … … 525 506 elif event != None: 526 507 self._set_compute_state(state='compute') 527 self.button_bookmark.Enable(True)528 508 self._set_bookmark_flag(True) 529 509 msg= "\n\nStarting a new invariant computation..." … … 531 511 532 512 533 if self._data is None or self.err_check_on_data():513 if self._data is None: 534 514 return 535 515 self.button_details.Enable() 536 516 #clear outputs textctrl 537 517 self._reset_output() … … 625 605 626 606 #enable the button_ok for more details 627 self. button_details.Enable()607 self._set_preview_flag(True) 628 608 629 609 if event != None: 630 if not self.button_report.IsEnabled(): 631 self.button_report.Enable(True) 632 self._set_preview_flag(True) 633 if not self.button_save.IsEnabled(): 634 self.button_save.Enable(True) 635 self._set_save_flag(True) 610 self._set_preview_flag(True) 611 self._set_save_flag(True) 636 612 wx.PostEvent(self.parent, 637 613 StatusEvent(status='\nFinished invariant computation...')) … … 653 629 654 630 if float(pre_state_num) <= 0: 655 self._undo_disable()656 631 self._set_undo_flag(False) 657 632 else: 658 self._undo_enable()659 633 self._set_undo_flag(True) 660 661 self._redo_enable()662 634 self._set_redo_flag(True) 663 635 self.is_power_out = False … … 680 652 681 653 if float(next_state_num)+2 > len(self.state.state_list): 682 self._redo_disable()683 654 self._set_redo_flag(False) 684 655 else: 685 self._redo_enable() 686 self._set_redo_flag(FTrue) 687 688 self._undo_enable() 656 self._set_redo_flag(True) 657 689 658 self._set_undo_flag(True) 690 659 self.is_power_out = False … … 830 799 self._enable_high_q_section() 831 800 self._reset_output() 832 self.button_undo.Disable()833 801 self._set_undo_flag(False) 834 self.button_redo.Disable()835 802 self._set_redo_flag(False) 836 self.button_bookmark.Disable()837 803 self._set_bookmark_flag(False) 838 self.button_report.Disable()839 804 self._set_preview_flag(False) 840 self.button_save.Disable()841 805 self._set_save_flag(False) 842 806 self.button_calculate.SetFocus() … … 886 850 887 851 event.Skip() 888 self._undo_enable()889 852 self._set_undo_flag(True) 890 self._redo_disable()891 853 self._set_redo_flag(False) 892 854 … … 930 892 pass 931 893 # Enable the undo button if it was not 932 self._undo_enable()933 894 self._set_undo_flag(True) 934 self._redo_disable()935 895 self._set_redo_flag(False) 936 896 … … 961 921 #copy.deepcopy(self.state.saved_state) 962 922 self.state.state_list[str(self.state.state_num)] = self.state.clone_state() 963 self._ undo_disable()923 self._set_undo_flag(False) 964 924 965 925 def _on_text(self, event): … … 1011 971 1012 972 event.Skip() 1013 self._undo_enable()1014 973 self._set_undo_flag(True) 1015 self._redo_disable()1016 974 self._set_redo_flag(False) 1017 self.button_bookmark.Enable(True)1018 975 self._set_bookmark_flag(True) 1019 self.button_report.Disable()1020 976 self._set_preview_flag(False) 1021 977 1022 1023 978 def _on_out_text(self, event): 1024 979 """ … … 1087 1042 msg +=" Right click on the panel to retrieve this state" 1088 1043 #wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 1089 name = "%d] bookmarked at %s on %s"%(self.bookmark_num, my_time, date)1044 name = "%d] bookmarked at %s on %s"%(self.bookmark_num, my_time, date) 1090 1045 1091 1046 # append it to menu 1092 id = wx.NewId()1093 self.popUpMenu.Append(id,name,str(msg))1094 wx.EVT_MENU(self, id, self._back_to_bookmark)1047 #id = wx.NewId() 1048 #self.popUpMenu.Append(id,name,str(msg)) 1049 #wx.EVT_MENU(self, id, self._back_to_bookmark) 1095 1050 state = self.state.clone_state() 1096 1051 comp_state = copy.deepcopy(self.state.state_list[str(compute_num)]) … … 1100 1055 1101 1056 wx.PostEvent(self.parent,StatusEvent(status=msg,info="info")) 1057 wx.PostEvent(self.parent, 1058 AppendBookmarkEvent(title=name, 1059 hint=str(msg), 1060 handler=self._back_to_bookmark)) 1102 1061 1103 1062 def _back_to_bookmark(self,event): … … 1107 1066 and set it as a new state 1108 1067 """ 1068 self._manager.on_perspective(event) 1069 menu = event.GetEventObject() 1109 1070 ## post help message for the selected model 1110 msg = self.popUpMenu.GetHelpString(event.GetId())1071 msg = menu.GetHelpString(event.GetId()) 1111 1072 msg +=" reloaded" 1112 1073 wx.PostEvent(self.parent, StatusEvent(status = msg )) 1113 1074 1114 name= self.popUpMenu.GetLabel(event.GetId()) 1075 name= menu.GetLabel(event.GetId()) 1076 1115 1077 num,time = name.split(']') 1116 1078 current_state_num = self.state.state_num … … 1122 1084 self.state.state_list[str(state_num)] = self.state.clone_state() 1123 1085 self.state.state_num = state_num 1124 self._undo_enable()1086 1125 1087 self._set_undo_flag(True) 1126 1088 self._info_bookmark_num(event) … … 1134 1096 if event == None: return 1135 1097 # get the object 1136 item = self.popUpMenu.FindItemById(event.GetId()) 1098 menu = event.GetEventObject() 1099 item = menu.FindItemById(event.GetId()) 1137 1100 text = item.GetText() 1138 1101 num = text.split(']')[0] … … 1159 1122 date= str( month)+"/"+str(day)+"/"+str(year) 1160 1123 return my_time, date 1161 1162 def _undo_enable(self): 1163 """ 1164 Enable undo button 1165 """ 1166 if not self.button_undo.IsEnabled(): 1167 self.button_undo.Enable(True) 1168 1169 def _undo_disable(self): 1170 """ 1171 Disable undo button 1172 """ 1173 if self.button_undo.IsEnabled(): 1174 self.button_undo.Disable() 1175 1176 def _redo_enable(self): 1177 """ 1178 Enable redo button 1179 """ 1180 if not self.button_redo.IsEnabled(): 1181 self.button_redo.Enable(True) 1182 1183 def _redo_disable(self): 1184 """ 1185 Disable redo button 1186 """ 1187 if self.button_redo.IsEnabled(): 1188 self.button_redo.Disable() 1124 1189 1125 1190 1126 def on_save(self, evt=None): … … 1303 1239 """ 1304 1240 #Sizer hint 1305 hint_msg = "First open data file from 'File' menu." 1306 hint_msg += "Then Highlight and right click on the data plot. \n" 1307 hint_msg += "Finally, select 'Compute Invariant'." 1241 hint_msg = "" 1242 1308 1243 self.hint_msg_txt = wx.StaticText(self, -1, hint_msg) 1309 1244 self.hint_msg_txt.SetForegroundColour("red") … … 1393 1328 """ 1394 1329 if event != None: 1395 self.button_bookmark.Enable(True)1396 1330 self._set_bookmark_flag(True) 1397 self.button_report.Disable()1398 1331 self._set_preview_flag(False) 1399 print "enable fit==>event!=None" 1400 1332 1401 1333 if self.fix_enable_low.IsEnabled(): 1402 1334 … … 1414 1346 """ 1415 1347 if event != None: 1416 self.button_bookmark.Enable(True)1417 1348 self._set_bookmark_flag(True) 1418 self.button_report.Disable()1419 1349 self._set_preview_flag(False) 1420 1350 … … 1443 1373 """ 1444 1374 if event != None: 1445 self.button_bookmark.Enable(True)1446 1375 self._set_bookmark_flag(True) 1447 self.button_report.Disable()1448 1376 self._set_preview_flag(False) 1449 1377 if self.guinier.GetValue(): … … 1546 1474 """ 1547 1475 if event != None: 1548 self.button_bookmark.Enable(True)1549 1476 self._set_bookmark_flag(True) 1550 self.button_report.Disable()1477 1551 1478 self._set_preview_flag(False) 1552 1479 if self.fix_enable_high.IsEnabled(): … … 1564 1491 """ 1565 1492 if event != None: 1566 self.button_bookmark.Enable(True)1567 1493 self._set_bookmark_flag(True) 1568 self.button_report.Disable()1569 1494 self._set_preview_flag(False) 1570 1495 if self.enable_high_cbox.GetValue(): … … 1839 1764 (self.button_details, 0 , wx.ALL, 10), 1840 1765 (self.button_calculate, 0 , 1841 wx.RIGHT|wx.TOP|wx.BOTTOM, 10)])#, 1842 #(self.button_undo, 0 , wx.ALL, 10), 1843 #(self.button_redo, 0 , wx.ALL, 10)]) 1844 def _layout_save_button(self): 1845 """ 1846 Do the layout for the save button widgets 1847 """ 1848 import sans.perspectives.invariant as inv 1849 1850 path = inv.get_data_path(media='media') 1851 self.undo_png = os.path.join(path,"undo.png") 1852 self.redo_png = os.path.join(path,"redo.png") 1853 self.bookmark_png = os.path.join(path,"bookmark.png") 1854 self.report_png = os.path.join(path,"report.png") 1855 self.save_png = os.path.join(path,"save.png") 1856 #undo button 1857 id = wx.NewId() 1858 #wx.Button(self, id, "Undo",size=(50,20)) 1859 self.button_undo = wx.BitmapButton(self, id,wx.Bitmap(self.undo_png)) 1860 self.button_undo.SetToolTipString("Undo") 1861 1862 #self.button_undo.SetBackgroundColour('#c2e6f8') 1863 self.Bind(wx.EVT_BUTTON, self.on_undo, id=id) 1864 self._undo_disable() 1865 #redo button 1866 id = wx.NewId() 1867 #wx.Button(self, id, "Redo",size=(50,20)) 1868 self.button_redo = wx.BitmapButton(self, id,wx.Bitmap(self.redo_png)) 1869 self.button_redo.SetToolTipString("Redo") 1870 self.Bind(wx.EVT_BUTTON, self.on_redo, id=id) 1871 self._redo_disable() 1872 self._set_redo_flag(False) 1873 #bookmark button 1874 id = wx.NewId() 1875 #wx.Button(self, id, "Undo",size=(50,20)) 1876 self.button_bookmark = wx.BitmapButton(self, id, 1877 wx.Bitmap(self.bookmark_png)) 1878 hint_msg = "Bookmark: right-click on the panel to retrieve it" 1879 self.button_bookmark.SetToolTipString(hint_msg) 1880 self.Bind(wx.EVT_BUTTON, self.on_bookmark, id=id) 1881 #report button 1882 id = wx.NewId() 1883 #wx.Button(self, id, "Redo",size=(50,20)) 1884 self.button_report = wx.BitmapButton(self, id, 1885 wx.Bitmap(self.report_png)) 1886 hint_msg = "Report the result of the computation" 1887 self.button_report.SetToolTipString(hint_msg) 1888 self.Bind(wx.EVT_BUTTON, self.on_preview, id=id) 1889 #self.button_report.Disable() 1890 #self._set_preview_flag(False) 1891 #save button 1892 id = wx.NewId() 1893 #wx.Button(self, id, "Save", name ='Save_invariant' ) 1894 self.button_save = wx.BitmapButton(self, id, wx.Bitmap(self.save_png), 1895 name='Save_invariant') 1896 self.button_save.SetToolTipString("Save as a file") 1897 self.Bind(wx.EVT_BUTTON, self.on_save, id=id) 1898 self.button_save.Disable() 1899 self._set_save_flag(False) 1900 self.save_button_sizer.AddMany([((PANEL_WIDTH/2,20), 1 , 1901 wx.EXPAND|wx.ADJUST_MINSIZE,0), 1902 (self.button_undo, 0 , 1903 wx.LEFT|wx.ADJUST_MINSIZE, 10), 1904 (self.button_redo, 0 , 1905 wx.LEFT|wx.ADJUST_MINSIZE, 10), 1906 (self.button_bookmark, 0 , 1907 wx.LEFT|wx.ADJUST_MINSIZE, 10), 1908 (self.button_report, 0 , 1909 wx.LEFT|wx.ADJUST_MINSIZE, 10), 1910 (self.button_save, 0 , 1911 wx.LEFT|wx.ADJUST_MINSIZE, 10)]) 1766 wx.RIGHT|wx.TOP|wx.BOTTOM, 10)]) 1912 1767 def _do_layout(self): 1913 1768 """ … … 1920 1775 self._layout_outputs_sizer() 1921 1776 self._layout_button() 1922 self._layout_save_button()1923 1777 self.main_sizer.AddMany([(self.data_name_boxsizer,0, wx.ALL, 10), 1924 1778 (self.outputs_sizer, 0, … … 1929 1783 wx.LEFT|wx.RIGHT|wx.BOTTOM, 10), 1930 1784 (self.extrapolation_sizer, 0, 1931 wx.LEFT|wx.RIGHT|wx.BOTTOM, 10),\1932 (self.save_button_sizer,0,1933 1785 wx.LEFT|wx.RIGHT|wx.BOTTOM, 10)]) 1934 1786 self.SetSizer(self.main_sizer) -
invariantview/perspectives/invariant/invariant_state.py
r75fbd17 rcb69775 208 208 # other outputs than Q* 209 209 name = item[0] + "_tcl" 210 exec "value = self.saved_state['%s']" % name 210 if name in self.saved_state.keys(): 211 exec "value = self.saved_state['%s']" % name 211 212 212 213 # Exclude the outputs w/'' … … 228 229 format_number(value, high=True)) 229 230 # Include warning msg 230 state += "\n\nNote:\n" + self.container.warning_msg 231 if self.container is not None: 232 state += "\n\nNote:\n" + self.container.warning_msg 231 233 return state 232 234 … … 745 747 # Call back to post the new state 746 748 self.state = output[0].meta_data['invstate'] 747 #self.call_back(state=output[0].meta_data['invstate'],748 #datainfo = output[0])749 self.call_back(state=output[0].meta_data['invstate'], 750 datainfo = output[0]) 749 751 return output[0] 750 752 else:
Note: See TracChangeset
for help on using the changeset viewer.