class DrawingHeadless(object):
    def __init__(self, parent):
        self.parent = parent
        self.canvas = TikZ()
        self.schematic = Schematic()

    def DrawSchematic(self, canvas=None):
        if canvas == None:
            canvas = self.canvas
        if SignalIntegrity.App.Project is None:
            return
        drawingPropertiesProject = SignalIntegrity.App.Project[
            'Drawing.DrawingProperties']
        grid = drawingPropertiesProject['Grid']
        originx = drawingPropertiesProject['Originx']
        originy = drawingPropertiesProject['Originy']
        devicePinConnectedList = self.schematic.DevicePinConnectedList()
        foundAPort = False
        foundASource = False
        foundAnOutput = False
        foundSomething = False
        foundAMeasure = False
        foundAStim = False
        foundAnUnknown = False
        foundASystem = False
        for deviceIndex in range(len(self.schematic.deviceList)):
            device = self.schematic.deviceList[deviceIndex]
            foundSomething = True
            devicePinsConnected = devicePinConnectedList[deviceIndex]
            device.DrawDevice(canvas, grid, originx, originy,
                              devicePinsConnected)
            deviceType = device['partname'].GetValue()
            if deviceType == 'Port':
                foundAPort = True
            elif deviceType in [
                    'Output', 'DifferentialVoltageOutput', 'CurrentOutput'
            ]:
                foundAnOutput = True
            elif deviceType == 'Stim':
                foundAStim = True
            elif deviceType == 'Measure':
                foundAMeasure = True
            elif deviceType == 'System':
                foundASystem = True
            elif deviceType == 'Unknown':
                foundAnUnknown = True
            elif device.netlist['DeviceName'] in [
                    'voltagesource', 'currentsource'
            ]:
                foundASource = True
        for wireProject in SignalIntegrity.App.Project[
                'Drawing.Schematic.Wires']:
            foundSomething = True
            wireProject.DrawWire(canvas, grid, originx, originy)
        for dot in self.schematic.DotList():
            size = grid / 8
            canvas.create_oval((dot[0] + originx) * grid - size,
                               (dot[1] + originy) * grid - size,
                               (dot[0] + originx) * grid + size,
                               (dot[1] + originy) * grid + size,
                               fill='black',
                               outline='black')
        self.foundSomething = foundSomething
        self.canSimulate = foundASource and foundAnOutput and not foundAPort and not foundAStim and not foundAMeasure and not foundAnUnknown and not foundASystem
        self.canCalculateSParameters = foundAPort and not foundAnOutput and not foundAMeasure and not foundAStim and not foundAnUnknown and not foundASystem
        self.canVirtualProbe = foundAStim and foundAnOutput and foundAMeasure and not foundAPort and not foundASource and not foundAnUnknown and not foundASystem
        self.canDeembed = foundAPort and foundAnUnknown and foundASystem and not foundAStim and not foundAMeasure and not foundAnOutput
        self.canCalculate = self.canSimulate or self.canCalculateSParameters or self.canVirtualProbe or self.canDeembed
        return canvas

    def InitFromProject(self):
        self.schematic = Schematic()
        self.schematic.InitFromProject()
 def __init__(self, parent):
     self.parent = parent
     self.canvas = TikZ()
     self.schematic = Schematic()
 def InitFromProject(self):
     self.schematic = Schematic()
     self.schematic.InitFromProject()