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:
Zheng, Lei
2019-09-17 20:42:39 +08:00
committed by wwmayer
parent d6a1ef125e
commit bb3baefdb5
20 changed files with 488 additions and 262 deletions

View File

@@ -57,6 +57,7 @@
#include "TaskView/TaskAppearance.h"
#include "ViewProviderDocumentObject.h"
#include "ViewProviderExtension.h"
#include "SoFCUnifiedSelection.h"
#include "Tree.h"
#include <Gui/ViewProviderDocumentObjectPy.h>
@@ -75,6 +76,10 @@ ViewProviderDocumentObject::ViewProviderDocumentObject()
ADD_PROPERTY(Visibility,(true));
ADD_PROPERTY(ShowInTree,(true));
ADD_PROPERTY(SelectionStyle,((long)0));
static const char *SelectionStyleEnum[] = {"Shape","BoundBox",0};
SelectionStyle.setEnums(SelectionStyleEnum);
static const char* OnTopEnum[]= {"Disabled","Enabled","Object","Element",NULL};
ADD_PROPERTY(OnTopWhenSelected,((long int)0));
ADD_PROPERTY_TYPE(OnTopWhenSelected,((long int)0), "Base", App::Prop_None,
@@ -181,6 +186,12 @@ void ViewProviderDocumentObject::onChanged(const App::Property* prop)
if(getObject() && getObject()->Visibility.getValue()!=Visibility.getValue())
getObject()->Visibility.setValue(Visibility.getValue());
}
else if (prop == &SelectionStyle) {
if(getRoot()->isOfType(SoFCSelectionRoot::getClassTypeId())) {
static_cast<SoFCSelectionRoot*>(getRoot())->selectionStyle = SelectionStyle.getValue()
?SoFCSelectionRoot::BOX:SoFCSelectionRoot::FULL;
}
}
if (pcDocument && !pcDocument->isModified() && testStatus(Gui::ViewStatus::TouchDocument)) {
if (prop)