acly.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. //
  2. //////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Copyright 2015 Autodesk, Inc. All rights reserved.
  5. //
  6. // Use of this software is subject to the terms of the Autodesk license
  7. // agreement provided at the time of installation or download, or which
  8. // otherwise accompanies this software in either electronic or hard copy form.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11. #ifndef _AC_LY_H
  12. #define _AC_LY_H
  13. #include "AdAChar.h"
  14. #include "acadstrc.h"
  15. #include "acarray.h"
  16. #include "dbsymtb.h"
  17. #include "dbxrecrd.h"
  18. class AcLySystemInternals;
  19. //Filter parse tree API (read-only)
  20. //
  21. //represents an relational expression of the form:
  22. //variable OP constant
  23. //where OP is either the equality operator (==) or the LIKE
  24. //operator
  25. //
  26. class AcLyRelExpr
  27. {
  28. public:
  29. virtual ~AcLyRelExpr() { }
  30. virtual const ACHAR * getVariable() const = 0;
  31. virtual const ACHAR * getConstant() const = 0;
  32. };
  33. //represents a term of the form:
  34. //a AND b
  35. class AcLyAndExpr
  36. {
  37. public:
  38. virtual ~AcLyAndExpr() { }
  39. virtual const AcArray<AcLyRelExpr*>& getRelExprs() const = 0;
  40. };
  41. //represents an expression of the form:
  42. //(a AND b) OR (c AND d) OR (e AND f)
  43. class AcLyBoolExpr
  44. {
  45. public:
  46. virtual ~AcLyBoolExpr() { }
  47. virtual const AcArray<AcLyAndExpr*>& getAndExprs() const = 0;
  48. };
  49. #ifndef HIMAGELIST
  50. struct _IMAGELIST;
  51. typedef struct _IMAGELIST* HIMAGELIST;
  52. #endif
  53. //Main filter API. All layer filters implement this interface.
  54. class AcLyLayerFilter : public AcRxObject, public AcHeapOperators
  55. {
  56. public:
  57. ACRX_DECLARE_MEMBERS(AcLyLayerFilter);
  58. AcLyLayerFilter ();
  59. virtual ~AcLyLayerFilter ();
  60. //persistent name of filter, some filters may not allow
  61. //renaming ("All", "Xref", etc.)
  62. virtual const ACHAR * name() const;
  63. virtual Acad::ErrorStatus setName(const ACHAR *);
  64. virtual bool allowRename() const;
  65. virtual Acad::ErrorStatus getImages(HIMAGELIST& imageList, Adesk::UInt32& normalImage, Adesk::UInt32& selected) const;
  66. virtual AcLyLayerFilter* parent() const;
  67. //nested filter manipulation
  68. virtual const AcArray<AcLyLayerFilter*>& getNestedFilters() const;
  69. virtual Acad::ErrorStatus addNested(AcLyLayerFilter* filter);
  70. virtual Acad::ErrorStatus removeNested(AcLyLayerFilter* filter);
  71. //some filters generate nested filters automatically (xref, standard)
  72. //the following api will be called on filters after they are loaded to allow
  73. //them to regenerate their nested filters
  74. virtual Acad::ErrorStatus generateNested();
  75. //returns true if this filter was dynamically generated i.e.
  76. //it doesn't persist on its own
  77. virtual bool dynamicallyGenerated() const;
  78. //returns true if this filter can have nested filters
  79. virtual bool allowNested() const;
  80. //returns true if this filter can be removed
  81. virtual bool allowDelete() const;
  82. //return true if this filter is a proxy for an
  83. //unknown filter (we are not going to show these on the UI)
  84. virtual bool isProxy() const;
  85. //groups are id filters, i.e. filters on layer id.
  86. virtual bool isIdFilter() const;
  87. //returns true if the given layer is "visible" with this filter
  88. //false otherwise
  89. virtual bool filter(AcDbLayerTableRecord* layer) const;
  90. //called by host application to show an editor window for the filter.
  91. //Display the editor as child of the active popup window
  92. //Return kUseDefault if you want to instruct the host application to
  93. //display the default filter dialog.
  94. enum DialogResult {kOk = 0, kCancel=1, kUseDefault = 2};
  95. virtual DialogResult showEditor();
  96. virtual const ACHAR * filterExpression() const;
  97. virtual Acad::ErrorStatus setFilterExpression(const ACHAR * expr);
  98. //returns a simple expression tree for this filter
  99. virtual const AcLyBoolExpr* filterExpressionTree() const;
  100. /*
  101. BNF for the valid boolean expression we evaluate
  102. <bool_expr>::= <bool_expr> or <and_expr> | <and_expr>
  103. <and_expr>::=<and_expr> and <rel_expr> | <rel_expr>
  104. <rel_expr>::=<variable><rel_op><constant>
  105. <rel_op>::= == | !=
  106. <constant>::=A-Z0-9*?~@.,-
  107. <variable>::=#A-Z0-9
  108. */
  109. //returns true if this and pOther will allow the same
  110. //layers
  111. virtual bool compareTo(const AcLyLayerFilter* pOther) const;
  112. //persistence support
  113. //
  114. //read/write native data, we use a dxf filer to decouple the filter
  115. //from the underlying xrecod. This is necessary to support custom filter
  116. //types.
  117. virtual Acad::ErrorStatus readFrom(AcDbDxfFiler* filer);
  118. virtual Acad::ErrorStatus writeTo(AcDbDxfFiler* pFiler) const;
  119. private:
  120. void *mp_impObj;
  121. friend class AcLySystemInternals;
  122. protected:
  123. AcLyLayerFilter(AcLySystemInternals*);
  124. };
  125. class AcLyLayerGroup : public AcLyLayerFilter
  126. {
  127. public:
  128. ACRX_DECLARE_MEMBERS(AcLyLayerGroup);
  129. AcLyLayerGroup();
  130. virtual Acad::ErrorStatus addLayerId (const AcDbObjectId& id);
  131. virtual Acad::ErrorStatus removeLayerId (const AcDbObjectId& id);
  132. virtual const AcDbObjectIdArray& layerIds () const;
  133. protected:
  134. AcLyLayerGroup(AcLySystemInternals*);
  135. };
  136. class AcLyLayerFilterManager
  137. {
  138. public:
  139. virtual ~AcLyLayerFilterManager() { }
  140. //reads the filters from the database this manager belongs to, and returns
  141. //the root filter in pRoot.
  142. //The caller is responsible for deleting the filters
  143. //by calling delete pRoot;
  144. virtual Acad::ErrorStatus getFilters(AcLyLayerFilter*& pRoot, AcLyLayerFilter*& pCurrent) = 0;
  145. //writes the filters pointer by pRoot into the current
  146. //database, call the various writeTo methods on each filter
  147. virtual Acad::ErrorStatus setFilters( const AcLyLayerFilter* pRoot, const AcLyLayerFilter* pCurrent) = 0;
  148. };
  149. //returns the filter manager for the given database
  150. AcLyLayerFilterManager* aclyGetLayerFilterManager(AcDbDatabase* pDb);
  151. #endif // _AC_LY_H