I am having trouble implementing the previewing and printing of PLplot output in a wxWidgets application. The PLplot code works reliably when drawing on a wxPLplotwindow, but works only on random pages when drawing on a wxPLplotstream that is created for print or print preview purposes. When it does not work, it produces nothing on the output device.
Versions: Eclipse CDT 3.4.2 MinGW 3.15 wxWidgets 2.8.9 PLplot 5.8.0-RC1 Windows XP SP3. The intended plot is a 2-D graph of a spectrum. The PLplot calls are in a class SpectrumPlot which knows nothing about wxWidgets. SpectrumPlot::Draw() takes a plstream as an argument and draws the graph on it. It works reliably when drawing on the wxPLplotstream obtained from a wxPLplotwindow. Printing is implemented with the provided wxPrinter and wxPrintPreview classes. These both use a class SpectraPrintout derived from the provided class wxPrintout in which GetPageInfo(), HasPage(), and OnPrintPage() are overridden. SpectraPrintout::OnPrintPage() creates a wxPLplotstream, passing to it the wxDC device context from the argument list of OnPrintPage(). Then it calls SpectrumPlot::Draw(). For debug purposes, after drawing the graph, OnPrintPage() calls wxDC::DrawCircle() to draw two circles over top of the graph. That is, the circles are drawn by directly accessing the wxWidgets methods, without using the PLplotstream. This sometimes works and sometimes does not, both in output to the printer, and in print preview. When it does work, the graph is either previewed or printed as it should be, and the wxDC::DrawCircle() circles appear on top of the graph (as expected, since they are drawn last). When it does not work, only the circles appear. The graph does not appear. When printing several pages in one printing operation, the code works on some pages and not on others. When previewing, some pages display correctly, others do not. Multiple attempts to preview the same page yield success and failure apparently at random. The wxDC::DrawCircle() circles are always displayed. However, when the graph is displayed correctly, the circles are black filled. When the graph is not displayed, the circles are white filled. This is likely because the graph drawing code changes the palette. Also, calling wxDC::MinX(), wxDC::MinY(), wxDC::MaxX(), wxDC::MaxY() gives zeros when the graph is not displayed correctly, but displays reasonable values when the graph is displayed correctly. This suggests that the underlying wxDC methods are not being called at all in the cases where the graph is not displayed correctly, so that the palette is not changed and the plot extent is not updated. It appears that some object is either not being properly initialized, or is being overwritten, at random. Perhaps an object created on the stack or the heap is being destroyed before it should be, causing some internal error to be set in PLplot. Since wxWidgets always draws the circles correctly, it appears that the problem exists in my code or the PLplot code, not wxWidgets. I would appreciate advice on how to narrow down the problem. Thanks. Jack Dodds Geo Equipment Manufacturing Ltd. Geotech Ltd. 245 Industrial Parkway North Aurora, Ontario, Canada L4G 4C4 Phone: 905-841-5004 Fax: 905-841-0611 Email: j...@geotech.ca When a print preview is called to write to a wxPLplotstream from ------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev _______________________________________________ Plplot-general mailing list Plplot-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-general