def __init__(self, scene, axis, posModel):
        QGraphicsItem.__init__(self, scene=scene)
        self.setFlag(QGraphicsItem.ItemHasNoContents);
        
        self.axis = axis
        self.posModel = posModel
        
        self._width = 0
        self._height = 0

        self.thick_penX = QPen(Qt.red, self.thick_width)
        self.thick_penX.setCosmetic(True)

        self.thick_penY = QPen(Qt.green, self.thick_width)
        self.thick_penY.setCosmetic(True)

        self.thin_penX = QPen(Qt.red, self.thin_width)
        self.thin_penX.setCosmetic(True)

        self.thin_penY = QPen(Qt.green, self.thin_width)
        self.thin_penY.setCosmetic(True)

        self.x = 0
        self.y = 0

        # These child items do most of the work.
        self._horizontal_marker = SliceMarkerLine(self, 'horizontal')
        self._vertical_marker = SliceMarkerLine(self, 'vertical')

        # We 
        self._horizontal_marker = SliceMarkerLine(self, 'horizontal')
        self._vertical_marker = SliceMarkerLine(self, 'vertical')
Example #2
0
File: Hook0.py Project: iras/JADE
 def mouseReleaseEvent (self, e):
     
     self.harpoon.setVisible (False)
             
     self.helper.initAndStartTimer ()
     
     QGraphicsItem.mouseReleaseEvent (self, e)
    def __init__(self, scene, axis, crop_extents_model, editable=True):

        self._cropColor = Qt.white

        QGraphicsItem.__init__(self, scene=scene)
        self.setFlag(QGraphicsItem.ItemHasNoContents)
        self.setAcceptHoverEvents(True)
        self.scene = scene
        self.axis = axis
        self.crop_extents_model = crop_extents_model

        self._width = 0
        self._height = 0

        # Add shading item first so crop lines are drawn on top.
        self._shading_item = ExcludedRegionShading(self,
                                                   self.crop_extents_model)

        self._horizontal0 = CropLine(self, 'horizontal', 0)
        self._horizontal1 = CropLine(self, 'horizontal', 1)
        self._vertical0 = CropLine(self, 'vertical', 0)
        self._vertical1 = CropLine(self, 'vertical', 1)

        self.crop_extents_model.changed.connect(self.onExtentsChanged)
        self.crop_extents_model.colorChanged.connect(self.onColorChanged)

        # keeping track which line started mouse move
        self._mouseMoveStartH = -1
        self._mouseMoveStartV = -1
        self._fractionOfDistance = 1
Example #4
0
    def __init__(self, scene, axis, posModel):
        """
        scene: Must be an ImageScene2D instance.  We manipulate the scene.allow_brushing flag.
        """
        QGraphicsItem.__init__(self, scene=scene)
        self.setFlag(QGraphicsItem.ItemHasNoContents);
        
        self.axis = axis
        self.posModel = posModel
        
        self._width = 0
        self._height = 0

        self.thick_penX = QPen(Qt.red, self.thick_width)
        self.thick_penX.setCosmetic(True)

        self.thick_penY = QPen(Qt.green, self.thick_width)
        self.thick_penY.setCosmetic(True)

        self.thin_penX = QPen(Qt.red, self.thin_width)
        self.thin_penX.setCosmetic(True)

        self.thin_penY = QPen(Qt.green, self.thin_width)
        self.thin_penY.setCosmetic(True)

        self.x = 0
        self.y = 0

        # These child items do most of the work.
        self._horizontal_marker = SliceMarkerLine(self, 'horizontal')
        self._vertical_marker = SliceMarkerLine(self, 'vertical')
Example #5
0
File: Hook0.py Project: iras/JADE
 def mousePressEvent (self, e):
     
     self.harpoon.setInitPos (self.pos()+self.parent.pos())
     self.harpoon.setVisible (True)
     
     self.harpoon.update ()
     QGraphicsItem.mousePressEvent (self, e)
