当前位置: 首页>>代码示例>>Python>>正文


Python DraggableTreeWidget.currentIndeces2方法代码示例

本文整理汇总了Python中popupcad.widgets.dragndroptree.DraggableTreeWidget.currentIndeces2方法的典型用法代码示例。如果您正苦于以下问题:Python DraggableTreeWidget.currentIndeces2方法的具体用法?Python DraggableTreeWidget.currentIndeces2怎么用?Python DraggableTreeWidget.currentIndeces2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在popupcad.widgets.dragndroptree.DraggableTreeWidget的用法示例。


在下文中一共展示了DraggableTreeWidget.currentIndeces2方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DraggableTreeDialog

# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentIndeces2 [as 别名]
class DraggableTreeDialog(qg.QDialog):
    def __init__(self, list_in, *args, **kwargs):
        super(DraggableTreeDialog, self).__init__(*args, **kwargs)
        self.listwidget = DraggableTreeWidget()

        button_ok = qg.QPushButton('Ok')
        button_cancel = qg.QPushButton('Cancel')
        
        sub_layout1 = qg.QHBoxLayout()
        sub_layout1.addWidget(button_ok)
        sub_layout1.addWidget(button_cancel)

        layout = qg.QVBoxLayout()
        layout.addWidget(self.listwidget)
        layout.addLayout(sub_layout1)

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

        self.listwidget.linklist(list_in)

    def set_data(self,ini):
        self.listwidget.selectIndeces(ini)

    def results(self):
        return self.listwidget.currentIndeces2()
开发者ID:nickgravish,项目名称:popupcad,代码行数:29,代码来源:table_editor_popup.py

示例2: Dialog

# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentIndeces2 [as 别名]

#.........这里部分代码省略.........

        number_of_parts_and_scale.addWidget(qg.QLabel('Scale'))
        self.scale = qg.QLineEdit()
        number_of_parts_and_scale.addWidget(self.scale)
        number_of_parts_and_scale.addStretch()

        #                       'x-gap', 'y-gap'
        xy_gap = qg.QHBoxLayout()
        xy_gap.addStretch()

        xy_gap.addWidget(qg.QLabel('X-gap'))
        self.x_gap = qg.QLineEdit()
        xy_gap.addWidget(self.x_gap)

        xy_gap.addWidget(qg.QLabel('Y-gap'))
        self.y_gap = qg.QLineEdit()
        xy_gap.addWidget(self.y_gap)
        xy_gap.addStretch()

        s_offset = qg.QHBoxLayout()
        s_offset.addStretch()
        s_offset.addWidget(qg.QLabel('Support offset'))
        self.support_offset = qg.QLineEdit()
        s_offset.addWidget(self.support_offset)
        s_offset.addStretch()

        # Button 1 and 2
        buttons = qg.QHBoxLayout()
        button1 = qg.QPushButton('Ok')
        button1.clicked.connect(self.accept)
        buttons.addWidget(button1)

        button2 = qg.QPushButton('Cancel')
        button2.clicked.connect(self.reject)
        buttons.addWidget(button2)

        instructions = qg.QHBoxLayout()
        instructions.addStretch()
        instructions.addWidget(qg.QLabel("Part to tile | Release cut (optional) | "
                                                               "Bounding box sketch | Sheet to tile into"))
        instructions.addStretch()


        layout = qg.QVBoxLayout()
        layout.addLayout(instructions)
        layout.addLayout(layout_ops_sheet_sketch)
        layout.addLayout(number_of_parts_and_scale)
        layout.addLayout(xy_gap)
        layout.addLayout(s_offset)
        layout.addLayout(buttons)
        self.setLayout(layout)

        # set text of all boxes
        self.scale.setText(str(self.sc_tp))
        self.N.setText(str(self.N_tp))
        self.y_gap.setText(str(self.y_gap_tp))
        self.x_gap.setText(str(self.x_gap_tp))
        self.support_offset.setText(str(self.support_offset_tp))

    def build_sketch_links(self):
        try:
            sketch_links = {}
            sketch_links['sketch_from']=[self.sketch_to_tile.itemlist.selectedItems()[0].value.id]
            return sketch_links
        except IndexError:
            return None

    def acceptdata(self):

        # get operation reference for part
        ii, jj = self.part.currentIndeces2()[0]
        opid = self.design.operations[ii].id
        part_opref = opid

        # get operation reference for sheet
        ii, jj = self.sheet.currentIndeces2()[0]
        opid = self.design.operations[ii].id
        sheet_opref = opid

        # get operation reference for release
        ii, jj = self.release.currentIndeces2()[0]
        opid = self.design.operations[ii].id
        release_opref = opid

        # get bounding box from the sketch
        tmp_sketch_id = self.sketch_to_tile.itemlist.selectedItems()[0].value.id
        sketch_bounding_box = self.design.sketches[tmp_sketch_id].output_csg()[0].bounds # may break if multiple sketches
        sketch_bounding_box = [geom/popupcad.csg_processing_scaling for geom in sketch_bounding_box]

        sketch_id = self.sketch_to_tile.itemlist.selectedItems()[0].value


        N = int(self.N.text())
        scale = float(self.scale.text())
        x_gap = float(self.x_gap.text())
        y_gap = float(self.y_gap.text())
        support_offset = float(self.support_offset.text())

        return part_opref, release_opref, sheet_opref, sketch_bounding_box, N, scale, \
               x_gap, y_gap, support_offset, sketch_id
