Page 1 of 1

Redraw function did not work

Posted: Thu Dec 14, 2017 2:41 am
by yjf27281181
Hello, Denial
I met a very weird problem which did not occur before. I tried to change the color of points in cloudpoints and hoped that their colors could be changed immediately. However, the reality is that the colors would not be changed immediately. In fact, I should change the option of "Active" in Scalar field and then change it back to make the colors change.

my code is:

Code: Select all

	CCLib::ScalarField* temp = cloudpoints->getScalarField(classificationScalar);
	unsigned cloudSize = cloudpoints->size();

	ccLog::Warning(QString("cloudSize[ %1]").arg(cloudSize));
	for (int i = 0; i < static_cast<int>(cloudSize); ++i)
	{
		temp->setValue(i, 8);
	}
	m_associatedWin->redraw(false);
Could you tell me how to fix it?

Re: Redraw function did not work

Posted: Thu Dec 14, 2017 8:04 pm
by daniel
I don't "deny" anything ;). My name is Daniel :D

When you modify a scalar field, you have to call the 'computeMinAndMax' on the scalar field (to update its min and max values).

And you may also have to call 'invalidateBoundingBox' on the point cloud (in fact it's a trick to call 'releaseVBOs', otherwise I'm not sure the VBOs will be updated - I'm not sure about that though). If you have to call this method, then don't hesitate to report it to me (I'll try to make this more easier).

Re: Redraw function did not work

Posted: Fri Dec 15, 2017 1:03 pm
by yjf27281181
Thank you Daniel(I hope this time I call your name correctly :D), this function works.
But I still do not understand what the function of "Redraw()" is. And few weeks ago, the colors of points could be changed immediately when I modified the scalar field even I did not add this function. Why?

Re: Redraw function did not work

Posted: Fri Dec 15, 2017 4:05 pm
by daniel
Was the first function (computeMinAndMax) sufficient? Or was it necessary to call the other one (invalidateBoundingBox)?

If VBOs are activated, then changing the scalar field may not update the representation of the scalar field (as colors) on the GPU memory. You have to tell CC that something has changed.