示例#1
0
    def if_elif_func(node, label):
        logs = {}
        # "if" line
        if_widget, if_layout = simpleWidgets.simpleWidget()

        # if
        if_layout.addWidget(simpleWidgets.simpleLabel(label))

        # condition
        sub_widget = terminalWidgets.LE_terminal()
        sub_widget.setup(node.test)
        if_layout.addWidget(sub_widget)
        logs.update({id(sub_widget): sub_widget})

        # :
        if_layout.addWidget(simpleWidgets.simpleLabel(':'))

        # Draw up a new ASTWidget to handle the branch
        space_widget, space_layout = simpleWidgets.simpleWidget()
        space_layout.addSpacing(50)
        ASTWidget_widget = ASTWidget(node)
        space_layout.addWidget(ASTWidget_widget)

        for branch in node:
            t = ASTWidget_widget.branchID_2_terminals[id(branch)]
            logs.update(t)

        return if_widget, space_widget, logs
示例#2
0
def rb_dotted_as_name(node):
    # Make the main widget container
    widget, layout = simpleWidgets.simpleWidget()
    logs = {}

    # Check the value
    n = len(node)
    for i in range(n):
        if i != 0:
            layout.addWidget(simpleWidgets.simpleLabel('.'))

        child, log = fetch(node[i])
        layout.addWidget(child)
        logs.update(log)

    if node.target:
        layout.addWidget(simpleWidgets.simpleLabel(' as '))

        # Check the target
        targetWidget = terminalWidgets.LE_terminal()
        targetWidget.setup(node, target=True)
        log = {id(targetWidget): targetWidget}
        layout.addWidget(targetWidget)
        logs.update(log)

    return widget, logs
示例#3
0
    def nH_widgetBuilder(cls, node, astTools):
        widget, layout = simpleWidgets.simpleWidget(vertical=True)
        logs = {}

        # "For" line
        For_widget, For_layout = simpleWidgets.simpleWidget()

        # for
        For_layout.addWidget(simpleWidgets.simpleLabel('for'))

        # Get the appropriate widget and add it to the layout
        sub_widget = terminalWidgets.LE_terminal()
        sub_widget.setup(node.iterator)
        For_layout.addWidget(sub_widget)
        logs.update({id(sub_widget): sub_widget})

        # in
        For_layout.addWidget(simpleWidgets.simpleLabel('in'))

        # Get the appropriate widget and add it to the layout
        sub_widget = terminalWidgets.LE_terminal()
        sub_widget.setup(node.target)
        For_layout.addWidget(sub_widget)
        logs.update({id(sub_widget): sub_widget})

        # :
        For_layout.addWidget(simpleWidgets.simpleLabel(':'))
        layout.addWidget(For_widget)

        # Draw up a new ASTWidget to handle the branch
        space_widget, space_layout = simpleWidgets.simpleWidget()
        space_layout.addSpacing(50)
        ASTWidget_widget = ASTWidget(node)
        space_layout.addWidget(ASTWidget_widget)
        layout.addWidget(space_widget)

        # TODO: EditAST needs a way to pass the terminals in a way that makes sense
        for branch in node:
            t = ASTWidget_widget.branchID_2_terminals[id(branch)]
            logs.update(t)

        return widget, logs
