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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
/////////////////////////////////////////////////////////////////////////////// 
// 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_DBDIMASSOC_H
#define OD_DBDIMASSOC_H
 
#include "TD_PackPush.h"
 
#include "DbSubentId.h"
#include "DbHandle.h"
#include "DbObject.h"
 
class OdDbDwgFiler;
class OdDbDxfFiler;
class OdGePoint3d;
class OdDbIdMapping;
 
 
/** \details
    This class uniquely defines Xref subentities within an OdDbDatabase instance.  
 
    \remarks
    Each OdDbXrefFullSubentPath object consists of a OdDbSubentId object,
    an ordered array of Object IDs, and an ordered array of entity handles. 
    The SubentId consists the index and subentType
    of the object. The array of Object IDs, and the array of handles, define the path to the 
    subentity from the outermost entity (in PaperSpace or ModelSpace) 
    to the entity containing the subentity.
    
    Library: TD_Db
 
    <group OdDb_Classes>
*/
class TOOLKIT_EXPORT OdDbXrefFullSubentPath : public OdDbFullSubentPath
{
public:
  /** \details
    Returns a reference to the embedded OdHandleArray object in this XrefFullSubentPath object.
    
    \param objectIds [out]  Receives the array reference.
  */
  OdHandleArray& xrefObjHandles();
  const OdHandleArray& xrefObjHandles()const;
 
  /** \details
    Reads the .dwg file format data of this object from the specified file.
       
    \param pFiler [in]  Pointer to the filer from which the data are to be read.
  */
  void dwgIn(OdDbDwgFiler* pFiler);
 
  /** \details
    Writes the .dwg file format data of this object to the specified filer. 
    
    \param pFiler [in]  Pointer to the filer to which the data are to be written.
    
  */
  void dwgOut(OdDbDwgFiler* pFiler) const;
 
  /** \details
    Writes the DXF format data of this object to the specified filer. 
    
    \param pFiler [in]  Pointer to the filer to which the data are to be written.
    \param groupCodeOffset [in]  Group code offset.
  */
  void dxfOut(OdDbDxfFiler* pFiler, OdInt groupCodeOffset = 0) const;
private:
  OdHandleArray m_XrefObjHandles;
};
 
class OdDbOsnapPointRef;
class OdDbViewport;
/** \details
    This template class is a specialization of the OdSmartPtr class for OdDbOsnapPointRef object pointers.
*/
typedef OdSmartPtr<OdDbOsnapPointRef> OdDbOsnapPointRefPtr;
//typedef OdArray<OdDbFullSubentPath> OdDbFullSubentPathArray;
 
/** \details
    This class defines a point reference between a dimension and
    its corresponding object.
 
    Library: TD_Db
    <group OdDb_Classes>
*/
class TOOLKIT_EXPORT OdDbPointRef : public OdRxObject
{
public:
  ODRX_DECLARE_MEMBERS(OdDbPointRef);
 
  virtual OdResult evalPoint(OdGePoint3d& pnt_wcs) = 0; 
  virtual OdResult getEntities(OdDbFullSubentPathArray& ents, bool getLastPtRef = true) const = 0;
  virtual bool isGeomErased() const = 0;
  virtual bool isXrefObj(OdDbObjectIdArray& ids1, OdDbObjectIdArray& ids2, bool isMainObj = true) const = 0;
  virtual OdResult updateXrefSubentPath() = 0;
  virtual OdResult updateSubentPath(OdDbIdMapping& idMap) = 0;
 
  virtual void dwgOutFields(OdDbDwgFiler* filer) const = 0;
  virtual void dwgInFields(OdDbDwgFiler* filer) = 0;
  virtual void dxfOutFields(OdDbDxfFiler* filer) const = 0;
  virtual OdResult dxfInFields(OdDbDxfFiler* filer) = 0;
 
  virtual void updateDueToMirror(bool inMirror = false) = 0;
 
/** \details
  Calculates transformation combined from OdDbViewport's MS2PS and BlockReference transformations
*/
  static bool calcTransform(const OdDbObjectIdArray& ids, OdGeMatrix3d& A_Ecs2Wcs);
 
  /** \details
  Returns matrix to convert MS coordinates to PS for given OdDbViewport entity
  */
  static OdGeMatrix3d mswcsToPswcs(const OdDbViewport* pVPort);
/*
  static OdResult  dwgInFields(OdDbDwgFiler* filer, OdDbDatabase* pDb, OdDbPointRef*& pPointRef);
  static OdResult  dwgOutFields(OdDbDwgFiler* filer, OdDbDatabase* pDb, const OdDbPointRef* pPointRef);
  static OdResult  dxfInFields(OdDbDxfFiler* filer, OdDbDatabase* pDb, OdDbPointRef*& pPointRef);
  static OdResult  dxfOutFields(OdDbDxfFiler* filer, OdDbDatabase* pDb, const OdDbPointRef* pPointRef);
  static OdDbEntityPtr subentPtr(const OdDbFullSubentPath& objPath, bool& isCloned, bool& reverseArc, bool& isStandAloneArc);
  static OdGeMatrix3d wcsToDcsMatrix(const OdDbViewport* pVPort);
*/
};
 
