Gui: refactor bounding box selection style
Previously, box style selection is rendered using customized SoBoxSelectionRenderAction, which does not support selection context, i.e. it does not work with Link. This patch implements context aware bound box rendering inside SoFCSelectionRoot, SoFCSelection and SoFCPathAnnotation (for always on top rendering). The box rendering in SoBoxSelectionRenderAction is disabled on construction. Box style selection can be enabled for individual object through property SelectionStyle (moved from ViewProviderGeometryObject to ViewProviderDocumentObject), or globally through Parameter BaseApp/Preferences/View/ShowSelectionBoundingBox. In addition, the parameter BaseApp/Preferences/View/UseNewSelection is used to override selection model reported from ViewProvider::useNewSelectionModel(). The reason being that, the same parameter is already used to toggle selection model inside SoFCSelection. This avoids inconsistency of selection model choice between view provider and the SoFCSelection node inside. Note that if the parameter 'UseNewSelection' is set to false, those view providers that choose old selection model will not work with Link.
This commit is contained in:
@@ -506,11 +506,15 @@ void View3DInventorViewer::init()
|
||||
pcOnTopMaterial->setOverride(true);
|
||||
pcGroupOnTop->addChild(pcOnTopMaterial);
|
||||
|
||||
pcGroupOnTopSel = new SoFCSelectionRoot;
|
||||
auto selRoot = new SoFCSelectionRoot;
|
||||
selRoot->selectionStyle = SoFCSelectionRoot::PASSTHROUGH;
|
||||
pcGroupOnTopSel = selRoot;
|
||||
pcGroupOnTopSel->setName("GroupOnTopSel");
|
||||
pcGroupOnTopSel->ref();
|
||||
pcGroupOnTop->addChild(pcGroupOnTopSel);
|
||||
pcGroupOnTopPreSel = new SoFCSelectionRoot;
|
||||
selRoot = new SoFCSelectionRoot;
|
||||
selRoot->selectionStyle = SoFCSelectionRoot::PASSTHROUGH;
|
||||
pcGroupOnTopPreSel = selRoot;
|
||||
pcGroupOnTopPreSel->setName("GroupOnTopPreSel");
|
||||
pcGroupOnTopPreSel->ref();
|
||||
pcGroupOnTop->addChild(pcGroupOnTopPreSel);
|
||||
@@ -805,9 +809,12 @@ void View3DInventorViewer::checkGroupOnTop(const SelectionChanges &Reason) {
|
||||
// onTop==2 means on top only if whole object is selected,
|
||||
// onTop==3 means on top only if some sub-element is selected
|
||||
// onTop==1 means either
|
||||
onTop = Gui::Selection().needPickedList()
|
||||
|| vp->OnTopWhenSelected.getValue()
|
||||
|| svp->OnTopWhenSelected.getValue();
|
||||
if(Gui::Selection().needPickedList())
|
||||
onTop = 1;
|
||||
else if(vp->OnTopWhenSelected.getValue())
|
||||
onTop = vp->OnTopWhenSelected.getValue();
|
||||
else
|
||||
onTop = svp->OnTopWhenSelected.getValue();
|
||||
if(Reason.Type == SelectionChanges::SetPreselect) {
|
||||
SoHighlightElementAction action;
|
||||
action.setHighlighted(true);
|
||||
|
||||
Reference in New Issue
Block a user