[kde-edu]: KDEEDU Plot widget

Andreas Nicolai Andreas.Nicolai at gmx.net
Fri Jun 17 19:08:11 CEST 2005


Hi Carsten,

> By the way: Wouldn't it make sense to have that in the lib as well? We only
> have about 10 lines of code changed in the derived method.

No problem. Moment, I'll take a look at it.

Hmm...

Appearently you just add connecting lines to a point series object. You could achieve the same by adding an extra line plot object for each point plot object you want to connect as soon as "Connect points" is turned on. Shouldn't make much difference in plot performance and the extra memory usage is surely acceptable.

Alternatively a new plot style - "points connected with a line", KPlotObject::POINTED_LINE
could be created. But then only one "size" for points and lines can be selected and also only one colour. I think the option of adding a point and line plot object together is a lot more flexible, or do I overlook something here?


Btw, something technical I noticed in your virtual function: in your code you just _add_ something to the already existing functionality of KPlotWidget, so whatever is done in the original function doesn't hurt you. Instead of copying the original source code and appending it I would suggest to put the following line in front of your code:

KPlotWidget::drawObjects(p); // call virtual function of parent object

and just place the additional code below, something like

for ( KPlotObject *po = ObjectList.first(); po; po = ObjectList.next() ) {
	if ( po->points()->count() ) {
		//draw the plot object
		p->setPen( QColor( po->color() ) );

		// skip everything that is not affected by our addition
		// since it has been already drawn in KPlotWidget::drawObjects();
		if (!m_connectPoints || po->type() != KPlotObject::POINTS)
			continue;

		// draw the connecting lines here...
		// ...
	}
}


Bye,
Andreas

-- 
Andreas Nicolai                   Andreas.Nicolai at gmx.net
Syracuse University               +01 (315) 443 1099
151 E.A.Link Hall
Syracuse NY 13244-1240


More information about the kde-edu mailing list