Page 1 of 1

m_app not initialized when running a plugin from the CLI

Posted: Mon Nov 07, 2022 9:55 pm
by ejweathersby
Good Afternoon,

I've got a plugin that works from within the cloudcompare GUI, but it throws a nullpointer exception for m_app when run from the commandline. It's my understanding that m_app is initialized when the plugin is, but that doesn't seem to be happening. Is there anything I need to do to force the initialization?

Thanks!

Re: m_app not initialized when running a plugin from the CLI

Posted: Tue Nov 08, 2022 10:46 pm
by daniel
Looking at the code, it seems that the 'ccMainAppInterface' member of plugins is only initialized in the GUI version. Mostly because it's a direct proxy to the main window (which doesn't exist in command line mode). Moreover, most of the methods of this interface wouldn't work in command line mode. The only interesting ones would be related to the database, but the database is managed in a very different way in command line mode...

What kind of plugins is it? Which method of the main app interface were you expecting to be able to use?

Re: m_app not initialized when running a plugin from the CLI

Posted: Thu Nov 10, 2022 5:49 pm
by ejweathersby
Thanks for the reply,

The plugin aligns clouds from a number of sensors. It's code I inherited from someone else so there maybe additional calls that I haven''t run across yet, but it looks like it is mostly used for database access. There are some process dialogs that are displayed, but we don't need those when it's running from the command line.

Re: m_app not initialized when running a plugin from the CLI

Posted: Fri Nov 11, 2022 9:44 am
by daniel
Yes, you generally don't want dialogs to show in command line mode (therefore, you can just test whether this main app interface is defined or not to detect that you are in command line mode or not, and therefore show or hide the dialogs.

For the database access, what kind of mechanism was in place? Was the plugin applied to some highlighted entities? Or was it looking for a particular type of entities in the whole DB?

Re: m_app not initialized when running a plugin from the CLI

Posted: Fri Nov 11, 2022 2:46 pm
by ejweathersby
The plugin iterates though all of the clouds in a specific group that is always assumed to be present (i.e. no need to select it). It adds some partially cloned clouds and data from a preexisting bin file to the database and it does some searching, by metadata, for planes from that bin file.

Re: m_app not initialized when running a plugin from the CLI

Posted: Sun Nov 13, 2022 10:25 pm
by daniel
I guess the only way for now is to implement the 'command line' entry point for your plugin.

See the qRansac_SD or qM3C2 plugins for reference:
https://github.com/CloudCompare/CloudCo ... Commands.h