Changeset 998ca90 in sasview for src/sas/sasgui
- Timestamp:
- Oct 7, 2016 12:21:40 PM (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:
- ff3f5821
- Parents:
- cb823f0
- Location:
- src/sas/sasgui
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/data_panel.py
re767897 r998ca90 890 890 891 891 892 def on_remove(self, event ):892 def on_remove(self, event, msg=""): 893 893 """ 894 894 Get a list of item checked and remove them from the treectrl 895 895 Ask the parent to remove reference to this item 896 896 """ 897 msg = "This operation will delete the data sets checked " 898 msg += "and all the dependents." 897 if msg == "": 898 msg = "This operation will delete the data sets checked " 899 msg += "and all the dependents." 899 900 msg_box = wx.MessageDialog(None, msg, 'Warning', wx.OK|wx.CANCEL) 900 901 if msg_box.ShowModal() != wx.ID_OK: 901 return 902 return True 902 903 903 904 data_to_remove, theory_to_remove, _ = self.set_data_helper() -
src/sas/sasgui/guiframe/gui_manager.py
r3fac0df r998ca90 1904 1904 if self._default_save_location == None: 1905 1905 self._default_save_location = os.getcwd() 1906 wx.PostEvent(self, StatusEvent(status="Loading Project file...")) 1907 dlg = wx.FileDialog(self, 1906 msg = "This operation will set SasView to its freshly opened state " 1907 msg += "before loading the project. Do you wish to continue?" 1908 if not self._data_panel.on_remove(None, msg): 1909 wx.PostEvent(self, StatusEvent(status="Loading Project file...")) 1910 dlg = wx.FileDialog(self, 1908 1911 "Choose a file", 1909 1912 self._default_save_location, "", 1910 1913 APPLICATION_WLIST) 1911 if dlg.ShowModal() == wx.ID_OK:1912 path = dlg.GetPath()1914 if dlg.ShowModal() == wx.ID_OK: 1915 path = dlg.GetPath() 1913 1916 if path is not None: 1914 1917 self._default_save_location = os.path.dirname(path) 1915 dlg.Destroy() 1916 1917 self.load_state(path=path, is_project=True) 1918 dlg.Destroy() 1919 1920 # Reset to a base state 1921 self._on_reset_state() 1922 1923 # Load the project file 1924 self.load_state(path=path, is_project=True) 1925 1926 def _on_reset_state(self): 1927 """ 1928 Resets SasView to its freshly opened state. 1929 :return: None 1930 """ 1931 # Reset all plugins to their base state 1932 for plugin in self.plugins: 1933 plugin.clear_panel() 1934 # Reset plot number to 0 1935 self.graph_num = 0 1936 # Remove all loaded data 1937 self._data_panel.selection_cbox.SetValue('Select all Data') 1938 self._data_panel._on_selection_type(None) 1918 1939 1919 1940 def _on_save_application(self, event): … … 2063 2084 except: 2064 2085 logging.info("Failed to connect to www.sasview.org") 2065 self._process_version(version_info, standalone=event == None) 2066 2067 2068 2069 # 2070 # try: 2071 # req = urllib2.Request(config.__update_URL__) 2072 # res = urllib2.urlopen(req) 2073 # content = res.read().strip() 2074 # logging.info("Connected to www.sasview.org. Latest version: %s" 2075 # % (content)) 2076 # version_info = json.loads(content) 2077 # except: 2078 # logging.info("Failed to connect to www.sasview.org") 2079 # version_info = {"version": "0.0.0"} 2080 # self._process_version(version_info, standalone=event == None) 2086 self._process_version(version_info, standalone=event == None) 2081 2087 2082 2088 def _process_version(self, version_info, standalone=True): -
src/sas/sasgui/perspectives/fitting/fitpanel.py
ra95ae9a r998ca90 200 200 nop = nop - 1 201 201 202 # #save the title of the last page tab added202 # save the title of the last page tab added 203 203 self.fit_page_name = {} 204 # #list of existing fit page204 # list of existing fit page 205 205 self.opened_pages = {} 206 self.fit_page_index = 0 207 self.batch_page_index = 0 206 208 207 209 def set_state(self, state): … … 242 244 self.close_all() 243 245 self._manager.mypanels = [] 246 self.sim_page = None 247 self.batch_page = None 244 248 245 249 def on_close_page(self, event=None): -
src/sas/sasgui/perspectives/fitting/pagestate.py
re89aed5 r998ca90 378 378 379 379 rep += "State created: %s\n" % time_str 380 rep += "State form factor combobox selection: %s\n" % self.formfactorcombobox 381 rep += "State structure factor combobox selection: %s\n" % self.structurecombobox 380 rep += "State form factor combobox selection: %s\n" % \ 381 self.formfactorcombobox 382 rep += "State structure factor combobox selection: %s\n" % \ 383 self.structurecombobox 382 384 rep += "is data : %s\n" % self.is_data 383 385 rep += "data's name : %s\n" % self.data_name … … 639 641 640 642 Compatible with standalone writing, or appending to an 641 already existing XML document. In that case, the XML document 642 isrequired. An optional entry node in the XML document may also be given.643 already existing XML document. In that case, the XML document is 644 required. An optional entry node in the XML document may also be given. 643 645 644 646 :param file: file to write to 645 647 :param doc: XML document object [optional] 646 :param entry_node: XML node within the XML document at which we will append the data [optional]647 648 :param entry_node: XML node within the XML document at which we 649 will append the data [optional] 648 650 """ 649 651 from xml.dom.minidom import getDOMImplementation … … 744 746 for item in LIST_OF_STATE_PARAMETERS: 745 747 element = newdoc.createElement(item[0]) 746 self._toXML_helper(thelist=getattr(self, item[1]), element=element, newdoc=newdoc) 748 self._toXML_helper(thelist=getattr(self, item[1]), 749 element=element, newdoc=newdoc) 747 750 inputs.appendChild(element) 748 751 … … 761 764 batch_combo.appendChild(constraints) 762 765 for constraint in batch_fit_state.constraints_list: 763 # model_cbox, param_cbox, egal_txt, constraint, btRemove, sizer 764 doc_cons = newdoc.createElement('constraint') 765 doc_cons.setAttribute('model_cbox', 766 str(constraint.model_cbox.GetValue())) 767 doc_cons.setAttribute('param_cbox', 768 str(constraint.param_cbox.GetValue())) 769 doc_cons.setAttribute('egal_txt', 770 str(constraint.egal_txt.GetLabel())) 771 doc_cons.setAttribute('constraint', 772 str(constraint.constraint.GetValue())) 773 constraints.appendChild(doc_cons) 766 if constraint.model_cbox.GetValue() != "": 767 # model_cbox, param_cbox, egal_txt, constraint, btRemove, sizer 768 doc_cons = newdoc.createElement('constraint') 769 doc_cons.setAttribute('model_cbox', 770 str(constraint.model_cbox.GetValue())) 771 doc_cons.setAttribute('param_cbox', 772 str(constraint.param_cbox.GetValue())) 773 doc_cons.setAttribute('egal_txt', 774 str(constraint.egal_txt.GetLabel())) 775 doc_cons.setAttribute('constraint', 776 str(constraint.constraint.GetValue())) 777 constraints.appendChild(doc_cons) 774 778 775 779 # Save all models … … 912 916 value = cls.type 913 917 except Exception: 914 logging.error("unable to load distribution %r for %s"915 918 base = "unable to load distribution %r for %s" 919 logging.error(base % (value, parameter)) 916 920 continue 917 921 _disp_obj_dict = getattr(self, varname) … … 1036 1040 raise RuntimeError, "The cansas writer expects a Data2D instance" 1037 1041 1042 title = "cansas1d/%s" % self.version 1043 title += "http://svn.smallangles.net/svn/canSAS/1dwg/trunk/cansas1d.xsd" 1038 1044 doc = xml.dom.minidom.Document() 1039 1045 main_node = doc.createElement("SASroot") 1040 1046 main_node.setAttribute("version", self.version) 1041 1047 main_node.setAttribute("xmlns", "cansas1d/%s" % self.version) 1042 main_node.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance")1043 main_node.setAttribute("xsi:schemaLocation",1044 "cansas1d/%s http://svn.smallangles.net/svn/canSAS/1dwg/trunk/cansas1d.xsd" % self.version)1048 main_node.setAttribute("xmlns:xsi", 1049 "http://www.w3.org/2001/XMLSchema-instance") 1050 main_node.setAttribute("xsi:schemaLocation", title) 1045 1051 1046 1052 doc.appendChild(main_node) … … 1051 1057 write_node(doc, entry_node, "Title", datainfo.title) 1052 1058 if datainfo is not None: 1053 write_node(doc, entry_node, "data_class", datainfo.__class__.__name__) 1059 write_node(doc, entry_node, "data_class", 1060 datainfo.__class__.__name__) 1054 1061 for item in datainfo.run: 1055 1062 runname = {} 1056 if datainfo.run_name.has_key(item) and len(str(datainfo.run_name[item])) > 1: 1063 if datainfo.run_name.has_key(item) and \ 1064 len(str(datainfo.run_name[item])) > 1: 1057 1065 runname = {'name': datainfo.run_name[item]} 1058 1066 write_node(doc, entry_node, "Run", item, runname) … … 1313 1321 namespaces={'ns': CANSAS_NS}) 1314 1322 model_list_items = model_list[0].xpath('ns:model_list_item', 1315 1323 namespaces={'ns': CANSAS_NS}) 1316 1324 for model in model_list_items: 1317 1325 attrs = model.attrib 1318 1326 sim_fit_state.model_list.append(attrs) 1327 1319 1328 constraints = simfitstate_0.xpath('ns:constraints', 1320 1329 namespaces={'ns': CANSAS_NS}) 1321 1330 constraint_list = constraints[0].xpath('ns:constraint', 1322 1331 namespaces={'ns': CANSAS_NS}) 1323 1332 for constraint in constraint_list: 1324 1333 attrs = constraint.attrib … … 1388 1397 data_info.notes.append(note_value) 1389 1398 except Exception: 1390 err_mess = "cansas_reader.read: error processing entry notes\n %s" % sys.exc_value 1399 err_mess = "cansas_reader.read: error processing entry notes\n" 1400 err_mess += " %s" % sys.exc_value 1391 1401 self.errors.append(err_mess) 1392 1402 logging.error(err_mess) … … 1398 1408 1399 1409 self._store_content('ns:SASsample/ns:ID', dom, 'ID', data_info.sample) 1400 self._store_float('ns:SASsample/ns:thickness', dom, 'thickness', data_info.sample) 1401 self._store_float('ns:SASsample/ns:transmission', dom, 'transmission', data_info.sample) 1402 self._store_float('ns:SASsample/ns:temperature', dom, 'temperature', data_info.sample) 1403 1404 nodes = dom.xpath('ns:SASsample/ns:details', namespaces={'ns': CANSAS_NS}) 1410 self._store_float('ns:SASsample/ns:thickness', dom, 'thickness', 1411 data_info.sample) 1412 self._store_float('ns:SASsample/ns:transmission', dom, 'transmission', 1413 data_info.sample) 1414 self._store_float('ns:SASsample/ns:temperature', dom, 'temperature', 1415 data_info.sample) 1416 1417 nodes = dom.xpath('ns:SASsample/ns:details', 1418 namespaces={'ns': CANSAS_NS}) 1405 1419 for item in nodes: 1406 1420 try: … … 1410 1424 data_info.sample.details.append(detail_value) 1411 1425 except Exception: 1412 err_mess = "cansas_reader.read: error processing sample details\n %s" % sys.exc_value 1426 err_mess = "cansas_reader.read: error processing entry notes\n" 1427 err_mess += " %s" % sys.exc_value 1413 1428 self.errors.append(err_mess) 1414 1429 logging.error(err_mess) 1415 1430 1416 1431 # Position (as a vector) 1417 self._store_float('ns:SASsample/ns:position/ns:x', dom, 'position.x', data_info.sample) 1418 self._store_float('ns:SASsample/ns:position/ns:y', dom, 'position.y', data_info.sample) 1419 self._store_float('ns:SASsample/ns:position/ns:z', dom, 'position.z', data_info.sample) 1432 self._store_float('ns:SASsample/ns:position/ns:x', dom, 'position.x', 1433 data_info.sample) 1434 self._store_float('ns:SASsample/ns:position/ns:y', dom, 'position.y', 1435 data_info.sample) 1436 self._store_float('ns:SASsample/ns:position/ns:z', dom, 'position.z', 1437 data_info.sample) 1420 1438 1421 1439 # Orientation (as a vector) … … 1551 1569 process.term.append(term_attr) 1552 1570 except: 1553 err_mess = "cansas_reader.read: error processing process term\n %s" % sys.exc_value 1571 err_mess = "cansas_reader.read: error processing " 1572 err_mess += "entry notes\n %s" % sys.exc_value 1554 1573 self.errors.append(err_mess) 1555 1574 logging.error(err_mess) … … 1579 1598 value_list = [] 1580 1599 if field is not None: 1581 value_list = [parse_entry_helper(node, item) for node in field] 1600 value_list = \ 1601 [parse_entry_helper(node, item) for node in field] 1582 1602 if len(value_list) < 2: 1583 1603 setattr(data_info, item[0], None) … … 1613 1633 entry_list = root.xpath('ns:SASentry', 1614 1634 namespaces={'ns': CANSAS_NS}) 1635 name_map = {} 1615 1636 for entry in entry_list: 1616 1637 try: -
src/sas/sasgui/perspectives/fitting/simfitpage.py
r4fea1df r998ca90 1050 1050 """ 1051 1051 1052 # FIXME: Not tracking data set name on loading ==> NECESSARY!1053 1052 model_map = {} 1054 1053 if fit.fit_panel.sim_page is None: … … 1069 1068 check = bool(saved_model.pop('checked')) 1070 1069 sim_page.model_list[i][0].SetValue(check) 1071 continue1070 break 1072 1071 i += 1 1073 1072 sim_page.check_model_name(None) … … 1080 1079 for index, item in enumerate(self.constraints_list): 1081 1080 model_cbox = item.pop('model_cbox') 1082 constraint_value = item.pop('constraint') 1083 param = item.pop('param_cbox') 1084 equality = item.pop('egal_txt') 1085 for key, value in model_map.iteritems(): 1086 model_cbox.replace(key, value) 1087 constraint_value.replace(key, value) 1088 1089 sim_page.constraints_list[index][0].SetValue(model_cbox) 1090 sim_page._on_select_model(None) 1091 sim_page.constraints_list[index][1].SetValue(param) 1092 sim_page.constraints_list[index][2].SetLabel(equality) 1093 sim_page.constraints_list[index][3].SetValue(constraint_value) 1094 sim_page._on_add_constraint(None) 1081 if model_cbox != "": 1082 constraint_value = item.pop('constraint') 1083 param = item.pop('param_cbox') 1084 equality = item.pop('egal_txt') 1085 for key, value in model_map.iteritems(): 1086 model_cbox.replace(key, value) 1087 constraint_value.replace(key, value) 1088 1089 sim_page.constraints_list[index][0].SetValue(model_cbox) 1090 sim_page._on_select_model(None) 1091 sim_page.constraints_list[index][1].SetValue(param) 1092 sim_page.constraints_list[index][2].SetLabel(equality) 1093 sim_page.constraints_list[index][3].SetValue(constraint_value) 1094 sim_page._on_add_constraint(None) 1095 1095 1096 1096 def _format_id(self, original_id):
Note: See TracChangeset
for help on using the changeset viewer.