MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / updateData

Method updateData

src/Gui/ViewProviderVRMLObject.cpp:213–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211}
212
213void ViewProviderVRMLObject::updateData(const App::Property* prop)
214{
215 auto ivObj = static_cast<App::VRMLObject*>(pcObject);
216 if (prop == &ivObj->VrmlFile) {
217 // read also from file
218 const char* filename = ivObj->VrmlFile.getValue();
219 QString fn = QString::fromUtf8(filename);
220 QFile file(fn);
221 SoInput in;
222 coinRemoveAllChildren(pcVRML);
223 if (!fn.isEmpty() && file.open(QFile::ReadOnly)) {
224 QFileInfo fi(fn);
225 QByteArray filepath = fi.absolutePath().toUtf8();
226 QByteArray subpath = filepath + "/" + ivObj->getNameInDocument();
227
228 // Add this to the search path in order to read inline files
229 SoInput::addDirectoryFirst(filepath.constData());
230 SoInput::addDirectoryFirst(subpath.constData());
231
232 // Read in the file
233 QByteArray buffer = file.readAll();
234 in.setBuffer((void*)buffer.constData(), buffer.length());
235 SoSeparator* node = SoDB::readAll(&in);
236
237 if (node) {
238 if (!checkRecursion(node)) {
239 Base::Console().error("The VRML file causes an infinite recursion!\n");
240 return;
241 }
242 pcVRML->addChild(node);
243
244 std::list<std::string> urls;
245 getLocalResources(node, urls);
246 if (!urls.empty() && ivObj->Urls.getSize() == 0) {
247 std::vector<std::string> res;
248 res.insert(res.end(), urls.begin(), urls.end());
249 ivObj->Urls.setValues(res);
250 }
251 }
252 SoInput::removeDirectory(filepath.constData());
253 SoInput::removeDirectory(subpath.constData());
254 }
255 }
256 else if (
257 prop->isDerivedFrom<App::PropertyPlacement>() && strcmp(prop->getName(), "Placement") == 0
258 ) {
259 // Note: If R is the rotation, c the rotation center and t the translation
260 // vector then Inventor applies the following transformation: R*(x-c)+c+t
261 // In FreeCAD a placement only has a rotation and a translation part but
262 // no rotation center. This means that the following equation must be ful-
263 // filled: R * (x-c) + c + t = R * x + t
264 // <==> R * x + t - R * c + c = R * x + t
265 // <==> (I-R) * c = 0 ==> c = 0
266 // This means that the center point must be the origin!
267 Base::Placement p = static_cast<const App::PropertyPlacement*>(prop)->getValue();
268 auto q0 = (float)p.getRotation().getValue()[0];
269 auto q1 = (float)p.getRotation().getValue()[1];
270 auto q2 = (float)p.getRotation().getValue()[2];

Callers

nothing calls this directly

Calls 15

coinRemoveAllChildrenFunction · 0.85
constDataMethod · 0.80
setBufferMethod · 0.80
getValueMethod · 0.45
isEmptyMethod · 0.45
openMethod · 0.45
getNameInDocumentMethod · 0.45
lengthMethod · 0.45
errorMethod · 0.45
addChildMethod · 0.45
emptyMethod · 0.45
getSizeMethod · 0.45

Tested by

no test coverage detected