Override mode works with non-toplevel viewprovider
And adopt the part design body to handle the override mode correctly
This commit is contained in:
parent
048c374080
commit
666a5968cb
|
@ -127,6 +127,7 @@
|
|||
|
||||
#include "SoTouchEvents.h"
|
||||
#include "WinNativeGestureRecognizers.h"
|
||||
#include "Document.h"
|
||||
|
||||
//#define FC_LOGGING_CB
|
||||
|
||||
|
@ -566,9 +567,15 @@ View3DInventorViewer::~View3DInventorViewer()
|
|||
void View3DInventorViewer::setDocument(Gui::Document* pcDocument)
|
||||
{
|
||||
// write the document the viewer belongs to to the selection node
|
||||
guiDocument = pcDocument;
|
||||
selectionRoot->pcDocument = pcDocument;
|
||||
}
|
||||
|
||||
Document* View3DInventorViewer::getDocument() {
|
||||
return guiDocument;
|
||||
}
|
||||
|
||||
|
||||
void View3DInventorViewer::initialize()
|
||||
{
|
||||
navigation = new CADNavigationStyle();
|
||||
|
@ -683,8 +690,9 @@ void View3DInventorViewer::setOverrideMode(const std::string& mode)
|
|||
|
||||
overrideMode = mode;
|
||||
|
||||
for (std::set<ViewProvider*>::iterator it = _ViewProviderSet.begin(); it != _ViewProviderSet.end(); ++it)
|
||||
(*it)->setOverrideMode(mode);
|
||||
auto views = getDocument()->getViewProvidersOfType(Gui::ViewProvider::getClassTypeId());
|
||||
for (auto view : views)
|
||||
view->setOverrideMode(mode);
|
||||
}
|
||||
|
||||
/// update override mode. doesn't affect providers
|
||||
|
|
|
@ -341,6 +341,7 @@ public:
|
|||
NavigationStyle* navigationStyle() const;
|
||||
|
||||
void setDocument(Gui::Document *pcDocument);
|
||||
Gui::Document* getDocument();
|
||||
|
||||
virtual PyObject *getPyObject(void);
|
||||
|
||||
|
@ -420,6 +421,7 @@ private:
|
|||
SbBool allowredir;
|
||||
|
||||
std::string overrideMode;
|
||||
Gui::Document* guiDocument = nullptr;
|
||||
|
||||
ViewerEventFilter* viewerEventFilter;
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ PROPERTY_SOURCE_ABSTRACT(Gui::ViewProvider, App::PropertyContainer)
|
|||
ViewProvider::ViewProvider()
|
||||
: pcAnnotation(0)
|
||||
, pyViewObject(0)
|
||||
, overrideMode("As Is")
|
||||
, _iActualMode(-1)
|
||||
, _iEditMode(-1)
|
||||
, viewOverrideMode(-1)
|
||||
|
@ -334,19 +335,27 @@ bool ViewProvider::isVisible() const
|
|||
}
|
||||
|
||||
void ViewProvider::setOverrideMode(const std::string &mode)
|
||||
{
|
||||
if (mode == "As Is")
|
||||
{
|
||||
if (mode == "As Is") {
|
||||
viewOverrideMode = -1;
|
||||
overrideMode = mode;
|
||||
}
|
||||
else {
|
||||
std::map<std::string, int>::const_iterator it = _sDisplayMaskModes.find(mode);
|
||||
if (it == _sDisplayMaskModes.end())
|
||||
return; //view style not supported
|
||||
viewOverrideMode = (*it).second;
|
||||
overrideMode = mode;
|
||||
}
|
||||
if (pcModeSwitch->whichChild.getValue() != -1)
|
||||
setModeSwitch();
|
||||
}
|
||||
|
||||
const string ViewProvider::getOverrideMode() {
|
||||
return overrideMode;
|
||||
}
|
||||
|
||||
|
||||
void ViewProvider::setModeSwitch()
|
||||
{
|
||||
if (viewOverrideMode == -1)
|
||||
|
|
|
@ -233,6 +233,7 @@ public:
|
|||
bool isVisible() const;
|
||||
/// Overrides the display mode with mode.
|
||||
virtual void setOverrideMode(const std::string &mode);
|
||||
const std::string getOverrideMode();
|
||||
//@}
|
||||
|
||||
|
||||
|
@ -348,6 +349,7 @@ protected:
|
|||
/// The root separator for annotations
|
||||
SoSeparator *pcAnnotation;
|
||||
ViewProviderPy* pyViewObject;
|
||||
std::string overrideMode;
|
||||
|
||||
private:
|
||||
void setModeSwitch();
|
||||
|
|
|
@ -105,13 +105,26 @@ void ViewProviderBody::attach(App::DocumentObject *pcFeat)
|
|||
void ViewProviderBody::setDisplayMode(const char* ModeName) {
|
||||
|
||||
//if we show "Through" we must avoid to set the display mask modes, as this would result
|
||||
//in going into tip mode. When through is chosen the child features are displayed, and all
|
||||
//in going into "tip" mode. When through is chosen the child features are displayed, and all
|
||||
//we need to ensure is that the display mode change is propagated to them fro within the
|
||||
//onChanged() method.
|
||||
if(DisplayModeBody.getValue() == 1)
|
||||
PartGui::ViewProviderPartExt::setDisplayMode(ModeName);
|
||||
}
|
||||
|
||||
void ViewProviderBody::setOverrideMode(const std::__cxx11::string& mode) {
|
||||
|
||||
//if we are in through mode, we need to ensure that the override mode is not set for the body
|
||||
//(as this would result in "tip" mode), it is enough when the children are set to the correct
|
||||
//override mode.
|
||||
|
||||
if(DisplayModeBody.getValue() != 0)
|
||||
Gui::ViewProvider::setOverrideMode(mode);
|
||||
else
|
||||
overrideMode = mode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool ViewProviderBody::doubleClicked(void)
|
||||
{
|
||||
|
@ -353,10 +366,24 @@ void ViewProviderBody::onChanged(const App::Property* prop) {
|
|||
|
||||
if(prop == &DisplayModeBody) {
|
||||
|
||||
if ( DisplayModeBody.getValue() == 0 )
|
||||
if ( DisplayModeBody.getValue() == 0 ) {
|
||||
//if we are in an override mode we need to make sure to come out, because
|
||||
//otherwise the maskmode is blocked and won't go into "through"
|
||||
if(getOverrideMode() != "As Is") {
|
||||
auto mode = getOverrideMode();
|
||||
ViewProvider::setOverrideMode("As Is");
|
||||
overrideMode = mode;
|
||||
}
|
||||
setDisplayMaskMode("Through");
|
||||
else
|
||||
setDisplayMaskMode(DisplayMode.getValueAsString());
|
||||
}
|
||||
else {
|
||||
if(getOverrideMode() == "As Is")
|
||||
setDisplayMaskMode(DisplayMode.getValueAsString());
|
||||
else {
|
||||
Base::Console().Message("Set override mode: %s\n", getOverrideMode().c_str());
|
||||
setDisplayMaskMode(getOverrideMode().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
unifyVisualProperty(prop);
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
virtual SoGroup* getChildRoot(void) const {return pcBodyChildren;}
|
||||
virtual std::vector<App::DocumentObject*> claimChildren3D(void)const;
|
||||
virtual void setDisplayMode(const char* ModeName);
|
||||
virtual void setOverrideMode(const std::__cxx11::string& mode);
|
||||
|
||||
virtual bool onDelete(const std::vector<std::string> &);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user