PartDesign: Change body viewprovider to group
This commit is contained in:
parent
9a3b952fb9
commit
b4a569e013
|
@ -41,6 +41,8 @@ BodyBase::BodyBase()
|
|||
{
|
||||
ADD_PROPERTY(Tip , (0) );
|
||||
ADD_PROPERTY(BaseFeature , (0) );
|
||||
|
||||
App::OriginGroupExtension::initExtension(this);
|
||||
}
|
||||
|
||||
BodyBase* BodyBase::findBodyOf(const App::DocumentObject* f)
|
||||
|
|
|
@ -439,26 +439,10 @@ void Body::onChanged (const App::Property* prop) {
|
|||
}
|
||||
|
||||
void Body::setupObject () {
|
||||
// NOTE: the code shared with App::OriginGroup
|
||||
App::Document *doc = getDocument ();
|
||||
|
||||
std::string objName = std::string ( getNameInDocument() ).append ( "Origin" );
|
||||
|
||||
App::DocumentObject *originObj = doc->addObject ( "App::Origin", objName.c_str () );
|
||||
|
||||
assert ( originObj && originObj->isDerivedFrom ( App::Origin::getClassTypeId () ) );
|
||||
Origin.setValue ( originObj );
|
||||
|
||||
Part::BodyBase::setupObject ();
|
||||
}
|
||||
|
||||
void Body::unsetupObject () {
|
||||
App::DocumentObject *origin = Origin.getValue ();
|
||||
|
||||
if (origin && !origin->isDeleting ()) {
|
||||
origin->getDocument ()->remObject (origin->getNameInDocument());
|
||||
}
|
||||
|
||||
Part::BodyBase::unsetupObject ();
|
||||
}
|
||||
|
||||
|
|
|
@ -61,22 +61,20 @@ using namespace PartDesignGui;
|
|||
|
||||
const char* PartDesignGui::ViewProviderBody::BodyModeEnum[] = {"Through","Tip",NULL};
|
||||
|
||||
PROPERTY_SOURCE(PartDesignGui::ViewProviderBody,PartGui::ViewProviderPart)
|
||||
PROPERTY_SOURCE_WITH_EXTENSIONS(PartDesignGui::ViewProviderBody,PartGui::ViewProviderPart)
|
||||
|
||||
ViewProviderBody::ViewProviderBody()
|
||||
{
|
||||
ADD_PROPERTY(DisplayModeBody,((long)0));
|
||||
DisplayModeBody.setEnums(BodyModeEnum);
|
||||
|
||||
pcBodyChildren = new SoSeparator();
|
||||
pcBodyChildren->ref();
|
||||
|
||||
sPixmap = "PartDesign_Body_Tree.svg";
|
||||
|
||||
Gui::ViewProviderOriginGroupExtension::initExtension(this);
|
||||
}
|
||||
|
||||
ViewProviderBody::~ViewProviderBody()
|
||||
{
|
||||
pcBodyChildren->unref ();
|
||||
connectChangedObjectApp.disconnect();
|
||||
connectChangedObjectGui.disconnect();
|
||||
}
|
||||
|
@ -85,9 +83,9 @@ void ViewProviderBody::attach(App::DocumentObject *pcFeat)
|
|||
{
|
||||
// call parent attach method
|
||||
ViewProviderPart::attach(pcFeat);
|
||||
|
||||
addDisplayMaskMode(pcBodyChildren, "Through");
|
||||
setDisplayMaskMode("Through");
|
||||
|
||||
//set default display mode
|
||||
onChanged(&DisplayModeBody);
|
||||
|
||||
App::Document *adoc = pcObject->getDocument ();
|
||||
Gui::Document *gdoc = Gui::Application::Instance->getDocument ( adoc ) ;
|
||||
|
@ -217,26 +215,47 @@ std::vector<App::DocumentObject*> ViewProviderBody::claimChildren(void)const
|
|||
|
||||
|
||||
std::vector<App::DocumentObject*> ViewProviderBody::claimChildren3D(void)const
|
||||
|
||||
{
|
||||
|
||||
PartDesign::Body* body = static_cast<PartDesign::Body*>(getObject());
|
||||
|
||||
|
||||
|
||||
const std::vector<App::DocumentObject*> & features = body->Group.getValues();
|
||||
|
||||
|
||||
|
||||
std::vector<App::DocumentObject*> rv;
|
||||
|
||||
|
||||
|
||||
if ( body->Origin.getValue() ) { // Add origin
|
||||
|
||||
rv.push_back (body->Origin.getValue());
|
||||
|
||||
}
|
||||
|
||||
if ( body->BaseFeature.getValue() ) { // Add Base Feature
|
||||
|
||||
rv.push_back (body->BaseFeature.getValue());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Add all other stuff
|
||||
|
||||
std::copy (features.begin(), features.end(), std::back_inserter (rv) );
|
||||
|
||||
|
||||
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TODO To be deleted (2015-09-08, Fat-Zer)
|
||||
//void ViewProviderBody::updateTree()
|
||||
//{
|
||||
|
@ -408,7 +427,7 @@ void ViewProviderBody::onChanged(const App::Property* prop) {
|
|||
ViewProvider::setOverrideMode("As Is");
|
||||
overrideMode = mode;
|
||||
}
|
||||
setDisplayMaskMode("Through");
|
||||
setDisplayMaskMode("Group");
|
||||
}
|
||||
else {
|
||||
if(getOverrideMode() == "As Is")
|
||||
|
@ -463,3 +482,11 @@ void ViewProviderBody::setVisualBodyMode(bool bodymode) {
|
|||
}
|
||||
}
|
||||
|
||||
std::vector< std::string > ViewProviderBody::getDisplayModes(void) const {
|
||||
|
||||
//we get all dislay modes and remove the "Group" mode, as this is what we use for "Through"
|
||||
//body display mode
|
||||
std::vector< std::string > modes = ViewProviderPart::getDisplayModes();
|
||||
modes.erase(modes.begin());
|
||||
return modes;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#define PARTGUI_ViewProviderBody_H
|
||||
|
||||
#include <Mod/Part/Gui/ViewProvider.h>
|
||||
#include <Gui/ViewProviderOriginGroupExtension.h>
|
||||
#include <QCoreApplication>
|
||||
|
||||
class SoGroup;
|
||||
|
@ -39,10 +40,10 @@ namespace PartDesignGui {
|
|||
* If the Body is not active it shows only the result shape (tip).
|
||||
* \author jriegel
|
||||
*/
|
||||
class PartDesignGuiExport ViewProviderBody : public PartGui::ViewProviderPart
|
||||
class PartDesignGuiExport ViewProviderBody : public PartGui::ViewProviderPart, public Gui::ViewProviderOriginGroupExtension
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(PartDesignGui::ViewProviderBody)
|
||||
PROPERTY_HEADER(PartDesignGui::ViewProviderBody);
|
||||
PROPERTY_HEADER_WITH_EXTENSIONS(PartDesignGui::ViewProviderBody);
|
||||
|
||||
public:
|
||||
/// constructor
|
||||
|
@ -59,8 +60,9 @@ public:
|
|||
virtual std::vector<App::DocumentObject*> claimChildren(void)const;
|
||||
|
||||
// returns the root node where the children gets collected(3D)
|
||||
virtual SoGroup* getChildRoot(void) const {return pcBodyChildren;}
|
||||
virtual std::vector<App::DocumentObject*> claimChildren3D(void)const;
|
||||
|
||||
virtual std::vector< std::string > getDisplayModes(void) const;
|
||||
virtual void setDisplayMode(const char* ModeName);
|
||||
virtual void setOverrideMode(const std::string& mode);
|
||||
|
||||
|
@ -89,9 +91,6 @@ protected:
|
|||
/// Set Feature viewprovider into visual body mode
|
||||
void setVisualBodyMode(bool bodymode);
|
||||
private:
|
||||
/// group used to store children collected by claimChildren3D() in the through (edit) mode.
|
||||
SoGroup *pcBodyChildren;
|
||||
|
||||
static const char* BodyModeEnum[];
|
||||
|
||||
boost::signals::connection connectChangedObjectApp;
|
||||
|
|
Loading…
Reference in New Issue
Block a user