How to highlight datum planes

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
jrheinlaender
Posts: 554
Joined: Sat Apr 07, 2012 2:42 am

How to highlight datum planes

Post by jrheinlaender »

Hi,

I implemented datum planes/lines/points but now I am at a loss on how to highlight them when they are pre-selected and selected?
Any hints?

Thanks,
Jan
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: How to highlight datum planes

Post by ickby »

Hello jan,

is your question regarding implementation of basic selection or how to show the selection in a comprehensible way? About the selection presentation you can look at my constraint selection implementation, it highlights the faces/edges/verteices used for the constraints and makes them visible through all parts. This makes it easy for the user to see what is selected even if it's deeply hidden inside the part, what would be the case for your planes too, I belive. I used the soannotation node for that. (But my implementation is rather hacky, not the best source for inspiration :) )
User avatar
yorik
Founder
Posts: 13659
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: How to highlight datum planes

Post by yorik »

I'm also interested in that (show the selection).. Can you point to an example code ickby?
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: How to highlight datum planes

Post by ickby »

As I said, It's not the cleanest implementation :) I abused the ViewProviderPart to create the coin nodes for the selected shape and just reorderd it's main node beneath a SoAnnotation node. This can be seen here: https://github.com/ickby/FreeCAD_constr ... traint.cpp

The node renders every node it owns on top of everything else in the scene, and if you make everything added to annotation a bit transparent it looks like it's shining through. Can't post a picture now, my freecad crashes :)
User avatar
yorik
Founder
Posts: 13659
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: How to highlight datum planes

Post by yorik »

Hm interesting... I should try something like that for the Draft dimensions (currently selectable but not highlighted). Anyway, this is a good trick indeed... Thanks! (half-transparent "glowing" stuff seems cool, I'll try that too)
jrheinlaender
Posts: 554
Joined: Sat Apr 07, 2012 2:42 am

Re: How to highlight datum planes

Post by jrheinlaender »

is your question regarding implementation of basic selection or how to show the selection in a comprehensible way?
When I hover the mouse over any solid geometry (e.g. face) it gets pre-selected and is visually highlighted. When I click on the face, it gets selected and highlighted in a different way.

With the datum planes which I implemented, they can be pre-selected and selected in the same way, but there is not visual feedback. Thats what I am trying to implement. The pre-selection and selection happens automatically (I didn't have to code it) but I must have missed a hook somewhere to make the visual feedback happen.
logari81
Posts: 658
Joined: Mon Jun 14, 2010 6:00 pm

Re: How to highlight datum planes

Post by logari81 »

I think I had the opposite problem when I implemented the ghost visualization of rejected pattern transformations.

As far as I remember I had to use SoIndexedFaceSet instead of SoBrepFaceSet. So you probably have to do the opposite.
jrheinlaender
Posts: 554
Joined: Sat Apr 07, 2012 2:42 am

Re: How to highlight datum planes

Post by jrheinlaender »

As far as I remember I had to use SoIndexedFaceSet instead of SoBrepFaceSet. So you probably have to do the opposite.
That didn't make any difference unfortunately. SoBrepFaceSet defines a highlightColor which is (0,0,0) by default but I can't see how to set it since the field is private in the class
logari81
Posts: 658
Joined: Mon Jun 14, 2010 6:00 pm

Re: How to highlight datum planes

Post by logari81 »

what do the following functions return on your viewprovider:

Code: Select all

useNewSelectionModel()
isSelectable()
?

if you use the SoFCUnifiedSelection.h model you shouldn't have to specify any highlight color or anything. I am 99% sure that SoBrepFaceSet supports this model and it should work by default.
jrheinlaender
Posts: 554
Joined: Sat Apr 07, 2012 2:42 am

Re: How to highlight datum planes

Post by jrheinlaender »

Both return true. I am deriving from ViewProviderGeometryObject.
Post Reply