Example #6
0
 def __init__(self, scale, source, target, parent=None):
     QGraphicsItem.__init__(self, parent)
     self.source = source
     self.target = target
     self.scale = scale
     self.updateShape()
     self.setZValue(2)
 def __init__(self, scale, source, target, parent=None):
     QGraphicsItem.__init__(self, parent)
     self.source = source
     self.target = target
     self.scale = scale
     self.updateShape()
     self.setZValue(2)
    def __init__(self, scene, axis, posModel):
        """
        scene: Must be an ImageScene2D instance.  We manipulate the scene.allow_brushing flag.
        """
        QGraphicsItem.__init__(self, scene=scene)
        self.setFlag(QGraphicsItem.ItemHasNoContents)

        self.axis = axis
        self.posModel = posModel

        self._width = 0
        self._height = 0

        self.thick_penX = QPen(Qt.red, self.thick_width)
        self.thick_penX.setCosmetic(True)

        self.thick_penY = QPen(Qt.green, self.thick_width)
        self.thick_penY.setCosmetic(True)

        self.thin_penX = QPen(Qt.red, self.thin_width)
        self.thin_penX.setCosmetic(True)

        self.thin_penY = QPen(Qt.green, self.thin_width)
        self.thin_penY.setCosmetic(True)

        self.x = 0
        self.y = 0

        # These child items do most of the work.
        self._horizontal_marker = SliceMarkerLine(self, 'horizontal')
        self._vertical_marker = SliceMarkerLine(self, 'vertical')
Example #9
0
 def __init__(self,
              scale,
              glob_scale,
              cell_id,
              polygon,
              points,
              walls,
              parent=None):
     QGraphicsItem.__init__(self, parent)
     self.cell_id = cell_id
     self.setZValue(2.5)
     self.setAcceptsHoverEvents(True)
     self.setSelectable(False)
     self.setFlag(QGraphicsItem.ItemSendsGeometryChanges, True)
     self.hover = False
     self.hover_contour = False
     self.hover_side = None
     self.scale = scale
     self.glob_scale = glob_scale
     self.setToolTip(unicode(cell_id))
     self.polygon_id = polygon
     self.walls = walls
     self.sides = []
     self.points = points
     self.current = False
     self.drag_line = False
     self.dragging_line = False
     self.editable = False
     self.p1 = None
     self.p2 = None
     self.setGeometry()
Example #10
0
    def __init__(self, scene, axis, crop_extents_model, editable=True):

        self._cropColor = Qt.white
        self._editable = editable

        QGraphicsItem.__init__(self, scene=scene)
        self.setFlag(QGraphicsItem.ItemHasNoContents);
        self.setAcceptHoverEvents(True)
        self.scene = scene
        self.axis = axis
        self.crop_extents_model = crop_extents_model
        self.crop_extents_model.editableChanged.connect( self.onEditableChanged)

        self._width = 0
        self._height = 0

        # Add shading item first so crop lines are drawn on top.
        self._shading_item = ExcludedRegionShading( self, self.crop_extents_model )

        self._horizontal0 = CropLine(self, 'horizontal', 0)
        self._horizontal1 = CropLine(self, 'horizontal', 1)
        self._vertical0 = CropLine(self, 'vertical', 0)
        self._vertical1 = CropLine(self, 'vertical', 1)

        self.crop_extents_model.changed.connect( self.onExtentsChanged )
        self.crop_extents_model.colorChanged.connect( self.onColorChanged )

        # keeping track which line started mouse move
        self._mouseMoveStartH = -1
        self._mouseMoveStartV = -1
        self._fractionOfDistance = 1
    def __init__(self, parent, direction):
        assert isinstance(parent, SliceIntersectionMarker)
        assert direction in ('horizontal', 'vertical')

        self._parent = parent
        self._direction = direction
        QGraphicsItem.__init__(self, parent)
        self.setAcceptHoverEvents(True)
