Exemplo n.º 1
0
    def __init__(self,operationlist,index0,operationindeces1=None,operationindeces2 = None):
        super(Dialog,self).__init__()
        
        if operationindeces1 ==None:
            operationindeces1 = []
        if operationindeces2 ==None:
            operationindeces2 = []
        
        from popupcad.widgets.operationlist import OperationList
        self.le0 = OperationList(LaminateOperation.unaryoperationtypes,LaminateOperation.pairoperationtypes,LaminateOperation.displayorder)
        self.operationlist = operationlist

        self.unarylistwidget = DraggableTreeWidget()
        self.unarylistwidget.linklist(self.operationlist)
        self.unarylistwidget.setSelectionMode(qg.QListWidget.SelectionMode.ExtendedSelection)
        self.unarylistwidget.selectIndeces(operationindeces1)

        self.pairlistwidget = DraggableTreeWidget()
        self.pairlistwidget.linklist(self.operationlist)
        self.pairlistwidget.setSelectionMode(qg.QListWidget.SelectionMode.ExtendedSelection)
        self.pairlistwidget.selectIndeces(operationindeces2)

        layout3 = qg.QVBoxLayout()
        layout3.addWidget(qg.QLabel('Unary Operators'))
        layout3.addWidget(self.unarylistwidget)

        layout4 = qg.QVBoxLayout()
        layout4.addWidget(qg.QLabel('Binary Operators'))
        layout4.addWidget(self.pairlistwidget)

        layout5 = qg.QHBoxLayout()
        layout5.addLayout(layout3)
        layout5.addLayout(layout4)

        button1 = qg.QPushButton('Ok')
        button2 = qg.QPushButton('Cancel')
        layout2 = qg.QHBoxLayout()
        layout2.addWidget(button1)
        layout2.addWidget(button2)

        layout = qg.QVBoxLayout()
        layout.addWidget(self.le0)
        layout.addLayout(layout5)
#        layout.addWidget(self.unarylistwidget)
#        layout.addWidget(self.pairlistwidget)
        layout.addLayout(layout2)

        self.setLayout(layout)    

        button1.pressed.connect(self.accept)
        button2.pressed.connect(self.reject)
        
        self.le0.unary_selected.connect(lambda:self.pairlistwidget.setEnabled(False))
        self.le0.binary_selected.connect(lambda:self.pairlistwidget.setEnabled(True))
        self.le0.setCurrentIndex(index0)
Exemplo n.º 2
0
    def __init__(self,cls,design,operations,selectedopindex=None,outputref = 0,selectedoutput = None,sketch = None,operation_type_index = 0):
        super(Dialog,self).__init__()
        self.design = design
        self.operations = [NullOp()]+operations
        self.cls = cls

        self.optree = DraggableTreeWidget()
        self.optree.linklist(self.operations)
        if selectedopindex!=None:
            selectedopindex = selectedopindex+1
        else:
            selectedopindex = 0
        
        self.optree.selectIndeces([(selectedopindex,outputref)])

        self.sketchwidget = SketchListManager(self.design)
        for ii in range(self.sketchwidget.itemlist.count()):
            item = self.sketchwidget.itemlist.item(ii)
            if item.value==sketch:
                item.setSelected(True)
        
        if selectedoutput == None:
            selectedoutput = [item.id for item in design.return_layer_definition().layers]
        self.outputlayerselector = qg.QListWidget()
        self.outputlayerselector.setSelectionBehavior(qg.QListWidget.SelectionBehavior.SelectRows)
        self.outputlayerselector.setSelectionMode(qg.QListWidget.SelectionMode.MultiSelection)
        outputitems = [popupcad.filetypes.listwidgetitem.ListWidgetItem(item,self.outputlayerselector) for item in design.return_layer_definition().layers]
        [item.setSelected(item.customdata.id in selectedoutput) for item in outputitems]        

        from popupcad.widgets.operationlist import OperationList
        self.operationtypeselector = OperationList([],cls.function_names,cls.function_names)
        self.operationtypeselector.setCurrentIndex(operation_type_index)        

        button1 = qg.QPushButton('Ok')
        button2 = qg.QPushButton('Cancel')
        buttonlayout = qg.QHBoxLayout()
        buttonlayout.addWidget(button1)
        buttonlayout.addWidget(button2)

        layout = qg.QVBoxLayout()
        layout.addWidget(self.sketchwidget)
        layout.addWidget(self.operationtypeselector)
        layout.addWidget(qg.QLabel('Parent Operation'))
        layout.addWidget(self.optree)
        layout.addWidget(qg.QLabel('Select Layers'))
        layout.addWidget(self.outputlayerselector)
        layout.addLayout(buttonlayout)
        self.setLayout(layout)        

        button1.pressed.connect(self.accept)
        button2.pressed.connect(self.reject)
