Class: UniqPin

Inherits:
Object
  • Object
show all
Defined in:
lib/class/Wire_helper.rb

Overview

UniqPin - Contain all data linked to one pin on the graphic

Instance Method Summary collapse

Constructor Details

#initialize(scene, pinNum, pinChip, xSig, ySig, xNum, yNum, xRect, yRect, wRect, hRect, rotation) ⇒ UniqPin

Returns a new instance of UniqPin.



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/class/Wire_helper.rb', line 186

def initialize(scene, pinNum, pinChip, xSig, ySig, xNum, yNum, xRect, yRect, wRect, hRect, rotation)
  signal_name = Pin.find_by(number: pinNum, chip_id: pinChip).signall
  @signalTxt = CustomItem.new(signal_name.name)
  @signalTxt.cursor = Qt::Cursor.new(Qt::PointingHandCursor)
  @signalTxt.setPin(self, signal_name)
  @signalTxt.setTextInteractionFlags(Qt::TextSelectableByMouse)
  @signalTxt.setX(xSig)
  @signalTxt.setY(ySig)
  @signalTxt.rotation = 270.00 if rotation
  scene.addItem(@signalTxt)

  @nbrTxt = CustomItem.new(pinNum.to_s)
  @nbrTxt.cursor = Qt::Cursor.new(Qt::PointingHandCursor)
  @nbrTxt.setPin(self, pinNum.to_s)
  @nbrTxt.setTextInteractionFlags(Qt::TextSelectableByMouse)
  @nbrTxt.setX(xNum)
  @nbrTxt.setY(yNum)
  @nbrTxt.rotation = 270.00 if rotation
  scene.addItem(@nbrTxt)
  @pinGraphItem = scene.addRect(xRect, yRect, wRect, hRect)
end

Instance Method Details

#setColorObject



208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/class/Wire_helper.rb', line 208

def setColor
  # Colors
  @on = Qt::Color.new(0, 0, 255)
  @off = Qt::Color.new(0, 0, 0)
  # Disable the pin if another pin is already enabled
  $pinEnabled.unsetColor unless $pinEnabled.nil?
  # Light the new pin
  @nbrTxt.setDefaultTextColor(@on)
  @signalTxt.setDefaultTextColor(@on)
  @bold = Qt::Font.new
  @bold.setBold(true)
  @signalTxt.setFont(@bold)
  $pinEnabled = self
end

#unsetColorObject



223
224
225
226
227
228
# File 'lib/class/Wire_helper.rb', line 223

def unsetColor
  @nbrTxt.setDefaultTextColor(@off)
  @signalTxt.setDefaultTextColor(@off)
  @bold.setBold(false)
  @signalTxt.setFont(@bold)
end