Example #12
0
 def __init__(self, tile):
     QGraphicsItem.__init__(self)
     self._tile = weakref.ref(tile) # avoid circular references for easier gc
     self._boundingRect = None
     self.setCacheMode(QGraphicsItem.DeviceCoordinateCache)
     # while moving the tile we use ItemCoordinateCache, see
     # Tile.setActiveAnimation
     self.setClippingFlags()
Example #13
0
 def __init__(self, unit):
     QGraphicsItem.__init__(self)
     self.unit = unit
     self.yPosition = unit * 0.03
     self.width = -self.unit * 0.02
     self.lengthInUnits = 200
     self.axisLength = self.lengthInUnits * unit
     self.axisStart = -self.axisLength / 2
Example #14
0
    def __init__(self, parent, direction):
        assert isinstance(parent, SliceIntersectionMarker)
        assert direction in ('horizontal', 'vertical')

        self._parent = parent
        self._direction = direction
        QGraphicsItem.__init__(self, parent)
        self.setAcceptHoverEvents(True)
Example #15
0
 def __init__(self, unit):
     QGraphicsItem.__init__(self)
     self.unit = unit
     self.yPosition = unit * 0.03
     self.width = -self.unit * 0.02
     self.lengthInUnits = 200
     self.axisLength = self.lengthInUnits * unit
     self.axisStart = -self.axisLength / 2
Example #16
0
 def __init__(self,
              size=32,
              bounds=QRectF(0, 0, 100, 100),
              pen=QPen(QColor(0, 0, 255, 64))):
     self.bounds = bounds
     QGraphicsItem.__init__(self)
     self.lines = []
     self.size = size
     self.pen = pen
Example #17
0
    def __init__(self):
        QGraphicsItem.__init__(self)

        self.__selected = None
        self.setZValue(3.0)

        self.__mark = EDraw.Circle(10, 3, 90).translated(QPointF(0.0, -12.0))

        self.__pen = EDraw.EColor.DefaultEnterHoverPen
Example #18
0
    def __init__(self, tiling, delay=datetime.timedelta(milliseconds=1000)):
        QGraphicsItem.__init__(self, parent=None)
        self.delay = delay
        self.setFlags(QGraphicsItem.ItemUsesExtendedStyleOption)

        self._tiling = tiling
        self._indicate = numpy.zeros(len(tiling))
        self._zeroProgressTimestamp = [datetime.datetime.now()] * len(tiling)
        self._last_zero = False
Example #19
0
    def addItem(self, QGraphicsItem):

        if self.__isNode(QGraphicsItem):
            QGraphicsItem.setZValue(1.0)
            QGraphicsItem.onPress.connect(self.__onNodePressed)

            self.__nodes[QGraphicsItem.Id] = QGraphicsItem

        QGraphicsScene.addItem(self, QGraphicsItem)
Example #20
0
File: Hook0.py Project: iras/JADE
 def hoverLeaveEvent (self, e):
     
     self.pen_color = QPen (Qt.black, 2)
     self._text_item.setDefaultTextColor (Qt.black)
     
     # records the node_id in the helper's attribute.
     self.comm.setHoveredSocketId (None)
     
     QGraphicsItem.hoverLeaveEvent (self, e)
Example #21
0
 def __init__(self, tile):
     QGraphicsItem.__init__(self)
     self._tile = weakref.ref(
         tile)  # avoid circular references for easier gc
     self._boundingRect = None
     self.setCacheMode(QGraphicsItem.DeviceCoordinateCache)
     # while moving the tile we use ItemCoordinateCache, see
     # Tile.setActiveAnimation
     self.setClippingFlags()
Example #22
0
    def __init__(self, tiling, delay=datetime.timedelta( milliseconds=1000 ) ):
        QGraphicsItem.__init__(self, parent=None)
        self.delay = delay
        self.setFlags(QGraphicsItem.ItemUsesExtendedStyleOption)

        self._tiling = tiling
        self._indicate = numpy.zeros(len(tiling))
        self._zeroProgressTimestamp = [datetime.datetime.now()] * len(tiling)
        self._last_zero = False
