/////////////////////////////////////////////////////////////////////////////// // 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. /////////////////////////////////////////////////////////////////////////////// #ifndef _EX_STEP_HOST_APP_SERVICES_H_ #define _EX_STEP_HOST_APP_SERVICES_H_ #include "OdString.h" #include "ExSystemServices.h" #include "DbHostAppProgressMeter.h" #include "ExPrintConsole.h" #ifdef NO_STEP_LIBS_LINK #include "daiHostAppServicesBase.h" #else #include "StepHostAppServices.h" #endif // NO_STEP_LIBS_LINK /** \details This class implements platform specific progress metering within ODA STEP SDK. \remarks This class receives progress notifications during various database operations such as loading and saving a step physical file. Working with an instance of the class should include the following steps: 1. Call the setLimit() method for setting the maximum progress value. 2. Call the start() method to begin progress metering. 3. Call the meterProgress() method each time you need to change the current progress value. 4. Call the stop() method to stop progress metering. */ class OdExStepHostAppProgressMeter : public OdDbHostAppProgressMeter { public: /** \details Creates a new ODA STEP SDK progress meter object. */ OdExStepHostAppProgressMeter(); /** \details Initializes the progress meter object. \param displayString [in] A string to be displayed. */ virtual void start(const OdString& displayString = OdString::kEmpty); /** \details Stops the progress metering. */ virtual void stop(); /** \details Increments the progress meter object. \remarks The completion percentage can be calculated by dividing the number of times this function is called by the value set by the setLimit() method. If an exception is thrown, the operation associated with the progress meter object should be halted. */ virtual void meterProgress(); /** \details Specifies the maximum number of times the progress meter object can be incremented. \param max [in] A maximum increments count. */ virtual void setLimit(int max); /** \details Controls display of the progress meter object. \param disable [in] A flag that disables progress metering. */ void disableOutput(bool disable) { m_disableOutput = disable; } /** \details Sets the prefix for the progress meter object. \param prefix [in] A new prefix for the progress meter object. */ void setPrefix(const OdString& prefix) { m_Prefix = prefix; } private: OdString m_Prefix; long m_MeterLimit; long m_MeterCurrent; long m_MeterOld; bool m_disableOutput; }; /** \details This class implements platform-dependent operations and progress metering for ODA STEP SDK. */ #ifdef NO_STEP_LIBS_LINK class OdExStepHostAppServices : public OdDAIHostAppServicesBase #else class OdExStepHostAppServices : public OdStepHostAppServices #endif // NO_STEP_LIBS_LINK { public: /** \details Creates an instance of services for platform-dependent operations and progress metering. */ OdExStepHostAppServices(); /** \details Returns an instance of a progress meter object. \returns Raw pointer to OdDbHostAppProgressMeter instance. */ virtual OdDbHostAppProgressMeter* newProgressMeter(); /** \details This method is called whenever ODA STEP SDK no longer needs the specified progress meter object. \param pProgressMeter [in] A pointer to the progress meter object that should be released. \remarks The current implementation does nothing. */ virtual void releaseProgressMeter(OdDbHostAppProgressMeter* pProgressMeter); /** \details Controls the display of the progress meter object. \param disable [in] A new value of the disable flag for the progress meter object. */ void disableProgressMeterOutput(bool disable) { m_progressMeter.disableOutput(disable); } public: #ifdef NO_STEP_LIBS_LINK /** \details Returns a database class. \returns nullptr currently. */ virtual OdRxClass* databaseClass() const; /** \details Returns a database class. \param schemaName [in] Schema name. \returns nullptr currently. */ virtual OdRxClass* databaseClass(const OdAnsiString& schemaName) const; #endif // NO_STEP_LIBS_LINK /** \details Retrieves the current name of the client program based on ODA STEP SDK. \returns A string object containing the custom application name. \remarks The default implementation of this method returns an empty string. */ virtual const OdString program() override { return OdString::kEmpty; } /** \details Retrieves the current name of the client product based on ODA STEP SDK. \returns A string object containing the current name of the client product. \remarks The default implementation of this method returns "ODA STEP SDK". */ virtual const OdString product() override { return OD_T("ODA STEP SDK"); } /** \details Retrieves the current name of the client company. \returns A string object containing the current name of the client company. \remarks The default implementation of this method returns "Open Design Alliance". */ virtual const OdString companyName() override { return OD_T("Open Design Alliance"); } /** \details Locates the TTF or TTC file containing the specified font description. \param description [in] Font description. \param filename [out] Receives the name of the TrueType font file. \returns Returns true and the filename if the font file was found; otherwise the method returns false. \remarks The default implementation of the method returns false. */ virtual bool ttfFileNameByDescriptor( const OdTtfDescriptor& description, OdString& filename) override { return false; } /** \details Retrieves the current default font name. \returns A string that contains the path to the font file to be used when a given font file can not be found by STEP SDK. \remarks The default implementation of the method returns an empty string. \sa Font Handling */ virtual OdString getAlternateFontName() const override { return OdString::kEmpty; } /** \details Retrieves the current font mapping file. This font mapping file is used by the getPreferableFont() method. \returns A string that contains the name of the font mapping file. \remarks The default implementation of this method returns an empty string. \sa Font Handling */ virtual OdString getFontMapFileName() const override { return OdString::kEmpty; } /** \details Retrieves the current preferable font name for a specified font name and type. \param fontName [in] A font name. \param fontType [in] A font type. \returns A string object containing the preferable font name. \remarks The default implementation of this method returns an empty string. The fontType parameter value must be one of the following:
Name Value Description
kFontTypeUnknown 0 Unknown.
kFontTypeShx 1 SHX font.
kFontTypeTrueType 2 TrueType font.
kFontTypeShape 3 Shape file.
kFontTypeBig 4 BigFont file.
\sa Font Handling */ virtual OdString getPreferableFont( const OdString& fontName, OdFontType fontType) override { return OdString::kEmpty; } /** \details Retrieves the current substitute font name. The substitute font is used in cases when a specified font is not found. \param fontName [in] A font name. \param fontType [in] A font type. \returns A string object that contains the substitute font name. \remarks The default implementation of this method returns an empty string. The fontType parameter value must be one of the following:
Name Value Description
kFontTypeUnknown 0 Unknown.
kFontTypeShx 1 SHX font.
kFontTypeTrueType 2 TrueType font.
kFontTypeShape 3 Shape file.
kFontTypeBig 4 BigFont file.
\sa Font Handling */ virtual OdString getSubstituteFont( const OdString& fontName, OdFontType fontType) override { return OdString::kEmpty; } private: OdExStepHostAppProgressMeter m_progressMeter; }; /************************************************************************/ /* Define a Custom Services class. */ /* */ /* Combines the platform dependent functionality of */ /* OdRxSystemServices and OdDbBaseHostAppServices */ /************************************************************************/ #include "DynamicLinker.h" // DOM-IGNORE-BEGIN class ExStepServices : public ExSystemServices, public OdExStepHostAppServices { protected: ODRX_USING_HEAP_OPERATORS(ExSystemServices); OdGsDevicePtr gsBitmapDevice(OdRxObject* /*pViewObj*/ = nullptr, OdDbBaseDatabase* /*pDb*/ = nullptr, OdUInt32 /*flags*/ = 0) { try { OdGsModulePtr pGsModule = ::odrxDynamicLinker()->loadModule(OdWinBitmapModuleName); return pGsModule->createBitmapDevice(); } catch (const OdError&) { } return OdGsDevicePtr(); } }; // DOM-IGNORE-END #endif // _EX_STEP_HOST_APP_SERVICES_H_