/** \details
 
    <group OdDb_Classes>
*/
class TOOLKIT_EXPORT OdDbOsnapPointRef : public OdDbPointRef
{
public:
  OdDbOsnapPointRef();
 
  ODRX_DECLARE_MEMBERS(OdDbOsnapPointRef);
 
  /** \details
    Returns the object snap mode for this OsnapPointRef object.
    \remarks
    osnapMode() returns one of the following:
    
    <table>
    Name                      Value   Description 
    OdDb::kOsModeEnd          1       End Point
    OdDb::kOsModeMid          2       Mid Point
    OdDb::kOsModeCen          3       Center
    OdDb::kOsModeNode         4       Node
    OdDb::kOsModeQuad         5       Quadrant
    OdDb::kOsModeIntersec     6       Intersection
    OdDb::kOsModeIns          7       Insertion point
    OdDb::kOsModePerp         8       Perpendicular
    OdDb::kOsModeTan          9       Tangent
    OdDb::kOsModeNear         10      Nearest
    OdDb::kOsModeApint        11      Apparent intersection
    OdDb::kOsModePar          12      Parallel
    OdDb::kOsModeStart        13      Start Point 
    </table>
 
  */
  OdDb::OsnapMode osnapType() const;
  /** \details
    Sets the object snap mode for this OsnapPointRef object.
 
    \remarks
    osnapMode must be one of the following:
    
    <table>
    Name                      Value   Description 
    OdDb::kOsModeEnd          1       End Point
    OdDb::kOsModeMid          2       Mid Point
    OdDb::kOsModeCen          3       Center
    OdDb::kOsModeNode         4       Node
    OdDb::kOsModeQuad         5       Quadrant
    OdDb::kOsModeIntersec     6       Intersection
    OdDb::kOsModeIns          7       Insertion point
    OdDb::kOsModePerp         8       Perpendicular
    OdDb::kOsModeTan          9       Tangent
    OdDb::kOsModeNear         10      Nearest
    OdDb::kOsModeApint        11      Apparent intersection
    OdDb::kOsModePar          12      Parallel
    OdDb::kOsModeStart        13      Start Point
    </table>
  */
  void setOsnapType(OdDb::OsnapMode osnapMode);
 
  /** \details
    Returns a reference to the OdDbXrefFullSubentPath of the main entity for the OsnapPointRef object. 
  */
  OdDbXrefFullSubentPath& mainEntity();
  /** \details
    Returns a reference to the OdDbXrefFullSubentPath of the intersecting entity for the OsnapPointRef object. 
  */
  OdDbXrefFullSubentPath& intersectEntity();
 
  void getIdPath(OdDbFullSubentPath& idPath) const;
  void setIdPath(const OdDbFullSubentPath& idPath);
 
  void getIntIdPath(OdDbFullSubentPath& intIdPath) const;
  void setIntIdPath(const OdDbFullSubentPath& intIdPath);
 
  /** \details
    Returns the near Osnap value for this OsnapPointRef object.
  */
  double nearPointParam() const;
 
  /** \details
    Returns the near Osnap value for this OsnapPointRef object.
    \param nearOsnap [in]  Near Osnap value.
  */
  void setNearPointParam(double nearOsnap);
 
  /** \details
    Returns a reference to the Osnap point for this OsnapPointRef object.
  */
  OdGePoint3d point() const;
  void setPoint(const OdGePoint3d& pt);
 
  /** \details
    Returns the last OsnapPointRef for this OsnapPointRef object.
  */
  const OdDbOsnapPointRef* lastPointRef() const;
  OdDbOsnapPointRef* lastPointRef();
 
  /** \details
    Sets the last OsnapPointRef for this OsnapPointRef object.
    \param pOsnapPointRef [in]  Pointer to the last OsnapPointRef object.
  */
  void setLastPointRef(OdDbOsnapPointRefPtr pOsnapPointRef);
 
  virtual bool isGeomErased() const;
  virtual bool isXrefObj(OdDbObjectIdArray& ids1, OdDbObjectIdArray& ids2, bool isMainObj = true) const;
  virtual OdResult updateXrefSubentPath();
  virtual OdResult updateSubentPath(OdDbIdMapping& idMap);
  virtual OdResult evalPoint(OdGePoint3d &pt);
  virtual OdResult getEntities(OdDbFullSubentPathArray& ents, bool getLastPtRef = true) const;
  virtual void updateDueToMirror(bool inMirror = false);
 
