Ejemplo n.º 1
0
    def mousePressEvent(self, event):
        pos = event.scenePos()

        if self.temp is not None:
            if event.button() == qc.Qt.LeftButton:
                self.temp.mousepress(pos)

        elif self.nextgeometry is not None:
            if event.button() == qc.Qt.LeftButton:
                if self.temp is None:
                    if self.nextgeometry == TextParent:
                        textpos = ShapeVertex(qh.to_tuple(pos),scaling = 1/popupcad.view_scaling)
                        text = GenericText('',textpos,font='Courier',fontsize=2)
                        temp = self.nextgeometry(text)
                        self.addItem(temp)
                        temp.editmode()

                    elif self.nextgeometry == DrawingPoint:
                        temp = self.nextgeometry(DrawnPoint(qh.to_tuple(pos),scaling = 1/popupcad.view_scaling))
                        self.addItem(temp)
                        self.setFocusItem(temp)
                        temp.updatescale()
                        self.childfinished()
                    else:
                        self.temp = self.nextgeometry()
                        self.addItem(self.temp)
                        self.setFocusItem(self.temp)
                        self.temp.mousepress(pos)
        else:
            qg.QGraphicsScene.mousePressEvent(self, event)
            self.leavingeditmode.emit()
Ejemplo n.º 2
0
 def itemChange(self, change, value):
     if change == self.ItemPositionHasChanged:
         if self.changed_trigger:
             self.changed_trigger = False
             self.scene().savesnapshot.emit()
         self.generic.pos.setpos(qh.to_tuple(self.pos()))
     return super(TextParent, self).itemChange(change, value)
Ejemplo n.º 3
0
    def mousepress(self, point):
        import numpy
        point = tuple(numpy.array(qh.to_tuple(point)) / popupcad.view_scaling)

        if not self.temphandle:
            a = ShapeVertex(point)
            self.temphandle = a.gen_interactive()
            self.temphandle.setParentItem(self)
            self.temphandle.updatescale()

        if self.generic.len_exterior() == 0:
            self.addhandle(self.temphandle)
            a = ShapeVertex(point)
            self.temphandle = a.gen_interactive()
            self.temphandle.setParentItem(self)
            self.temphandle.updatescale()
            self.updateshape()
            return

        elif self.generic.len_exterior() == 1:
            if self.addhandle(self.temphandle):
                self.finish_definition()
                self.updateshape()
                return

            else:
                return
        else:
            raise Exception
            self.finish_definition()
            self.updateshape()
            return
        self.updateshape()
Ejemplo n.º 4
0
 def itemChange(self, change, value):
     if change == self.ItemPositionHasChanged:
         if self.changed_trigger:
             self.changed_trigger = False
             self.scene().savesnapshot.emit()
         self.generic.pos.setpos(qh.to_tuple(self.pos()))
     return super(TextParent, self).itemChange(change, value)
Ejemplo n.º 5
0
 def addvertex(self, qpoint):
     from popupcad.geometry.vertex import ShapeVertex
     import numpy
     v = ShapeVertex(numpy.array(qh.to_tuple(qpoint))/popupcad.view_scaling)
     self.generic.addvertex_exterior(v, special=True)
     self.updatehandles()
     self.refreshview()
Ejemplo n.º 6
0
 def addvertex(self, qpoint):
     from popupcad.geometry.vertex import ShapeVertex
     import numpy
     v = ShapeVertex(numpy.array(qh.to_tuple(qpoint))/popupcad.view_scaling)
     self.generic.addvertex_exterior(v, special=True)
     self.updatehandles()
     self.refreshview()
Ejemplo n.º 7
0
    def mousepress(self, point):
        import numpy
        point = tuple(numpy.array(qh.to_tuple(point)) / popupcad.view_scaling)

        if not self.temphandle:
            a = ShapeVertex(point)
            self.temphandle = a.gen_interactive()
            self.temphandle.setParentItem(self)
            self.temphandle.updatescale()

        if self.generic.len_exterior() == 0:
            self.addhandle(self.temphandle)
            a = ShapeVertex(point)
            self.temphandle = a.gen_interactive()
            self.temphandle.setParentItem(self)
            self.temphandle.updatescale()
            self.updateshape()
            return

        elif self.generic.len_exterior() == 1:
            if self.addhandle(self.temphandle):
                self.finish_definition()
                self.updateshape()
                return

            else:
                return
        else:
            raise Exception
            self.finish_definition()
            self.updateshape()
            return
        self.updateshape()
