zjf
2023-03-06 392b76515f40376b6d36f40a114850ef63650384
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
/////////////////////////////////////////////////////////////////////////////// 
// Copyright (C) 2002-2016, Open Design Alliance (the "Alliance"). 
// All rights reserved. 
// 
// This software and its documentation and related materials are owned by 
// the Alliance. The software may only be incorporated into application 
// programs owned by members of the Alliance, subject to a signed 
// Membership Agreement and Supplemental Software License Agreement with the
// Alliance. The structure and organization of this software are the valuable  
// trade secrets of the Alliance and its suppliers. The software is also 
// protected by copyright law and international treaty provisions. Application  
// programs incorporating this software must include the following statement 
// with their copyright notices:
//   
//   This application incorporates Teigha(R) software pursuant to a license 
//   agreement with Open Design Alliance.
//   Teigha(R) Copyright (C) 2002-2016 by Open Design Alliance. 
//   All rights reserved.
//
// By use of this software, its documentation or related materials, you 
// acknowledge and accept the above terms.
///////////////////////////////////////////////////////////////////////////////
 
 
 
#ifndef _OD_LY_H
#define _OD_LY_H
 
#include "TD_PackPush.h"
 
#include "RxObject.h"
#include "OdArray.h"
#include "DbObjectId.h"
#include "IdArrays.h"
 
 
class OdLyLayerFilter;
/** \details
  This template class is a specialization of the OdSmartPtr class for OdLyLayerFilter object pointers.
*/
typedef OdSmartPtr<OdLyLayerFilter> OdLyLayerFilterPtr;
/** \details
  This template class is a specialization of the OdArray class for OdLyLayerFilter object pointers.
*/
typedef OdArray<OdLyLayerFilterPtr> OdLyLayerFilterArray;
 
class OdDbLayerTableRecord;
class OdDbDxfFiler;
class OdLySystemInternals;
 
/** \details
            
    Library: TD_Db
 
    <group OdLy_Classes> 
*/
class OdLyRelExpr
{
public:
    virtual ~OdLyRelExpr() {}
    virtual const OdString& getConstant() const = 0;
    virtual const OdString& getVariable() const = 0;
protected:
    OdLyRelExpr() {}
};
 
/** \details
            
    Library: TD_Db
 
    <group OdLy_Classes> 
*/
class OdLyAndExpr
{
public:
    virtual ~OdLyAndExpr() {}
    virtual const OdArray<OdLyRelExpr*>& getRelExprs() const = 0;
protected:
    OdLyAndExpr() {}
};
 
/** \details
            
    Library: TD_Db
 
    <group OdLy_Classes> 
*/
class OdLyBoolExpr
{
public:
    virtual ~OdLyBoolExpr() {}
    virtual const OdArray<OdLyAndExpr*>& getAndExprs() const = 0;
protected:
    OdLyBoolExpr() {}
};
 
/** \details
    This class implements LayerFilter objects. 
 
    \remarks
    This class allows the client to specify, retrieve, and nest and unnest LayerFilters,
    and to determine if a layer is visible with for LayerFilter object.
    
    All Layer Filters implement this interface.
    \sa
    TD_Db
    <group OdLy_Classes> 
*/
class TOOLKIT_EXPORT OdLyLayerFilter : public OdRxObject
{
public:
  ODRX_DECLARE_MEMBERS(OdLyLayerFilter);
  OdLyLayerFilter();
  virtual ~OdLyLayerFilter();
  
  /** \details
    Returns the name of this LayerFilter object.
  */
  virtual const OdString& name() const;
  
  /** \details
    Sets the name of this LayerFilter object.
    \param name [in]  Name.
    
    \remarks
    Returns true if and only if successful.
 
    Some LayerFilter objects do not allow renamimg; e.g., "All", "Xref".
 
  */
  virtual bool setName(
    const OdString& name);
    
  /** \details
    Returns true if and only if this LayerFilter object can be renamed.
 
    \remarks
    Some LayerFilter objects do not allow renamimg; e.g., "All", "Xref".
  */
  virtual bool allowRename() const;
 
  /** \details
    Returns the parent LayerFilter of this LayerFilter object.
 
    \remarks
    All LayerFilter objects, except the top level, "ALL", have parents.
  */
  virtual OdLyLayerFilter* parent() const;
  
  /** \details
    Returns the nested LayerFilters of this LayerFilter object.
  */
  virtual const OdLyLayerFilterArray& getNestedFilters() const;
 
  /** \details
    Adds the specified LayerFilter as a nested LayerFilter to this LayerFilter object.
    \param pLayerFilter [in]  Pointer to the LayerFilter to nest.
  */
  virtual void addNested(
    OdLyLayerFilter* pLayerFilter);
    
  /** \details
    Removes the specified LayerFilter as a nested LayerFilter of this LayerFilter object.
    \param pLayerFilter [in]  Pointer to the LayerFilter to remove.
  */
  virtual void removeNested(
    OdLyLayerFilter* pLayerFilter);
  
  /** \details
    Notification function called after a LayerFilter is loaded.
    
    \remarks
    This is an opportunity for a LayerFilter to automatically generate its nested filters.
  */
  virtual OdResult generateNested();
  
  
  /** \details
    Returns true if and only if this LayerFilter was dynamically generated.
    
    \remarks
    True indicates that this LayerFilter should not be persisted.
  */
  virtual bool dynamicallyGenerated() const;
  
  /** \details
    Returns true if and only if this LayerFilter allows nested LayerFilters.
  */
  virtual bool allowNested() const;
  
  /** \details
    Returns true if and only if this LayerFilter can be deleted.
  */
  virtual bool allowDelete() const;
  