  void getXrefHandles(OdHandleArray& xrefHandles) const;
  void setXrefHandles(const OdHandleArray& xrefHandles);
  void getXrefIntHandles(OdHandleArray& xrefHandles) const;
  void setXrefIntHandles(const OdHandleArray& xrefHandles);
 
  /** \details
    Reads the .dwg file format data of this object from the specified file.
       
    \param pFiler [in]  Pointer to the filer from which the data are to be read.
  */
  void dwgInFields(OdDbDwgFiler* pFiler);
  /** \details
    Writes the .dwg file format data of this object to the specified filer. 
    
    \param pFiler [in]  Pointer to the filer to which the data are to be written.
  */
  void dwgOutFields(OdDbDwgFiler* pFiler) const;
  /** \details
    Writes the DXF format data of this object to the specified filer. 
    
    \param pFiler [in]  Pointer to the filer to which the data are to be written.
  */
  void dxfOutFields(OdDbDxfFiler* pFiler) const;
  OdResult dxfInFields(OdDbDxfFiler* filer);
private:
  OdDb::OsnapMode        m_OsnapMode;
  OdDbXrefFullSubentPath m_MainEntity;
  OdDbXrefFullSubentPath m_IntersectEntity;
  double                 m_dNearOsnap;
  OdGePoint3d            m_OsnapPoint;
  OdDbOsnapPointRefPtr   m_pLastPointRef;
  bool                   m_bUpdateDueToMirror;
};
 
/** \details
    This class represents Associative Dimension objects in an OdDbDatabase instance.
 
    Library: TD_Db
    
    <group OdDb_Classes>
*/
class TOOLKIT_EXPORT OdDbDimAssoc : public OdDbObject
{
public:
  ODDB_DECLARE_MEMBERS(OdDbDimAssoc);
 
  OdDbDimAssoc();
 
  enum { kMaxPointRefs = 4 };
  
  enum PointType 
  {
    kXline1Point          = 0,
    kXline2Point          = 1,
    kOriginPoint          = 0,
    kDefiningPoint        = 1,
    kXline1Start          = 0,
    kXline1End            = 1,
    kXline2Start          = 2,
    kXline2End            = 3,
    kVertexPoint          = 2,
    kChordPoint           = 0,
    kCenterPoint          = 1,
    kFarChordPoint        = 1,
    kOverrideCenterPoint  = 2,
    kAngLineStart         = 2,
    kJogPoint             = 3,
    kAngLineEnd           = 3,
    kLeaderPoint          = 0
  };
 
  enum RotatedDimType
  {
    kUnknown       = 0,
    kParallel      = 1,
    kPerpendicular = 2
  };
 
  enum AssocFlags 
  {
    kFirstPointRef     = (1<<0),
    kSecondPointRef    = (1<<1),
    kThirdPointRef     = (1<<2),
    kFourthPointRef    = (1<<3)
  };
 
  virtual OdResult dwgInFields(OdDbDwgFiler* pFiler) ODRX_OVERRIDE;
  virtual void dwgOutFields(OdDbDwgFiler* pFiler) const ODRX_OVERRIDE;
  virtual OdResult dxfInFields(OdDbDxfFiler* pFiler) ODRX_OVERRIDE;
  virtual void dxfOutFields(OdDbDxfFiler* pFiler) const ODRX_OVERRIDE;
 
  /** \details
    Returns the Object ID of the Dimension entity associated with this Associative Dimension object (DXF 330).
  */
  OdDbObjectId dimObjId() const;
 
  /** \details
    Sets the Object ID of the Dimension entity associated with this Associative Dimension object (DXF 330).
    \param dimId [in]  Dimension Object ID.
  */
  void setDimObjId(const OdDbObjectId& dimId);
 
  /** \details
    Returns the associativity flag of this Associative Dimension object (DXF 90).
  */
  OdInt32 assocFlag() const;
 
  /** \details
    Returns the associativity flag of the specified Osnap Point Reference for this Associative Dimension object.
  */
  bool assocFlag(int pointIndex) const;
 
  void setAssocFlag(int assocFlag);
  // Sets the index of point reference being used and establishes or clears the association flag. 
  void setAssocFlag(int pointIndex, bool flagValue);
 
  /** \details
    Returns the specified Osnap Point Reference for this Associative Dimension object.
    
    \param pointIndex [in]  Point index. The value should be 0, 1, 2, 3 or from the PointType enum 
    
    \remarks
    pointIndex must be one of the following:
   
  */
  OdDbOsnapPointRefPtr pointRef(int pointIndex) const;
 