Example #23
0
File: Tags0.py Project: iras/JADE
 def mousePressEvent (self, e):
     
     #self.setAcceptedMouseButtons(Qt.NoButton)
     self.previousMouseGrabberItem = self.scene.mouseGrabberItem()
     
     if e.button() == Qt.RightButton:
         pos = self.pos()
         self.comm.emitCtxMenuSignal (pos)
     
     QGraphicsItem.mousePressEvent (self, e)
Example #24
0
 def __init__(self, parent=None):
     QGraphicsItem.__init__(self, parent)
     self.setZValue(5)
     self.setFlags(QGraphicsItem.ItemIsMovable)
     self.setAcceptsHoverEvents(True)
     self.on_search = False
     self.on_template = None
     self.last_pos = None
     self.changing = False
     self.setGeometry()
Example #25
0
File: Tags0.py Project: iras/JADE
 def hoverLeaveEvent (self, e):
     
     # records the node_id in the helper's attribute.
     self.comm.setHoveredItemId (None)
     
     # deal with the harpoon.
     if not self.helper.isTimerEnded():
         self.setSelected (True)
     
     QGraphicsItem.hoverLeaveEvent (self, e)
Example #26
0
 def __init__(self, parent=None):
     QGraphicsItem.__init__(self, parent)
     self.setZValue(5)
     self.setFlags(QGraphicsItem.ItemIsMovable)
     self.setAcceptsHoverEvents(True)
     self.on_search = False
     self.on_template = None
     self.last_pos = None
     self.changing = False
     self.setGeometry()
Example #27
0
 def __init__(self, parent=None, graphicView=None, graphicScene=None):
     QGraphicsItem.__init__(self)
     self.set_default_data()
     self.className = QGraphicsTextItem(self)
     self.functionsItem = FunctionsContainerModel(self)
     self.className.setPlainText(self.defaultClassName)
     self.setFlag(self.ItemIsMovable)
     self.setFlag(self.ItemSendsGeometryChanges)
     self.functionsItem.setPos(0, self.__get_title_height())
     self.attributesItem = FunctionsContainerModel(self)
     self.attributesItem.setPos(0, self.functionsItem.get_height())
Example #28
0
 def __init__(self, parent=None, graphicView=None, graphicScene=None):
     QGraphicsItem.__init__(self)
     self.set_default_data()
     self.className = QGraphicsTextItem(self)
     self.functionsItem = FunctionsContainerModel(self)
     self.className.setPlainText(self.defaultClassName)
     self.setFlag(self.ItemIsMovable)
     self.setFlag(self.ItemSendsGeometryChanges)
     self.functionsItem.setPos(0, self.__get_title_height())
     self.attributesItem = FunctionsContainerModel(self)
     self.attributesItem.setPos(0, self.functionsItem.get_height())
Example #29
0
 def mousePressEvent(self, event):
     if event.button() != Qt.LeftButton:
         event.ignore()
         QGraphicsItem.mousePressEvent(self, event)
         return
     if not self.controller().isSelectToolActive():
         return
     self.scene().views()[0].addToPressList(self)
     self._dragMode = True
     self.pressX = event.scenePos().x()
     self.pressBaseIdx = self.activeSlice()
Example #30
0
 def mouseReleaseEvent(self, event):
     if self.dragging_line:
         log_debug("Adding point to cell")
         self.setGeometry()
         drag_side = (self.drag_side+1) % (len(self.polygon)-1)
         self.scene().addPointToCell(self.cell_id, drag_side, self.mapToScene(event.pos()))
     else:
         event.ignore()
         QGraphicsItem.mouseReleaseEvent(self, event)
     self.drag_line = False
     self.dragging_line = False
Example #31
0
    def __init__(self, parent, direction, index):
        assert isinstance(parent, CroppingMarkers)
        assert direction in ('horizontal', 'vertical')

        self._parent = parent
        self._direction = direction
        self._index = index
        QGraphicsItem.__init__(self, parent)
        self.setAcceptHoverEvents(True)

        self._position = 0
