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.

162 lines
5.4 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef SELECTION3D_H
  8. #define SELECTION3D_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "Box3D.h"
  13. #include "MapClass.h" // For CMapObjectList
  14. #include "ToolInterface.h"
  15. #include "UtlVector.h"
  16. class CMapWorld;
  17. class CMapView;
  18. class CMapView2D;
  19. class CMapView3D;
  20. class GDinputvariable;
  21. class CRender2D;
  22. class Selection3D : public Box3D
  23. {
  24. public:
  25. Selection3D();
  26. ~Selection3D();
  27. void Init( CMapDoc *pDocument );
  28. inline bool IsBoxSelecting();
  29. inline bool IsLogicalBoxSelecting();
  30. void EndBoxSelection();
  31. // Start, end logical selection
  32. void StartLogicalBoxSelection( CMapViewLogical *pView, const Vector &vStart );
  33. void EndLogicalBoxSelection( );
  34. // Tool3D implementation.
  35. virtual void SetEmpty();
  36. virtual bool IsEmpty();
  37. //
  38. // CBaseTool implementation.
  39. //
  40. virtual void OnActivate();
  41. virtual void OnDeactivate();
  42. virtual ToolID_t GetToolID() { return TOOL_POINTER; }
  43. virtual bool OnContextMenu2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint);
  44. virtual bool OnKeyDown2D(CMapView2D *pView, UINT nChar, UINT nRepCnt, UINT nFlags);
  45. virtual bool OnLMouseDown2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint);
  46. virtual bool OnLMouseUp2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint);
  47. virtual bool OnMouseMove2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint);
  48. virtual bool OnKeyDown3D(CMapView3D *pView, UINT nChar, UINT nRepCnt, UINT nFlags);
  49. virtual bool OnLMouseDblClk3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  50. virtual bool OnLMouseDown3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  51. virtual bool OnLMouseUp3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  52. virtual bool OnMouseMove3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  53. virtual void RenderTool2D(CRender2D *pRender);
  54. virtual void RenderToolLogical(CRender2D *pRender);
  55. virtual void RenderTool3D(CRender3D *pRender);
  56. virtual bool OnContextMenuLogical(CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint);
  57. virtual bool OnKeyDownLogical(CMapViewLogical *pView, UINT nChar, UINT nRepCnt, UINT nFlags);
  58. virtual bool OnLMouseDownLogical(CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint);
  59. virtual bool OnLMouseUpLogical(CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint);
  60. virtual bool OnMouseMoveLogical(CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint);
  61. virtual bool OnLMouseDblClkLogical(CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint);
  62. void UpdateSelectionBounds();
  63. bool m_bBoxSelection;
  64. protected:
  65. void TransformSelection();
  66. void TransformLogicalSelection( const Vector2D &vecTranslation );
  67. void FinishTranslation(bool bSave, bool bClone );
  68. void StartTranslation(CMapView *pView, const Vector2D &vPoint, const Vector &vHandleOrigin );
  69. bool StartBoxSelection( CMapView *pView, const Vector2D &vPoint, const Vector &vStart);
  70. void UpdateHandleState();
  71. virtual unsigned int GetConstraints(unsigned int nKeyFlags);
  72. void NudgeObjects(CMapView *pView, int nChar, bool bSnap, bool bClone);
  73. GDinputvariable *ChooseEyedropperVar(CMapView *pView, CUtlVector<GDinputvariable *> &VarList);
  74. CMapEntity *FindEntityInTree(CMapClass *pObject);
  75. void SelectInBox(CMapDoc *pDoc, bool bInsideOnly);
  76. CBaseTool *GetToolObject( CMapView2D *pView, const Vector2D &ptScreen, bool bAttach );
  77. CBaseTool *GetToolObjectLogical( CMapViewLogical *pView, const Vector2D &vPoint, bool bAttach );
  78. void SetEyedropperCursor();
  79. void EyedropperPick2D(CMapView2D *pView, const Vector2D &vPoint);
  80. void EyedropperPick3D(CMapView3D *pView, const Vector2D &vPoint);
  81. void EyedropperPick(CMapView *pView, CMapClass *pObject);
  82. void OnEscape(CMapDoc *pDoc);
  83. //
  84. // Tool3D implementation.
  85. //
  86. virtual int HitTest(CMapView *pView, const Vector2D &pt, bool bTestHandles = false);
  87. // Methods related to logical operations
  88. void EyedropperPickLogical( CMapViewLogical *pView, const Vector2D &vPoint );
  89. bool HitTestLogical( CMapView *pView, const Vector2D &ptClient );
  90. void SelectInLogicalBox(CMapDoc *pDoc, bool bInsideOnly);
  91. CSelection *m_pSelection; // the documents selection opject
  92. bool m_bEyedropper; // True if we are holding down the eyedropper hotkey.
  93. bool m_bSelected; // Did we select an object on left button down?
  94. bool m_b3DEditMode; // editing mode in 3D on/off
  95. bool m_bDrawAsSolidBox; // sometimes we want to render the tool bbox solid
  96. // These are fields related to manipulation in logical views
  97. Vector2D m_vLDownLogicalClient; // Logical client pos at which lbutton was pressed.
  98. Vector2D m_vecLogicalSelBoxMins;
  99. Vector2D m_vecLogicalSelBoxMaxs;
  100. bool m_bInLogicalBoxSelection; // Are we doing box selection in the logical mode?
  101. COLORREF m_clrLogicalBox; // The color of the logical box
  102. Vector2D m_vLastLogicalDragPoint; // Last point at which we dragged (world coords)
  103. Vector2D m_vLogicalTranslation;
  104. bool m_bIsLogicalTranslating; // true while translation in logical view
  105. bool m_bLButtonDown;
  106. bool m_bLeftDragged;
  107. };
  108. //-----------------------------------------------------------------------------
  109. // Are we in box selection?
  110. //-----------------------------------------------------------------------------
  111. inline bool Selection3D::IsBoxSelecting()
  112. {
  113. return m_bBoxSelection;
  114. }
  115. inline bool Selection3D::IsLogicalBoxSelecting()
  116. {
  117. return m_bInLogicalBoxSelection;
  118. }
  119. #endif // SELECTION3D_H