PartDesign: Boolean must show the operation result, not the children. fixes #0003184
This commit is contained in:
@@ -649,6 +649,7 @@ void finishFeature(const Gui::Command* cmd, const std::string& FeatName,
|
||||
cmd->copyVisual(FeatName.c_str(), "LineColor", pcActiveBody->getNameInDocument());
|
||||
cmd->copyVisual(FeatName.c_str(), "PointColor", pcActiveBody->getNameInDocument());
|
||||
cmd->copyVisual(FeatName.c_str(), "Transparency", pcActiveBody->getNameInDocument());
|
||||
cmd->copyVisual(FeatName.c_str(), "DisplayMode", pcActiveBody->getNameInDocument());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -230,12 +230,21 @@ void ViewProvider::setBodyMode(bool bodymode) {
|
||||
std::vector<App::Property*> props;
|
||||
getPropertyList(props);
|
||||
|
||||
auto vp = getBodyViewProvider();
|
||||
if(!vp)
|
||||
return;
|
||||
|
||||
for(App::Property* prop : props) {
|
||||
|
||||
//we keep visibility and selectibility per object
|
||||
if(prop == &Visibility ||
|
||||
prop == &Selectable)
|
||||
continue;
|
||||
|
||||
//we hide only properties which are available in the body, not special ones
|
||||
if(!vp->getPropertyByName(prop->getName()))
|
||||
continue;
|
||||
|
||||
prop->setStatus(App::Property::Hidden, bodymode);
|
||||
}
|
||||
}
|
||||
@@ -261,6 +270,20 @@ PyObject* ViewProvider::getPyObject()
|
||||
return pyViewObject;
|
||||
}
|
||||
|
||||
ViewProviderBody* ViewProvider::getBodyViewProvider() {
|
||||
|
||||
auto body = PartDesign::Body::findBodyOf(getObject());
|
||||
auto doc = getDocument();
|
||||
if(body && doc) {
|
||||
auto vp = doc->getViewProvider(body);
|
||||
if(vp && vp->isDerivedFrom(ViewProviderBody::getClassTypeId()))
|
||||
return static_cast<ViewProviderBody*>(vp);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
namespace Gui {
|
||||
/// @cond DOXERR
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#define PARTGUI_ViewProvider_H
|
||||
|
||||
#include <Mod/Part/Gui/ViewProvider.h>
|
||||
#include "ViewProviderBody.h"
|
||||
#include <Gui/ViewProviderPythonFeature.h>
|
||||
|
||||
|
||||
@@ -59,6 +60,9 @@ public:
|
||||
//shape of this viewprovider from other viewproviders without doing anything to the
|
||||
//document and properties.
|
||||
void makeTemporaryVisible(bool);
|
||||
|
||||
//Returns the ViewProvider of the body the feature belongs to, or NULL, if not in a body
|
||||
ViewProviderBody* getBodyViewProvider();
|
||||
|
||||
virtual PyObject* getPyObject(void);
|
||||
|
||||
|
||||
@@ -31,21 +31,30 @@
|
||||
|
||||
#include "ViewProviderBoolean.h"
|
||||
#include "TaskBooleanParameters.h"
|
||||
#include "ViewProviderBody.h"
|
||||
#include <Mod/PartDesign/App/FeatureBoolean.h>
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
PROPERTY_SOURCE_WITH_EXTENSIONS(PartDesignGui::ViewProviderBoolean,PartDesignGui::ViewProvider)
|
||||
|
||||
const char* PartDesignGui::ViewProviderBoolean::DisplayEnum[] = {"Result","Tools",NULL};
|
||||
|
||||
|
||||
ViewProviderBoolean::ViewProviderBoolean()
|
||||
{
|
||||
sPixmap = "PartDesign_Boolean.svg";
|
||||
initExtension(this);
|
||||
|
||||
ADD_PROPERTY(Display,((long)0));
|
||||
Display.setEnums(DisplayEnum);
|
||||
}
|
||||
|
||||
ViewProviderBoolean::~ViewProviderBoolean()
|
||||
@@ -116,4 +125,27 @@ bool ViewProviderBoolean::onDelete(const std::vector<std::string> &s)
|
||||
return ViewProvider::onDelete(s);
|
||||
}
|
||||
|
||||
void ViewProviderBoolean::attach(App::DocumentObject* obj) {
|
||||
PartGui::ViewProviderPartExt::attach(obj);
|
||||
|
||||
//set default display mode to override the "Group" display mode
|
||||
setDisplayMode("Flat Lines");
|
||||
}
|
||||
|
||||
void ViewProviderBoolean::onChanged(const App::Property* prop) {
|
||||
|
||||
PartDesignGui::ViewProvider::onChanged(prop);
|
||||
|
||||
if(prop == &Display) {
|
||||
|
||||
if(Display.getValue() == 0) {
|
||||
auto vp = getBodyViewProvider();
|
||||
if(vp)
|
||||
setDisplayMode(vp->DisplayMode.getValueAsString());
|
||||
else
|
||||
setDisplayMode("Flat Lines");
|
||||
} else {
|
||||
setDisplayMode("Group");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,13 +41,19 @@ public:
|
||||
/// destructor
|
||||
virtual ~ViewProviderBoolean();
|
||||
|
||||
App::PropertyEnumeration Display;
|
||||
|
||||
/// grouping handling
|
||||
void setupContextMenu(QMenu*, QObject*, const char*);
|
||||
|
||||
virtual bool onDelete(const std::vector<std::string> &);
|
||||
virtual void attach(App::DocumentObject*);
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
|
||||
static const char* DisplayEnum[];
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user