class TransformEditor
Edition class for the transformer. We aren't using Rock's default RigidBodyStateEditor because it is really way too bloated
Attributes
producer[R]
rotation[R]
rotation_editors[R]
source_frame[R]
target_frame[R]
translation[R]
translation_editors[R]
Public Class Methods
new(producer, source_frame, target_frame, parent = nil)
click to toggle source
Calls superclass method
# File bin/rock-transformer, line 15 def initialize(producer, source_frame, target_frame, parent = nil) super(parent) @producer = producer @source_frame = source_frame @target_frame = target_frame @translation = [0, 0, 0] @rotation = [0, 0, 0] create_ui update(translation_vector, rotation_quat) end
Public Instance Methods
create_ui()
click to toggle source
# File bin/rock-transformer, line 34 def create_ui header = Qt::VBoxLayout.new(self) layout.add_widget Qt::Label.new("<b>Producer</b>: #{producer}") layout.add_widget Qt::Label.new("<b>Source</b>: #{source_frame}") layout.add_widget Qt::Label.new("<b>Target</b>: #{target_frame}") layout = Qt::GridLayout.new layout.add_widget Qt::Label.new("<b>Translation</b>"), 0, 0, 1, 2 layout.add_widget(Qt::Label.new("X"), 1, 0) layout.add_widget(Qt::Label.new("Y"), 2, 0) layout.add_widget(Qt::Label.new("Z"), 3, 0) @translation_editors = Array.new layout.add_widget(translation_editors[0] = Qt::DoubleSpinBox.new, 1, 1) layout.add_widget(translation_editors[1] = Qt::DoubleSpinBox.new, 2, 1) layout.add_widget(translation_editors[2] = Qt::DoubleSpinBox.new, 3, 1) layout.add_widget Qt::Label.new("<b>Rotation</b>"), 0, 2, 1, 2 layout.add_widget(Qt::Label.new("X"), 1, 2) layout.add_widget(Qt::Label.new("Y"), 2, 2) layout.add_widget(Qt::Label.new("Z"), 3, 2) @rotation_editors = Array.new layout.add_widget(rotation_editors[0] = Qt::SpinBox.new, 1, 3) layout.add_widget(rotation_editors[1] = Qt::SpinBox.new, 2, 3) layout.add_widget(rotation_editors[2] = Qt::SpinBox.new, 3, 3) header.add_layout(layout) translation_editors.each_with_index do |editor, editor_idx| editor.minimum = -10_000 editor.maximum = 10_000 editor.single_step = 0.1 editor.connect(SIGNAL('valueChanged(double)')) do |value| translation[editor_idx] = value emit valueChanged(translation_vector, rotation_quat) end end rotation_editors.each_with_index do |editor, editor_idx| editor.minimum = -180 editor.maximum = 180 editor.single_step = 1 editor.connect(SIGNAL('valueChanged(int)')) do |value| rotation[editor_idx] = value * Math::PI / 180 emit valueChanged(translation_vector, rotation_quat) end end end
rotation_quat()
click to toggle source
# File bin/rock-transformer, line 30 def rotation_quat Eigen::Quaternion.from_euler(Eigen::Vector3.new(*rotation.reverse), 2, 1, 0).to_qt end
translation_vector()
click to toggle source
# File bin/rock-transformer, line 26 def translation_vector Qt::Vector3D.new(*translation) end
update(translation, rotation)
click to toggle source
# File bin/rock-transformer, line 84 def update(translation, rotation) self.translation_editors[0].setValue(translation.x) self.translation_editors[1].setValue(translation.y) self.translation_editors[2].setValue(translation.z) yaw, pitch, roll = *Eigen::Quaternion.new(rotation.scalar, rotation.x, rotation.y, rotation.z).to_euler.to_a self.rotation_editors[0].setValue(yaw * 180 / Math::PI) self.rotation_editors[1].setValue(pitch * 180 / Math::PI) self.rotation_editors[2].setValue(roll * 180 / Math::PI) end