Exemplo n.º 3
0
    def __init__(
            self,
            operations,
            layerlist,
            index0=0,
            selectedop=None,
            selectedunary=None,
            selectedpair=None,
            selectedoutput=None,
            outputref=0):
        super(Dialog, self).__init__()

        sp = qg.QSizePolicy()
        sp.setHorizontalPolicy(sp.Policy.Minimum)
        sp.setVerticalPolicy(sp.Policy.Minimum)
        if selectedop is None:
            selectedop = len(operations) - 1
        if selectedunary is None:
            selectedunary = []
        if selectedpair is None:
            selectedpair = []
        if selectedoutput is None:
            selectedoutput = layerlist

        from popupcad.widgets.operationlist import OperationList
        self.le0 = OperationList(
            LayerOp2.unaryoperationtypes,
            LayerOp2.pairoperationtypes,
            LayerOp2.displayorder)

        self.operations = operations
        self.operationselector = DraggableTreeWidget()
        self.operationselector.linklist(self.operations)
        self.operationselector.selectIndeces([(selectedop, outputref)])

        self.unarylayerselector = qg.QListWidget()
        self.unarylayerselector.setSelectionBehavior(
            qg.QListWidget.SelectionBehavior.SelectRows)
        self.unarylayerselector.setSelectionMode(
            qg.QListWidget.SelectionMode.MultiSelection)
        unaryitems = [
            ListWidgetItem(
                item,
                self.unarylayerselector) for item in layerlist]

        self.pairlayerselector = qg.QListWidget()
        self.pairlayerselector.setSelectionBehavior(
            qg.QListWidget.SelectionBehavior.SelectRows)
        self.pairlayerselector.setSelectionMode(
            qg.QListWidget.SelectionMode.MultiSelection)
        pairitems = [
            ListWidgetItem(
                item,
                self.pairlayerselector) for item in layerlist]

        self.outputlayerselector = qg.QListWidget()
        self.outputlayerselector.setSelectionBehavior(
            qg.QListWidget.SelectionBehavior.SelectRows)
        self.outputlayerselector.setSelectionMode(
            qg.QListWidget.SelectionMode.MultiSelection)
        outputitems = [
            ListWidgetItem(
                item,
                self.outputlayerselector) for item in layerlist]

        layout2 = qg.QVBoxLayout()
#        self.layout2.setContentsMargins(0,0,0,0)
        layout2.addWidget(qg.QLabel('Unary Operators'))
        layout2.addWidget(self.unarylayerselector)

        layout3 = qg.QVBoxLayout()
#        self.layout2.setContentsMargins(0,0,0,0)
        layout3.addWidget(qg.QLabel('Binary Operators'))
        layout3.addWidget(self.pairlayerselector)

        layout4 = qg.QHBoxLayout()
        layout4.addLayout(layout2)
        layout4.addLayout(layout3)

        layout = qg.QVBoxLayout()
        layout.addWidget(self.le0)
        layout.addWidget(qg.QLabel('Parent Operation'))
        layout.addWidget(self.operationselector)
        layout.addLayout(layout4)
        layout.addWidget(qg.QLabel('Output Layers'))
        layout.addWidget(self.outputlayerselector)

        button1 = qg.QPushButton('Ok')
        button2 = qg.QPushButton('Cancel')

        layout2 = qg.QHBoxLayout()
        layout2.addWidget(button1)
        layout2.addWidget(button2)

        layout.addLayout(layout2)

        self.setLayout(layout)
        button1.clicked.connect(self.accept)
        button2.clicked.connect(self.reject)

        self.le0.unary_selected.connect(
            lambda: self.pairlayerselector.setEnabled(False))
        self.le0.binary_selected.connect(
            lambda: self.pairlayerselector.setEnabled(True))
        self.le0.setCurrentIndex(index0)

        [item.setSelected(item.customdata.id in selectedunary)
         for item in unaryitems]
        [item.setSelected(item.customdata.id in selectedpair)
         for item in pairitems]
        [item.setSelected(item.customdata.id in selectedoutput)
         for item in outputitems]
