in recent days I have extended the ViewProviderExt class in the Part module to support all display modes like the default ViewProviderPart class. There we only have a handful of shapes, i.e. one node for all faces, one node for all edges and one node for all vertices. Compared to the default view provider the rendering speed and user interaction is incredible fast. The slow-down of the default view provider comes from the fact that we use an own node for each element which especially makes user-interaction extremely slow.
To have a good comparison of the both you can run this piece of python code:
Code: Select all
from PartDesign.Scripts import Gear App.ActiveDocument.addObject("Part::FeatureExt").Shape=App.ActiveDocument.Gear3D.Shape
The new thing is that selection is partially working. If you have CAD navigation enabled and click somewhere on an element you see the element name in the status bar. The idea behind is actually quite simple. With the SoDetail classes we have all what we need. For lines and points we can use the ready classes SoIndexedLineSet and SoPointSet. Only for faces we had to sub-class SoIndexedFaceSet to support segments/parts. In ViewProviderPartExt::getElement(const SoPickedPoint* pp) we can distinguish which type (face, edge or vertex) was picked and get its element id directly from the SoDetail sub-classes.
So, the next steps will be to wire this with our selection framework which is actually easy and to give some user feedback in the 3d view, i.e. to highlight the element. This, however, is much harder because we have to find a way to render only a part of a shape node with a different color to highlight it -- preferably drawing to the front buffer to be fast. Any ideas how this can be achieved?
Another point we should take into account: the new selection uses a single SoFCUnifiedSelection node as root in the scene graph. This node is implemented to run a pick action for every mouse movement. This however causes a noticeable slow-down if you have e.g. a huge mesh in the document. With the old approach we are able to disable selection on object-side to avoid performance problems. However, with this global selection node this is not longer possible because it runs the slow ray pick action independent of selection is disabled on object side or not.
There is also a design flaw in SoFCUnifiedSelection because the access to the View3DInventorViewer class is hard-coded. However, this can lead to some problems when loading an existent .iv file. The cleaner way is to implement an SoElement sub-class and define the viewer instance in the actualRedraw() method.
Any comments are welcome.