source: sasview/src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py @ f46f6dc

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since f46f6dc was f46f6dc, checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago

Multishell parameters support - prototype SASVIEW-346

  • Property mode set to 100755
File size: 2.5 KB
RevLine 
[4c7dd9f]1import sys
[0efe791]2
[4c7dd9f]3from PyQt4 import QtCore
[60af928]4from PyQt4 import QtGui
[4c7dd9f]5
[60af928]6from FittingWidget import FittingWidget
[8bdb6f5]7
[60af928]8class FittingWindow(QtGui.QTabWidget):
[0efe791]9    """
10    """
[60af928]11    name = "Fitting" # For displaying in the combo box in DataExplorer
12    def __init__(self, manager=None, parent=None, data=None):
[f46f6dc]13        super(FittingWindow, self).__init__()
14
15        self.manager = manager
16        self.parent = parent
17        self._data = data
18
19        # List of active fits
20        self.tabs = []
21
22        # Max index for adding new, non-clashing tab names
23        self.maxIndex = 0
24
25        # Index of the current tab
26        self.currentTab = 0
27
28        # The current optimizer
29        self.optimizer = 'DREAM'
30
31        # The tabs need to be closeable
32        self.setTabsClosable(True)
[60af928]33
34        # Initialize the first tab
[f46f6dc]35        self.addFit(None)
36
37        # Deal with signals
38        self.tabCloseRequested.connect(self.tabCloses)
39
40        self.setWindowTitle('Fit panel - Active Fitting Optimizer: %s' % self.optimizer)
[60af928]41
42    def addFit(self, data):
43        """
44        Add a new tab for passed data
45        """
[f46f6dc]46        tab     = FittingWidget(manager=self.manager, parent=self.parent, data=data)
47        self.tabs.append(tab)
48        self.maxIndex += 1
49        self.addTab(tab, self.tabName())
50
51    def tabName(self):
52        """
53        Get the new tab name, based on the number of fitting tabs so far
54        """
55        page_name = "FitPage" + str(self.maxIndex)
56        return page_name
57
58    def tabCloses(self, index):
59        """
60        Update local bookkeeping on tab close
61        """
62        assert(len(self.tabs) >= index)
63        # don't remove the last tab
64        if len(self.tabs) <= 1:
65            return
66        del self.tabs[index]
67        self.removeTab(index)
68
69    def allowBatch(self):
70        """
71        Tell the caller that we accept multiple data instances
72        """
73        return True
74
75    def setData(self, data=None):
76        """
77        Assign new dataset to the fitting instance
78        """
79        assert(data is not None)
80
81        # find an unassigned tab.
82        # if none, open a new tab.
83        tab_to_send = None
84        for tab in self.tabs:
85            if tab.acceptsData():
86                tab_to_send = tab
87                break
88        # send data
89        if tab_to_send is None:
90            self.addFit(data)
91        else:
92            tab_to_send.data = data
93        pass
[4c7dd9f]94
95if __name__ == "__main__":
96    app = QtGui.QApplication([])
[83d6249]97    dlg = FittingWindow()
[4c7dd9f]98    dlg.show()
99    sys.exit(app.exec_())
Note: See TracBrowser for help on using the repository browser.