ccCoordinateSystem.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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: Chris Brown #
  15. //# #
  16. //##########################################################################
  17. #pragma once
  18. //Local
  19. #include "ccGenericPrimitive.h"
  20. class ccPlane;
  21. //! Coordinate System (primitive)
  22. /** Coordinate System primitive
  23. **/
  24. class QCC_DB_LIB_API ccCoordinateSystem : public ccGenericPrimitive
  25. {
  26. public:
  27. //! Default constructor
  28. /** Coordinate System is essentially just a way to visualize a transform matrix.
  29. \param displayScale global scale/size
  30. \param axisWidth axes width
  31. \param transMat optional 3D transformation (can be set afterwards with ccDrawableObject::setGLTransformation)
  32. \param name name
  33. **/
  34. ccCoordinateSystem( PointCoordinateType displayScale,
  35. PointCoordinateType axisWidth,
  36. const ccGLMatrix* transMat = nullptr,
  37. QString name = QString("CoordinateSystem"));
  38. //! Default constructor
  39. /** Coordinate System is essentially just a way to visualize a transform matrix.
  40. \param transMat optional 3D transformation (can be set afterwards with ccDrawableObject::setGLTransformation)
  41. \param name name
  42. **/
  43. ccCoordinateSystem( const ccGLMatrix* transMat,
  44. QString name = QString("CoordinateSystem"));
  45. //! Simplified constructor
  46. /** For ccHObject factory only!
  47. **/
  48. ccCoordinateSystem(QString name = QString("CoordinateSystem"));
  49. //! Returns class ID
  50. virtual CC_CLASS_ENUM getClassID() const override { return CC_TYPES::COORDINATESYSTEM; }
  51. //inherited from ccGenericPrimitive
  52. virtual QString getTypeName() const override { return "CoordinateSystem"; }
  53. virtual ccGenericPrimitive* clone() const override;
  54. inline bool axisPlanesAreShown() const { return m_showAxisPlanes; }
  55. void showAxisPlanes(bool show) { m_showAxisPlanes = show; }
  56. inline bool axisLinesAreShown() const { return m_showAxisLines; }
  57. void showAxisLines(bool show) { m_showAxisLines = show; }
  58. //ccPlane get2AxisPlane(int axisNum);
  59. inline CCVector3 getOrigin() const { return m_transformation.getTranslationAsVec3D(); };
  60. inline PointCoordinateType getAxisWidth() const { return m_width; };
  61. void setAxisWidth(PointCoordinateType size);
  62. inline PointCoordinateType getDisplayScale() const { return m_DisplayScale; };
  63. void setDisplayScale(PointCoordinateType size);
  64. CCVector3 getXYPlaneNormal() const;
  65. CCVector3 getYZPlaneNormal() const;
  66. CCVector3 getZXPlaneNormal() const;
  67. //! Default Display scale
  68. static constexpr PointCoordinateType DEFAULT_DISPLAY_SCALE = 1.0;
  69. //! Minimum Display scale
  70. static constexpr float MIN_DISPLAY_SCALE_F = 0.001f;
  71. //! Default Axis line width
  72. static constexpr PointCoordinateType AXIS_DEFAULT_WIDTH = 4.0;
  73. //! Minimum Axis line width
  74. static constexpr float MIN_AXIS_WIDTH_F = 1.0f;
  75. //! Maximum Axis line width
  76. static constexpr float MAX_AXIS_WIDTH_F = 16.0f;
  77. protected:
  78. //inherited from ccDrawable
  79. void drawMeOnly(CC_DRAW_CONTEXT& context) override;
  80. //inherited from ccGenericPrimitive
  81. bool toFile_MeOnly(QFile& out, short dataVersion) const override;
  82. bool fromFile_MeOnly(QFile& in, short dataVersion, int flags, LoadedIDMap& oldToNewIDMap) override;
  83. short minimumFileVersion_MeOnly() const override;
  84. bool buildUp() override;
  85. ccPlane* createXYplane(const ccGLMatrix* transMat = nullptr) const;
  86. ccPlane* createYZplane(const ccGLMatrix* transMat = nullptr) const;
  87. ccPlane* createZXplane(const ccGLMatrix* transMat = nullptr) const;
  88. //! CoordinateSystem options
  89. PointCoordinateType m_DisplayScale;
  90. PointCoordinateType m_width;
  91. bool m_showAxisPlanes;
  92. bool m_showAxisLines;
  93. };