dblstate.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2015 Autodesk, Inc. All rights reserved.
  4. //
  5. // Use of this software is subject to the terms of the Autodesk license
  6. // agreement provided at the time of installation or download, or which
  7. // otherwise accompanies this software in either electronic or hard copy form.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. //
  11. // DESCRIPTION: AcDbLayerStateManager class definition.
  12. //
  13. // WRITTEN: 11/99 by Anil Patel
  14. #ifndef ACDB_LSTATE_H
  15. #define ACDB_LSTATE_H
  16. #include "dbmain.h"
  17. #include "acarray.h"
  18. #include "acstring.h"
  19. #pragma pack(push, 8)
  20. class AcDbImpLayerStateManager;
  21. class AcDbLayerStateManagerReactor;
  22. class AcDbLayerStateManager: public AcRxObject
  23. {
  24. public:
  25. ACRX_DECLARE_MEMBERS(AcDbLayerStateManager);
  26. // Construction/destruction
  27. AcDbLayerStateManager();
  28. AcDbLayerStateManager(AcDbDatabase *pHostDb);
  29. virtual ~AcDbLayerStateManager();
  30. enum LayerStateMask {
  31. kNone = 0x0000,
  32. kOn = 0x0001,
  33. kFrozen = 0x0002,
  34. kLocked = 0x0004,
  35. kPlot = 0x0008,
  36. kNewViewport = 0x0010,
  37. kColor = 0x0020,
  38. kLineType = 0x0040,
  39. kLineWeight = 0x0080,
  40. kPlotStyle = 0x0100,
  41. kCurrentViewport = 0x0200,
  42. kTransparency = 0x0400,
  43. kAll = kOn | kFrozen | kLocked | kPlot | kNewViewport |
  44. kColor | kLineType | kLineWeight | kPlotStyle |
  45. kCurrentViewport | kTransparency,
  46. kStateIsHidden = 0x8000,
  47. kLastRestored = 0x10000,
  48. kDecomposition = kAll | 0x20000
  49. };
  50. enum {
  51. kUndefDoNothing = 0,
  52. kUndefTurnOff = 1,
  53. kUndefFreeze = 2,
  54. kRestoreAsOverrides = 4
  55. };
  56. bool addReactor(AcDbLayerStateManagerReactor * pReactor);
  57. bool removeReactor(AcDbLayerStateManagerReactor * pReactor);
  58. // Service methods
  59. AcDbObjectId layerStatesDictionaryId(bool bCreateIfNotPresent=false);
  60. bool hasLayerState(const ACHAR *sName);
  61. Acad::ErrorStatus saveLayerState(const ACHAR *sName, LayerStateMask mask);
  62. Acad::ErrorStatus restoreLayerState(const ACHAR *sName);
  63. Acad::ErrorStatus setLayerStateMask(const ACHAR *sName,
  64. LayerStateMask mask);
  65. Acad::ErrorStatus getLayerStateMask(const ACHAR *sName,
  66. LayerStateMask &returnMask);
  67. Acad::ErrorStatus deleteLayerState(const ACHAR *sName);
  68. Acad::ErrorStatus renameLayerState(const ACHAR *sName,
  69. const ACHAR *sNewName);
  70. Acad::ErrorStatus importLayerState(const ACHAR *sFilename);
  71. Acad::ErrorStatus importLayerState(const ACHAR *sFilename, AcString & sName);
  72. Acad::ErrorStatus exportLayerState(const ACHAR *sNameToExport,
  73. const ACHAR *sFilename);
  74. Acad::ErrorStatus saveLayerState(const ACHAR *sName, LayerStateMask mask, const AcDbObjectId& idVp);
  75. Acad::ErrorStatus restoreLayerState(const ACHAR *sName, const AcDbObjectId& idVp, int nRestoreFlags = 0, const LayerStateMask* pClientMask = NULL);
  76. Acad::ErrorStatus setLayerStateDescription(const ACHAR* sName,
  77. const ACHAR* sDesc);
  78. Acad::ErrorStatus getLayerStateDescription(const ACHAR* sName, ACHAR*& sDesc);
  79. bool layerStateHasViewportData(const ACHAR* sName);
  80. Acad::ErrorStatus importLayerStateFromDb(const ACHAR *pStateName, AcDbDatabase* pDb);
  81. Acad::ErrorStatus getLayerStateNames(AcStringArray& lsArray, bool bIncludeHidden = true, bool bIncludeXref = true);
  82. Acad::ErrorStatus getLastRestoredLayerState(AcString & sName, AcDbObjectId &restoredLSId);
  83. Acad::ErrorStatus getLayerStateLayers(AcStringArray& layerArray, const ACHAR* sName, bool bInvert = false);
  84. bool compareLayerStateToDb(const ACHAR* sName, const AcDbObjectId& idVp);
  85. Acad::ErrorStatus addLayerStateLayers(const ACHAR *sName, const AcDbObjectIdArray& layerIds);
  86. Acad::ErrorStatus removeLayerStateLayers(const ACHAR *sName, const AcStringArray& layerNames);
  87. bool isDependentLayerState(const ACHAR *sName);
  88. AcDbDatabase * getDatabase() const;
  89. private:
  90. friend class AcDbImpDatabase;
  91. AcDbImpLayerStateManager *mpImpLSM;
  92. };
  93. /////////////////////////////////////////////////////////////////////////////
  94. /////////////////////////////////////////////////////////////////////////////
  95. class AcDbLayerStateManagerReactor : public AcRxObject
  96. {
  97. public:
  98. ACRX_DECLARE_MEMBERS(AcDbLayerStateManagerReactor);
  99. virtual void layerStateCreated(const ACHAR * layerStateName,
  100. const AcDbObjectId& layerStateId);
  101. virtual void layerStateCompareFailed(const ACHAR * layerStateName,
  102. const AcDbObjectId& layerStateId);
  103. virtual void layerStateToBeRestored(const ACHAR * layerStateName,
  104. const AcDbObjectId& layerStateId);
  105. virtual void layerStateRestored(const ACHAR * layerStateName,
  106. const AcDbObjectId& layerStateId);
  107. virtual void abortLayerStateRestore(const ACHAR * layerStateName,
  108. const AcDbObjectId& layerStateId);
  109. virtual void layerStateToBeDeleted(const ACHAR * layerStateName,
  110. const AcDbObjectId& layerStateId);
  111. virtual void layerStateDeleted(const ACHAR * layerStateName);
  112. virtual void abortLayerStateDelete(const ACHAR * layerStateName,
  113. const AcDbObjectId& layerStateId);
  114. virtual void layerStateToBeRenamed(const ACHAR * oldLayerStateName,
  115. const ACHAR * newLayerStateName);
  116. virtual void layerStateRenamed(const ACHAR * oldLayerStateName,
  117. const ACHAR * newLayerStateName);
  118. virtual void abortLayerStateRename(const ACHAR * oldLayerStateName,
  119. const ACHAR * newLayerStateName);
  120. };
  121. #pragma pack(pop)
  122. #endif