@@ -71,6 +71,16 @@ def __init__(self, meshcat_provider, parent=None, dataset_loaded=False):
71
71
self .ui .robotModelToolButton .clicked .connect (self .open_urdf_file )
72
72
self .ui .packageDirToolButton .clicked .connect (self .open_package_directory )
73
73
74
+ # Force the arrowScaling_lineEdit to be a positive float
75
+ self .ui .arrowScaling_lineEdit .setValidator (QtGui .QDoubleValidator (0 , 100 , 2 ))
76
+
77
+ # connect the arrowScaling_checkBox to the handle_arrow_scaling method
78
+ self .ui .arrowScaling_checkBox .toggled .connect (self .handle_arrow_scaling )
79
+
80
+ self .clicked_button = None
81
+ self .std_button = None
82
+ self .ui .buttonBox .clicked .connect (self .buttonBox_on_click )
83
+
74
84
if dataset_loaded :
75
85
frames = meshcat_provider .robot_frames ()
76
86
self .ui .frameNameComboBox .addItems (frames )
@@ -93,7 +103,33 @@ def get_urdf_path(self):
93
103
94
104
def get_package_directory (self ):
95
105
return self .ui .packageDirLineEdit .text ()
106
+
107
+ def buttonBox_on_click (self , button ):
108
+ self .clicked_button = button
109
+
110
+ self .std_button = self .ui .buttonBox .standardButton (button )
96
111
112
+ def get_clicked_button_role (self ):
113
+ if self .clicked_button is not None :
114
+ return self .ui .buttonBox .buttonRole (self .clicked_button )
115
+ return None
116
+
117
+ def get_clicked_button_text (self ):
118
+ if self .clicked_button is not None :
119
+ return self .clicked_button .text ()
120
+ return None
121
+
122
+ def get_clicked_standard_button (self ):
123
+ return self .std_button
124
+
125
+ def handle_arrow_scaling (self ):
126
+ # if arrowScaling_checkBox is checked the lineEdit must be disabled else it must be enabled
127
+ if self .ui .arrowScaling_checkBox .isChecked ():
128
+ self .ui .arrowScaling_lineEdit .setText ("" )
129
+ self .ui .arrowScaling_lineEdit .setEnabled (False )
130
+ else :
131
+ self .ui .arrowScaling_lineEdit .setText ("" )
132
+ self .ui .arrowScaling_lineEdit .setEnabled (True )
97
133
98
134
class About (QtWidgets .QMainWindow ):
99
135
def __init__ (self ):
@@ -682,9 +718,45 @@ def open_set_robot_model(self):
682
718
)
683
719
outcome = dlg .exec ()
684
720
if outcome == QDialog .Accepted :
685
- if not self .dataset_loaded :
686
- self .meshcat_provider .model_path = dlg .get_urdf_path ()
687
- self .meshcat_provider .custom_package_dir = dlg .get_package_directory ()
721
+
722
+ # check which button was clicked
723
+ button_role = dlg .get_clicked_button_role ()
724
+ button_text = dlg .get_clicked_button_text ()
725
+ std_button = dlg .get_clicked_standard_button ()
726
+
727
+ if std_button == QtWidgets .QDialogButtonBox .SaveAll :
728
+ if not self .dataset_loaded :
729
+ self .meshcat_provider .model_path = dlg .get_urdf_path ()
730
+ self .meshcat_provider .custom_package_dir = dlg .get_package_directory ()
731
+
732
+
733
+ arrow_scaling_value = dlg .ui .arrowScaling_lineEdit .text ()
734
+ if not arrow_scaling_value :
735
+ arrow_scaling_value = "1.0"
736
+ else :
737
+ arrow_scaling_value = float (arrow_scaling_value )
738
+ self .signal_provider .set_custom_max_arrow (
739
+ not dlg .ui .arrowScaling_checkBox .isChecked (),
740
+ arrow_scaling_value
741
+ )
742
+ if std_button == QtWidgets .QDialogButtonBox .Save :
743
+ # we need to check which tab is selected in the dlg
744
+ if dlg .ui .tabWidget .currentIndex () == 0 :
745
+ if not self .dataset_loaded :
746
+ self .meshcat_provider .model_path = dlg .get_urdf_path ()
747
+ self .meshcat_provider .custom_package_dir = dlg .get_package_directory ()
748
+ else :
749
+ arrow_scaling_value = dlg .ui .arrowScaling_lineEdit .text ()
750
+ # if it is empty we set it to 1.0
751
+ if not arrow_scaling_value :
752
+ arrow_scaling_value = "1.0"
753
+ else :
754
+ arrow_scaling_value = float (arrow_scaling_value )
755
+ self .signal_provider .set_custom_max_arrow (
756
+ not dlg .ui .arrowScaling_checkBox .isChecked (),
757
+ arrow_scaling_value
758
+ )
759
+
688
760
else :
689
761
self .meshcat_provider .load_model (
690
762
self .signal_provider .joints_name ,
0 commit comments