File gl_plot.py copied from file qt_plot.py (similarity 83%) (mode: 100644) (index 645d9c4..320f5bd) |
2 |
2 |
# coding: utf-8 |
# coding: utf-8 |
3 |
3 |
|
|
4 |
4 |
import pyqtgraph as pg |
import pyqtgraph as pg |
|
5 |
|
import pyqtgraph.opengl as gl |
5 |
6 |
from pyqtgraph.Qt import QtGui |
from pyqtgraph.Qt import QtGui |
6 |
7 |
from pyqtgraph.Qt import QtCore |
from pyqtgraph.Qt import QtCore |
7 |
|
from pyqtgraph import console |
|
|
8 |
|
|
8 |
9 |
|
|
9 |
10 |
import numpy as np |
import numpy as np |
10 |
11 |
import pandas as pd # required for estimation graph |
import pandas as pd # required for estimation graph |
11 |
12 |
|
|
12 |
13 |
from . import estimation as stm |
from . import estimation as stm |
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
# |
|
17 |
|
# ani čert se tu nevyzná |
|
18 |
|
# |
|
19 |
|
|
|
20 |
|
def qt_gui_plot_2d(sample_box, space='R', *args, **kwargs): |
|
|
14 |
|
from . import qt_plot |
|
15 |
|
|
|
16 |
|
def qt_gui_plot_3d(sample_box, space='R', *args, **kwargs): |
21 |
17 |
""" |
""" |
22 |
18 |
This function will start Qt graph window in event loop |
This function will start Qt graph window in event loop |
23 |
|
To run code beyond the loop call QtGuiPlot2D directly |
|
24 |
19 |
""" |
""" |
25 |
20 |
|
|
26 |
|
qtplot = QtGuiPlot2D(sample_box, space, *args, **kwargs) |
|
|
21 |
|
return QtGuiPlot3D(sample_box, space, *args, **kwargs) |
27 |
22 |
|
|
28 |
|
## Display the widget as a new window |
|
29 |
|
qtplot.w.show() |
|
30 |
|
## Start the Qt event loop |
|
31 |
|
qtplot.app.exec_() |
|
32 |
|
return qtplot |
|
33 |
23 |
|
|
34 |
|
class QtGuiPlot2D: |
|
|
24 |
|
### Define a top-level widget to hold everything |
|
25 |
|
class QtGuiPlot3D(qt_plot.QtGuiPlot2D): |
35 |
26 |
#sb_runned = QtCore.pyqtSignal() |
#sb_runned = QtCore.pyqtSignal() |
36 |
|
# snad pri vykreslování argy-kvargy nevádí |
|
37 |
|
def __init__(self, sample_box, space='R', *args, **kwargs): |
|
38 |
|
self.sample_box = sample_box |
|
39 |
|
#sample_box.sample_box._log = self.logger |
|
40 |
|
self.space = space |
|
41 |
|
# "zapnuté" prostory |
|
42 |
|
#self.spaces = ['R', 'aR', 'Rn', 'aRn', 'P', 'aP', 'GK', 'aGK', 'G', 'aG', 'U', 'aU'] |
|
43 |
|
self.spaces = ['R', 'aR', 'Rn', 'aRn', 'P', 'GK', 'G', 'aG', 'U', 'aU'] |
|
44 |
|
|
|
45 |
|
self.app = pg.mkQApp() |
|
46 |
|
|
|
47 |
|
|
|
48 |
|
### Define a top-level widget to hold everything |
|
49 |
|
self.w = QtGui.QMainWindow() |
|
50 |
|
self.w.setWindowTitle(sample_box.gm_signature + " plot") |
|
|
27 |
|
|
|
28 |
|
def initialize_central_widget(self): |
|
29 |
|
self.central_widget = gl.GLViewWidget() |
|
30 |
|
self.redraw_called.connect(self.redraw_plot) |
51 |
31 |
|
|
|
32 |
|
self.base_plotting = BasePlotting(self) |
|
33 |
|
self.px_size = 5 |
|
34 |
|
#self.plot_widget_2d() |
|
35 |
|
|
|
36 |
|
def redraw_plot(self): |
|
37 |
|
try: |
|
38 |
|
self.central_widget.clear() |
|
39 |
|
self.central_widget.reset() |
|
40 |
|
except: #č 0.10 ještě neměla ty funkce |
|
41 |
|
for item in self.central_widget.items: |
|
42 |
|
item._setView(None) |
|
43 |
|
self.central_widget.items = [] |
|
44 |
|
self.central_widget.update() |
|
45 |
|
|
52 |
46 |
|
|
53 |
|
self.bar = self.w.menuBar() |
|
54 |
|
self.view = self.bar.addMenu("View") |
|
|
47 |
|
|
|
48 |
|
def plot_setup(self): |
55 |
49 |
self.graph_menu = self.bar.addMenu("BlackBox") |
self.graph_menu = self.bar.addMenu("BlackBox") |
56 |
|
self.triangulation_action = QtGui.QAction("Show triangulation", self.w, checkable=True) |
|
|
50 |
|
self.triangulation_action = QtGui.QAction("Show triangulation", self, checkable=True) |
57 |
51 |
self.triangulation_action.triggered.connect(self.triangulation_slot) |
self.triangulation_action.triggered.connect(self.triangulation_slot) |
58 |
52 |
self.graph_menu.addAction(self.triangulation_action) |
self.graph_menu.addAction(self.triangulation_action) |
59 |
|
|
|
60 |
|
# radší to udělám jako widget |
|
61 |
|
# self.candidates_action = QtGui.QAction("Show candidates", self.w, checkable=True) |
|
62 |
|
# self.candidates_action.triggered.connect(self.candidates_slot) |
|
63 |
|
# self.graph_menu.addAction(self.candidates_action) |
|
64 |
|
#self.file = self.bar.addMenu("File") |
|
65 |
|
#self.file.addAction("quit") |
|
66 |
|
|
|
67 |
|
### Create some widgets to be placed inside |
|
68 |
|
self.combo_space = pg.ComboBox(items=self.spaces, default=space) |
|
69 |
|
self.combo_space.activated[str].connect(self.change_space) |
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
|
self.slider = QtGui.QSlider(QtCore.Qt.Horizontal) |
|
75 |
|
self.slider.valueChanged.connect(self._slider_chainged) |
|
76 |
|
self.slider.sliderReleased.connect(self.slice_plot_data) |
|
77 |
|
|
|
78 |
|
self.label_nsim = QtGui.QLabel() |
|
79 |
|
self.label_nsim.setText(str(sample_box.nsim)) |
|
80 |
|
|
|
81 |
|
|
|
82 |
|
self.btn = QtGui.QPushButton('run box') |
|
83 |
|
self.btn.clicked.connect(self.run_sb) |
|
84 |
|
|
|
85 |
|
self.btn2 = QtGui.QPushButton('connect/disconnect') |
|
86 |
|
self.btn2.setCheckable(True) |
|
87 |
|
self.btn2.clicked.connect(self.bx_connect) |
|
88 |
|
|
|
89 |
|
# self.btn_connect = QtGui.QPushButton('connect') |
|
90 |
|
# self.btn_connect.clicked.connect(lambda:self.sample_box.connect(self.logger)) |
|
91 |
|
# |
|
92 |
|
# self.btn_disconnect = QtGui.QPushButton('disconnect') |
|
93 |
|
# self.btn_disconnect.clicked.connect(self.sample_box.disconnect) |
|
94 |
|
|
|
95 |
|
|
|
96 |
|
# zkusím prostě generovať |
|
97 |
|
self.plotWidget = pg.PlotWidget() |
|
98 |
|
self.plotWidget.setBackground('w') |
|
99 |
|
self.px_size = 2.5 |
|
100 |
|
self.plot_widget_2d() |
|
101 |
|
|
|
102 |
|
|
|
103 |
|
## Create a grid layout to manage the widgets size and position |
|
104 |
|
self.layout = pg.LayoutWidget() |
|
105 |
|
self.w.setCentralWidget(self.layout) |
|
106 |
|
#self.w.setLayout(self.layout) |
|
107 |
|
|
|
108 |
|
|
|
109 |
|
## Add widgets to the layout in their proper positions |
|
110 |
|
self.layout.addWidget(self.combo_space, 0, 0) |
|
111 |
|
self.layout.addWidget(self.slider, 0, 1) |
|
112 |
|
self.layout.addWidget(self.label_nsim, 0, 2) |
|
113 |
|
self.layout.addWidget(self.btn, 0, 3) |
|
114 |
|
self.layout.addWidget(self.btn2, 0, 4) |
|
115 |
|
self.layout.addWidget(self.plotWidget, 1, 0, 1, 5) |
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
|
119 |
|
# Dockables, najzajimavejší věc |
|
120 |
|
self.dockables = [] |
|
121 |
|
|
|
122 |
|
|
|
123 |
|
dock = QtGui.QDockWidget("Interactive python console", self.w) |
|
124 |
|
dock.setWidget(console.ConsoleWidget(namespace={**locals(), **globals()})) |
|
125 |
|
self.dockables.append(dock) |
|
126 |
|
self.w.addDockWidget(QtCore.Qt.BottomDockWidgetArea, dock) |
|
127 |
|
|
|
128 |
53 |
|
|
129 |
|
dock = QtGui.QDockWidget("BlackBox output", self.w) |
|
130 |
|
self.output_label = QtGui.QLabel() |
|
131 |
|
dock.setWidget(self.output_label) |
|
132 |
|
self.dockables.append(dock) |
|
133 |
|
self.w.tabifyDockWidget(self.dockables[0], dock) |
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
|
dock = dock_r = QtGui.QDockWidget("Simplex-based pf estimation", self.w) |
|
139 |
|
dock.setWidget(SimplexEstimationWidget(self, dock)) |
|
140 |
|
self.dockables.append(dock) |
|
141 |
|
self.w.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock) |
|
142 |
|
|
|
143 |
|
|
|
144 |
|
dock = QtGui.QDockWidget("Tesselation-based pf estimation", self.w) |
|
145 |
|
dock.setWidget(VoronoiEstimationWidget(self, dock)) |
|
146 |
|
self.dockables.append(dock) |
|
147 |
|
self.w.tabifyDockWidget(dock_r, dock) |
|
148 |
|
|
|
149 |
|
|
|
150 |
|
dock = QtGui.QDockWidget("Blackbox's candidates", self.w) |
|
151 |
|
dock.setWidget(CandidatesWidget(self, dock)) |
|
152 |
|
self.dockables.append(dock) |
|
153 |
|
self.w.tabifyDockWidget(dock_r, dock) |
|
154 |
|
|
|
155 |
|
|
|
156 |
|
# graphy musí jít po těch stm widgetech - ať nejdřív zpracujou odhady |
|
157 |
|
dock = QtGui.QDockWidget("TRI_current estimation graph", self.w) |
|
158 |
|
dock.setWidget(TriEstimationGraph(self.sample_box, tri_estimation_name='TRI_current_estimations')) |
|
159 |
|
self.dockables.append(dock) |
|
160 |
|
self.w.tabifyDockWidget(self.dockables[0], dock) |
|
161 |
|
|
|
162 |
|
dock = QtGui.QDockWidget("TRI_overall estimation graph", self.w) |
|
163 |
|
dock.setWidget(TriEstimationGraph(self.sample_box, tri_estimation_name='TRI_overall_estimations')) |
|
164 |
|
self.dockables.append(dock) |
|
165 |
|
self.w.tabifyDockWidget(self.dockables[0], dock) |
|
166 |
|
|
|
167 |
|
dock = QtGui.QDockWidget("Simplex estimation graph", self.w) |
|
168 |
|
dock.setWidget(SimpleSimplexEstimationGraph(self.sample_box, dock)) |
|
169 |
|
self.dockables.append(dock) |
|
170 |
|
self.w.tabifyDockWidget(self.dockables[0], dock) |
|
171 |
54 |
|
|
|
55 |
|
|
|
56 |
|
|
172 |
57 |
|
|
173 |
|
dock = QtGui.QDockWidget("Voronoi estimation graph", self.w) |
|
174 |
|
dock.setWidget(VoronoiEstimationGraph(self.sample_box, dock)) |
|
175 |
|
self.dockables.append(dock) |
|
176 |
|
self.w.tabifyDockWidget(self.dockables[0], dock) |
|
177 |
|
|
|
178 |
|
|
|
179 |
|
for dock in self.dockables: |
|
180 |
|
self.view.addAction(dock.toggleViewAction()) |
|
181 |
|
#dock.setFloating(True) |
|
182 |
|
|
|
183 |
|
#self.w.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.items) |
|
184 |
|
|
|
185 |
|
|
|
186 |
|
# status bar, mainly to observe BlackBox |
|
187 |
|
self.statusBar = QtGui.QStatusBar() |
|
188 |
|
self.w.setStatusBar(self.statusBar) |
|
189 |
|
self.btn_continue = QtGui.QPushButton('continue') |
|
190 |
|
self.continue_label = QtGui.QLabel() |
|
191 |
|
# self.continue_layout = QtGui.QHBoxLayout() |
|
192 |
|
# self.continue_layout.addWidget(self.btn_continue) |
|
193 |
|
# self.continue_layout.addWidget(self.continue_label) |
|
194 |
|
self.statusBar.addWidget(self.btn_continue) |
|
195 |
|
self.statusBar.addWidget(self.continue_label) |
|
196 |
|
self.btn_continue.hide() |
|
197 |
|
self.continue_label.hide() |
|
198 |
|
|
|
199 |
|
self.statusBar.showMessage("Vitáme vás u nás!") |
|
200 |
|
|
|
201 |
|
def bx_connect(self): |
|
202 |
|
if self.btn2.isChecked(): |
|
203 |
|
try: |
|
204 |
|
self.sample_box.connect(self.logger) |
|
205 |
|
except BaseException as e: |
|
206 |
|
print(self.__class__.__name__ + ":", "connection to BlackBox failed", repr(e)) |
|
207 |
|
else: |
|
208 |
|
try: |
|
209 |
|
self.sample_box.disconnect() |
|
210 |
|
except BaseException as e: |
|
211 |
|
print(self.__class__.__name__ + ":", "error while disconnecting of BlackBox", repr(e)) |
|
212 |
|
|
|
213 |
|
|
|
214 |
|
def logger(self, *args, msg="", indent=0, **kwargs): |
|
215 |
|
self.continue_label.setText("BlackBox: " + msg) |
|
216 |
|
self.output_label.setText(str(args) + str(kwargs)) |
|
217 |
|
|
|
218 |
|
loop = QtCore.QEventLoop() |
|
219 |
|
self.btn_continue.clicked.connect(loop.quit) |
|
220 |
|
self.btn_continue.show() |
|
221 |
|
self.continue_label.show() |
|
222 |
|
# i want to clear status bar temporaly |
|
223 |
|
status = self.statusBar.currentMessage() |
|
224 |
|
self.statusBar.clearMessage() |
|
225 |
|
|
|
226 |
|
loop.exec_() # Execution stops here until finished called |
|
227 |
|
|
|
228 |
|
self.btn_continue.hide() |
|
229 |
|
self.continue_label.hide() |
|
230 |
|
self.statusBar.showMessage(status) |
|
231 |
|
|
|
232 |
|
def _slider_chainged(self, value): |
|
233 |
|
self.label_nsim.setText(str(value)) |
|
234 |
|
if not self.slider.isSliderDown(): # co to vůbec děla? |
|
235 |
|
self.slice_plot_data() |
|
236 |
|
|
|
237 |
|
def run_sb(self): |
|
238 |
|
with pg.BusyCursor(): |
|
239 |
|
sample = self.sample_box() |
|
240 |
|
|
|
241 |
|
# slider |
|
242 |
|
self.slider.setMaximum(self.sample_box.nsim) |
|
243 |
|
self.slider.setValue(self.sample_box.nsim) |
|
244 |
|
|
|
245 |
|
self.slice_plot_data(sample) |
|
246 |
|
#self.sb_runned.emit() |
|
247 |
|
|
|
248 |
|
|
|
249 |
|
|
|
250 |
|
# zatím tak |
|
251 |
|
for dock in self.dockables: |
|
252 |
|
try: |
|
253 |
|
dock.widget().redraw() |
|
254 |
|
except AttributeError: |
|
255 |
|
pass |
|
256 |
|
#dock.setFloating(True) |
|
|
58 |
|
## def _slider_chainged(self, value): |
|
59 |
|
## self.label_nsim.setText(str(value)) |
|
60 |
|
## if not self.slider.isSliderDown(): # co to vůbec děla? |
|
61 |
|
## self.slice_plot_data() |
|
62 |
|
## |
|
63 |
|
## def run_sb(self): |
|
64 |
|
## with pg.BusyCursor(): |
|
65 |
|
## sample = self.sample_box() |
|
66 |
|
## |
|
67 |
|
## # slider |
|
68 |
|
## self.slider.setMaximum(self.sample_box.nsim) |
|
69 |
|
## self.slider.setValue(self.sample_box.nsim) |
|
70 |
|
## |
|
71 |
|
## self.slice_plot_data(sample) |
|
72 |
|
## #self.sb_runned.emit() |
|
73 |
|
## |
|
74 |
|
## |
|
75 |
|
## |
|
76 |
|
## # zatím tak |
|
77 |
|
## for dock in self.dockables: |
|
78 |
|
## try: |
|
79 |
|
## dock.widget().redraw() |
|
80 |
|
## except AttributeError: |
|
81 |
|
## pass |
|
82 |
|
## #dock.setFloating(True) |
257 |
83 |
|
|
258 |
84 |
def plot_widget_2d(self): |
def plot_widget_2d(self): |
259 |
85 |
self.plotWidget.clear() |
self.plotWidget.clear() |
|
... |
... |
class QtGuiPlot2D: |
270 |
96 |
elif self.space in ('P', 'U'): |
elif self.space in ('P', 'U'): |
271 |
97 |
self.plotWidget.plot((0,0,1,1,0), (0,1,1,0,0), pen='k') |
self.plotWidget.plot((0,0,1,1,0), (0,1,1,0,0), pen='k') |
272 |
98 |
|
|
273 |
|
x, y = (*getattr(self.sample_box.failure_samples, self.space).T,) |
|
|
99 |
|
x, y, z, *__ = (*getattr(self.sample_box.failure_samples, self.space).T,) |
274 |
100 |
self.failures = self.plotWidget.plot(x, y, pen=None, symbol='x', symbolPen='r', name='Failures') # symbolBrush=0.2, |
self.failures = self.plotWidget.plot(x, y, pen=None, symbol='x', symbolPen='r', name='Failures') # symbolBrush=0.2, |
275 |
101 |
|
|
276 |
|
x, y = (*getattr(self.sample_box.success_samples, self.space).T,) |
|
|
102 |
|
x, y, z, *__ = (*getattr(self.sample_box.success_samples, self.space).T,) |
277 |
103 |
self.successes = self.plotWidget.plot(x, y, pen=None, symbol='+', symbolPen='g', name='Successes') |
self.successes = self.plotWidget.plot(x, y, pen=None, symbol='+', symbolPen='g', name='Successes') |
278 |
104 |
|
|
279 |
105 |
x = y = () |
x = y = () |
280 |
106 |
self.last = self.plotWidget.plot(x, y, pen=None, symbol='o', symbolPen='c', name='Last shot', symbolBrush=None) |
self.last = self.plotWidget.plot(x, y, pen=None, symbol='o', symbolPen='c', name='Last shot', symbolBrush=None) |
281 |
107 |
self.shot = self.plotWidget.plot(x, y, pen=None, symbol='+', symbolPen='c', name='Last shot') |
self.shot = self.plotWidget.plot(x, y, pen=None, symbol='+', symbolPen='c', name='Last shot') |
282 |
108 |
|
|
283 |
|
# ne všichni majó definované hranice |
|
284 |
|
try: |
|
285 |
|
bounds = self.sample_box.get_2D_boundary(nrod=1000) |
|
286 |
|
|
|
287 |
|
for bound in bounds: |
|
288 |
|
self.plotWidget.plot(*getattr(bound, self.space).T, pen='b') |
|
289 |
|
except AttributeError: |
|
290 |
|
pass #print("čo sa děje?") |
|
291 |
109 |
|
|
292 |
110 |
# pro začatek postačí |
# pro začatek postačí |
293 |
111 |
self.triangulation = [] |
self.triangulation = [] |
|
... |
... |
class QtGuiPlot2D: |
353 |
171 |
|
|
354 |
172 |
|
|
355 |
173 |
|
|
356 |
|
def change_space(self, space): |
|
357 |
|
self.space = space |
|
358 |
|
self.plot_widget_2d() |
|
359 |
|
self.slice_plot_data() |
|
360 |
174 |
|
|
361 |
175 |
|
|
362 |
176 |
def triangulation_slot(self): |
def triangulation_slot(self): |
|
... |
... |
class QtGuiPlot2D: |
373 |
187 |
|
|
374 |
188 |
|
|
375 |
189 |
|
|
|
190 |
|
|
|
191 |
|
class PlotViewWidget(QtGui.QListWidget): |
|
192 |
|
pass |
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
|
class BasePlotting(gl.GLScatterPlotItem): |
|
197 |
|
def __init__(self, w): |
|
198 |
|
super().__init__() |
|
199 |
|
self.w = w |
|
200 |
|
#self.w.box_runned.connect(self.redraw) #č dublikuje slice_changed |
|
201 |
|
self.w.space_changed.connect(self.redraw) |
|
202 |
|
self.w.slice_changed.connect(self.redraw) |
|
203 |
|
self.w.redraw_called.connect(self.plot) |
|
204 |
|
|
|
205 |
|
|
|
206 |
|
def plot(self): |
|
207 |
|
self.redraw() |
|
208 |
|
self.w.central_widget.addItem(self) |
|
209 |
|
|
|
210 |
|
#č důležité je, že GLScatterPlotItem nemá .redraw() |
|
211 |
|
def redraw(self): |
|
212 |
|
nsim = self.w.slider.value() |
|
213 |
|
|
|
214 |
|
pos = getattr(self.w.sample_box, self.w.space)[:nsim] |
|
215 |
|
color = np.empty((nsim, 4)) |
|
216 |
|
failsi = self.w.sample_box.failsi[:nsim] |
|
217 |
|
color[failsi] = (1, 0, 0, 1) |
|
218 |
|
color[~failsi] = (0, 1, 0, 1) |
|
219 |
|
|
|
220 |
|
self.setData(pos=pos, color=color) |
|
221 |
|
|
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
|
226 |
|
|
|
227 |
|
|
376 |
228 |
""" |
""" |
377 |
229 |
============= |
============= |
378 |
230 |
График виӝет |
График виӝет |
|
... |
... |
class SimpleSimplexEstimationGraph(pg.PlotWidget): |
445 |
297 |
self.black_box = black_box |
self.black_box = black_box |
446 |
298 |
|
|
447 |
299 |
|
|
448 |
|
self.log_x_chk = QtGui.QAction("Log X") |
|
|
300 |
|
self.log_x_chk = QtGui.QAction("Log X", self.plotItem.ctrlMenu) |
449 |
301 |
self.log_x_chk.setCheckable(True) |
self.log_x_chk.setCheckable(True) |
450 |
|
self.log_y_chk = QtGui.QAction("Log Y") |
|
|
302 |
|
self.log_y_chk = QtGui.QAction("Log Y", self.plotItem.ctrlMenu) |
451 |
303 |
self.log_y_chk.setCheckable(True) |
self.log_y_chk.setCheckable(True) |
452 |
304 |
# setLogMode(self, x=None, y=None) |
# setLogMode(self, x=None, y=None) |
453 |
305 |
self.log_x_chk.triggered.connect(lambda: self.setLogMode(x=self.log_x_chk.isChecked())) |
self.log_x_chk.triggered.connect(lambda: self.setLogMode(x=self.log_x_chk.isChecked())) |
454 |
306 |
self.log_y_chk.triggered.connect(self.setup) |
self.log_y_chk.triggered.connect(self.setup) |
455 |
307 |
|
|
456 |
|
self.reaction = QtGui.QAction("Redraw") |
|
|
308 |
|
self.reaction = QtGui.QAction("Redraw", self.plotItem.ctrlMenu) |
457 |
309 |
self.reaction.triggered.connect(self.redraw) |
self.reaction.triggered.connect(self.redraw) |
458 |
310 |
|
|
459 |
311 |
#pw.plotItem.ctrlMenu.actions() |
#pw.plotItem.ctrlMenu.actions() |
|
... |
... |
class VoronoiEstimationGraph(pg.PlotWidget): |
579 |
431 |
self.setBackground('w') |
self.setBackground('w') |
580 |
432 |
|
|
581 |
433 |
|
|
582 |
|
self.reaction = QtGui.QAction("Redraw") |
|
|
434 |
|
self.reaction = QtGui.QAction("Redraw", self.plotItem.ctrlMenu) |
583 |
435 |
self.reaction.triggered.connect(self.redraw) |
self.reaction.triggered.connect(self.redraw) |
584 |
436 |
self.plotItem.ctrlMenu.insertAction(self.plotItem.ctrlMenu.actions()[0], self.reaction) |
self.plotItem.ctrlMenu.insertAction(self.plotItem.ctrlMenu.actions()[0], self.reaction) |
585 |
437 |
|
|
|
... |
... |
class SimplexEstimationWidget(pg.LayoutWidget): |
698 |
550 |
self.setup() |
self.setup() |
699 |
551 |
|
|
700 |
552 |
def setup(self): |
def setup(self): |
701 |
|
self.l1 = self.addLabel(text='Model space') |
|
|
553 |
|
self.l1 = self.addLabel('Model space') |
702 |
554 |
self.model_space = pg.ComboBox(items=self.sb_item.spaces, default=self.sb_item.space) |
self.model_space = pg.ComboBox(items=self.sb_item.spaces, default=self.sb_item.space) |
703 |
555 |
self.addWidget(self.model_space, col=1) |
self.addWidget(self.model_space, col=1) |
704 |
556 |
self.l2 = self.addLabel(text='Sampling space', row=1, col=0) |
self.l2 = self.addLabel(text='Sampling space', row=1, col=0) |
File qt_plot.py changed (mode: 100644) (index 645d9c4..3fc3044) |
4 |
4 |
import pyqtgraph as pg |
import pyqtgraph as pg |
5 |
5 |
from pyqtgraph.Qt import QtGui |
from pyqtgraph.Qt import QtGui |
6 |
6 |
from pyqtgraph.Qt import QtCore |
from pyqtgraph.Qt import QtCore |
|
7 |
|
|
7 |
8 |
from pyqtgraph import console |
from pyqtgraph import console |
8 |
9 |
|
|
9 |
10 |
import numpy as np |
import numpy as np |
|
... |
... |
import pandas as pd # required for estimation graph |
11 |
12 |
|
|
12 |
13 |
from . import estimation as stm |
from . import estimation as stm |
13 |
14 |
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
# |
|
17 |
|
# ani čert se tu nevyzná |
|
18 |
|
# |
|
19 |
|
|
|
|
15 |
|
|
20 |
16 |
def qt_gui_plot_2d(sample_box, space='R', *args, **kwargs): |
def qt_gui_plot_2d(sample_box, space='R', *args, **kwargs): |
21 |
17 |
""" |
""" |
22 |
18 |
This function will start Qt graph window in event loop |
This function will start Qt graph window in event loop |
23 |
|
To run code beyond the loop call QtGuiPlot2D directly |
|
24 |
19 |
""" |
""" |
25 |
20 |
|
|
26 |
|
qtplot = QtGuiPlot2D(sample_box, space, *args, **kwargs) |
|
|
21 |
|
return QtGuiPlot2D(sample_box, space, *args, **kwargs) |
|
22 |
|
|
|
23 |
|
|
|
24 |
|
### Define a top-level widget to hold everything |
|
25 |
|
class QtGuiPlot2D(QtGui.QMainWindow): |
|
26 |
|
#č dublikuje slice_changed |
|
27 |
|
# do not redraw twice! |
|
28 |
|
box_runned = QtCore.pyqtSignal() |
|
29 |
|
space_changed = QtCore.pyqtSignal() |
|
30 |
|
slice_changed = QtCore.pyqtSignal() |
|
31 |
|
redraw_called = QtCore.pyqtSignal() |
|
32 |
|
estimation_added = QtCore.pyqtSignal() |
27 |
33 |
|
|
28 |
|
## Display the widget as a new window |
|
29 |
|
qtplot.w.show() |
|
30 |
|
## Start the Qt event loop |
|
31 |
|
qtplot.app.exec_() |
|
32 |
|
return qtplot |
|
33 |
|
|
|
34 |
|
class QtGuiPlot2D: |
|
35 |
|
#sb_runned = QtCore.pyqtSignal() |
|
36 |
34 |
# snad pri vykreslování argy-kvargy nevádí |
# snad pri vykreslování argy-kvargy nevádí |
37 |
35 |
def __init__(self, sample_box, space='R', *args, **kwargs): |
def __init__(self, sample_box, space='R', *args, **kwargs): |
|
36 |
|
|
|
37 |
|
#E former self.w = QtGui.QMainWindow() |
|
38 |
|
self.app = pg.mkQApp() |
|
39 |
|
super().__init__() |
|
40 |
|
self.setWindowTitle(sample_box.gm_signature + " plot") |
|
41 |
|
|
38 |
42 |
self.sample_box = sample_box |
self.sample_box = sample_box |
39 |
43 |
#sample_box.sample_box._log = self.logger |
#sample_box.sample_box._log = self.logger |
|
44 |
|
self.last_shot = None |
40 |
45 |
self.space = space |
self.space = space |
41 |
46 |
# "zapnuté" prostory |
# "zapnuté" prostory |
42 |
47 |
#self.spaces = ['R', 'aR', 'Rn', 'aRn', 'P', 'aP', 'GK', 'aGK', 'G', 'aG', 'U', 'aU'] |
#self.spaces = ['R', 'aR', 'Rn', 'aRn', 'P', 'aP', 'GK', 'aGK', 'G', 'aG', 'U', 'aU'] |
43 |
48 |
self.spaces = ['R', 'aR', 'Rn', 'aRn', 'P', 'GK', 'G', 'aG', 'U', 'aU'] |
self.spaces = ['R', 'aR', 'Rn', 'aRn', 'P', 'GK', 'G', 'aG', 'U', 'aU'] |
|
49 |
|
|
|
50 |
|
# initialize central widget |
|
51 |
|
self.initialize_central_widget() |
44 |
52 |
|
|
45 |
|
self.app = pg.mkQApp() |
|
|
53 |
|
# common setup |
|
54 |
|
self.setup() |
|
55 |
|
|
|
56 |
|
self.plot_setup() |
|
57 |
|
|
|
58 |
|
## Display the widget as a new window |
|
59 |
|
self.show() |
|
60 |
|
|
|
61 |
|
# |
|
62 |
|
self.redraw_called.emit() |
|
63 |
|
|
|
64 |
|
## Start the Qt event loop |
|
65 |
|
self.app.exec_() |
|
66 |
|
|
|
67 |
|
|
|
68 |
|
def initialize_central_widget(self): |
|
69 |
|
self.central_widget = pg.PlotWidget() |
|
70 |
|
self.px_size = 2.5 |
|
71 |
|
self.plot_widget_2d() |
|
72 |
|
self.redraw_called.connect(self.central_widget.clear) |
46 |
73 |
|
|
47 |
74 |
|
|
48 |
|
### Define a top-level widget to hold everything |
|
49 |
|
self.w = QtGui.QMainWindow() |
|
50 |
|
self.w.setWindowTitle(sample_box.gm_signature + " plot") |
|
51 |
75 |
|
|
|
76 |
|
def setup(self): |
52 |
77 |
|
|
53 |
|
self.bar = self.w.menuBar() |
|
|
78 |
|
self.bar = self.menuBar() |
54 |
79 |
self.view = self.bar.addMenu("View") |
self.view = self.bar.addMenu("View") |
55 |
|
self.graph_menu = self.bar.addMenu("BlackBox") |
|
56 |
|
self.triangulation_action = QtGui.QAction("Show triangulation", self.w, checkable=True) |
|
57 |
|
self.triangulation_action.triggered.connect(self.triangulation_slot) |
|
58 |
|
self.graph_menu.addAction(self.triangulation_action) |
|
59 |
80 |
|
|
60 |
|
# radší to udělám jako widget |
|
61 |
|
# self.candidates_action = QtGui.QAction("Show candidates", self.w, checkable=True) |
|
62 |
|
# self.candidates_action.triggered.connect(self.candidates_slot) |
|
63 |
|
# self.graph_menu.addAction(self.candidates_action) |
|
64 |
|
#self.file = self.bar.addMenu("File") |
|
65 |
|
#self.file.addAction("quit") |
|
|
81 |
|
|
66 |
82 |
|
|
67 |
83 |
### Create some widgets to be placed inside |
### Create some widgets to be placed inside |
68 |
|
self.combo_space = pg.ComboBox(items=self.spaces, default=space) |
|
|
84 |
|
self.combo_space = pg.ComboBox(items=self.spaces, default=self.space) |
69 |
85 |
self.combo_space.activated[str].connect(self.change_space) |
self.combo_space.activated[str].connect(self.change_space) |
70 |
86 |
|
|
71 |
87 |
|
|
|
... |
... |
class QtGuiPlot2D: |
73 |
89 |
|
|
74 |
90 |
self.slider = QtGui.QSlider(QtCore.Qt.Horizontal) |
self.slider = QtGui.QSlider(QtCore.Qt.Horizontal) |
75 |
91 |
self.slider.valueChanged.connect(self._slider_chainged) |
self.slider.valueChanged.connect(self._slider_chainged) |
76 |
|
self.slider.sliderReleased.connect(self.slice_plot_data) |
|
|
92 |
|
self.slider.sliderReleased.connect(lambda:self.slice_changed.emit()) |
|
93 |
|
self.slider.setMaximum(self.sample_box.nsim) |
|
94 |
|
self.slider.setValue(self.sample_box.nsim) |
77 |
95 |
|
|
78 |
96 |
self.label_nsim = QtGui.QLabel() |
self.label_nsim = QtGui.QLabel() |
79 |
|
self.label_nsim.setText(str(sample_box.nsim)) |
|
|
97 |
|
self.label_nsim.setText(str(self.sample_box.nsim)) |
80 |
98 |
|
|
81 |
99 |
|
|
82 |
100 |
self.btn = QtGui.QPushButton('run box') |
self.btn = QtGui.QPushButton('run box') |
|
... |
... |
class QtGuiPlot2D: |
86 |
104 |
self.btn2.setCheckable(True) |
self.btn2.setCheckable(True) |
87 |
105 |
self.btn2.clicked.connect(self.bx_connect) |
self.btn2.clicked.connect(self.bx_connect) |
88 |
106 |
|
|
89 |
|
# self.btn_connect = QtGui.QPushButton('connect') |
|
90 |
|
# self.btn_connect.clicked.connect(lambda:self.sample_box.connect(self.logger)) |
|
91 |
|
# |
|
92 |
|
# self.btn_disconnect = QtGui.QPushButton('disconnect') |
|
93 |
|
# self.btn_disconnect.clicked.connect(self.sample_box.disconnect) |
|
94 |
|
|
|
95 |
|
|
|
96 |
|
# zkusím prostě generovať |
|
97 |
|
self.plotWidget = pg.PlotWidget() |
|
98 |
|
self.plotWidget.setBackground('w') |
|
99 |
|
self.px_size = 2.5 |
|
100 |
|
self.plot_widget_2d() |
|
|
107 |
|
self.btn3 = QtGui.QPushButton('redraw') |
|
108 |
|
self.btn3.clicked.connect(lambda:self.redraw_called.emit()) |
101 |
109 |
|
|
102 |
110 |
|
|
103 |
111 |
## Create a grid layout to manage the widgets size and position |
## Create a grid layout to manage the widgets size and position |
104 |
112 |
self.layout = pg.LayoutWidget() |
self.layout = pg.LayoutWidget() |
105 |
|
self.w.setCentralWidget(self.layout) |
|
|
113 |
|
self.setCentralWidget(self.layout) |
106 |
114 |
#self.w.setLayout(self.layout) |
#self.w.setLayout(self.layout) |
107 |
|
|
|
|
115 |
|
|
|
116 |
|
# |
|
117 |
|
self.list_view = QtGui.QListWidget() |
108 |
118 |
|
|
109 |
119 |
## Add widgets to the layout in their proper positions |
## Add widgets to the layout in their proper positions |
|
120 |
|
#self.layout.addWidget(self.list_view, 0, 0, 2, 1) |
110 |
121 |
self.layout.addWidget(self.combo_space, 0, 0) |
self.layout.addWidget(self.combo_space, 0, 0) |
111 |
122 |
self.layout.addWidget(self.slider, 0, 1) |
self.layout.addWidget(self.slider, 0, 1) |
112 |
123 |
self.layout.addWidget(self.label_nsim, 0, 2) |
self.layout.addWidget(self.label_nsim, 0, 2) |
113 |
124 |
self.layout.addWidget(self.btn, 0, 3) |
self.layout.addWidget(self.btn, 0, 3) |
114 |
|
self.layout.addWidget(self.btn2, 0, 4) |
|
115 |
|
self.layout.addWidget(self.plotWidget, 1, 0, 1, 5) |
|
|
125 |
|
self.layout.addWidget(self.btn2, 0, 4) |
|
126 |
|
self.layout.addWidget(self.btn3, 0, 5) |
|
127 |
|
self.layout.addWidget(self.central_widget, 1, 0, 1, 6) |
116 |
128 |
|
|
|
129 |
|
|
|
130 |
|
|
|
131 |
|
|
117 |
132 |
|
|
118 |
133 |
|
|
119 |
134 |
# Dockables, najzajimavejší věc |
# Dockables, najzajimavejší věc |
120 |
135 |
self.dockables = [] |
self.dockables = [] |
121 |
136 |
|
|
122 |
137 |
|
|
123 |
|
dock = QtGui.QDockWidget("Interactive python console", self.w) |
|
|
138 |
|
dock = QtGui.QDockWidget("Interactive python console", self) |
124 |
139 |
dock.setWidget(console.ConsoleWidget(namespace={**locals(), **globals()})) |
dock.setWidget(console.ConsoleWidget(namespace={**locals(), **globals()})) |
125 |
140 |
self.dockables.append(dock) |
self.dockables.append(dock) |
126 |
|
self.w.addDockWidget(QtCore.Qt.BottomDockWidgetArea, dock) |
|
|
141 |
|
self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, dock) |
127 |
142 |
|
|
128 |
143 |
|
|
129 |
|
dock = QtGui.QDockWidget("BlackBox output", self.w) |
|
|
144 |
|
dock = QtGui.QDockWidget("BlackBox output", self) |
130 |
145 |
self.output_label = QtGui.QLabel() |
self.output_label = QtGui.QLabel() |
131 |
146 |
dock.setWidget(self.output_label) |
dock.setWidget(self.output_label) |
132 |
147 |
self.dockables.append(dock) |
self.dockables.append(dock) |
133 |
|
self.w.tabifyDockWidget(self.dockables[0], dock) |
|
|
148 |
|
self.tabifyDockWidget(self.dockables[0], dock) |
134 |
149 |
|
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
|
dock = dock_r = QtGui.QDockWidget("Simplex-based pf estimation", self.w) |
|
139 |
|
dock.setWidget(SimplexEstimationWidget(self, dock)) |
|
|
150 |
|
|
|
151 |
|
dock = QtGui.QDockWidget("View", self) |
|
152 |
|
dock.setWidget(PlotViewWidget()) |
140 |
153 |
self.dockables.append(dock) |
self.dockables.append(dock) |
141 |
|
self.w.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock) |
|
|
154 |
|
self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dock) |
|
155 |
|
|
142 |
156 |
|
|
|
157 |
|
## dock = dock_r = QtGui.QDockWidget("Simplex-based pf estimation", self.w) |
|
158 |
|
## dock.setWidget(SimplexEstimationWidget(self, dock)) |
|
159 |
|
## self.dockables.append(dock) |
|
160 |
|
## self.w.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock) |
143 |
161 |
|
|
144 |
|
dock = QtGui.QDockWidget("Tesselation-based pf estimation", self.w) |
|
|
162 |
|
#! |
|
163 |
|
dock = dock_r = QtGui.QDockWidget("Tesselation-based pf estimation", self) |
145 |
164 |
dock.setWidget(VoronoiEstimationWidget(self, dock)) |
dock.setWidget(VoronoiEstimationWidget(self, dock)) |
146 |
165 |
self.dockables.append(dock) |
self.dockables.append(dock) |
147 |
|
self.w.tabifyDockWidget(dock_r, dock) |
|
|
166 |
|
self.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock) |
|
167 |
|
#self.w.tabifyDockWidget(dock_r, dock) |
148 |
168 |
|
|
149 |
169 |
|
|
150 |
|
dock = QtGui.QDockWidget("Blackbox's candidates", self.w) |
|
|
170 |
|
dock = QtGui.QDockWidget("Blackbox's candidates", self) |
151 |
171 |
dock.setWidget(CandidatesWidget(self, dock)) |
dock.setWidget(CandidatesWidget(self, dock)) |
152 |
172 |
self.dockables.append(dock) |
self.dockables.append(dock) |
153 |
|
self.w.tabifyDockWidget(dock_r, dock) |
|
|
173 |
|
self.tabifyDockWidget(dock_r, dock) |
154 |
174 |
|
|
155 |
175 |
|
|
156 |
176 |
# graphy musí jít po těch stm widgetech - ať nejdřív zpracujou odhady |
# graphy musí jít po těch stm widgetech - ať nejdřív zpracujou odhady |
157 |
|
dock = QtGui.QDockWidget("TRI_current estimation graph", self.w) |
|
|
177 |
|
dock = QtGui.QDockWidget("TRI_current estimation graph", self) |
158 |
178 |
dock.setWidget(TriEstimationGraph(self.sample_box, tri_estimation_name='TRI_current_estimations')) |
dock.setWidget(TriEstimationGraph(self.sample_box, tri_estimation_name='TRI_current_estimations')) |
159 |
179 |
self.dockables.append(dock) |
self.dockables.append(dock) |
160 |
|
self.w.tabifyDockWidget(self.dockables[0], dock) |
|
|
180 |
|
self.tabifyDockWidget(self.dockables[0], dock) |
161 |
181 |
|
|
162 |
|
dock = QtGui.QDockWidget("TRI_overall estimation graph", self.w) |
|
|
182 |
|
dock = QtGui.QDockWidget("TRI_overall estimation graph", self) |
163 |
183 |
dock.setWidget(TriEstimationGraph(self.sample_box, tri_estimation_name='TRI_overall_estimations')) |
dock.setWidget(TriEstimationGraph(self.sample_box, tri_estimation_name='TRI_overall_estimations')) |
164 |
184 |
self.dockables.append(dock) |
self.dockables.append(dock) |
165 |
|
self.w.tabifyDockWidget(self.dockables[0], dock) |
|
|
185 |
|
self.tabifyDockWidget(self.dockables[0], dock) |
166 |
186 |
|
|
167 |
|
dock = QtGui.QDockWidget("Simplex estimation graph", self.w) |
|
|
187 |
|
dock = QtGui.QDockWidget("Simplex estimation graph", self) |
168 |
188 |
dock.setWidget(SimpleSimplexEstimationGraph(self.sample_box, dock)) |
dock.setWidget(SimpleSimplexEstimationGraph(self.sample_box, dock)) |
169 |
189 |
self.dockables.append(dock) |
self.dockables.append(dock) |
170 |
|
self.w.tabifyDockWidget(self.dockables[0], dock) |
|
|
190 |
|
self.tabifyDockWidget(self.dockables[0], dock) |
171 |
191 |
|
|
172 |
192 |
|
|
173 |
|
dock = QtGui.QDockWidget("Voronoi estimation graph", self.w) |
|
|
193 |
|
dock = QtGui.QDockWidget("Voronoi estimation graph", self) |
174 |
194 |
dock.setWidget(VoronoiEstimationGraph(self.sample_box, dock)) |
dock.setWidget(VoronoiEstimationGraph(self.sample_box, dock)) |
175 |
195 |
self.dockables.append(dock) |
self.dockables.append(dock) |
176 |
|
self.w.tabifyDockWidget(self.dockables[0], dock) |
|
|
196 |
|
self.tabifyDockWidget(self.dockables[0], dock) |
177 |
197 |
|
|
178 |
198 |
|
|
179 |
199 |
for dock in self.dockables: |
for dock in self.dockables: |
|
... |
... |
class QtGuiPlot2D: |
185 |
205 |
|
|
186 |
206 |
# status bar, mainly to observe BlackBox |
# status bar, mainly to observe BlackBox |
187 |
207 |
self.statusBar = QtGui.QStatusBar() |
self.statusBar = QtGui.QStatusBar() |
188 |
|
self.w.setStatusBar(self.statusBar) |
|
|
208 |
|
self.setStatusBar(self.statusBar) |
189 |
209 |
self.btn_continue = QtGui.QPushButton('continue') |
self.btn_continue = QtGui.QPushButton('continue') |
190 |
210 |
self.continue_label = QtGui.QLabel() |
self.continue_label = QtGui.QLabel() |
191 |
211 |
# self.continue_layout = QtGui.QHBoxLayout() |
# self.continue_layout = QtGui.QHBoxLayout() |
|
... |
... |
class QtGuiPlot2D: |
197 |
217 |
self.continue_label.hide() |
self.continue_label.hide() |
198 |
218 |
|
|
199 |
219 |
self.statusBar.showMessage("Vitáme vás u nás!") |
self.statusBar.showMessage("Vitáme vás u nás!") |
|
220 |
|
|
|
221 |
|
|
|
222 |
|
def plot_setup(self): |
|
223 |
|
self.graph_menu = self.bar.addMenu("BlackBox") |
|
224 |
|
self.triangulation_action = QtGui.QAction("Show triangulation", self, checkable=True) |
|
225 |
|
self.triangulation_action.triggered.connect(self.triangulation_slot) |
|
226 |
|
self.graph_menu.addAction(self.triangulation_action) |
|
227 |
|
|
|
228 |
|
|
|
229 |
|
# |
|
230 |
|
#č Tlačítka! |
|
231 |
|
# |
|
232 |
|
|
|
233 |
|
|
|
234 |
|
def _slider_chainged(self, value): |
|
235 |
|
self.label_nsim.setText(str(value)) |
|
236 |
|
if not self.slider.isSliderDown(): # co to vůbec děla? |
|
237 |
|
self.slice_changed.emit() |
|
238 |
|
|
|
239 |
|
def change_space(self, space): |
|
240 |
|
self.space = space |
|
241 |
|
self.space_changed.emit() |
|
242 |
|
#self.plot_widget_2d() |
|
243 |
|
#self.slice_plot_data() |
|
244 |
|
|
|
245 |
|
def run_sb(self): |
|
246 |
|
with pg.BusyCursor(): |
|
247 |
|
self.last_shot = self.sample_box() |
|
248 |
|
|
|
249 |
|
# slider |
|
250 |
|
#č zpusobí slice_changed |
|
251 |
|
self.slider.setMaximum(self.sample_box.nsim) |
|
252 |
|
self.slider.setValue(self.sample_box.nsim) |
|
253 |
|
|
|
254 |
|
self.box_runned.emit() |
|
255 |
|
|
|
256 |
|
|
|
257 |
|
|
|
258 |
|
|
|
259 |
|
|
200 |
260 |
|
|
201 |
261 |
def bx_connect(self): |
def bx_connect(self): |
202 |
262 |
if self.btn2.isChecked(): |
if self.btn2.isChecked(): |
|
... |
... |
class QtGuiPlot2D: |
229 |
289 |
self.continue_label.hide() |
self.continue_label.hide() |
230 |
290 |
self.statusBar.showMessage(status) |
self.statusBar.showMessage(status) |
231 |
291 |
|
|
232 |
|
def _slider_chainged(self, value): |
|
233 |
|
self.label_nsim.setText(str(value)) |
|
234 |
|
if not self.slider.isSliderDown(): # co to vůbec děla? |
|
235 |
|
self.slice_plot_data() |
|
236 |
|
|
|
237 |
|
def run_sb(self): |
|
238 |
|
with pg.BusyCursor(): |
|
239 |
|
sample = self.sample_box() |
|
240 |
|
|
|
241 |
|
# slider |
|
242 |
|
self.slider.setMaximum(self.sample_box.nsim) |
|
243 |
|
self.slider.setValue(self.sample_box.nsim) |
|
244 |
|
|
|
245 |
|
self.slice_plot_data(sample) |
|
246 |
|
#self.sb_runned.emit() |
|
247 |
|
|
|
248 |
|
|
|
249 |
|
|
|
250 |
|
# zatím tak |
|
251 |
|
for dock in self.dockables: |
|
252 |
|
try: |
|
253 |
|
dock.widget().redraw() |
|
254 |
|
except AttributeError: |
|
255 |
|
pass |
|
256 |
|
#dock.setFloating(True) |
|
|
292 |
|
|
257 |
293 |
|
|
258 |
294 |
def plot_widget_2d(self): |
def plot_widget_2d(self): |
259 |
295 |
self.plotWidget.clear() |
self.plotWidget.clear() |
|
... |
... |
class QtGuiPlot2D: |
270 |
306 |
elif self.space in ('P', 'U'): |
elif self.space in ('P', 'U'): |
271 |
307 |
self.plotWidget.plot((0,0,1,1,0), (0,1,1,0,0), pen='k') |
self.plotWidget.plot((0,0,1,1,0), (0,1,1,0,0), pen='k') |
272 |
308 |
|
|
273 |
|
x, y = (*getattr(self.sample_box.failure_samples, self.space).T,) |
|
|
309 |
|
x, y, z, *__ = (*getattr(self.sample_box.failure_samples, self.space).T,) |
274 |
310 |
self.failures = self.plotWidget.plot(x, y, pen=None, symbol='x', symbolPen='r', name='Failures') # symbolBrush=0.2, |
self.failures = self.plotWidget.plot(x, y, pen=None, symbol='x', symbolPen='r', name='Failures') # symbolBrush=0.2, |
275 |
311 |
|
|
276 |
|
x, y = (*getattr(self.sample_box.success_samples, self.space).T,) |
|
|
312 |
|
x, y, z, *__ = (*getattr(self.sample_box.success_samples, self.space).T,) |
277 |
313 |
self.successes = self.plotWidget.plot(x, y, pen=None, symbol='+', symbolPen='g', name='Successes') |
self.successes = self.plotWidget.plot(x, y, pen=None, symbol='+', symbolPen='g', name='Successes') |
278 |
314 |
|
|
279 |
315 |
x = y = () |
x = y = () |
280 |
316 |
self.last = self.plotWidget.plot(x, y, pen=None, symbol='o', symbolPen='c', name='Last shot', symbolBrush=None) |
self.last = self.plotWidget.plot(x, y, pen=None, symbol='o', symbolPen='c', name='Last shot', symbolBrush=None) |
281 |
317 |
self.shot = self.plotWidget.plot(x, y, pen=None, symbol='+', symbolPen='c', name='Last shot') |
self.shot = self.plotWidget.plot(x, y, pen=None, symbol='+', symbolPen='c', name='Last shot') |
282 |
318 |
|
|
283 |
|
# ne všichni majó definované hranice |
|
284 |
|
try: |
|
285 |
|
bounds = self.sample_box.get_2D_boundary(nrod=1000) |
|
286 |
|
|
|
287 |
|
for bound in bounds: |
|
288 |
|
self.plotWidget.plot(*getattr(bound, self.space).T, pen='b') |
|
289 |
|
except AttributeError: |
|
290 |
|
pass #print("čo sa děje?") |
|
291 |
319 |
|
|
292 |
320 |
# pro začatek postačí |
# pro začatek postačí |
293 |
321 |
self.triangulation = [] |
self.triangulation = [] |
|
... |
... |
class QtGuiPlot2D: |
353 |
381 |
|
|
354 |
382 |
|
|
355 |
383 |
|
|
356 |
|
def change_space(self, space): |
|
357 |
|
self.space = space |
|
358 |
|
self.plot_widget_2d() |
|
359 |
|
self.slice_plot_data() |
|
|
384 |
|
|
360 |
385 |
|
|
361 |
386 |
|
|
362 |
387 |
def triangulation_slot(self): |
def triangulation_slot(self): |
|
... |
... |
class QtGuiPlot2D: |
373 |
398 |
|
|
374 |
399 |
|
|
375 |
400 |
|
|
|
401 |
|
|
|
402 |
|
class PlotViewWidget(QtGui.QListWidget): |
|
403 |
|
def __init__(self): |
|
404 |
|
super().__init__() |
|
405 |
|
self.addItem("Item 1") |
|
406 |
|
self.addItem("Item 3") |
|
407 |
|
self.addItem("Item 4") |
|
408 |
|
|
|
409 |
|
|
|
410 |
|
|
376 |
411 |
""" |
""" |
377 |
412 |
============= |
============= |
378 |
413 |
График виӝет |
График виӝет |
|
... |
... |
class SimpleSimplexEstimationGraph(pg.PlotWidget): |
445 |
480 |
self.black_box = black_box |
self.black_box = black_box |
446 |
481 |
|
|
447 |
482 |
|
|
448 |
|
self.log_x_chk = QtGui.QAction("Log X") |
|
|
483 |
|
self.log_x_chk = QtGui.QAction("Log X", self.plotItem.ctrlMenu) |
449 |
484 |
self.log_x_chk.setCheckable(True) |
self.log_x_chk.setCheckable(True) |
450 |
|
self.log_y_chk = QtGui.QAction("Log Y") |
|
|
485 |
|
self.log_y_chk = QtGui.QAction("Log Y", self.plotItem.ctrlMenu) |
451 |
486 |
self.log_y_chk.setCheckable(True) |
self.log_y_chk.setCheckable(True) |
452 |
487 |
# setLogMode(self, x=None, y=None) |
# setLogMode(self, x=None, y=None) |
453 |
488 |
self.log_x_chk.triggered.connect(lambda: self.setLogMode(x=self.log_x_chk.isChecked())) |
self.log_x_chk.triggered.connect(lambda: self.setLogMode(x=self.log_x_chk.isChecked())) |
454 |
489 |
self.log_y_chk.triggered.connect(self.setup) |
self.log_y_chk.triggered.connect(self.setup) |
455 |
490 |
|
|
456 |
|
self.reaction = QtGui.QAction("Redraw") |
|
|
491 |
|
self.reaction = QtGui.QAction("Redraw", self.plotItem.ctrlMenu) |
457 |
492 |
self.reaction.triggered.connect(self.redraw) |
self.reaction.triggered.connect(self.redraw) |
458 |
493 |
|
|
459 |
494 |
#pw.plotItem.ctrlMenu.actions() |
#pw.plotItem.ctrlMenu.actions() |
|
... |
... |
class VoronoiEstimationGraph(pg.PlotWidget): |
579 |
614 |
self.setBackground('w') |
self.setBackground('w') |
580 |
615 |
|
|
581 |
616 |
|
|
582 |
|
self.reaction = QtGui.QAction("Redraw") |
|
|
617 |
|
self.reaction = QtGui.QAction("Redraw", self.plotItem.ctrlMenu) |
583 |
618 |
self.reaction.triggered.connect(self.redraw) |
self.reaction.triggered.connect(self.redraw) |
584 |
619 |
self.plotItem.ctrlMenu.insertAction(self.plotItem.ctrlMenu.actions()[0], self.reaction) |
self.plotItem.ctrlMenu.insertAction(self.plotItem.ctrlMenu.actions()[0], self.reaction) |
585 |
620 |
|
|
|
... |
... |
class SimplexEstimationWidget(pg.LayoutWidget): |
698 |
733 |
self.setup() |
self.setup() |
699 |
734 |
|
|
700 |
735 |
def setup(self): |
def setup(self): |
701 |
|
self.l1 = self.addLabel(text='Model space') |
|
|
736 |
|
self.l1 = self.addLabel('Model space') |
702 |
737 |
self.model_space = pg.ComboBox(items=self.sb_item.spaces, default=self.sb_item.space) |
self.model_space = pg.ComboBox(items=self.sb_item.spaces, default=self.sb_item.space) |
703 |
738 |
self.addWidget(self.model_space, col=1) |
self.addWidget(self.model_space, col=1) |
704 |
739 |
self.l2 = self.addLabel(text='Sampling space', row=1, col=0) |
self.l2 = self.addLabel(text='Sampling space', row=1, col=0) |