From: <Han...@sh...> - 2008-01-30 12:45:51
|
Hi Werner, First, i1 is the stream number of the main stream (obtained from = plgstrm) and i2 is another (different) number obtained from plmkstrm. Further, according to the docu, plmkstrm switches automatically to the = new stream. But I can try. I assume you mean plend1, as this one ends = the current stream and plend stop the complete package. Ok, I tried to add plsstrm but that did not help. Regards, Hans Rijneke. Shell International Exploration and Production B.V. The Hague, The Netherlands - Trade Register no. 27002688 Address: Kessler Park 1, 2280 GS Rijswijk, The Netherlands (: +31 070 447 2737 *: <mailto:han...@sh...> 6: <http://www.shell.com/eandp-en> Disclaimer of Liability:=20 This message, any attachment and response string are confidential and = may be legally privileged. It is intended only for the use of the = parties to whom it is addressed. If you are not the addressee indicated = in this message please notify the sender immediately by reply email = and destroy this message. All information and attachments remain the property of Shell -----Original Message----- From: plp...@li... [mailto:plp...@li...]On Behalf Of Werner Smekal Sent: woensdag 30 januari 2008 13:33 To: plp...@li... Subject: Re: [Plplot-general] Segmentation violation Hi Hans, I'm working on a similar thing for the wxwidgets driver, and one driver=20 which has this already implemented is the tk driver, or more=20 specifically the tk bindings. In the file bindings/tk/plframe.c you'll=20 find the following code snippet: /*-----------------------------------------------------------------------= ---*\ * Save * * Processes "save" widget command. * Saves plot to a file. \*-----------------------------------------------------------------------= ---*/ static int Save(Tcl_Interp *interp, register PlFrame *plFramePtr, int argc, const char **argv) { int length; char c; FILE *sfile; /* removed some code ........... */ /* save to specified device & file */ if ((c =3D=3D 'a') && (strncmp(argv[0], "as", length) =3D=3D 0)) { if (argc < 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", " save as device file\"", (char *) NULL); return TCL_ERROR; } /* If save previously in effect, delete old stream */ if (plFramePtr->ipls_save) { plsstrm(plFramePtr->ipls_save); plend1(); } /* Create stream for saves to selected device & file */ plmkstrm(&plFramePtr->ipls_save); if (plFramePtr->ipls_save < 0) { Tcl_AppendResult(interp, "Error -- cannot create stream", (char *) NULL); plFramePtr->ipls_save =3D 0; return TCL_ERROR; } /* Open file for writes */ if ((sfile =3D fopen(argv[2], "wb+")) =3D=3D NULL) { Tcl_AppendResult(interp, "Error -- cannot open file ", argv[2], " for writing", (char *) NULL); plFramePtr->ipls_save =3D 0; plend1(); return TCL_ERROR; } /* Initialize stream */ plsdev(argv[1]); plsfile(sfile); /* Note: many drivers ignore these, needed to preserve the aspect=20 ratio */ plspage( 0., 0., plFramePtr->width, plFramePtr->height, 0, 0 ); plcpstrm(plFramePtr->ipls, 0); pladv(0); /* Remake current plot and then switch back to original stream */ plreplot(); plflush(); plsstrm(plFramePtr->ipls); } /* close save file */ else if ((c =3D=3D 'c') && (strncmp(argv[0], "close", length) = =3D=3D 0)) { if ( ! plFramePtr->ipls_save) { Tcl_AppendResult(interp, "Error -- no current save file", (char *) NULL); return TCL_ERROR; } else { plsstrm(plFramePtr->ipls_save); plend1(); plFramePtr->ipls_save =3D 0; plsstrm(plFramePtr->ipls); } } /* unrecognized */ else { Tcl_AppendResult(interp, "bad option to \"save\": must be ", "as or close", (char *) NULL); return TCL_ERROR; } return TCL_OK; } At first look, you doing the right thing, maybe it helps if you try to=20 set the stream with plsstrm right before plend(). Wouldn't know why this = is necessary, but try it. plend should only end the current stream. Do=20 i1 and i2 contain different integers or the same? HTH, Werner Han...@sh... wrote: > Dear All, >=20 > I like to save some pictures as are currently displayed on the screen=20 > into a "jpeg" file and then continue with plotting to the screen. >=20 > I tried to do it as follows : >=20 > call plgstrm(i1) > call plmkstrm(i2) > call plsfnam('tmp.jpg') > call plsdev('jpeg') > call plcpstrm(i1,.false.) > call plreplot > call plend1 > call plsstrm(i1) >=20 > But as soon as I start plotting again the program crashes with a=20 > segmentation violation. >=20 > Using "valgrind" on this, it looks like "plend1" frees the plot buffer = > of the main stream. Removing "plend1" indeed let me continuing = plotting,=20 > but then at the end, the call to "plend" gives me errors from "glibc"=20 > about corrupted links. Moreover by not calling "plend1" I think a lot = of=20 > memory will be wasted. >=20 > Is the way as described above for creating an intermediate "jpeg" file = > valid or do I have to follow another route ? >=20 > Any help is appreciated. >=20 > Thanks, > Hans Rijneke. >=20 > Shell International Exploration and Production B.V. > The Hague, The Netherlands - Trade Register no. 27002688 > Address: Kessler Park 1, 2280 GS Rijswijk, The Netherlands >=20 > (***:* +31 070 447 2737 > ****:_ __<mailto:han...@sh...>_* > *6:**__*_____ <http://www.shell.com/eandp-en>_ >=20 > */Disclaimer of Liability: /* > */This message, any attachment and response string are confidential = and=20 > may be legally privileged. It is intended only for the use of the=20 > parties to whom it is addressed. If you are not the addressee=20 > indicated in this message please notify the sender immediately by=20 > reply email and destroy this message./* >=20 > */All information and attachments remain the property of = Shell/**//*// >=20 >=20 > = ------------------------------------------------------------------------ >=20 > = -------------------------------------------------------------------------= > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >=20 >=20 > = ------------------------------------------------------------------------ >=20 > _______________________________________________ > Plplot-general mailing list > Plp...@li... > https://lists.sourceforge.net/lists/listinfo/plplot-general --=20 Dr. Werner Smekal Institut fuer Allgemeine Physik Technische Universitaet Wien Wiedner Hauptstr 8-10 A-1040 Wien Austria email: sm...@ia... web: http://www.iap.tuwien.ac.at/~smekal phone: +43-(0)1-58801-13463 (office) +43-(0)1-58801-13469 (laboratory) fax: +43-(0)1-58801-13499 -------------------------------------------------------------------------= This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Plplot-general mailing list Plp...@li... https://lists.sourceforge.net/lists/listinfo/plplot-general |