Changeset 5c4b674 in sasview


Ignore:
Timestamp:
Mar 2, 2011 4:35:08 PM (13 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
883e5f5
Parents:
22b3fe1
Message:

working on data panel

Location:
guiframe
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • guiframe/dataFitting.py

    r8a7d922 r5c4b674  
    3333        self.ytransform = None 
    3434        self.title = "" 
    35      
     35        self.scale = None 
     36         
    3637    def copy_from_datainfo(self, data1d): 
    3738        """ 
     
    107108        self.ytransform = None 
    108109        self.title = "" 
     110        self.scale = None 
    109111     
    110112    def copy_from_datainfo(self, data1d): 
     
    176178                            q_data=q_data, mask=mask) 
    177179        self.id = None 
     180        self.group_id = [] 
     181        self.is_data = True 
    178182        self.path = None 
     183        self.xtransform = None 
     184        self.ytransform = None 
    179185        self.title = "" 
    180186        self.scale = None 
    181         self.group_id = [] 
    182187         
    183188    def copy_from_datainfo(self, data2d): 
  • guiframe/data_manager.py

    ra07e72f r5c4b674  
    117117                msg += "" 
    118118                logging.info(msg) 
    119             data_state = DataState(data) 
     119                self.stored_data[data.id].data = data 
     120                data_state = self.stored_data[data.id] 
     121            else: 
     122                data_state = DataState(data) 
     123                self.stored_data[data.id] = data_state 
    120124            self._selected_data[data.id] = data_state 
    121             self.stored_data[data.id] = data_state 
    122125       
    123126    def set_auto_plot(self, flag=False): 
  • guiframe/data_panel.py

    rea5692d r5c4b674  
    2121 
    2222PANEL_WIDTH = 200 
    23  
     23#PANEL_HEIGHT = 560 
     24PANEL_HEIGHT = 800 
    2425class DataTreeCtrl(CT.CustomTreeCtrl): 
    2526    """ 
     
    4748    #ALWAYS_ON = True 
    4849    def __init__(self, parent, list=[],list_of_perspective=[], 
    49                  size=(PANEL_WIDTH,560), manager=None, *args, **kwds): 
     50                 size=(PANEL_WIDTH,PANEL_HEIGHT), manager=None, *args, **kwds): 
    5051        kwds['size']= size 
    5152        ScrolledPanel.__init__(self, parent=parent, *args, **kwds) 
     
    6869        self.define_panel_structure() 
    6970        self.layout_selection() 
    70         self.layout_list() 
     71        self.layout_data_list() 
     72        self.layout_theory_list() 
    7173        self.layout_button() 
    7274        self.layout_batch() 
     
    7981        self.vbox  = wx.BoxSizer(wx.VERTICAL) 
    8082        self.sizer1 = wx.BoxSizer(wx.VERTICAL) 
    81         self.sizer1.SetMinSize((w/12, h/2)) 
     83        self.sizer1.SetMinSize((w/12, h*1/5)) 
     84        self.sizer6 = wx.BoxSizer(wx.VERTICAL) 
     85        self.sizer6.SetMinSize((w/12, h*1/5)) 
    8286        self.sizer2 = wx.BoxSizer(wx.VERTICAL) 
    8387        self.sizer3 = wx.GridBagSizer(5,5) 
     
    8791        self.vbox.Add(self.sizer5, 0,wx.EXPAND|wx.ALL,10) 
    8892        self.vbox.Add(self.sizer1, 0,wx.EXPAND|wx.ALL,0) 
     93        self.vbox.Add(self.sizer6, 0,wx.EXPAND|wx.ALL,0) 
    8994        self.vbox.Add(self.sizer2, 0,wx.EXPAND|wx.ALL,10) 
    9095        self.vbox.Add(self.sizer3, 0,wx.EXPAND|wx.ALL,10) 
     
    269274                            (self.rb_batch_mode,0, wx.ALL,5)]) 
    270275       
    271     def layout_list(self): 
     276    def layout_data_list(self): 
    272277        """ 
    273278        Add a listcrtl in the panel 
     
    280285        self.sizer1.Add(label, 0, wx.LEFT, 10) 
    281286        self.sizer1.Add(self.tree_ctrl,1, wx.EXPAND|wx.ALL, 10) 
     287         
     288    def layout_theory_list(self): 
     289        """ 
     290        Add a listcrtl in the panel 
     291        """ 
     292        self.tree_ctrl_theory = DataTreeCtrl(parent=self) 
     293        self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_CHECKED, self.on_check_item) 
     294        self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_RIGHT_CLICK, self.on_right_click) 
     295        label = wx.StaticText(self, -1, "CREATED DATA") 
     296        label.SetForegroundColour('blue') 
     297        self.sizer6.Add(label, 0, wx.LEFT, 10) 
     298        self.sizer6.Add(self.tree_ctrl_theory,1, wx.EXPAND|wx.ALL, 10) 
    282299 
    283300    def on_right_click(self, event): 
     
    332349            path = dstate.get_path()  
    333350            theory_list = dstate.get_theory() 
    334             theory = None 
    335             if  theory_list: 
    336                 theory = theory_list[len(theory_list)-1] 
    337351            data_child = None 
    338             for item in self.list_cb_data: 
    339                 if self.tree_ctrl.GetItemText(item) == data_name: 
    340                     data_child = item 
    341                     for process in data.process: 
    342                         theory_child = self.tree_ctrl.FindItem(data_child, 
    343                                                         "Available Theories"), 
    344                         if theory is not None: 
    345                             av_theory_child =self.tree_ctrl.AppendItem(theory_child, 
    346                                                 theory.name,ct_type=1, data=theory.id) 
    347                             self.list_cb_theory.append(av_theory_child) 
    348                             av_theory_child_info =self.tree_ctrl.AppendItem(av_theory_child, 
    349                                                      'info') 
    350                             for process in theory.process: 
    351                                 info_time_child =self.tree_ctrl.AppendItem(av_theory_child_info, 
    352                                          process.__str__()) 
    353                     
    354                     break 
     352            if theory_list: 
     353                for theory_id,theory in theory_list: 
     354                    for item in self.list_cb_data: 
     355                        data_id, data_class = self.tree_ctrl.GetItemPyData(item)  
     356                        if data_id == data.id: 
     357                            data_child = item 
     358                            for process in data.process: 
     359                                theory_child = self.tree_ctrl.FindItem(data_child, 
     360                                                                "Available Theories"), 
     361                                if theory is not None: 
     362                                    av_theory_child =self.tree_ctrl.AppendItem(theory_child, 
     363                                            theory.name,ct_type=1,  
     364                                            data=(theory_id, theory)) 
     365                                    self.list_cb_theory.append(av_theory_child) 
     366                                    av_theory_child_info =self.tree_ctrl.AppendItem(av_theory_child, 
     367                                                             'info') 
     368                                    for process in theory.process: 
     369                                        info_time_child = self.tree_ctrl.AppendItem(av_theory_child_info, 
     370                                                 process.__str__()) 
     371                            
     372                        break 
    355373            if data_child is None: 
    356                 data_child =self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, 
    357                                                    data_name,ct_type=1, data=(data.id, data_class)) 
     374                data_child = self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, 
     375                                            data_name, ct_type=1,  
     376                                            data=(data.id, data_class)) 
    358377                cb_data = self.tree_ctrl.GetFirstChild(self.tree_ctrl.root)  
    359378                item, id = cb_data 
     
    466485    ALWAYS_ON = True 
    467486     
    468     def __init__(self, parent=None, owner=None, manager=None,size=(600, 600), 
     487    def __init__(self, parent=None, owner=None, manager=None,size=(600, 800), 
    469488                         list_of_perspective=[],list=[], *args, **kwds): 
    470489        #kwds['size'] = size 
  • guiframe/data_state.py

    r584c4c4 r5c4b674  
    2323        self.name = "" 
    2424        self.path = None 
    25         self.theory_list = [] 
     25        self.theory_list = {} 
    2626        self.state_list = [] 
    2727        self.message = "" 
     
    5252        """ 
    5353        """ 
    54         self.theory_list.append(theory) 
     54        self.theory_list[theory.id] = theory 
    5555         
    5656    def get_theory(self): 
  • guiframe/local_perspectives/plotting/plotting.py

    ra07e72f r5c4b674  
    7575        """show plug-in panel""" 
    7676        pass 
     77     
     78    #def _on_plot_event(self, event): 
     79    #     return profile(self.tested_on_plot_event, event) 
    7780     
    7881    def _on_plot_event(self, event): 
     
    162165             
    163166        return 
     167 
     168def profile(fn, *args, **kw): 
     169    import cProfile, pstats, os 
     170    global call_result 
     171    def call(): 
     172        global call_result 
     173        call_result = fn(*args, **kw) 
     174    cProfile.runctx('call()', dict(call=call), {}, 'profile.txt') 
     175    stats = pstats.Stats('profile.txt') 
     176    stats.sort_stats('time') 
     177    #stats.sort_stats('calls') 
     178    stats.print_stats() 
     179    #os.unlink('profile.out') 
     180    return call_result 
     181 
    164182    
  • guiframe/state_reader.py

    ra07e72f r5c4b674  
    3939from lxml import etree 
    4040import xml.dom.minidom 
    41 from DataLoader.readers.cansas_reader import Reader as CansasReader 
     41 
    4242has_converter = True 
    4343try: 
     
    4646    has_converter = False 
    4747 
    48 CANSAS_NS = "cansas1d/1.0" 
     48STATE_NS = "State/1.0" 
    4949 
    5050def write_node(doc, parent, name, value, attr={}): 
     
    7676    :return: Element, or None 
    7777    """ 
    78     nodes = node.xpath(location, namespaces={'ns': CANSAS_NS}) 
     78    nodes = node.xpath(location, namespaces={'ns': STATE_NODE}) 
    7979     
    8080    if len(nodes)>0: 
     
    9090    :param node: node to start at 
    9191    """ 
    92     nodes = node.xpath(location, namespaces={'ns': CANSAS_NS}) 
     92    nodes = node.xpath(location, namespaces={'ns': STATE_NODE}) 
    9393     
    9494    value = None 
     
    9999        except: 
    100100            # Could not pass, skip and return None 
    101             msg = "cansas_reader.get_float: could not " 
     101            msg = "state_reader.get_float: could not " 
    102102            msg += " convert '%s' to float" % nodes[0].text 
    103103            logging.error(msg) 
     
    107107 
    108108             
    109 class Reader1D(CansasReader): 
     109class Reader1D: 
    110110    """ 
    111     Class to load cansas 1D XML files 
     111    read state of a plugin  and available data  
    112112     
    113113    :Dependencies: 
     
    125125     
    126126    def __init__(self): 
    127         CansasReader.__init__(self) 
    128127        ## List of errors 
    129128        self.errors = [] 
     
    155154                 
    156155                entry_list = root.xpath('/ns:SASroot/ns:SASentry', 
    157                                          namespaces={'ns': CANSAS_NS}) 
     156                                         namespaces={'ns': STATE_NODE}) 
    158157                 
    159158                for entry in entry_list: 
     
    196195         
    197196        # Look up run number    
    198         nodes = dom.xpath('ns:Run', namespaces={'ns': CANSAS_NS}) 
     197        nodes = dom.xpath('ns:Run', namespaces={'ns': STATE_NODE}) 
    199198        for item in nodes:     
    200199            if item.text is not None: 
     
    210209 
    211210        # Notes 
    212         note_list = dom.xpath('ns:SASnote', namespaces={'ns': CANSAS_NS}) 
     211        note_list = dom.xpath('ns:SASnote', namespaces={'ns': STATE_NODE}) 
    213212        for note in note_list: 
    214213            try: 
     
    218217                        data_info.notes.append(note_value) 
    219218            except: 
    220                 err_mess = "cansas_reader.read: error processing" 
     219                err_mess = "state_reader.read: error processing" 
    221220                err_mess += " entry notes\n  %s" % sys.exc_value 
    222221                self.errors.append(err_mess) 
     
    238237         
    239238        nodes = dom.xpath('ns:SASsample/ns:details',  
    240                           namespaces={'ns': CANSAS_NS}) 
     239                          namespaces={'ns': STATE_NODE}) 
    241240        for item in nodes: 
    242241            try: 
     
    246245                        data_info.sample.details.append(detail_value) 
    247246            except: 
    248                 err_mess = "cansas_reader.read: error processing " 
     247                err_mess = "state_reader.read: error processing " 
    249248                err_mess += " sample details\n  %s" % sys.exc_value 
    250249                self.errors.append(err_mess) 
     
    299298        # Collimation info ################### 
    300299        nodes = dom.xpath('ns:SASinstrument/ns:SAScollimation',  
    301                           namespaces={'ns': CANSAS_NS}) 
     300                          namespaces={'ns': STATE_NODE}) 
    302301        for item in nodes: 
    303302            collim = Collimation() 
     
    307306             
    308307            # Look for apertures 
    309             apert_list = item.xpath('ns:aperture', namespaces={'ns': CANSAS_NS}) 
     308            apert_list = item.xpath('ns:aperture', namespaces={'ns': STATE_NODE}) 
    310309            for apert in apert_list: 
    311310                aperture =  Aperture() 
     
    331330        # Detector info ###################### 
    332331        nodes = dom.xpath('ns:SASinstrument/ns:SASdetector', 
    333                            namespaces={'ns': CANSAS_NS}) 
     332                           namespaces={'ns': STATE_NODE}) 
    334333        for item in nodes: 
    335334             
     
    373372 
    374373        # Processes info ###################### 
    375         nodes = dom.xpath('ns:SASprocess', namespaces={'ns': CANSAS_NS}) 
     374        nodes = dom.xpath('ns:SASprocess', namespaces={'ns': STATE_NODE}) 
    376375        for item in nodes: 
    377376            process = Process() 
     
    380379            self._store_content('ns:description', item, 'description', process) 
    381380             
    382             term_list = item.xpath('ns:term', namespaces={'ns': CANSAS_NS}) 
     381            term_list = item.xpath('ns:term', namespaces={'ns': STATE_NODE}) 
    383382            for term in term_list: 
    384383                try: 
     
    390389                        process.term.append(term_attr) 
    391390                except: 
    392                     err_mess = "cansas_reader.read: error processing " 
     391                    err_mess = "state_reader.read: error processing " 
    393392                    err_mess += " process term\n  %s" % sys.exc_value 
    394393                    self.errors.append(err_mess) 
     
    396395             
    397396            note_list = item.xpath('ns:SASprocessnote',  
    398                                    namespaces={'ns': CANSAS_NS}) 
     397                                   namespaces={'ns': STATE_NODE}) 
    399398            for note in note_list: 
    400399                if note.text is not None: 
     
    405404             
    406405        # Data info ###################### 
    407         nodes = dom.xpath('ns:SASdata', namespaces={'ns': CANSAS_NS}) 
     406        nodes = dom.xpath('ns:SASdata', namespaces={'ns': STATE_NODE}) 
    408407        if len(nodes) > 1: 
    409408            msg = "CanSAS reader is not compatible with multiple" 
     
    411410            raise RuntimeError, msg 
    412411         
    413         nodes = dom.xpath('ns:SASdata/ns:Idata', namespaces={'ns': CANSAS_NS}) 
     412        nodes = dom.xpath('ns:SASdata/ns:Idata', namespaces={'ns': STATE_NODE}) 
    414413 
    415414        x  = numpy.zeros(0) 
     
    634633                write_node(doc, pt, "Idev", datainfo.dy[i], 
    635634                            {'unit':datainfo.y_unit}) 
    636  
    637          
     635        #data gui info 
     636        gui_info = doc.createElement("DataInfoGui") 
     637         
     638        write_node(doc, gui_info, "group_id", 'group_id') 
     639        for item in datainfo.group_id: 
     640            write_node(doc, gui_info, "group_id", str(item)) 
     641        write_node(doc, gui_info, "name", datainfo.name) 
     642        write_node(doc, gui_info, "id", datainfo.id) 
     643        write_node(doc, gui_info, "group_id", datainfo.groud_id) 
     644        write_node(doc, gui_info, "name", datainfo.name) 
     645        write_node(doc, gui_info, "is_data", datainfo.is_data) 
     646        write_node(doc, gui_info, "xtransform", datainfo.xtransform) 
     647        write_node(doc, gui_info, "scale", datainfo.scale) 
     648        write_node(doc, gui_info, "ytransform", datainfo.ytransform) 
     649        write_node(doc, gui_info, "path", datainfo.path) 
     650        node.appendChild(gui_info) 
    638651        # Sample info 
    639652        sample = doc.createElement("SASsample") 
     
    922935            
    923936 
    924 class Reader2D(CansasReader): 
     937class Reader2D: 
    925938    """ 
    926     Class to load a .fitv fitting file 
     939    Class to load a basic guiframe state 
    927940    """ 
    928941    ## File type 
     
    11541167        return doc, entry_node 
    11551168    
    1156     def _parse_state(self, entry): 
     1169    def _parse_state(self, entry, NODE_NAME= 'state'): 
    11571170        """ 
    11581171        Read a fit result from an XML node 
     
    11661179        # Locate the P(r) node 
    11671180        try: 
    1168             nodes = entry.xpath('ns:%s' % FITTING_NODE_NAME, namespaces={'ns': CANSAS_NS}) 
     1181            nodes = entry.xpath('ns:%s' % NODE_NAME, namespaces={'ns': STATE_NODE}) 
    11691182            if nodes !=[]: 
    11701183                # Create an empty state 
     
    11871200         
    11881201        """ 
    1189         node = dom.xpath('ns:data_class', namespaces={'ns': CANSAS_NS}) 
     1202        node = dom.xpath('ns:data_class', namespaces={'ns': STATE_NODE}) 
    11901203        if not node or node[0].text.lstrip().rstrip() != "Data2D": 
    11911204            return CansasReader._parse_entry(self, dom) 
     
    11981211         
    11991212        # Look up run number    
    1200         nodes = dom.xpath('ns:Run', namespaces={'ns': CANSAS_NS}) 
     1213        nodes = dom.xpath('ns:Run', namespaces={'ns': STATE_NODE}) 
    12011214        for item in nodes:     
    12021215            if item.text is not None: 
     
    12111224 
    12121225        # Notes 
    1213         note_list = dom.xpath('ns:SASnote', namespaces={'ns': CANSAS_NS}) 
     1226        note_list = dom.xpath('ns:SASnote', namespaces={'ns': STATE_NODE}) 
    12141227        for note in note_list: 
    12151228            try: 
     
    12191232                        data_info.notes.append(note_value) 
    12201233            except: 
    1221                 err_mess = "cansas_reader.read: error processing entry notes\n  %s" % sys.exc_value 
     1234                err_mess = "state_reader.read: error processing entry notes\n  %s" % sys.exc_value 
    12221235                self.errors.append(err_mess) 
    12231236                logging.error(err_mess) 
     
    12371250                     dom, 'temperature', data_info.sample) 
    12381251         
    1239         nodes = dom.xpath('ns:SASsample/ns:details', namespaces={'ns': CANSAS_NS}) 
     1252        nodes = dom.xpath('ns:SASsample/ns:details', namespaces={'ns': STATE_NODE}) 
    12401253        for item in nodes: 
    12411254            try: 
     
    12451258                        data_info.sample.details.append(detail_value) 
    12461259            except: 
    1247                 err_mess = "cansas_reader.read: error processing sample details\n  %s" % sys.exc_value 
     1260                err_mess = "state_reader.read: error processing sample details\n  %s" % sys.exc_value 
    12481261                self.errors.append(err_mess) 
    12491262                logging.error(err_mess) 
     
    12961309         
    12971310        # Collimation info ################### 
    1298         nodes = dom.xpath('ns:SASinstrument/ns:SAScollimation', namespaces={'ns': CANSAS_NS}) 
     1311        nodes = dom.xpath('ns:SASinstrument/ns:SAScollimation', namespaces={'ns': STATE_NODE}) 
    12991312        for item in nodes: 
    13001313            collim = Collimation() 
     
    13041317             
    13051318            # Look for apertures 
    1306             apert_list = item.xpath('ns:aperture', namespaces={'ns': CANSAS_NS}) 
     1319            apert_list = item.xpath('ns:aperture', namespaces={'ns': STATE_NODE}) 
    13071320            for apert in apert_list: 
    13081321                aperture =  Aperture() 
     
    13271340         
    13281341        # Detector info ###################### 
    1329         nodes = dom.xpath('ns:SASinstrument/ns:SASdetector', namespaces={'ns': CANSAS_NS}) 
     1342        nodes = dom.xpath('ns:SASinstrument/ns:SASdetector', namespaces={'ns': STATE_NODE}) 
    13301343        for item in nodes: 
    13311344             
     
    13601373 
    13611374        # Processes info ###################### 
    1362         nodes = dom.xpath('ns:SASprocess', namespaces={'ns': CANSAS_NS}) 
     1375        nodes = dom.xpath('ns:SASprocess', namespaces={'ns': STATE_NODE}) 
    13631376        for item in nodes: 
    13641377            process = Process() 
     
    13671380            self._store_content('ns:description', item, 'description', process) 
    13681381             
    1369             term_list = item.xpath('ns:term', namespaces={'ns': CANSAS_NS}) 
     1382            term_list = item.xpath('ns:term', namespaces={'ns': STATE_NODE}) 
    13701383            for term in term_list: 
    13711384                try: 
     
    13771390                        process.term.append(term_attr) 
    13781391                except: 
    1379                     err_mess = "cansas_reader.read: error processing process term\n  %s" % sys.exc_value 
     1392                    err_mess = "state_reader.read: error processing process term\n  %s" % sys.exc_value 
    13801393                    self.errors.append(err_mess) 
    13811394                    logging.error(err_mess) 
    13821395             
    1383             note_list = item.xpath('ns:SASprocessnote', namespaces={'ns': CANSAS_NS}) 
     1396            note_list = item.xpath('ns:SASprocessnote', namespaces={'ns': STATE_NODE}) 
    13841397            for note in note_list: 
    13851398                if note.text is not None: 
     
    13901403             
    13911404        # Data info ###################### 
    1392         nodes = dom.xpath('ns:SASdata', namespaces={'ns': CANSAS_NS}) 
     1405        nodes = dom.xpath('ns:SASdata', namespaces={'ns': STATE_NODE}) 
    13931406        if len(nodes)>1: 
    13941407            raise RuntimeError, "CanSAS reader is not compatible with multiple SASdata entries" 
     
    14391452                    # Specifying the namespace will take care of the file format version  
    14401453                    root = tree.getroot() 
    1441                     entry_list = root.xpath('ns:SASentry', namespaces={'ns': CANSAS_NS}) 
     1454                    entry_list = root.xpath('ns:SASentry', namespaces={'ns': STATE_NODE}) 
    14421455                    for entry in entry_list:    
    14431456                        try: 
     
    15871600    logging.basicConfig(level=logging.ERROR, 
    15881601                        format='%(asctime)s %(levelname)s %(message)s', 
    1589                         filename='cansas_reader.log', 
     1602                        filename='state_reader.log', 
    15901603                        filemode='w') 
    15911604    reader = Reader() 
Note: See TracChangeset for help on using the changeset viewer.