Changeset 940aca7 in sasview


Ignore:
Timestamp:
May 19, 2012 10:17:02 AM (12 years ago)
Author:
Mathieu Doucet <doucetm@…>
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:
baa915c
Parents:
d225e32
Message:

Merge 2.1.1 into trunk

Files:
23 edited

Legend:

Unmodified
Added
Removed
  • fittingview/src/sans/perspectives/fitting/basepage.py

    r19e614a r940aca7  
    113113        self.enable2D = False 
    114114        self.is_mac = ON_MAC 
    115          
     115        self.formfactorbox = None 
     116        self.structurebox = None 
    116117        ##list of model parameters. each item must have same length 
    117118        ## each item related to a given parameters 
     
    882883            self.state.disp_list = copy.deepcopy(self.disp_list) 
    883884            self.state.model = self.model.clone() 
     885             
     886            #model combobox: complex code because of mac's silent error 
     887            if self.structurebox != None: 
     888                if self.structurebox.IsShown(): 
     889                    self.state.structurecombobox = 'None' 
     890                    s_select = self.structurebox.GetSelection() 
     891                    if s_select > 0: 
     892                        self.state.structurecombobox = self.structurebox.\ 
     893                        GetString(s_select) 
     894            if self.formfactorbox != None: 
     895                f_select = self.formfactorbox.GetSelection() 
     896                if f_select > 0: 
     897                        self.state.formfactorcombobox = self.formfactorbox.\ 
     898                        GetString(f_select) 
     899                         
    884900        #save radiobutton state for model selection 
    885901        self.state.shape_rbutton = self.shape_rbutton.GetValue() 
     
    887903        self.state.struct_rbutton = self.struct_rbutton.GetValue() 
    888904        self.state.plugin_rbutton = self.plugin_rbutton.GetValue() 
    889         #model combobox 
    890         self.state.structurebox = self.structurebox.GetLabel() 
    891         self.state.formfactorbox = self.formfactorbox.GetLabel() 
    892905         
    893906        self.state.enable2D = copy.deepcopy(self.enable2D) 
     
    12311244            structfactor_pos = 0 
    12321245            for ind_struct in range(self.structurebox.GetCount()): 
    1233                 if self.structurebox.GetString(ind_struct) == (state.structurecombobox) > 0: 
     1246                if self.structurebox.GetString(ind_struct) == (state.structurecombobox): 
    12341247                    structfactor_pos = int(ind_struct) 
    12351248                    break 
     
    14281441        self.state.struct_rbutton = self.struct_rbutton.GetValue() 
    14291442        self.state.plugin_rbutton = self.plugin_rbutton.GetValue() 
    1430         self.state.structurebox = self.structurebox.GetLabel() 
    1431         self.state.formfactorbox = self.formfactorbox.GetLabel() 
     1443        self.state.structurecombobox = self.structurebox.GetLabel() 
     1444        self.state.formfactorcombobox = self.formfactorbox.GetLabel() 
    14321445        
    14331446        ## post state to fit panel 
  • fittingview/src/sans/perspectives/fitting/batchfitpage.py

    r978feaa r940aca7  
    3838        self.window_caption  = "BatchFit" 
    3939        self._set_save_flag(False) 
     40        self._set_bookmark_flag(False) 
    4041         
    4142    def _fill_range_sizer(self): 
     
    365366            self._set_paste_flag(True) 
    366367            if self.data != None: 
    367                 self._set_bookmark_flag(True) 
    368                 self._keep.Enable(True) 
     368                self._set_bookmark_flag(False) 
     369                self._keep.Enable(False) 
    369370                 
    370371            temp_smear = None 
     
    552553        else: 
    553554            if self.model != None: 
    554                 self._set_bookmark_flag(True) 
    555                 self._keep.Enable(True) 
    556             self._set_save_flag(True) 
     555                self._set_bookmark_flag(False) 
     556                self._keep.Enable(False) 
     557            self._set_save_flag(False) 
    557558            self._set_preview_flag(True) 
    558559            """ 
  • fittingview/src/sans/perspectives/fitting/fit_thread.py

    raff2913 r940aca7  
    2626                 completefn = None, 
    2727                 updatefn   = None, 
    28                  yieldtime  = 0.01, 
    29                  worktime   = 0.01, 
     28                 yieldtime  = 0.03, 
     29                 worktime   = 0.03, 
    3030                 ftol       = None, 
    3131                 reset_flag = False): 
  • fittingview/src/sans/perspectives/fitting/fitpage.py

    rac2b835 r940aca7  
    12201220                is_data = check_data_validity(self.data) 
    12211221                if is_data: 
    1222                     self._set_bookmark_flag(True) 
    1223                     self._keep.Enable(True) 
     1222                    self._set_bookmark_flag(not self.batch_on) 
     1223                    self._keep.Enable(not self.batch_on) 
    12241224                    self._set_save_flag(True) 
    12251225            # Reset smearer, model and data 
     
    14821482        if len(self.parameters) > 0: 
    14831483            for item in self.parameters: 
    1484                 #Skip t ifhe angle parameters if 1D data 
    1485                 if self.data.__class__.__name__ != "Data2D" and \ 
    1486                         not self.enable2D: 
    1487                     if item in self.orientation_params: 
     1484                if item[0].IsShown(): 
     1485                    #Skip t ifhe angle parameters if 1D data 
     1486                    if self.data.__class__.__name__ != "Data2D" and \ 
     1487                            not self.enable2D: 
     1488                        if item in self.orientation_params: 
     1489                            continue 
     1490                    if item in self.param_toFit: 
    14881491                        continue 
    1489                 if item in self.param_toFit: 
    1490                     continue 
    1491                 ## hide statictext +/- 
    1492                 if len(item) < 4: 
    1493                     continue 
    1494                 if item[3] != None and item[3].IsShown(): 
    1495                     item[3].Hide() 
    1496                 ## hide textcrtl  for error after fit 
    1497                 if item[4] != None and item[4].IsShown(): 
    1498                     item[4].Hide() 
     1492                    ## hide statictext +/- 
     1493                    if len(item) < 4: 
     1494                        continue 
     1495                    if item[3] != None and item[3].IsShown(): 
     1496                        item[3].Hide() 
     1497                    ## hide textcrtl  for error after fit 
     1498                    if item[4] != None and item[4].IsShown(): 
     1499                        item[4].Hide() 
    14991500   
    15001501        if len(self.fittable_param) > 0: 
    15011502            for item in self.fittable_param: 
    1502                 #Skip t ifhe angle parameters if 1D data 
    1503                 if self.data.__class__.__name__ != "Data2D" and \ 
    1504                         not self.enable2D: 
    1505                     if item in self.orientation_params: 
     1503                if item[0].IsShown(): 
     1504                    #Skip t ifhe angle parameters if 1D data 
     1505                    if self.data.__class__.__name__ != "Data2D" and \ 
     1506                            not self.enable2D: 
     1507                        if item in self.orientation_params: 
     1508                            continue 
     1509                    if item in self.param_toFit: 
    15061510                        continue 
    1507                 if item in self.param_toFit: 
    1508                     continue 
    1509                 if len(item) < 4: 
    1510                     continue 
    1511                 ## hide statictext +/- 
    1512                 if item[3] != None and item[3].IsShown(): 
    1513                     item[3].Hide() 
    1514                 ## hide textcrtl  for error after fit 
    1515                 if item[4] != None and item[4].IsShown(): 
    1516                     item[4].Hide() 
     1511                    if len(item) < 4: 
     1512                        continue 
     1513                    ## hide statictext +/- 
     1514                    if item[3] != None and item[3].IsShown(): 
     1515                        item[3].Hide() 
     1516                    ## hide textcrtl  for error after fit 
     1517                    if item[4] != None and item[4].IsShown(): 
     1518                        item[4].Hide() 
    15171519        return 
    15181520                 
     
    18471849        else: 
    18481850            if self.model != None: 
    1849                 self._set_bookmark_flag(True) 
    1850                 self._keep.Enable(True) 
     1851                self._set_bookmark_flag(not self.batch_on) 
     1852                self._keep.Enable(not self.batch_on) 
    18511853                 
    18521854            self._set_save_flag(True) 
     
    19411943            #replace data plot on combo box selection 
    19421944            #by removing the previous selected data 
    1943             wx.PostEvent(self._manager.parent, 
    1944                          NewPlotEvent(action="remove", 
    1945                                       group_id=self.graph_id, id=id)) 
     1945            #wx.PostEvent(self._manager.parent, 
     1946            #             NewPlotEvent(action="remove", 
     1947            #                          group_id=self.graph_id, id=id)) 
    19461948            #plot the current selected data 
    19471949            wx.PostEvent(self._manager.parent, 
    1948                          NewPlotEvent(plot=self.data, 
     1950                         NewPlotEvent(action="check", plot=self.data, 
    19491951                                      title=str(self.data.title))) 
    19501952            self._draw_model() 
     
    20772079        for item in self.param_toFit: 
    20782080            if len(item) > 5 and item != None: 
    2079                 ## reset error value to initial state 
    2080                 if not self.is_mac: 
    2081                     item[3].Hide() 
    2082                     item[4].Hide() 
    2083                 for ind in range(len(out)): 
    2084                     if item[1] == p_name[ind]: 
    2085                         break 
    2086                 if len(out) <= len(self.param_toFit) and out[ind] != None: 
    2087                     val_out = format_number(out[ind], True) 
    2088                     item[2].SetValue(val_out) 
    2089  
    2090                 if(cov != None and len(cov) == len(out)): 
    2091                     try: 
    2092                         if dispersity != None: 
    2093                             if self.enable_disp.GetValue(): 
    2094                                 if hasattr(self, "text_disp_1"): 
    2095                                     if self.text_disp_1 != None: 
    2096                                         if not self.text_disp_1.IsShown()\ 
    2097                                             and not self.is_mac: 
    2098                                             self.text_disp_1.Show(True) 
    2099                     except: 
    2100                         pass 
    2101                      
    2102                     if cov[ind] != None: 
    2103                         if numpy.isfinite(float(cov[ind])): 
    2104                             val_err = format_number(cov[ind], True) 
    2105                             if not self.is_mac: 
    2106                                 item[3].Show(True) 
    2107                                 item[4].Show(True) 
    2108                             item[4].SetValue(val_err) 
    2109                             has_error = True 
     2081                if item[0].IsShown(): 
     2082                    ## reset error value to initial state 
     2083                    if not self.is_mac: 
     2084                        item[3].Hide() 
     2085                        item[4].Hide() 
     2086                    for ind in range(len(out)): 
     2087                        if item[1] == p_name[ind]: 
     2088                            break 
     2089                    if len(out) > 0 and out[ind] != None: 
     2090                        val_out = format_number(out[ind], True) 
     2091                        item[2].SetValue(val_out) 
     2092     
     2093                    if(cov != None and len(cov) == len(out)): 
     2094                        try: 
     2095                            if dispersity != None: 
     2096                                if self.enable_disp.GetValue(): 
     2097                                    if hasattr(self, "text_disp_1"): 
     2098                                        if self.text_disp_1 != None: 
     2099                                            if not self.text_disp_1.IsShown()\ 
     2100                                                and not self.is_mac: 
     2101                                                self.text_disp_1.Show(True) 
     2102                        except: 
     2103                            pass 
     2104                         
     2105                        if cov[ind] != None: 
     2106                            if numpy.isfinite(float(cov[ind])): 
     2107                                val_err = format_number(cov[ind], True) 
     2108                                if not self.is_mac: 
     2109                                    item[3].Show(True) 
     2110                                    item[4].Show(True) 
     2111                                item[4].SetValue(val_err) 
     2112                                has_error = True 
    21102113                i += 1 
     2114            else: 
     2115                raise ValueError, "onsetValues: Invalid parameters..." 
    21112116        #Show error title when any errors displayed 
    21122117        if has_error: 
     
    26062611        for item in self.parameters: 
    26072612            if item[0].GetValue() and item not in self.param_toFit: 
    2608                 self.param_toFit.append(item) 
     2613                if item[0].IsShown(): 
     2614                    self.param_toFit.append(item) 
    26092615        for item in self.fittable_param: 
    26102616            if item[0].GetValue() and item not in self.param_toFit: 
    2611                 self.param_toFit.append(item) 
     2617                if item[0].IsShown(): 
     2618                    self.param_toFit.append(item) 
    26122619        self.save_current_state_fit() 
    26132620        
     
    26162623        param2fit = [] 
    26172624        for item in self.param_toFit: 
    2618             if item[0]: 
     2625            if item[0] and item[0].IsShown(): 
    26192626                param2fit.append(item[1]) 
    26202627        self.parent._manager.set_param2fit(self.uid, param2fit) 
     
    26282635            if  self.cb1.GetValue(): 
    26292636                for item in self.parameters: 
    2630                     ## for data2D select all to fit 
    2631                     if self.data.__class__.__name__ == "Data2D" or \ 
    2632                             self.enable2D: 
    2633                         item[0].SetValue(True) 
    2634                         self.param_toFit.append(item) 
    2635                     else: 
    2636                         ## for 1D all parameters except orientation 
    2637                         if not item in self.orientation_params: 
     2637                    if item[0].IsShown(): 
     2638                        ## for data2D select all to fit 
     2639                        if self.data.__class__.__name__ == "Data2D" or \ 
     2640                                self.enable2D: 
    26382641                            item[0].SetValue(True) 
    26392642                            self.param_toFit.append(item) 
     2643                        else: 
     2644                            ## for 1D all parameters except orientation 
     2645                            if not item in self.orientation_params: 
     2646                                item[0].SetValue(True) 
     2647                                self.param_toFit.append(item) 
     2648                    else: 
     2649                        item[0].SetValue(False) 
    26402650                #if len(self.fittable_param)>0: 
    26412651                for item in self.fittable_param: 
    2642                     if self.data.__class__.__name__ == "Data2D" or \ 
    2643                             self.enable2D: 
    2644                         item[0].SetValue(True) 
    2645                         self.param_toFit.append(item) 
    2646                         try: 
    2647                             if len(self.values[item[1]]) > 0: 
    2648                                 item[0].SetValue(False) 
    2649                         except: 
    2650                             pass 
    2651  
    2652                     else: 
    2653                         ## for 1D all parameters except orientation 
    2654                         if not item in self.orientation_params_disp: 
     2652                    if item[0].IsShown(): 
     2653                        if self.data.__class__.__name__ == "Data2D" or \ 
     2654                                self.enable2D: 
    26552655                            item[0].SetValue(True) 
    26562656                            self.param_toFit.append(item) 
     
    26602660                            except: 
    26612661                                pass 
     2662     
     2663                        else: 
     2664                            ## for 1D all parameters except orientation 
     2665                            if not item in self.orientation_params_disp: 
     2666                                item[0].SetValue(True) 
     2667                                self.param_toFit.append(item) 
     2668                                try: 
     2669                                    if len(self.values[item[1]]) > 0: 
     2670                                        item[0].SetValue(False) 
     2671                                except: 
     2672                                    pass 
     2673                    else: 
     2674                        item[0].SetValue(False) 
    26622675 
    26632676            else: 
     
    26772690        param2fit = [] 
    26782691        for item in self.param_toFit: 
    2679             if item[0]: 
     2692            if item[0] and item[0].IsShown(): 
    26802693                param2fit.append(item[1]) 
    26812694        self.parent._manager.set_param2fit(self.uid, param2fit) 
     
    26942707                    continue 
    26952708            #Select parameters to fit for list of primary parameters 
    2696             if item[0].GetValue(): 
     2709            if item[0].GetValue() and item[0].IsShown(): 
    26972710                if not (item in self.param_toFit): 
    26982711                    self.param_toFit.append(item) 
     
    27102723                if item in self.orientation_params: 
    27112724                    continue 
    2712             if item[0].GetValue(): 
     2725            if item[0].GetValue() and item[0].IsShown(): 
    27132726                if not (item in self.param_toFit): 
    27142727                    self.param_toFit.append(item) 
     
    27422755        param2fit = [] 
    27432756        for item in self.param_toFit: 
    2744             if item[0]: 
     2757            if item[0] and item[0].IsShown(): 
    27452758                param2fit.append(item[1]) 
    27462759        self.parent._manager.set_param2fit(self.uid, param2fit) 
  • fittingview/src/sans/perspectives/fitting/fitting.py

    rb9dd680 r940aca7  
    4848 
    4949 
    50 if sys.platform.count("darwin") == 0: 
     50if sys.platform == "win32": 
    5151    ON_MAC = False 
    5252else: 
     
    7373        self.weight = None 
    7474        self.fit_panel = None 
     75        self.plot_panel = None 
    7576        # Start with a good default 
    7677        self.elapsed = 0.022 
     
    460461                 
    461462        """ 
     463        self.plot_panel = plotpanel 
    462464        graph = plotpanel.graph 
    463465        fit_option = "Select data for fitting" 
     
    483485                else: 
    484486                    return [] 
     487            return [[fit_option, fit_hint, self._onSelect]] 
    485488        return [] 
    486489 
     
    12811284        added to self.page_finder 
    12821285        """ 
    1283         self.panel = event.GetEventObject() 
     1286        panel = self.plot_panel 
     1287        if panel == None: 
     1288            raise ValueError, "Fitting:_onSelect: NonType panel" 
    12841289        Plugin.on_perspective(self, event=event) 
    1285         self.select_data(self.panel) 
     1290        self.select_data(panel) 
    12861291         
    12871292    def select_data(self, panel): 
    12881293        """ 
    12891294        """ 
    1290         self.panel = panel 
    1291         for plottable in self.panel.graph.plottables: 
     1295        for plottable in panel.graph.plottables: 
    12921296            if plottable.__class__.__name__ in ["Data1D", "Theory1D"]: 
    1293                 data_id = self.panel.graph.selected_plottable 
    1294                 if plottable == self.panel.plots[data_id]: 
     1297                data_id = panel.graph.selected_plottable 
     1298                if plottable == panel.plots[data_id]: 
    12951299                    data = plottable 
    12961300                    self.add_fit_page(data=[data]) 
     
    18801884 
    18811885        if len(title) > 1: 
    1882             new_plot.title = "Model2D for " + data_name 
     1886            new_plot.title = "Model2D for %s "% model.name + data_name 
    18831887        new_plot.name = model.name + " [" + \ 
    1884                                     data_name + "-2D]" 
     1888                                    data_name + "]" 
    18851889        theory_data = deepcopy(new_plot) 
    1886         theory_data.name = "Unknown" 
    18871890         
    18881891        self.page_finder[page_id].set_theory_data(data=theory_data, 
     
    21282131            residuals.xaxis('\\rm{Q} ', 'A^{-1}') 
    21292132            residuals.yaxis('\\rm{Residuals} ', 'normalized') 
     2133        theory_name = str(theory_data.name.split()[0]) 
    21302134        new_plot = residuals 
    2131         new_plot.name = "Residuals for " + str(theory_data.name.split()[0]) + "[" +  str(data.name) +"]" 
     2135        new_plot.name = "Residuals for " + str(theory_name) + "[" +\ 
     2136                        str(data.name) +"]" 
    21322137        ## allow to highlight data when plotted 
    21332138        new_plot.interactive = True 
    21342139        ## when 2 data have the same id override the 1 st plotted 
    2135         new_plot.id = "res" + str(data_copy.id) 
     2140        new_plot.id = "res" + str(data_copy.id) + str(theory_name) 
    21362141        ##group_id specify on which panel to plot this data 
    21372142        group_id = self.page_finder[page_id].get_graph_id() 
  • fittingview/src/sans/perspectives/fitting/simfitpage.py

    rf32d144 r940aca7  
    215215             
    216216        self._update_easy_setup_cb() 
     217        self.Layout() 
    217218        self.Refresh() 
    218219         
     
    664665        ## some model or parameters can be constrained 
    665666        self._show_constraint() 
     667        self.sizer3.Layout() 
     668        self.Layout() 
     669        self.Refresh() 
    666670         
    667671    def _fill_sizer_fit(self): 
  • park_integration/src/sans/fit/ParkFitting.py

    r06e7c26 r940aca7  
    435435            if result is not None: 
    436436                for p in result.parameters: 
    437                     if p.data.name == small_result.data.name: 
     437                    if p.data.name == small_result.data.name and \ 
     438                            p.model.name == small_result.model.name: 
    438439                        small_result.index = m.data.idx 
    439440                        small_result.fitness = result.fitness 
  • plottools/src/danse/common/plottools/SizeDialog.py

    r10bfeb3 r940aca7  
    1010        textbox = wx.BoxSizer(wx.HORIZONTAL) 
    1111        hbox = wx.BoxSizer(wx.HORIZONTAL) 
    12         text1 = "Enter in a custom size (float values > 0 accepted)" 
     12        text1 = "Enter in a custom size (> 0 accepted)" 
    1313        msg = wx.StaticText(self, -1, text1, (30,15), style=wx.ALIGN_CENTRE) 
    1414        msg.SetLabel(text1) 
     
    1616         
    1717        textbox.Add(self.myTxtCtrl, flag=wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 
    18                  border=10, proportion=2) 
     18                 border=10) 
    1919        vbox.Add(msg, flag=wx.ALL, border=10, proportion=1) 
    2020        vbox.Add(textbox, flag=wx.EXPAND|wx.TOP|wx.BOTTOM|wx.ADJUST_MINSIZE, 
    2121                 border=10) 
    22         self.myTxtCtrl.SetValue(str(10)) 
     22        self.myTxtCtrl.SetValue(str(5)) 
    2323         
    2424        okButton = wx.Button(self, wx.ID_OK, 'OK', size=(70, 25)) 
  • sansguiframe/src/sans/guiframe/gui_manager.py

    r6306f2f r940aca7  
    452452            return 
    453453        _, ext = os.path.splitext(name) 
    454         fd = open(file_name, 'w') 
     454        try: 
     455            fd = open(file_name, 'w') 
     456        except: 
     457            # On Permission denied: IOError 
     458            temp_dir = get_user_directory() 
     459            temp_file_name = os.path.join(temp_dir, name) 
     460            fd = open(temp_file_name, 'w') 
    455461        separator = "\t" 
    456462        if ext.lower() == ".csv": 
     
    491497            excel_app.Visible = 1 
    492498        except: 
    493             msg = "Error occured when calling Excel\n" 
    494             msg += "Check that Excel in installed in this machine or \n" 
    495             msg += "Check that %s really exists.\n" % str(file_name) 
     499            msg = "Error occured when calling Excel.\n" 
     500            msg += "Check that Excel installed in this machine or \n" 
     501            msg += "check that %s really exists.\n" % str(file_name) 
    496502            wx.PostEvent(self, StatusEvent(status=msg, 
    497503                                             info="error")) 
     
    10311037        return menu_list 
    10321038         
    1033          
     1039    def get_current_context_menu(self, plotpanel=None): 
     1040        """ 
     1041        Get the context menu items made available  
     1042        by the current plug-in.  
     1043        This function is used by the plotting module 
     1044        """ 
     1045        if plotpanel is None: 
     1046            return 
     1047        menu_list = [] 
     1048        item = self._current_perspective 
     1049        if item != None: 
     1050            menu_list.extend(item.get_context_menu(plotpanel=plotpanel)) 
     1051        return menu_list 
     1052             
    10341053    def on_panel_close(self, event): 
    10351054        """ 
     
    25982617                if has_errors: 
    25992618                    if data.dx != [] and data.dx[i] != None: 
    2600                         out.write("%g  %g  %g  %g\n" % (data.x[i],  
    2601                                                     data.y[i], 
    2602                                                     data.dy[i], 
    2603                                                     data.dx[i])) 
     2619                        if  data.dx[i] != None: 
     2620                            out.write("%g  %g  %g  %g\n" % (data.x[i],  
     2621                                                        data.y[i], 
     2622                                                        data.dy[i], 
     2623                                                        data.dx[i])) 
     2624                        else: 
     2625                            out.write("%g  %g  %g\n" % (data.x[i],  
     2626                                                        data.y[i], 
     2627                                                        data.dy[i])) 
    26042628                    else: 
    26052629                        out.write("%g  %g  %g\n" % (data.x[i],  
  • sansguiframe/src/sans/guiframe/gui_statusbar.py

    r199fdec r940aca7  
    238238        clear the progress bar 
    239239        """ 
    240         flag = False 
    241         if (self.nb_start <= self.nb_stop) or \ 
    242             (self.nb_progress <= self.nb_stop): 
    243             flag = True 
     240        flag = True 
     241        # Why we do this? 
     242        #if (self.nb_start <= self.nb_stop) or \ 
     243        #    (self.nb_progress <= self.nb_stop): 
     244        #    flag = True 
    244245        return flag 
    245246     
  • sansguiframe/src/sans/guiframe/local_perspectives/plotting/AnnulusSlicer.py

    r13382fc7 r940aca7  
    167167 
    168168        new_plot.group_id = "AnnulusPhi" + self.base.data2D.name 
    169         new_plot.id = None 
    170         #new_plot.is_data= True 
     169        new_plot.id = "AnnulusPhi" + self.base.data2D.name 
     170        new_plot.is_data= True 
    171171        new_plot.xtransform = "x" 
    172172        new_plot.ytransform = "y" 
  • sansguiframe/src/sans/guiframe/local_perspectives/plotting/Plotter1D.py

    r78919f45 r940aca7  
    4141DEFAULT_BEAM = 0.005 
    4242BIN_WIDTH = 1 
    43  
     43IS_MAC = (sys.platform == 'darwin') 
    4444 
    4545class ModelPanel1D(PlotPanel, PanelBase): 
     
    174174        # It was found that wx >= 2.9.3 sends an event even if no size changed. 
    175175        # So manually recode the size (=x_size) and compare here. 
     176        # Massy code to work around:< 
     177        if self.parent._mgr != None: 
     178            max_panel = self.parent._mgr.GetPane(self) 
     179            if max_panel.IsMaximized(): 
     180                self.parent._mgr.RestorePane(max_panel) 
     181                max_panel.Maximize() 
    176182        if self.x_size != None: 
    177183            if self.x_size == self.GetSize(): 
     
    286292            try: 
    287293                self._onEVT_FUNC_PROPERTY() 
     294                if IS_MAC: 
     295                    # MAC: forcing to plot 2D avg 
     296                    self.canvas._onDrawIdle() 
    288297            except: 
    289298                msg=" Encountered singular points..." 
     
    409418                if plot != self.plots[self.graph.selected_plottable]: 
    410419                    continue 
     420                 
     421            id = wx.NewId() 
     422            plot_menu.Append(id, "&DataInfo", name) 
     423            wx.EVT_MENU(self, id, self. _onDataShow) 
     424            id = wx.NewId() 
     425            plot_menu.Append(id, "&Save Points as a File", name) 
     426            wx.EVT_MENU(self, id, self._onSave) 
     427            plot_menu.AppendSeparator() 
     428             
    411429            #add menu of other plugins 
    412             item_list = self.parent.get_context_menu(self) 
     430            item_list = self.parent.get_current_context_menu(self) 
    413431               
    414432            if (not item_list == None) and (not len(item_list) == 0): 
     
    425443                        pass 
    426444                plot_menu.AppendSeparator() 
    427                  
    428             id = wx.NewId() 
    429             plot_menu.Append(id, "&DataInfo", name) 
    430             wx.EVT_MENU(self, id, self. _onDataShow) 
    431             id = wx.NewId() 
    432             plot_menu.Append(id, "&Save Points as a File", name) 
    433             wx.EVT_MENU(self, id, self._onSave) 
    434             plot_menu.AppendSeparator() 
     445             
    435446            if self.parent.ClassName.count('wxDialog') == 0:  
    436447                id = wx.NewId() 
  • sansguiframe/src/sans/guiframe/local_perspectives/plotting/Plotter2D.py

    r2778c4f r940aca7  
    321321        if len(self.data2D.detector) == 1:         
    322322             
    323             item_list = self.parent.get_context_menu(self) 
     323            item_list = self.parent.get_current_context_menu(self) 
    324324            if (not item_list == None) and (not len(item_list) == 0) and\ 
    325325                self.data2D.name.split(" ")[0] != 'Residuals':   
     
    631631            new_plot.yaxis("\\rm{Intensity} ", "cm^{-1}") 
    632632 
    633         new_plot.group_id = "Circ avg " + self.data2D.name 
     633        new_plot.group_id = "2daverage" + self.data2D.name 
    634634        new_plot.id = "Circ avg " + self.data2D.name 
    635635        new_plot.is_data = True 
  • sansguiframe/src/sans/guiframe/local_perspectives/plotting/SectorSlicer.py

    r789ffc6 r940aca7  
    183183            new_plot.yaxis("\\rm{Residuals} ", "/") 
    184184 
    185         new_plot.group_id = "SectorQ" + self.base.data2D.name 
    186         new_plot.id = None 
     185        new_plot.group_id = "2daverage" + self.base.data2D.name 
     186        new_plot.id = "SectorQ" + self.base.data2D.name 
    187187        new_plot.is_data = True 
    188188        self.base.parent.update_theory(data_id=data, \ 
  • sansguiframe/src/sans/guiframe/local_perspectives/plotting/SlicerParameters.py

    r8c347a6 r940aca7  
    8787                    ctl.SetValue(format_number(str(params[item]))) 
    8888                    self.Bind(wx.EVT_TEXT_ENTER, self.onTextEnter) 
    89                     ctl.Bind(wx.EVT_KILL_FOCUS, self.onTextEnter) 
    9089                    self.parameters.append([item, ctl]) 
    9190                    self.bck.Add(ctl, (iy, ix), (1, 1),  
  • sansguiframe/src/sans/guiframe/local_perspectives/plotting/boxSlicer.py

    r13382fc7 r940aca7  
    198198            new_plot.yaxis("\\rm{Residuals} ", "/") 
    199199             
    200         new_plot.group_id = str(self.averager.__name__) + self.base.data2D.name 
    201         #new_plot.id = str(self.averager.__name__) 
    202         #new_plot.is_data= True 
     200        new_plot.group_id = "2daverage" + self.base.data2D.name 
     201        new_plot.id = (self.averager.__name__) + self.base.data2D.name 
     202        new_plot.is_data= True 
    203203        self.base.parent.update_theory(data_id=self.base.data2D.id, \ 
    204204                                       theory=new_plot) 
  • sansguiframe/src/sans/guiframe/local_perspectives/plotting/plotting.py

    r48832ac r940aca7  
    276276         
    277277        """ 
     278        action_check = False 
    278279        if hasattr(event, 'action'): 
    279             group_id = event.group_id 
    280             if group_id in self.plot_panels.keys(): 
    281                 #remove data from panel 
    282                 if event.action.lower().strip() == 'remove': 
    283                     id = event.id 
    284                     return self.remove_plot(group_id, id) 
    285                 if event.action.lower().strip() == 'hide': 
    286                     return self.hide_panel(group_id) 
    287                 if event.action.lower().strip() == 'delete': 
    288                     panel = self.plot_panels[group_id] 
    289                     uid = panel.uid 
    290                     return self.parent.delete_panel(uid) 
    291                 if event.action.lower().strip() == "clear": 
    292                     return self.clear_panel_by_id(group_id) 
     280            action_string = event.action.lower().strip() 
     281            if action_string == 'check': 
     282                action_check = True 
     283            else: 
     284                group_id = event.group_id 
     285                if group_id in self.plot_panels.keys(): 
     286                    #remove data from panel 
     287                    if action_string == 'remove': 
     288                        id = event.id 
     289                        return self.remove_plot(group_id, id) 
     290                    if action_string == 'hide': 
     291                        return self.hide_panel(group_id) 
     292                    if action_string == 'delete': 
     293                        panel = self.plot_panels[group_id] 
     294                        uid = panel.uid 
     295                        return self.parent.delete_panel(uid) 
     296                    if action_string == "clear": 
     297                        return self.clear_panel_by_id(group_id) 
     298                     
    293299        if not hasattr(event, 'plot'):     
    294300            return 
    295301        title = None 
    296302        if hasattr(event, 'title'): 
    297             title = 'Graph'#event.title 
    298                  
     303            title = 'Graph'#event.title       
    299304        data = event.plot 
    300         group_id = data.group_id 
    301              
    302         if group_id in self.plot_panels.keys(): 
     305        group_id = data.group_id     
     306        if group_id in self.plot_panels.keys(): 
     307            if action_check: 
     308                # Check if the plot already exist. if it does, do nothing. 
     309                if data.id in self.plot_panels[group_id].plots.keys(): 
     310                    return  
    303311            #update a panel graph  
    304312            panel = self.plot_panels[group_id] 
     
    309317                new_panel = self.create_1d_panel(data, group_id) 
    310318            else: 
     319                # Need to make the group_id consistent with 1D thus no if below 
     320                if len(self.plot_panels.values()) > 0: 
     321                    for p_group_id in self.plot_panels.keys(): 
     322                        p_plot = self.plot_panels[p_group_id] 
     323                        if data.id in p_plot.plots.keys(): 
     324                            p_plot.plots[data.id] = data 
     325                            self.plot_panels[group_id] = p_plot 
     326                            if group_id != p_group_id: 
     327                                del self.plot_panels[p_group_id] 
     328                                if p_group_id in data.list_group_id: 
     329                                    data.list_group_id.remove(p_group_id) 
     330                                if group_id not in data.list_group_id: 
     331                                    data.list_group_id.append(group_id) 
     332                            p_plot.group_id = group_id 
     333                            return 
     334                 
    311335                new_panel = self.create_2d_panel(data, group_id) 
    312             self.create_panel_helper(new_panel, data, group_id, title) 
    313              
     336            self.create_panel_helper(new_panel, data, group_id, title)  
    314337        return 
    315338 
  • sansguiframe/src/sans/guiframe/local_perspectives/plotting/profile_dialog.py

    r2d443fd r940aca7  
    5353            self.SetTitle("Scattering Length Density Profile") 
    5454            self.parent = parent 
     55            self._mgr = None 
    5556            self.data = data 
    5657            self.str = self.data.__str__() 
     
    7576            self.newplot.dy = None 
    7677            self.newplot.name = 'SLD' 
     78            self.newplot.id = self.newplot.name 
    7779            self.plotpanel.add_image(self.newplot)  
    7880            self.plotpanel.subplot.set_ylim(min(data_plot.y) - _Y_OFF ,  
     
    8183                                                max(data_plot.x) + _X_OFF) 
    8284            #self.Centre() 
     85            self.plotpanel.resizing = False 
     86            self.plotpanel.canvas.set_resizing(self.plotpanel.resizing) 
     87            self.plotpanel.subplot.figure.canvas.draw_idle() 
    8388            self.Layout() 
    8489 
     
    175180        self.parent.parent.parent.on_change_caption(name, old_caption, new_caption) 
    176181     
     182    def disable_app_menu(self, panel): 
     183        """ 
     184        Disable menu bar 
     185        """ 
     186        # Not implemented! 
     187        return 
    177188     
    178189class SLDplotpanel(PlotPanel): 
     
    203214        self.yaxis_label = '' 
    204215        self.yaxis_unit = '' 
     216        self.resizing = True 
    205217         
    206218    def add_image(self, plot): 
     
    208220        Add image(Theory1D) 
    209221        """ 
    210         self.plots[plot.name] = plot 
    211         self.plots[plot.name].is_data = False 
    212         #init graph 
    213         #self.gaph = Graph() 
     222        self.plots[plot.id] = plot 
     223        self.plots[plot.id].is_data = True 
    214224        #add plot 
    215225        self.graph.add(plot) 
     
    222232        self.yaxis_unit = '10^{-6}A^{-2}' 
    223233        self.graph.yaxis(self.yaxis_label, self.yaxis_unit) 
     234        #self.subplot.figure.canvas.draw_idle() 
     235        # For latter scale changes  
     236        self.plots[plot.id].xaxis('\\rm{%s} '% x1_label, 'A') 
     237        self.plots[plot.id].yaxis('\\rm{SLD} ', '10^{-6}A^{-2}') 
    224238        #draw 
    225239        self.graph.render(self) 
    226         self.subplot.figure.canvas.draw_idle() 
    227                  
    228         # For latter scale changes  
    229         self.plots[plot.name].xaxis('\\rm{%s} '% x1_label, 'A') 
    230         self.plots[plot.name].yaxis('\\rm{SLD} ', '10^{-6}A^{-2}') 
    231240         
    232241    def on_set_focus(self, event): 
     
    257266        """ 
    258267        pass 
    259      
     268                            
    260269    def _onSave(self, evt): 
    261270        """ 
     
    265274         
    266275        """ 
    267         
    268         path = None 
    269         wildcard = "Text files (*.txt)|*.txt|"\ 
    270                     "CanSAS 1D files(*.xml)|*.xml"  
    271         default_name = "sld_profile" 
     276        menu = evt.GetEventObject() 
     277        id = evt.GetId() 
     278        self.set_selected_from_menu(menu, id) 
     279        data = self.plots[self.graph.selected_plottable] 
     280        default_name = data.label 
     281        if default_name.count('.') > 0: 
     282            default_name = default_name.split('.')[0] 
     283        default_name += "_out" 
    272284        if self.parent != None: 
    273             self._default_save_location = self.parent.parent._default_save_location 
    274         dlg = wx.FileDialog(self, "Choose a file", 
    275                             self._default_save_location, 
    276                             default_name, wildcard , wx.SAVE) 
    277         
    278         if dlg.ShowModal() == wx.ID_OK: 
    279             path = dlg.GetPath() 
    280             # ext_num = 0 for .txt, ext_num = 1 for .xml 
    281             # This is MAC Fix 
    282             ext_num = dlg.GetFilterIndex() 
    283             if ext_num == 0: 
    284                 format = '.txt' 
    285             else: 
    286                 format = '.xml' 
    287             path = os.path.splitext(path)[0] + format 
    288             mypath = os.path.basename(path) 
    289              
    290             #TODO: This is bad design. The DataLoader is designed  
    291             #to recognize extensions. 
    292             # It should be a simple matter of calling the . 
    293             #save(file, data, '.xml') method 
    294             # of the sans.dataloader.loader.Loader class. 
    295             from sans.dataloader.loader import  Loader 
    296             #Instantiate a loader  
    297             loader = Loader()  
    298             data = self.parent.data 
    299             format = ".txt" 
    300             if os.path.splitext(mypath)[1].lower() == format: 
    301                 # Make sure the ext included in the file name 
    302                 # especially on MAC 
    303                 fName = os.path.splitext(path)[0] + format 
    304                 self._onsaveTXT(fName) 
    305             format = ".xml" 
    306             if os.path.splitext(mypath)[1].lower() == format: 
    307                 # Make sure the ext included in the file name 
    308                 # especially on MAC 
    309                 fName = os.path.splitext(path)[0] + format 
    310                 loader.save(fName, data, format) 
    311             try: 
    312                 self._default_save_location = os.path.dirname(path) 
    313                 self.parent.parent._default_save_location = self._default_save_location 
    314             except: 
    315                 pass     
    316         dlg.Destroy() 
    317           
     285            # What an ancestor! 
     286            fit_panel = self.parent.parent.parent 
     287            fit_panel.parent.save_data1d(data, default_name) 
     288              
    318289class ViewerFrame(wx.Frame): 
    319290    """ 
  • sansguiframe/src/sans/guiframe/media/Graph_help.html

    rd874092 r940aca7  
    77<li><a href="#reset">Reset Graph</a></li> 
    88<li><a href="#hide">Hide/Show/Delete Graph</a></li> 
     9<li><a href="#info">Data Info</a></li> 
    910<li><a href="#save">Save plot Image</a></li> 
    1011<li><a href="#savedata">Save Data</a></li> 
    1112<li><a href="#drag">Drag plot</a></li> 
    12 <li><a href="#select">Select Data</a></li> 
    1313<li><a href="#zoom">Zoom In/Out</a></li> 
    1414<li><a href="#remove">Remove Data</a></li> 
     
    3333<h5><a name="hide">Hide/Show/Delete Graph</a></h5> 
    3434<p> 
    35         To Hide, click the Hide (closed eye) button in the tool bar.<br> 
     35        To Hide, click the Hide (bar) button in the tool bar.<br> 
    3636        To Show, select the the 'Show' menuitem in the 'Graph' menu in the menu bar.<br> 
    3737        To Delete, click the 'x' button in the title bar.<br> 
     
    4343        Right click on plot. Context menu will pop-up select save image [file name].A dialog 
    4444        window opens and write a the name of the file to save and click on <b>Save Image.</b> 
     45</p> 
     46 
     47<h5><a name="info"> Data Info</a></h5> 
     48<p> 
     49        From the context menu, select 'Data Info' to see the data information dialog panel. 
    4550</p> 
    4651 
  • sansmodels/src/libigor/libStructureFactor.c

    r67424cd r940aca7  
    77#include "StandardHeaders.h"                    // Include ANSI headers, Mac headers, IgorXOP.h, XOP.h and XOPSupport.h 
    88#include "libStructureFactor.h" 
    9  
    10 static double gMSAWave[17]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}; 
    119 
    1210//Hard Sphere Structure Factor 
     
    177175HayterPenfoldMSA(double dp[], double q) 
    178176{ 
     177  double gMSAWave[17]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}; 
    179178        double Elcharge=1.602189e-19;           // electron charge in Coulombs (C) 
    180179        double kB=1.380662e-23;                         // Boltzman constant in J/K 
     
    231230         
    232231        ierr=0; 
    233         ierr=sqcoef(ierr); 
     232        ierr=sqcoef(ierr, gMSAWave); 
    234233        if (ierr>=0) { 
    235                 SofQ=sqhcal(Qdiam); 
     234                SofQ=sqhcal(Qdiam, gMSAWave); 
    236235        }else{ 
    237236        //SofQ=NaN; 
     
    269268// 
    270269int 
    271 sqcoef(int ir) 
     270sqcoef(int ir, double gMSAWave[]) 
    272271{        
    273272        int itm=40,ix,ig,ii; 
    274273        double acc=5.0E-6,del,e1,e2,f1,f2; 
    275          
     274 
    276275        //      WAVE gMSAWave = $"root:HayPenMSA:gMSAWave" 
    277276        f1=0;           //these were never properly initialized... 
     
    284283                gMSAWave[16]=gMSAWave[4]; 
    285284                ix=1; 
    286                 ir = sqfun(ix,ir); 
     285                ir = sqfun(ix,ir,gMSAWave); 
    287286                gMSAWave[14]=gMSAWave[15]; 
    288287                gMSAWave[4]=gMSAWave[16]; 
     
    310309                        gMSAWave[16]=e1; 
    311310                        ix=2; 
    312                         ir = sqfun(ix,ir); 
     311                        ir = sqfun(ix,ir,gMSAWave); 
    313312                        f1=gMSAWave[15]; 
    314313                        e1=gMSAWave[16]; 
     
    317316                        gMSAWave[16]=e2; 
    318317                        ix=2; 
    319                         ir = sqfun(ix,ir); 
     318                        ir = sqfun(ix,ir,gMSAWave); 
    320319                        f2=gMSAWave[15]; 
    321320                        e2=gMSAWave[16]; 
     
    327326                gMSAWave[16]=e2; 
    328327                ix=4; 
    329                 ir = sqfun(ix,ir); 
     328                ir = sqfun(ix,ir,gMSAWave); 
    330329                gMSAWave[14]=gMSAWave[15]; 
    331330                e2=gMSAWave[16]; 
     
    338337        gMSAWave[16]=gMSAWave[4]; 
    339338        ix=3; 
    340         ir = sqfun(ix,ir); 
     339        ir = sqfun(ix,ir,gMSAWave); 
    341340        gMSAWave[14]=gMSAWave[15]; 
    342341        gMSAWave[4]=gMSAWave[16]; 
     
    349348 
    350349int 
    351 sqfun(int ix, int ir) 
     350sqfun(int ix, int ir, double gMSAWave[]) 
    352351{        
    353352        double acc=1.0e-6; 
     
    712711 
    713712double 
    714 sqhcal(double qq) 
     713sqhcal(double qq, double gMSAWave[]) 
    715714{        
    716715    double SofQ,etaz,akz,gekz,e24,x1,x2,ck,sk,ak2,qk,q2k,qk2,qk3,qqk,sink,cosk,asink,qcosk,aqk,inter;            
    717716        //      WAVE gMSAWave = $"root:HayPenMSA:gMSAWave" 
    718          
     717 
    719718        etaz = gMSAWave[10]; 
    720719        akz =  gMSAWave[12]; 
  • sansmodels/src/libigor/libStructureFactor.h

    r67424cd r940aca7  
    1010 
    1111//function prototypes 
    12 double sqhcal(double qq); 
    13 int sqfun(int ix, int ir); 
    14 int sqcoef(int ir); 
     12double sqhcal(double qq, double gMSAWave[]); 
     13int sqfun(int ix, int ir, double gMSAWave[]); 
     14int sqcoef(int ir, double gMSAWave[]); 
  • sansmodels/src/sans/models/media/model_functions.html

    r57eab9e r940aca7  
    57495749<p class="MsoNormal">The contrast is defined as SLD(core) 
    57505750– SLD(shell) or 
    5751 SLD(shell – solvent). In the parameters, equat_core = equatorial radius 
    5752 of the 
    5753 core, polar_core = polar radius of the core, equat_shell = r<sub>min</sub> 
    5754 (or 
    5755 equatorial radius of the shell), and polar_shell = = r<sub>maj</sub> 
    5756 (or polar radius 
    5757 of the shell).</p> 
     5751SLD(shell – solvent). In the parameters, equat_core = equatorial core radius,  
     5752polar_core = polar core radius, equat_shell = r<sub>min</sub> 
     5753(or equatorial outer radius), and polar_shell = = r<sub>maj</sub> 
     5754(or polar outer radius).</p> 
    57585755<p class="MsoNormal">&nbsp;</p> 
    57595756<p class="MsoNormal">For P*S: The 2<sup>nd</sup> 
  • sansview/README.txt

    rfa00944 r940aca7  
    9494                        - run 'python sansview.py' under the 'sansview' folder. 
    9595                - The following modules are required: 
    96                         * matplotlib >= 0.99.0(WIN), 0.99.1.1(MAC) 
    97                         * numpy >= 1.4.1 
    98                         * scipy >= 0.7.2 
    99                         * wxpython 2.8.11 unicode(WIN), 2.8.12.0(MAC) < 2.9.xx 
    100                         * lxml >= 2.2.2 
    101                         * multiprocessing-2.6.2(X) 
    102                         * comtypes (for PDF window)(WIN) 
    103                         * pywin32 (to read ms office)(WIN) 
    104                         * PIL (Python Image Library) 
    105                         * Pyparsing (apply for periodictable and bundling) 
    106                         * periodictable = 1.3.0 (using 'easy_install periodictable') 
    107                         * pisa (html to pdf : MAC) 
    108                         * MinGW/Cygwin (for Windows) or other GNU compiler (gcc) 
    109                         * Optional: setuptools, svn, Innosetup, py2exe(WIN),and/or py2app(MAC) to build App from the source. 
     96                        - wxPython 2.8.12.1 
     97                        - matplotlib 1.1.0  
     98                        - SciPy 0.10.1 
     99                        - py2app (MAC) 
     100 
     101                        (The following three are easily installed using easy_install) 
     102                        - lxml 2.3.0 
     103                        - numpy 1.6.1 
     104                        - periodictable 1.3.0 
     105 
     106                        (The following are additional dependencies for Windows) 
     107                        - comtypes 0.6.2 
     108                        - pywin32 build 217 
     109                        - pisa 3.0.27 (NOT 3.0.33) 
     110                        - html5lib 0.95 
     111                        - reportlab 2.5 
     112                        - pyparsing 1.5.5 
     113                        - PIL 1.1.7 
     114                        - setuptools 0.6c11 
     115                        - py2exe 0.6.9 (WIN) 
     116                        - svn 
     117                        - MinGW w/ gcc version 4.6.1 (WIN) 
     118                        - Innosetup (WIN). 
     119 
     120                        (On Windows, the following site has all the dependencies nicely packaged) 
     121                        http://www.lfd.uci.edu/~gohlke/pythonlibs/ 
    110122 
    111123 
Note: See TracChangeset for help on using the changeset viewer.