Ejemplo n.º 1
0
    def __init__(self, design, sketches, layers, operations, jointop=None):
        super(MainWidget, self).__init__()
        self.design = design
        self.sketches = sketches
        self.layers = layers
        self.operations = operations

        self.designwidget = DesignListManager(design)

        self.input_table = Table(InputRow(self.get_subdesign_operations,self.get_operations),Delegate)
        self.sketch_table = Table(SketchRow(self.get_subdesign_sketches,self.get_sketches),Delegate)
        self.output_table = Table(OutputRow(self.get_subdesign_operations),Delegate)

        self.sketch_control = TableControl(self.sketch_table, self)
        self.input_control = TableControl(self.input_table, self)
        self.output_control = TableControl(self.output_table, self)

        button_ok = qg.QPushButton('Ok')
        button_cancel = qg.QPushButton('Cancel')

        button_ok.clicked.connect(self.accept)
        button_cancel.clicked.connect(self.reject)

        sublayout2 = qg.QHBoxLayout()
        sublayout2.addWidget(button_ok)
        sublayout2.addWidget(button_cancel)

        layout = qg.QVBoxLayout()
        layout.addWidget(self.designwidget)
        layout.addWidget(self.sketch_control)
        layout.addWidget(self.input_control)
        layout.addWidget(self.output_control)
        layout.addLayout(sublayout2)
        self.setLayout(layout)

        if jointop is not None:
            subdesign = design.subdesigns[jointop.design_links['source'][0]]
            for ii in range(self.designwidget.itemlist.count()):
                item = self.designwidget.itemlist.item(ii)
                if item.value == subdesign:
                    item.setSelected(True)
            for item in jointop.sketch_list:
                self.sketch_table.row_add([subdesign.sketches[item.ref1]], [design.sketches[item.ref2]])
            for item in jointop.input_list:
                index1 = self.subdesign().operation_index(item.ref1[0])
                output1 = item.ref1[1]
                index2 = self.design.operation_index(item.ref2[0])
                output2 = item.ref2[1]
                self.input_table.row_add([(index1, output1)], [(index2, output2)],item.shift)
            for item in jointop.output_list:
                index1 = self.subdesign().operation_index(item.ref1[0])
                output1 = item.ref1[1]
                self.output_table.row_add([(index1, output1)],item.shift)

        self.designwidget.itemlist.itemSelectionChanged.connect(
            self.input_table.reset)
        self.designwidget.itemlist.itemSelectionChanged.connect(
            self.output_table.reset)
        self.designwidget.itemlist.itemSelectionChanged.connect(
            self.sketch_table.reset)