开发者ID:heiko114514,项目名称:popupcad,代码行数:104,代码来源:tilepart.py

示例3: Dialog

# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentIndeces2 [as 别名]
class Dialog(qg.QDialog):

    def __init__(
            self,
            operationlist,
            device_index=0,
            support_index=0,
            support_width=1.0,
            support_out=1.0,
            hole_radius=1.0,
            cut_width=1.0,
            deviceoutputref=0,
            supportoutputref=0):
        super(Dialog, self).__init__()

        self.operationlist = operationlist

        self.device_index = DraggableTreeWidget()
        self.device_index.linklist(self.operationlist)
#        self.device_index.setCurrentIndeces(device_index,deviceoutputref)
        self.device_index.selectIndeces([(device_index, deviceoutputref)])

        self.support_index = DraggableTreeWidget()
        self.support_index.linklist(self.operationlist)
#        self.support_index.setCurrentIndeces(support_index,supportoutputref)
        self.support_index.selectIndeces([(support_index, supportoutputref)])

        self.support_width = qg.QLineEdit()
        self.support_width.setAlignment(qc.Qt.AlignRight)
        self.support_width.setText(str(support_width))
        v = StrictDoubleValidator(0, 1e6, 4, self.support_width)
        self.support_width.setValidator(v)

        self.support_out = qg.QLineEdit()
        self.support_out.setAlignment(qc.Qt.AlignRight)
        self.support_out.setText(str(support_out))
        v = StrictDoubleValidator(0, 1e6, 4, self.support_out)
        self.support_out.setValidator(v)

        self.hole_radius = qg.QLineEdit()
        self.hole_radius.setAlignment(qc.Qt.AlignRight)
        self.hole_radius.setText(str(hole_radius))
        v = StrictDoubleValidator(0, 1e6, 4, self.hole_radius)
        self.hole_radius.setValidator(v)

        self.cut_width = qg.QLineEdit()
        self.cut_width.setAlignment(qc.Qt.AlignRight)
        self.cut_width.setText(str(cut_width))
        v = StrictDoubleValidator(0, 1e6, 4, self.cut_width)
        self.cut_width.setValidator(v)

        self.Device = qg.QRadioButton('Device')
        self.Support = qg.QRadioButton('Support')
        self.Cuts = qg.QRadioButton('Cuts')

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

        layout = qg.QGridLayout()
