File wellmet/qt_gui/qt_pairwise.py changed (mode: 100644) (index cf0ec32..9575b89) |
... |
... |
class ContactWidget(pg.LayoutWidget): |
630 |
630 |
|
|
631 |
631 |
self.setup() |
self.setup() |
632 |
632 |
self.kwargs = {} |
self.kwargs = {} |
|
633 |
|
self.check_contact = self.peacefully_check_contact |
633 |
634 |
self.setup_CS() |
self.setup_CS() |
634 |
635 |
|
|
635 |
636 |
def on_nsim_changed(self, n): |
def on_nsim_changed(self, n): |
636 |
637 |
try: |
try: |
637 |
|
del self.condensed_qontacts |
|
638 |
638 |
del self.qframe |
del self.qframe |
|
639 |
|
del self.condensed_qontacts |
639 |
640 |
except AttributeError: |
except AttributeError: |
640 |
641 |
pass |
pass |
641 |
642 |
size = n * (n - 1) // 2 |
size = n * (n - 1) // 2 |
|
... |
... |
class ContactWidget(pg.LayoutWidget): |
708 |
709 |
def discover(self): |
def discover(self): |
709 |
710 |
nsim = self.nsim |
nsim = self.nsim |
710 |
711 |
if nsim > 0: |
if nsim > 0: |
711 |
|
self.setup_CS() |
|
712 |
712 |
self.stopbtn.setEnabled(True) |
self.stopbtn.setEnabled(True) |
713 |
713 |
self.stopbtn.setCheckable(True) |
self.stopbtn.setCheckable(True) |
714 |
714 |
|
|
|
... |
... |
class ContactWidget(pg.LayoutWidget): |
817 |
817 |
self.dlg += 1 |
self.dlg += 1 |
818 |
818 |
return self.dlg.wasCanceled() |
return self.dlg.wasCanceled() |
819 |
819 |
|
|
|
820 |
|
|
820 |
821 |
|
|
821 |
822 |
@staticmethod |
@staticmethod |
822 |
823 |
def get_user_consent(): |
def get_user_consent(): |
|
... |
... |
class ContactWidget(pg.LayoutWidget): |
825 |
826 |
"Would you like to start Qhull anyway?" |
"Would you like to start Qhull anyway?" |
826 |
827 |
) == QtWidgets.QMessageBox.Yes |
) == QtWidgets.QMessageBox.Yes |
827 |
828 |
|
|
|
829 |
|
|
|
830 |
|
def get_qhull(self): |
|
831 |
|
try: |
|
832 |
|
return True, self.qframe |
|
833 |
|
except AttributeError: |
|
834 |
|
sample_box = self.w.get_sample_box() |
|
835 |
|
if (sample_box.nvar < 10) or self.get_user_consent(): |
|
836 |
|
sample_space = getattr(sample_box, self.w.space) |
|
837 |
|
self.qframe = wireframe.Qframe(sample_space) |
|
838 |
|
return True, self.qframe |
|
839 |
|
else: |
|
840 |
|
return False, None |
|
841 |
|
|
|
842 |
|
|
828 |
843 |
def check(self): |
def check(self): |
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) |
|
|
844 |
|
if self.get_qhull()[0]: |
833 |
845 |
with pg.ProgressDialog("Going over all the simplices..", 0, |
with pg.ProgressDialog("Going over all the simplices..", 0, |
834 |
846 |
self.qframe.nsimplex, cancelText='Stop', |
self.qframe.nsimplex, cancelText='Stop', |
835 |
847 |
busyCursor=True) as dlg: |
busyCursor=True) as dlg: |
836 |
848 |
self.dlg = dlg |
self.dlg = dlg |
837 |
849 |
self.qframe.generate_wireframe(self.qframe_callback) |
self.qframe.generate_wireframe(self.qframe_callback) |
838 |
|
self.condensed_qontacts = self.qframe.condensed_contacts |
|
839 |
|
self.show() |
|
|
850 |
|
if not self.dlg.wasCanceled(): |
|
851 |
|
self.condensed_qontacts = self.qframe.condensed_contacts |
|
852 |
|
self.show() |
840 |
853 |
|
|
841 |
854 |
|
|
842 |
855 |
|
|
843 |
856 |
def clear(self): |
def clear(self): |
844 |
857 |
self.condensed_contacts[:] = 0 |
self.condensed_contacts[:] = 0 |
845 |
858 |
try: |
try: |
846 |
|
del self.condensed_qontacts |
|
847 |
859 |
del self.qframe |
del self.qframe |
|
860 |
|
del self.condensed_qontacts |
848 |
861 |
except AttributeError: |
except AttributeError: |
849 |
862 |
pass |
pass |
850 |
863 |
|
|
|
... |
... |
class ContactWidget(pg.LayoutWidget): |
867 |
880 |
|
|
868 |
881 |
def _set_param(self): |
def _set_param(self): |
869 |
882 |
params = list() |
params = list() |
|
883 |
|
#č check_all ovlivňuje discover(). discover ho i kontroluje |
870 |
884 |
params.append({'name': 'check_all', 'title': 'all contacts', |
params.append({'name': 'check_all', 'title': 'all contacts', |
871 |
885 |
'type': 'bool', 'value': True, |
'type': 'bool', 'value': True, |
872 |
886 |
'tip': 'allows to skip "green" contacts'}) |
'tip': 'allows to skip "green" contacts'}) |
|
... |
... |
class ContactWidget(pg.LayoutWidget): |
878 |
892 |
'title': "method"}) |
'title': "method"}) |
879 |
893 |
|
|
880 |
894 |
params.append({'name': 'solver', 'title': "solver", 'type': 'list', 'value': 'convex_sprite', |
params.append({'name': 'solver', 'title': "solver", 'type': 'list', 'value': 'convex_sprite', |
881 |
|
'values': ['convex_solver', 'convex_spline', 'convex_sort', 'convex_sprite'], |
|
|
895 |
|
'values': ['convex_solver', 'convex_spline', 'convex_sort', 'convex_sprite', 'convex_slice'], |
882 |
896 |
'tip': "Versions from the earliest (the worst) to the latest (the best). Names have no any special meaning."}) |
'tip': "Versions from the earliest (the worst) to the latest (the best). Names have no any special meaning."}) |
883 |
897 |
|
|
884 |
898 |
params.append({'name': 'tries_to_fix', 'type': 'int', |
params.append({'name': 'tries_to_fix', 'type': 'int', |
|
... |
... |
class ContactWidget(pg.LayoutWidget): |
894 |
908 |
|
|
895 |
909 |
#č chlapi tomu svému stromu dali zabrat |
#č chlapi tomu svému stromu dali zabrat |
896 |
910 |
#č udělali i signaly |
#č udělali i signaly |
897 |
|
contact_finder = self.param.child('method') |
|
898 |
|
contact_finder.sigValueChanged.connect(self.method_changed) |
|
|
911 |
|
p = self.param.child('force_update') |
|
912 |
|
p.sigValueChanged.connect(self.check_method_changed) |
|
913 |
|
|
|
914 |
|
p = self.param.child('solver') |
|
915 |
|
p.sigValueChanged.connect(self.cs_solver_changed) |
|
916 |
|
|
|
917 |
|
p = self.param.child('method') |
|
918 |
|
p.sigValueChanged.connect(self.method_changed) |
|
919 |
|
|
|
920 |
|
|
|
921 |
|
p = self.param.child('tries_to_fix') |
|
922 |
|
p.sigValueChanged.connect(self.convex_paremeters_changed) |
|
923 |
|
|
|
924 |
|
p = self.param.child('tol') |
|
925 |
|
p.sigValueChanged.connect(self.convex_paremeters_changed) |
|
926 |
|
|
|
927 |
|
|
|
928 |
|
def convex_paremeters_changed(self, *args, **kwargs): |
|
929 |
|
self.kwargs['tries_to_fix'] = self.param.getValues()['tries_to_fix'][0] |
|
930 |
|
self.kwargs['tol'] = self.param.getValues()['tol'][0] |
|
931 |
|
|
|
932 |
|
|
|
933 |
|
def check_method_changed(self, parameter): |
|
934 |
|
if parameter.value(): |
|
935 |
|
self.check_contact = self.force_check_contact |
|
936 |
|
else: |
|
937 |
|
self.check_contact = self.peacefully_check_contact |
|
938 |
|
|
|
939 |
|
def cs_solver_changed(self, parameter): |
|
940 |
|
#č ale.. lezeme do vnítřku cizí třídy.. |
|
941 |
|
solver = getattr(wireframe, parameter.value()) |
|
942 |
|
self.CS.convex_solver = solver |
899 |
943 |
|
|
900 |
944 |
def method_changed(self, parameter): |
def method_changed(self, parameter): |
|
945 |
|
self.setup_CS() |
901 |
946 |
if parameter.value() == 'ConvexSolver': |
if parameter.value() == 'ConvexSolver': |
902 |
947 |
self.param.child('solver').show() |
self.param.child('solver').show() |
903 |
948 |
self.param.child('tries_to_fix').show() |
self.param.child('tries_to_fix').show() |
|
... |
... |
class ContactWidget(pg.LayoutWidget): |
911 |
956 |
def setup_CS(self): |
def setup_CS(self): |
912 |
957 |
sample_box = self.w.get_sample_box() |
sample_box = self.w.get_sample_box() |
913 |
958 |
sample_space = getattr(sample_box, self.w.space) |
sample_space = getattr(sample_box, self.w.space) |
914 |
|
self.kwargs.clear() |
|
915 |
|
|
|
916 |
959 |
|
|
|
960 |
|
#č kvůli Qhull se může stát, že budeme muset zachovat starý CS |
|
961 |
|
#č proto opatrně mažeme kwargs no a tak. |
917 |
962 |
method = self.param.child('method').value() |
method = self.param.child('method').value() |
918 |
963 |
if method == 'Qhull': |
if method == 'Qhull': |
919 |
|
self.CS = wireframe.Qframe(sample_space) |
|
|
964 |
|
status, qframe = self.get_qhull() |
|
965 |
|
if status: |
|
966 |
|
self.CS = qframe |
|
967 |
|
self.kwargs.clear() |
920 |
968 |
elif method == 'DirectContact': |
elif method == 'DirectContact': |
921 |
969 |
self.CS = wireframe.DirectContact(sample_space) |
self.CS = wireframe.DirectContact(sample_space) |
|
970 |
|
self.kwargs.clear() |
922 |
971 |
elif method == 'ConvexSolver': |
elif method == 'ConvexSolver': |
923 |
972 |
solver = getattr(wireframe, self.param.child('solver').value()) |
solver = getattr(wireframe, self.param.child('solver').value()) |
924 |
973 |
self.CS = wireframe.ConvexSolver(sample_space, convex_solver=solver) |
self.CS = wireframe.ConvexSolver(sample_space, convex_solver=solver) |
|
974 |
|
#self.kwargs.clear() #č aby se to neztratilo až bude 100500 metodů |
925 |
975 |
self.kwargs['tries_to_fix'] = self.param.getValues()['tries_to_fix'][0] |
self.kwargs['tries_to_fix'] = self.param.getValues()['tries_to_fix'][0] |
926 |
976 |
self.kwargs['tol'] = self.param.getValues()['tol'][0] |
self.kwargs['tol'] = self.param.getValues()['tol'][0] |
927 |
977 |
else: |
else: |
928 |
978 |
raise ValueError("ContactWidget: unknown method") |
raise ValueError("ContactWidget: unknown method") |
929 |
979 |
|
|
930 |
|
if self.param.getValues()['force_update'][0]: |
|
931 |
|
self.check_contact = self.force_check_contact |
|
932 |
|
else: |
|
933 |
|
self.check_contact = self.peacefully_check_contact |
|
|
980 |
|
|
934 |
981 |
|
|
935 |
982 |
|
|