Class: SvgGLView

Inherits:
Qt::GLWidget show all
Defined in:
ext/ruby/qtruby/examples/painting/svgviewer/svgview.rb

Instance Method Summary collapse

Methods inherited from Qt::GLWidget

#format

Methods inherited from Qt::Base

#%, #&, #*, #**, #+, #-, #-@, #/, #<, #<<, #<=, #==, #>, #>=, #>>, #QCOMPARE, #QEXPECT_FAIL, #QFAIL, #QSKIP, #QTEST, #QVERIFY, #QVERIFY2, #QWARN, #^, ancestors, #is_a?, #methods, private_slots, #protected_methods, #public_methods, q_classinfo, q_signal, q_slot, signals, #singleton_methods, slots, #|, #~

Constructor Details

#initialize(file, parent) ⇒ SvgGLView

Returns a new instance of SvgGLView.



122
123
124
125
126
127
# File 'ext/ruby/qtruby/examples/painting/svgviewer/svgview.rb', line 122

def initialize(file, parent)
    super(Qt::GLFormat.new(Qt::GL::SampleBuffers), parent)
    @doc = Qt::SvgRenderer.new(file, self)
    connect(@doc, SIGNAL(:repaintNeeded),
            self, SLOT(:update))
end

Instance Method Details

#paintEvent(event) ⇒ Object



129
130
131
132
133
# File 'ext/ruby/qtruby/examples/painting/svgviewer/svgview.rb', line 129

def paintEvent(event)
    p = Qt::Painter.new(self)
    @doc.render(p)
       p.end
end

#sizeHintObject



135
136
137
138
139
140
# File 'ext/ruby/qtruby/examples/painting/svgviewer/svgview.rb', line 135

def sizeHint()
    if @doc
        return @doc.defaultSize()
       end
    return super()
end

#wheelEvent(e) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'ext/ruby/qtruby/examples/painting/svgviewer/svgview.rb', line 142

def wheelEvent(e)
    diff = 0.1
    size = @doc.defaultSize()
    w = size.width()
    h = size.height()
    if e.delta() > 0
        w = (width() + width() * diff)
        h = (height() + height() * diff)
    else
        w = (width() - width() * diff)
        h = (height() - height() * diff)
    end
    resize(w, h)
end