[kde-edu]: cleaning up KPlotWidget

Jason Harris kstars at 30doradus.org
Tue Sep 5 09:46:33 CEST 2006


After my failed attempt to replace KPlotWidget, I decided to at least give it 
some love :).  Since several programs use this class, I want to give people a 
chance to comment or object before I commit.  If there are no objections, I 
will update all kdeedu programs which use KPlotWidget to the new API.

The changes:

+ get rid of explicit buffering, since this is handled internally by Qt4.
+ Reorganize paint code; renamed drawBox() to drawAxes(), and recalcPixRect() 
to setPixRect().
+ Adding TopAxis and RightAxis.  Adding a secondary Data space so these two 
axes can optionally show different limits than LeftAxis and BottomAxis.

+ Each Axis now handles the calculation of its own tickmarks (rather than 
KPlotWidget doing it).  The major and minor tickmark positions are stored in 
two QList<double>'s.
+ Simplified redundant visibility variables.  Each Axis now has a Visibility 
flag (controlling the drawing of the axis line and the tickmarks), and its 
own ShowTickLabels flag.  The Axis label is drawn if it exists.
+ I will also likely rework the tick label formatting code.  Rather than three 
separate functions for the field width, format char, and precision, I want to 
have a QString that encodes the formatting, such as "7.2g" for field width=7, 
format='g' and precision=2.  This will also allow more flexibility.  For 
example, a format string "hh:mm" could be used for expressing time values, or  
"dms" for angle values.

Let me hear your feedback; I'll be finishing it up over the next few days and 
then will make sure all kdeedu apps work with the new API (unless you tell me 
to leave yours alone).  Are there apps outside kdeedu using KPlotWidget?

KStars: http://edu.kde.org/kstars
Community Forums: http://kstars.30doradus.org

More information about the kde-edu mailing list