Exemplo n.º 4
0
class Dialog(qg.QDialog):

    def __init__(
            self,
            operationlist,
            index0,
            operationindeces1=None,
            operationindeces2=None):
        super(Dialog, self).__init__()

        if operationindeces1 is None:
            operationindeces1 = []
        if operationindeces2 is None:
            operationindeces2 = []

        from popupcad.widgets.operationlist import OperationList
        self.le0 = OperationList(
            LaminateOperation2.unaryoperationtypes,
            LaminateOperation2.pairoperationtypes,
            LaminateOperation2.displayorder)
        self.operationlist = operationlist

        self.unarylistwidget = DraggableTreeWidget()
        self.unarylistwidget.linklist(self.operationlist)
        self.unarylistwidget.setSelectionMode(qg.QListWidget.ExtendedSelection)
        self.unarylistwidget.selectIndeces(operationindeces1)

        self.pairlistwidget = DraggableTreeWidget()
        self.pairlistwidget.linklist(self.operationlist)
        self.pairlistwidget.setSelectionMode(
            qg.QListWidget.ExtendedSelection)
        self.pairlistwidget.selectIndeces(operationindeces2)

        layout3 = qg.QVBoxLayout()
        layout3.addWidget(qg.QLabel('Unary Operators'))
        layout3.addWidget(self.unarylistwidget)

        layout4 = qg.QVBoxLayout()
        layout4.addWidget(qg.QLabel('Binary Operators'))
        layout4.addWidget(self.pairlistwidget)

        layout5 = qg.QHBoxLayout()
        layout5.addLayout(layout3)
        layout5.addLayout(layout4)

        button1 = qg.QPushButton('Ok')
        button2 = qg.QPushButton('Cancel')
        layout2 = qg.QHBoxLayout()
        layout2.addWidget(button1)
        layout2.addWidget(button2)

        layout = qg.QVBoxLayout()
        layout.addWidget(self.le0)
        layout.addLayout(layout5)
#        layout.addWidget(self.unarylistwidget)
#        layout.addWidget(self.pairlistwidget)
        layout.addLayout(layout2)

        self.setLayout(layout)

        button1.clicked.connect(self.accept)
        button2.clicked.connect(self.reject)

        self.le0.unary_selected.connect(
            lambda: self.pairlistwidget.setEnabled(False))
        self.le0.binary_selected.connect(
            lambda: self.pairlistwidget.setEnabled(True))
        self.le0.setCurrentIndex(index0)

    def acceptdata(self):
        unaryparents = self.unarylistwidget.currentRefs()
        pairparents = self.pairlistwidget.currentRefs()
        function = self.le0.currentText()
        operation_links = {'unary': unaryparents, 'binary': pairparents}
        return operation_links, function
