コード例 #1
0
    def edit(self, parent, design, editedsignal):
        from popupcad.guis.sketcher import Sketcher
        prioroperations = design.prioroperations(self)

        layers = [design.return_layer_definition().getlayer(ref)
                  for ref in self.layer_links]
        opindex = self.operationtypes.index(self.function)
        sketch = design.sketches[self.sketchid]

        try:
            ii = design.operation_index(self.operation_link1)
        except popupcad.filetypes.design.NoOperation:
            ii = None

        f = lambda *args: self.editedsketch(design, editedsignal, *args)
        kk = self.operationtypes.index(self.function)
        dialog = Sketcher(
            parent,
            sketch,
            design,
            ii=ii,
            jj=self.outputref,
            kk=kk,
            isOperation=True,
            selectops=True,
            accept_method=f,
            selectedlayers=layers)
#        dialog= popupcad.guis.sketcher.SketcherMainWindow(parent,sketch,design.return_layer_definition().layers,layers,prioroperations,self.operation_link1,self.operationtypes,opindex,design,True)
#        dialog.sketchaccepted.connect(f)
        dialog.show()
        dialog.activateWindow()
        dialog.raise_()
コード例 #2
0
ファイル: sketchoperation.py プロジェクト: apullin/popupcad
    def new(cls,parent,design,currentop,newsignal):
        from popupcad.guis.sketcher import Sketcher
        prioroperations = design.operations
        sketch = Sketch()
        try:
            seededrefop = prioroperations[-1].id
        except IndexError:
            seededrefop = None
        f = lambda *args:cls.addedsketch(design,newsignal,*args)
        dialog = Sketcher(parent,sketch,design,isOperation=True,selectops = True,accept_method=f)
#        dialog = popupcad.guis.sketcher.SketcherMainWindow(parent,sketch,design.return_layer_definition().layers,design.return_layer_definition().layers,prioroperations,seededrefop,cls.operationtypes,0,design,True)
#        dialog.sketchaccepted.connect(f)
        dialog.show()
        dialog.activateWindow()
        dialog.raise_()
コード例 #3
0
ファイル: placeop5.py プロジェクト: jackcarter125/popupcad
class Dialog(qg.QDialog):

    def __init__(
            self,
            design,
            prioroperations,
            sketch=None,
            subdesign=None,
            subopid=None,
            transformtype=None,
            shift=0,
            flip=False,
            scalex=1.,
            scaley=1.):
        super(Dialog, self).__init__()

        if sketch is None:
            self.sketch = Sketch()
        else:
            self.sketch = sketch

        if transformtype is None:
            self.transformtype = PlaceOperation5.transformtypes.place
        else:
            self.transformtype = transformtype

        self.combobox = qg.QComboBox()

        self.subdesign = subdesign
        self.subopid = subopid
        self.prioroperations = prioroperations
        self.design = design

        self.lineedit = qg.QLineEdit()
        self.lineedit.setReadOnly(True)
        button3 = qg.QPushButton('...')
        button3.clicked.connect(self.getfile)

        button_sketch = qg.QPushButton('Edit Sketch')
        button_sketch.clicked.connect(self.opensketch)

        self.radiobox_place = qg.QRadioButton('Place')
        self.radiobox_stretch = qg.QRadioButton('Stretch')
        self.radiobox_scale = qg.QRadioButton('Scale')
        self.radiobox_custom = qg.QRadioButton('Custom')

        custom_layout = qg.QVBoxLayout()
        self.scalex = qg.QLineEdit()
        self.scaley = qg.QLineEdit()
        self.scalex.setText(str(scalex))
        self.scaley.setText(str(scaley))
        custom_layout.addWidget(self.scalex)
        custom_layout.addWidget(self.scaley)

        layout_stretch_scale = qg.QHBoxLayout()
        layout_stretch_scale.addWidget(self.radiobox_place)
        layout_stretch_scale.addWidget(self.radiobox_stretch)
        layout_stretch_scale.addWidget(self.radiobox_scale)
        layout_stretch_scale.addWidget(self.radiobox_custom)
        layout_stretch_scale.addLayout(custom_layout)

        layout5 = qg.QHBoxLayout()
        layout5.addWidget(qg.QLabel('Flip Layers'))
        self.flip = qg.QCheckBox()
        self.flip.setChecked(flip)
        layout5.addWidget(self.flip)

        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)

        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.addLayout(layout3)
        layout.addWidget(self.combobox)
        layout.addWidget(button_sketch)
        layout.addLayout(layout_stretch_scale)
        layout.addLayout(layout5)
        layout.addLayout(layout4)
        layout.addLayout(layout2)
        self.setLayout(layout)

        self.radiobox_place.setChecked(False)
        self.radiobox_scale.setChecked(False)
        self.radiobox_stretch.setChecked(False)
        self.radiobox_custom.setChecked(False)
        if self.transformtype == PlaceOperation5.transformtypes.place:
            self.radiobox_place.setChecked(True)
        elif self.transformtype == PlaceOperation5.transformtypes.stretch:
            self.radiobox_stretch.setChecked(True)
        elif self.transformtype == PlaceOperation5.transformtypes.scale:
            self.radiobox_scale.setChecked(True)
        elif self.transformtype == PlaceOperation5.transformtypes.custom:
            self.radiobox_custom.setChecked(True)

        if self.subdesign is not None:
            self.validatename()

    def opensketch(self):
        from popupcad.guis.sketcher import Sketcher
        try:
            seededrefop = self.prioroperations[-1].id
        except IndexError:
            seededrefop = None
        self.sketcherdialog = Sketcher(
            self,
            self.sketch,
            self.design,
            accept_method=self.addsketchop,
            selectops=True)
        self.sketcherdialog.show()
        self.sketcherdialog.activateWindow()
        self.sketcherdialog.raise_()

    def addsketchop(self, sketch):
        self.sketch = sketch

    def validatename(self):
        self.combobox.clear()
        self.combobox.addItems([str(op) for op in self.subdesign.operations])
        try:
            ii = self.subdesign.operation_index(self.subopid)
        except NoOperation:
            self.subopid = self.subdesign.findlastdesignop().id
            ii = self.subdesign.operation_index(self.subopid)
        self.combobox.setCurrentIndex(ii)
        self.lineedit.setText(self.subdesign.get_basename())

    def getfile(self):
        design = Design.open(self)
        if design is not None:
            self.subdesign = design
            self.validatename()
        else:
            self.subdesign = None

    def acceptdata(self):
        if self.radiobox_scale.isChecked():
            transformtype = PlaceOperation5.transformtypes.scale
        elif self.radiobox_stretch.isChecked():
            transformtype = PlaceOperation5.transformtypes.stretch
        elif self.radiobox_place.isChecked():
            transformtype = PlaceOperation5.transformtypes.place
        elif self.radiobox_custom.isChecked():
            transformtype = PlaceOperation5.transformtypes.custom

        ii = self.combobox.currentIndex()
        self.subopid = self.subdesign.operations[ii].id

        self.design.sketches[self.sketch.id] = self.sketch
        self.design.subdesigns[self.subdesign.id] = self.subdesign

        return self.sketch.id, self.subdesign.id, self.subopid, transformtype, self.sb.value(
        ), self.flip.isChecked(), float(self.scalex.text()), float(self.scaley.text())