Example #32
0
    def __init__(self, parent, direction, index):
        assert isinstance(parent, CroppingMarkers)
        assert direction in ('horizontal', 'vertical')

        self._parent = parent
        self._direction = direction
        self._index = index
        QGraphicsItem.__init__(self, parent)
        self.setAcceptHoverEvents(True)
        
        self._position = 0
Example #33
0
 def mouseReleaseEvent(self, event):
     if self.dragging_line:
         log_debug("Adding point to cell")
         self.setGeometry()
         drag_side = (self.drag_side + 1) % (len(self.polygon) - 1)
         self.scene().addPointToCell(self.cell_id, drag_side,
                                     self.mapToScene(event.pos()))
     else:
         event.ignore()
         QGraphicsItem.mouseReleaseEvent(self, event)
     self.drag_line = False
     self.dragging_line = False
Example #34
0
    def __init__(self, start, end, pen=QPen(QColor(0, 0, 0, 255))):
        self.pen = pen

        QGraphicsItem.__init__(self)

        self.starting_line = QLineF(start, end)
        self.bounds = QRectF(start - (end - start), end + (end - start))

        self.steps = 4
        self.smooth = 50
        self.dampen = 100
        self.update_lines()
Example #35
0
    def __init__(self,
                 id,
                 title='',
                 title_above=False,
                 title_location=AxisMiddle,
                 line=None,
                 arrows=0,
                 plot=None,
                 bounds=None):
        QGraphicsItem.__init__(self)
        self.setFlag(QGraphicsItem.ItemHasNoContents)
        self.setZValue(AxisZValue)
        self.id = id
        self.title = title
        self.title_location = title_location
        self.data_line = line
        self.plot = plot
        self.graph_line = None
        self.size = None
        self.scale = None
        self.tick_length = (10, 5, 0)
        self.arrows = arrows
        self.title_above = title_above
        self.line_item = QGraphicsLineItem(self)
        self.title_item = QGraphicsTextItem(self)
        self.end_arrow_item = None
        self.start_arrow_item = None
        self.show_title = False
        self.scale = None
        path = QPainterPath()
        path.setFillRule(Qt.WindingFill)
        path.moveTo(0, 3.09)
        path.lineTo(0, -3.09)
        path.lineTo(9.51, 0)
        path.closeSubpath()
        self.arrow_path = path
        self.label_items = []
        self.label_bg_items = []
        self.tick_items = []
        self._ticks = []
        self.zoom_transform = QTransform()
        self.labels = None
        self.values = None
        self._bounds = bounds
        self.auto_range = None
        self.auto_scale = True

        self.zoomable = False
        self.update_callback = None
        self.max_text_width = 50
        self.text_margin = 5
        self.always_horizontal_text = False
Example #36
0
 def mouseReleaseEvent(self, event):
     pos = event.pos()
     x = pos.x()
     y = pos.y()
     if self.on_search:
         self.updateCursor(x, y, True)
         event.accept()
         return
     elif self.on_template:
         self.updateCursor(x, y, False)
         event.accept()
         return
     QGraphicsItem.mouseReleaseEvent(self, event)
Example #37
0
 def mouseReleaseEvent(self, event):
     pos = event.pos()
     x = pos.x()
     y = pos.y()
     if self.on_search:
         self.updateCursor(x, y, True)
         event.accept()
         return
     elif self.on_template:
         self.updateCursor(x, y, False)
         event.accept()
         return
     QGraphicsItem.mouseReleaseEvent(self, event)
Example #38
0
 def __init__(self, target, tail_length = 3):
     # super params (x, y, width, height)
     QGraphicsItem.__init__(self)
     
     self._is_selected=False
     self.history = History() # used to store the previous points where the target has been
     self.tail_length = tail_length
     self.target = target
     
     self.plane = PlaneView(self)
     # self.speed_vector = LineItem(parent = self.plane)
     self.label=TargetLabel(parent = self.plane)
     self.box_line = LineItem(parent = self.plane)
