QCustomPlot Discussion and Comments

QCPCurve : set CurveT From CurveKeyReturn to overview

Hi,

I'm currently subclassing QCPItemTracer to support QCPCurve.

For the updatePosition() method, I'm trying to find the curveValue from the curveKey like for graphs.
But if I understand the function curve->data()->findbegin takes the curveT as argument and not the curveKey.

QCPCurveDataContainer::const_iterator it =curve->data()->findBegin(curveKey);

My question is how can I find the curveT from the approximative curveKey to be able to use findBegin correctly ?

Thanks a lot for your help

Hi,

This is what I just did

double t = 0;
double value = 0;
double key = 0;
 QCPCurveDataContainer::const_iterator first = mCurve->data()->constBegin();
 QCPCurveDataContainer::const_iterator last = mCurve->data()->constEnd()-1;

for (QCPCurveDataContainer::const_iterator it = first; it != last +1; it++) {
	if (it->key <=  mCurveKey) {
                t = it->t;
		key = it->key;
		value = it->value;
	}
} 

QCPCurveDataContainer::const_iterator it = mCurve->data()->findBegin(t); 

And then i did the same code as updateposition() for graphs.

Is that right ?

Thanks