123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- //////////////////////////////////////////////////////////////////////////////
- //
- // Copyright 2015 Autodesk, Inc. All rights reserved.
- //
- // Use of this software is subject to the terms of the Autodesk license
- // agreement provided at the time of installation or download, or which
- // otherwise accompanies this software in either electronic or hard copy form.
- //
- //////////////////////////////////////////////////////////////////////////////
- //
- // ========= xgraph.h: AcDbXrefGraph classes ================
- //
- // This header defines classes:
- //
- // AcDbXrefGraph - a derived class for representing Xrefs
- // AcDbXrefGraphNode - each node represents one Xref database
- //
- // An AcDbXrefGraph is a representation of the relationship between a
- // host drawing, its Xref'ed drawings, and any nested Xref drawings.
- // Each database, or Xref BLock Table Record is represented by an
- // AcDbXrefGraphNode in the graph. The host drawing is always the
- // rootNode. Each reference is represented by an edge in the graph,
- // and can be queried for by calling AcDbGraphNode::in(idx) for who
- // is referencing this node, and AcDbGraphNode::out(idx) for who this
- // node references.
- //
- // Detection for circular references is done by internally creating
- // a duplicate set of references in each node and then triming away
- // all leaf nodes, which terminate without circularity. If any nodes
- // remain in the duplicate graph, those nodes exist in a cycle.
- // AcDbGraph::findCycles() is used to set up the internal cycle
- // information and enable several query methods to return information
- // about any cycles found.
- //
- //
- #ifndef AD_XGRAPH_H
- #define AD_XGRAPH_H 1
- #include "graph.h"
- #include "AdAChar.h"
- #pragma pack (push, 8)
- // =====================================
- // Xref Graph Classes
- // =====================================
- class AcDbXrefGraphNode : public AcDbGraphNode
- {
- public:
- AcDbXrefGraphNode(const ACHAR * pName = NULL,
- const AcDbObjectId& btrId = AcDbObjectId::kNull,
- AcDbDatabase* pDb = NULL,
- AcDb::XrefStatus status = AcDb::kXrfResolved);
- virtual ~AcDbXrefGraphNode();
- const ACHAR * name() const;
- AcDbObjectId btrId() const;
- AcDbDatabase* database() const;
- Acad::ErrorStatus setName(const ACHAR * pName);
- void setBtrId(const AcDbObjectId& id);
- void setDatabase(AcDbDatabase* pDb);
- bool isNested() const;
- AcDb::XrefStatus xrefStatus() const;
- void setXrefStatus(AcDb::XrefStatus stat);
- AcDb::XrefNotificationStatus xrefNotificationStatus() const;
- void setXrefNotificationStatus(AcDb::XrefNotificationStatus stat);
- void* xData() { return mpxdata; }
- void setxData(void *pXData) { mpxdata = pXData; }
- Acad::ErrorStatus xrefReadSubstatus() const;
- private:
- void* mpxdata; // since data already used!
- ACHAR * mpName;
- AcDbObjectId mBtrId;
- // AcDbDatabase* uses base class data() member
- AcDb::XrefStatus mStatus;
- AcDb::XrefNotificationStatus mNotifyStatus;
- };
- class AcDbXrefGraph : public AcDbGraph
- {
- public:
- AcDbXrefGraph(AcDbXrefGraphNode* pHostDwg = NULL);
- virtual ~AcDbXrefGraph();
- AcDbXrefGraphNode* xrefNode(const ACHAR * pName) const;
- AcDbXrefGraphNode* xrefNode(AcDbObjectId btrId) const;
- AcDbXrefGraphNode* xrefNode(const AcDbDatabase* pDb) const;
- AcDbXrefGraphNode* xrefNode(int idx) const;
- AcDbXrefGraphNode* hostDwg() const;
- Adesk::Boolean markUnresolvedTrees ();
- // cycle detection
- virtual Adesk::Boolean findCycles(AcDbGraphNode* pStart = NULL);
- };
- // =====================================
- // General Utility functions
- // =====================================
- // Acad.lib only -- Not for use in ObjectDBX
- //
- Acad::ErrorStatus acedGetCurDwgXrefGraph(AcDbXrefGraph&,
- Adesk::Boolean includeGhosts = Adesk::kFalse);
- // =====================================
- // Inline methods
- // =====================================
- // AcDbXrefGraphNode inlines ...
- inline const ACHAR * AcDbXrefGraphNode::name() const { return mpName; }
- inline AcDbObjectId AcDbXrefGraphNode::btrId() const { return mBtrId; }
- inline AcDbDatabase* AcDbXrefGraphNode::database() const
- { return (AcDbDatabase*)data(); }
- inline void AcDbXrefGraphNode::setBtrId(const AcDbObjectId& id)
- { mBtrId = id; }
- inline void AcDbXrefGraphNode::setDatabase(AcDbDatabase* pDb)
- { setData(pDb); }
- inline bool AcDbXrefGraphNode::isNested() const
- { return !isMarkedAs(kFirstLevel); }
- inline AcDb::XrefStatus AcDbXrefGraphNode::xrefStatus() const
- { return mStatus; }
- inline void AcDbXrefGraphNode::setXrefStatus(AcDb::XrefStatus stat)
- { mStatus = stat; }
- inline AcDb::XrefNotificationStatus
- AcDbXrefGraphNode::xrefNotificationStatus() const
- { return mNotifyStatus; }
- inline void AcDbXrefGraphNode::setXrefNotificationStatus(
- AcDb::XrefNotificationStatus stat)
- { mNotifyStatus = stat; }
- // AcDbXrefGraph inlines ...
- inline AcDbXrefGraphNode* AcDbXrefGraph::xrefNode(int idx) const
- { return (AcDbXrefGraphNode*)node(idx); }
- inline AcDbXrefGraphNode* AcDbXrefGraph::hostDwg() const
- { return (AcDbXrefGraphNode*)rootNode(); }
- #pragma pack (pop)
- #endif
|