App: Apply clang format (part 2)

This commit is contained in:
wmayer
2024-11-21 12:27:35 +01:00
committed by wwmayer
parent 164f1e3813
commit fadfc7e270
44 changed files with 12163 additions and 8775 deletions

View File

@@ -47,12 +47,12 @@ PROPERTY_SOURCE(App::GeoFeature, App::DocumentObject)
GeoFeature::GeoFeature()
{
ADD_PROPERTY_TYPE(Placement,(Base::Placement()),nullptr,Prop_NoRecompute,nullptr);
ADD_PROPERTY_TYPE(Placement, (Base::Placement()), nullptr, Prop_NoRecompute, nullptr);
}
GeoFeature::~GeoFeature() = default;
void GeoFeature::transformPlacement(const Base::Placement &transform)
void GeoFeature::transformPlacement(const Base::Placement& transform)
{
Base::Placement plm = this->Placement.getValue();
plm = transform * plm;
@@ -66,7 +66,7 @@ Base::Placement GeoFeature::globalPlacement() const
auto ext = group->getExtensionByType<GeoFeatureGroupExtension>();
return ext->globalGroupPlacement() * Placement.getValue();
}
return Placement.getValue();
return Placement.getValue();
}
const PropertyComplexGeoData* GeoFeature::getPropertyOfGeometry() const
@@ -78,22 +78,22 @@ PyObject* GeoFeature::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new GeoFeaturePy(this),true);
PythonObject = Py::Object(new GeoFeaturePy(this), true);
}
return Py::new_reference_to(PythonObject);
}
ElementNamePair
GeoFeature::getElementName(const char *name, ElementNameType type) const
ElementNamePair GeoFeature::getElementName(const char* name, ElementNameType type) const
{
(void)type;
if(!name)
if (!name) {
return {};
}
auto prop = getPropertyOfGeometry();
if (!prop) {
return ElementNamePair("",name);
return ElementNamePair("", name);
}
auto geo = prop->getComplexData();
@@ -104,8 +104,8 @@ GeoFeature::getElementName(const char *name, ElementNameType type) const
return _getElementName(name, geo->getElementName(name));
}
ElementNamePair
GeoFeature::_getElementName(const char* name, const Data::MappedElement& mapped) const
ElementNamePair GeoFeature::_getElementName(const char* name,
const Data::MappedElement& mapped) const
{
ElementNamePair ret;
if (mapped.index && mapped.name) {
@@ -123,9 +123,9 @@ GeoFeature::_getElementName(const char* name, const Data::MappedElement& mapped)
// missing reference
std::ostringstream ss;
ss << Data::MISSING_PREFIX << dot + 1;
return ElementNamePair(name, ss.str().c_str() );
return ElementNamePair(name, ss.str().c_str());
}
return ElementNamePair(name,"");
return ElementNamePair(name, "");
}
else {
std::string oldName;
@@ -134,53 +134,70 @@ GeoFeature::_getElementName(const char* name, const Data::MappedElement& mapped)
}
}
DocumentObject *GeoFeature::resolveElement(DocumentObject *obj, const char *subname,
ElementNamePair &elementName, bool append,
ElementNameType type, const DocumentObject *filter,
const char **_element, GeoFeature **geoFeature)
DocumentObject* GeoFeature::resolveElement(DocumentObject* obj,
const char* subname,
ElementNamePair& elementName,
bool append,
ElementNameType type,
const DocumentObject* filter,
const char** _element,
GeoFeature** geoFeature)
{
elementName.newName.clear();
elementName.oldName.clear();
if(!obj || !obj->isAttachedToDocument())
if (!obj || !obj->isAttachedToDocument()) {
return nullptr;
if(!subname)
}
if (!subname) {
subname = "";
const char *element = Data::findElementName(subname);
if(_element) *_element = element;
}
const char* element = Data::findElementName(subname);
if (_element) {
*_element = element;
}
auto sobj = obj->getSubObject(std::string(subname, element).c_str());
if(!sobj)
if (!sobj) {
return nullptr;
}
auto linked = sobj->getLinkedObject(true);
auto geo = Base::freecad_dynamic_cast<GeoFeature>(linked);
if(!geo && linked) {
if (!geo && linked) {
auto ext = linked->getExtensionByType<LinkBaseExtension>(true);
if(ext)
if (ext) {
geo = Base::freecad_dynamic_cast<GeoFeature>(ext->getTrueLinkedObject(true));
}
}
if(geoFeature)
if (geoFeature) {
*geoFeature = geo;
if(filter && geo!=filter)
}
if (filter && geo != filter) {
return nullptr;
if(!element || !element[0]) {
if(append)
}
if (!element || !element[0]) {
if (append) {
elementName.oldName = Data::oldElementName(subname);
}
return sobj;
}
if(!geo || hasHiddenMarker(element)) {
if(!append)
if (!geo || hasHiddenMarker(element)) {
if (!append) {
elementName.oldName = element;
else
}
else {
elementName.oldName = Data::oldElementName(subname);
}
return sobj;
}
if(!append)
elementName = geo->getElementName(element,type);
else{
const auto &names = geo->getElementName(element,type);
std::string prefix(subname,element-subname);
if(!names.newName.empty())
if (!append) {
elementName = geo->getElementName(element, type);
}
else {
const auto& names = geo->getElementName(element, type);
std::string prefix(subname, element - subname);
if (!names.newName.empty()) {
elementName.newName = prefix + names.newName;
}
elementName.oldName = prefix + names.oldName;
}
return sobj;
@@ -264,12 +281,12 @@ std::vector<const char*> GeoFeature::getElementTypes(bool /*all*/) const
return prop->getComplexData()->getElementTypes();
}
std::vector<Data::IndexedName>
GeoFeature::getHigherElements(const char *element, bool silent) const
std::vector<Data::IndexedName> GeoFeature::getHigherElements(const char* element, bool silent) const
{
auto prop = getPropertyOfGeometry();
if (!prop)
if (!prop) {
return {};
}
return prop->getComplexData()->getHigherElements(element, silent);
}
@@ -284,8 +301,8 @@ Base::Placement GeoFeature::getPlacementFromProp(App::DocumentObject* obj, const
}
Base::Placement GeoFeature::getGlobalPlacement(App::DocumentObject* targetObj,
App::DocumentObject* rootObj,
const std::string& sub)
App::DocumentObject* rootObj,
const std::string& sub)
{
if (!targetObj || !rootObj || sub.empty()) {
return Base::Placement();
@@ -295,7 +312,9 @@ Base::Placement GeoFeature::getGlobalPlacement(App::DocumentObject* targetObj,
App::Document* doc = rootObj->getDocument();
Base::Placement plc = getPlacementFromProp(rootObj, "Placement");
if (targetObj == rootObj) return plc;
if (targetObj == rootObj) {
return plc;
}
for (auto& name : names) {
App::DocumentObject* obj = doc->getObject(name.c_str());
@@ -319,7 +338,7 @@ Base::Placement GeoFeature::getGlobalPlacement(App::DocumentObject* targetObj,
}
Base::Placement GeoFeature::getGlobalPlacement(App::DocumentObject* targetObj,
App::PropertyXLinkSub* prop)
App::PropertyXLinkSub* prop)
{
if (!targetObj || !prop) {
return Base::Placement();