Toponaming: Remove all FC_USE_TNP_FIX protected old code
This commit is contained in:
@@ -555,14 +555,7 @@ void ComplexGeoDataPy::setPlacement(Py::Object arg)
|
||||
|
||||
Py::String ComplexGeoDataPy::getElementMapVersion() const
|
||||
{
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
return Py::String(getComplexGeoDataPtr()->getElementMapVersion());
|
||||
#else
|
||||
// This is to allow python level tests visibility into whether element maps are in use, so that
|
||||
// expectations can be adjusted. Eventually this ifdef and clause should be removed, and at the
|
||||
// same time all python tests checking for ElementMapVersion != '' should also be removed.
|
||||
return Py::String();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -89,11 +89,6 @@ GeoFeature::getElementName(const char *name, ElementNameType type) const
|
||||
if(!name)
|
||||
return {};
|
||||
|
||||
#ifndef FC_USE_TNP_FIX
|
||||
ret.oldName = name;
|
||||
|
||||
return ret;
|
||||
#else
|
||||
auto prop = getPropertyOfGeometry();
|
||||
if (!prop) {
|
||||
return ElementNamePair("",name);
|
||||
@@ -105,7 +100,6 @@ GeoFeature::getElementName(const char *name, ElementNameType type) const
|
||||
}
|
||||
|
||||
return _getElementName(name, geo->getElementName(name));
|
||||
#endif
|
||||
}
|
||||
|
||||
ElementNamePair
|
||||
@@ -143,17 +137,14 @@ DocumentObject *GeoFeature::resolveElement(DocumentObject *obj, const char *subn
|
||||
ElementNameType type, const DocumentObject *filter,
|
||||
const char **_element, GeoFeature **geoFeature)
|
||||
{
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
elementName.newName.clear();
|
||||
elementName.oldName.clear();
|
||||
#endif
|
||||
if(!obj || !obj->isAttachedToDocument())
|
||||
return nullptr;
|
||||
if(!subname)
|
||||
subname = "";
|
||||
const char *element = Data::findElementName(subname);
|
||||
if(_element) *_element = element;
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
auto sobj = obj->getSubObject(std::string(subname, element).c_str());
|
||||
if(!sobj)
|
||||
return nullptr;
|
||||
@@ -164,13 +155,6 @@ DocumentObject *GeoFeature::resolveElement(DocumentObject *obj, const char *subn
|
||||
if(ext)
|
||||
geo = Base::freecad_dynamic_cast<GeoFeature>(ext->getTrueLinkedObject(true));
|
||||
}
|
||||
#else
|
||||
auto sobj = obj->getSubObject(subname);
|
||||
if(!sobj)
|
||||
return nullptr;
|
||||
obj = sobj->getLinkedObject(true);
|
||||
auto geo = dynamic_cast<GeoFeature*>(obj);
|
||||
#endif
|
||||
if(geoFeature)
|
||||
*geoFeature = geo;
|
||||
if(!obj || (filter && obj!=filter))
|
||||
@@ -217,7 +201,6 @@ bool GeoFeature::getCameraAlignmentDirection(Base::Vector3d& direction, const ch
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
bool GeoFeature::hasMissingElement(const char* subname)
|
||||
{
|
||||
return Data::hasMissingElement(subname);
|
||||
@@ -287,5 +270,3 @@ GeoFeature::getHigherElements(const char *element, bool silent) const
|
||||
return {};
|
||||
return prop->getComplexData()->getHigherElements(element, silent);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -148,7 +148,6 @@ public:
|
||||
* @return bool whether or not a direction is found.
|
||||
*/
|
||||
virtual bool getCameraAlignmentDirection(Base::Vector3d& direction, const char* subname = nullptr) const;
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
/** Search sub element using internal cached geometry
|
||||
*
|
||||
* @param element: element name
|
||||
@@ -184,8 +183,6 @@ protected:
|
||||
void onChanged(const Property* prop) override;
|
||||
// void onDocumentRestored() override;
|
||||
void updateElementReference();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
ElementNamePair _getElementName(const char* name,
|
||||
const Data::MappedElement& mapped) const;
|
||||
|
||||
@@ -111,7 +111,6 @@ bool PropertyLinkBase::isSame(const Property &other) const
|
||||
}
|
||||
|
||||
void PropertyLinkBase::unregisterElementReference() {
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
for (auto obj : _ElementRefs) {
|
||||
auto it = _ElementRefMap.find(obj);
|
||||
if (it != _ElementRefMap.end()) {
|
||||
@@ -122,7 +121,6 @@ void PropertyLinkBase::unregisterElementReference() {
|
||||
}
|
||||
}
|
||||
_ElementRefs.clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
void PropertyLinkBase::unregisterLabelReferences()
|
||||
@@ -241,7 +239,6 @@ PropertyLinkBase::getElementReferences(DocumentObject* feature)
|
||||
}
|
||||
|
||||
void PropertyLinkBase::updateElementReferences(DocumentObject *feature, bool reverse) {
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
if (!feature || !feature->getNameInDocument()) {
|
||||
return;
|
||||
}
|
||||
@@ -267,15 +264,10 @@ void PropertyLinkBase::updateElementReferences(DocumentObject *feature, bool rev
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void)feature;
|
||||
(void)reverse;
|
||||
#endif
|
||||
}
|
||||
|
||||
void PropertyLinkBase::_registerElementReference(App::DocumentObject *obj, std::string &sub, ShadowSub &shadow)
|
||||
{
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
if (!obj || !obj->getNameInDocument() || sub.empty()) {
|
||||
return;
|
||||
}
|
||||
@@ -301,11 +293,6 @@ void PropertyLinkBase::_registerElementReference(App::DocumentObject *obj, std::
|
||||
if (_ElementRefs.insert(geo).second) {
|
||||
_ElementRefMap[geo].insert(this);
|
||||
}
|
||||
#else
|
||||
(void)obj;
|
||||
(void)sub;
|
||||
(void)shadow;
|
||||
#endif
|
||||
}
|
||||
|
||||
class StringGuard {
|
||||
@@ -370,7 +357,6 @@ bool PropertyLinkBase::_updateElementReference(DocumentObject *feature,
|
||||
App::DocumentObject *obj, std::string &sub, ShadowSub &shadow,
|
||||
bool reverse, bool notify)
|
||||
{
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
if (!obj || !obj->getNameInDocument()) {
|
||||
return false;
|
||||
}
|
||||
@@ -512,14 +498,6 @@ bool PropertyLinkBase::_updateElementReference(DocumentObject *feature,
|
||||
updateSub(shadow.oldName);
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
(void)feature;
|
||||
(void)obj;
|
||||
(void)reverse;
|
||||
(void)notify;
|
||||
shadow.oldName = sub;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::pair<DocumentObject*, std::string>
|
||||
@@ -545,14 +523,12 @@ PropertyLinkBase::tryReplaceLink(const PropertyContainer* owner,
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
}
|
||||
else if (newObj == obj) {
|
||||
// This means the new object is already sub-object of this parent
|
||||
// (consider a case of swapping the tool and base object of the Cut
|
||||
// feature). We'll swap the old and new object.
|
||||
return tryReplaceLink(owner, obj, parent, newObj, oldObj, subname);
|
||||
#endif
|
||||
}
|
||||
if (!subname || !subname[0]) {
|
||||
return res;
|
||||
@@ -586,11 +562,9 @@ PropertyLinkBase::tryReplaceLink(const PropertyContainer* owner,
|
||||
return res;
|
||||
}
|
||||
break;
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
}
|
||||
else if (sobj == newObj) {
|
||||
return tryReplaceLink(owner, obj, parent, newObj, oldObj, subname);
|
||||
#endif
|
||||
}
|
||||
else if (prev == parent) {
|
||||
break;
|
||||
@@ -1291,7 +1265,6 @@ static inline const std::string &getSubNameWithStyle(const std::string &subName,
|
||||
if(!shadow.oldName.empty())
|
||||
return shadow.oldName;
|
||||
}else if(!shadow.newName.empty()) {
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
if (Data::hasMissingElement(shadow.oldName.c_str())) {
|
||||
auto pos = shadow.newName.rfind('.');
|
||||
if (pos != std::string::npos) {
|
||||
@@ -1300,9 +1273,6 @@ static inline const std::string &getSubNameWithStyle(const std::string &subName,
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void) tmp;
|
||||
#endif
|
||||
return shadow.newName;
|
||||
}
|
||||
return subName;
|
||||
@@ -1320,7 +1290,6 @@ std::vector<std::string> PropertyLinkSub::getSubValues(bool newStyle) const {
|
||||
|
||||
std::vector<std::string> PropertyLinkSub::getSubValuesStartsWith(const char* starter, bool newStyle) const
|
||||
{
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
assert(_cSubList.size() == _ShadowSubList.size());
|
||||
std::vector<std::string> ret;
|
||||
std::string tmp;
|
||||
@@ -1331,18 +1300,6 @@ std::vector<std::string> PropertyLinkSub::getSubValuesStartsWith(const char* sta
|
||||
ret.emplace_back(element);
|
||||
}
|
||||
return ret;
|
||||
|
||||
#else
|
||||
(void)newStyle;
|
||||
|
||||
std::vector<std::string> temp;
|
||||
for(const auto & it : _cSubList) {
|
||||
if(strncmp(starter, it.c_str(), strlen(starter)) == 0) {
|
||||
temp.push_back(it);
|
||||
}
|
||||
}
|
||||
return temp;
|
||||
#endif
|
||||
}
|
||||
|
||||
App::DocumentObject * PropertyLinkSub::getValue(Base::Type t) const
|
||||
@@ -1356,14 +1313,9 @@ PyObject *PropertyLinkSub::getPyObject()
|
||||
Py::List list(static_cast<int>(_cSubList.size()));
|
||||
if (_pcLinkSub) {
|
||||
tup[0] = Py::asObject(_pcLinkSub->getPyObject());
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
int i = 0;
|
||||
for (auto &sub : getSubValues(testFlag(LinkNewElement)))
|
||||
list[i++] = Py::String(sub);
|
||||
#else
|
||||
for(unsigned int i = 0;i<_cSubList.size(); i++)
|
||||
list[i] = Py::String(_cSubList[i]);
|
||||
#endif
|
||||
tup[1] = list;
|
||||
return Py::new_reference_to(tup);
|
||||
}
|
||||
@@ -1692,12 +1644,7 @@ void PropertyLinkBase::_getLinksTo(std::vector<App::ObjectIdentifier>& identifie
|
||||
#define ATTR_SHADOW "shadow"
|
||||
#define ATTR_MAPPED "mapped"
|
||||
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
#define IGNORE_SHADOW false
|
||||
#else
|
||||
// We do not have topo naming yet, ignore shadow sub for now
|
||||
#define IGNORE_SHADOW true
|
||||
#endif
|
||||
|
||||
void PropertyLinkSub::Save (Base::Writer &writer) const
|
||||
{
|
||||
@@ -1885,9 +1832,7 @@ Property *PropertyLinkSub::Copy() const
|
||||
PropertyLinkSub *p= new PropertyLinkSub();
|
||||
p->_pcLinkSub = _pcLinkSub;
|
||||
p->_cSubList = _cSubList;
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
p->_ShadowSubList = _ShadowSubList;
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -1896,12 +1841,8 @@ void PropertyLinkSub::Paste(const Property &from)
|
||||
if(!from.isDerivedFrom(PropertyLinkSub::getClassTypeId()))
|
||||
throw Base::TypeError("Incompatible property to paste to");
|
||||
auto &link = static_cast<const PropertyLinkSub&>(from);
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
setValue(link._pcLinkSub, link._cSubList,
|
||||
std::vector<ShadowSub>(link._ShadowSubList));
|
||||
#else
|
||||
setValue(link._pcLinkSub, link._cSubList);
|
||||
#endif
|
||||
}
|
||||
|
||||
void PropertyLinkSub::getLinks(std::vector<App::DocumentObject *> &objs,
|
||||
@@ -2360,7 +2301,6 @@ void PropertyLinkSubList::setSubListValues(const std::vector<PropertyLinkSubList
|
||||
{
|
||||
std::vector<DocumentObject*> links;
|
||||
std::vector<std::string> subs;
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
for (std::vector<PropertyLinkSubList::SubSet>::const_iterator it = values.begin(); it != values.end(); ++it) {
|
||||
if (it->second.empty()) {
|
||||
links.push_back(it->first);
|
||||
@@ -2372,14 +2312,6 @@ void PropertyLinkSubList::setSubListValues(const std::vector<PropertyLinkSubList
|
||||
subs.push_back(*jt);
|
||||
}
|
||||
}
|
||||
#else
|
||||
for (const auto & value : values) {
|
||||
for (const auto& jt : value.second) {
|
||||
links.push_back(value.first);
|
||||
subs.push_back(jt);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
setValues(links, subs);
|
||||
}
|
||||
|
||||
@@ -2844,9 +2776,7 @@ Property *PropertyLinkSubList::Copy() const
|
||||
PropertyLinkSubList *p = new PropertyLinkSubList();
|
||||
p->_lValueList = _lValueList;
|
||||
p->_lSubList = _lSubList;
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
p->_ShadowSubList = _ShadowSubList;
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -2855,12 +2785,8 @@ void PropertyLinkSubList::Paste(const Property &from)
|
||||
if(!from.isDerivedFrom(PropertyLinkSubList::getClassTypeId()))
|
||||
throw Base::TypeError("Incompatible property to paste to");
|
||||
auto &link = static_cast<const PropertyLinkSubList&>(from);
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
setValues(link._lValueList, link._lSubList,
|
||||
std::vector<ShadowSub>(link._ShadowSubList));
|
||||
#else
|
||||
setValues(link._lValueList, link._lSubList);
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned int PropertyLinkSubList::getMemSize () const
|
||||
@@ -3480,9 +3406,7 @@ void PropertyXLink::setSubValues(std::vector<std::string> &&subs,
|
||||
_ShadowSubList.clear();
|
||||
if(shadows.size() == _SubList.size()) {
|
||||
_ShadowSubList = std::move(shadows);
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
onContainerRestored(); // re-register element references
|
||||
#endif
|
||||
} else
|
||||
updateElementReference(nullptr);
|
||||
checkLabelReferences(_SubList);
|
||||
@@ -3990,9 +3914,7 @@ void PropertyXLink::copyTo(PropertyXLink &other,
|
||||
other._SubList = std::move(*subs);
|
||||
else {
|
||||
other._SubList = _SubList;
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
other._ShadowSubList = _ShadowSubList;
|
||||
#endif
|
||||
}
|
||||
other._Flags = _Flags;
|
||||
}
|
||||
@@ -4021,19 +3943,12 @@ void PropertyXLink::Paste(const Property &from)
|
||||
FC_WARN("Object '" << other.docName << '#' << other.objectName << "' not found");
|
||||
return;
|
||||
}
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
setValue(obj,std::vector<std::string>(other._SubList),
|
||||
std::vector<ShadowSub>(other._ShadowSubList));
|
||||
} else
|
||||
setValue(std::string(other.filePath),std::string(other.objectName),
|
||||
std::vector<std::string>(other._SubList),
|
||||
std::vector<ShadowSub>(other._ShadowSubList));
|
||||
#else
|
||||
setValue(obj,std::vector<std::string>(other._SubList));
|
||||
} else
|
||||
setValue(std::string(other.filePath),std::string(other.objectName),
|
||||
std::vector<std::string>(other._SubList));
|
||||
#endif
|
||||
setFlag(LinkAllowPartial,other.testFlag(LinkAllowPartial));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user