Ejemplo n.º 8
0
    def wheelEvent(self, event):
        p1 = event.pos()
        p2 = self.mapToScene(p1)

        if qt.loaded == 'PyQt5':
            delta = event.angleDelta().y()
        else:
            delta = event.delta()

        if delta < 0:
            zoom = 1. / popupcad.zoom_scale_factor
        else:
            zoom = popupcad.zoom_scale_factor

        newzoom = zoom * self.zoom()

        if newzoom > popupcad.zoom_max:
            zoom = popupcad.zoom_max / self.zoom()
        elif newzoom < popupcad.zoom_min:
            zoom = popupcad.zoom_min / self.zoom()

        self.scale(zoom, zoom)
        p3 = self.mapToScene(p1)

        dx = qh.to_tuple(p3 - p2)
        self.translate(*dx)
        event.accept()
Ejemplo n.º 9
0
    def mousemove(self, point):
        import numpy
        point = tuple(numpy.array(qh.to_tuple(point)) / popupcad.view_scaling)

        if not not self.temphandle:
            self.temphandle.generic.setpos(point)
            self.temphandle.updateshape()
        self.updateshape()
Ejemplo n.º 10
0
    def mousemove(self, point):
        import numpy
        point = tuple(numpy.array(qh.to_tuple(point)) / popupcad.view_scaling)

        if not not self.temphandle:
            self.temphandle.generic.setpos(point)
            self.temphandle.updateshape()
        self.updateshape()
Ejemplo n.º 11
0
 def mouseMoveEvent(self, event):
     import numpy
     if self.changed_trigger:
         self.changed_trigger = False
         self.moved_trigger = True
         self.scene().savesnapshot.emit()
     dp = event.scenePos() - event.lastScenePos()
     dp = tuple(numpy.array(qh.to_tuple(dp)) / popupcad.view_scaling)
     self.generic.constrained_shift(dp, self.constraintsystem())
     self.scene().updateshape()
Ejemplo n.º 12
0
 def mouseMoveEvent(self, event):
     import numpy
     if self.changed_trigger:
         self.changed_trigger = False
         self.moved_trigger = True
         self.scene().savesnapshot.emit()
     dp = event.scenePos() - event.lastScenePos()
     dp = tuple(numpy.array(qh.to_tuple(dp)) / popupcad.view_scaling)
     self.generic.constrained_shift(dp, self.constraintsystem())
     self.scene().updateshape()
Ejemplo n.º 13
0
    def mousePressEvent(self, event):
        pos = event.scenePos()

        if self.temp is not None:
            if event.button() == qc.Qt.LeftButton:
                self.temp.mousepress(pos)

        elif self.nextgeometry is not None:
            if event.button() == qc.Qt.LeftButton:
                if self.temp is None:
                    if self.nextgeometry == TextParent:
                        textpos = ShapeVertex(qh.to_tuple(pos),
                                              scaling=1 /
                                              popupcad.view_scaling)
                        text = GenericText('',
                                           textpos,
                                           font='Courier New',
                                           fontsize=1)
                        temp = self.nextgeometry(text)
                        self.addItem(temp)
                        temp.editmode()

                    elif self.nextgeometry == DrawingPoint:
                        temp = self.nextgeometry(
                            DrawnPoint(qh.to_tuple(pos),
                                       scaling=1 / popupcad.view_scaling))
                        self.addItem(temp)
                        self.setFocusItem(temp)
                        temp.updatescale()
                        self.childfinished()
                    else:
                        self.temp = self.nextgeometry()
                        self.addItem(self.temp)
                        self.setFocusItem(self.temp)
                        self.temp.mousepress(pos)
        else:
            qg.QGraphicsScene.mousePressEvent(self, event)
            self.leavingeditmode.emit()
Ejemplo n.º 14
0
 def addhandle(self, handle):
     if self.generic.len_exterior() == 0:
         self.generic.addvertex_exterior(handle.get_generic())
         self.temphandle = None
         return True
     elif self.generic.len_exterior() == 1:
         if qh.to_tuple(handle.pos()) != self.generic.get_exterior()[-1].getpos():
             if self.checkdist(handle.generic.getpos(scaling=popupcad.view_scaling),self.generic.get_exterior()[-1].getpos(scaling=popupcad.view_scaling)):
                 self.generic.addvertex_exterior(handle.get_generic())
                 self.temphandle = None
                 return True
     else:
         raise Exception
         self.temphandle = None
         return True