Exemplo n.º 5
0
class Dialog(qg.QDialog):
    def __init__(self,cls,design,operations,selectedopindex=None,outputref = 0,selectedoutput = None,sketch = None,operation_type_index = 0):
        super(Dialog,self).__init__()
        self.design = design
        self.operations = [NullOp()]+operations
        self.cls = cls

        self.optree = DraggableTreeWidget()
        self.optree.linklist(self.operations)
        if selectedopindex!=None:
            selectedopindex = selectedopindex+1
        else:
            selectedopindex = 0
        
        self.optree.selectIndeces([(selectedopindex,outputref)])

        self.sketchwidget = SketchListManager(self.design)
        for ii in range(self.sketchwidget.itemlist.count()):
            item = self.sketchwidget.itemlist.item(ii)
            if item.value==sketch:
                item.setSelected(True)
        
        if selectedoutput == None:
            selectedoutput = [item.id for item in design.return_layer_definition().layers]
        self.outputlayerselector = qg.QListWidget()
        self.outputlayerselector.setSelectionBehavior(qg.QListWidget.SelectionBehavior.SelectRows)
        self.outputlayerselector.setSelectionMode(qg.QListWidget.SelectionMode.MultiSelection)
        outputitems = [popupcad.filetypes.listwidgetitem.ListWidgetItem(item,self.outputlayerselector) for item in design.return_layer_definition().layers]
        [item.setSelected(item.customdata.id in selectedoutput) for item in outputitems]        

        from popupcad.widgets.operationlist import OperationList
        self.operationtypeselector = OperationList([],cls.function_names,cls.function_names)
        self.operationtypeselector.setCurrentIndex(operation_type_index)        

        button1 = qg.QPushButton('Ok')
        button2 = qg.QPushButton('Cancel')
        buttonlayout = qg.QHBoxLayout()
        buttonlayout.addWidget(button1)
        buttonlayout.addWidget(button2)

        layout = qg.QVBoxLayout()
        layout.addWidget(self.sketchwidget)
        layout.addWidget(self.operationtypeselector)
        layout.addWidget(qg.QLabel('Parent Operation'))
        layout.addWidget(self.optree)
        layout.addWidget(qg.QLabel('Select Layers'))
        layout.addWidget(self.outputlayerselector)
        layout.addLayout(buttonlayout)
        self.setLayout(layout)        

        button1.pressed.connect(self.accept)
        button2.pressed.connect(self.reject)


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

    def acceptdata(self):
        sketchid =  self.sketch().id

        selected_indeces = self.optree.currentIndeces2()
        if len(selected_indeces)>0:
            ii,jj = selected_indeces[0]
        else:
            ii,jj = 0,0
            self.operationeditor.selectIndeces([(ii,jj)])
            
        ii -= 1
        if ii==-1:
            operation_link1, outputref = None,0
        else:
            operation_link1, outputref = self.optree.currentRefs()[0]
        
        layer_links = [item.customdata.id for item in self.outputlayerselector.selectedItems()]

        operation_type_index = self.operationtypeselector.currentIndex()

        function = self.cls.operationtypes[operation_type_index]
#        outputref = 0
        return sketchid, operation_link1,layer_links,function,outputref
Exemplo n.º 6
0
    def __init__(self,
                 operations,
                 layerlist,
                 index0=0,
                 selectedop=None,
                 selectedunary=None,
                 selectedpair=None,
                 selectedoutput=None,
                 outputref=0):
        super(Dialog, self).__init__()

        sp = qg.QSizePolicy()
        sp.setHorizontalPolicy(sp.Minimum)
        sp.setVerticalPolicy(sp.Minimum)
        if selectedop is None:
            selectedop = len(operations) - 1
        if selectedunary is None:
            selectedunary = []
        if selectedpair is None:
            selectedpair = []
        if selectedoutput is None:
            selectedoutput = layerlist

        from popupcad.widgets.operationlist import OperationList
        self.le0 = OperationList(LayerOp2.unaryoperationtypes,
                                 LayerOp2.pairoperationtypes,
                                 LayerOp2.displayorder)

        self.operations = operations
        self.operationselector = DraggableTreeWidget()
        self.operationselector.linklist(self.operations)
        self.operationselector.selectIndeces([(selectedop, outputref)])

        self.unarylayerselector = qg.QListWidget()
        self.unarylayerselector.setSelectionBehavior(qg.QListWidget.SelectRows)
        self.unarylayerselector.setSelectionMode(qg.QListWidget.MultiSelection)
        unaryitems = [
            ListWidgetItem(item, self.unarylayerselector) for item in layerlist
        ]

        self.pairlayerselector = qg.QListWidget()
        self.pairlayerselector.setSelectionBehavior(qg.QListWidget.SelectRows)
        self.pairlayerselector.setSelectionMode(qg.QListWidget.MultiSelection)
        pairitems = [
            ListWidgetItem(item, self.pairlayerselector) for item in layerlist
        ]

        self.outputlayerselector = qg.QListWidget()
        self.outputlayerselector.setSelectionBehavior(
            qg.QListWidget.SelectRows)
        self.outputlayerselector.setSelectionMode(
            qg.QListWidget.MultiSelection)
        outputitems = [
            ListWidgetItem(item, self.outputlayerselector)
            for item in layerlist
        ]

        layout2 = qg.QVBoxLayout()
        #        self.layout2.setContentsMargins(0,0,0,0)
        layout2.addWidget(qg.QLabel('Unary Operators'))
        layout2.addWidget(self.unarylayerselector)

        layout3 = qg.QVBoxLayout()
        #        self.layout2.setContentsMargins(0,0,0,0)
        layout3.addWidget(qg.QLabel('Binary Operators'))
        layout3.addWidget(self.pairlayerselector)

        layout4 = qg.QHBoxLayout()
        layout4.addLayout(layout2)
        layout4.addLayout(layout3)

        layout = qg.QVBoxLayout()
        layout.addWidget(self.le0)
        layout.addWidget(qg.QLabel('Parent Operation'))
        layout.addWidget(self.operationselector)
        layout.addLayout(layout4)
        layout.addWidget(qg.QLabel('Output Layers'))
        layout.addWidget(self.outputlayerselector)

        button1 = qg.QPushButton('Ok')
        button2 = qg.QPushButton('Cancel')

        layout2 = qg.QHBoxLayout()
        layout2.addWidget(button1)
        layout2.addWidget(button2)

        layout.addLayout(layout2)

        self.setLayout(layout)
        button1.clicked.connect(self.accept)
        button2.clicked.connect(self.reject)

        self.le0.unary_selected.connect(
            lambda: self.pairlayerselector.setEnabled(False))
        self.le0.binary_selected.connect(
            lambda: self.pairlayerselector.setEnabled(True))
        self.le0.setCurrentIndex(index0)

        [
            item.setSelected(item.customdata.id in selectedunary)
            for item in unaryitems
        ]
        [
            item.setSelected(item.customdata.id in selectedpair)
            for item in pairitems
        ]
        [
            item.setSelected(item.customdata.id in selectedoutput)
            for item in outputitems
        ]
