m_app not initialized when running a plugin from the CLI

Feel free to ask any question here
Post Reply
ejweathersby
Posts: 3
Joined: Mon Nov 07, 2022 9:22 pm

m_app not initialized when running a plugin from the CLI

Post 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!
daniel
Site Admin
Posts: 7710
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

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

Post 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?
Daniel, CloudCompare admin
ejweathersby
Posts: 3
Joined: Mon Nov 07, 2022 9:22 pm

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

Post 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.
daniel
Site Admin
Posts: 7710
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

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

Post 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?
Daniel, CloudCompare admin
ejweathersby
Posts: 3
Joined: Mon Nov 07, 2022 9:22 pm

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

Post 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.
daniel
Site Admin
Posts: 7710
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

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

Post 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
Daniel, CloudCompare admin
Post Reply