File wellmet/qt_gui/qt_pairwise.py changed (mode: 100644) (index 924117b..46b7402) |
... |
... |
from pyqtgraph.Qt import QtCore |
8 |
8 |
|
|
9 |
9 |
import numpy as np |
import numpy as np |
10 |
10 |
from scipy import spatial # for distance matrix |
from scipy import spatial # for distance matrix |
11 |
|
from ..wireframe import ConvexSpline |
|
|
11 |
|
from .. import wireframe |
12 |
12 |
from .. import reader |
from .. import reader |
13 |
13 |
|
|
14 |
14 |
|
|
|
... |
... |
class ContactWidget(pg.LayoutWidget): |
635 |
635 |
def on_nsim_changed(self, n): |
def on_nsim_changed(self, n): |
636 |
636 |
try: |
try: |
637 |
637 |
del self.condensed_qontacts |
del self.condensed_qontacts |
|
638 |
|
del self.qframe |
638 |
639 |
except AttributeError: |
except AttributeError: |
639 |
640 |
pass |
pass |
640 |
641 |
size = n * (n - 1) // 2 |
size = n * (n - 1) // 2 |
|
... |
... |
class ContactWidget(pg.LayoutWidget): |
659 |
660 |
i, j = min(x, y), max(x, y) |
i, j = min(x, y), max(x, y) |
660 |
661 |
entry = m * i + j - ((i + 2) * (i + 1)) // 2 |
entry = m * i + j - ((i + 2) * (i + 1)) // 2 |
661 |
662 |
try: |
try: |
662 |
|
val = self.condensed_qontacts[entry] |
|
|
663 |
|
if self.condensed_qontacts[entry]: |
|
664 |
|
self.status_label.setText("There is DEFINITELY contact between %d and %d" % (x, y)) |
|
665 |
|
else: |
|
666 |
|
self.status_label.setText("There is definitely NO contact between %d and %d" % (x, y)) |
663 |
667 |
except AttributeError: |
except AttributeError: |
664 |
668 |
val = self.condensed_contacts[entry] |
val = self.condensed_contacts[entry] |
665 |
|
|
|
666 |
|
if val > 0: |
|
667 |
|
self.status_label.setText("There IS contact between %d and %d" % (x, y)) |
|
668 |
|
elif val < 0: |
|
669 |
|
self.status_label.setText("There is NO contact between %d and %d" % (x, y)) |
|
670 |
|
else: |
|
671 |
|
self.status_label.setText("") |
|
|
669 |
|
if val > 0: |
|
670 |
|
self.status_label.setText("There IS contact between %d and %d" % (x, y)) |
|
671 |
|
elif val < 0: |
|
672 |
|
self.status_label.setText("There is NO contact between %d and %d" % (x, y)) |
|
673 |
|
else: |
|
674 |
|
self.status_label.setText("") |
672 |
675 |
|
|
673 |
676 |
|
|
674 |
677 |
def on_mouse_dragged(self, x, y): |
def on_mouse_dragged(self, x, y): |
|
... |
... |
class ContactWidget(pg.LayoutWidget): |
807 |
810 |
def stop(self): |
def stop(self): |
808 |
811 |
self.stopbtn.setChecked(True) |
self.stopbtn.setChecked(True) |
809 |
812 |
|
|
|
813 |
|
def qframe_callback(self): |
|
814 |
|
# keep the GUI responsive :) |
|
815 |
|
self.w.app.processEvents() |
|
816 |
|
|
|
817 |
|
self.dlg += 1 |
|
818 |
|
return self.dlg.wasCanceled() |
|
819 |
|
|
|
820 |
|
|
|
821 |
|
@staticmethod |
|
822 |
|
def get_user_consent(): |
|
823 |
|
return QtWidgets.QMessageBox.question(None, |
|
824 |
|
"Performing triangulation in high dimensions may take a while...", |
|
825 |
|
"Would you like to start Qhull anyway?" |
|
826 |
|
) == QtWidgets.QMessageBox.Yes |
|
827 |
|
|
810 |
828 |
def check(self): |
def check(self): |
811 |
|
pass |
|
|
829 |
|
sample_box = self.w.get_sample_box() |
|
830 |
|
if (sample_box.nvar < 10) or self.get_user_consent(): |
|
831 |
|
sample_space = getattr(sample_box, self.w.space) |
|
832 |
|
self.qframe = wireframe.Qframe(sample_space) |
|
833 |
|
with pg.ProgressDialog("Going over all the simplices..", 0, |
|
834 |
|
self.qframe.nsimplex, cancelText='Stop', |
|
835 |
|
busyCursor=True) as dlg: |
|
836 |
|
self.dlg = dlg |
|
837 |
|
self.qframe.generate_wireframe(self.qframe_callback) |
|
838 |
|
self.condensed_qontacts = self.qframe.condensed_contacts |
|
839 |
|
self.show() |
|
840 |
|
|
|
841 |
|
|
812 |
842 |
|
|
813 |
843 |
def clear(self): |
def clear(self): |
814 |
844 |
self.condensed_contacts[:] = 0 |
self.condensed_contacts[:] = 0 |
|
... |
... |
class ContactWidget(pg.LayoutWidget): |
822 |
852 |
self.w.image_view.update() |
self.w.image_view.update() |
823 |
853 |
|
|
824 |
854 |
def show(self): |
def show(self): |
825 |
|
self.w.image_view.blue[self.mask] = self.condensed_contacts |
|
826 |
855 |
try: |
try: |
827 |
|
self.w.image_view.blue[self.mask] -= self.condensed_qontacts |
|
|
856 |
|
self.w.image_view.blue[self.mask] = self.condensed_qontacts * 2 - 1 |
|
857 |
|
self.w.image_view.blue[self.mask] -= self.condensed_contacts |
828 |
858 |
self.w.image_view.blue[self.mask] /= 2 |
self.w.image_view.blue[self.mask] /= 2 |
829 |
859 |
except AttributeError: |
except AttributeError: |
830 |
|
pass |
|
|
860 |
|
self.w.image_view.blue[self.mask] = self.condensed_contacts |
831 |
861 |
self.w.image_view.update(autoRange=False) |
self.w.image_view.update(autoRange=False) |
832 |
862 |
|
|
833 |
863 |
def hide(self): |
def hide(self): |
|
... |
... |
class ContactWidget(pg.LayoutWidget): |
874 |
904 |
def setup_CS(self): |
def setup_CS(self): |
875 |
905 |
sample_box = self.w.get_sample_box() |
sample_box = self.w.get_sample_box() |
876 |
906 |
sample_space = getattr(sample_box, self.w.space) |
sample_space = getattr(sample_box, self.w.space) |
877 |
|
self.CS = ConvexSpline(sample_space) |
|
|
907 |
|
self.CS = wireframe.ConvexSpline(sample_space) |
878 |
908 |
|
|
879 |
909 |
if self.param.getValues()['force_update'][0]: |
if self.param.getValues()['force_update'][0]: |
880 |
910 |
self.check_contact = self.force_check_contact |
self.check_contact = self.force_check_contact |