Ejemplo n.º 15
0
 def addhandle(self, handle):
     if self.generic.len_exterior() == 0:
         self.generic.addvertex_exterior(handle.get_generic())
         self.temphandle = None
         return True
     elif self.generic.len_exterior() == 1:
         if qh.to_tuple(handle.pos()) != self.generic.get_exterior()[-1].getpos():
             if self.checkdist(handle.generic.getpos(scaling=popupcad.view_scaling),
                               self.generic.get_exterior()[-1].getpos(scaling=popupcad.view_scaling)):
                 self.generic.addvertex_exterior(handle.get_generic())
                 self.temphandle = None
                 return True
     else:
         raise Exception
         self.temphandle = None
         return True
Ejemplo n.º 16
0
    def mouseMoveEvent(self, event):
        import numpy
        if self.connectedinteractive.mode is not None:
            if self.connectedinteractive.mode == self.connectedinteractive.modes.mode_edit:
                if self.changed_trigger:
                    self.changed_trigger = False
                    self.moved_trigger = True
                    self.scene().savesnapshot.emit()
                dp = event.scenePos() - event.lastScenePos()
                dp = tuple(numpy.array(qh.to_tuple(dp)) / popupcad.view_scaling)
                self.generic.constrained_shift(dp, self.constraintsystem())
#                self.updateshape()
#                try:
#                    self.connectedinteractive.updateshape()
#                except AttributeError:
#                    pass
                self.scene().updateshape()
Ejemplo n.º 17
0
    def mouseMoveEvent(self, event):
        import numpy
        if self.connectedinteractive.mode is not None:
            if self.connectedinteractive.mode == self.connectedinteractive.modes.mode_edit:
                if self.changed_trigger:
                    self.changed_trigger = False
                    self.moved_trigger = True
                    self.scene().savesnapshot.emit()
                dp = event.scenePos() - event.lastScenePos()
                dp = tuple(numpy.array(qh.to_tuple(dp)) / popupcad.view_scaling)
                self.generic.constrained_shift(dp, self.constraintsystem())
#                self.updateshape()
#                try:
#                    self.connectedinteractive.updateshape()
#                except AttributeError:
#                    pass
                self.scene().updateshape()
Ejemplo n.º 18
0
    def mousepress(self, point):
        import numpy
        point = tuple(numpy.array(qh.to_tuple(point)) / popupcad.view_scaling)

        if not self.temphandle:
            a = ShapeVertex(point)
            self.temphandle = a.gen_interactive()
            self.temphandle.setParentItem(self)
            self.temphandle.updatescale()
            self.addhandle(self.temphandle)
        else:
            self.addhandle(self.temphandle)
        if not self.temphandle:
            a = ShapeVertex(point)
            self.temphandle = a.gen_interactive()
            self.temphandle.setParentItem(self)
            self.temphandle.updatescale()

        self.updateshape()
Ejemplo n.º 19
0
    def mousepress(self, point):
        import numpy
        point = tuple(numpy.array(qh.to_tuple(point)) / popupcad.view_scaling)

        if not self.temphandle:
            a = ShapeVertex(point)
            self.temphandle = a.gen_interactive()
            self.temphandle.setParentItem(self)
            self.temphandle.updatescale()
            self.addhandle(self.temphandle)
        else:
            self.addhandle(self.temphandle)
        if not self.temphandle:
            a = ShapeVertex(point)
            self.temphandle = a.gen_interactive()
            self.temphandle.setParentItem(self)
            self.temphandle.updatescale()

        self.updateshape()
Ejemplo n.º 20
0
    def wheelEvent(self, event):
        p1 = event.pos()
        p2 = self.mapToScene(p1)

        if event.delta() < 0:
            zoom = 1. / popupcad.zoom_scale_factor
        else:
            zoom = popupcad.zoom_scale_factor

        newzoom = zoom * self.zoom()

        if newzoom > popupcad.zoom_max:
            zoom = popupcad.zoom_max / self.zoom()
        elif newzoom < popupcad.zoom_min:
            zoom = popupcad.zoom_min / self.zoom()

        self.scale(zoom, zoom)
        p3 = self.mapToScene(p1)

        dx = qh.to_tuple(p3 - p2)
        self.translate(*dx)
        event.accept()
Ejemplo n.º 21
0
 def setPos(self, pos):
     import numpy
     pos = tuple(numpy.array(qh.to_tuple(pos)) / popupcad.view_scaling)
     self.generic.setpos(pos)
     self.updateshape()
Ejemplo n.º 22
0
 def setPos(self, pos):
     import numpy
     pos = tuple(numpy.array(qh.to_tuple(pos)) / popupcad.view_scaling)
     self.generic.setpos(pos)
     self.updateshape()