示例#4
0
    def nH_widgetBuilder(cls, node, astTools):
        # Make the frame
        widget = QFrame()
        layout = QVBoxLayout()
        widget.setLayout(layout)

        terminalsDict = {}

        # Build the widget from the assignment node
        # Set up the title
        titleString = ''
        if len(node.value) == 1:
            titleString = node.value.value
        else:
            for i in range(len(node.value) - 1):
                if i == 0:
                    pass
                else:
                    titleString += '.'
                titleString += node.value[i].value

        titleLabel = simpleWidgets.simpleLabel(titleString)
        titleLabel.setAlignment(Qt.AlignHCenter)
        titleLabel.setToolTip(node.dumps())
        layout.addWidget(titleLabel)

        # Add the inputs
        inputs = node.value[-1]

        if len(inputs) == 0:
            pass
        else:
            inputTitleLabel = simpleWidgets.simpleLabel('Inputs')
            inputTitleLabel.setAlignment(Qt.AlignHCenter)
            layout.addWidget(inputTitleLabel)

            for i, eachInput in enumerate(inputs):
                eachWidget, eachLayout = simpleWidgets.simpleWidget()
                if eachInput.target:  # Check for keyword arguments
                    input_label = '{} : '.format(eachInput.target)
                else:
                    input_label = 'Argument {} : '.format(i + 1)  # No kwargs
                eachLabel = simpleWidgets.simpleLabel(input_label)
                eachLE = terminalWidgets.LE_terminal()
                # eachLE    = terminalWidgets.COMBO_terminal()
                eachLE.setup(eachInput.value)
                eachLayout.addWidget(eachLabel)
                eachLayout.addWidget(eachLE, 1)
                # eachLayout.addStretch(1)
                layout.addWidget(eachWidget, 1)
                terminalsDict.update({id(eachLE): eachLE})

        return widget, terminalsDict
示例#5
0
    def nH_widgetBuilder(cls, node, astTools):
        # Make the frame
        widget = QFrame()
        layout = QVBoxLayout()
        widget.setLayout(layout)

        terminalsDict = {}

        # Build the widget from the assignment node
        # Set up the title
        titleString = ''
        if len(node.value) == 1:
            titleString = node.value.value
        else:
            for i in range(len(node.value) - 1):
                if i == 0:
                    pass
                else:
                    titleString += '.'
                titleString += node.value[i].value

        titleLabel = simpleWidgets.simpleLabel(titleString)
        titleLabel.setAlignment(Qt.AlignHCenter)
        titleLabel.setToolTip(node.dumps())
        layout.addWidget(titleLabel)

        # Add a horizontal widget to put the input and output widgets into
        # Output vertical layout
        input_output_widget = QWidget()
        input_output_layout = QHBoxLayout()
        input_output_widget.setLayout(input_output_layout)

        # Add the outputs
        # If there is just one target, put it in a list
        n = len(node.target)
        if n == 1:
            outputs = [node.target]
        else:
            outputs = node.target

        # Output vertical layout
        output_widget = QWidget()
        output_layout = QVBoxLayout()
        output_widget.setLayout(output_layout)

        outputTitleLabel = simpleWidgets.simpleLabel('Outputs')
        outputTitleLabel.setAlignment(Qt.AlignHCenter)
        output_layout.addWidget(outputTitleLabel)

        for i in range(len(outputs)):
            eachWidget, eachLayout = simpleWidgets.simpleWidget()
            eachLabel = simpleWidgets.simpleLabel('Output {} :'.format(i + 1))
            eachLE = terminalWidgets.LE_terminal()
            # eachLE    = terminalWidgets.COMBO_terminal()
            eachLE.setup(outputs[i])
            eachLayout.addWidget(eachLabel)
            eachLayout.addWidget(eachLE, 1)
            # eachLayout.addStretch(1)
            output_layout.addWidget(eachWidget, 1)
            terminalsDict.update({id(eachLE): eachLE})

        input_output_layout.addWidget(output_widget, 1)

        # Add the inputs
        inputs = node.value[-1]
        # input vertical layout
        input_widget = QWidget()
        input_layout = QVBoxLayout()
        input_widget.setLayout(input_layout)

        inputTitleLabel = simpleWidgets.simpleLabel('Inputs')
        inputTitleLabel.setAlignment(Qt.AlignHCenter)
        input_layout.addWidget(inputTitleLabel)

        for i, eachInput in enumerate(inputs):
            eachWidget, eachLayout = simpleWidgets.simpleWidget()
            if eachInput.target:  # Check for keyword arguments
                input_label = '{} : '.format(eachInput.target)
            else:
                input_label = 'Argument {} : '.format(i + 1)  # No kwargs
            eachLabel = simpleWidgets.simpleLabel(input_label)
            eachLE = terminalWidgets.LE_terminal()
            # eachLE    = terminalWidgets.COMBO_terminal()
            eachLE.setup(eachInput.value)
            eachLayout.addWidget(eachLabel)
            eachLayout.addWidget(eachLE, 1)
            # eachLayout.addStretch(1)
            input_layout.addWidget(eachWidget, 1)
            terminalsDict.update({id(eachLE): eachLE})

        input_output_layout.addWidget(input_widget, 1)
        layout.addWidget(input_output_widget, 1)

        return widget, terminalsDict
