Exemplo n.º 1
0
 def edit(self, parent, design=None, **kwargs):
     from popupcad.guis.sketcher import Sketcher
     sketcher = Sketcher(parent,
                         self,
                         design,
                         accept_method=self.edit_result,
                         **kwargs)
     sketcher.show()
     sketcher.graphicsview.zoomToFit()
Exemplo n.º 2
0
 def new_method(self):
     from popupcad.guis.sketcher import Sketcher
     from popupcad.filetypes.sketch import Sketch
     def accept_method(sketch):
         self.design.sketches[sketch.id] = sketch
         self.refresh_list(sketch)
     sketcher = Sketcher(None,Sketch(),self.design,accept_method = accept_method,selectops = True)
     sketcher.show()
     sketcher.graphicsview.zoomToFit()
Exemplo n.º 3
0
 def edit(self, parent, design=None, **kwargs):
     from popupcad.guis.sketcher import Sketcher
     sketcher = Sketcher(
         parent,
         self,
         design,
         accept_method=self.edit_result,
         **kwargs)
     sketcher.show()
     sketcher.graphicsview.zoomToFit()
Exemplo n.º 4
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_()
Exemplo n.º 5
0
 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_() 
Exemplo n.º 6
0
    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_()
Exemplo n.º 7
0
    def new_method(self):
        from popupcad.guis.sketcher import Sketcher
        from popupcad.filetypes.sketch import Sketch

        def accept_method(sketch):
            self.design.sketches[sketch.id] = sketch
            self.refresh_list(sketch)
            self.items_updated.emit()

        sketcher = Sketcher(None,
                            Sketch.new(),
                            self.design,
                            accept_method=accept_method,
                            selectops=True)
        sketcher.show()
        sketcher.move_center()

        sketcher.graphicsview.zoomToFit()
Exemplo n.º 8
0
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())
Exemplo n.º 9
0
# -*- coding: utf-8 -*-
"""
Written by Daniel M. Aukes and CONTRIBUTORS
Email: danaukes<at>asu.edu.
Please see LICENSE for full license.
"""

import popupcad
from popupcad.guis.sketcher import Sketcher
import sys

import qt.QtCore as qc
import qt.QtGui as qg

if __name__=='__main__':
    
    app = qg.QApplication(sys.argv)
    sketch = popupcad.filetypes.sketch.Sketch.load_yaml('testpoints.sketch')
    mw = Sketcher(None, sketch)
    #mw.loadsketch(sketch)
    #mw.show()
    geom1 = mw.sketch.operationgeometry[0]
    geom2 = mw.sketch.operationgeometry[1]
    
    #item = mw.scene.itemAt(-17239.488120, 29782.449730)
    
    #sys.exit(app.exec_())