[kde-edu]: KDE/kdeedu/libkdeedu/kdeeduplot

David Saxton david at bluehaze.org
Wed Oct 18 21:26:54 CEST 2006


Example result of automatic positioning of labels: 
http://www.bluehaze.org/~david/label-positioning.png

(I haven't tested the code with drawing the label directly over a point yet, 
since such usage has never come up yet in KmPlot).

Unfortunately I don't have any time at the moment to extract any of the code 
myself, but it should be pretty easy to extract. Just pull in 
the "View::initDrawLabels" and "View::drawLabel" functions, and add any other 
functions / member variables that the compiler complains are missing. Be 
careful about some parts of the code that use KmPlot's coordinate system 
instead of the widget (pixel) coordinate system, though. The former is 
generally referred to as "realPos", and the latter as "pixelPos".


On Wednesday 18 Oct 2006 20:18, Benoît Jacob wrote:
> Sounds good! I don't have any experience with kmplot, so I don't know how
> good it is at drawing labels. Your algorithm seems to make sense, only you
> have the experience to tell how well/fast it does the job. Really, if you
> think it's good enough for kdeeduplot, then go ahead: I can't deny I'm
> short on time and don't want to duplicae something that has already been
> done in KDE! So just tell me what you decide. On the other hand, if you
> don't do it, then I might be better off implementing my own algorithm
> rather than trying to extract the relevant part of your code.
>
> Benoit
>
> Le mercredi 18 octobre 2006 20:53, David Saxton a écrit :
> > KmPlot has some code for automatic positioning of labels (to avoid
> > overwriting other labels or existing plots). If this is appropriate for
> > your use, look in svn://trunk/KDE/kdeedu/kmplot/kmplot/view.[cpp/h], in
> > particular "View::initDrawLabels" and "View::drawLabel".
> >
> > The algorithm is pretty crude, but fast enough - it just keeps track of
> > where stuff has been drawn, and when View::drawLabel is called with a
> > label and a position, it just shifts the position about until it finds
> > somewhere close by with most of the label area unused. If the label could
> > not be drawn over the requested position, then it draws a line from the
> > label to the requested position.
> >
> > David


More information about the kde-edu mailing list