Page 1 of 2

How to resize "Plane"

Posted: Sat Feb 09, 2013 6:09 pm
by eimixas
Is any way to resize plane constructed with:

Code: Select all

ccPlane* pPlane = pCloud->fitPlane(&rms); 
(cloud is build from 3 selected points)

It looks like plane (rectangle) is constructed like mesh using 2 faces (tiangles) - they are shown if "wireframe" option is selected. Should i somehow modify those faces?

Could be rotation changed too? (not plane rotation, but rotation of rectangle that represents plane)

Re: How to resize "Plane"

Posted: Sun Feb 10, 2013 12:35 pm
by daniel
Primitives are parametric meshes that depends only on their 'parameters' value. The associated mesh structures (vertices and triangles) are mainly used for display and may be regenerated each time a parameter of the primitive changes (notably it's 'precision' parameter). So you can of course modify the vertices position, but you may lose this modification in an unpredictable way (each time the primitive is cloned, saved, or each time it's 'precision' parameter is changed, etc.).

The best way to do what you want is to 'duplicate' the primitive with new parameters:

Code: Select all

ccPlane* newPlane = new ccPlane(newXWidth,newYWidth,&pPlane->getTransformation());
After that, you'll have to restore display parameters yourself (plane color, stippling, etc.).

P.S. : please ask this kind of questions in the 'Developer > qCC' thread

Re: How to resize "Plane"

Posted: Sun Feb 10, 2013 6:00 pm
by eimixas
OK, i will ask similar question in 'Developer > qCC'
(i see you moved this one)

I understand - i will duplicate with new parameters. Bet how can i get old ones? pPlane->m_xWidth and pPlane->m_yHeight are "access protected" and could find how to get them.
(i want to create new plane 5mm larger then original - so i need old width/height)

Re: How to resize "Plane"

Posted: Mon Feb 11, 2013 9:22 am
by daniel
I've just added accessors to several primitives parameters (plane, sphere, box and extru).

Re: How to resize "Plane"

Posted: Thu Feb 14, 2013 12:31 pm
by eimixas
How to remove object?

New plane is created, but old ones has to be removed.

here is part of my code:

Code: Select all

	//Parent->removeChild(pPlane);
	m_app->removeFromDB(pPlane);
	
	m_app->refreshAll();
	m_app->updateUI();

	//delete pPlane;
it works only if i comment Parent->removeChild(pPlane); and delete pPlane;
is it ok? do i need only "m_app->removeFromDB(pPlane);"?

Re: How to resize "Plane"

Posted: Thu Feb 14, 2013 12:40 pm
by eimixas
And what is correct way to "select" newly created plane?

if i do like this:

Code: Select all

	NewPlane->setSelected(true);
	Parent->addChild(NewPlane);
	m_app->addToDB(NewPlane); 

	m_app->removeFromDB(pPlane);
	
	m_app->refreshAll();
	m_app->updateUI();
	m_app->redrawAll();
it is drawn as selected - but all plugin buttons are disabled. and it is not selected in "DB Tree"
Am i wrong somethere or some kind of bug?

Re: How to resize "Plane"

Posted: Thu Feb 14, 2013 12:58 pm
by daniel
Yep, 'removeFromDB' does all the job.

By the way, if you want to remove an object from DB tree without deleting it, there's another method (MainWindow::removeObjectTemporarilyFromDBTree).

Re: How to resize "Plane"

Posted: Thu Feb 14, 2013 1:10 pm
by eimixas
Thank you, i will user removeFromDB only.
And what about "selecting" newly created objects?

Re: How to resize "Plane"

Posted: Thu Feb 14, 2013 2:17 pm
by daniel
To 'select' an entity just as the user would do, see ccDBRoot::selectEntity.

In MainWindow, you can call

Code: Select all

m_ccRoot->selectEntity(myEntity);

Re: How to resize "Plane"

Posted: Thu Feb 14, 2013 3:07 pm
by eimixas
Is it possible to call this method from plugin's ::DoAction()?

something like

Code: Select all

ccDBRoot* m_ccDBRoot = (ccDBRoot*)(m_app->dbRoot());
m_ccDBRoot->selectEntity(NewPlane);
but i get:
qPlaneSizeReducePlugin.obj : error LNK2019: unresolved external symbol "public: void __thiscall ccDBRoot::selectEntity(class ccHObject *)" (?selectEntity@ccDBRoot@@QAEXPAVccHObject@@@Z) referenced in function "protected: void __thiscall qPlaneSizeReducePlugin::doAction(void)" (?doAction@qPlaneSizeReducePlugin@@IAEXXZ)