Example #39
0
	def __init__(self, start, end, pen = QPen(QColor(0,0,0,255))):
		self.pen = pen

		QGraphicsItem.__init__(self)

		self.starting_line = QLineF(start, end)
		self.bounds = QRectF(
			start - (end - start),
			end + (end - start))

		self.steps = 4
		self.smooth = 50
		self.dampen = 100
		self.update_lines()
Example #40
0
 def __init__(self, scale, pt_id, parent=None):
     QGraphicsItem.__init__(self, parent)
     self.pt_id = pt_id
     self.scale = scale
     self.setZValue(1)
     #self.setFlag(QGraphicsItem.ItemIgnoresTransformations, True)
     self.setSelectable()
     self.link = None
     self.back_link = None
     self.arrow = None
     self._show_template = False  # Are we showing the template *now* ?
     self.hover_template = False
     self.hover = False
     self.setGeometry()
Example #41
0
 def __init__(self, scale, pt_id, parent=None):
     QGraphicsItem.__init__(self, parent)
     self.pt_id = pt_id
     self.scale = scale
     self.setZValue(1)
     #self.setFlag(QGraphicsItem.ItemIgnoresTransformations, True)
     self.setSelectable()
     self.link = None
     self.back_link = None
     self.arrow = None
     self._show_template = False  # Are we showing the template *now* ?
     self.hover_template = False
     self.hover = False
     self.setGeometry()
Example #42
0
    def __init__(self, parent, direction, index):
        assert isinstance(parent, CroppingMarkers)
        assert direction in ('horizontal', 'vertical')

        self._parent = parent
        self._direction = direction
        self._index = index
        QGraphicsItem.__init__(self, parent)
        self.setAcceptHoverEvents(True)
        self._position = 0
        self._line_thickness = 1

        # keeping track which line started mouse move
        self._mouseMoveStartH = -1
        self._mouseMoveStartV = -1
Example #43
0
File: Hook0.py Project: iras/JADE
 def hoverEnterEvent (self, e):
     
     self.pen_color = QPen (Qt.red, 2)
     self._text_item.setDefaultTextColor (Qt.red)
             
     # records the node_id in the helper's attribute.
     self.comm.setHoveredSocketId (self.socket_id)
     
     # deal with the harpoon.
     if not self.helper.isTimerEnded():
         self.setSelected (True)
         self.helper.getGraphView().addLinkAndWirePressBtnListener ()
     
     #self._text_item.setToolTip (self._text_item.toPlainText ())
     QGraphicsItem.hoverEnterEvent (self, e)
Example #44
0
    def __init__(self, line_length, offset, linespace, align, hyphenate, block_id):
        QGraphicsItem.__init__(self)

        self.line_length, self.offset, self.line_space = line_length, offset, linespace
        self.align, self.hyphenate, self.block_id = align, hyphenate, block_id

        self.tokens = collections.deque()
        self.current_width = 0
        self.length_in_space = 0
        self.height, self.descent, self.width = 0, 0, 0
        self.links = collections.deque()
        self.current_link = None
        self.valign = None
        if not hasattr(self, 'children'):
            self.children = self.childItems
    def __init__(self, parent, direction, index):
        assert isinstance(parent, CroppingMarkers)
        assert direction in ('horizontal', 'vertical')

        self._parent = parent
        self._direction = direction
        self._index = index
        QGraphicsItem.__init__(self, parent)
        self.setAcceptHoverEvents(True)
        self._position = 0
        self._line_thickness = 1

        # keeping track which line started mouse move
        self._mouseMoveStartH = -1
        self._mouseMoveStartV = -1
 def __init__(self):
     QGraphicsItem.__init__(self)
     
     self.width = 0
     self.height = 0
           
     self.penX = QPen(Qt.red, 2)
     self.penX.setCosmetic(True)
     
     self.penY = QPen(Qt.green, 2)
     self.penY.setCosmetic(True)
     
     self.x = 0
     self.y = 0
     
     self.isVisible = False
    def __init__(self, x1, y1, x2, y2, parent=None, scene=None):
        QGraphicsItem.__init__(self, x1, y1, x2, y2,
                               parent=parent, scene=scene)
        self.selec = False
        self.ctrlPressed = False
        self.selectWidth = 2.5
        self.id = None
        self.parentSelected = False
        self.parentList = []
        self.allItems = []

        self.backupPen = self.pen()

        self.select_pen = QPen(QtCore.Qt.gray)
        self.select_pen.setStyle(QtCore.Qt.DotLine)
        self.select_pen.setWidthF(self.selectWidth)
    def __init__(self, parent=None, icon=None, iconSize=None, **kwargs):
        QGraphicsItem.__init__(self, parent, **kwargs)
        self.setFlag(QGraphicsItem.ItemUsesExtendedStyleOption, True)

        if icon is None:
            icon = QIcon()

        if iconSize is None:
            style = QApplication.instance().style()
            size = style.pixelMetric(style.PM_LargeIconSize)
            iconSize = QSize(size, size)

        self.__transformationMode = Qt.SmoothTransformation

        self.__iconSize = QSize(iconSize)
        self.__icon = QIcon(icon)
