From 1ff2dbe4290f13372088019645290a9875eb1f3b Mon Sep 17 00:00:00 2001 From: Daniel Girardeau-Montaut Date: Sat, 1 Apr 2023 14:28:09 +0200 Subject: [PATCH] Syntax update --- src/JsonRPCPlugin.cpp | 92 ++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/src/JsonRPCPlugin.cpp b/src/JsonRPCPlugin.cpp index 79a4f92..a58d07f 100644 --- a/src/JsonRPCPlugin.cpp +++ b/src/JsonRPCPlugin.cpp @@ -24,13 +24,13 @@ //qCC_db #include //qCC_gl -#include +#include //qCC_io #include //CC plugins #include -JsonRPCPlugin::JsonRPCPlugin( QObject *parent ) +JsonRPCPlugin::JsonRPCPlugin(QObject* parent) : QObject( parent ) , ccStdPluginInterface( ":/CC/plugin/JsonRPCPlugin/info.json" ) { @@ -39,7 +39,7 @@ JsonRPCPlugin::JsonRPCPlugin( QObject *parent ) connect(&rpc_server, &JsonRPCServer::execute, this, &JsonRPCPlugin::execute); } -QList JsonRPCPlugin::getActions() +QList JsonRPCPlugin::getActions() { qDebug() << "JsonRPCPlugin::getActions"; @@ -206,7 +206,7 @@ JsonRPCResult JsonRPCPlugin::execute(QString method, QMap par // redraw if (need_redraw) { - ccGLWindow* win = m_app->getActiveGLWindow(); + ccGLWindowInterface* win = m_app->getActiveGLWindow(); if (win) win->redraw(); } @@ -215,55 +215,57 @@ JsonRPCResult JsonRPCPlugin::execute(QString method, QMap par } // concatenate the names recursively -QString JsonRPCPlugin::recursiveName(ccHObject *obj) +QString JsonRPCPlugin::recursiveName(ccHObject* obj) { QString name; - while(obj) { - name.prepend(obj->getName()+"/"); - obj = obj->getParent(); - } + while (obj) + { + name.prepend(obj->getName() + "/"); + obj = obj->getParent(); + } return name; } - // select objects along the path and create if not existing -ccHObject *JsonRPCPlugin::createParent(QString path) +ccHObject* JsonRPCPlugin::createParent(QString path) { - QStringList tokens = path.split("/"); - qDebug() << "createParent() " << path << tokens; - auto parent = m_app->dbRootObject(); - while(!tokens.isEmpty() && parent) - { - if(!tokens.first().trimmed().isEmpty()) - { - ccHObject *next{nullptr}; - ccHObject::Container filteredChildren; - parent->filterChildren(filteredChildren, false, CC_TYPES::HIERARCHY_OBJECT, true); - for(const auto &child: filteredChildren) - { - qDebug() << "iterate name:" << child->getName() << ", type:" << child->getClassID() << " recursive: " << recursiveName(child); + QStringList tokens = path.split("/"); + qDebug() << "createParent() " << path << tokens; + auto parent = m_app->dbRootObject(); + while (!tokens.isEmpty() && parent) + { + if (!tokens.first().trimmed().isEmpty()) + { + ccHObject* next{ nullptr }; + ccHObject::Container filteredChildren; + parent->filterChildren(filteredChildren, false, CC_TYPES::HIERARCHY_OBJECT, true); + for (const auto &child : filteredChildren) + { + qDebug() << "iterate name:" << child->getName() << ", type:" << child->getClassID() << " recursive: " << recursiveName(child); - if(child->getName().compare(tokens.first().trimmed(), Qt::CaseInsensitive) == 0) { - // name matches - next = child; - break; - } - } - if(!next) - { - // not found; create one - next = new ccHObject(tokens.first().trimmed()); - if(!next) { - return parent; - } - parent->addChild(next); - m_app->addToDB(next); - } - parent = next; - } - tokens.removeFirst(); - } - return parent; + if (child->getName().compare(tokens.first().trimmed(), Qt::CaseInsensitive) == 0) + { + // name matches + next = child; + break; + } + } + if (!next) + { + // not found; create one + next = new ccHObject(tokens.first().trimmed()); + if (!next) + { + return parent; + } + parent->addChild(next); + m_app->addToDB(next); + } + parent = next; + } + tokens.removeFirst(); + } + return parent; }