/////////////////////////////////////////////////////////////////////////////// // 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. /////////////////////////////////////////////////////////////////////////////// /************************************************************************/ /* Simple application displays a dump of XData linkages */ /* of model elements from a DGN file. */ /************************************************************************/ #include "OdaCommon.h" #include "StaticRxObject.h" #include "RxInit.h" #include "RxDynamicModule.h" #include "DynamicLinker.h" /************************************************************************/ /* Required ODA Drawings API for DGN header files */ /************************************************************************/ #include "DgDatabase.h" #include "ExDgnHostAppServices.h" /************************************************************************/ /* Required ODA Drawings SDK header files */ /************************************************************************/ #include "DbDatabase.h" #include "DbFiler.h" #include "ExSystemServices.h" #include "ExHostAppServices.h" /*************************************************************************************/ /* Here to include ODA Drawings API for DGN header files required for your sample */ /*************************************************************************************/ #include "DgModel.h" #include "DgLine.h" /************************************************************************************/ /* Here to include ODA Drawings SDK header files required for your sample */ /************************************************************************************/ #include "DbBlockTableRecord.h" #include "DbLine.h" #define STL_USING_IOSTREAM #include "OdaSTL.h" #define STD(a) std::a #ifdef OD_HAVE_CONSOLE_H_FILE #include #endif /************************************************************************/ /* Define a Custom SystemServices class */ /************************************************************************/ class MySystemServices : public ExSystemServices { }; /************************************************************************/ /* Define a Custom Db HostAppServices class */ /************************************************************************/ class MyDbHostAppServices : public ExHostAppServices { #ifdef _MSC_VER public: /**********************************************************************/ /* Define a console interface for password support. */ /**********************************************************************/ bool getPassword(const OdString& dwgName, bool /*isXref*/, OdPassword& password) { odPrintConsoleString(L"Enter password to open drawing: %ls\n", dwgName.c_str()); wchar_t pwdBuff[_MAX_PATH] = {0}; STD(wcin).get(pwdBuff, L'\n').get(); ::CharUpperW(pwdBuff); password = pwdBuff; return !password.isEmpty(); } #endif public: virtual OdDbBaseHostAppServices* getDgnHostAppServices() const { return m_pDgnHostApp; } public: MyDbHostAppServices() : m_pDgnHostApp(0) {} void setDgnHostAppServices(OdDbBaseHostAppServices* pHostApp) { m_pDgnHostApp = pHostApp; } private: OdDbBaseHostAppServices* m_pDgnHostApp; }; /************************************************************************/ /* Define a Custom Dgn HostAppServices class */ /************************************************************************/ class MyDgHostAppServices : public OdExDgnHostAppServices { public: virtual OdDbBaseHostAppServices* getDbHostAppServices() const { return m_pDbHostApp; } public: MyDgHostAppServices() : m_pDbHostApp(0) {} void setDbHostAppServices(OdDbBaseHostAppServices* pHostApp) { m_pDbHostApp = pHostApp; } private: OdDbBaseHostAppServices* m_pDbHostApp; }; #ifndef _TOOLKIT_IN_DLL_ #include "RxDynamicModule.h" ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdDgnModule); ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdDwgModule); ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdDwgDbModuleImpl); #if defined DGNIMPORT_ENABLE ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(DgnImportModule); ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdDgImportLineStyleModule); #endif ODRX_BEGIN_STATIC_MODULE_MAP() ODRX_DEFINE_STATIC_APPLICATION(L"TG_Db", OdDgnModule) ODRX_DEFINE_STATIC_APPLICATION(OdDbModuleName, OdDwgModule) ODRX_DEFINE_STATIC_APPLICATION(L"TG_DwgDb", OdDwgDbModuleImpl) #if defined DGNIMPORT_ENABLE ODRX_DEFINE_STATIC_APPMODULE(L"TD_DgnImport", DgnImportModule) ODRX_DEFINE_STATIC_APPMODULE(L"ExDgnImportLineStyle", OdDgImportLineStyleModule) #endif ODRX_END_STATIC_MODULE_MAP() #endif /************************************************************************/ /* Main */ /************************************************************************/ #if defined(OD_USE_WMAIN) int wmain(int argc, wchar_t* argv[]) #else int main(int argc, char* argv[]) #endif { #ifdef OD_HAVE_CCOMMAND_FUNC argc = ccommand(&argv); #endif #ifdef OD_HAVE_SETLOCALE_FUNC /********************************************************************/ /* For correct Unicode translation, apply the current system locale.*/ /********************************************************************/ setlocale(LC_ALL, ""); /********************************************************************/ /* But use usual conversion for scanf()/sprintf() */ /********************************************************************/ setlocale(LC_NUMERIC, "C"); #endif /**********************************************************************/ /* Verify the argument count and display an error message as required */ /**********************************************************************/ if ( argc < 3 ) { odPrintConsoleString(L"\nExDwgXData sample program. Copyright (c) 2025, Open Design Alliance\n"); odPrintConsoleString(L"\tusage:ExDwgXData