#        layout = qg.QVBoxLayout()
        layout.addWidget(qg.QLabel('Device'), 1, 1)
        layout.addWidget(self.device_index, 1, 2)
        layout.addWidget(qg.QLabel('Support Sketch'), 2, 1)
        layout.addWidget(self.support_index, 2, 2)
        layout.addWidget(qg.QLabel('Support Width'), 3, 1)
        layout.addWidget(self.support_width, 3, 2)
        layout.addWidget(qg.QLabel('Support Out'), 4, 1)
        layout.addWidget(self.support_out, 4, 2)
        layout.addWidget(qg.QLabel('Hole Radius'), 5, 1)
        layout.addWidget(self.hole_radius, 5, 2)
        layout.addWidget(qg.QLabel('CutWidth'), 6, 1)
        layout.addWidget(self.cut_width, 6, 2)
        layout.addWidget(button1, 7, 1)
        layout.addWidget(button2, 7, 2)

        self.setLayout(layout)

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

    def acceptdata(self):
        ii, kk = self.device_index.currentIndeces2()[0]
        jj, ll = self.support_index.currentIndeces2()[0]
        return self.operationlist[ii].id, self.operationlist[jj].id, float(
            self.support_width.text()), float(
            self.support_out.text()), float(
            self.hole_radius.text()), float(
                self.cut_width.text()), kk, ll
开发者ID:Skylion007,项目名称:popupcad,代码行数:90,代码来源:customsupport2.py

示例4: Dialog

# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentIndeces2 [as 别名]

#.........这里部分代码省略.........
        layout4.addWidget(self.sb)

        button1 = qg.QPushButton('Ok')
        button1.clicked.connect(self.accept)
        button2 = qg.QPushButton('Cancel')
        button2.clicked.connect(self.reject)

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

        layout3 = qg.QHBoxLayout()
        layout3.addWidget(self.sketchwidget_from)
        layout3.addWidget(self.sketchwidget_to)

        layout = qg.QVBoxLayout()
        layout.addWidget(qg.QLabel('Operations'))
        layout.addWidget(self.operation_list)
#        layout.addWidget(qg.QLabel('Sketch'))
        layout.addLayout(layout3)
        layout.addLayout(templayout1)
        layout.addLayout(templayout2)
        layout.addLayout(layout5)
        layout.addLayout(layout4)
        layout.addLayout(layout2)
        self.setLayout(layout)

        self.radiobox_scale_x.setChecked(False)
        self.radiobox_custom_x.setChecked(False)
        self.radiobox_scale_y.setChecked(False)
        self.radiobox_custom_y.setChecked(False)

        if self.placeop.transformtype_x == TransformInternal.transformtypes.scale:
            self.radiobox_scale_x.setChecked(True)
        elif self.placeop.transformtype_x == TransformInternal.transformtypes.custom:
            self.radiobox_custom_x.setChecked(True)

        if self.placeop.transformtype_y == TransformInternal.transformtypes.scale:
            self.radiobox_scale_y.setChecked(True)
        elif self.placeop.transformtype_y == TransformInternal.transformtypes.custom:
            self.radiobox_custom_y.setChecked(True)

        if self.placeop.sketch_links is not None:
            sketch_from = self.design.sketches[self.placeop.sketch_links['sketch_from'][0]]
            sketch_to = self.design.sketches[self.placeop.sketch_links['sketch_to'][0]]

            for ii in range(self.sketchwidget_from.itemlist.count()):
                item = self.sketchwidget_from.itemlist.item(ii)
                if item.value == sketch_from:
                    item.setSelected(True)
    
            for ii in range(self.sketchwidget_to.itemlist.count()):
                item = self.sketchwidget_to.itemlist.item(ii)
                if item.value == sketch_to:
                    item.setSelected(True)

        if self.placeop.operation_links is not None:
            id, jj = self.placeop.operation_links['from'][0]
            ii = design.operation_index(id)
            self.operation_list.selectIndeces([(ii, jj)])

        self.scalex.setText(str(self.placeop.scalex))
        self.scaley.setText(str(self.placeop.scaley))
        self.flip.setChecked(self.placeop.flip)
        self.sb.setValue(self.placeop.shift)
        self.sketchwidget_from.items_updated.connect(lambda:self.sketchwidget_to.refresh_list(retain_selection=True))
        self.sketchwidget_to.items_updated.connect(lambda:self.sketchwidget_from.refresh_list(retain_selection=True))
        
    def build_sketch_links(self):
        try:
            sketch_links = {}
            sketch_links['sketch_from']=[self.sketchwidget_from.itemlist.selectedItems()[0].value.id]
            sketch_links['sketch_to']=[self.sketchwidget_to.itemlist.selectedItems()[0].value.id]
            return sketch_links
        except IndexError:
            return None

    def acceptdata(self):
        if self.radiobox_scale_x.isChecked():
            transformtype_x = TransformInternal.transformtypes.scale
        elif self.radiobox_custom_x.isChecked():
            transformtype_x = TransformInternal.transformtypes.custom

        if self.radiobox_scale_y.isChecked():
            transformtype_y = TransformInternal.transformtypes.scale
        elif self.radiobox_custom_y.isChecked():
            transformtype_y = TransformInternal.transformtypes.custom

        ii, jj = self.operation_list.currentIndeces2()[0]
        opid = self.design.operations[ii].id
        opref = opid, jj
        operation_links = {'from':[opref]}
        sketch_links = self.build_sketch_links()
        
        shift = self.sb.value()
        flip = self.flip.isChecked()
        scale_x = float(self.scalex.text())
        scale_y = float(self.scaley.text())
                      
        return sketch_links, operation_links,transformtype_x, transformtype_y, shift, flip, scale_x, scale_y
