Team Fortress 2 Source Code as on 22/4/2020
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.

115 lines
3.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: The document. Exposes functions for object creation, deletion, and
  4. // manipulation. Holds the current tool. Handles GUI messages that are
  5. // view-independent.
  6. //
  7. //=============================================================================//
  8. #ifndef SELECTIONMANAGER_H
  9. #define SELECTIONMANAGER_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "mapclass.h"
  14. class CMapDoc;
  15. enum
  16. {
  17. hitFirst = 0,
  18. hitNext = -1,
  19. hitPrev = -2
  20. };
  21. // SelectObject/SelectFace parameters:
  22. typedef enum
  23. {
  24. scToggle = 0x01, // toogle selection state of this object
  25. scSelect = 0x02, // select this object
  26. scUnselect = 0x04, // unselect this object
  27. scClear = 0x10, // Clear current before selecting
  28. scNoLift = 0x20, // Don't lift face attributes into Face Properties dialog dvs: lame!
  29. scNoApply = 0x40, // Don't apply face attributes from Face Properties dialog to selected face dvs: lame!
  30. scCascading = 0x80, // Select all entities attached to outputs of this entity
  31. scCascadingRecursive = 0x100, // Select all entities attached to outputs of this entity, recursively
  32. scSelectAll = 0x200,
  33. scSaveChanges = 0x400, // changing the selection causes changes made in the properties dialog be saved
  34. };
  35. class CSelection
  36. {
  37. public:
  38. CSelection(void);
  39. virtual ~CSelection(void);
  40. void Init(CMapDoc *pDocument);
  41. bool SelectObject(CMapClass *pobj, int cmd = scSelect);
  42. void SelectObjectList(const CMapObjectList *pList, int cmd = (scClear|scSelect|scSaveChanges) );
  43. bool RemoveAll(); // true if any elements were removed
  44. bool RemoveInvisibles(); // true if any elements were removed
  45. bool RemoveDead(); // true if any elements were removed
  46. int GetCount();
  47. bool IsEmpty();
  48. bool IsSelected(CMapClass *pObject);
  49. bool IsAnEntitySelected();
  50. bool IsEditable();
  51. bool IsCopyable();
  52. const CMapObjectList* GetList(void);
  53. CMapDoc *GetMapDoc() { return m_pDocument; }
  54. // HitList feature
  55. const CMapObjectList* GetHitList(void);
  56. void ClearHitList();
  57. void AddHit(CMapClass *pObject);
  58. void SetCurrentHit(int iIndex, bool bCascading = false);
  59. SelectMode_t GetMode(void);
  60. void SetMode(SelectMode_t eSelectMode);
  61. void SetSelectionState(SelectionState_t eSelectionState);
  62. bool GetBounds(Vector &vecMins, Vector &vecMaxs);
  63. // Used for translations. Uses entity origins and brush bounds. That way, when moving stuff,
  64. // the entity origins will stay on the grid.
  65. void GetBoundsForTranslation( Vector &vecMins, Vector &vecMaxs );
  66. bool GetBoundsCenter(Vector &vecCenter);
  67. void GetLastValidBounds(Vector &vecMins, Vector &vecMaxs);
  68. bool GetLogicalBounds(Vector2D &vecMins, Vector2D &vecMaxs);
  69. bool GetLogicalBoundsCenter( Vector2D &vecCenter );
  70. void SetBoundsDirty() {m_bBoundsDirty = true;}
  71. protected:
  72. void UpdateSelectionBounds();
  73. CMapDoc *m_pDocument; // document this selection set belongs to
  74. SelectMode_t m_eSelectMode; // Controls what gets selected based on what the user clicked on.
  75. CMapObjectList m_SelectionList; // The list of selected objects.
  76. bool m_bBoundsDirty; // recalc bounds box with next query
  77. BoundBox m_Bounds; // current bounds
  78. BoundBox m_LastValidBounds; // last valid selection bounds
  79. Vector2D m_vecLogicalMins; // Selection bounds in "logical" space
  80. Vector2D m_vecLogicalMaxs;
  81. // Hit selection.
  82. CMapObjectList m_HitList; // list of 'hit' object (potential selected object)
  83. int m_iCurHit; // current hit or -1
  84. };
  85. #endif // SELECTIONMANAGER_H