Exemplo n.º 7
0
    def __init__(self,
                 operationlist,
                 index0,
                 operationindeces1=None,
                 operationindeces2=None):
        super(Dialog, self).__init__()

        if operationindeces1 is None:
            operationindeces1 = []
        if operationindeces2 is None:
            operationindeces2 = []

        from popupcad.widgets.operationlist import OperationList
        self.le0 = OperationList(LaminateOperation2.unaryoperationtypes,
                                 LaminateOperation2.pairoperationtypes,
                                 LaminateOperation2.displayorder)
        self.operationlist = operationlist

        self.unarylistwidget = DraggableTreeWidget()
        self.unarylistwidget.linklist(self.operationlist)
        self.unarylistwidget.setSelectionMode(qg.QListWidget.ExtendedSelection)
        self.unarylistwidget.selectIndeces(operationindeces1)

        self.pairlistwidget = DraggableTreeWidget()
        self.pairlistwidget.linklist(self.operationlist)
        self.pairlistwidget.setSelectionMode(qg.QListWidget.ExtendedSelection)
        self.pairlistwidget.selectIndeces(operationindeces2)

        layout3 = qg.QVBoxLayout()
        layout3.addWidget(qg.QLabel('Unary Operators'))
        layout3.addWidget(self.unarylistwidget)

        layout4 = qg.QVBoxLayout()
        layout4.addWidget(qg.QLabel('Binary Operators'))
        layout4.addWidget(self.pairlistwidget)

        layout5 = qg.QHBoxLayout()
        layout5.addLayout(layout3)
        layout5.addLayout(layout4)

        button1 = qg.QPushButton('Ok')
        button2 = qg.QPushButton('Cancel')
        layout2 = qg.QHBoxLayout()
        layout2.addWidget(button1)
        layout2.addWidget(button2)

        layout = qg.QVBoxLayout()
        layout.addWidget(self.le0)
        layout.addLayout(layout5)
        #        layout.addWidget(self.unarylistwidget)
        #        layout.addWidget(self.pairlistwidget)
        layout.addLayout(layout2)

        self.setLayout(layout)

        button1.clicked.connect(self.accept)
        button2.clicked.connect(self.reject)

        self.le0.unary_selected.connect(
            lambda: self.pairlistwidget.setEnabled(False))
        self.le0.binary_selected.connect(
            lambda: self.pairlistwidget.setEnabled(True))
        self.le0.setCurrentIndex(index0)