开发者ID:heiko114514,项目名称:popupcad,代码行数:104,代码来源:transform_internal.py

示例5: Dialog

# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentIndeces2 [as 别名]
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
开发者ID:apullin,项目名称:popupcad,代码行数:85,代码来源:sketchoperation2.py

示例6: Dialog

# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentIndeces2 [as 别名]

#.........这里部分代码省略.........

#        layout3 = qg.QHBoxLayout()
#        layout3.addWidget(self.lineedit)
#        layout3.addWidget(button3)

        button1 = qg.QPushButton('Ok')
        button1.clicked.connect(self.accept)
        button2 = qg.QPushButton('Cancel')
        button2.clicked.connect(self.reject)

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

        layout = qg.QVBoxLayout()
#        layout.addWidget(qg.QLabel('Design'))
        layout.addWidget(self.designwidget)
        layout.addWidget(qg.QLabel('Sub-Design Operations'))
        layout.addWidget(self.optree)
#        layout.addWidget(qg.QLabel('Sketch'))
        layout.addWidget(self.sketchwidget)
        layout.addLayout(templayout1)
        layout.addLayout(templayout2)
        layout.addLayout(layout5)
        layout.addLayout(layout4)
        layout.addLayout(layout2)
        self.setLayout(layout)

        self.radiobox_scale_x.setChecked(False)
        self.radiobox_custom_x.setChecked(False)
        self.radiobox_scale_y.setChecked(False)
        self.radiobox_custom_y.setChecked(False)

        if self.transformtype_x == PlaceOperation8.transformtypes.scale:
            self.radiobox_scale_x.setChecked(True)
        elif self.transformtype_x == PlaceOperation8.transformtypes.custom:
            self.radiobox_custom_x.setChecked(True)

        if self.transformtype_y == PlaceOperation8.transformtypes.scale:
            self.radiobox_scale_y.setChecked(True)
        elif self.transformtype_y == PlaceOperation8.transformtypes.custom:
            self.radiobox_custom_y.setChecked(True)

        self.designwidget.itemlist.itemSelectionChanged.connect(
            self.loadoperations)

        for ii in range(self.designwidget.itemlist.count()):
            item = self.designwidget.itemlist.item(ii)
            if item.value == subdesign:
                item.setSelected(True)

        for ii in range(self.sketchwidget.itemlist.count()):
            item = self.sketchwidget.itemlist.item(ii)
            if item.value == sketch:
                item.setSelected(True)

        self.loadoperations()
        try:
            if subopref is not None:
                id, jj = subopref
                if subdesign is not None:
                    ii = subdesign.operation_index(id)
                    self.optree.selectIndeces([(ii, jj)])
        except NoOperation:
            pass

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

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

    def loadoperations(self):
        if len(self.designwidget.itemlist.selectedItems()) > 0:
            self.optree.linklist(self.subdesign().operations)

    def acceptdata(self):
        if self.radiobox_scale_x.isChecked():
            transformtype_x = PlaceOperation8.transformtypes.scale
        elif self.radiobox_custom_x.isChecked():
            transformtype_x = PlaceOperation8.transformtypes.custom

        if self.radiobox_scale_y.isChecked():
            transformtype_y = PlaceOperation8.transformtypes.scale
        elif self.radiobox_custom_y.isChecked():
            transformtype_y = PlaceOperation8.transformtypes.custom

        ii, jj = self.optree.currentIndeces2()[0]
        subopid = self.subdesign().operations[ii].id
        subopref = subopid, jj
        sketch_links = {'place': [self.sketch().id]}
        design_links = {'subdesign': [self.subdesign().id]}
        return sketch_links, design_links, subopref, transformtype_x, transformtype_y, self.sb.value(
        ), self.flip.isChecked(), float(self.scalex.text()), float(self.scaley.text())