  /** \details
    Returns true if and only if this LayerFilter is a proxy LayerFilter.
  */
  virtual bool isProxy() const;
  
  /** \details
    Returns true if and only if this LayerFilter filters for the Object ID of a LayerTableRecord.
    
    \remarks
    These filters are known as LayerGroups.
  */
  virtual bool isIdFilter() const;
  
  /** \details
    Returns true if and only if the specified layer is visible with this LayerFilter object.
    \param layer [in]  Layer.
  */
  virtual bool filter(
    OdDbLayerTableRecord* layer) const;
  
  /** \details
    Returns the filter expression for this LayerFilter object.
    
    BNF for the valid boolean expression:
    <bool_expr>::= <bool_expr> or <and_expr> | <and_expr>
    <and_expr>::=<and_expr> and <rel_expr> | <rel_expr>
    <rel_expr>::=<variable><rel_op><constant> 
    <rel_op>::= == | !=
    <constant>::=A-Z0-9*?~@.,-
    <variable>::=#A-Z0-9
 
    Supported variables are:
 
    NAME
    LOCKED
    PLOTTABLE
    LINETYPE
    LINEWEIGHT
    COLOR
    OFF
    FROZEN
    PLOTSTYLENAME
    NEWVPFROZEN
    VP
    VPFROZEN
    VPCOLOR
    VPLINETYPE
    VPLINEWEIGHT
  */
  virtual const OdString& filterExpression() const;
 
  /** \details
    Returns the filter expression for this LayerFilter object.
  */
  const OdLyBoolExpr* filterExpressionTree() const;
  
  /** \details
    Sets the filter expression for this LayerFilter object.
    \param filterExpression [in]  Filter expression.
  */
  virtual OdResult setFilterExpression(
     const OdString& filterExpression );
  
  
  /** \details
    Returns true if and only if this LayerFilter object and the specified LayerFilter
    object allow the same layers.
    \param pOther [in]  Pointer to the other LayerFilter.
  */
  virtual bool compareTo(
    const OdLyLayerFilter* pOther) const;
  
  /** \details
    Reads the DXF format data of this object from the specified filter.
    \param pFiler [in]  Pointer to the filer from which data are to be read.
  */
  virtual OdResult readFrom(
    OdDbDxfFiler* pFiler);
    
  /** \details
    Writes the DXF format data of this object to the specified filter.
    \param pFiler [in]  Pointer to the filer to which data are to be written.
  */
  virtual void writeTo(
    OdDbDxfFiler* pFiler) const;
  
private:
  void* m_pImpl;
  friend class OdLySystemInternals;
  
protected:
  OdLyLayerFilter( OdLySystemInternals* );
};
 
 
/** \details
    This class implements LayerGroup objects. 
 
    \remarks
    This class allows the client to specify, retrieve, and group and ungroup layers,
    and to determine if a layer is grouped within a LayerGroup object.
 
    \sa
    TD_Db
    <group OdLy_Classes> 
*/
class TOOLKIT_EXPORT OdLyLayerGroup : public OdLyLayerFilter
{
public:
  ODRX_DECLARE_MEMBERS(OdLyLayerGroup);
  OdLyLayerGroup();
  
  /** \details
    Adds the specified layer to this LayerGroup object.
    \param layerId [in]  Object ID of the OdDbLayerTableRecord.
  */
  virtual void addLayerId(
    const OdDbObjectId& layerId);
    
  /** \details
    Removes the specified layer to this LayerGroup object.
    \param layerId [in]  Object ID of the OdDbLayerTableRecord.
  */
  virtual void removeLayerId (
    const OdDbObjectId& layerId);
  
  /** \details
    Returns the LayerTableRecord Object IDs in this LayerGroup object.
  */
  virtual const OdDbObjectIdArray& layerIds() const;
  
protected:
  OdLyLayerGroup( OdLySystemInternals* );
};
 
typedef OdSmartPtr<OdLyLayerGroup> OdLyLayerGroupPtr;
 
/** \details
    This class simplifies accessing LayerFilter objects in the LayerTable extension dictionary.
    \sa
    TD_Db
    <group OdLy_Classes> 
*/
class OdLyLayerFilterManager : public OdRxObject
{
public:
  ODRX_DECLARE_MEMBERS(OdLyLayerFilterManager);
  /** \details
    Returns the root and current filters from the database containing this LayerFilterManager object.
    \param pRoot [out]  Receives a SmartPointer to the root filter.
    \param pCurrent [out]  Receives a SmartPointer to the filter current when setFilters() was last called.  
  */
  virtual OdResult getFilters(
    OdLyLayerFilterPtr& pRoot, 
    OdLyLayerFilterPtr& pCurrent ) = 0;
  
  /** \details
    Writes the filter tree and current filters to the database containing this LayerFilterManager object.
    \param pRoot [in]  Pointer to the root filter.
    \param pCurrent [in]  Pointer to the current filter to be persisted.  
  */
  virtual void setFilters(
    const OdLyLayerFilterPtr pRoot, 
    const OdLyLayerFilterPtr pCurrent ) = 0;
};
 
/** \details
  This template class is a specialization of the OdSmartPtr class for OdLyLayerFilterManager object pointers.
*/
typedef OdSmartPtr<OdLyLayerFilterManager> OdLyLayerFilterManagerPtr;
 
/** \details
  Returns a LayerFilterManager object for the specified database.
  \param pDb [in]  Pointer to the database.
*/
TOOLKIT_EXPORT OdLyLayerFilterManagerPtr odlyGetLayerFilterManager(
  OdDbDatabase* pDb );
 
#include "TD_PackPop.h"
 
#endif  // _OD_LY_H