diff --git a/README.md b/README.md index 8a79036..2a6aebb 100644 --- a/README.md +++ b/README.md @@ -87,8 +87,22 @@ interface silent: bool, optional, if true, then filterdialog is suppressed transformation: list of float (16values), optional, after import this transformation matrix is applied to the object, - clear - clear all objects +- version - return version number of plugin ``` +debugging +--------- + +I use QtCreator for developement. +In order to load the plugin during debugging it must placed in a folder that is looked up. +- /usr/lib/cloudcompare/plugins +- /home/username/.local/share/CCCorp/CloudCompare/plugins +- /usr/local/share/CCCorp/CloudCompare/plugins +- /usr/share/CCCorp/CloudCompare/plugins +- /var/lib/snapd/desktop/CCCorp/CloudCompare/plugins + +I set a link in the .local/share folder to the recent compiled version: + ln -s build-CloudCompare-Desktop-Debug/plugins/core/Standard/qJSonRPCPlugin/libQJSON_RPC_PLUGINd.so ~/.local/share/CCCorp/CloudCompare/plugins/libQJSON_RPC_PLUGINd.so contact ------- diff --git a/include/JsonRPCPlugin.h b/include/JsonRPCPlugin.h index 6670cf9..6d0c473 100644 --- a/include/JsonRPCPlugin.h +++ b/include/JsonRPCPlugin.h @@ -42,6 +42,7 @@ public slots: private: //! Default action QAction* m_action{nullptr}; + const QString version{"1.0"}; protected: /// server that emit the execute signals JsonRPCServer rpc_server; diff --git a/src/JsonRPCPlugin.cpp b/src/JsonRPCPlugin.cpp index 563d13e..a3e3344 100644 --- a/src/JsonRPCPlugin.cpp +++ b/src/JsonRPCPlugin.cpp @@ -154,20 +154,25 @@ JsonRPCResult JsonRPCPlugin::execute(QString method, QMap par result = JsonRPCResult::error(1, "cancelled by user"); } } - else if (method == "clear") - { + else if (method == "clear") + { // remove everything below root auto root = m_app->dbRootObject(); ccHObject* child; while ((child = root->getChild(0)) != nullptr) - { + { m_app->removeFromDB(child, true); } need_redraw = true; result = JsonRPCResult::success(0); } - + else if (method == "version") + { + // return version number of plugin + result = JsonRPCResult::success(version); + } + // redraw if (need_redraw) { diff --git a/test/client_version.py b/test/client_version.py new file mode 100755 index 0000000..48b9656 --- /dev/null +++ b/test/client_version.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 + +import asyncio +import websockets + +async def hello(): + uri = "ws://localhost:6001" + async with websockets.connect(uri) as websocket: + await websocket.send('{"jsonrpc": "2.0", "method": "version", "id": 6}') + result = await websocket.recv() + print("result: ", result) + +asyncio.get_event_loop().run_until_complete(hello()) +