开发者ID:heiko114514,项目名称:popupcad,代码行数:104,代码来源:placeop8.py

示例7: Sketcher

# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentIndeces2 [as 别名]

#.........这里部分代码省略.........
        ii -= 1
        if ii >= 0:
            if self.design is not None:
                print(ii, jj)
                try:
                    operationgeometries = self.design.operations[
                        ii].output[jj].controlpolygons()
                    staticgeometries = [item.outputstatic()
                                        for item in operationgeometries]

                    controlpoints = self.design.operations[
                        ii].output[jj].controlpoints()
                    controlpoints = [point.gen_interactive()
                                     for point in controlpoints]

                    controllines = self.design.operations[
                        ii].output[jj].controllines()
                    controllines = [line.gen_interactive()
                                    for line in controllines]
                except (IndexError, AttributeError):
                    pass
        return staticgeometries, controlpoints, controllines

    def load_references_inner(self, ii, jj):
        self.scene.removerefgeoms()
        self.static_items, self.controlpoints, self.controllines = self.load_references3(
            ii, jj)
        self.scene.update_extra_objects(self.controlpoints + self.controllines)
        self.scene.updatevertices()
        [self.scene.addItem(item) for item in self.static_items]

    def load_references(self):
        if self.selectops:
            selected_indeces = self.optree.currentIndeces2()
            if len(selected_indeces) > 0:
                ii, jj = selected_indeces[0]
                self.load_references_inner(ii, jj)

    def flipdirection(self):
        selecteditems = self.scene.selectedItems()
        for item in selecteditems:
            item.generic.flip()
            item.updateshape()

    def hollow(self):
        selecteditems = self.scene.selectedItems()
        newgenerics = []
        for item in selecteditems:
            newgenerics.extend(item.generic.hollow())
            item.harddelete()
        for item in newgenerics:
            self.scene.addItem(item.outputinteractive())

    def fill(self):
        selecteditems = self.scene.selectedItems()
        newgenerics = []
        for item in selecteditems:
            newgenerics.extend(item.generic.fill())
            item.harddelete()
        for item in newgenerics:
            self.scene.addItem(item.outputinteractive())

    def array(self):
        dialog = qg.QDialog()
        x_num = qg.QSpinBox()
        x_num.setValue(2)
开发者ID:jackcarter125,项目名称:popupcad,代码行数:70,代码来源:sketcher.py

示例8: Sketcher

# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentIndeces2 [as 别名]

