class Ui::RelationsView

Constants

ZOOM_STEP

Attributes

display[R]

The underlying RelationsCanvas object

graphics[R]
prefixActions[R]
verticalLayout[R]

Public Instance Methods

scene() click to toggle source
# File lib/roby/gui/relations_view.rb, line 77
def scene; graphics.scene end
setupActions(view) click to toggle source
# File lib/roby/gui/relations_view.rb, line 145
def setupActions(view)
    @display   = display = view.view

    @actionShowAll = Qt::Action.new(view)
    @actionShowAll.objectName = "actionShowAll"
    @actionShowAll.text = "Show All"
    @actionRedraw = Qt::Action.new(view)
    @actionRedraw.objectName = "actionRedraw"
    @actionRedraw.text = "Redraw"
    @actionZoom = Qt::Action.new(view)
    @actionZoom.objectName = "actionZoom"
    @actionZoom.text = "Zoom +"
    @actionUnzoom = Qt::Action.new(view)
    @actionUnzoom.objectName = "actionUnzoom"
    @actionUnzoom.text = "Zoom -"
    @actionFit = Qt::Action.new(view)
    @actionFit.objectName = "actionFit"
    @actionFit.text = "Fit View"
    @actionOwnership = Qt::Action.new(view)
    @actionOwnership.objectName = "actionOwnership"
    @actionOwnership.text = "Display Ownership"
    @actionOwnership.checkable = true
    @actionOwnership.checked = true
    @actionSVGExport = Qt::Action.new(view)
    @actionSVGExport.objectName = "actionSVGExport"
    @actionSVGExport.text = "SVG Export"
    @actionPrint = Qt::Action.new(view)
    @actionPrint.objectName = "actionPrint"
    @actionPrint.text = "Print"
    @actionKeepSignals = Qt::Action.new(view)
    @actionKeepSignals.objectName = "actionKeepSignals"
    @actionKeepSignals.text = "Keep Signals"
    @actionKeepSignals.checkable = true
    @actionKeepSignals.checked = false
    @actionBookmarksAdd = Qt::Action.new(view)
    @actionBookmarksAdd.objectName = "actionBookmarksAdd"
    @actionBookmarksAdd.text = "Add Bookmark"
    @actionHideFinalized = Qt::Action.new(view)
    @actionHideFinalized.objectName = "actionHideFinalized"
    @actionHideFinalized.text = "Hide Finalized"
    @actionHideFinalized.checkable = true
    @actionHideFinalized.checked = true
    @actionConfigure = Qt::Action.new(view)
    @actionConfigure.objectName = "actionConfigure"
    @actionConfigure.text = "Configure"

    @menubar = Qt::MenuBar.new(view)
    @menubar.objectName = "menubar"
    @menubar.geometry = Qt::Rect.new(0, 0, 800, 21)
    @menuView = Qt::Menu.new("View", @menubar)
    @menuView.objectName = "menuView"

    @menubar.addAction(@menuView.menuAction())
    @menuView.addAction(@actionKeepSignals)
    @menuView.addAction(@actionShowAll)
    @menuView.addSeparator()
    @menuView.addAction(@actionZoom)
    @menuView.addAction(@actionUnzoom)
    @menuView.addAction(@actionFit)
    @menuView.addSeparator()
    @menuView.addAction(@actionSVGExport)
    @menuView.addAction(@actionPrint)
    @menuView.addAction(@actionConfigure)

    @verticalLayout.setMenuBar(@menubar)

    @actionConfigure.connect(SIGNAL(:triggered)) do
        if !@configuration_widget
            @configuration_widget = Qt::Widget.new
            @configuration_widget_ui = Ui::RelationsConfig.new(@configuration_widget, display)
        end
        @configuration_widget.show
    end
    
    #############################################################
    # Handle the other toolbar's buttons
    graphics.extend GraphicsViewBehaviour
    graphics.display = display

    @actionShowAll.connect(SIGNAL(:triggered)) do
        display.graphics.keys.each do |obj|
            display.set_visibility(obj, true) if obj.kind_of?(Roby::Task::DRoby) || (obj.kind_of?(Roby::EventGenerator::DRoby) && !obj.respond_to?(:task))
        end
        display.update
    end

    @actionZoom.connect(SIGNAL(:triggered)) do 
        scale = graphics.matrix.m11
        if scale + ZOOM_STEP > 1
            scale = 1 - ZOOM_STEP
        end
        graphics.resetMatrix
        graphics.scale scale + ZOOM_STEP, scale + ZOOM_STEP
    end
    @actionUnzoom.connect(SIGNAL(:triggered)) do
        scale = graphics.matrix.m11
        graphics.resetMatrix
        graphics.scale scale - ZOOM_STEP, scale - ZOOM_STEP
    end
    @actionFit.connect(SIGNAL(:triggered)) do
        graphics.fitInView(graphics.scene.items_bounding_rect, Qt::KeepAspectRatio)
    end

    @actionKeepSignals.connect(SIGNAL(:triggered)) do 
        display.keep_signals = @actionKeepSignals.checked?
    end

    @actionPrint.connect(SIGNAL(:triggered)) do
        return unless scene
        printer = Qt::Printer.new;
        if Qt::PrintDialog.new(printer).exec() == Qt::Dialog::Accepted
            painter = Qt::Painter.new(printer);
            painter.setRenderHint(Qt::Painter::Antialiasing);
            scene.render(painter);
        end
    end

    @actionSVGExport.connect(SIGNAL(:triggered)) do
        return unless scene

        if path = Qt::FileDialog.get_save_file_name(nil, "SVG Export")
            svg = Qt::SvgGenerator.new
            svg.file_name = path
            svg.size = Qt::Size.new(Integer(scene.width * 0.8), Integer(scene.height * 0.8))
            painter = Qt::Painter.new
            painter.begin(svg)
            scene.render(painter)
            painter.end
        end
    end
    @actionSVGExport.enabled = defined?(Qt::SvgGenerator)
end