[CC] Research on CC Plugin

Source: Internet
Author: User

The content of the application Plugin framework includes: Main program app, plugin plugin.

1, the implementation of an application frame key points are:

A plug-in standard interface in which a collection of plugins exists in the main program. The main program through the loop read each plug-in, the plug-in object through the polymorphic mechanism into the plug-in interface, implementation of plug-in loading.

The main program object or the main program interface needs to be passed as a parameter to the plug-in object to facilitate the plug-in object to invoke the main program's contents, such as the Master view, toolbars, tree views, status bars, etc.

2, open source point cloud processing software cloudcompare is also a plug-in framework, it is also necessary to include these content.

Plug-in interface: Ccplugininterface, each plug-in object has a new interface class defined on Ccplugininterface basis classes Ccstdplugininterface:public Ccplugininterface

Specific plug-ins are inherited from Ccstdplugininterface tired, such as, Class Qmyplugin:public qobject, public ccstdplugininterface

Main Program object: Class Ccmainappinterface,mainwindow main Form classes implement the Ccmainappinterface interface.

The Mainwindow::loadplugins () method is responsible for the plug-in invocation. (in Mainwindow.cpp file)

1 voidmainwindow::loadplugins ()2 {3Menuplugins->setenabled (false);4Menushadersandfilters->setenabled (false);5Toolbarplugintools->setvisible (false);6Toolbarglfilters->setvisible (false);7 8     //"Static" plugins9     foreach(Qobject *plugin, qpluginloader::staticinstances ())Ten Dispatchplugin (plugin); One  ACcconsole::P rint (QString ("Application path:")+Qcoreapplication::applicationdirpath ()); -  - #ifDefined (Q_OS_MAC) the     //plugins is in the bundle -QString Path =Qcoreapplication::applicationdirpath (); -Path.remove ("MacOS" ); -M_pluginspath = path +"Plugins/ccplugins"; + #else -     //plugins is in Bin/plugins +M_pluginspath = Qcoreapplication::applicationdirpath () +qstring ("/plugins"); A #endif at  -Ccconsole::P rint (QString ("Plugins lookup dir.:%1"). Arg (M_pluginspath)); -  - qstringlist filters; - #ifDefined (Q_os_win) -Filters <<"*.dll"; in #elifDefined (q_os_linux) -Filters <<"*.so"; to #elifDefined (Q_OS_MAC) +Filters <<"*.dylib"; - #endif the qdir Pluginsdir (m_pluginspath); * pluginsdir.setnamefilters (filters); $     foreach(QString filename, pluginsdir.entrylist (filters))Panax Notoginseng     { - Qpluginloader Loader (pluginsdir.absolutefilepath (filename)); theqobject* plugin =loader.instance (); +         if(plugin) A         { theCcconsole::P rint (QString ("Found New plugin: '%1 '"). ARG (filename)); +             if(Dispatchplugin (plugin)) -             { $M_pluginfilenames + =filename; $             } -             Else -             { the                 Deleteplugin; -Plugin =0;WuyiCcconsole::warning ("\tunsupported or invalid plugin type"); the             } -         } Wu         Else -         { About             Deleteplugin; $Plugin =0; -Ccconsole::warning (QString ("[Plugin]%1")/*. Arg (Pluginsdir.absolutefilepath (filename))*/. Arg (loader.errorstring ())); -         } -     } A  +     if(menuplugins) the     { -Menuplugins->setenabled (!m_stdplugins.empty ()); $     } the  the     if(toolbarplugintools->isenabled ()) the     { theActiondisplayplugintools->setenabled (true); -Actiondisplayplugintools->setchecked (true); in     } the     Else the     { About         //dgm:doesn ' t work:( the         //actiondisplayplugintools->setchecked (false); the     } the  +     if(toolbarglfilters->isenabled ()) -     { theActiondisplayglfilterstools->setenabled (true);BayiActiondisplayglfilterstools->setchecked (true); the     } the     Else -     { -         //dgm:doesn ' t work:( the         //actiondisplayglfilterstools->setchecked (false); the     } the}

The main program calls the plug-in when it loads the plugin. Setmainappinterface method, the main program parameters are passed in so that the plugin can get the contents of the main program.

1 // ! Sets application entrypoint2*/* called just after plugin creation by QCC3*  */4virtualvoid setmainappinterface (ccmainappinterface* app);

3. Get the point cloud layer in the main form

Code in Doaction:

1     Constcchobject::container& selectedentities = m_app->getselectedentities ();2size_t Selnum =selectedentities.size ();3     if(selnum!=1)4     {5M_app->disptoconsole ("Select only one cloud!", ccmainappinterface::err_console_message);6         return;7     }8 9cchobject* ent = selectedentities[0];Ten assert (ENT); One     if(!ent | |!ent->IsA (cc_types::P oint_cloud)) A     { -M_app->disptoconsole ("Select A real point cloud!", ccmainappinterface::err_console_message); -         return; the     } -  -ccpointcloud* pc = Static_cast<ccpointcloud*>(ENT); -  +     //Input Cloud -unsigned count = pc->size (); +     BOOLHasnorms = pc->hasnormals (); A CCVector3 bbmin, Bbmax; atPc->Getboundingbox (Bbmin,bbmax); -     Constccvector3d& Globalshift = pc->Getglobalshift (); -     DoubleGlobalscale = Pc->getglobalscale ();

[CC] Research on CC Plugin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.