本文整理汇总了Python中popupcad.widgets.dragndroptree.DraggableTreeWidget.currentRefs方法的典型用法代码示例。如果您正苦于以下问题:Python DraggableTreeWidget.currentRefs方法的具体用法?Python DraggableTreeWidget.currentRefs怎么用?Python DraggableTreeWidget.currentRefs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类popupcad.widgets.dragndroptree.DraggableTreeWidget
的用法示例。
在下文中一共展示了DraggableTreeWidget.currentRefs方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentRefs [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: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentRefs [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
示例3: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentRefs [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
示例4: MainWidget
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentRefs [as 别名]
#.........这里部分代码省略.........
self.design = design
self.sketches = sketches
self.layers = layers
self.operations = operations
self.operation_list = DraggableTreeWidget()
self.operation_list.linklist(self.operations)
self.table = Table(JointRow(self.get_sketches, self.get_layers),Delegate)
table_control= TableControl(self.table, self)
button_ok = qg.QPushButton('Ok')
button_cancel = qg.QPushButton('Cancel')
button_ok.clicked.connect(self.accept)
button_cancel.clicked.connect(self.reject)
self.buffer_val = qg.QLineEdit()
sublayout2 = qg.QHBoxLayout()
sublayout2.addStretch()
sublayout2.addWidget(button_ok)
sublayout2.addWidget(button_cancel)
sublayout2.addStretch()
layout = qg.QVBoxLayout()
layout.addWidget(qg.QLabel('Device'))
layout.addWidget(self.operation_list)
layout.addWidget(table_control)
layout.addWidget(qg.QLabel('Buffer'))
layout.addWidget(self.buffer_val)
layout.addLayout(sublayout2)
self.setLayout(layout)
if jointop is not None:
try:
op_ref, output_ii = jointop.operation_links['parent'][0]
op_ii = design.operation_index(op_ref)
self.operation_list.selectIndeces([(op_ii, output_ii)])
except(IndexError, KeyError):
pass
try:
fixed_ref, fixed_output_ii = jointop.operation_links[
'fixed'][0]
fixed_ii = design.operation_index(fixed_ref)
self.fixed.selectIndeces([(fixed_ii, fixed_output_ii)])
except(IndexError, KeyError):
pass
for item in jointop.joint_defs:
sketch = self.design.sketches[item.sketch]
joint_layer = self.design.return_layer_definition().getlayer(
item.joint_layer)
sublaminate_layers = [self.design.return_layer_definition().getlayer(
item2) for item2 in item.sublaminate_layers]
self.table.row_add(
sketch,
joint_layer,
sublaminate_layers,
item.width)
else:
self.table.row_add_empty()
self.buffer_val.setText(str(buffer))
self.table.resizeColumnsToContents()
self.table.reset_min_width()
self.table.setHorizontalScrollBarPolicy(qc.Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
def contact_sketch(self):
try:
return self.sketchwidget.itemlist.selectedItems()[0].value
except IndexError:
return None
def get_sketches(self):
return self.sketches
def get_layers(self):
return self.layers
def acceptdata(self):
jointdefs = []
for ii in range(self.table.rowCount()):
sketch = self.table.item(ii, 0).data(qc.Qt.ItemDataRole.UserRole)
joint_layer = self.table.item(
ii, 1).data(
qc.Qt.ItemDataRole.UserRole)
sublaminate_layers = self.table.item(
ii, 2).data(
qc.Qt.ItemDataRole.UserRole)
width = (self.table.item(ii, 3).data(qc.Qt.ItemDataRole.UserRole))
jointdefs.append(JointDef(sketch.id,joint_layer.id,[item.id for item in sublaminate_layers],width))
operation_links = {}
operation_links['parent'] = self.operation_list.currentRefs()
sketch_links = {}
return operation_links,sketch_links,jointdefs,float(self.buffer_val.text())
示例5: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentRefs [as 别名]
#.........这里部分代码省略.........
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]
def acceptdata(self):
function = self.le0.currentText()
unary_layer_links = [
item.customdata.id for item in self.unarylayerselector.selectedItems()]
pair_layer_links = [
item.customdata.id for item in self.pairlayerselector.selectedItems()]
output_layer_links = [
item.customdata.id for item in self.outputlayerselector.selectedItems()]
operation_links = {'parent': self.operationselector.currentRefs()}
return operation_links, function, unary_layer_links, pair_layer_links, output_layer_links
示例6: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentRefs [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()
示例7: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentRefs [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
示例8: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentRefs [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
示例9: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentRefs [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
示例10: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentRefs [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
示例11: Dialog
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentRefs [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
示例12: MainWidget
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentRefs [as 别名]
#.........这里部分代码省略.........
sublayout2.addStretch()
sublayout2.addWidget(button_ok)
sublayout2.addWidget(button_cancel)
sublayout2.addStretch()
layout = qg.QVBoxLayout()
layout.addLayout(sublayout1)
layout.addWidget(table_control)
layout.addLayout(sublayout2)
self.setLayout(layout)
if jointop is not None:
try:
op_ref, output_ii = jointop.operation_links['parent'][0]
op_ii = design.operation_index(op_ref)
self.operation_list.selectIndeces([(op_ii, output_ii)])
except(IndexError, KeyError):
pass
try:
fixed_ref, fixed_output_ii = jointop.operation_links[
'fixed'][0]
fixed_ii = design.operation_index(fixed_ref)
self.fixed.selectIndeces([(fixed_ii, fixed_output_ii)])
except(IndexError, KeyError):
pass
for item in jointop.joint_defs:
sketch = self.design.sketches[item.sketch]
joint_layer = self.design.return_layer_definition().getlayer(
item.joint_layer)
sublaminate_layers = [self.design.return_layer_definition().getlayer(
item2) for item2 in item.sublaminate_layers]
self.table.row_add(
sketch,
joint_layer,
sublaminate_layers,
item.width,
item.stiffness,
item.damping,
item.preload_angle,
item.limit_negative,
item.limit_positive)
else:
self.table.row_add_empty()
self.table.resizeColumnsToContents()
self.table.reset_min_width()
self.table.setHorizontalScrollBarPolicy(qc.Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
def contact_sketch(self):
try:
return self.sketchwidget.itemlist.selectedItems()[0].value
except IndexError:
return None
def get_sketches(self):
return self.sketches
def get_layers(self):
return self.layers
def acceptdata(self):
jointdefs = []
for ii in range(self.table.rowCount()):
sketch = self.table.item(ii, 0).data(qc.Qt.ItemDataRole.UserRole)
joint_layer = self.table.item(
ii, 1).data(
qc.Qt.ItemDataRole.UserRole)
sublaminate_layers = self.table.item(
ii, 2).data(
qc.Qt.ItemDataRole.UserRole)
width = (self.table.item(ii, 3).data(qc.Qt.ItemDataRole.UserRole))
stiffness = (
self.table.item(
ii, 4).data(
qc.Qt.ItemDataRole.UserRole))
damping = (
self.table.item(
ii,
5).data(
qc.Qt.ItemDataRole.UserRole))
preload_angle = (self.table.item(ii, 6).data(qc.Qt.ItemDataRole.UserRole))
limit_negative = (self.table.item(ii, 7).data(qc.Qt.ItemDataRole.UserRole))
limit_positive = (self.table.item(ii, 8).data(qc.Qt.ItemDataRole.UserRole))
jointdefs.append(JointDef(sketch.id,
joint_layer.id,
[item.id for item in sublaminate_layers],
width,
stiffness,
damping,
preload_angle,limit_negative,limit_positive))
operation_links = {}
operation_links['parent'] = self.operation_list.currentRefs()
operation_links['fixed'] = self.fixed.currentRefs()
sketch_links = {}
sketch_links['contact_points'] = [self.contact_sketch().id]
return operation_links,sketch_links,jointdefs
示例13: MainWidget
# 需要导入模块: from popupcad.widgets.dragndroptree import DraggableTreeWidget [as 别名]
# 或者: from popupcad.widgets.dragndroptree.DraggableTreeWidget import currentRefs [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