void ProxyObject::setParent(const ProxyObjectPtr &parent, TemporalValue<Location>::Time timeStamp, const Location &absLocation, const Location &relLocation) { if (!parent) { unsetParent(timeStamp, absLocation); return; } ProxyObjectPtr oldParent (getParentProxy()); if (oldParent) { oldParent->ProxyObjectProvider::removeListener(this); } parent->ProxyObjectProvider::addListener(this); // Using now() should best allow a linear extrapolation to work. Location lastPosition(globalLocation(timeStamp)); mParentId = parent->getObjectReference(); Location newparentLastGlobal(parent->globalLocation(timeStamp)); /* std::cout<<" Last parent global "<<std::endl<<newparentLastGlobal<<std::endl<< "global loc = "<<std::endl<<lastPosition<< std::endl<<"local loc = "<<std::endl<<lastPosition.toLocal(newparentLastGlobal)<<std::endl; */ mLocation.resetValue(timeStamp, lastPosition.toLocal(newparentLastGlobal)); mLocation.updateValue(timeStamp, relLocation); PositionProvider::notify(&PositionListener::setParent, parent, timeStamp, absLocation, relLocation); }
void Picture::Remove (Iterator& i) { UList* doomed = Elem(i); Graphic* g = graphic(doomed); Next(i); unsetParent(g); _kids->Remove(doomed); delete doomed; uncacheExtent(); uncacheParents(); }
void ProxyObject::setParent(const ProxyObjectPtr &parent, TemporalValue<Location>::Time timeStamp) { if (!parent) { unsetParent(timeStamp); return; } Location globalParent (parent->globalLocation(timeStamp)); Location globalLoc (globalLocation(timeStamp)); // std::cout << "Extrapolated = "<<extrapolateLocation(timeStamp)<<std::endl; Location localLoc (globalLoc.toLocal(globalParent)); /* std::cout<<" Setting parent "<<std::endl<<globalParent<<std::endl<< "global loc = "<<std::endl<<globalLoc<< std::endl<<"local loc = "<<std::endl<<localLoc<<std::endl; */ setParent(parent, timeStamp, globalLoc, localLoc); }
void Picture::Remove (Graphic* g) { unsetParent(g); _kids->Delete(g); uncacheExtent(); uncacheParents(); }
// protected: // Notification that the Parent has been destroyed void ProxyObject::destroyed() { unsetParent(TemporalValue<Location>::Time::now()); }
void ProxyObject::unsetParent(TemporalValue<Location>::Time timeStamp) { unsetParent(timeStamp, globalLocation(timeStamp)); }