Ejemplo n.º 2
0
    def __init__(self, design, sketches, layers, operations, jointop=None,buffer = .01):
        super(MainWidget, self).__init__()
        self.design = design
        self.sketches = sketches
        self.layers = layers
        self.operations = operations

        self.operation_list = DraggableTreeWidget()
        self.operation_list.linklist(self.operations)

        self.table = Table(JointRow(self.get_sketches, self.get_layers),Delegate)
        table_control= TableControl(self.table, self)

        button_ok = qg.QPushButton('Ok')
        button_cancel = qg.QPushButton('Cancel')

        button_ok.clicked.connect(self.accept)
        button_cancel.clicked.connect(self.reject)
                
                
        self.buffer_val = qg.QLineEdit()                
                
        sublayout2 = qg.QHBoxLayout()
        sublayout2.addStretch()
        sublayout2.addWidget(button_ok)
        sublayout2.addWidget(button_cancel)
        sublayout2.addStretch()

        layout = qg.QVBoxLayout()
        layout.addWidget(qg.QLabel('Device'))
        layout.addWidget(self.operation_list)
        layout.addWidget(table_control)
        layout.addWidget(qg.QLabel('Buffer'))
        layout.addWidget(self.buffer_val)
        layout.addLayout(sublayout2)
        
        self.setLayout(layout)

        if jointop is not None:
            try:
                op_ref, output_ii = jointop.operation_links['parent'][0]
                op_ii = design.operation_index(op_ref)
                self.operation_list.selectIndeces([(op_ii, output_ii)])
            except(IndexError, KeyError):
                pass

            try:
                fixed_ref, fixed_output_ii = jointop.operation_links[
                    'fixed'][0]
                fixed_ii = design.operation_index(fixed_ref)
                self.fixed.selectIndeces([(fixed_ii, fixed_output_ii)])
            except(IndexError, KeyError):
                pass

            for item in jointop.joint_defs:
                sketch = self.design.sketches[item.sketch]
                joint_layer = self.design.return_layer_definition().getlayer(
                    item.joint_layer)
                sublaminate_layers = [self.design.return_layer_definition().getlayer(
                    item2) for item2 in item.sublaminate_layers]
                self.table.row_add(
                    sketch,
                    joint_layer,
                    sublaminate_layers,
                    item.width)            
        else:
            self.table.row_add_empty()
        self.buffer_val.setText(str(buffer))

        self.table.resizeColumnsToContents()
        self.table.reset_min_width()
        self.table.setHorizontalScrollBarPolicy(qc.Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
Ejemplo n.º 3
0
class MainWidget(qg.QDialog):

    def __init__(self, design, sketches, layers, operations, jointop=None,buffer = .01):
        super(MainWidget, self).__init__()
        self.design = design
        self.sketches = sketches
        self.layers = layers
        self.operations = operations

        self.operation_list = DraggableTreeWidget()
        self.operation_list.linklist(self.operations)

        self.table = Table(JointRow(self.get_sketches, self.get_layers),Delegate)
        table_control= TableControl(self.table, self)

        button_ok = qg.QPushButton('Ok')
        button_cancel = qg.QPushButton('Cancel')

        button_ok.clicked.connect(self.accept)
        button_cancel.clicked.connect(self.reject)
                
                
        self.buffer_val = qg.QLineEdit()                
                
        sublayout2 = qg.QHBoxLayout()
        sublayout2.addStretch()
        sublayout2.addWidget(button_ok)
        sublayout2.addWidget(button_cancel)
        sublayout2.addStretch()

        layout = qg.QVBoxLayout()
        layout.addWidget(qg.QLabel('Device'))
        layout.addWidget(self.operation_list)
        layout.addWidget(table_control)
        layout.addWidget(qg.QLabel('Buffer'))
        layout.addWidget(self.buffer_val)
        layout.addLayout(sublayout2)
        
        self.setLayout(layout)

        if jointop is not None:
            try:
                op_ref, output_ii = jointop.operation_links['parent'][0]
                op_ii = design.operation_index(op_ref)
                self.operation_list.selectIndeces([(op_ii, output_ii)])
            except(IndexError, KeyError):
                pass

            try:
                fixed_ref, fixed_output_ii = jointop.operation_links[
                    'fixed'][0]
                fixed_ii = design.operation_index(fixed_ref)
                self.fixed.selectIndeces([(fixed_ii, fixed_output_ii)])
            except(IndexError, KeyError):
                pass

            for item in jointop.joint_defs:
                sketch = self.design.sketches[item.sketch]
                joint_layer = self.design.return_layer_definition().getlayer(
                    item.joint_layer)
                sublaminate_layers = [self.design.return_layer_definition().getlayer(
                    item2) for item2 in item.sublaminate_layers]
                self.table.row_add(
                    sketch,
                    joint_layer,
                    sublaminate_layers,
                    item.width)            
        else:
            self.table.row_add_empty()
        self.buffer_val.setText(str(buffer))

        self.table.resizeColumnsToContents()
        self.table.reset_min_width()
        self.table.setHorizontalScrollBarPolicy(qc.Qt.ScrollBarPolicy.ScrollBarAlwaysOff)

    def contact_sketch(self):
        try:
            return self.sketchwidget.itemlist.selectedItems()[0].value
        except IndexError:
            return None


    def get_sketches(self):
        return self.sketches

    def get_layers(self):
        return self.layers

    def acceptdata(self):
        jointdefs = []
        for ii in range(self.table.rowCount()):
            sketch = self.table.item(ii, 0).data(qc.Qt.ItemDataRole.UserRole)
            joint_layer = self.table.item(
                ii, 1).data(
                qc.Qt.ItemDataRole.UserRole)
            sublaminate_layers = self.table.item(
                ii, 2).data(
                qc.Qt.ItemDataRole.UserRole)
            width = (self.table.item(ii, 3).data(qc.Qt.ItemDataRole.UserRole))
            jointdefs.append(JointDef(sketch.id,joint_layer.id,[item.id for item in sublaminate_layers],width))
        operation_links = {}
        operation_links['parent'] = self.operation_list.currentRefs()
        sketch_links = {}
        return operation_links,sketch_links,jointdefs,float(self.buffer_val.text())
Ejemplo n.º 4
0
class MainWidget(qg.QDialog):

    def __init__(self, design, sketches, layers, operations, jointop=None):
        super(MainWidget, self).__init__()
        self.design = design
        self.sketches = sketches
        self.layers = layers
        self.operations = operations

        self.designwidget = DesignListManager(design)

        self.input_table = Table(InputRow(self.get_subdesign_operations,self.get_operations),Delegate)
        self.sketch_table = Table(SketchRow(self.get_subdesign_sketches,self.get_sketches),Delegate)
        self.output_table = Table(OutputRow(self.get_subdesign_operations),Delegate)

        self.sketch_control = TableControl(self.sketch_table, self)
        self.input_control = TableControl(self.input_table, self)
        self.output_control = TableControl(self.output_table, self)

        button_ok = qg.QPushButton('Ok')
        button_cancel = qg.QPushButton('Cancel')

        button_ok.clicked.connect(self.accept)
        button_cancel.clicked.connect(self.reject)

        sublayout2 = qg.QHBoxLayout()
        sublayout2.addWidget(button_ok)
        sublayout2.addWidget(button_cancel)

        layout = qg.QVBoxLayout()
        layout.addWidget(self.designwidget)
        layout.addWidget(self.sketch_control)
        layout.addWidget(self.input_control)
        layout.addWidget(self.output_control)
        layout.addLayout(sublayout2)
        self.setLayout(layout)

        if jointop is not None:
            subdesign = design.subdesigns[jointop.design_links['source'][0]]
            for ii in range(self.designwidget.itemlist.count()):
                item = self.designwidget.itemlist.item(ii)
                if item.value == subdesign:
                    item.setSelected(True)
            for item in jointop.sketch_list:
                self.sketch_table.row_add([subdesign.sketches[item.ref1]], [design.sketches[item.ref2]])
            for item in jointop.input_list:
                index1 = self.subdesign().operation_index(item.ref1[0])
                output1 = item.ref1[1]
                index2 = self.design.operation_index(item.ref2[0])
                output2 = item.ref2[1]
                self.input_table.row_add([(index1, output1)], [(index2, output2)],item.shift)
            for item in jointop.output_list:
                index1 = self.subdesign().operation_index(item.ref1[0])
                output1 = item.ref1[1]
                self.output_table.row_add([(index1, output1)],item.shift)

        self.designwidget.itemlist.itemSelectionChanged.connect(
            self.input_table.reset)
        self.designwidget.itemlist.itemSelectionChanged.connect(
            self.output_table.reset)
        self.designwidget.itemlist.itemSelectionChanged.connect(
            self.sketch_table.reset)

    def get_operations(self):
        return self.operations

    def get_subdesign_operations(self):
        return self.subdesign().operations

    def get_sketches(self):
        return self.design.sketches.values()

    def get_subdesign_sketches(self):
        return self.subdesign().sketches.values()

    def subdesign(self):
        try:
            return self.designwidget.itemlist.selectedItems()[0].value
        except IndexError:
            return None

    def acceptdata(self):

        sketch_list = []
        data = self.sketch_table.export_data()
        for sketch1, sketch2 in data:
            sketch_list.append(SketchData(sketch1[0].id, sketch2[0].id))

        input_list = []
        for refs_from, refs_to,shift in self.input_table.export_data():
            op1_index, op1_output = refs_from[0]
            op2_index, op2_output = refs_to[0]
            op1_ref = self.subdesign().operations[op1_index].id
            op2_ref = self.design.operations[op2_index].id
            input_list.append(InputData((op1_ref, op1_output), (op2_ref, op2_output),shift))

        output_list = []
        for ref1,shift in self.output_table.export_data():
            op1_index, op1_output = ref1[0]
            op1_ref = self.subdesign().operations[op1_index].id
            output_list.append(OutputData((op1_ref, op1_output),shift))

        design_links = {}
        design_links['source'] = [self.subdesign().id]

        return design_links, sketch_list, input_list, output_list
Ejemplo n.º 5
0
    def __init__(self, design, sketches, layers, operations, jointop=None,sketch = None):
        super(MainWidget, self).__init__()
        self.design = design
        self.sketches = sketches
        self.layers = layers
        self.operations = operations

        self.operation_list = DraggableTreeWidget()
        self.operation_list.linklist(self.operations)

        self.fixed = DraggableTreeWidget()
        self.fixed.linklist(self.operations)

        self.table = Table(JointRow(self.get_sketches, self.get_layers),Delegate)
        table_control= TableControl(self.table, self)


        self.sketchwidget = SketchListManager(self.design,name='Contact Points Sketch')
        for ii in range(self.sketchwidget.itemlist.count()):
            item = self.sketchwidget.itemlist.item(ii)
            if item.value == sketch:
                item.setSelected(True)

        button_ok = qg.QPushButton('Ok')
        button_cancel = qg.QPushButton('Cancel')

        button_ok.clicked.connect(self.accept)
        button_cancel.clicked.connect(self.reject)
                
        sublayout1 = qg.QHBoxLayout()
        sublayout1_1 = qg.QVBoxLayout()
        sublayout1_2 = qg.QVBoxLayout()
        sublayout1_3 = qg.QVBoxLayout()

        sublayout1_1.addWidget(qg.QLabel('Device'))
        sublayout1_1.addWidget(self.operation_list)
        sublayout1_2.addWidget(qg.QLabel('Fixed Region'))
        sublayout1_2.addWidget(self.fixed)
        sublayout1_3.addWidget(self.sketchwidget)

        sublayout1.addLayout(sublayout1_1)
        sublayout1.addLayout(sublayout1_2)
        sublayout1.addLayout(sublayout1_3)

        sublayout2 = qg.QHBoxLayout()
        sublayout2.addStretch()
        sublayout2.addWidget(button_ok)
        sublayout2.addWidget(button_cancel)
        sublayout2.addStretch()

        layout = qg.QVBoxLayout()
        layout.addLayout(sublayout1)
        layout.addWidget(table_control)
        layout.addLayout(sublayout2)
        
        self.setLayout(layout)

        if jointop is not None:
            try:
                op_ref, output_ii = jointop.operation_links['parent'][0]
                op_ii = design.operation_index(op_ref)
                self.operation_list.selectIndeces([(op_ii, output_ii)])
            except(IndexError, KeyError):
                pass

            try:
                fixed_ref, fixed_output_ii = jointop.operation_links[
                    'fixed'][0]
                fixed_ii = design.operation_index(fixed_ref)
                self.fixed.selectIndeces([(fixed_ii, fixed_output_ii)])
            except(IndexError, KeyError):
                pass

            for item in jointop.joint_defs:
                sketch = self.design.sketches[item.sketch]
                joint_layer = self.design.return_layer_definition().getlayer(
                    item.joint_layer)
                sublaminate_layers = [self.design.return_layer_definition().getlayer(
                    item2) for item2 in item.sublaminate_layers]
                self.table.row_add(
                    sketch,
                    joint_layer,
                    sublaminate_layers,
                    item.width,
                    item.stiffness,
                    item.damping,
                    item.preload_angle,
                    item.limit_negative,
                    item.limit_positive)            
        else:
            self.table.row_add_empty()

        self.table.resizeColumnsToContents()
        self.table.reset_min_width()
        self.table.setHorizontalScrollBarPolicy(qc.Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
Ejemplo n.º 6
0
class MainWidget(qg.QDialog):

    def __init__(self, design, sketches, layers, operations, jointop=None,sketch = None):
        super(MainWidget, self).__init__()
        self.design = design
        self.sketches = sketches
        self.layers = layers
        self.operations = operations

        self.operation_list = DraggableTreeWidget()
        self.operation_list.linklist(self.operations)

        self.fixed = DraggableTreeWidget()
        self.fixed.linklist(self.operations)

        self.table = Table(JointRow(self.get_sketches, self.get_layers),Delegate)
        table_control= TableControl(self.table, self)


        self.sketchwidget = SketchListManager(self.design,name='Contact Points Sketch')
        for ii in range(self.sketchwidget.itemlist.count()):
            item = self.sketchwidget.itemlist.item(ii)
            if item.value == sketch:
                item.setSelected(True)

        button_ok = qg.QPushButton('Ok')
        button_cancel = qg.QPushButton('Cancel')

        button_ok.clicked.connect(self.accept)
        button_cancel.clicked.connect(self.reject)
                
        sublayout1 = qg.QHBoxLayout()
        sublayout1_1 = qg.QVBoxLayout()
        sublayout1_2 = qg.QVBoxLayout()
        sublayout1_3 = qg.QVBoxLayout()

        sublayout1_1.addWidget(qg.QLabel('Device'))
        sublayout1_1.addWidget(self.operation_list)
        sublayout1_2.addWidget(qg.QLabel('Fixed Region'))
        sublayout1_2.addWidget(self.fixed)
        sublayout1_3.addWidget(self.sketchwidget)

        sublayout1.addLayout(sublayout1_1)
        sublayout1.addLayout(sublayout1_2)
        sublayout1.addLayout(sublayout1_3)

        sublayout2 = qg.QHBoxLayout()
        sublayout2.addStretch()
        sublayout2.addWidget(button_ok)
        sublayout2.addWidget(button_cancel)
        sublayout2.addStretch()

        layout = qg.QVBoxLayout()
        layout.addLayout(sublayout1)
        layout.addWidget(table_control)
        layout.addLayout(sublayout2)
        
        self.setLayout(layout)

        if jointop is not None:
            try:
                op_ref, output_ii = jointop.operation_links['parent'][0]
                op_ii = design.operation_index(op_ref)
                self.operation_list.selectIndeces([(op_ii, output_ii)])
            except(IndexError, KeyError):
                pass

            try:
                fixed_ref, fixed_output_ii = jointop.operation_links[
                    'fixed'][0]
                fixed_ii = design.operation_index(fixed_ref)
                self.fixed.selectIndeces([(fixed_ii, fixed_output_ii)])
            except(IndexError, KeyError):
                pass

            for item in jointop.joint_defs:
                sketch = self.design.sketches[item.sketch]
                joint_layer = self.design.return_layer_definition().getlayer(
                    item.joint_layer)
                sublaminate_layers = [self.design.return_layer_definition().getlayer(
                    item2) for item2 in item.sublaminate_layers]
                self.table.row_add(
                    sketch,
                    joint_layer,
                    sublaminate_layers,
                    item.width,
                    item.stiffness,
                    item.damping,
                    item.preload_angle,
                    item.limit_negative,
                    item.limit_positive)            
        else:
            self.table.row_add_empty()

        self.table.resizeColumnsToContents()
        self.table.reset_min_width()
        self.table.setHorizontalScrollBarPolicy(qc.Qt.ScrollBarPolicy.ScrollBarAlwaysOff)

    def contact_sketch(self):
        try:
            return self.sketchwidget.itemlist.selectedItems()[0].value
        except IndexError:
            return None


    def get_sketches(self):
        return self.sketches

    def get_layers(self):
        return self.layers

    def acceptdata(self):
        jointdefs = []
        for ii in range(self.table.rowCount()):
            sketch = self.table.item(ii, 0).data(qc.Qt.ItemDataRole.UserRole)
            joint_layer = self.table.item(
                ii, 1).data(
                qc.Qt.ItemDataRole.UserRole)
            sublaminate_layers = self.table.item(
                ii, 2).data(
                qc.Qt.ItemDataRole.UserRole)
            width = (self.table.item(ii, 3).data(qc.Qt.ItemDataRole.UserRole))
            stiffness = (
                self.table.item(
                    ii, 4).data(
                    qc.Qt.ItemDataRole.UserRole))
            damping = (
                self.table.item(
                    ii,
                    5).data(
                    qc.Qt.ItemDataRole.UserRole))
            preload_angle = (self.table.item(ii, 6).data(qc.Qt.ItemDataRole.UserRole))
            limit_negative = (self.table.item(ii, 7).data(qc.Qt.ItemDataRole.UserRole))
            limit_positive = (self.table.item(ii, 8).data(qc.Qt.ItemDataRole.UserRole))
            jointdefs.append(JointDef(sketch.id,
                                      joint_layer.id,
                                      [item.id for item in sublaminate_layers],
                                      width,
                                      stiffness,
                                      damping,
                                      preload_angle,limit_negative,limit_positive))
        operation_links = {}
        operation_links['parent'] = self.operation_list.currentRefs()
        operation_links['fixed'] = self.fixed.currentRefs()
        sketch_links = {}
        sketch_links['contact_points'] = [self.contact_sketch().id]
        return operation_links,sketch_links,jointdefs
Ejemplo n.º 7
0
    def __init__(self, design, sketches, layers, operations, jointop=None,sketch = None):
        super(MainWidget, self).__init__()
        self.design = design
        self.sketches = sketches
        self.layers = layers
        self.operations = operations

        self.operation_list = DraggableTreeWidget()
        self.operation_list.linklist(self.operations)

        self.fixed = DraggableTreeWidget()
        self.fixed.linklist(self.operations)

        self.table = Table(JointRow(self.get_sketches, self.get_layers),Delegate)
        table_control= TableControl(self.table, self)


        self.sketchwidget = SketchListManager(self.design,name='Contact Points Sketch')
        for ii in range(self.sketchwidget.itemlist.count()):
            item = self.sketchwidget.itemlist.item(ii)
            if item.value == sketch:
                item.setSelected(True)

        button_ok = qg.QPushButton('Ok')
        button_cancel = qg.QPushButton('Cancel')

        button_ok.clicked.connect(self.accept)
        button_cancel.clicked.connect(self.reject)
                
        sublayout1 = qg.QHBoxLayout()
        sublayout1_1 = qg.QVBoxLayout()
        sublayout1_2 = qg.QVBoxLayout()
        sublayout1_3 = qg.QVBoxLayout()

        sublayout1_1.addWidget(qg.QLabel('Device'))
        sublayout1_1.addWidget(self.operation_list)
        sublayout1_2.addWidget(qg.QLabel('Fixed Region'))
        sublayout1_2.addWidget(self.fixed)
        sublayout1_3.addWidget(self.sketchwidget)

        sublayout1.addLayout(sublayout1_1)
        sublayout1.addLayout(sublayout1_2)
        sublayout1.addLayout(sublayout1_3)

        sublayout2 = qg.QHBoxLayout()
        sublayout2.addStretch()
        sublayout2.addWidget(button_ok)
        sublayout2.addWidget(button_cancel)
        sublayout2.addStretch()

        layout = qg.QVBoxLayout()
        layout.addLayout(sublayout1)
        layout.addWidget(table_control)
        layout.addLayout(sublayout2)
        
        self.setLayout(layout)

        if jointop is not None:
            try:
                op_ref, output_ii = jointop.operation_links['parent'][0]
                op_ii = design.operation_index(op_ref)
                self.operation_list.selectIndeces([(op_ii, output_ii)])
            except(IndexError, KeyError):
                pass

            try:
                fixed_ref, fixed_output_ii = jointop.operation_links[
                    'fixed'][0]
                fixed_ii = design.operation_index(fixed_ref)
                self.fixed.selectIndeces([(fixed_ii, fixed_output_ii)])
            except(IndexError, KeyError):
                pass

            for item in jointop.joint_defs:
                sketch = self.design.sketches[item.sketch]
                joint_layer = self.design.return_layer_definition().getlayer(
                    item.joint_layer)
                sublaminate_layers = [self.design.return_layer_definition().getlayer(
                    item2) for item2 in item.sublaminate_layers]
                self.table.row_add(
                    sketch,
                    joint_layer,
                    sublaminate_layers,
                    item.width,
                    item.stiffness,
                    item.damping,
                    item.preload_angle,
                    item.limit_negative,
                    item.limit_positive)            
        else:
            self.table.row_add_empty()

        self.table.resizeColumnsToContents()
        self.table.reset_min_width()
        self.table.setHorizontalScrollBarPolicy(qc.Qt.ScrollBarAlwaysOff)
Ejemplo n.º 8
0
    def __init__(self,
                 design,
                 sketches,
                 layers,
                 operations,
                 jointop=None,
                 buffer=.01):
        super(MainWidget, self).__init__()
        self.design = design
        self.sketches = sketches
        self.layers = layers
        self.operations = operations

        self.operation_list = DraggableTreeWidget()
        self.operation_list.linklist(self.operations)

        self.table = Table(JointRow(self.get_sketches, self.get_layers),
                           Delegate)
        table_control = TableControl(self.table, self)

        button_ok = qg.QPushButton('Ok')
        button_cancel = qg.QPushButton('Cancel')

        button_ok.clicked.connect(self.accept)
        button_cancel.clicked.connect(self.reject)

        self.buffer_val = qg.QLineEdit()

        sublayout2 = qg.QHBoxLayout()
        sublayout2.addStretch()
        sublayout2.addWidget(button_ok)
        sublayout2.addWidget(button_cancel)
        sublayout2.addStretch()

        layout = qg.QVBoxLayout()
        layout.addWidget(qg.QLabel('Device'))
        layout.addWidget(self.operation_list)
        layout.addWidget(table_control)
        layout.addWidget(qg.QLabel('Buffer'))
        layout.addWidget(self.buffer_val)
        layout.addLayout(sublayout2)

        self.setLayout(layout)

        if jointop is not None:
            try:
                op_ref, output_ii = jointop.operation_links['parent'][0]
                op_ii = design.operation_index(op_ref)
                self.operation_list.selectIndeces([(op_ii, output_ii)])
            except (IndexError, KeyError):
                pass

            try:
                fixed_ref, fixed_output_ii = jointop.operation_links['fixed'][
                    0]
                fixed_ii = design.operation_index(fixed_ref)
                self.fixed.selectIndeces([(fixed_ii, fixed_output_ii)])
            except (IndexError, KeyError):
                pass

            for item in jointop.joint_defs:
                sketch = self.design.sketches[item.sketch]
                joint_layer = self.design.return_layer_definition().getlayer(
                    item.joint_layer)
                sublaminate_layers = [
                    self.design.return_layer_definition().getlayer(item2)
                    for item2 in item.sublaminate_layers
                ]
                self.table.row_add(sketch, joint_layer, sublaminate_layers,
                                   item.width)
        else:
            self.table.row_add_empty()
        self.buffer_val.setText(str(buffer))

        self.table.resizeColumnsToContents()
        self.table.reset_min_width()
        self.table.setHorizontalScrollBarPolicy(qc.Qt.ScrollBarAlwaysOff)
Ejemplo n.º 9
0
class MainWidget(qg.QDialog):
    def __init__(self,
                 design,
                 sketches,
                 layers,
                 operations,
                 jointop=None,
                 buffer=.01):
        super(MainWidget, self).__init__()
        self.design = design
        self.sketches = sketches
        self.layers = layers
        self.operations = operations

        self.operation_list = DraggableTreeWidget()
        self.operation_list.linklist(self.operations)

        self.table = Table(JointRow(self.get_sketches, self.get_layers),
                           Delegate)
        table_control = TableControl(self.table, self)

        button_ok = qg.QPushButton('Ok')
        button_cancel = qg.QPushButton('Cancel')

        button_ok.clicked.connect(self.accept)
        button_cancel.clicked.connect(self.reject)

        self.buffer_val = qg.QLineEdit()

        sublayout2 = qg.QHBoxLayout()
        sublayout2.addStretch()
        sublayout2.addWidget(button_ok)
        sublayout2.addWidget(button_cancel)
        sublayout2.addStretch()

        layout = qg.QVBoxLayout()
        layout.addWidget(qg.QLabel('Device'))
        layout.addWidget(self.operation_list)
        layout.addWidget(table_control)
        layout.addWidget(qg.QLabel('Buffer'))
        layout.addWidget(self.buffer_val)
        layout.addLayout(sublayout2)

        self.setLayout(layout)

        if jointop is not None:
            try:
                op_ref, output_ii = jointop.operation_links['parent'][0]
                op_ii = design.operation_index(op_ref)
                self.operation_list.selectIndeces([(op_ii, output_ii)])
            except (IndexError, KeyError):
                pass

            try:
                fixed_ref, fixed_output_ii = jointop.operation_links['fixed'][
                    0]
                fixed_ii = design.operation_index(fixed_ref)
                self.fixed.selectIndeces([(fixed_ii, fixed_output_ii)])
            except (IndexError, KeyError):
                pass

            for item in jointop.joint_defs:
                sketch = self.design.sketches[item.sketch]
                joint_layer = self.design.return_layer_definition().getlayer(
                    item.joint_layer)
                sublaminate_layers = [
                    self.design.return_layer_definition().getlayer(item2)
                    for item2 in item.sublaminate_layers
                ]
                self.table.row_add(sketch, joint_layer, sublaminate_layers,
                                   item.width)
        else:
            self.table.row_add_empty()
        self.buffer_val.setText(str(buffer))

        self.table.resizeColumnsToContents()
        self.table.reset_min_width()
        self.table.setHorizontalScrollBarPolicy(qc.Qt.ScrollBarAlwaysOff)

    def contact_sketch(self):
        try:
            return self.sketchwidget.itemlist.selectedItems()[0].value
        except IndexError:
            return None

    def get_sketches(self):
        return self.sketches

    def get_layers(self):
        return self.layers

    def acceptdata(self):
        jointdefs = []
        for ii in range(self.table.rowCount()):
            sketch = self.table.item(ii, 0).data(qc.Qt.UserRole)
            joint_layer = self.table.item(ii, 1).data(qc.Qt.UserRole)
            sublaminate_layers = self.table.item(ii, 2).data(qc.Qt.UserRole)
            width = (self.table.item(ii, 3).data(qc.Qt.UserRole))
            jointdefs.append(
                JointDef(sketch.id, joint_layer.id,
                         [item.id for item in sublaminate_layers], width))
        operation_links = {}
        operation_links['parent'] = self.operation_list.currentRefs()
        sketch_links = {}
        return operation_links, sketch_links, jointdefs, float(
            self.buffer_val.text())