Redraw function did not work

For any question about plugins!
Post Reply
yjf27281181
Posts: 16
Joined: Mon Sep 26, 2016 12:46 am

Redraw function did not work

Post 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?
daniel
Site Admin
Posts: 7713
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Redraw function did not work

Post 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).
Daniel, CloudCompare admin
yjf27281181
Posts: 16
Joined: Mon Sep 26, 2016 12:46 am

Re: Redraw function did not work

Post 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?
daniel
Site Admin
Posts: 7713
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Redraw function did not work

Post 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.
Daniel, CloudCompare admin
Post Reply