+ fixes #0002029: VRML inline ignored
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
# include <qfileinfo.h>
|
||||
# include <qdir.h>
|
||||
# include <QPrinter>
|
||||
# include <QFileInfo>
|
||||
# include <Inventor/SoInput.h>
|
||||
#endif
|
||||
|
||||
#include <xercesc/util/XMLString.hpp>
|
||||
@@ -268,6 +270,11 @@ PyObject* Application::sOpen(PyObject * /*self*/, PyObject *args,PyObject * /*kw
|
||||
ext == QLatin1String("wrz")) {
|
||||
if (!Application::Instance->activeDocument())
|
||||
App::GetApplication().newDocument();
|
||||
|
||||
// Add this to the search path in order to read inline files (#0002029)
|
||||
QByteArray path = fi.absolutePath().toUtf8();
|
||||
SoInput::addDirectoryFirst(path.constData());
|
||||
|
||||
//QString cmd = QString("Gui.activeDocument().addAnnotation(\"%1\",\"%2\")").arg(fi.baseName()).arg(fi.absoluteFilePath());
|
||||
QString cmd = QString::fromLatin1(
|
||||
"App.ActiveDocument.addObject(\"App::VRMLObject\",\"%1\")."
|
||||
@@ -276,6 +283,7 @@ PyObject* Application::sOpen(PyObject * /*self*/, PyObject *args,PyObject * /*kw
|
||||
"App.ActiveDocument.recompute()")
|
||||
.arg(fi.baseName()).arg(fi.absoluteFilePath());
|
||||
Base::Interpreter().runString(cmd.toUtf8());
|
||||
SoInput::removeDirectory(path.constData());
|
||||
}
|
||||
else if (ext == QLatin1String("py") || ext == QLatin1String("fcmacro") ||
|
||||
ext == QLatin1String("fcscript")) {
|
||||
@@ -335,12 +343,18 @@ PyObject* Application::sInsert(PyObject * /*self*/, PyObject *args,PyObject * /*
|
||||
if (!doc)
|
||||
doc = App::GetApplication().newDocument(DocName);
|
||||
|
||||
// Add this to the search path in order to read inline files (#0002029)
|
||||
QByteArray path = fi.absolutePath().toUtf8();
|
||||
SoInput::addDirectoryFirst(path.constData());
|
||||
|
||||
App::DocumentObject* obj = doc->addObject("App::VRMLObject",
|
||||
(const char*)fi.baseName().toUtf8());
|
||||
obj->Label.setValue((const char*)fi.baseName().toUtf8());
|
||||
static_cast<App::PropertyFileIncluded*>(obj->getPropertyByName("VrmlFile"))
|
||||
->setValue((const char*)fi.absoluteFilePath().toUtf8());
|
||||
doc->recompute();
|
||||
|
||||
SoInput::removeDirectory(path.constData());
|
||||
}
|
||||
else if (ext == QLatin1String("py") || ext == QLatin1String("fcmacro") ||
|
||||
ext == QLatin1String("fcscript")) {
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
# include <Inventor/nodes/SoSeparator.h>
|
||||
# include <Inventor/nodes/SoTransform.h>
|
||||
# include <QFile>
|
||||
# include <QFileInfo>
|
||||
#endif
|
||||
|
||||
#include "ViewProviderVRMLObject.h"
|
||||
@@ -91,10 +92,15 @@ void ViewProviderVRMLObject::updateData(const App::Property* prop)
|
||||
SoInput in;
|
||||
pcVRML->removeAllChildren();
|
||||
if (!fn.isEmpty() && file.open(QFile::ReadOnly)) {
|
||||
QFileInfo fi(fn);
|
||||
QByteArray path = fi.absolutePath().toUtf8();
|
||||
// Add this to the search path in order to read inline files
|
||||
SoInput::addDirectoryFirst(path.constData());
|
||||
QByteArray buffer = file.readAll();
|
||||
in.setBuffer((void *)buffer.constData(), buffer.length());
|
||||
SoSeparator * node = SoDB::readAll(&in);
|
||||
if (node) pcVRML->addChild(node);
|
||||
SoInput::removeDirectory(path.constData());
|
||||
}
|
||||
}
|
||||
else if (prop->isDerivedFrom(App::PropertyPlacement::getClassTypeId()) &&
|
||||
|
||||
Reference in New Issue
Block a user