24 Apr 15:43
some new information (with code) on the nonprinting qwtplotmarker problem
From: Peter Leopold <Peter.Leopold <at> BioAnalyte.com>
Subject: some new information (with code) on the nonprinting qwtplotmarker problem
Newsgroups: gmane.comp.graphics.qwt.general
Date: 2008-04-24 13:43:57 GMT
Subject: some new information (with code) on the nonprinting qwtplotmarker problem
Newsgroups: gmane.comp.graphics.qwt.general
Date: 2008-04-24 13:43:57 GMT
Uwe Rathmann <Uwe.Rathmann <at> tigertal.de> writes:
>
> On Wednesday 23 April 2008 22:34, Peter Leopold wrote:
>
> > Has anyone had success labeling QwtPlots with QwtPlotMarkers, then
> > exporting the plots to pdf or a printer?
>
> Yes, f.e the bode example does it.
>
> > If so, do you create std::vector<QwtPlotMarker> to hold the markers?
> > QList<QwtPlotMarker>? Dynamically allocated arrays, viz.,
>
> No, why should I ?
>
Thanks Uwe. Points taken! A new day brings new energy to this mini-project.
Here
is more information:
1) My plotmarkers are alphanumeric strings "A1" "G3" etc. They show up on the
screen, but not in the pdf file or in the printer.
2) I tried printing to PostScriptFormat. Same problem. Here is the code.
void printPlotToFile(
QwtPlot *qwtplot
,QString filename
){
QPrinter qp;
#if(0)
filename += ".pdf";
qp.setOutputFormat(QPrinter::PdfFormat);
#else
filename += ".ps";
qp.setOutputFormat(QPrinter::PostScriptFormat);
#endif
qp.setOutputFileName(filename);
qp.setOrientation(QPrinter::Landscape);
qp.setResolution(300);//dpi
QwtPlotPrintFilter ppf;
ppf.setOptions(QwtPlotPrintFilter::PrintAll);
ppf.color(Qt::red,QwtPlotPrintFilter::Marker);
qwtplot->replot();
qwtplot->print(qp,ppf);
}
3) Things I know don't matter: qp.setResolution(),
QwtPlotPrintFilter.setOptions() and .color(). Postscript vs. pdf.
setOrientation(); replot();
4) I looked at both the pdf file and the postscript file in emacs looking
for my alphanumeric markers "A1" etc. They weren't there, but then most
of the file was encoded, anyway, so literals character strings were
probably also encoded.
5) I loaded the .ps file into PhotoShop and got a clue in the form of an
error message from PhotoShop. "This file uses one or more fonts which are
unavailable on this machine." (Note that fonts for title, subtitle and
legend are supported and print fine.)
6) So I set font explicitly where the QwtPlotMarkers are created
int annotatePlot(){
if(markerTIC!=0)delete [] markerTIC;markerTIC=0;
try{markerTIC = new QwtPlotMarker [part.size()];}// 'part' is an std::vector
catch(...){return MEMORY_ALLOCATION_ERROR;}
QFont qf("Helvetica", 12);
QwtText qtxt;
qtxt.setFont(qf);
for(unsigned int i=0;i<part.size();i++){
qtxt.setText(part[i].vial); // part[i].vial is a QString
markerTIC[i].setLabel(qtxt);
markerTIC[i].setValue(part[i].midpoint,LabelOffset+part[i].height);
markerTIC[i].attach(qwtPlotTIC); //what happens to memory
//profile in attach)? I don't know
}
return OK;
}
Helvetica is also described as an unsupported font by PhotoShop!?!?!
That's very strange.
So this is where I stand now.
Next steps
1) The next step is to try to try to extract the markerTIC array from
qwtPlotTIC to prove that it is still there. It is certainly still there
in my own memory space. I don't destruct my copy (the only copy?) of
the QwtPlotMarker array until I do a general memory cleanup.
2) Assuming qwtPlot still has its qwtPlotMarkers, I will then chase the
problem down the rabbit hole called qwtPlot->print(). For this, I will
follow Uwe's advice to compile a debug version of qwt.
Everything is being done in qwt5.0.2, with mingw on Windows and g++ on
Linux. While this may yet be a Microsoft printer driver interface issue,
it is not a Microsoft development environment issue.
I can't see any way to finesse this problem.
I can attach the screen shot and the pdf to make the point of the
missing alphanumerics. (First I have to figure out how to attach
files in this user forum.)
Peter
> > Uwe suggested that I try to compile the entire source of Qwt into my own
> > app.
>
> No, all I asked you is to try a few simple things to identify the source of
> the problem. Obviously you did none of them, instead you reposted the same
> problem without any new informations.
>
> > I will try this in the next few days, but since my compilation
> > environment (basically just qmake -project ; qmake ; make) is not
> > compatible with the elegant, non-local architecture of the qwt project
> > files, and I would (and could) break a lot to make it work.
>
> On Linux ( with shared libraries ) with Qwt 5.0.2:
>
> - Build Qwt as it is in debug mode somewhere and don't install it.
> - export LD_LIBRARY_PATH=/your/path/to/qwt-5.0.2/lib:$LD_LIBRARY_PATH
>
> Try "ldd /your/path/to/your/application" to be sure, that it uses your local
> Qwt build. If true start your application. Nothing will be broken, believe
> me.
>
> Uwe
>
> PS:
>
> Only if you are using static libraries you need to rebuild your application.
> Then you need to replace the paths to Qwt temporarily in your project file:
>
> INCLUDEPATH += /your/path/to/qwt-5.0.2/src
> LIBS += -L/your/path/ro/qwt-5.0.2/lib -lqwt
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
>
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
RSS Feed