/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, 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 Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// /************************************************************************/ /* EnhancedLine.cpp: Implementation of the CEnhancedLine class */ /* and related command */ /* This clas is substituted at run-time instead of OdDbLine class */ /************************************************************************/ #include "OdaCommon.h" #include "EnhancedLine.h" ODDB_PSEUDO_DEFINE_MEMBERS( CEnhancedLine, // Class name OdDbLine, // Base class name OdDbLine, // Pseudo base class name DBOBJECT_CONSTR); OdString CEnhancedLine::comment() { assertReadEnabled(); return m_strComment; } void CEnhancedLine::setComment(const OdString& newComment) { assertWriteEnabled(); // To trigger undo recording m_strComment = newComment; } OdResult CEnhancedLine::dwgInFields(OdDbDwgFiler* pFiler) { OdResult res = OdDbLine::dwgInFields(pFiler); if (res == eOk) switch (pFiler->filerType()) { case OdDbFiler::kFileFiler: // .dwg and .dxf files case OdDbFiler::kBagFiler: // entGet/EntMod case OdDbFiler::kPageFiler: // Only if no Ids in custom data case OdDbFiler::kIdXlateFiler: case OdDbFiler::kIdFiler: case OdDbFiler::kPurgeFiler: break; // Do not read custom data - it was not saved //case OdDbFiler::kCopyFiler: //case OdDbFiler::kUndoFiler: //case OdDbFiler::kDeepCloneFiler: //case OdDbFiler::kWblockCloneFiler: default: // read custom data m_strComment = pFiler->rdString(); break; } return res; } void CEnhancedLine::dwgOutFields(OdDbDwgFiler* pFiler) const { OdDbLine::dwgOutFields(pFiler); switch (pFiler->filerType()) { case OdDbFiler::kFileFiler: // .dwg and .dxf files case OdDbFiler::kBagFiler: // entGet/EntMod case OdDbFiler::kPageFiler: // Only if no Ids in custom data case OdDbFiler::kIdXlateFiler: case OdDbFiler::kIdFiler: case OdDbFiler::kPurgeFiler: break; // Do not save custom data //case OdDbFiler::kCopyFiler: //case OdDbFiler::kUndoFiler: //case OdDbFiler::kDeepCloneFiler: //case OdDbFiler::kWblockCloneFiler: default: // write custom data pFiler->wrString(m_strComment); break; } } OdResult CEnhancedLine::dxfInFields(OdDbDxfFiler* pFiler) { OdResult res = OdDbLine::dxfInFields(pFiler); if (res == eOk && pFiler->filerType() == OdDbFiler::kBagFiler) { // To enable this data participate in entGet/entMod int nCode = pFiler->nextItem(); ODA_ASSERT_ONCE(("Unexpected group code", nCode == 1)); if (nCode == 1) { m_strComment = pFiler->rdString(); } } return res; } void CEnhancedLine::dxfOutFields(OdDbDxfFiler* pFiler) const { OdDbLine::dxfOutFields(pFiler); if (pFiler->filerType() == OdDbFiler::kBagFiler) { // To enable this data participate in entGet/entMod pFiler->wrString(1, m_strComment); } } #include "DbCommandContext.h" #include "ClassFilter.h" /*********************************************/ /* SetComment - Command setting custom data */ /*********************************************/ void _SetComment_func(OdEdCommandContext* pCmdCtx) { OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbUserIO* pIO = pDbCmdCtx->dbUserIO(); ClassFilter fltr; fltr.setClass(CEnhancedLine::desc()); // To select only this class entities OdDbSelectionSetPtr pSSet = pIO->select("Select a Line:", 0, 0, OdString::kEmpty, &fltr); if (pSSet->numEntities()) // To prevent starting undo record if nothing selected { pDbCmdCtx->database()->startUndoRecord(); for (OdDbSelectionSetIteratorPtr pIter = pSSet->newIterator(); !pIter->done(); pIter->next()) { CEnhancedLinePtr pLine = pIter->objectId().safeOpenObject(OdDb::kForWrite); OdString strOldComment = pLine->comment(); OdString strPrompt = L"Enter new comment <" + strOldComment + L">"; OdString strNewComment = pDbCmdCtx->dbUserIO()->getString(strPrompt, OdEd::kInpDefault, strOldComment); if (strNewComment != strOldComment) pLine->setComment(strNewComment); } } }