PySimEd:Building own components

Z kiwiki
Prejsť na: navigácia, hľadanie

The part of a diagram are methods for creating custom user-defined components. The following example demonstrates creating user defined simple graphical component - resistor:

class Resistor(Component):
    def __init__(self, name, pos):
        Component.__init__(self, name, pos)
 
        self.compType   = TYPE_SPICE
        self.box        = QRectF(-40, -10, 80, 20)
        self.addParameter('Ref',  'R',  True, QPointF(  0,-15), Color.black )
        self.addParameter('Value','4k7',True, QPointF(  0, 15), Color.blue  )
        self.addTerminal('A',1, TERM_INOUT, QPointF(-40,0)) 
        self.addTerminal('B',2, TERM_INOUT, QPointF( 40,0))
 
    def drawShape(self, gc):
        path = QPainterPath()
        gc.setPen(QPen(self.shapeColor))	
        path.addRect(-23, -8, 46,16)
        path.moveTo(-40,0)
        path.lineTo(-23,0)
        path.moveTo(40,0)
        path.lineTo(23,0)
        gc.drawPath(path)
Osobné nástroje
Menné priestory

Varianty
Operácie
Navigácia
Rýchle linky
Nástroje
Tlačiť/exportovať