Class: CameraDialog
- Inherits:
-
Qt::Dialog
- Object
- Qt::Base
- Qt::Dialog
- CameraDialog
- Defined in:
- ext/ruby/qtruby/examples/ruboids/ruboids/CameraDialog.rb
Instance Method Summary collapse
- #addSlider(row, box, layout, label, min, max, pageStep, slot, initialValue) ⇒ Object
- #cameraChanged ⇒ Object
-
#initialize(parent) ⇒ CameraDialog
constructor
A new instance of CameraDialog.
- #slotLocXChanged(val) ⇒ Object
- #slotLocYChanged(val) ⇒ Object
- #slotLocZChanged(val) ⇒ Object
- #slotReset ⇒ Object
- #slotRotationXChanged(val) ⇒ Object
- #slotRotationYChanged(val) ⇒ Object
- #slotRotationZChanged(val) ⇒ Object
- #slotZoomChanged(val) ⇒ Object
Methods inherited from Qt::Dialog
Methods inherited from Qt::Base
#%, #&, #*, #**, #+, #-, #-@, #/, #<, #<<, #<=, #==, #>, #>=, #>>, #QCOMPARE, #QEXPECT_FAIL, #QFAIL, #QSKIP, #QTEST, #QVERIFY, #QVERIFY2, #QWARN, #^, ancestors, #is_a?, #methods, private_slots, #protected_methods, #public_methods, q_classinfo, q_signal, q_slot, signals, #singleton_methods, slots, #|, #~
Constructor Details
#initialize(parent) ⇒ CameraDialog
Returns a new instance of CameraDialog.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/CameraDialog.rb', line 37 def initialize(parent) super @locAdjustors = [] @rotationAdjustors = [] @otherAdjustors = [] @avoidUpdates = false @camera = World.instance.camera # Remember values for reset @origCamera = @camera.dup() # Group and layout widgets vLayout = Qt::VBoxLayout.new(self) locBox = Qt::GroupBox.new('Location', self) rotationBox = Qt::GroupBox.new('Rotation', self) otherBox = Qt::GroupBox.new('Other', self) locLayout = Qt::GridLayout.new(locBox) rotationLayout = Qt::GridLayout.new(rotationBox) otherLayout = Qt::GridLayout.new(otherBox) = Qt::HBoxLayout.new() vLayout.addWidget(locBox) vLayout.addWidget(rotationBox) vLayout.addWidget(otherBox) vLayout.addSpacing(10) vLayout.addLayout() # Add extra space at the top of each layout so the group box title # doesn't get squished. # locLayout.addRowSpacing(0, 15) # rotationLayout.addRowSpacing(0, 15) # otherLayout.addRowSpacing(0, 15) # Contents of camera location box @locAdjustors << addSlider(1, locBox, locLayout, 'X', -1000, 1000, 1, 'slotLocXChanged(int)', @camera.position.x) @locAdjustors << addSlider(2, locBox, locLayout, 'Y', -1000, 1000, 1, 'slotLocYChanged(int)', @camera.position.y) @locAdjustors << addSlider(3, locBox, locLayout, 'Z', -1000, 1000, 1, 'slotLocZChanged(int)', @camera.position.z) # Contents of camera rotation box @rotationAdjustors << addSlider(1, rotationBox, rotationLayout, 'X', 0, 360, 1, 'slotRotationXChanged(int)', @camera.rotation.x) @rotationAdjustors << addSlider(2, rotationBox, rotationLayout, 'Y', 0, 360, 1, 'slotRotationYChanged(int)', @camera.rotation.y) @rotationAdjustors << addSlider(3, rotationBox, rotationLayout, 'Z', 0, 360, 1, 'slotRotationZChanged(int)', @camera.rotation.z) @otherAdjustors << addSlider(1, otherBox, otherLayout, 'Zoom', 1, 100, 1, 'slotZoomChanged(int)', @camera.zoom * 10.0) @otherAdjustors[0].origValue = @camera.zoom # The Close button = Qt::PushButton.new('Close', self) connect(, SIGNAL('clicked()'), self, SLOT('close()')) .setDefault(true) .setFixedSize(.sizeHint()) .addWidget() # The Close button = Qt::PushButton.new('Reset', self) connect(, SIGNAL('clicked()'), self, SLOT('slotReset()')) .setFixedSize(.sizeHint()) .addWidget() # 15 layout management locLayout.activate() rotationLayout.activate() otherLayout.activate() vLayout.activate() resize(0, 0) setWindowTitle('Camera Settings') end |
Instance Method Details
#addSlider(row, box, layout, label, min, max, pageStep, slot, initialValue) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/CameraDialog.rb', line 121 def addSlider(row, box, layout, label, min, max, pageStep, slot, initialValue) # Label text = Qt::Label.new(label, box) text.setMinimumSize(text.sizeHint()) layout.addWidget(text, row, 0) # Slider = Qt::Slider.new(Qt::Horizontal, box) do |s| s.range = min..max s. = initialValue s.pageStep = pageStep end .minimumSize = .sizeHint .minimumWidth = 180 layout.addWidget(, row, 1) # Connection from slider signal to our slot connect(, SIGNAL('valueChanged(int)'), self, SLOT(slot)) # Number display num = Qt::Label.new('XXXXX', box) num.setMinimumSize(num.sizeHint()) num.setFrameStyle(Qt::Frame::Panel | Qt::Frame::Sunken) num.setAlignment(Qt::AlignRight | Qt::AlignVCenter) num.setNum(initialValue) layout.addWidget(num, row, 2) return Adjustor.new(, num, initialValue) end |
#cameraChanged ⇒ Object
155 156 157 |
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/CameraDialog.rb', line 155 def cameraChanged World.instance.setupTranslation() unless @avoidUpdates end |
#slotLocXChanged(val) ⇒ Object
159 160 161 162 163 |
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/CameraDialog.rb', line 159 def slotLocXChanged(val) @locAdjustors[0].setNum(val) @camera.position.x = val cameraChanged() end |
#slotLocYChanged(val) ⇒ Object
165 166 167 168 169 |
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/CameraDialog.rb', line 165 def slotLocYChanged(val) @locAdjustors[1].setNum(val) @camera.position.y = val cameraChanged() end |
#slotLocZChanged(val) ⇒ Object
171 172 173 174 175 |
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/CameraDialog.rb', line 171 def slotLocZChanged(val) @locAdjustors[2].setNum(val) @camera.position.z = val cameraChanged() end |
#slotReset ⇒ Object
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/CameraDialog.rb', line 201 def slotReset @avoidUpdates = true @camera.position.x = @locAdjustors[0].reset() @camera.position.y = @locAdjustors[1].reset() @camera.position.z = @locAdjustors[2].reset() @camera.rotation.x = @rotationAdjustors[0].reset() @camera.rotation.y = @rotationAdjustors[1].reset() @camera.rotation.z = @rotationAdjustors[2].reset() @camera.zoom = @otherAdjustors[0].reset() @avoidUpdates = false cameraChanged() end |
#slotRotationXChanged(val) ⇒ Object
177 178 179 180 181 |
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/CameraDialog.rb', line 177 def slotRotationXChanged(val) @rotationAdjustors[0].setNum(val) @camera.rotation.x = val cameraChanged() end |
#slotRotationYChanged(val) ⇒ Object
183 184 185 186 187 |
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/CameraDialog.rb', line 183 def slotRotationYChanged(val) @rotationAdjustors[1].setNum(val) @camera.rotation.y = val cameraChanged() end |
#slotRotationZChanged(val) ⇒ Object
189 190 191 192 193 |
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/CameraDialog.rb', line 189 def slotRotationZChanged(val) @rotationAdjustors[2].setNum(val) @camera.rotation.z = val cameraChanged() end |
#slotZoomChanged(val) ⇒ Object
195 196 197 198 199 |
# File 'ext/ruby/qtruby/examples/ruboids/ruboids/CameraDialog.rb', line 195 def slotZoomChanged(val) @otherAdjustors[0].setNum(val) @camera.zoom = val / 10.0 cameraChanged() end |