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.

117 lines
3.3 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Tool used for picking brush faces.
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TOOLPICKFACE_H
  8. #define TOOLPICKFACE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "MapFace.h"
  13. #include "ToolInterface.h"
  14. class CMapView3D;
  15. class CToolPickFace;
  16. //
  17. // Selection states for entries in our list of selected faces.
  18. //
  19. enum FaceState_t
  20. {
  21. FaceState_Select = 0, //
  22. FaceState_Partial, // Used for multiselect; the face is in at least one of the face lists being edited.
  23. FaceState_None, // Used for multiselect; to deselect partially selected faces. Otherwise they are removed from the list.
  24. };
  25. //
  26. // An entry in our list of selected faces.
  27. //
  28. struct SelectedFace_t
  29. {
  30. CMapFace *pFace; // Pointer to the face.
  31. FaceState_t eState; // The current selection state of this face.
  32. FaceState_t eOriginalState; // The original selection state of this face.
  33. };
  34. //
  35. // Interface for notification by the face picking tool. Inherit from this if you
  36. // are a client of the face picker.
  37. //
  38. class IPickFaceTarget
  39. {
  40. public:
  41. virtual void OnNotifyPickFace(CToolPickFace *pTool) = 0;
  42. };
  43. class CToolPickFace : public CBaseTool
  44. {
  45. public:
  46. //
  47. // Constructor/Destructor
  48. //
  49. CToolPickFace();
  50. ~CToolPickFace();
  51. //
  52. // CBaseTool virtual implementations
  53. //
  54. virtual void OnDeactivate();
  55. virtual ToolID_t GetToolID(void) { return TOOL_PICK_FACE; }
  56. virtual bool OnLMouseUp3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  57. virtual bool OnLMouseDown3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  58. virtual bool OnLMouseDblClk3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  59. virtual bool OnRMouseUp3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  60. virtual bool OnRMouseDown3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  61. virtual bool OnMouseMove3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
  62. //
  63. // Functions specific to this tool.
  64. //
  65. inline void Attach(IPickFaceTarget *pTarget);
  66. void AllowMultiSelect(bool bAllow);
  67. void GetSelectedFaces(CMapFaceList &FaceListFull, CMapFaceList &FaceListPartial);
  68. void SetSelectedFaces(CMapFaceList &FaceListFull, CMapFaceList &FaceListPartial);
  69. protected:
  70. void CycleSelectFace(CMapFace *pFace);
  71. void DeselectAll(void);
  72. void DeselectFace(int nIndex);
  73. void DeselectFace(CMapFace *pFace);
  74. int FindFace(CMapFace *pFace);
  75. void SelectFace(CMapFace *pFace);
  76. void AddToList(CMapFace *pFace, FaceState_t eState);
  77. void RemoveFromList(int nIndex);
  78. void SetEyedropperCursor(void);
  79. IPickFaceTarget *m_pNotifyTarget; // Object to notify when selection events occur.
  80. bool m_bAllowMultiSelect; // If false, only one face can be selected at a time.
  81. CUtlVector <SelectedFace_t> m_Faces; // Picked faces and their selection state (partial or full).
  82. };
  83. //-----------------------------------------------------------------------------
  84. // Purpose: Attaches the given notification target to this tool. That object
  85. // will be used for all future notifications and updates by the tool.
  86. //-----------------------------------------------------------------------------
  87. void CToolPickFace::Attach(IPickFaceTarget *pNotifyTarget)
  88. {
  89. m_pNotifyTarget = pNotifyTarget;
  90. }
  91. #endif // TOOLPICKFACE_H