#.........这里部分代码省略.........
    def acceptdata(self):
        self.update_sketch_geometries()
        return self.sketch,

    def load_references3(self, ii, jj):
        staticgeometries, controlpoints, controllines = [], [], []
        ii -= 1
        if ii >= 0:
            if self.design is not None:
                print(ii, jj)
                try:
                    operationgeometries = self.design.operations[ii].output[jj].controlpolygons()
                    staticgeometries = [item.outputstatic() for item in operationgeometries]

                    controlpoints = self.design.operations[ii].output[jj].controlpoints()
                    controlpoints = [point.gen_interactive() for point in controlpoints]

                    controllines = self.design.operations[ii].output[jj].controllines()
                    controllines = [line.gen_interactive() for line in controllines]
                except (IndexError, AttributeError):
                    pass
        return staticgeometries, controlpoints, controllines

    def load_references_inner(self, ii, jj):
        self.scene.removerefgeoms()
        self.static_items, self.controlpoints, self.controllines = self.load_references3(
            ii, jj)
        self.scene.update_extra_objects(self.controlpoints + self.controllines)
        self.scene.updatevertices()
        [self.scene.addItem(item) for item in self.static_items]

    def load_references(self):
        if self.selectops:
            selected_indeces = self.optree.currentIndeces2()
            if len(selected_indeces) > 0:
                ii, jj = selected_indeces[0]
                self.load_references_inner(ii, jj)

    def flipdirection(self):
        selecteditems = self.scene.selectedItems()
        for item in selecteditems:
            item.generic.flip()
            item.updateshape()

    def hollow(self):
        selecteditems = self.scene.selectedItems()
        newgenerics = []
        for item in selecteditems:
            newgenerics.extend(item.generic.hollow())
            item.harddelete()
        for item in newgenerics:
            self.scene.addItem(item.outputinteractive())

    def fill(self):
        selecteditems = self.scene.selectedItems()
        newgenerics = []
        for item in selecteditems:
            newgenerics.extend(item.generic.fill())
            item.harddelete()
        for item in newgenerics:
            self.scene.addItem(item.outputinteractive())

    def extract(self):
        if self.selectops:
            selected_indeces = self.optree.currentIndeces2()
            if len(selected_indeces) > 0:
开发者ID:nickgravish,项目名称:popupcad,代码行数:70,代码来源:sketcher.py

示例9: Sketcher

# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentIndeces2 [as 别名]

#.........这里部分代码省略.........
        if self.accept_method!=None:
            self.accept_method(*self.acceptdata())
        self.close()

    def reject(self):
        self.close()

    def keyPressEvent(self,event):
        if not self.keypressfiltering(event):
            super(Sketcher,self).keyPressEvent(event)
    
    def loadpropwindow(self,obj):
        widget = obj.properties()
        self.propdock.setWidget(widget)        
        
    def acceptdata(self):
        self.buildsketch()
        return self.sketch,

    def keypressfiltering(self,event):
        if event.key() == qc.Qt.Key_Escape:
            return True
        elif event.key() == qc.Qt.Key_Enter:
            return True
        elif event.key() == qc.Qt.Key_Return:
            return True
        else:
            return False

    def load_references3(self,ii,jj):
        staticgeometries,controlpoints,controllines = [],[],[]        
        ii-=1
        if ii>=0:
            if self.design !=None:
                print(ii,jj)
                try:
                    operationgeometries = self.design.operations[ii].output[jj].controlpolygons()
                    staticgeometries =  [item.outputstatic() for item in operationgeometries]
    
                    controlpoints = self.design.operations[ii].output[jj].controlpoints()
                    controlpoints = [point.gen_interactive() for point in controlpoints]
    
                    controllines = self.design.operations[ii].output[jj].controllines()
                    controllines = [line.gen_interactive() for line in controllines]
                except (IndexError,AttributeError):
                    pass
        return staticgeometries,controlpoints,controllines
    
    def load_references_inner(self,ii,jj):
        self.scene.removerefgeoms()
        self.static_items,self.controlpoints,self.controllines = self.load_references3(ii,jj)
        self.scene.update_extra_objects(self.controlpoints+self.controllines)
        self.scene.updatevertices()
        [self.scene.addItem(item) for item in self.static_items]

    def load_references(self):
        if self.selectops:
            selected_indeces = self.optree.currentIndeces2()
            if len(selected_indeces)>0:
                ii,jj = selected_indeces[0]
                self.load_references_inner(ii,jj)

    def group(self):
        from popupcad.graphics2d.grouper import Grouper
        o = Grouper()        
        selecteditems = self.scene.selectedItems()
        associateditems = [vertex for item in selecteditems if hasattr(item,'handles') for vertex in item.handles()]
        selecteditems+associateditems
        o.addchildren(associateditems)
        self.scene.addItem(o)
        
    def ungroup(self):
        from popupcad.graphics2d.grouper import Grouper
        for item in self.scene.selectedItems():
            if isinstance(item,Grouper):
                item.resetTransform()
                item.setPos(0,0)
                item.removegroupeditems()
                item.softdelete()
    def flipdirection(self):
        selecteditems = self.scene.selectedItems()
        for item in selecteditems:
            item.generic.flip()
            item.updateshape()
    def hollow(self):
        selecteditems = self.scene.selectedItems()
        newgenerics = []
        for item in selecteditems:
            newgenerics.append(item.generic.hollow())
            item.harddelete()
        for item in newgenerics:
            self.scene.addItem(item.outputinteractive())
    def fill(self):
        selecteditems = self.scene.selectedItems()
        newgenerics = []
        for item in selecteditems:
            newgenerics.append(item.generic.fill())
            item.harddelete()
        for item in newgenerics:
            self.scene.addItem(item.outputinteractive())
