Changeset 6300dfe in sasview for src/sas/sasgui/perspectives/fitting


Ignore:
Timestamp:
Aug 23, 2017 8:05:45 AM (7 years ago)
Author:
Tim Snow <tim.snow@…>
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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
f0a16d5
Parents:
367a31c (diff), f001bc9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into ticket-869

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r914c49d5 r367a31c  
    1515import traceback 
    1616 
     17from Queue import Queue 
     18from threading import Thread 
    1719from collections import defaultdict 
    1820from wx.lib.scrolledpanel import ScrolledPanel 
     
    241243        self.set_layout() 
    242244 
     245        # Setting up a thread for the fitting 
     246        self.threaded_draw_queue = Queue() 
     247 
     248        self.draw_worker_thread = Thread(target = self._threaded_draw_worker, 
     249                                         args = (self.threaded_draw_queue,)) 
     250        self.draw_worker_thread.setDaemon(True) 
     251        self.draw_worker_thread.start() 
     252 
     253        # And a home for the thread submission times 
     254        self.last_time_fit_submitted = 0.00 
     255 
    243256    def set_index_model(self, index): 
    244257        """ 
     
    16931706        :param chisqr: update chisqr value [bool] 
    16941707        """ 
    1695         wx.CallAfter(self._draw_model_after, update_chisqr, source) 
     1708        # Get the time 
     1709        current_time = time.time() 
     1710 
     1711        # When loading we slam a number of fits through here 
     1712        # let's filter these out to start with 
     1713        if current_time > (self.last_time_fit_submitted + 0.1): 
     1714            # Submitting the rest 
     1715            self.threaded_draw_queue.put([update_chisqr, source]) 
     1716        else: 
     1717            pass 
     1718 
     1719        self.last_time_fit_submitted = current_time 
     1720 
     1721    def _threaded_draw_worker(self, threaded_draw_queue): 
     1722        while True: 
     1723            # Check to see is a manager is running and a calc is running 
     1724            if ((self._manager.calc_1D is not None 
     1725                 and self._manager.calc_1D.isrunning()) or 
     1726                (self._manager.calc_2D is not None 
     1727                 and self._manager.calc_2D.isrunning())): 
     1728                # If a manager is running a calculation 
     1729                # then trim the queue 
     1730                if self.threaded_draw_queue.qsize() > 1: 
     1731                    for loopIter in range(threaded_draw_queue.qsize() - 1): 
     1732                        dump = self.threaded_draw_queue.get() 
     1733                        self.threaded_draw_queue.task_done() 
     1734            else: 
     1735                # Otherwise, just run 
     1736                input_variables = threaded_draw_queue.get() 
     1737                self._draw_model_after(input_variables[0], input_variables[1]) 
     1738                event = StatusEvent(status="Computation is in progress...", 
     1739                                    type="progress") 
     1740                wx.PostEvent(self._manager.parent, event) 
     1741                threaded_draw_queue.task_done() 
    16961742 
    16971743    def _draw_model_after(self, update_chisqr=True, source='model'): 
     
    17161762            toggle_mode_on = self.model_view.IsEnabled() 
    17171763            is_2d = self._is_2D() 
     1764 
    17181765            self._manager.draw_model(self.model, 
    17191766                                     data=self.data, 
Note: See TracChangeset for help on using the changeset viewer.