1 """GUI configuration for globally available pluggable optimizers.
2
3 Copyright 2008-2012 Research Foundation State University of New York
4 This file is part of QUB Express.
5
6 QUB Express is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 QUB Express is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License,
17 named LICENSE.txt, in the QUB Express program directory. If not, see
18 <http://www.gnu.org/licenses/>.
19
20 """
21
22 import gtk
23 import numpy
24 import qubx.accept
25 import qubx.faces
26 import qubx.GTK
27 import qubx.optimize
28 import qubx.pyenv
29 import qubx.settings
30 import qubx.tree
31 import qubx.treeGTK
32 from qubx.util_types import Reffer, WeakEvent
33
52
53
55 __explore_featured = ['profile', 'optTree', 'treeview', 'refresh']
56 - def __init__(self, caption, profile, global_name=""):
67 self.treeview.root = self.optTree[ str(self.optTree['Method'].data) ]
69 qubx.pyenv.env.OnScriptable('qubx.optimize.set_options(%s, %s)' %
70 (repr(self.profile), repr(qubx.tree.tree_to_dict(self.optTree[str(self.optTree['Method'].data)]))))
71
72
90 priority = qubx.tree.node_data_or_def(self.optTree.find('Methods').find(name), rec['priority'])
91 order = priority or rec['priority'] or 1
92 ix = len(self.__priorities)
93 while (ix > 0) and (self.__priorities[ix-1] > order):
94 ix -= 1
95 self.insert(ix, bool(priority), name)
96 self.__recs.insert(ix, rec)
97 self.__priorities.insert(ix, order)
99 self.clear()
100 recs = self.__recs
101 self.__recs, self.__priorities = [], []
102 for rec in recs:
103 self.__onOptimizerAdded(rec['name'], rec)
104 self.options_box.refresh()
106 rec = self.__recs[ix]
107 self.optTree['Methods'][rec['name']].data = (active and self.__priorities[ix] or 0)
108 qubx.pyenv.env.OnScriptable("qubx.optimize.set_opt_priority(%s, %s, %i)" % (repr(self.profile), repr(rec['name']), (active and self.__priorities[ix] or 0)))
110 self.__recs[a], self.__recs[b] = self.__recs[b], self.__recs[a]
111 self.__priorities[a], self.__priorities[b] = self.__priorities[b], self.__priorities[a]
112 self.__reorder(min(a,b))
114 p = self.__priorities[ix0-1] if ix0 else 0
115 for i in xrange(ix0, len(self.__recs)):
116 p = self.__priorities[i] = p + 1
117 if self.get_active(i):
118 name = self.__recs[i]['name']
119 node = self.optTree['Methods'][name]
120 if (not node.data) or (node.data[0] != p):
121 self.optTree['Methods'][name].data = p
122 qubx.pyenv.env.OnScriptable("qubx.optimize.set_method_priority(%s, %s, %i)" % (repr(self.profile), repr(name), p))
124 self.optTree['Method'].data = self.__recs[ix]['name']
125 self.options_box.refresh()
134
135
136
137
139 __explore_featured = ['profile', 'optTree', 'treeview', 'refresh']
151 self.treeview.root = self.optTree[ str(self.optTree['Method'].data) ]
153 qubx.pyenv.env.OnScriptable('qubx.optimize.set_options(%s, %s)' %
154 (repr(self.profile), repr(qubx.tree.tree_to_dict(self.optTree[str(self.optTree['Method'].data)]))))
155
165