implementing new graphics toolkit

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

implementing new graphics toolkit

olli
Hello,
I would like to write a new octave graphics toolkit, which generates WebGL output for the purpose of generating online documentation.

I have difficulties to find the detailed steps how to add a new graphics toolkit, which a assume to be
1) subclass an abstract toolkit class
2) implement all missing methods, maybe "drawLine", "setPixel",... or more complicated "plot2D", "plot3D", ...
3) compile new library containing this toolkit and link octave executable against it
4) register new library in some configuration file.

Is this the right approach? If yes,
which is the base class to extend?
which Makefile needs changes to add the new toolkit library?
how do I make the toolkit known to octave?

If this is totally wrong, I'd appreciate some hints how to get started with a new graphics toolkit implementation. Maybe some FAQ or README file exists already?

Thank you
Oliver
Reply | Threaded
Open this post in threaded view
|

Re: implementing new graphics toolkit

Mike Miller-4
On Mon, Apr 18, 2016 at 04:44:43 -0700, olli wrote:
> Hello,
> I would like to write a new octave graphics toolkit, which generates WebGL
> output for the purpose of generating online documentation.

Sounds neat, please do.

> I have difficulties to find the detailed steps how to add a new graphics
> toolkit, which a assume to be
> 1) subclass an abstract toolkit class
> 2) implement all missing methods, maybe "drawLine", "setPixel",... or more
> complicated "plot2D", "plot3D", ...
> 3) compile new library containing this toolkit and link octave executable
> against it
> 4) register new library in some configuration file.
>
> Is this the right approach? If yes,
> which is the base class to extend?
> which Makefile needs changes to add the new toolkit library?
> how do I make the toolkit known to octave?
>
> If this is totally wrong, I'd appreciate some hints how to get started with
> a new graphics toolkit implementation. Maybe some FAQ or README file exists
> already?

I think this is one of those times where the best documentation is to
read the existing code. We have three different toolkits in Octave now,
so there are some examples to draw from.

I haven't done this myself, but if you do work on this please do
document what you find out and consider contributing it back to the
community.

Your assumptions are mostly right, except you do not need to link Octave
against your toolkit, you can simply load it as an oct-file and register
it at runtime and it will appear as a new toolkit ready to be used. So
steps 3-4 would be

  3. compile oct-file containing this toolkit called "__init_mytk__"
  4. call addpath on the directory containing __init_mytk__.oct
  5. call register_graphics_toolkit ("mytk")

The simplest toolkit to start from is the gnuplot one, because most of
its functions are in m-files. Look at __init_gnuplot__.cc [1] for what I
assume to be a pretty minimal skeleton for how to subclass and register
a new graphics toolkit.

You'll probably then want to look at the GL-based toolkits [2],[3] for
examples of how the base_graphics_toolkit interfaces with the actual
graphical framework being used.

[1]: http://hg.savannah.gnu.org/hgweb/octave/file/@/libinterp/dldfcn/__init_gnuplot__.cc
[2]: http://hg.savannah.gnu.org/hgweb/octave/file/@/libinterp/dldfcn/__init_fltk__.cc
[3]: http://hg.savannah.gnu.org/hgweb/octave/file/@/libgui/graphics

--
mike

Reply | Threaded
Open this post in threaded view
|

Re: implementing new graphics toolkit

olli
Thank you, Mike
I found everything that I need for my understanding in __init_gnuplot__.cc.

Just a comment for other people trying something similar, the actual work is done in  scripts/plot/util/__gnuplot_drawnow__.m and scripts/plot/util/private/__go_draw_figure__.m, both feval'ed from __init_gnuplot__.cc.

Once this project is finished and cleaned up, I will make it available to anybody interested. But don't expect completion before the end of the year...


On Tue, Apr 19, 2016 at 8:44 PM, Mike Miller <[hidden email]> wrote:
On Mon, Apr 18, 2016 at 04:44:43 -0700, olli wrote:
> Hello,
> I would like to write a new octave graphics toolkit, which generates WebGL
> output for the purpose of generating online documentation.

Sounds neat, please do.

> I have difficulties to find the detailed steps how to add a new graphics
> toolkit, which a assume to be
> 1) subclass an abstract toolkit class
> 2) implement all missing methods, maybe "drawLine", "setPixel",... or more
> complicated "plot2D", "plot3D", ...
> 3) compile new library containing this toolkit and link octave executable
> against it
> 4) register new library in some configuration file.
>
> Is this the right approach? If yes,
> which is the base class to extend?
> which Makefile needs changes to add the new toolkit library?
> how do I make the toolkit known to octave?
>
> If this is totally wrong, I'd appreciate some hints how to get started with
> a new graphics toolkit implementation. Maybe some FAQ or README file exists
> already?

I think this is one of those times where the best documentation is to
read the existing code. We have three different toolkits in Octave now,
so there are some examples to draw from.

I haven't done this myself, but if you do work on this please do
document what you find out and consider contributing it back to the
community.

Your assumptions are mostly right, except you do not need to link Octave
against your toolkit, you can simply load it as an oct-file and register
it at runtime and it will appear as a new toolkit ready to be used. So
steps 3-4 would be

  3. compile oct-file containing this toolkit called "__init_mytk__"
  4. call addpath on the directory containing __init_mytk__.oct
  5. call register_graphics_toolkit ("mytk")

The simplest toolkit to start from is the gnuplot one, because most of
its functions are in m-files. Look at __init_gnuplot__.cc [1] for what I
assume to be a pretty minimal skeleton for how to subclass and register
a new graphics toolkit.

You'll probably then want to look at the GL-based toolkits [2],[3] for
examples of how the base_graphics_toolkit interfaces with the actual
graphical framework being used.

[1]: http://hg.savannah.gnu.org/hgweb/octave/file/@/libinterp/dldfcn/__init_gnuplot__.cc
[2]: http://hg.savannah.gnu.org/hgweb/octave/file/@/libinterp/dldfcn/__init_fltk__.cc
[3]: http://hg.savannah.gnu.org/hgweb/octave/file/@/libgui/graphics

--
mike

Reply | Threaded
Open this post in threaded view
|

Re: implementing new graphics toolkit

Andreas Weber-6
Hi Oliver,

Am 20.04.2016 um 10:46 schrieb Oliver Peters:
> Once this project is finished and cleaned up, I will make it available
> to anybody interested. But don't expect completion before the end of the
> year...

what is the state of that project? Is the sourcecode available?

-- Andy