ccMainAppInterface.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. #pragma once
  2. //##########################################################################
  3. //# #
  4. //# CLOUDCOMPARE #
  5. //# #
  6. //# This program is free software; you can redistribute it and/or modify #
  7. //# it under the terms of the GNU General Public License as published by #
  8. //# the Free Software Foundation; version 2 of the License. #
  9. //# #
  10. //# This program is distributed in the hope that it will be useful, #
  11. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  12. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  13. //# GNU General Public License for more details. #
  14. //# #
  15. //# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
  16. //# #
  17. //##########################################################################
  18. //Qt
  19. #include <QString>
  20. //qCC_db
  21. #include <ccHObject.h>
  22. #include <ccHObjectCaster.h>
  23. //qCC_gl
  24. #include <ccGLUtils.h>
  25. class QMainWindow;
  26. class QWidget;
  27. class ccGLWindowInterface;
  28. class ccColorScalesManager;
  29. class ccOverlayDialog;
  30. class ccPickingHub;
  31. //! Main application interface (for plugins)
  32. class ccMainAppInterface
  33. {
  34. public:
  35. virtual ~ccMainAppInterface() = default;
  36. //! Returns main window
  37. virtual QMainWindow* getMainWindow() = 0;
  38. //! Returns active GL sub-window (if any)
  39. virtual ccGLWindowInterface* getActiveGLWindow() = 0;
  40. //! Creates a new instance of GL window (with its encapsulating widget)
  41. /** \warning This instance must be destroyed by the application as well (see destroyGLWindow)
  42. Note that the encapsulating widget is the window instance itself if 'stereo' mode is disabled
  43. **/
  44. virtual void createGLWindow(ccGLWindowInterface*& window, QWidget*& widget) const { window = nullptr; widget = nullptr; }
  45. //! Destroys an instance of GL window created by createGLWindow
  46. virtual void destroyGLWindow(ccGLWindowInterface*) const {}
  47. //! Registers a MDI area 'overlay' dialog
  48. /** Overlay dialogs are displayed in the central MDI area, above the 3D views.
  49. The position (pos) is defined relatively to the MDI area (as one of its 4 corners).
  50. And it is automatically updated when the main window is moved or resized.
  51. Registered dialogs are automatically released when CloudCompare stops.
  52. Notes:
  53. - it may be necessary to call 'updateOverlayDialogsPlacement' after calling this method
  54. - it's a good idea to freeez the UI when the tool starts to avoid other overlay dialogs
  55. to appear (don't forget to unfreeze the UI afterwards)
  56. **/
  57. virtual void registerOverlayDialog(ccOverlayDialog* dlg, Qt::Corner pos) {}
  58. //! Unregisters a MDI area 'overlay' dialog
  59. /** \warning Original overlay dialog object will be deleted (see QObject::deleteLater)
  60. **/
  61. virtual void unregisterOverlayDialog(ccOverlayDialog* dlg) {}
  62. //! Forces the update of all registered MDI 'overlay' dialogs
  63. virtual void updateOverlayDialogsPlacement() {}
  64. //! Returns the unique ID generator
  65. virtual ccUniqueIDGenerator::Shared getUniqueIDGenerator() = 0;
  66. //! Attempts to load a file
  67. virtual ccHObject* loadFile(QString filename, bool silent) = 0;
  68. //! Adds an entity to the main db
  69. /** \param obj entity
  70. \param updateZoom updates active GL display zoom to fit the whole scene, including this new entity (addToDisplay must be true)
  71. \param autoExpandDBTree whether DB tree should automatically be expanded
  72. \param checkDimensions whether to check entity's dimensions (and potentially asking the user to shift/rescale it) or not
  73. \param autoRedraw whether to redraw the 3D view automatically or not (warning: if 'updateZoom' is true, the 3D view will always be redrawn)
  74. **/
  75. virtual void addToDB( ccHObject* obj,
  76. bool updateZoom = false,
  77. bool autoExpandDBTree = true,
  78. bool checkDimensions = false,
  79. bool autoRedraw = true) = 0;
  80. //! Removes an entity from main db tree
  81. /** Object is automatically detached from its parent.
  82. \param obj entity
  83. \param autoDelete automatically deletes object
  84. **/
  85. virtual void removeFromDB(ccHObject* obj, bool autoDelete = true) = 0;
  86. //! Backup "context" for an object
  87. /** Used with removeObjectTemporarilyFromDBTree/putObjectBackIntoDBTree.
  88. **/
  89. struct ccHObjectContext
  90. {
  91. ccHObject* parent = nullptr;
  92. int childFlags = 0;
  93. int parentFlags = 0;
  94. };
  95. //! Removes object temporarily from DB tree
  96. /** This method must be called before any modification to the db tree
  97. \warning May change the set of currently selected entities
  98. **/
  99. virtual ccHObjectContext removeObjectTemporarilyFromDBTree(ccHObject* obj) { return {}; }
  100. //! Adds back object to DB tree
  101. /** This method should be called once modifications to the db tree are finished
  102. (see removeObjectTemporarilyFromDBTree).
  103. **/
  104. virtual void putObjectBackIntoDBTree(ccHObject* obj, const ccHObjectContext& context) {}
  105. //! Selects or unselects an entity (in db tree)
  106. /** \param obj entity
  107. \param selected whether entity should be selected or not
  108. **/
  109. virtual void setSelectedInDB(ccHObject* obj, bool selected) = 0;
  110. //! Returns currently selected entities ("read only")
  111. virtual const ccHObject::Container& getSelectedEntities() const = 0;
  112. //! Checks if we have any selections
  113. bool haveSelection() const { return !getSelectedEntities().empty(); }
  114. //! Checks if we have exactly one selection
  115. bool haveOneSelection() const { return getSelectedEntities().size() == 1; }
  116. //! Console message level (see dispToConsole)
  117. enum ConsoleMessageLevel
  118. {
  119. STD_CONSOLE_MESSAGE = 0,
  120. WRN_CONSOLE_MESSAGE = 1,
  121. ERR_CONSOLE_MESSAGE = 2,
  122. };
  123. //! Prints a message to console
  124. /** \param message message
  125. \param level message level (standard, warning, error)
  126. **/
  127. virtual void dispToConsole(QString message, ConsoleMessageLevel level = STD_CONSOLE_MESSAGE) = 0;
  128. //! Forces display of console widget
  129. virtual void forceConsoleDisplay() {}
  130. //! Returns DB root (as a ccHObject)
  131. virtual ccHObject* dbRootObject() = 0;
  132. //! Forces redraw of all GL windows
  133. /** \param only2D whether to redraw everything (false) or only the 2D layer (true)
  134. **/
  135. virtual void redrawAll(bool only2D = false) = 0;
  136. //! Redraws all GL windows that have the 'refresh' flag on
  137. /** See ccGLWindowInterface::toBeRefreshed and ccDrawableObject::prepareDisplayForRefresh.
  138. \param only2D whether to redraw everything (false) or only the 2D layer (true)
  139. **/
  140. virtual void refreshAll(bool only2D = false) = 0;
  141. //! Enables all GL windows
  142. virtual void enableAll() = 0;
  143. //! Disables all GL windows
  144. virtual void disableAll() = 0;
  145. //! Disables all GL windows but the specified one
  146. virtual void disableAllBut(ccGLWindowInterface* win) = 0;
  147. //! Updates UI (menu and properties browser) to reflect current selection state
  148. /** This method should be called whenever a change is made to any selected entity
  149. **/
  150. virtual void updateUI() = 0;
  151. //! Freezes/unfreezes UI
  152. /** \param state freeze state
  153. **/
  154. virtual void freezeUI(bool state) = 0;
  155. //! Returns color scale manager (unique instance)
  156. virtual ccColorScalesManager* getColorScalesManager() { return nullptr; }
  157. //! Spawns an histogram dialog
  158. virtual void spawnHistogramDialog( const std::vector<unsigned>& histoValues,
  159. double minVal,
  160. double maxVal,
  161. QString title,
  162. QString xAxisLabel ) {}
  163. //! Returns the picking hub (if any)
  164. virtual ccPickingHub* pickingHub() { return nullptr; }
  165. //other useful methods
  166. virtual void setView( CC_VIEW_ORIENTATION view ) = 0;
  167. virtual void toggleActiveWindowCenteredPerspective() = 0;
  168. virtual void toggleActiveWindowCustomLight() = 0;
  169. virtual void toggleActiveWindowSunLight() = 0;
  170. virtual void toggleActiveWindowViewerBasedPerspective() = 0;
  171. virtual void zoomOnSelectedEntities() = 0;
  172. virtual void setGlobalZoom() = 0;
  173. virtual void increasePointSize() = 0;
  174. virtual void decreasePointSize() = 0;
  175. };