Example #49
0
    def __init__(self, line_length, offset, linespace, align, hyphenate,
                 block_id):
        QGraphicsItem.__init__(self)

        self.line_length, self.offset, self.line_space = line_length, offset, linespace
        self.align, self.hyphenate, self.block_id = align, hyphenate, block_id

        self.tokens = collections.deque()
        self.current_width = 0
        self.length_in_space = 0
        self.height, self.descent, self.width = 0, 0, 0
        self.links = collections.deque()
        self.current_link = None
        self.valign = None
        if not hasattr(self, 'children'):
            self.children = self.childItems
Example #50
0
    def __init__(self, parent=None, icon=None, iconSize=None, **kwargs):
        QGraphicsItem.__init__(self, parent, **kwargs)
        self.setFlag(QGraphicsItem.ItemUsesExtendedStyleOption, True)

        if icon is None:
            icon = QIcon()

        if iconSize is None:
            style = QApplication.instance().style()
            size = style.pixelMetric(style.PM_LargeIconSize)
            iconSize = QSize(size, size)

        self.__transformationMode = Qt.SmoothTransformation

        self.__iconSize = QSize(iconSize)
        self.__icon = QIcon(icon)
Example #51
0
 def itemChange(self, change, value):
     if change == QGraphicsItem.ItemPositionChange:
         pos = value.toPointF()
         scene = self.scene()
         if not self.changing and scene is not None:
             self.changing = True
             scene.templatePosChange.emit(pos)
             self.changing = False
     return QGraphicsItem.itemChange(self, change, value)
Example #52
0
 def mouseMoveEvent(self, event):
     params = parameters.instance
     pos = event.pos()
     x = pos.x()
     y = pos.y()
     if self.on_search:
         ns = norm(x, y)
         params.search_size = ns
         self.updateCursor(x, y, True)
         event.accept()
         return
     elif self.on_template:
         ns = max(abs(x), abs(y))
         params.template_size = ns
         self.updateCursor(x, y, False)
         event.accept()
         return
     QGraphicsItem.mouseMoveEvent(self, event)
Example #53
0
 def mousePressEvent(self, event):
     if self.hover_side is not None:
         moving_point = QPointF(event.pos())
         self.drag_side = self.hover_side
         #self.polygon.insert(self.hover_side+1, moving_point)
         #self.sides[self.hover_side] = [self.polygon[self.hover_side], self.polygon[self.hover_side+1]]
         #self.sides.insert(self.hover_side+1, [self.polygon[self.hover_side+1], self.polygon[self.hover_side+2]])
         self.moving_point = moving_point
         self.start_drag = event.screenPos()
         self.hover_contour = False
         self.hover_side = None
         self.drag_line = True
         self.dragging_line = False
         self.update()
         event.accept()
     else:
         event.ignore()
         QGraphicsItem.mousePressEvent(self, event)
