ccColorScalesManager.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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: EDF R&D / TELECOM ParisTech (ENST-TSI) #
  15. //# #
  16. //##########################################################################
  17. #ifndef CC_COLOR_SCALES_MANAGER_HEADER
  18. #define CC_COLOR_SCALES_MANAGER_HEADER
  19. //Local
  20. #include "ccColorScale.h"
  21. //Qt
  22. #include <QMap>
  23. //! Color scales manager/container
  24. class QCC_DB_LIB_API ccColorScalesManager
  25. {
  26. public:
  27. //! Returns unique instance
  28. static ccColorScalesManager* GetUniqueInstance();
  29. //! Releases unique instance
  30. static void ReleaseUniqueInstance();
  31. //! Destructor
  32. virtual ~ccColorScalesManager();
  33. //! Pre-defined color scales (all relative - i.e. expand to actual SF)
  34. enum DEFAULT_SCALES { BGYR = 0, /**< Blue-Green-Yellow-Red ramp (default for distances display) */
  35. GREY = 1, /**< Grey ramp (default for Global Illumination) */
  36. BWR = 2, /**< Blue-White-Red ramp (for signed SF)*/
  37. RY = 3, /**< Red-Yellow ramp */
  38. RW = 4, /**< Red-White ramp */
  39. ABS_NORM_GREY = 5, /**< Absolute normalized grey ramp (intensities between 0 and 1) */
  40. HSV_360_DEG = 6, /**< HSV colors between 0 and 360 degrees */
  41. VERTEX_QUALITY = 7, /**< Mesh vertex quality (see CCCoreLib::MeshSamplingTools::VertexFlags) */
  42. DIP_BRYW = 8, /**< Dip (0 - 90 degrees) (Brown-Red-Yellow-White) */
  43. DIP_DIR_REPEAT = 9, /**< Dip direction (0 - 360 degrees) */
  44. VIRIDIS = 10, /**< matplotlib library colorscale created by Stéfan van der Walt and Nathaniel Smith */
  45. BROWN_YELLOW = 11, /**< Brown-Yellow */
  46. YELLOW_BROWN = 12, /**< Yellow-Brown */
  47. TOPO_LANDSERF = 13, /**< Topo Landserf (quartile) */
  48. HIGH_CONTRAST = 14, /**< High contrast */
  49. CIVIDIS = 15, /**< matplotlib library colorscale - see https://arxiv.org/ftp/arxiv/papers/1712/1712.01662.pdf */
  50. };
  51. //! Returns a pre-defined color scale UUID
  52. static QString GetDefaultScaleUUID(int scale) { return QString::number(scale); }
  53. //! Returns a pre-defined color scale (static shortcut)
  54. static ccColorScale::Shared GetDefaultScale(DEFAULT_SCALES scale = BGYR)
  55. {
  56. ccColorScalesManager* instance = GetUniqueInstance();
  57. return instance ? instance->getDefaultScale(scale) : ccColorScale::Shared(nullptr);
  58. }
  59. //! Returns a pre-defined color scale
  60. ccColorScale::Shared getDefaultScale(DEFAULT_SCALES scale) const { return getScale(GetDefaultScaleUUID(scale)); }
  61. //! Returns a color scale based on its UUID
  62. ccColorScale::Shared getScale(QString UUID) const;
  63. //! Adds a new color scale
  64. void addScale(ccColorScale::Shared scale);
  65. //! Removes a color scale
  66. /** Warning: can't remove default scales!
  67. **/
  68. void removeScale(QString UUID);
  69. //! Color scales map type
  70. typedef QMap< QString, ccColorScale::Shared > ScalesMap;
  71. //! Access to the internal map
  72. ScalesMap& map() { return m_scales; }
  73. //! Access to the internal map (const)
  74. const ScalesMap& map() const { return m_scales; }
  75. //! Loads custom color scales from persistent settings
  76. void fromPersistentSettings();
  77. //! Save custom color scales to persistent settings
  78. void toPersistentSettings() const;
  79. protected:
  80. //! Default constructor
  81. ccColorScalesManager();
  82. //! Creates a pre-defined color scale
  83. static ccColorScale::Shared Create(DEFAULT_SCALES scaleType);
  84. //! Color scales
  85. ScalesMap m_scales;
  86. };
  87. #endif //CC_COLOR_SCALES_MANAGER_HEADER