示例#6
0
 def nH_widgetBuilder(cls, node, astTools):
     widget = terminalWidgets.LE_terminal()
     widget.setup(node)
     return widget, {id(widget): widget}
示例#7
0
def LE_handle(node):
    widget = terminalWidgets.LE_terminal()
    widget.setup(node)
    return widget, {id(widget): widget}
示例#8
0
    def nH_widgetBuilder(node, astTools):
        """
        nH_widgetBuilder is defined in nodeHander class but it MUST be overwritten. This is where the widget and its functionality is defined. The only purpose of the method defined in nodeHandler is to alert the program that the method hasn't been overwritten and can't be used.
        """
        # Make the frame
        widget = QFrame()
        layout = QVBoxLayout()
        widget.setLayout(layout)

        terminalsDict = {}

        # Add the title
        titleLabel = simpleWidgets.simpleLabel('Create From Mold')
        titleLabel.setToolTip(node.dumps())
        titleLabel.setAlignment(Qt.AlignHCenter)
        layout.addWidget(titleLabel)

        ## Check for each positional argument
        labels_tooltips_nodes = []

        DM_label = 'DM Object : '
        DM_tooltip = 'Name of the de-la-mo model object'
        DM_node = node.value.value[2].value[0]
        labels_tooltips_nodes.append([DM_label, DM_tooltip, DM_node])

        mold_label = 'Mold : '
        mold_tooltip = 'Mold'
        mold_node = node.value.value[2].value[1]
        labels_tooltips_nodes.append([mold_label, mold_tooltip, mold_node])

        direction_label = 'Direction : '
        direction_tooltip = '\'OFFSET\' or \'ORIG\' '
        direction_node = node.value.value[2].value[2]
        labels_tooltips_nodes.append(
            [direction_label, direction_tooltip, direction_node])

        thickness_label = 'Layer thickness : '
        thickness_tooltip = 'Layer thickness'
        thickness_node = node.value.value[2].value[3]
        labels_tooltips_nodes.append(
            [thickness_label, thickness_tooltip, thickness_node])

        name_label = 'Unique layer name : '
        name_tooltip = 'Unique layer name'
        name_node = node.value.value[2].value[4]
        labels_tooltips_nodes.append([name_label, name_tooltip, name_node])

        section_label = 'Section : '
        section_tooltip = 'ABAQUS section of the layer'
        section_node = node.value.value[2].value[5]
        labels_tooltips_nodes.append(
            [section_label, section_tooltip, section_node])

        layup_label = 'Ply orientation : '
        layup_tooltip = 'Ply orientation in degrees'
        layup_node = node.value.value[2].value[6]
        labels_tooltips_nodes.append([layup_label, layup_tooltip, layup_node])

        # Add a horizontal widget to put the input and output widgets into
        # Output vertical layout
        input_output_widget = QWidget()
        input_output_layout = QHBoxLayout()
        input_output_widget.setLayout(input_output_layout)

        # input vertical layout
        input_widget = QWidget()
        input_layout = QVBoxLayout()
        input_widget.setLayout(input_layout)
        input_Label = simpleWidgets.simpleLabel('Inputs')
        input_Label.setAlignment(Qt.AlignHCenter)
        input_layout.addWidget(input_Label)

        # Build the GUI
        for label, tooltip, astNode in labels_tooltips_nodes:
            eachWidget, eachLayout = simpleWidgets.simpleWidget()
            eachLabel = simpleWidgets.simpleLabel(label)
            eachLabel.setToolTip(tooltip)
            eachLE = terminalWidgets.LE_terminal()
            # eachLE    = terminalWidgets.COMBO_terminal()
            eachLE.setup(astNode)
            eachLayout.addWidget(eachLabel)
            eachLayout.addWidget(eachLE, 1)
            # eachLayout.addStretch(1)
            input_layout.addWidget(eachWidget, 1)
            terminalsDict.update({id(eachLE): eachLE})

        ## Check for keyword arguments
        if node.value.value[2].value[7].target.value == 'coordsys':
            coordsys_tooltip = 'Reference coordinate system for layup'
            coordsys_node = node.value.value[2].value[7].value

            anotherWidget, anotherLayout = simpleWidgets.simpleWidget()
            anotherLabel = simpleWidgets.simpleLabel('coordsys : ')
            anotherLabel.setToolTip(tooltip)
            anotherLE = terminalWidgets.LE_terminal()
            # eachLE    = terminalWidgets.COMBO_terminal()
            anotherLE.setup(coordsys_node)
            anotherLayout.addWidget(anotherLabel)
            anotherLayout.addWidget(anotherLE, 1)
            # eachLayout.addStretch(1)
            input_layout.addWidget(anotherWidget, 1)
            terminalsDict.update({id(anotherLE): anotherLE})

        # Outputs
        # Output vertical layout
        output_widget = QWidget()
        output_layout = QVBoxLayout()
        output_widget.setLayout(output_layout)
        output_Label = simpleWidgets.simpleLabel('Outputs')
        output_Label.setAlignment(Qt.AlignHCenter)
        output_layout.addWidget(output_Label)

        label = 'New Layer : '
        tooltip = 'Create a new layer from a mold'
        astNode = node.target
        eachWidget, eachLayout = simpleWidgets.simpleWidget()
        eachLabel = simpleWidgets.simpleLabel(label)
        eachLabel.setToolTip(tooltip)
        eachLE = terminalWidgets.LE_terminal()
        # eachLE    = terminalWidget.COMBO_terminal()
        eachLE.setup(astNode)
        eachLayout.addWidget(eachLabel)
        eachLayout.addWidget(eachLE, 1)
        # eachLayout.addStretch(1)
        output_layout.addWidget(eachWidget, 1)
        terminalsDict.update({id(eachLE): eachLE})

        # Add output and input widgets to the main input_output_layout
        input_output_layout.addWidget(output_widget)
        input_output_layout.addWidget(input_widget)

        # Add input_output_widget to the main layout
        layout.addWidget(input_output_widget)

        return widget, terminalsDict
