25
#include "PreCompiled.h"
28
#include <Inventor/nodes/SoSeparator.h>
31
#include <App/DocumentObject.h>
32
#include <App/GeoFeatureGroupExtension.h>
34
#include "ViewProviderGeoFeatureGroupExtension.h"
35
#include "ViewProviderDocumentObject.h"
36
#include "Application.h"
37
#include "SoFCUnifiedSelection.h"
42
EXTENSION_PROPERTY_SOURCE(Gui::ViewProviderGeoFeatureGroupExtension, Gui::ViewProviderGroupExtension)
44
ViewProviderGeoFeatureGroupExtension::ViewProviderGeoFeatureGroupExtension()
46
initExtensionType(ViewProviderGeoFeatureGroupExtension::getExtensionClassTypeId());
48
pcGroupChildren = new SoFCSelectionRoot;
49
pcGroupChildren->ref();
50
pcGroupFront = new SoSeparator();
52
pcGroupBack = new SoSeparator();
56
ViewProviderGeoFeatureGroupExtension::~ViewProviderGeoFeatureGroupExtension()
58
pcGroupChildren->unref();
59
pcGroupChildren = nullptr;
60
pcGroupFront->unref();
61
pcGroupFront = nullptr;
63
pcGroupBack = nullptr;
67
std::vector<App::DocumentObject*> ViewProviderGeoFeatureGroupExtension::extensionClaimChildren3D() const {
70
auto* ext = getExtendedViewProvider()->getObject()->getExtensionByType<App::GeoFeatureGroupExtension>();
72
auto objs = ext->Group.getValues();
78
std::vector<App::DocumentObject*> ViewProviderGeoFeatureGroupExtension::extensionClaimChildren() const {
80
auto* group = getExtendedViewProvider()->getObject()->getExtensionByType<App::GeoFeatureGroupExtension>();
81
const std::vector<App::DocumentObject*> &model = group->Group.getValues ();
82
std::set<App::DocumentObject*> outSet;
85
for (auto obj: model) {
87
if (!obj || obj->hasExtension(App::GeoFeatureGroupExtension::getExtensionClassTypeId())) { continue; }
89
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider ( obj );
90
if (!vp || vp == getExtendedViewProvider()) { continue; }
92
auto children = vp->claimChildren();
93
std::remove_copy ( children.begin (), children.end (), std::inserter (outSet, outSet.begin () ), nullptr);
97
std::vector<App::DocumentObject*> Result;
98
for(auto obj : model) {
99
if(!obj || !obj->isAttachedToDocument())
101
if(outSet.count(obj))
102
obj->setStatus(App::ObjectStatus::GeoExcluded,true);
104
obj->setStatus(App::ObjectStatus::GeoExcluded,false);
105
Result.push_back(obj);
111
void ViewProviderGeoFeatureGroupExtension::extensionFinishRestoring()
114
extensionClaimChildren();
115
ViewProviderGroupExtension::extensionFinishRestoring();
118
void ViewProviderGeoFeatureGroupExtension::extensionAttach(App::DocumentObject* pcObject)
120
ViewProviderGroupExtension::extensionAttach(pcObject);
121
getExtendedViewProvider()->addDisplayMaskMode(pcGroupChildren, "Group");
124
void ViewProviderGeoFeatureGroupExtension::extensionSetDisplayMode(const char* ModeName)
126
if ( strcmp("Group",ModeName)==0 )
127
getExtendedViewProvider()->setDisplayMaskMode("Group");
129
ViewProviderGroupExtension::extensionSetDisplayMode( ModeName );
132
std::vector<std::string> ViewProviderGeoFeatureGroupExtension::extensionGetDisplayModes() const
135
std::vector<std::string> StrList = ViewProviderGroupExtension::extensionGetDisplayModes();
138
StrList.emplace_back("Group");
143
void ViewProviderGeoFeatureGroupExtension::extensionUpdateData(const App::Property* prop)
145
auto obj = getExtendedViewProvider()->getObject()->getExtensionByType<App::GeoFeatureGroupExtension>();
146
if (obj && prop == &obj->placement()) {
147
getExtendedViewProvider()->setTransformation ( obj->placement().getValue().toMatrix() );
150
ViewProviderGroupExtension::extensionUpdateData ( prop );
155
EXTENSION_PROPERTY_SOURCE_TEMPLATE(Gui::ViewProviderGeoFeatureGroupExtensionPython, Gui::ViewProviderGeoFeatureGroupExtension)
158
template class GuiExport ViewProviderExtensionPythonT<ViewProviderGeoFeatureGroupExtension>;