ccColorFromScalarDlg.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 or later 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: CloudCompare project #
  15. //# #
  16. //##########################################################################
  17. #ifndef CC_FROM_SCALAR_DLG_HEADER
  18. #define CC_FROM_SCALAR_DLG_HEADER
  19. //Qt
  20. #include <QColor>
  21. //CC
  22. #include <ccColorScale.h>
  23. #include <ccHistogramWindow.h>
  24. #include <ccScalarField.h>
  25. class ccPointCloud;
  26. namespace Ui {
  27. class ColorFromScalarDialog;
  28. }
  29. //! Dialog to change the color levels
  30. class ccColorFromScalarDlg : public QDialog
  31. {
  32. Q_OBJECT
  33. public:
  34. //! Default constructor
  35. ccColorFromScalarDlg(QWidget* parent, ccPointCloud* pointCloud);
  36. ~ccColorFromScalarDlg();
  37. static constexpr int c_channelCount = 4;
  38. void refreshDisplay();
  39. //update and redraw histograms
  40. void updateHistogram(int);
  41. protected:
  42. //events to set scalar fields
  43. void onChannelChangedR(int) { updateChannel(0); }
  44. void onChannelChangedG(int) { updateChannel(1); }
  45. void onChannelChangedB(int) { updateChannel(2); }
  46. void onChannelChangedA(int) { updateChannel(3); }
  47. void updateChannel(int);
  48. void updateSpinBoxLimits(int);
  49. void setDefaultSatValuePerChannel(int);
  50. void updateColormaps();
  51. //mapping ranges changed
  52. void minChangedR(double val) { minChanged(0, val, true); }
  53. void maxChangedR(double val) { maxChanged(0, val, true); }
  54. void minChangedG(double val) { minChanged(1, val, true); }
  55. void maxChangedG(double val) { maxChanged(1, val, true); }
  56. void minChangedB(double val) { minChanged(2, val, true); }
  57. void maxChangedB(double val) { maxChanged(2, val, true); }
  58. void minChangedA(double val) { minChanged(3, val, true); }
  59. void maxChangedA(double val) { maxChanged(3, val, true); }
  60. void minSpinChangedR(double val) { minChanged(0, val, false); }
  61. void maxSpinChangedR(double val) { maxChanged(0, val, false); }
  62. void minSpinChangedG(double val) { minChanged(1, val, false); }
  63. void maxSpinChangedG(double val) { maxChanged(1, val, false); }
  64. void minSpinChangedB(double val) { minChanged(2, val, false); }
  65. void maxSpinChangedB(double val) { maxChanged(2, val, false); }
  66. void minSpinChangedA(double val) { minChanged(3, val, false); }
  67. void maxSpinChangedA(double val) { maxChanged(3, val, false); }
  68. void toggleFixedR() { updateChannel(0);}
  69. void toggleFixedG() { updateChannel(1);}
  70. void toggleFixedB() { updateChannel(2);}
  71. void toggleFixedA() { updateChannel(3);}
  72. void toggleColors(int val);
  73. void toggleColorMode(bool state);
  74. void minChanged(int n, double val, bool slider);
  75. void maxChanged(int n, double val, bool slider);
  76. //done!
  77. void onApply();
  78. void disableAllButCancel();
  79. protected:
  80. void resizeEvent(QResizeEvent* event);
  81. bool m_prevFixed[c_channelCount];
  82. //! Associated histogram view
  83. ccHistogramWindow *m_histograms[c_channelCount]; //0 - red, 1 - green, 2 - blue, 3 - alpha
  84. //scalar fields
  85. ccScalarField *m_scalars[c_channelCount]; //0 - red, 1 - green, 2 - blue, 3 - alpha
  86. //gui elements
  87. QComboBox* m_combos[c_channelCount];
  88. QDoubleSpinBox* m_boxes_min[c_channelCount];
  89. QDoubleSpinBox* m_boxes_max[c_channelCount];
  90. QLabel* m_labels_min[c_channelCount];
  91. QLabel* m_labels_max[c_channelCount];
  92. QCheckBox* m_reverse[c_channelCount];
  93. //saturation values
  94. double m_minSat[c_channelCount];
  95. double m_maxSat[c_channelCount];
  96. //! Associated colour scales
  97. ccColorScale::Shared m_colors[c_channelCount];
  98. //! Associated point cloud (color source)
  99. ccPointCloud* m_cloud;
  100. //! Associated point cloud scalar field original scale (to restore on exit)
  101. ccColorScale::Shared m_storedOrigColorScale;
  102. ccScalarField::Range m_storedOrigSatRange;
  103. ccScalarField::Range m_storedOrigDisplayRange;
  104. //set true when catastrophic failure has occured
  105. bool m_systemInvalid;
  106. private:
  107. Ui::ColorFromScalarDialog *m_ui;
  108. };
  109. #endif //CC_COLOR_LEVELS_DLG_HEADER