示例#9
0
    def nH_widgetBuilder(cls, ast, astTools):
        # Make the frame
        widget = QFrame()
        layout = QVBoxLayout()
        widget.setLayout(layout)

        terminalsDict = {}

        # Save the last_intro_node
        widget.last_intro_node = 66

        # Set up the title
        titleString = 'De-La-Mo Initialization'

        titleLabel = simpleWidgets.simpleLabel(titleString)
        titleLabel.setAlignment(Qt.AlignHCenter)

        intro_dump = ''
        for i in range(widget.last_intro_node):
            intro_dump += ast[i].dumps()
            intro_dump += '\n'

        titleLabel.setToolTip(intro_dump)
        layout.addWidget(titleLabel)

        descriptionText = \
        'This block hides a significant amount of the initialization of the script. It holds \n \
        the code that imports de-la-mo modules, loads parameters, and instantiates tools used \n \
        in the rest of the script. It is not important to the end user, but if the user is \n \
        interested they may right click on the block and select \'Split\' from the menu, or \n \
        the user may look at the raw code in a text editor.'

        description = simpleWidgets.simpleLabel(descriptionText)
        description.setAlignment(Qt.AlignHCenter)
        layout.addWidget(description)

        # input and output lists
        input_labels_tooltips_nodes = []
        output_labels_tooltips_nodes = []

        # Example
        # DM_label = 'DM Object : '
        # DM_tooltip = 'Name of the de-la-mo model object'
        # DM_node = node.value.value[2].value[0]
        # input_labels_tooltips_nodes.append([DM_label,DM_tooltip,DM_node])

        # Node 16
        DM_label = 'DM Object : '
        DM_tooltip = 'Name of the de-la-mo model object'
        DM_node = ast[16].target
        output_labels_tooltips_nodes.append([DM_label, DM_tooltip, DM_node])

        # Node 34
        ScriptName_label = 'Script Name : '
        ScriptName_tooltip = 'Should match the name of the python script open here, with quotes.'
        ScriptName_node = ast[34].value.value[2][0].value
        input_labels_tooltips_nodes.append(
            [ScriptName_label, ScriptName_tooltip, ScriptName_node])

        # Node 41
        parameter_label = 'Abaqus Parameter File : '
        parameter_tooltip = ''
        parameter_node = ast[41].value[2][0].value
        input_labels_tooltips_nodes.append(
            [parameter_label, parameter_tooltip, parameter_node])

        # Add a horizontal widget to put the input and output widgets into
        # Output vertical layout
        input_output_widget = QWidget()
        input_output_layout = QHBoxLayout()
        input_output_widget.setLayout(input_output_layout)

        # input vertical layout
        input_widget = QWidget()
        input_layout = QVBoxLayout()
        input_widget.setLayout(input_layout)
        input_Label = simpleWidgets.simpleLabel('Inputs')
        input_Label.setAlignment(Qt.AlignHCenter)
        input_layout.addWidget(input_Label)

        # Build the GUI
        for label, tooltip, astNode in input_labels_tooltips_nodes:
            eachWidget, eachLayout = simpleWidgets.simpleWidget()
            eachLabel = simpleWidgets.simpleLabel(label)
            eachLabel.setToolTip(tooltip)
            eachLE = terminalWidgets.LE_terminal()
            # eachLE    = terminalWidgets.COMBO_terminal()
            eachLE.setup(astNode)
            eachLayout.addWidget(eachLabel)
            eachLayout.addWidget(eachLE, 1)
            # eachLayout.addStretch(1)
            input_layout.addWidget(eachWidget, 1)
            terminalsDict.update({id(eachLE): eachLE})

        # Outputs
        # Output vertical layout
        output_widget = QWidget()
        output_layout = QVBoxLayout()
        output_widget.setLayout(output_layout)
        output_Label = simpleWidgets.simpleLabel('Outputs')
        output_Label.setAlignment(Qt.AlignHCenter)
        output_layout.addWidget(output_Label)

        # Build the GUI
        for label, tooltip, astNode in output_labels_tooltips_nodes:
            eachWidget, eachLayout = simpleWidgets.simpleWidget()
            eachLabel = simpleWidgets.simpleLabel(label)
            eachLabel.setToolTip(tooltip)
            eachLE = terminalWidgets.LE_terminal()
            # eachLE    = terminalWidgets.COMBO_terminal()
            eachLE.setup(astNode)
            eachLayout.addWidget(eachLabel)
            eachLayout.addWidget(eachLE, 1)
            # eachLayout.addStretch(1)
            output_layout.addWidget(eachWidget, 1)
            terminalsDict.update({id(eachLE): eachLE})

        # Add output and input widgets to the main input_output_layout
        input_output_layout.addWidget(output_widget)
        input_output_layout.addWidget(input_widget)

        # Add input_output_widget to the main layout
        layout.addWidget(input_output_widget)

        return widget, terminalsDict