Skip to content

Commit

Permalink
Merge branch 'main' into annotation_dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan authored Dec 11, 2023
2 parents f128ad2 + e3bb0af commit d2c14b9
Show file tree
Hide file tree
Showing 164 changed files with 6,764 additions and 2,105 deletions.
2 changes: 1 addition & 1 deletion src/App/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,7 @@ std::set<DocumentObject *> Application::getLinksTo(
} else {
std::set<Document*> docs;
for(auto o : obj->getInList()) {
if(o && o->getNameInDocument() && docs.insert(o->getDocument()).second) {
if(o && o->isAttachedToDocument() && docs.insert(o->getDocument()).second) {
o->getDocument()->getLinksTo(links,obj,options,maxCount);
if(maxCount && (int)links.size()>=maxCount)
break;
Expand Down
20 changes: 10 additions & 10 deletions src/App/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ void Document::exportObjects(const std::vector<App::DocumentObject*>& obj, std::

if(FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG)) {
for(auto o : obj) {
if(o && o->getNameInDocument()) {
if(o && o->isAttachedToDocument()) {
FC_LOG("exporting " << o->getFullName());
if (!o->getPropertyByName("_ObjectUUID")) {
auto prop = static_cast<PropertyUUID*>(o->addDynamicProperty(
Expand Down Expand Up @@ -1492,7 +1492,7 @@ Document::importObjects(Base::XMLReader& reader)

std::vector<App::DocumentObject*> objs = readObjects(reader);
for(auto o : objs) {
if(o && o->getNameInDocument()) {
if(o && o->isAttachedToDocument()) {
o->setStatus(App::ObjImporting,true);
FC_LOG("importing " << o->getFullName());
if (auto propUUID = Base::freecad_dynamic_cast<PropertyUUID>(
Expand All @@ -1519,7 +1519,7 @@ Document::importObjects(Base::XMLReader& reader)
signalFinishImportObjects(objs);

for(auto o : objs) {
if(o && o->getNameInDocument())
if(o && o->isAttachedToDocument())
o->setStatus(App::ObjImporting,false);
}

Expand Down Expand Up @@ -2424,7 +2424,7 @@ static void _buildDependencyList(const std::vector<App::DocumentObject*> &object
while(!objs.empty()) {
auto obj = objs.front();
objs.pop_front();
if(!obj || !obj->getNameInDocument())
if(!obj || !obj->isAttachedToDocument())
continue;

auto it = outLists.find(obj);
Expand All @@ -2451,7 +2451,7 @@ static void _buildDependencyList(const std::vector<App::DocumentObject*> &object
if(objectMap && depList) {
for (const auto &v : outLists) {
for(auto obj : v.second) {
if(obj && obj->getNameInDocument())
if(obj && obj->isAttachedToDocument())
add_edge((*objectMap)[v.first],(*objectMap)[obj],*depList);
}
}
Expand Down Expand Up @@ -2846,7 +2846,7 @@ int Document::recompute(const std::vector<App::DocumentObject*> &objs, bool forc
FC_LOG("Recompute pass " << passes);
for (; idx < topoSortedObjects.size(); ++idx) {
auto obj = topoSortedObjects[idx];
if(!obj->getNameInDocument() || filter.find(obj)!=filter.end())
if(!obj->isAttachedToDocument() || filter.find(obj)!=filter.end())
continue;
// ask the object if it should be recomputed
bool doRecompute = false;
Expand Down Expand Up @@ -2903,7 +2903,7 @@ int Document::recompute(const std::vector<App::DocumentObject*> &objs, bool forc
FC_TIME_LOG(t2, "Recompute");

for(auto obj : topoSortedObjects) {
if(!obj->getNameInDocument())
if(!obj->isAttachedToDocument())
continue;
obj->setStatus(ObjectStatus::PendingRecompute,false);
obj->setStatus(ObjectStatus::Recompute2,false);
Expand Down Expand Up @@ -3064,8 +3064,8 @@ std::vector<App::DocumentObject*> DocumentP::topologicalSort(const std::vector<A

for (auto objectIt : objects) {
// We now support externally linked objects
// if(!obj->getNameInDocument() || obj->getDocument()!=this)
if(!objectIt->getNameInDocument())
// if(!obj->isAttachedToDocument() || obj->getDocument()!=this)
if(!objectIt->isAttachedToDocument())
continue;
//we need inlist with unique entries
auto in = objectIt->getInList();
Expand Down Expand Up @@ -3179,7 +3179,7 @@ bool Document::recomputeFeature(DocumentObject* Feat, bool recursive)
d->clearRecomputeLog(Feat);

// verify that the feature is (active) part of the document
if (Feat->getNameInDocument()) {
if (Feat->isAttachedToDocument()) {
if(recursive) {
bool hasError = false;
recompute({Feat},true,&hasError);
Expand Down
22 changes: 11 additions & 11 deletions src/App/DocumentObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ const char* DocumentObject::getStatusString() const
}

std::string DocumentObject::getFullName() const {
if(!getDocument() || !pcNameInDocument)
if(!getDocument() || !isAttachedToDocument())
return "?";
std::string name(getDocument()->getName());
name += '#';
Expand Down Expand Up @@ -305,13 +305,13 @@ const char *DocumentObject::getNameInDocument() const
}

int DocumentObject::isExporting() const {
if(!getDocument() || !getNameInDocument())
if(!getDocument() || !isAttachedToDocument())
return 0;
return getDocument()->isExporting(this);
}

std::string DocumentObject::getExportName(bool forced) const {
if(!pcNameInDocument)
if(!isAttachedToDocument())
return {};

if(!forced && !isExporting())
Expand Down Expand Up @@ -441,7 +441,7 @@ void DocumentObject::getInListEx(std::set<App::DocumentObject*> &inSet,
// outLists first here.
for(auto doc : GetApplication().getDocuments()) {
for(auto obj : doc->getObjects()) {
if(!obj || !obj->getNameInDocument() || obj==this)
if(!obj || !obj->isAttachedToDocument() || obj==this)
continue;
const auto &outList = obj->getOutList();
outLists[obj].insert(outList.begin(),outList.end());
Expand Down Expand Up @@ -481,7 +481,7 @@ void DocumentObject::getInListEx(std::set<App::DocumentObject*> &inSet,
auto obj = pendings.top();
pendings.pop();
for(auto o : obj->getInList()) {
if(o && o->getNameInDocument() && inSet.insert(o).second) {
if(o && o->isAttachedToDocument() && inSet.insert(o).second) {
pendings.push(o);
if(inList)
inList->push_back(o);
Expand Down Expand Up @@ -839,7 +839,7 @@ std::vector<DocumentObject*> DocumentObject::getSubObjectList(const char *subnam
char c = sub[pos+1];
sub[pos+1] = 0;
auto sobj = getSubObject(sub.c_str());
if(!sobj || !sobj->getNameInDocument())
if(!sobj || !sobj->isAttachedToDocument())
break;
res.push_back(sobj);
sub[pos+1] = c;
Expand All @@ -859,14 +859,14 @@ std::vector<std::string> DocumentObject::getSubObjects(int reason) const {

std::vector<std::pair<App::DocumentObject *,std::string>> DocumentObject::getParents(int depth) const {
std::vector<std::pair<App::DocumentObject *, std::string>> ret;
if (!getNameInDocument() || !GetApplication().checkLinkDepth(depth, MessageOption::Throw)) {
if (!isAttachedToDocument() || !GetApplication().checkLinkDepth(depth, MessageOption::Throw)) {
return ret;
}

std::string name(getNameInDocument());
name += ".";
for (auto parent : getInList()) {
if (!parent || !parent->getNameInDocument()) {
if (!parent || !parent->isAttachedToDocument()) {
continue;
}

Expand Down Expand Up @@ -927,7 +927,7 @@ DocumentObject *DocumentObject::getLinkedObject(

void DocumentObject::Save (Base::Writer &writer) const
{
if (this->getNameInDocument())
if (this->isAttachedToDocument())
writer.ObjectName = this->getNameInDocument();
App::ExtensionContainer::Save(writer);
}
Expand Down Expand Up @@ -1164,7 +1164,7 @@ DocumentObject *DocumentObject::resolve(const char *subname,
DocumentObject *DocumentObject::resolveRelativeLink(std::string &subname,
DocumentObject *&link, std::string &linkSub) const
{
if(!link || !link->getNameInDocument() || !getNameInDocument())
if(!link || !link->isAttachedToDocument() || !isAttachedToDocument())
return nullptr;
auto ret = const_cast<DocumentObject*>(this);
if(link != ret) {
Expand Down Expand Up @@ -1268,6 +1268,6 @@ bool DocumentObject::redirectSubName(std::ostringstream &, DocumentObject *, Doc

void DocumentObject::onPropertyStatusChanged(const Property &prop, unsigned long oldStatus) {
(void)oldStatus;
if(!Document::isAnyRestoring() && getNameInDocument() && getDocument())
if(!Document::isAnyRestoring() && isAttachedToDocument() && getDocument())
getDocument()->signalChangePropertyEditor(*getDocument(),prop);
}
2 changes: 1 addition & 1 deletion src/App/DocumentObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ DocumentObjectT &DocumentObjectT::operator=(DocumentObjectT&& obj)

void DocumentObjectT::operator=(const DocumentObject* obj)
{
if(!obj || !obj->getNameInDocument()) {
if(!obj || !obj->isAttachedToDocument()) {
object.clear();
label.clear();
document.clear();
Expand Down
2 changes: 1 addition & 1 deletion src/App/FreeCADInit.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def tryProcessMetadataFile(MetadataFile):
Ntf = FreeCAD.Console.PrintNotification
Tnf = FreeCAD.Console.PrintTranslatedNotification

#store the cmake variales
#store the cmake variables
App.__cmake__ = cmake;

#store unit test names
Expand Down
2 changes: 1 addition & 1 deletion src/App/GeoFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ DocumentObject *GeoFeature::resolveElement(DocumentObject *obj, const char *subn
ElementNameType type, const DocumentObject *filter,
const char **_element, GeoFeature **geoFeature)
{
if(!obj || !obj->getNameInDocument())
if(!obj || !obj->isAttachedToDocument())
return nullptr;
if(!subname)
subname = "";
Expand Down
2 changes: 1 addition & 1 deletion src/App/GeoFeatureGroupExtension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ void GeoFeatureGroupExtension::getInvalidLinkObjects(const DocumentObject* obj,

bool GeoFeatureGroupExtension::extensionGetSubObjects(std::vector<std::string> &ret, int) const {
for(auto obj : Group.getValues()) {
if(obj && obj->getNameInDocument() && !obj->testStatus(ObjectStatus::GeoExcluded))
if(obj && obj->isAttachedToDocument() && !obj->testStatus(ObjectStatus::GeoExcluded))
ret.push_back(std::string(obj->getNameInDocument())+'.');
}
return true;
Expand Down
8 changes: 4 additions & 4 deletions src/App/GroupExtension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void GroupExtension::removeObjectsFromDocument()
void GroupExtension::removeObjectFromDocument(DocumentObject* obj)
{
// check that object is not invalid
if (!obj || !obj->getNameInDocument())
if (!obj || !obj->isAttachedToDocument())
return;

// remove all children
Expand Down Expand Up @@ -351,7 +351,7 @@ void GroupExtension::extensionOnChanged(const Property* p) {
if(p == &Group) {
_Conns.clear();
for(auto obj : Group.getValue()) {
if(obj && obj->getNameInDocument()) {
if(obj && obj->isAttachedToDocument()) {
//NOLINTBEGIN
_Conns[obj] = obj->signalChanged.connect(std::bind(
&GroupExtension::slotChildChanged,this,sp::_1, sp::_2));
Expand Down Expand Up @@ -398,7 +398,7 @@ bool GroupExtension::extensionGetSubObject(DocumentObject *&ret, const char *sub

bool GroupExtension::extensionGetSubObjects(std::vector<std::string> &ret, int) const {
for(auto obj : Group.getValues()) {
if(obj && obj->getNameInDocument())
if(obj && obj->isAttachedToDocument())
ret.push_back(std::string(obj->getNameInDocument())+'.');
}
return true;
Expand All @@ -421,7 +421,7 @@ void GroupExtension::getAllChildren(std::vector<App::DocumentObject*> &res,
std::set<App::DocumentObject*> &rset) const
{
for(auto obj : Group.getValues()) {
if(!obj || !obj->getNameInDocument())
if(!obj || !obj->isAttachedToDocument())
continue;
if(!rset.insert(obj).second)
continue;
Expand Down
6 changes: 3 additions & 3 deletions src/App/GroupExtensionPyImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ PyObject* GroupExtensionPy::addObject(PyObject *args)
return nullptr;

DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(object);
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->getNameInDocument()) {
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->isAttachedToDocument()) {
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot add an invalid object");
return nullptr;
}
Expand Down Expand Up @@ -174,7 +174,7 @@ PyObject* GroupExtensionPy::removeObject(PyObject *args)
return nullptr;

DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(object);
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->getNameInDocument()) {
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->isAttachedToDocument()) {
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot remove an invalid object");
return nullptr;
}
Expand Down Expand Up @@ -262,7 +262,7 @@ PyObject* GroupExtensionPy::hasObject(PyObject *args)

DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(object);
bool recursive = Base::asBoolean(recursivePy);
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->getNameInDocument()) {
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->isAttachedToDocument()) {
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check an invalid object");
return nullptr;
}
Expand Down
Loading

0 comments on commit d2c14b9

Please sign in to comment.