本文整理汇总了Python中popupcad.widgets.dragndroptree.DraggableTreeWidget.selectIndeces方法的典型用法代码示例。如果您正苦于以下问题:Python DraggableTreeWidget.selectIndeces方法的具体用法?Python DraggableTreeWidget.selectIndeces怎么用?Python DraggableTreeWidget.selectIndeces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类popupcad.widgets.dragndroptree.DraggableTreeWidget
的用法示例。
在下文中一共展示了DraggableTreeWidget.selectIndeces方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import selectIndeces [as 别名]
class Dialog(qg.QDialog):
def __init__(self, design, operations, selectedop=None, outputref=0):
super(Dialog, self).__init__()
self.design = design
self.le1 = DraggableTreeWidget()
self.le1.linklist(operations)
if selectedop is not None:
self.le1.selectIndeces([(selectedop, outputref)])
layout = qg.QVBoxLayout()
layout.addWidget(qg.QLabel('Operation to Flatten'))
layout.addWidget(self.le1)
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)
def acceptdata(self):
ref, ii = self.le1.currentRefs()[0]
generic = self.design.op_from_ref(ref).output[ii].generic_laminate()
return ref, ii, generic
示例2: DraggableTreeDialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import selectIndeces [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()
示例3: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import selectIndeces [as 别名]
class Dialog(qg.QDialog):
def __init__(self,operations,index,shift=0,flip=False,rotate = False,outputref = 0):
super(Dialog,self).__init__()
self.operations = operations
self.le1 = DraggableTreeWidget()
self.le1.linklist(self.operations)
self.le1.selectIndeces([(index,outputref)])
# self.le1.addItems([str(op) for op in operations])
layout5 = qg.QHBoxLayout()
layout5.addWidget(qg.QLabel('Flip Layers'))
self.flip = qg.QCheckBox()
self.flip.setChecked(flip)
layout5.addWidget(self.flip)
layout6 = qg.QHBoxLayout()
layout6.addWidget(qg.QLabel('Rotate Layers'))
self.rotate = qg.QCheckBox()
self.rotate.setChecked(rotate)
layout6.addWidget(self.rotate)
layout4 = qg.QHBoxLayout()
layout4.addWidget(qg.QLabel('Shift Layers'))
self.sb = qg.QSpinBox()
self.sb.setRange(-100,100)
self.sb.setSingleStep(1)
self.sb.setValue(shift)
layout4.addWidget(self.sb)
button1 = qg.QPushButton('Ok')
button2 = qg.QPushButton('Cancel')
layout2 = qg.QHBoxLayout()
layout2.addWidget(button1)
layout2.addWidget(button2)
layout = qg.QVBoxLayout()
layout.addWidget(qg.QLabel('Parent Operation'))
layout.addWidget(self.le1)
layout.addLayout(layout5)
layout.addLayout(layout6)
layout.addLayout(layout4)
layout.addLayout(layout2)
self.setLayout(layout)
button1.pressed.connect(self.accept)
button2.pressed.connect(self.reject)
# self.le1.setCurrentIndex(index)
def acceptdata(self):
# ii = self.le1.currentIndex()
ref,ii = self.le1.currentRefs()[0]
return ref,self.sb.value(),self.flip.isChecked(),self.rotate.isChecked(),ii
示例4: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import selectIndeces [as 别名]
class Dialog(qg.QDialog):
def __init__(self,design,operations,operation_index,sketch = None):
super(Dialog,self).__init__()
SketchListManager(design)
self.optree = DraggableTreeWidget()
self.optree.linklist(operations)
self.sketchwidget = SketchListManager(design)
button1 = qg.QPushButton('Ok')
button1.pressed.connect(self.accept)
button2 = qg.QPushButton('Cancel')
button2.pressed.connect(self.reject)
layout2 = qg.QHBoxLayout()
layout2.addWidget(button1)
layout2.addWidget(button2)
layout=qg.QVBoxLayout()
layout.addWidget(self.optree)
layout.addWidget(self.sketchwidget)
layout.addLayout(layout2)
self.setLayout(layout)
for ii in range(self.sketchwidget.itemlist.count()):
item = self.sketchwidget.itemlist.item(ii)
if item.value==sketch:
item.setSelected(True)
try:
self.optree.selectIndeces([operation_index])
except NoOperation:
pass
def acceptdata(self):
operation_links = {}
operation_links['source'] = [self.optree.currentRefs()[0]]
sketch_links= {}
try:
sketch_links['cross_section'] = [self.sketchwidget.itemlist.selectedItems()[0].value.id]
except IndexError:
pass
return operation_links,sketch_links,100
示例5: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import selectIndeces [as 别名]
class Dialog(qg.QDialog):
def __init__(
self,
keepouttypes,
valuenames,
defaults,
operations,
selectedop,
show,
values=None,
keepouttype=None,
outputref=0):
super(Dialog, self).__init__()
self.operations = operations
self.le1 = DraggableTreeWidget()
self.le1.linklist(self.operations)
self.le1.selectIndeces([(selectedop, outputref)])
if values is None:
values = defaults[:]
layout = qg.QVBoxLayout()
layout.addWidget(qg.QLabel('Parent Operation'))
layout.addWidget(self.le1)
self.valueboxes = []
for valuename, v in zip(valuenames, values):
templayout = qg.QHBoxLayout()
valueedit = qg.QLineEdit()
valueedit.setAlignment(qc.Qt.AlignRight)
valueedit.setText(str(v))
# self.valueedit.setInputMask('#009.0')
valueedit.setValidator(
qg.QDoubleValidator(-999.0, 999.0, 4, valueedit))
templayout.addStretch()
templayout.addWidget(qg.QLabel(valuename))
templayout.addWidget(valueedit)
self.valueboxes.append(valueedit)
layout.addLayout(templayout)
self.radiobuttons = []
if 'keepout' in show:
for key, value2 in keepouttypes.dict.items():
b = qg.QRadioButton(key)
b.setChecked(keepouttype == value2)
b.uservalue = value2
self.radiobuttons.append(b)
layout.addWidget(b)
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)
def acceptdata(self):
option = None
for b in self.radiobuttons:
if b.isChecked():
option = b.uservalue
ref, ii = self.le1.currentRefs()[0]
values = [float(valueedit.text()) for valueedit in self.valueboxes]
return ref, values, option, ii
示例6: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import selectIndeces [as 别名]
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
示例7: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import selectIndeces [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
示例8: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import selectIndeces [as 别名]
class Dialog(qg.QDialog):
def __init__(self,design,operationlist,device_index=0,support_width = 1.0,support_out = 1.0,hole_radius = 1.0,cut_width = 1.0,deviceoutputref = 0,sketch = None,selectedoutput = None):
super(Dialog,self).__init__()
self.design = design
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.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 = [ListWidgetItem(item,self.outputlayerselector) for item in design.return_layer_definition().layers]
[item.setSelected(item.customdata.id in selectedoutput) for item in outputitems]
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)
layout = qg.QVBoxLayout()
button1 = qg.QPushButton('Ok')
button2 = qg.QPushButton('Cancel')
gridlayout = qg.QGridLayout()
gridlayout.addWidget(qg.QLabel('Support Width'),1,1)
gridlayout.addWidget(self.support_width,1,2)
gridlayout.addWidget(qg.QLabel('Support Out'),2,1)
gridlayout.addWidget(self.support_out,2,2)
gridlayout.addWidget(qg.QLabel('Hole Radius'),3,1)
gridlayout.addWidget(self.hole_radius,3,2)
gridlayout.addWidget(qg.QLabel('CutWidth'),4,1)
gridlayout.addWidget(self.cut_width,4,2)
gridlayout.addWidget(button1,5,1)
gridlayout.addWidget(button2,5,2)
layout.addWidget(self.device_index)
layout.addWidget(self.sketchwidget)
layout.addWidget(self.outputlayerselector)
layout.addLayout(gridlayout)
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
opid,outputref= self.device_index.currentRefs()[0]
layer_links = [item.customdata.id for item in self.outputlayerselector.selectedItems()]
return opid,sketchid,layer_links,float(self.support_width.text()),float(self.support_out.text()),float(self.hole_radius.text()),float(self.cut_width.text()),outputref
示例9: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import selectIndeces [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
示例10: MainWidget
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import selectIndeces [as 别名]
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.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))
button_add = qg.QPushButton('Add')
button_remove = qg.QPushButton('Remove')
button_up = qg.QPushButton('up')
button_down = qg.QPushButton('down')
button_add.pressed.connect(self.table.row_add_empty)
button_remove.pressed.connect(self.table.row_remove)
button_up.pressed.connect(self.table.row_shift_up)
button_down.pressed.connect(self.table.row_shift_down)
sublayout1 = qg.QHBoxLayout()
sublayout1.addWidget(button_add)
sublayout1.addWidget(button_remove)
sublayout1.addStretch()
sublayout1.addWidget(button_up)
sublayout1.addWidget(button_down)
button_ok = qg.QPushButton('Ok')
button_cancel = qg.QPushButton('Cancel')
button_ok.pressed.connect(self.accept)
button_cancel.pressed.connect(self.reject)
sublayout2 = qg.QHBoxLayout()
sublayout2.addWidget(button_ok)
sublayout2.addWidget(button_cancel)
layout = qg.QVBoxLayout()
layout.addWidget(qg.QLabel('Device'))
layout.addWidget(self.operation_list)
layout.addWidget(qg.QLabel('Fixed Region'))
layout.addWidget(self.fixed)
layout.addWidget(self.table)
layout.addLayout(sublayout1)
layout.addLayout(sublayout2)
self.setLayout(layout)
if jointop!=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)
else:
self.table.row_add_empty()
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))
jointdefs.append(JointDef(sketch.id,joint_layer.id,[item.id for item in sublaminate_layers],width,stiffness,damping,preload_angle))
operation_links = {}
operation_links['parent'] = self.operation_list.currentRefs()
operation_links['fixed'] = self.fixed.currentRefs()
return operation_links,jointdefs
示例11: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import selectIndeces [as 别名]
class Dialog(qg.QDialog):
def __init__(self,design,prioroperations, tilepart = None):
super(Dialog, self).__init__()
if tilepart is not None:
self.sheet_opref_tp = tilepart.sheet_opref
self.release_opref_tp = tilepart.release_opref
self.part_opref_tp = tilepart.part_opref
self.sketch_bounding_box_tp = tilepart.sketch_bounding_box
self.sketch_id_tp = tilepart.sketch_id
self.sc_tp = tilepart.sc
self.N_tp = tilepart.N
self.x_gap_tp = tilepart.x_gap
self.y_gap_tp = tilepart.y_gap
self.support_offset_tp = tilepart.support_offset
else:
# define defaults
self.sheet_opref_tp = None if len(design.operations) == 0 else design.operations[0].id
self.release_opref_tp = None if len(design.operations) == 0 else design.operations[0].id
self.part_opref_tp = None if len(design.operations) == 0 else design.operations[0].id
sketchids = [id for key, id in enumerate(design.sketches)]
self.sketch_id_tp = None if len(design.sketches) == 0 else design.sketches[sketchids[0]]
self.sketch_bounding_box_tp = [(0,0),(0,0)]
self.sc_tp = 1
self.N_tp = 10
self.x_gap_tp = 0
self.y_gap_tp = 0
self.support_offset_tp = 0
self.build_dialog(design, prioroperations)
def build_dialog(self, design, prioroperations):
self.prioroperations = prioroperations
self.design = design
# operation/part | sketch to tile in | sheet to tile into
# 'Number of parts', 'Scale'
# 'x-gap', 'y-gap'
# 'Support offset'
self.part = DraggableTreeWidget()
self.part.linklist(prioroperations)
# self.part.setCurrentItem()
self.part.selectIndeces([(design.operation_index(self.part_opref_tp), 0)])
self.release = DraggableTreeWidget()
self.release.linklist(prioroperations)
self.release.selectIndeces([(design.operation_index(self.release_opref_tp), 0)])
self.sketch_to_tile = SketchListManager(design,name = 'Sketch of tile area')
self.sketch_to_tile.refresh_list(selected_item = self.sketch_id_tp)
self.sheet = DraggableTreeWidget()
self.sheet.linklist(prioroperations)
self.sheet.selectIndeces([(design.operation_index(self.sheet_opref_tp), 0)])
# operation/part | sketch to tile in | sheet to tile into
layout_ops_sheet_sketch = qg.QHBoxLayout()
layout_ops_sheet_sketch.addWidget(self.part)
layout_ops_sheet_sketch.addWidget(self.release)
layout_ops_sheet_sketch.addWidget(self.sketch_to_tile)
layout_ops_sheet_sketch.addWidget(self.sheet)
# layout_ops_sheet_sketch = qg.QHBoxLayout()
# part_vbox = qg.QVBoxLayout()
# part_vbox.addWidget(qg.QLabel('Part to tile'))
# part_vbox.addWidget(self.part)
# layout_ops_sheet_sketch.addLayout(part_vbox)
# layout_ops_sheet_sketch.addStretch()
#
# rel_vbox = qg.QVBoxLayout()
# rel_vbox.addWidget(qg.QLabel('Release cut (optional)'))
# rel_vbox.addWidget(self.release)
# layout_ops_sheet_sketch.addLayout(rel_vbox)
# layout_ops_sheet_sketch.addStretch()
#
# sktch_vbox = qg.QVBoxLayout()
# sktch_vbox.addWidget(self.sketch_to_tile)
# layout_ops_sheet_sketch.addLayout(sktch_vbox)
# layout_ops_sheet_sketch.addStretch()
#
# sht_vbox = qg.QVBoxLayout()
# sht_vbox.addWidget(qg.QLabel('Sheet to tile into'))
# sht_vbox.addWidget(self.release)
# layout_ops_sheet_sketch.addLayout(sht_vbox)
# 'Number of parts', 'Scale'
number_of_parts_and_scale = qg.QHBoxLayout()
number_of_parts_and_scale.addStretch()
number_of_parts_and_scale.addWidget(qg.QLabel('Number of parts'))
self.N = qg.QLineEdit()
number_of_parts_and_scale.addWidget(self.N)
#.........这里部分代码省略.........
示例12: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import selectIndeces [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())
示例13: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import selectIndeces [as 别名]
class Dialog(qg.QDialog):
def __init__(
self, keepouttypes, valuenames, defaults, operations, show, operationindeces=None, values=None, keepouttype=None
):
super(Dialog, self).__init__()
self.operations = operations
self.le1 = DraggableTreeWidget()
self.le1.linklist(self.operations)
self.le3 = DraggableTreeWidget()
self.le3.linklist(self.operations)
if operationindeces is not None:
self.le1.selectIndeces(operationindeces[0:1])
self.le3.selectIndeces(operationindeces[1:2])
if values is None:
values = defaults[:]
layout = qg.QVBoxLayout()
layout.addWidget(qg.QLabel("Sheet"))
layout.addWidget(self.le1)
layout.addWidget(qg.QLabel("Device"))
layout.addWidget(self.le3)
self.valueboxes = []
for valuename, v in zip(valuenames, values):
templayout = qg.QHBoxLayout()
valueedit = qg.QLineEdit()
valueedit.setAlignment(qc.Qt.AlignRight)
valueedit.setText(str(v))
# self.valueedit.setInputMask('#009.0')
valueedit.setValidator(qg.QDoubleValidator(-999.0, 999.0, 4, valueedit))
templayout.addStretch()
templayout.addWidget(qg.QLabel(valuename))
templayout.addWidget(valueedit)
self.valueboxes.append(valueedit)
layout.addLayout(templayout)
self.radiobuttons = []
if "keepout" in show:
for key, value2 in keepouttypes.dict.items():
b = qg.QRadioButton(key)
b.setChecked(keepouttype == value2)
b.uservalue = value2
self.radiobuttons.append(b)
layout.addWidget(b)
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)
def acceptdata(self):
option = None
for b in self.radiobuttons:
if b.isChecked():
option = b.uservalue
operationlinks = [self.le1.currentRefs()[0], self.le3.currentRefs()[0]]
values = [float(valueedit.text()) for valueedit in self.valueboxes]
return operationlinks, values, option
示例14: MainWidget
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import selectIndeces [as 别名]
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:
#.........这里部分代码省略.........
示例15: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import selectIndeces [as 别名]
class Dialog(qg.QDialog):
def __init__(
self,design,
operations,
index,
shift=0,
flip=False,
rotate=False,
outputref=0):
super(Dialog, self).__init__()
self.design = design
self.operations = operations
self.le1 = DraggableTreeWidget()
self.le1.linklist(self.operations)
self.le1.selectIndeces([(index, outputref)])
# self.le1.addItems([str(op) for op in operations])
self.layer_widget = popupcad.widgets.listeditor.ListSelector()
self.layer_widget.linklist(self.design.return_layer_definition().layers)
layout5 = qg.QHBoxLayout()
layout5.addWidget(qg.QLabel('Flip Layers'))
self.flip = qg.QCheckBox()
self.flip.setChecked(flip)
layout5.addWidget(self.flip)
layout6 = qg.QHBoxLayout()
layout6.addWidget(qg.QLabel('Rotate Layers'))
self.rotate = qg.QCheckBox()
self.rotate.setChecked(rotate)
layout6.addWidget(self.rotate)
layout4 = qg.QHBoxLayout()
layout4.addWidget(qg.QLabel('Shift Layers'))
self.sb = qg.QSpinBox()
self.sb.setRange(-100, 100)
self.sb.setSingleStep(1)
self.sb.setValue(shift)
layout4.addWidget(self.sb)
button1 = qg.QPushButton('Ok')
button2 = qg.QPushButton('Cancel')
layout2 = qg.QHBoxLayout()
layout2.addWidget(button1)
layout2.addWidget(button2)
layout = qg.QVBoxLayout()
layout.addWidget(qg.QLabel('Filter'))
layout.addWidget(self.layer_widget)
layout.addWidget(qg.QLabel('Parent Operation'))
layout.addWidget(self.le1)
layout.addLayout(layout5)
layout.addLayout(layout6)
layout.addLayout(layout4)
layout.addLayout(layout2)
self.setLayout(layout)
button1.clicked.connect(self.accept)
button2.clicked.connect(self.reject)
# self.le1.setCurrentIndex(index)
def acceptdata(self):
operation_links = {'parent': [self.le1.currentRefs()[0]]}
return operation_links, self.sb.value(
), self.flip.isChecked(), self.rotate.isChecked()