Class: UniqPin
- Inherits:
-
Object
- Object
- UniqPin
- Defined in:
- lib/class/Wire_helper.rb
Overview
UniqPin - Contain all data linked to one pin on the graphic
Instance Method Summary collapse
-
#initialize(scene, pinNum, pinChip, xSig, ySig, xNum, yNum, xRect, yRect, wRect, hRect, rotation, api) ⇒ UniqPin
constructor
A new instance of UniqPin.
- #setColor ⇒ Object
- #unsetColor ⇒ Object
Constructor Details
#initialize(scene, pinNum, pinChip, xSig, ySig, xNum, yNum, xRect, yRect, wRect, hRect, rotation, api) ⇒ UniqPin
Returns a new instance of UniqPin.
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/class/Wire_helper.rb', line 187 def initialize(scene, pinNum, pinChip, xSig, ySig, xNum, yNum, xRect, yRect, wRect, hRect, rotation, api) currentPin = Pin.where(pin_number: pinNum, pin_chip: pinChip).pluck(:pin_signal)[0] currentSignal = Signall.where(signal_id: currentPin).pluck(:signal_name)[0] # Set the signal id @signalId = currentSignal @api = api # Signal text @signalTxt = CustomItem.new(currentSignal) @signalTxt.cursor = Qt::Cursor.new(Qt::PointingHandCursor) @signalTxt.setPin(self) @signalTxt.setTextInteractionFlags(Qt::TextSelectableByMouse) @signalTxt.setX(xSig) @signalTxt.setY(ySig) if rotation @signalTxt.rotation = 270.00 end scene.addItem(@signalTxt) # Number text @nbrTxt = CustomItem.new(pinNum.to_s) @nbrTxt.cursor = Qt::Cursor.new(Qt::PointingHandCursor) @nbrTxt.setPin(self) @nbrTxt.setTextInteractionFlags(Qt::TextSelectableByMouse) @nbrTxt.setX(xNum) @nbrTxt.setY(yNum) if rotation @nbrTxt.rotation = 270.00 end scene.addItem(@nbrTxt) # Pin graphic @pinGraphItem = scene.addRect(xRect, yRect, wRect, hRect) end |
Instance Method Details
#setColor ⇒ Object
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/class/Wire_helper.rb', line 222 def setColor # Colors @on = Qt::Color.new(0, 0, 255) @off = Qt::Color.new(0, 0, 0) # Disable the pin if a pin is already enabled unless $pinEnabled.nil? $pinEnabled.unsetColor end # Light the new pin @nbrTxt.setDefaultTextColor(@on) @signalTxt.setDefaultTextColor(@on) @bold = Qt::Font.new @bold.setBold(true) @signalTxt.setFont(@bold) $pinEnabled = self end |
#unsetColor ⇒ Object
239 240 241 242 243 244 |
# File 'lib/class/Wire_helper.rb', line 239 def unsetColor @nbrTxt.setDefaultTextColor(@off) @signalTxt.setDefaultTextColor(@off) @bold.setBold(false) @signalTxt.setFont(@bold) end |