开发者ID:apullin,项目名称:popupcad,代码行数:104,代码来源:sketcher.py

示例10: Dialog

# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentIndeces2 [as 别名]

#.........这里部分代码省略.........
        elif self.placeop.transformtype_y == TransformExternal.transformtypes.custom:
            self.radiobox_custom_y.setChecked(True)

        self.designwidget.itemlist.itemSelectionChanged.connect(self.loadoperations)

        if self.placeop.sketch_links is not None:
            sketch_to = self.design.sketches[self.placeop.sketch_links["sketch_to"][0]]

            for ii in range(self.sketchwidget_to.itemlist.count()):
                item = self.sketchwidget_to.itemlist.item(ii)
                if item.value == sketch_to:
                    item.setSelected(True)

        self.loadoperations()

        try:
            subdesign = design.subdesigns[self.placeop.design_links["subdesign"][0]]
            for ii in range(self.designwidget.itemlist.count()):
                item = self.designwidget.itemlist.item(ii)
                if item.value == subdesign:
                    item.setSelected(True)

            if self.placeop.subopref is not None:
                id, jj = self.placeop.subopref
                ii = subdesign.operation_index(id)
                self.operation_list.selectIndeces([(ii, jj)])

            sketch_from = subdesign.sketches[self.placeop.sub_sketch_id]
            for ii in range(self.sketchwidget_from.itemlist.count()):
                item = self.sketchwidget_from.itemlist.item(ii)
                if item.value == sketch_from:
                    item.setSelected(True)
        except TypeError:
            pass

        self.scalex.setText(str(self.placeop.scalex))
        self.scaley.setText(str(self.placeop.scaley))
        self.flip.setChecked(self.placeop.flip)
        self.sb.setValue(self.placeop.shift)

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

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

    def build_sketch_links(self):
        try:
            sketch_links = {}
            sketch_links["sketch_to"] = [self.sketchwidget_to.itemlist.selectedItems()[0].value.id]
            return sketch_links
        except IndexError:
            return None

    def loadoperations(self):
        if len(self.designwidget.itemlist.selectedItems()) > 0:
            self.operation_list.linklist(self.subdesign().operations)
            self.sketchwidget_from.update_list(self.subdesign().sketches)

    def acceptdata(self):
        if self.radiobox_scale_x.isChecked():
            transformtype_x = TransformExternal.transformtypes.scale
        elif self.radiobox_custom_x.isChecked():
            transformtype_x = TransformExternal.transformtypes.custom

        if self.radiobox_scale_y.isChecked():
            transformtype_y = TransformExternal.transformtypes.scale
        elif self.radiobox_custom_y.isChecked():
            transformtype_y = TransformExternal.transformtypes.custom

        ii, jj = self.operation_list.currentIndeces2()[0]
        sketch_links = self.build_sketch_links()
        subopid = self.subdesign().operations[ii].id
        subopref = subopid, jj
        sub_sketch_id = self.sketchwidget_from.itemlist.selectedItems()[0].value.id
        design_links = {"subdesign": [self.subdesign().id]}

        shift = self.sb.value()
        flip = self.flip.isChecked()
        scale_x = float(self.scalex.text())
        scale_y = float(self.scaley.text())

        return (
            sketch_links,
            design_links,
            subopref,
            sub_sketch_id,
            transformtype_x,
            transformtype_y,
            shift,
            flip,
            scale_x,
            scale_y,
        )
开发者ID:jackcarter125,项目名称:popupcad,代码行数:104,代码来源:transform_external.py


注:本文中的popupcad.widgets.dragndroptree.DraggableTreeWidget.currentIndeces2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。