Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

150 lines
3.8 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef BOX3D_H
  8. #define BOX3D_H
  9. #pragma once
  10. #include "Tool3D.h"
  11. #include "BoundBox.h"
  12. class CMapView2D;
  13. class CRender3D;
  14. //
  15. // Formats for displaying world units.
  16. //
  17. enum WorldUnits_t
  18. {
  19. Units_None,
  20. Units_Inches,
  21. Units_Feet_Inches,
  22. };
  23. class Box3D : public Tool3D, public BoundBox
  24. {
  25. public:
  26. Box3D(void);
  27. static inline void SetWorldUnits(WorldUnits_t eWorldUnits);
  28. static inline WorldUnits_t GetWorldUnits(void);
  29. //
  30. // CBaseTool implementation.
  31. //
  32. virtual void SetEmpty();
  33. virtual void RenderTool2D(CRender2D *pRender);
  34. virtual void RenderTool3D(CRender3D *pRender);
  35. virtual void UpdateStatusBar();
  36. protected:
  37. enum
  38. {
  39. expandbox = 0x01,
  40. thicklines = 0x04,
  41. boundstext = 0x08,
  42. };
  43. enum TransformMode_t
  44. {
  45. modeNone = 0,
  46. modeMove,
  47. modeScale,
  48. modeRotate,
  49. modeShear,
  50. modeLast,
  51. };
  52. void StartNew( CMapView *pView, const Vector2D &vPoint, const Vector &vecStart, const Vector &vecSize);
  53. inline int GetTranslateMode() { return m_TranslateMode; }
  54. virtual void ToggleTranslateMode(void);
  55. void EnableHandles(bool bEnable);
  56. void SetDrawFlags(DWORD dwFlags);
  57. DWORD GetDrawFlags() { return m_dwDrawFlags; }
  58. void SetDrawColors(COLORREF dwHandleColor, COLORREF dwBoxColor);
  59. virtual void GetStatusString(char *pszBuf);
  60. unsigned long UpdateCursor(CMapView *pView, const Vector &vHandleHit, TransformMode_t eTransformMode);
  61. void HandleToWorld( Vector &vWorld, const Vector &vHandle, const Vector *pCustomHandleBox = NULL);
  62. const Vector NearestCorner(const Vector2D &vPoint, CMapView *pView, const Vector *pCustomHandleBox = NULL);
  63. int GetVisibleHandles( Vector *handles, CMapView *, int nMode );
  64. void RenderHandles2D(CRender2D *pRender, const Vector &mins, const Vector &maxs );
  65. void RenderHandles3D(CRender3D *pRender, const Vector &mins, const Vector &maxs);
  66. //
  67. // Tool3D implementation.
  68. //
  69. public:
  70. virtual int HitTest(CMapView *pView, const Vector2D &ptClient, bool bTestHandles = false);
  71. // If pCustomHandleBox is non-null, it points at an array 2 vectors (min and max), and
  72. // it will use those bounds to figure out the corners that it will align to the grid.
  73. virtual void StartTranslation( CMapView *pView, const Vector2D &vPoint, const Vector &vHandleOrigin, const Vector *pRefPoint = NULL, const Vector *pCustomHandleBox = NULL );
  74. virtual bool UpdateTranslation(const Vector &vUpdate, UINT uConstraints);
  75. virtual void FinishTranslation(bool bSave);
  76. virtual void TranslatePoint(Vector& pt);
  77. void TranslateBox(Vector& mins, Vector& maxs);
  78. virtual const VMatrix& GetTransformMatrix();
  79. protected:
  80. void UpdateTransformMatrix();
  81. static WorldUnits_t m_eWorldUnits;
  82. COLORREF m_clrHandle;
  83. COLORREF m_clrBox;
  84. TransformMode_t m_TranslateMode; // current translation mode
  85. Vector m_TranslateHandle; // current translation handle/corner
  86. Vector m_vTranslationFixPoint; // fix point, meaning it remains unchanged by translation, eg rotation center etc.
  87. VMatrix m_TransformMatrix;
  88. bool m_bEnableHandles; // check/show handles yes/no
  89. Vector m_LastHitTestHandle; // handle hit by last HitTest call
  90. TransformMode_t m_LastTranslateMode; // last translate mode
  91. bool m_bPreventOverlap;
  92. DWORD m_dwDrawFlags;
  93. };
  94. //-----------------------------------------------------------------------------
  95. // Purpose:
  96. //-----------------------------------------------------------------------------
  97. WorldUnits_t Box3D::GetWorldUnits(void)
  98. {
  99. return(m_eWorldUnits);
  100. }
  101. //-----------------------------------------------------------------------------
  102. // Purpose:
  103. //-----------------------------------------------------------------------------
  104. void Box3D::SetWorldUnits(WorldUnits_t eWorldUnits)
  105. {
  106. m_eWorldUnits = eWorldUnits;
  107. }
  108. #endif // BOX3D_H