class Roby::GUI::Roby::GUI::Qt::GraphicsScene

Attributes

default_arrow_brush[R]
default_arrow_pen[R]

Public Instance Methods

add_arrow(size, pen = nil, brush = nil) click to toggle source
# File lib/roby/gui/relations_view/relations_canvas.rb, line 324
def add_arrow(size, pen = nil, brush = nil)
    @default_arrow_pen   ||= Qt::Pen.new(ARROW_COLOR)
    @default_arrow_brush ||= Qt::Brush.new(ARROW_COLOR)

    @arrow_points ||= (1..4).map { Qt::PointF.new(0, 0) }
    @arrow_points[1].x = -size
    @arrow_points[1].y = size / 2
    @arrow_points[2].x = -size
    @arrow_points[2].y = -size / 2
    polygon = Qt::PolygonF.new(@arrow_points)
    @arrow_line ||=   Qt::LineF.new(-1, 0, 0, 0)

    ending = add_polygon polygon, (pen || default_arrow_pen), (brush || default_arrow_brush)
    line   = add_line @arrow_line

    @arrow_id ||= 0
    id = (@arrow_id += 1)
    line.setData(0, Qt::Variant.new(id.to_s))
    ending.setData(0, Qt::Variant.new(id.to_s))

    line.parent_item = ending
    ending.singleton_class.class_eval do
        attr_accessor :line

        def pen=(pen)
            super
            line.pen = pen
        end
    end
    ending.line = line
    ending
end
pen=(pen) click to toggle source
Calls superclass method
# File lib/roby/gui/relations_view/relations_canvas.rb, line 348
def pen=(pen)
    super
    line.pen = pen
end