[Rock-dev] Subclassing a C++ widget from ruby, and registering the result as a Vizkit widget

Alexander Duda Alexander.Duda at dfki.de
Mon Apr 11 12:05:01 CEST 2011


On Mon, 2011-04-11 at 11:09 +0200, Sylvain Joyeux wrote:
> Hello
> 
> I'd like to subclass the ImageView widget to create a RasterMapView 
> widget -- which is basically converting a Gdal raster band into an image.
> 
> I'd like to do it in Ruby ... and register the result in vizkit.
> 
> As far as I understood, it boils down to get vizkit to return me the 
> ImageView class (NOT an ImageView instance), i.e.
> 
> 
> <code>
> require 'vizkit'
> image_view_klass = Vizkit.<I don't know what to put there>
> class RasterMapView < image_view_klass
>    [implement the view]
> end
> Vizkit::UILoader.register_ruby_widget "RasterMapView", 
> RasterMapView.method(:new)
> Vizkit::UILoader.register_widget_for "RasterMapView", Gdal::Band, :display
> </code>
> 
> Can I do that ? And if I can, how ?
> 
> Sylvain

This is not going to work because the ImageView class is not known to
ruby. You can only instantiate an instance of the ImageView class which
behaves like a QWidget class on the ruby side.

Unfortunately all events from the ImageView class are not redirected to
the ruby instance so you cannot extend the instance to implement a new
behavior. To get this running you have to write qt bindings.

But you could create your own view by creating a custom QImage which is
displayed by a ImageView instance. 

Alex

-- 
Dipl.-Ing. Alexander Duda 
Unterwasserrobotik

DFKI Bremen
Robotics Innovation Center
Robert-Hooke-Straße 5
28359 Bremen, Germany

Phone: +49 (0)421 178-456620
Fax:   +49 (0)421 178-454150
E-Mail: alexander.duda at dfki.de

Weitere Informationen: http://www.dfki.de/robotik
-----------------------------------------------------------------------
Deutsches Forschungszentrum fuer Kuenstliche Intelligenz GmbH
Firmensitz: Trippstadter Straße 122, D-67663 Kaiserslautern
Geschaeftsfuehrung: Prof. Dr. Dr. h.c. mult. Wolfgang Wahlster
(Vorsitzender) Dr. Walter Olthoff
Vorsitzender des Aufsichtsrats: Prof. Dr. h.c. Hans A. Aukes
Amtsgericht Kaiserslautern, HRB 2313
Sitz der Gesellschaft: Kaiserslautern (HRB 2313)
USt-Id.Nr.:    DE 148646973
Steuernummer:  19/673/0060/3



More information about the Rock-dev mailing list