Esempio n. 1
0
    def __init__(self, visualizer, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle("Force Vector Visualization")
        layout = QtGui.QGridLayout()
        layout.setColumnStretch(0, 0)
        layout.setColumnStretch(1, 1)

        row = 0

        # Magnitude representation
        layout.addWidget(QtGui.QLabel("Magnitude representation"), row, 0)
        self.magnitude_mode = QtGui.QComboBox()
        modes = ContactVisModes.get_modes()
        mode_labels = [ContactVisModes.get_mode_string(m) for m in modes]
        self.magnitude_mode.addItems(mode_labels)
        self.magnitude_mode.setCurrentIndex(visualizer.magnitude_mode)
        mode_tool_tip = 'Determines how force magnitude is visualized:\n'
        for m in modes:
            mode_tool_tip += '  - {}: {}\n'.format(
                ContactVisModes.get_mode_string(m),
                ContactVisModes.get_mode_docstring(m))
        self.magnitude_mode.setToolTip(mode_tool_tip)
        layout.addWidget(self.magnitude_mode, row, 1)
        row += 1

        # Global scale.
        layout.addWidget(QtGui.QLabel("Global scale"), row, 0)
        self.global_scale = QtGui.QLineEdit()
        self.global_scale.setToolTip(
            'All visualized forces are multiplied by this scale factor (must '
            'be non-negative)')
        validator = QtGui.QDoubleValidator(0, 100, 3, self.global_scale)
        validator.setNotation(QtGui.QDoubleValidator.StandardNotation)
        self.global_scale.setValidator(validator)
        self.global_scale.setText("{:.3f}".format(visualizer.global_scale))
        layout.addWidget(self.global_scale, row, 1)
        row += 1

        # Magnitude cut-off.
        layout.addWidget(QtGui.QLabel("Minimum force"), row, 0)
        self.min_magnitude = QtGui.QLineEdit()
        self.min_magnitude.setToolTip('Forces with a magnitude less than this '
                                      'value will not be visualized (must be '
                                      '> 1e-10)')
        validator = QtGui.QDoubleValidator(1e-10, 100, 10, self.min_magnitude)
        validator.setNotation(QtGui.QDoubleValidator.StandardNotation)
        self.min_magnitude.setValidator(validator)
        self.min_magnitude.setText("{:.3g}".format(visualizer.min_magnitude))
        layout.addWidget(self.min_magnitude, row, 1)
        row += 1

        # Accept/cancel.
        btns = QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel
        buttons = QtGui.QDialogButtonBox(btns, QtCore.Qt.Horizontal, self)
        buttons.connect('accepted()', self.accept)
        buttons.connect('rejected()', self.reject)
        layout.addWidget(buttons, row, 0, 1, 2)

        self.setLayout(layout)
Esempio n. 2
0
    def showDialog(self):

        self.d = QtGui.QDialog()

        buttons = QtGui.QDialogButtonBox()
        buttons.addButton('Yes', QtGui.QDialogButtonBox.AcceptRole)
        buttons.addButton('No', QtGui.QDialogButtonBox.RejectRole)
        buttons.connect('accepted()', self.d.accept)
        buttons.connect('rejected()', self.d.reject)

        l = QtGui.QVBoxLayout(self.d)
        l.addWidget(QtGui.QLabel(self.properties.message))
        l.addWidget(buttons)

        self.d.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
        self.d.show()
        self.d.raise_()
        self.d.connect('accepted()', self.accept)
        self.d.connect('rejected()', self.reject)
Esempio n. 3
0
    def showDialog(self):

        self.d = QtGui.QDialog()

        buttons = QtGui.QDialogButtonBox()
        buttons.addButton("Yes", QtGui.QDialogButtonBox.AcceptRole)
        buttons.addButton("No", QtGui.QDialogButtonBox.RejectRole)
        buttons.connect("accepted()", self.d.accept)
        buttons.connect("rejected()", self.d.reject)

        l = QtGui.QVBoxLayout(self.d)
        l.addWidget(QtGui.QLabel(self.message))
        l.addWidget(buttons)

        self.d.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
        self.d.show()
        self.d.raise_()
        self.d.connect("accepted()", self.onYes)
        self.d.connect("rejected()", self.onNo)
    def __init__(self,
                 visualizer,
                 show_contact_edges_state,
                 show_pressure_state,
                 show_spatial_force_state,
                 show_traction_vectors_state,
                 show_slip_velocity_vectors_state,
                 max_pressure_observed,
                 reset_max_pressure_observed_functor,
                 parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle('Hydroelastic contact visualization settings')
        self.reset_max_pressure_observed_functor = \
            reset_max_pressure_observed_functor
        layout = QtGui.QGridLayout()
        layout.setColumnStretch(0, 0)
        layout.setColumnStretch(1, 1)

        row = 0

        # Color map selection.
        layout.addWidget(QtGui.QLabel('Color map'), row, 0)
        self.color_map_mode = QtGui.QComboBox()
        modes = ColorMapModes.get_modes()
        mode_labels = [ColorMapModes.get_mode_string(m) for m in modes]
        self.color_map_mode.addItems(mode_labels)
        self.color_map_mode.setCurrentIndex(visualizer.color_map_mode)
        mode_tool_tip = 'Determines the mapping from pressures to colors:\n'
        for m in modes:
            mode_tool_tip += '  - {}: {}\n'.format(
                ColorMapModes.get_mode_string(m),
                ColorMapModes.get_mode_docstring(m))
        self.color_map_mode.setToolTip(mode_tool_tip)
        layout.addWidget(self.color_map_mode, row, 1)
        row += 1

        # Minimum pressure.
        layout.addWidget(QtGui.QLabel('Minimum pressure'), row, 0)
        self.min_pressure = QtGui.QLineEdit()
        self.min_pressure.setToolTip('Pressures at or less than this value '
                                     'will be visualized as the color defined'
                                     ' at the minimum value of the color map '
                                     '(must be at least zero).')
        self.min_pressure_validator = QtGui.QDoubleValidator(
            0, 1e20, 2, self.min_pressure)
        self.min_pressure_validator.setNotation(
            QtGui.QDoubleValidator.ScientificNotation)
        self.min_pressure.setValidator(self.min_pressure_validator)
        self.min_pressure.setText('{:.3g}'.format(visualizer.min_pressure))
        # TODO(seancurtis-TRI) This is supposed to automatically update max
        # pressure. However, changing min pressure to be larger and then
        # tabbing out of the widget doesn't necessarily send the
        # editingFinished signal (whether it is sent appears to be arbitrary).
        # We need to figure this out before we make a modeless configuration
        # panel.
        self.min_pressure.editingFinished.connect(self.update_max_validator)
        layout.addWidget(self.min_pressure, row, 1)
        row += 1

        # Maximum pressure.
        layout.addWidget(QtGui.QLabel('Maximum pressure'), row, 0)
        self.max_pressure = QtGui.QLineEdit()
        self.max_pressure.setToolTip('Pressures at or greater than this value '
                                     'will be visualized as the color defined'
                                     ' at the maximum value of the color map.')
        self.max_pressure_validator = QtGui.QDoubleValidator(
            0, 1e20, 2, self.max_pressure)
        self.max_pressure_validator.setNotation(
            QtGui.QDoubleValidator.ScientificNotation)
        self.max_pressure.setValidator(self.max_pressure_validator)
        self.max_pressure.setText('{:.3g}'.format(visualizer.max_pressure))
        self.max_pressure.editingFinished.connect(self.update_min_validator)
        layout.addWidget(self.max_pressure, row, 1)
        row += 1

        # Whether to show pressure.
        layout.addWidget(QtGui.QLabel('Render contact surface with pressure'),
                         row, 0)
        self.show_pressure = QtGui.QCheckBox()
        self.show_pressure.setChecked(show_pressure_state)
        self.show_pressure.setToolTip('Renders filled-in polygons with '
                                      'interior coloring representing '
                                      'pressure using the given color map.')
        layout.addWidget(self.show_pressure, row, 1)
        row += 1

        # Whether to show the contact surface as a wireframe.
        layout.addWidget(QtGui.QLabel('Render contact surface wireframe'), row,
                         0)
        self.show_contact_edges = QtGui.QCheckBox()
        self.show_contact_edges.setChecked(show_contact_edges_state)
        self.show_contact_edges.setToolTip('Renders the edges of the '
                                           'contact surface.')
        layout.addWidget(self.show_contact_edges, row, 1)
        row += 1

        # Whether to show the force and moment vectors.
        layout.addWidget(QtGui.QLabel('Render contact forces and moments'),
                         row, 0)
        self.show_spatial_force = QtGui.QCheckBox()
        self.show_spatial_force.setChecked(show_spatial_force_state)
        self.show_spatial_force.setToolTip('Renders the contact forces (in '
                                           'red) and moments (in blue)')
        layout.addWidget(self.show_spatial_force, row, 1)
        row += 1

        # Whether to show the per-quadrature-point traction vectors.
        layout.addWidget(QtGui.QLabel('Render traction vectors'), row, 0)
        self.show_traction_vectors = QtGui.QCheckBox()
        self.show_traction_vectors.setChecked(show_traction_vectors_state)
        self.show_traction_vectors.setToolTip('Renders the traction vectors '
                                              '(per quadrature point) in '
                                              'magenta')
        layout.addWidget(self.show_traction_vectors, row, 1)
        row += 1

        # Whether to show the per-quadrature-point slip velocity vectors.
        layout.addWidget(QtGui.QLabel('Render slip velocity vectors'), row, 0)
        self.show_slip_velocity_vectors = QtGui.QCheckBox()
        self.show_slip_velocity_vectors.setChecked(
            show_slip_velocity_vectors_state)
        self.show_slip_velocity_vectors.setToolTip('Renders the slip velocity '
                                                   'vectors (per quadrature '
                                                   'point) in cyan')
        layout.addWidget(self.show_slip_velocity_vectors, row, 1)
        row += 1

        # The maximum pressure value recorded and a button to reset it.
        self.pressure_value_label = QtGui.QLabel(
            'Maximum pressure value observed: {:.5e}'.format(
                max_pressure_observed))
        layout.addWidget(self.pressure_value_label, row, 0)
        reset_button = QtGui.QPushButton('Reset max observed pressure')
        reset_button.connect('clicked()', self.reset_max_pressure_observed)
        layout.addWidget(reset_button, row, 1)
        row += 1

        # Accept/cancel.
        btns = QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel
        buttons = QtGui.QDialogButtonBox(btns, QtCore.Qt.Horizontal, self)
        buttons.connect('accepted()', self.accept)
        buttons.connect('rejected()', self.reject)
        layout.addWidget(buttons, row, 0, 1, 2)

        self.setLayout(layout)
    def __init__(self, visualizer, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle('Hydroelastic contact visualization settings')
        self.reset_max_pressure_observed_functor = \
            visualizer.reset_max_pressure_observed
        layout = QtGui.QGridLayout()
        layout.setColumnStretch(0, 0)
        layout.setColumnStretch(1, 1)

        row = 0

        # Color map selection.
        layout.addWidget(QtGui.QLabel('Color map'), row, 0)
        self.color_map_mode = QtGui.QComboBox()
        modes = ColorMapModes.get_modes()
        mode_labels = [ColorMapModes.get_mode_string(m) for m in modes]
        self.color_map_mode.addItems(mode_labels)
        self.color_map_mode.setCurrentIndex(visualizer.color_map_mode)
        mode_tool_tip = 'Determines the mapping from pressures to colors:\n'
        for m in modes:
            mode_tool_tip += '  - {}: {}\n'.format(
                ColorMapModes.get_mode_string(m),
                ColorMapModes.get_mode_docstring(m))
        self.color_map_mode.setToolTip(mode_tool_tip)
        layout.addWidget(self.color_map_mode, row, 1)
        row += 1

        # Minimum pressure.
        layout.addWidget(QtGui.QLabel('Minimum pressure'), row, 0)
        self.min_pressure = QtGui.QLineEdit()
        self.min_pressure.setToolTip('Pressures at or less than this value '
                                     'will be visualized as the color defined'
                                     ' at the minimum value of the color map '
                                     '(must be at least zero).')
        self.min_pressure_validator = QtGui.QDoubleValidator(
            0, 1e20, 2, self.min_pressure)
        self.min_pressure_validator.setNotation(
            QtGui.QDoubleValidator.ScientificNotation)
        self.min_pressure.setValidator(self.min_pressure_validator)
        self.min_pressure.setText('{:.3g}'.format(visualizer.min_pressure))
        # TODO(seancurtis-TRI) This is supposed to automatically update max
        # pressure. However, changing min pressure to be larger and then
        # tabbing out of the widget doesn't necessarily send the
        # editingFinished signal (whether it is sent appears to be arbitrary).
        # We need to figure this out before we make a modeless configuration
        # panel.
        self.min_pressure.editingFinished.connect(self.update_max_validator)
        layout.addWidget(self.min_pressure, row, 1)
        row += 1

        # Maximum pressure.
        layout.addWidget(QtGui.QLabel('Maximum pressure'), row, 0)
        self.max_pressure = QtGui.QLineEdit()
        self.max_pressure.setToolTip('Pressures at or greater than this value '
                                     'will be visualized as the color defined'
                                     ' at the maximum value of the color map.')
        self.max_pressure_validator = QtGui.QDoubleValidator(
            0, 1e20, 2, self.max_pressure)
        self.max_pressure_validator.setNotation(
            QtGui.QDoubleValidator.ScientificNotation)
        self.max_pressure.setValidator(self.max_pressure_validator)
        self.max_pressure.setText('{:.3g}'.format(visualizer.max_pressure))
        self.max_pressure.editingFinished.connect(self.update_min_validator)
        layout.addWidget(self.max_pressure, row, 1)
        row += 1

        # Whether to show pressure.
        layout.addWidget(QtGui.QLabel('Render contact surface with pressure'),
                         row, 0)
        self.show_pressure = QtGui.QCheckBox()
        self.show_pressure.setChecked(visualizer.show_pressure)
        self.show_pressure.setToolTip('Renders filled-in polygons with '
                                      'interior coloring representing '
                                      'pressure using the given color map.')
        layout.addWidget(self.show_pressure, row, 1)
        row += 1

        # Whether to show the contact surface as a wireframe.
        layout.addWidget(QtGui.QLabel('Render contact surface wireframe'), row,
                         0)
        self.show_contact_edges = QtGui.QCheckBox()
        self.show_contact_edges.setChecked(visualizer.show_contact_edges)
        self.show_contact_edges.setToolTip('Renders the edges of the '
                                           'contact surface.')
        layout.addWidget(self.show_contact_edges, row, 1)
        row += 1

        contact_data_grp = QtGui.QGroupBox("Contact data")
        contact_layout = QtGui.QGridLayout()
        contact_data_grp.setLayout(contact_layout)
        contact_layout.setColumnStretch(0, 0)
        contact_layout.setColumnStretch(1, 1)
        contact_row = 0
        layout.addWidget(contact_data_grp, row, 0, 1, 2)
        row += 1

        # Whether to show the force and moment vectors.
        contact_layout.addWidget(
            QtGui.QLabel('Render contact force and moment '
                         'vectors'), contact_row, 0)
        self.show_spatial_force = QtGui.QCheckBox()
        self.show_spatial_force.setChecked(visualizer.show_spatial_force)
        self.show_spatial_force.setToolTip('Renders the contact forces (in '
                                           'red) and moments (in blue)')
        contact_layout.addWidget(self.show_spatial_force, contact_row, 1)
        contact_row += 1

        # Whether to show the per-quadrature-point traction vectors.
        contact_layout.addWidget(QtGui.QLabel('Render traction vectors'),
                                 contact_row, 0)
        self.show_traction_vectors = QtGui.QCheckBox()
        self.show_traction_vectors.setChecked(visualizer.show_traction_vectors)
        self.show_traction_vectors.setToolTip('Renders the traction vectors '
                                              '(per quadrature point) in '
                                              'magenta')
        contact_layout.addWidget(self.show_traction_vectors, contact_row, 1)
        contact_row += 1

        # Whether to show the per-quadrature-point slip velocity vectors.
        contact_layout.addWidget(QtGui.QLabel('Render slip velocity vectors'),
                                 contact_row, 0)
        self.show_slip_velocity_vectors = QtGui.QCheckBox()
        self.show_slip_velocity_vectors.setChecked(
            visualizer.show_slip_velocity_vectors)
        self.show_slip_velocity_vectors.setToolTip('Renders the slip velocity '
                                                   'vectors (per quadrature '
                                                   'point) in cyan')
        contact_layout.addWidget(self.show_slip_velocity_vectors, contact_row,
                                 1)
        contact_row += 1

        # TODO(DamrongGuoy): The following three widgets "Magnitude
        #  representation", "Global scale", and "Magnitude cut-off" are copied
        #  and modified from show_point_pair_contact.py _ContactConfigDialog().
        #  We should have both show_hydroelastic_contact.py and
        #  show_point_pair_contact.py share the code instead of duplication.
        #  Furthermore, we should have this setting for each of force, moment,
        #  traction, and slip vectors. See issue #14680.

        # Magnitude representation
        layout.addWidget(QtGui.QLabel("Vector scaling mode"), row, 0)
        self.magnitude_mode = QtGui.QComboBox()
        modes = ContactVisModes.get_modes()
        mode_labels = [ContactVisModes.get_mode_string(m) for m in modes]
        self.magnitude_mode.addItems(mode_labels)
        self.magnitude_mode.setCurrentIndex(visualizer.magnitude_mode)
        mode_tool_tip = 'Determines how the magnitude of all hydroelastic ' \
                        'vector quantities are visualized:\n'
        for m in modes:
            mode_tool_tip += '  - {}: {}\n'.format(
                ContactVisModes.get_mode_string(m),
                ContactVisModes.get_mode_docstring(m))
        self.magnitude_mode.setToolTip(mode_tool_tip)
        layout.addWidget(self.magnitude_mode, row, 1)
        row += 1

        # Global scale.
        layout.addWidget(QtGui.QLabel("Global scale of all vectors"), row, 0)
        self.global_scale = QtGui.QLineEdit()
        self.global_scale.setToolTip(
            'All visualized vectors are multiplied by this scale factor (must '
            'be non-negative and at most 100). It is dimensionless.')
        validator = QtGui.QDoubleValidator(0, 100, 3, self.global_scale)
        validator.setNotation(QtGui.QDoubleValidator.StandardNotation)
        self.global_scale.setValidator(validator)
        self.global_scale.setText("{:.3f}".format(visualizer.global_scale))
        layout.addWidget(self.global_scale, row, 1)
        row += 1

        # Magnitude cut-off.
        layout.addWidget(QtGui.QLabel("Minimum vector"), row, 0)
        self.min_magnitude = QtGui.QLineEdit()
        self.min_magnitude.setToolTip('Vectors with a magnitude less than '
                                      'this value will not be visualized '
                                      '(must be > 1e-10 and at most 100')
        validator = QtGui.QDoubleValidator(1e-10, 100, 10, self.min_magnitude)
        validator.setNotation(QtGui.QDoubleValidator.StandardNotation)
        self.min_magnitude.setValidator(validator)
        self.min_magnitude.setText("{:.3g}".format(visualizer.min_magnitude))
        layout.addWidget(self.min_magnitude, row, 1)
        row += 1

        # The maximum pressure value recorded and a button to reset it.
        self.pressure_value_label = QtGui.QLabel(
            'Maximum pressure value observed: {:.5e}'.format(
                visualizer.max_pressure_observed))
        layout.addWidget(self.pressure_value_label, row, 0)
        reset_button = QtGui.QPushButton('Reset max observed pressure')
        reset_button.connect('clicked()', self.reset_max_pressure_observed)
        layout.addWidget(reset_button, row, 1)
        row += 1

        # Accept/cancel.
        btns = QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel
        buttons = QtGui.QDialogButtonBox(btns, QtCore.Qt.Horizontal, self)
        buttons.connect('accepted()', self.accept)
        buttons.connect('rejected()', self.reject)
        layout.addWidget(buttons, row, 0, 1, 2)

        self.setLayout(layout)