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