Skip to content

Commit

Permalink
Extensions: Fix rebase errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ickby authored and wwmayer committed Oct 8, 2016
1 parent 594bb4f commit 1287f30
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 29 deletions.
3 changes: 3 additions & 0 deletions src/App/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,11 +1137,14 @@ void Application::initTypes(void)

// Extension classes
App ::Extension ::init();
App ::ExtensionContainer ::init();
App ::DocumentObjectExtension ::init();
App ::GroupExtension ::init();
App ::GroupExtensionPython ::init();
App ::GeoFeatureGroupExtension ::init();
App ::GeoFeatureGroupExtensionPython::init();
App ::OriginGroupExtension ::init();
App ::OriginGroupExtensionPython::init();

// Document classes
App ::TransactionalObject ::init();
Expand Down
2 changes: 1 addition & 1 deletion src/App/DocumentObjectGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace App {
/// @cond DOXERR
PROPERTY_SOURCE_TEMPLATE(App::DocumentObjectGroupPython, App::DocumentObjectGroup)
template<> const char* App::DocumentObjectGroupPython::getViewProviderName(void) const {
return "Gui::ViewProviderGroupExtensionPython";
return "Gui::ViewProviderDocumentObjectGroupPython";
}
template<> PyObject* App::DocumentObjectGroupPython::getPyObject(void) {
if (PythonObject.is(Py::_None())) {
Expand Down
5 changes: 3 additions & 2 deletions src/App/PropertyFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ std::string PropertyFileIncluded::getDocTransientPath(void) const
{
std::string path;
PropertyContainer *co = getContainer();
if (co->isDerivedFrom(DocumentObject::getClassTypeId())) {
path = static_cast<DocumentObject*>(co)->getDocument()->TransientDir.getValue();
auto obj = dynamic_cast<DocumentObject*>(co);
if (obj) {
path = obj->getDocument()->TransientDir.getValue();
std::replace(path.begin(), path.end(), '\\', '/');
}
return path;
Expand Down
41 changes: 21 additions & 20 deletions src/Gui/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,27 +275,28 @@ FreeCADGui_subgraphFromObject(PyObject * /*self*/, PyObject *args)
SoNode* node = 0;
try {
Base::BaseClass* base = static_cast<Base::BaseClass*>(Base::Type::createInstanceByName(vp.c_str(), true));
if (base && base->getTypeId().isDerivedFrom(Gui::ViewProviderDocumentObject::getClassTypeId())) {
std::unique_ptr<Gui::ViewProviderDocumentObject> vp(static_cast<Gui::ViewProviderDocumentObject*>(base));
std::map<std::string, App::Property*> Map;
obj->getPropertyMap(Map);
vp->attach(obj);
for (std::map<std::string, App::Property*>::iterator it = Map.begin(); it != Map.end(); ++it) {
vp->updateData(it->second);
}

std::vector<std::string> modes = vp->getDisplayModes();
if (!modes.empty())
vp->setDisplayMode(modes.front().c_str());
node = vp->getRoot()->copy();
node->ref();
std::string type = "So";
type += node->getTypeId().getName().getString();
type += " *";
PyObject* proxy = 0;
proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", type.c_str(), (void*)node, 1);
return Py::new_reference_to(Py::Object(proxy, true));
//throws if dynamic_cast fails, hence no check needed
std::unique_ptr<Gui::ViewProviderDocumentObject> vp(dynamic_cast<Gui::ViewProviderDocumentObject*>(base));

std::map<std::string, App::Property*> Map;
obj->getPropertyMap(Map);
vp->attach(obj);
for (std::map<std::string, App::Property*>::iterator it = Map.begin(); it != Map.end(); ++it) {
vp->updateData(it->second);
}

std::vector<std::string> modes = vp->getDisplayModes();
if (!modes.empty())
vp->setDisplayMode(modes.front().c_str());
node = vp->getRoot()->copy();
node->ref();
std::string type = "So";
type += node->getTypeId().getName().getString();
type += " *";
PyObject* proxy = 0;
proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", type.c_str(), (void*)node, 1);
return Py::new_reference_to(Py::Object(proxy, true));

}
catch (const Base::Exception& e) {
if (node) node->unref();
Expand Down
5 changes: 3 additions & 2 deletions src/Gui/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,10 @@ void Document::slotNewObject(const App::DocumentObject& Obj)
setModified(true);
Base::BaseClass* base = static_cast<Base::BaseClass*>(Base::Type::createInstanceByName(cName.c_str(),true));
if (base) {
pcProvider = dynamic_cast<ViewProviderDocumentObject*>(base);
// type not derived from ViewProviderDocumentObject!!!
assert(base->getTypeId().isDerivedFrom(Gui::ViewProviderDocumentObject::getClassTypeId()));
pcProvider = static_cast<ViewProviderDocumentObject*>(base);
assert(pcProvider);

d->_ViewProviderMap[&Obj] = pcProvider;

try {
Expand Down
5 changes: 3 additions & 2 deletions src/Gui/TreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ void TreeView::mouseDoubleClickEvent (QMouseEvent * event)
if (!view) return;
getMainWindow()->setActiveWindow(view);
}
else if (item->getTypeId().isDerivedFrom(ViewProvider::getClassTypeId())) {
if (static_cast<ViewProvider*>(item)->doubleClicked() == false)
else {
auto* vp = dynamic_cast<ViewProvider*>(item);
if (vp && vp->doubleClicked() == false)
QTreeView::mouseDoubleClickEvent(event);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/Gui/propertyeditor/PropertyItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,9 @@ QString PropertyItem::pythonIdentifier(const App::Property* prop) const
return QString::fromLatin1("FreeCAD.getDocument(\"%1\").getObject(\"%2\").%3")
.arg(docName).arg(objName).arg(propName);
}
if (parent->getTypeId().isDerivedFrom(Gui::ViewProviderDocumentObject::getClassTypeId())) {
App::DocumentObject* obj = static_cast<Gui::ViewProviderDocumentObject*>(parent)->getObject();
auto* vp = dynamic_cast<Gui::ViewProviderDocumentObject*>(parent);
if (vp) {
App::DocumentObject* obj = vp->getObject();
App::Document* doc = obj->getDocument();
QString docName = QString::fromLatin1(App::GetApplication().getDocumentName(doc));
QString objName = QString::fromLatin1(obj->getNameInDocument());
Expand Down

0 comments on commit 1287f30

Please sign in to comment.