Closed 461353349 closed 4 years ago
Hi, CinoLib is meant to provide basic ingredients to build research oriented software prototypes. To this end, the functionalities you mention are not strictly contained in the library, but all the ingredients are available, so that you can implement them with a few lines of code. As a representative example, I am attaching at the bottom of this message a simple implementation of the mouse_click callback which would allow you to show/hide a selected element from a volumetric mesh such as the one shown in the picture above with CTRL+click and SHIFT+click. To try it out you can literally copy/paste such code in the library examples, and play it.
A few extra notes on this tool:
the {vert/edge/face/poly}_pick facilities are implemented in the most trivial possible way, so they run in O(n) with n being the number of elements. This is usually OK for user interaction and medium sized meshes. Should you need more speed, you can always use a cinolib::Octree and the ray intersection query, obtaining more accurate item selections at a much faster speed.
the selection of all the elements inside a box drawn in the canvas could be easily generated starting from my example. In that case you should implement the mouse_press/mouse_release callbacks for the generation of the wanted rectangular selection. The rest is not significantly different from the code I am sharing with you
Good luck!
gui.callback_mouse_press = [&](GLcanvas *c, QMouseEvent *e)
{
if(e->modifiers() == Qt::ControlModifier)
{
vec3d p;
vec2i click(e->x(), e->y());
if (c->unproject(click, p))
{
uint pid = m.pick_poly(p);
m.poly_data(pid).visible = false;
m.updateGL();
c->updateGL();
}
}
else if(e->modifiers() == Qt::ShiftModifier)
{
vec3d p;
vec2i click(e->x(), e->y());
if(c->unproject(click, p))
{
uint fid = m.pick_face(p);
for(uint pid : m.adj_f2p(fid)) m.poly_data(pid).visible = true;
m.updateGL();
c->updateGL();
}
}
};
I see! Thank you very much!!!
Hello @mlivesu
could you please give an up-to-date sampel code for doing this without Qt (but GLFW instead) ? I tried this, but the 'visible' attribute is no longer available:
I found this:
m.poly_data(pid).flags[HIDDEN] = false;
and it seems to work.
But I am now wondering how the CTRL key is supposed to work: it seems to set tets as visible when selecting a tet witH CTRL key, but I don't know how it could work..
Hi, sorry for the late reply but I was on vacation :)
As you noticed some things have changed since my reply to this issue back in 2019. In the current version of cinolib manual selection facilities to show/hide elements have been incorporated in the VolumeMeshControls. More specifically, if you run the tetmesh viewer example and press the TAB key to show the side bar, you will notice that there is a menu item called Manual Digging
. If you expand this, you can select an action between dig
, undig
, isolate
. All these options are controlled with SHIFT + mouse click on a mesh element and serve to: hide an element (dig
), show an element (undig
) or to hide all the elements that are incident to a selected element (isolate
).
I hope this will help you out! Marco
If the selected elements could be shown or hidden, The inside of the model could be seen. It is useful for some applications. Will cinolib add the mouse selction api or functions? For example 1) Interactive rectangle selection of nodes or elements; 2) Hiding the selected nodes and elements.