  /** \details
    Sets the specified Osnap Point Reference for this Associative Dimension object.
    
    \param pointIndex [in]  Point index. The value should be 0, 1, 2, 3 or from the PointType enum 
    \param pOsnapPointRef [in]  SmartPointer to the Osnap Point Reference.
  */
  void setPointRef(int pointIndex, OdDbOsnapPointRefPtr pOsnapPointRef);
 
  /** \details
  Returns the rotated dimension type of this Associative Dimension object (DXF 71).
 
  \remarks
  rotatedDimType() returns one of the following:
 
  <table>
  Name              Value
  kParallel         1
  kPerpendicular    2
  </table>
  */
  RotatedDimType rotatedDimType() const;
 
  /** \details
  Sets the rotated dimension type of this Associative Dimension object (DXF 71).
 
  \remarks
  rotatedDimType must be one of the following:
 
  <table>
  Name              Value
  kParallel         1
  kPerpendicular    2
  </table>
  */
  void setRotatedDimType(RotatedDimType dimType);
 
  void addToPointRefReactor();
  void addToDimensionReactor(bool isAdd = true);
 
  OdResult removePointRef(int ptType);
  OdResult updateDimension(bool update = true, bool skipReactors = false);
  void removeAssociativity(bool force = true);
  
  /** \details
  Returns the trans-space flag of this Associative Dimension object (DXF 70).
  */
  bool isTransSpatial() const;
  /** \details
  Sets the trans-space flag of this Associative Dimension object (DXF 70).
  \param transSpace [out]  Trans-space flag.
  */
  void setTransSpatial(bool value);
  
 
  OdResult post(OdDbObjectId dimId, OdDbObjectId& dimAssocId, bool isActive = true);
  OdResult getDimAssocGeomIds(OdDbObjectIdArray& geomIds) const;
  bool isAllGeomErased() const;
  
  virtual void modifiedGraphics(const OdDbObject* pObj) ODRX_OVERRIDE;
  virtual void copied(const OdDbObject* pObj, const OdDbObject* pNewObj) ODRX_OVERRIDE;
  virtual void erased(const OdDbObject *pObj, bool erasing = true) ODRX_OVERRIDE;
  virtual void openedForModify(const OdDbObject* pObject) ODRX_OVERRIDE;
 
  virtual OdDbObjectPtr subWblockClone(OdDbIdMapping& idMap, OdDbObject* pOwner, bool bPrimary) const ODRX_OVERRIDE;
  virtual OdDbObjectPtr subDeepClone(OdDbIdMapping& idMap, OdDbObject* pOwner, bool bPrimary) const ODRX_OVERRIDE;
 
protected:
  OdResult setPointRefReactor(int ptType, bool isAdd = true);
};
 
/** \details
    This template class is a specialization of the OdSmartPtr class for OdDbDimAssoc object pointers.
*/
typedef OdSmartPtr<OdDbDimAssoc> OdDbDimAssocPtr;
 
//
// Inlines
//
 
inline
OdHandleArray& OdDbXrefFullSubentPath::xrefObjHandles()
  return m_XrefObjHandles; 
}
 
inline
const OdHandleArray& OdDbXrefFullSubentPath::xrefObjHandles() const
  return m_XrefObjHandles; 
}
 
inline
OdDb::OsnapMode OdDbOsnapPointRef::osnapType() const
{
  return m_OsnapMode;
}
 
inline
void OdDbOsnapPointRef::setOsnapType(OdDb::OsnapMode osnapMode)
{
  m_OsnapMode = osnapMode;
}
 
inline
OdDbXrefFullSubentPath& OdDbOsnapPointRef::mainEntity()
{
  return m_MainEntity;
}
 
inline
OdDbXrefFullSubentPath& OdDbOsnapPointRef::intersectEntity()
{
  return m_IntersectEntity;
}
 
inline
double OdDbOsnapPointRef::nearPointParam() const
{
  return m_dNearOsnap;
}
 
inline
void OdDbOsnapPointRef::setNearPointParam(double nearOsnap)
{
  m_dNearOsnap = nearOsnap;
}
 
inline
OdGePoint3d OdDbOsnapPointRef::point() const
{
  return m_OsnapPoint;
}
inline
void OdDbOsnapPointRef::setPoint(const OdGePoint3d& pt)
{
  m_OsnapPoint = pt;
}
 
inline
const OdDbOsnapPointRef* OdDbOsnapPointRef::lastPointRef() const
{
  return m_pLastPointRef;
}
inline
OdDbOsnapPointRef* OdDbOsnapPointRef::lastPointRef()
{
  return m_pLastPointRef;
}
 
inline
void OdDbOsnapPointRef::setLastPointRef(OdDbOsnapPointRefPtr pOsnapPointRef)
{
  m_pLastPointRef = pOsnapPointRef;
}
 
#include "TD_PackPop.h"
 
#endif // OD_DBDIMASSOC_H