Managing DB tree view (colapse items)

Any question about the main GUI application (frontend)
Post Reply
eimixas
Posts: 36
Joined: Thu Jan 17, 2013 8:14 am

Managing DB tree view (colapse items)

Post by eimixas »

1.Is there posibility to control if item in DB tree view is colapsed or expanded?
PointX are show as expanded, PointY is colapsed.
If sphere, plane or any primitive is created - it is shown expanded at first (image below).

2. I modified ccGLWindow.cpp to create spheres instead of labels (SHIFT+LEFT MOUSE).
there is code:

Code: Select all

ccHObject* obj = m_globalDBRoot->find(selectedID);
if (obj && obj->isKindOf(CC_POINT_CLOUD))
{
	/*
	cc2DLabel* label = new cc2DLabel();
	label->addPoint(static_cast<ccGenericPointCloud*>(obj),pointID);
	label->setVisible(true);
	label->setDisplay(obj->getDisplay());
	label->setPosition((float)(cursorX+20)/(float)width(),(float)(cursorY+20)/(float)height());
	*/

	ccGenericPointCloud* cloud = static_cast<ccGenericPointCloud*>(obj);
	const CCVector3 *Point = cloud->getPoint(pointID);
	ccGLMatrix *SphereTransformation = new ccGLMatrix();
	(*SphereTransformation) += (*Point);
	ccSphere* label = new ccSphere(0.5f, SphereTransformation, "PointX", 12);
	delete SphereTransformation;

	label->setColor(ccColor::magenta);
	label->showColors(true);
	label->setDrawName(true);
	label->setVisible(true);
	label->setDisplay(obj->getDisplay());

	obj->addChild(label,true);
	emit newLabel(static_cast<ccHObject*>(label));
	QApplication::processEvents();
	redraw();
}
There "obj" represents selected point cloud, is the posibility to get selected "Group" like A1, A2 or A3 in image?

Image
daniel
Site Admin
Posts: 7712
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Managing DB tree view (colapse items)

Post by daniel »

1. Whether the item is expanded or not is selectable when the object is added to DB tree (see addToDB, second parameter 'autoExpandDBTree').

2. By doing so, you break apart from the official CC version and your plugin won't work anymore with it (+ mind the consequences regarding the GPL license). I won't be able to help you anymore either. Wouldn't it be easier to hide the 2D part of the label and simply change its label ? (it's a much minor modification for the software)

For the grouping issue, you could look among the cloud's children and find the group with the right name? (I'm not sure to have clearly understand what you want to do here).
Daniel, CloudCompare admin
eimixas
Posts: 36
Joined: Thu Jan 17, 2013 8:14 am

Re: Managing DB tree view (colapse items)

Post by eimixas »

1. Thank you, it works, great.

2.problems with labels already encountered:
a) labels could not be moved in DB tree (they depends on it's point cloud)
b) label could not exist independently, new point cloud has to be created.
and spheres for this situation are just great :)

Could i make modifications to cGenericPrimitve.h and others like:

Code: Select all

public:
+	//! Returns if draw name or not
+	virtual bool getDrawName() { return m_drawName; }

+	//! Sets if draw name or not
+	virtual void setDrawName(bool drawName) { m_drawName = drawName; }
protected:
+	bool m_drawName;
and in ccSphere.cpp

Code: Select all

+void ccSphere::drawMeOnly(CC_DRAW_CONTEXT& context)
+{
+	ccGenericPrimitive::drawMeOnly(context);

+	if (getDrawName())
+	{
+	...
+	}
+}
and other modifications that does not affects application behaviour unless are set to change something.
How can i submit code (what application is recomended in windows environment)?

And for point_picking - i tried to find if it is possible. I would make to it configurable: creates 2D labels unless some checkbox is checked to do it in other way.

Or are any of my intentions not acceptable for you or GPL license?

3. Group
In image "PointY" is selected (as any other item could be selected in tree)
And i want to know what object or group of them is selected in tree, so i could set parent to new objects.
("obj" in that context represents cloud in which point is picked/selected, not object in tree)
daniel
Site Admin
Posts: 7712
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Managing DB tree view (colapse items)

Post by daniel »

1. Good.

2. "SHIFT+left click" is for labels and will stay like this in CC. We can't modify the application general behavior/GUI for a particular plugin. So instead of trying to use an already existing shortcut, the best solution for your plugin is to add a dedicated button for adding/picking a sphere at a given place. Your plugin can output multiple QAction(s), one of which being such a tool). This action will use the same framework as the standard point picking mechanism in CC (see ccPointPropertiesDlg for instance: listen to the 'leftButtonClicked' signal of ccGLWindow then do whatever you desire). By the way, QAction can have associated keyboard shortcuts (make sure to set the keyboard shortcut to 'Qt::ApplicationShortcut').

On the contrary, the 'draw name' mechanism could be extended to all objects (as this is a more generic mechanism that could be interesting for others). It could be added not only to all primitives but instead to all 'ccDrawableObject' object. I'll try to make something of it quickly.

And if you have a git-hub account you can make 'pull requests' (see https://github.com/cloudcompare/trunk). Github provides its own dedicated tool on windows (http://windows.github.com/).

3. It's another reason why you shouldn't place your code in ccGLWindow. In the 'Model-View-Controller' paradigm, view components (such as ccGLWindow) shouldn't be able to modify the database directly (they are only a particular way to look at the database). So 'ccGLWindow' can only 'read' the database and send signals that will eventually be grabbed by the controller (the core application) which is allowed to modify the database. By the way this is very practical when you want to use the same 'view' component with different applications (this is the case of 'ccGLWindow' that is also used by ccViewer, while ccViewer has a different database).

Anyway, if you react on the 'leftButtonClicked' signal in your plugin (which is closer to the 'controller' part) you will be able to get the currently selected object (with 'm_app' member) and do what you wish. At least I guess so.
Daniel, CloudCompare admin
daniel
Site Admin
Posts: 7712
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Managing DB tree view (colapse items)

Post by daniel »

I've just added to the main branch methods to display the entity name in 3D.
It can be activated (in the code) with:

Code: Select all

myEntity->showNameIn3D(true);
It can also be interactively activated/deactivated via the properties dialog. Default behavior is: name centered on the bounding box. But for spheres: the name is aligned on the right.
Daniel, CloudCompare admin
eimixas
Posts: 36
Joined: Thu Jan 17, 2013 8:14 am

Re: Managing DB tree view (colapse items)

Post by eimixas »

Yes, already tested :)
It has "black" background, why?
Why not like labels 3D name - without background?
daniel
Site Admin
Posts: 7712
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Managing DB tree view (colapse items)

Post by daniel »

Because you can't read it above white entities (default clouds in CC are white). In fact ,it's 25% transparent black and it's simply the inverse of the text color (if you change the text color, the background automatically change also).
Daniel, CloudCompare admin
Post Reply