mirror of
https://gitlab.com/theadib/JSonRPCPlugin.git
synced 2026-08-29 15:40:24 +08:00
Syntax update
This commit is contained in:
+47
-45
@@ -24,13 +24,13 @@
|
||||
//qCC_db
|
||||
#include <ccGenericPointCloud.h>
|
||||
//qCC_gl
|
||||
#include <ccGLWindow.h>
|
||||
#include <ccGLWindowInterface.h>
|
||||
//qCC_io
|
||||
#include <FileIOFilter.h>
|
||||
//CC plugins
|
||||
#include <ccMainAppInterface.h>
|
||||
|
||||
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<QAction *> JsonRPCPlugin::getActions()
|
||||
QList<QAction*> JsonRPCPlugin::getActions()
|
||||
{
|
||||
qDebug() << "JsonRPCPlugin::getActions";
|
||||
|
||||
@@ -206,7 +206,7 @@ JsonRPCResult JsonRPCPlugin::execute(QString method, QMap<QString, QVariant> 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<QString, QVariant> 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user