>From a quick check of one of the Fortran exmples in gtk-fortran, I think
that the problem is that the call is too early. The call to pl_cmd needs to
come AFTER the call to plinit or plstar (it seems counter-intuitive but
that seems to be the case) -- here is the relevant bit from the gtk version
of example one:

    call plscmap0(rval, gval, bval)
    call plsdev("extcairo")

    ! By default the "extcairo" driver does not reset the background
    ! This is equivalent to the command line option "-drvopt
set_background=1"
    call plsetopt("drvopt", "set_background=1")

    ! The "extcairo" device doesn't read the size from the context.
    write(geometry, "(I0,'x',I0)") width, height
    call plsetopt("geometry",  geometry)

    !  Divide page into 2x2 plots
    call plstar(2,2)

    ! Tell the "extcairo" driver where the context is located. This must be
    ! done AFTER the plstar or plinit call.

    call pl_cmd(PLESC_DEVINIT, cc)


    !  Do a plot
    call plot1()

Since I don't know exactly what is in your Initialize_PLplot; routine, I
can't tell if the pl_cmd needs to come in there or if it can come after.

On 12 June 2015 at 21:24, Sundelin Henri <henri.sunde...@aalto.fi> wrote:

>  Hi,
>
>  I’ve been trying to get the extcairo driver to work with GtkAda. I’ve
> been trying to replicate the ext-cairo-test.c example, but I haven’t been
> yet succesful, I get a segfault.. Everything works fine with pdfcairo
> driver though.
>
>  I had to expand the Ada binding a bit, since pl_cmd was not available.
> Added this to plplot_thin.ads:
>     procedure pl_cmd(cmd: PLINT; arg : System.Address);
>    pragma Import(C, pl_cmd, "pl_cmd");
>
>  The code I’m trying is very simple:
> …
>         function Convert is new Ada.Unchecked_Conversion (Source =>
> Cairo_Context,
>                                                      Target =>
> System.Address);
>
>  …
>        — init gtkada etc..
> …
>         Cr := Cairo.Create (surface);
>
>       Set_Device_Name("extcairo");
>       pl_cmd( PLESC_DEVINIT,Convert(Cr) );
>       Put_line("Cr "&System.Address_Image(Convert(Cr)));
>       Initialize_PLplot;
>       Simple_Plot(X=>Pt.X, Y1=>Pt.Y,  X_Label=>To_String(Pt.X_Label),
>
> Y_Label=>To_String(Pt.Y_Label),Title_Label=>To_String(Pt.Title));
>       End_PLplot;
>  ..
> Simple_Plot segfaults. The address printed looks valid.
>
>  I’m developing on OSX, haven’t yet tried on Linux if it makes any
> difference.
>
>  Thoughts?
>
>  //Henri
>
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Plplot-devel mailing list
> Plplot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/plplot-devel
>
>
------------------------------------------------------------------------------
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to