ccStdPluginInterface.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //##########################################################################
  2. //# #
  3. //# CLOUDCOMPARE #
  4. //# #
  5. //# This program is free software; you can redistribute it and/or modify #
  6. //# it under the terms of the GNU General Public License as published by #
  7. //# the Free Software Foundation; version 2 of the License. #
  8. //# #
  9. //# This program is distributed in the hope that it will be useful, #
  10. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  11. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  12. //# GNU General Public License for more details. #
  13. //# #
  14. //# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
  15. //# #
  16. //##########################################################################
  17. #pragma once
  18. //Qt
  19. #include <QActionGroup>
  20. #include <QWidget>
  21. //qCC_db
  22. #include <ccHObject.h>
  23. //qCC
  24. #include "ccDefaultPluginInterface.h"
  25. #include "ccMainAppInterface.h"
  26. //UI Modification flags
  27. #define CC_PLUGIN_REFRESH_GL_WINDOWS 0x00000001
  28. #define CC_PLUGIN_REFRESH_ENTITY_BROWSER 0x00000002
  29. #define CC_PLUGIN_EXPAND_DB_TREE 0x00000004
  30. //! Standard CC plugin interface
  31. /** Version 1.5
  32. The plugin is now responsible for its own actions (QAction ;)
  33. and the associated ccMainAppInterface member should give it
  34. access to everything it needs in the main application.
  35. **/
  36. class ccStdPluginInterface : public ccDefaultPluginInterface
  37. {
  38. public:
  39. //! Default constructor
  40. ccStdPluginInterface( const QString &resourcePath = QString() ) :
  41. ccDefaultPluginInterface( resourcePath )
  42. , m_app(nullptr)
  43. {
  44. }
  45. //! Destructor
  46. ~ccStdPluginInterface() override = default;
  47. //inherited from ccPluginInterface
  48. CC_PLUGIN_TYPE getType() const override { return CC_STD_PLUGIN; }
  49. //! Sets application entry point
  50. /** Called just after plugin creation by qCC
  51. **/
  52. virtual void setMainAppInterface(ccMainAppInterface* app)
  53. {
  54. m_app = app;
  55. if (m_app)
  56. {
  57. //we use the same 'unique ID' generator in plugins as in the main
  58. //application (otherwise we'll have issues with 'unique IDs'!)
  59. ccObject::SetUniqueIDGenerator(m_app->getUniqueIDGenerator());
  60. }
  61. }
  62. //! A callback pointer to the main app interface for use by plugins
  63. /** Any plugin (and its tools) may need to access methods of this interface
  64. **/
  65. virtual ccMainAppInterface * getMainAppInterface() { return m_app; }
  66. //! Get a list of actions for this plugin
  67. virtual QList<QAction *> getActions() = 0;
  68. //! This method is called by the main application whenever the entity selection changes
  69. /** Does nothing by default. Should be re-implemented by the plugin if necessary.
  70. \param selectedEntities currently selected entities
  71. **/
  72. virtual void onNewSelection(const ccHObject::Container& selectedEntities) { /*ignored by default*/ }
  73. //! Shortcut to ccMainAppInterface::dispToConsole
  74. inline virtual void dispToConsole(const QString& message, ccMainAppInterface::ConsoleMessageLevel level = ccMainAppInterface::STD_CONSOLE_MESSAGE)
  75. {
  76. if (m_app)
  77. {
  78. m_app->dispToConsole(message, level);
  79. }
  80. }
  81. protected:
  82. //! Main application interface
  83. ccMainAppInterface* m_app;
  84. };
  85. Q_DECLARE_METATYPE(const ccStdPluginInterface *);
  86. Q_DECLARE_INTERFACE(ccStdPluginInterface,"cccorp.cloudcompare.ccStdPluginInterface/1.5")