ccviewer.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. #pragma once
  2. //##########################################################################
  3. //# #
  4. //# CLOUDCOMPARE LIGHT VIEWER #
  5. //# #
  6. //# This project has been initiated under funding from ANR/CIFRE #
  7. //# #
  8. //# This program is free software; you can redistribute it and/or modify #
  9. //# it under the terms of the GNU General Public License as published by #
  10. //# the Free Software Foundation; version 2 or later of the License. #
  11. //# #
  12. //# This program is distributed in the hope that it will be useful, #
  13. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  14. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  15. //# GNU General Public License for more details. #
  16. //# #
  17. //# +++ COPYRIGHT: EDF R&D + TELECOM ParisTech (ENST-TSI) +++ #
  18. //# #
  19. //##########################################################################
  20. //Qt
  21. #include <QMainWindow>
  22. #include <QStringList>
  23. //CCPluginAPI
  24. #include <ccMainAppInterface.h>
  25. //GUIs
  26. #include <ui_ccviewer.h>
  27. //System
  28. #include <set>
  29. class ccGLWindowInterface;
  30. class ccHObject;
  31. class Mouse3DInput;
  32. class ccGamepadManager;
  33. //! Application main window
  34. class ccViewer : public QMainWindow, public ccMainAppInterface
  35. {
  36. Q_OBJECT
  37. public:
  38. //! Default constructor
  39. ccViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
  40. //! Default destructor
  41. ~ccViewer() override;
  42. //! Adds entity to display db
  43. void addToDB( ccHObject* entity,
  44. bool updateZoom = false,
  45. bool autoExpandDBTree = true,
  46. bool checkDimensions = false,
  47. bool autoRedraw = true) override;
  48. //! Removes an entity from display db
  49. void removeFromDB(ccHObject* obj, bool autoDelete = true) override;
  50. //! Checks for loaded entities
  51. /** If none, a message is displayed to invite the user
  52. to drag & drop files.
  53. **/
  54. bool checkForLoadedEntities();
  55. public:
  56. //! Tries to load (and then adds to main db) a list of entity (files)
  57. /** \param filenames filenames to load
  58. \return the first loaded entity/group
  59. **/
  60. ccHObject* addToDB(QStringList filenames);
  61. public: // ccMainInterface compliance
  62. QMainWindow* getMainWindow() override { return this; }
  63. ccGLWindowInterface* getActiveGLWindow() override { return m_glWindow; }
  64. ccHObject* loadFile(QString filename, bool silent) override { return addToDB(QStringList{ filename }); }
  65. void setSelectedInDB(ccHObject* obj, bool selected) override {}
  66. const ccHObject::Container& getSelectedEntities() const override;
  67. void dispToConsole(QString message, ConsoleMessageLevel level = STD_CONSOLE_MESSAGE) override;
  68. ccHObject* dbRootObject() override;
  69. void redrawAll(bool only2D = false) override;
  70. void refreshAll(bool only2D = false) override;
  71. void enableAll() override;
  72. void disableAll() override;
  73. void disableAllBut(ccGLWindowInterface* win) override;
  74. void updateUI() override {}
  75. void freezeUI(bool state) override {}
  76. void setView(CC_VIEW_ORIENTATION view) override;
  77. void toggleActiveWindowCenteredPerspective() override;
  78. void toggleActiveWindowCustomLight() override;
  79. void toggleActiveWindowSunLight() override;
  80. void toggleActiveWindowViewerBasedPerspective() override;
  81. void zoomOnSelectedEntities() override { zoomOnSelectedEntity(); }
  82. void increasePointSize() override;
  83. void decreasePointSize() override;
  84. ccUniqueIDGenerator::Shared getUniqueIDGenerator() override;
  85. protected:
  86. //! Shows display parameters dialog
  87. void showDisplayParameters();
  88. //! Updates display to match display parameters
  89. void updateDisplay();
  90. //! Selects entity
  91. void selectEntity(ccHObject* entity);
  92. //! Delete selected entity
  93. void doActionDeleteSelectedEntity();
  94. //! Slot called when the exclusive full screen mode is called
  95. void onExclusiveFullScreenToggled(bool);
  96. void doActionEditCamera();
  97. void toggleSunLight(bool);
  98. void toggleCustomLight(bool);
  99. void toggleStereoMode(bool);
  100. void toggleFullScreen(bool);
  101. void toggleRotationAboutVertAxis();
  102. void doActionAbout();
  103. void doActionDisplayShortcuts();
  104. void setPivotAlwaysOn();
  105. void setPivotRotationOnly();
  106. void setPivotOff();
  107. void setOrthoView();
  108. void setCenteredPerspectiveView();
  109. void setViewerPerspectiveView();
  110. void setGlobalZoom() override;
  111. void zoomOnSelectedEntity();
  112. //default views
  113. void setFrontView();
  114. void setBottomView();
  115. void setTopView();
  116. void setBackView();
  117. void setLeftView();
  118. void setRightView();
  119. void setIsoView1();
  120. void setIsoView2();
  121. //selected entity properties
  122. void toggleColorsShown(bool);
  123. void toggleNormalsShown(bool);
  124. void toggleMaterialsShown(bool);
  125. void toggleScalarShown(bool);
  126. void toggleColorbarShown(bool);
  127. void changeCurrentScalarField(bool);
  128. //3D mouse
  129. void on3DMouseMove(std::vector<float>&);
  130. void on3DMouseKeyUp(int);
  131. void on3DMouseKeyDown(int);
  132. void on3DMouseCMDKeyDown(int);
  133. void on3DMouseCMDKeyUp(int);
  134. void on3DMouseReleased();
  135. void enable3DMouse(bool state);
  136. //GL filters
  137. void doEnableGLFilter();
  138. void doDisableGLFilter();
  139. protected: //methods
  140. //! Loads plugins (from files)
  141. void loadPlugins();
  142. //! Makes the GL frame background gradient match the OpenGL window one
  143. void updateGLFrameGradient();
  144. //! Updates perspective UI elements
  145. void reflectPerspectiveState();
  146. //! Updates pivot UI elements
  147. void reflectPivotVisibilityState();
  148. //! Updates lights UI elements
  149. void reflectLightsState();
  150. //! Checks whether stereo mode can be stopped (if necessary) or not
  151. bool checkStereoMode();
  152. protected: //members
  153. //! Releases any connected 3D mouse (if any)
  154. void release3DMouse();
  155. //! Associated GL context
  156. ccGLWindowInterface* m_glWindow;
  157. //! Currently selected object
  158. ccHObject* m_selectedObject;
  159. //! 3D mouse handler
  160. Mouse3DInput* m_3dMouseInput;
  161. //! Gamepad handler
  162. ccGamepadManager* m_gamepadManager;
  163. private:
  164. //! Associated GUI
  165. Ui::ccViewerClass ui;
  166. };