Example #54
0
    def __init__(self, scene):
        QGraphicsItem.__init__(self, scene=scene)

        self._width = 0
        self._height = 0

        self.penDotted = QPen(Qt.red, 2, Qt.DotLine, Qt.RoundCap, Qt.RoundJoin)
        self.penDotted.setCosmetic(True)

        self.penSolid = QPen(Qt.red, 2)
        self.penSolid.setCosmetic(True)

        self.x = 0
        self.y = 0
        self.brushSize = 0

        self.mode = self.modeXYPosition
        self._enabled = True
    def __init__(self, parent=None, image=None):
        """
		This method initializes the class.

		:param parent: Object parent. ( QObject )
		:param image: Image. ( QImage )
		"""

        LOGGER.debug("> Initializing '{0}()' class.".format(
            self.__class__.__name__))

        QGraphicsItem.__init__(self, parent)

        # --- Setting class attributes. ---
        self.__image = None
        self.image = image or QImage()
        self.__width = image.width()
        self.__height = image.height()
Example #56
0
 def __init__(self, scale, pt_id, new=False, cells=(), parent=None):
     QGraphicsItem.__init__(self, parent)
     self.remove_in_all = False
     self.new = new
     self.pt_id = pt_id
     self.scale = scale
     self.setZValue(3)
     self.setAcceptsHoverEvents(True)
     self.setSelectable()
     self.link = None
     self.back_link = None
     self.arrow = None
     self._show_template = False  # Are we showing the template *now* ?
     self.hover_template = False
     self.hover = False
     self.setToolTip(unicode(pt_id))
     self.cells = tuple(cells)
     self.setGeometry()
     self.setFlag(QGraphicsItem.ItemSendsGeometryChanges, True)
Example #57
0
    def __init__(self, scene, axis, crop_extents_model):
        QGraphicsItem.__init__(self, scene=scene)
        self.setFlag(QGraphicsItem.ItemHasNoContents)

        self.axis = axis
        self.crop_extents_model = crop_extents_model

        self._width = 0
        self._height = 0

        # Add shading item first so crop lines are drawn on top.
        self._shading_item = ExcludedRegionShading(self,
                                                   self.crop_extents_model)

        self._horizontal0 = CropLine(self, 'horizontal', 0)
        self._horizontal1 = CropLine(self, 'horizontal', 1)
        self._vertical0 = CropLine(self, 'vertical', 0)
        self._vertical1 = CropLine(self, 'vertical', 1)

        self.crop_extents_model.changed.connect(self.onExtentsChanged)
Example #58
0
    def __init__(self, x1, y1, x2, y2, parent=None, scene=None):
        QGraphicsItem.__init__(self,
                               x1,
                               y1,
                               x2,
                               y2,
                               parent=parent,
                               scene=scene)
        self.selec = False
        self.ctrlPressed = False
        self.selectWidth = 2.5
        self.id = None
        self.parentSelected = False
        self.parentList = []
        self.allItems = []

        self.backupPen = self.pen()

        self.select_pen = QPen(QtCore.Qt.gray)
        self.select_pen.setStyle(QtCore.Qt.DotLine)
        self.select_pen.setWidthF(self.selectWidth)
Example #59
0
    def __init__(self, scene):
        QGraphicsItem.__init__(self, scene=scene)

        self._width = 0
        self._height = 0

        self.thick_penX = QPen(Qt.red, self.thick_width)
        self.thick_penX.setCosmetic(True)

        self.thick_penY = QPen(Qt.green, self.thick_width)
        self.thick_penY.setCosmetic(True)

        self.thin_penX = QPen(Qt.red, self.thin_width)
        self.thin_penX.setCosmetic(True)

        self.thin_penY = QPen(Qt.green, self.thin_width)
        self.thin_penY.setCosmetic(True)

        self.x = 0
        self.y = 0

        self.isVisible = True