ccShiftAndScaleCloudDlg.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. #ifndef CC_RECENTER_CLOUD_DIALOG
  2. #define CC_RECENTER_CLOUD_DIALOG
  3. //local
  4. #include "qCC_io.h"
  5. #include "ccGlobalShiftManager.h"
  6. //Qt
  7. #include <QDialog>
  8. //CCCoreLib
  9. #include <CCGeom.h>
  10. class Ui_GlobalShiftAndScaleDlg;
  11. class QAbstractButton;
  12. //! Dialog for selection of cloud center
  13. class QCC_IO_LIB_API ccShiftAndScaleCloudDlg : public QDialog
  14. {
  15. Q_OBJECT
  16. public:
  17. //! Default constructor
  18. /** \param Pg a point expressed in the original coordinate system
  19. \param Dg bounding box diagonal in the original coordinate system (or <= 0 to ignore)
  20. \param parent parent widget
  21. **/
  22. ccShiftAndScaleCloudDlg(const CCVector3d& Pg, double Dg = 0, QWidget* parent = nullptr);
  23. //! Reverse mode constructor
  24. /** \param Pl a point expressed in the local coordinate system
  25. \param Dl bounding box diagonal in the local coordinate system
  26. \param Pg a point expressed in the original coordinate system
  27. \param Dg bounding box diagonal in the original coordinate system
  28. \param parent parent widget
  29. **/
  30. ccShiftAndScaleCloudDlg(const CCVector3d& Pl, double Dl, const CCVector3d& Pg, double Dg, QWidget* parent= nullptr);
  31. //! Sets the Shift fields (X, Y and Z) precision (default should be 2)
  32. void setShiftFieldsPrecision(int precision);
  33. //! Destructor
  34. virtual ~ccShiftAndScaleCloudDlg();
  35. //! Returns shift
  36. CCVector3d getShift() const;
  37. //! Returns scale
  38. double getScale() const;
  39. //! Whether shift should be applied to all files
  40. bool applyAll() const { return m_applyAll; }
  41. //! Whether the user has clicked on the cancel button or not
  42. bool cancelled() const { return m_cancel; }
  43. //! Whether to show dialog items related to scale
  44. void showScaleItems(bool state);
  45. //! Whether to show the 'Apply all' button or not
  46. void showApplyAllButton(bool state);
  47. //! Whether to show the 'Apply' button or not
  48. void showApplyButton(bool state);
  49. //! Whether to show the 'No' button or not
  50. void showNoButton(bool state);
  51. //! Whether to show the 'Cancel' button or not
  52. void showCancelButton(bool state);
  53. //! Whether to show or not the warning about non pertinent shift information
  54. void showWarning(bool state);
  55. //! Whether to show or not the title
  56. void showTitle(bool state);
  57. //! Whether to show or not the 'Keep global position' checkbox
  58. void showKeepGlobalPosCheckbox(bool state);
  59. //! Returns whether the global position should be preserved or not
  60. bool keepGlobalPos() const;
  61. //! Sets whether the global position should be preserved or not
  62. void setKeepGlobalPos(bool state);
  63. //! Whether to show or not the 'Preserve shift on save' checkbox
  64. void showPreserveShiftOnSave(bool state);
  65. //! Returns whether the global shift should be preserved or not
  66. bool preserveShiftOnSave() const;
  67. //! Sets whether the global shift should be preserved or not
  68. void setPreserveShiftOnSave(bool state);
  69. //! Adds shift info to the combox
  70. /** \param info shift info
  71. \return index in combo-box
  72. **/
  73. int addShiftInfo(const ccGlobalShiftManager::ShiftInfo& info);
  74. //! Adds shift info to the combox
  75. /** \param info shift info
  76. \return index in combo-box
  77. **/
  78. int addShiftInfo(const std::vector<ccGlobalShiftManager::ShiftInfo>& info);
  79. //! Returns a given input info
  80. bool getInfo(size_t index, ccGlobalShiftManager::ShiftInfo& info) const;
  81. //! Returns the number of info currently stored
  82. size_t infoCount() const { return m_defaultInfos.size(); }
  83. //! Sets the current combo-box entry (profile)
  84. void setCurrentProfile(int index);
  85. //! Sets the last shift and scale information
  86. static void SetLastInfo(const CCVector3d& shift, double scale);
  87. protected:
  88. //! Slot called when the 'loadComboBox' index changes
  89. void onLoadIndexChanged(int);
  90. //! Slot called when the 'Keep global position' checkbox is toggled
  91. void onGlobalPosCheckBoxToggled(bool);
  92. //! Analyzes the clicked button
  93. void onClick(QAbstractButton* button);
  94. //! Updates info on the global and local coordinate systems
  95. void updateGlobalAndLocalSystems();
  96. //! Displays more info about global shift mechanism
  97. void displayMoreInfo();
  98. protected:
  99. //! Initialization routine
  100. void init();
  101. //! Sets displayed shift
  102. void setShift(const CCVector3d& shift);
  103. //! Sets displayed scale
  104. void setScale(double scale);
  105. //! Updates info on the local coordinate system
  106. void updateLocalSystem();
  107. //! Updates info on the global coordinate system
  108. void updateGlobalSystem();
  109. //! Associated UI
  110. Ui_GlobalShiftAndScaleDlg* m_ui;
  111. //! Whether shift should be applied to all files
  112. bool m_applyAll;
  113. //! Whether the user has clicked on Cancel or not
  114. bool m_cancel;
  115. //! Default infos (typically loaded from the global_shift_list.txt' file)
  116. std::vector<ccGlobalShiftManager::ShiftInfo> m_defaultInfos;
  117. //! Active info entry index
  118. int m_activeInfoIndex;
  119. //! Original coordinate system point
  120. CCVector3d m_originalPoint;
  121. //! Original coordinate system diagonal
  122. double m_originalDiagonal;
  123. //! Local coordinate system point (reversed mode only)
  124. CCVector3d m_localPoint;
  125. //! Local coordinate system diagonal (reversed mode only)
  126. double m_localDiagonal;
  127. //! Whether the reverse mode is active or not
  128. bool m_reversedMode;
  129. };
  130. #endif