/////////////////////////////////////////////////////////////////////////////// // 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 _TvExDbCommandContext_h_Included_ #define _TvExDbCommandContext_h_Included_ #include "TD_PackPush.h" #include "TvExDbUserIO.h" #include "Ed/EdFunctionIO.h" #include "StaticRxObject.h" #include "ExEdBaseIO.h" #include "Ed/EdCommandContext.h" #include "Ed/EdUserIO.h" #include "SSet.h" #include "OdUnitsFormatter.h" /** \details This class defines the interface for I/O and database access for custom commands during their execution. \remarks Client applications that invoke custom commands, should use an instance of this class (or a subclass) to pass to the OdEdCommandStack::executeCommand function. Using this class instead of a true instance of OdEdCommandContext provides custom commands with database access. */ class TvExDbCommandContextBase : public OdEdCommandContext { public: ODRX_DECLARE_MEMBERS(TvExDbCommandContextBase); }; /** \details This template class is a specialization of the OdSmartPtr class for OdTvDbCommandContext object pointers. */ typedef OdSmartPtr TvExDbCommandContextBasePtr; #define OdTvExPdfPublishCmdsModuleName L"ExTvPdfPublishCmds.tx" class TvExDbCommandContext; /** \details This template class is a specialization of the OdSmartPtr class for TvExDbCommandContext object pointers. */ typedef OdSmartPtr TvExDbCommandContextPtr; /** \details This class implements the interface for I/O and database access for custom commands during their execution. Library: Source code provided. */ class TvExDbCommandContext : public TvExDbCommandContextBase , protected TvExDbUserIO , protected OdEdFunctionIO { protected: ODRX_USING_HEAP_OPERATORS(TvExDbCommandContextBase); OdSmartPtr m_pIoStream; OdRxObject* m_pDb; OdGePoint3d m_LASTPOINT; mutable OdRxDictionaryPtr m_pArbDataDic; TvExDbCommandContext* m_pOwner; /** \details Returns a SmartPointer to the arbitrary data dictionary for this CommandContext object. \remarks A dictionary is created if a dictionary does not exist. */ OdRxDictionaryPtr arbDataDic() const; /** \details Returns input of a string from the StreamBuf associated with this CommandContext object. \param options [in] Combination of OdEd::CommonInputOptions and OdEd::GetStringOptions enum values. \param prompt [in] Prompt output before pausing for user input. \param pTracker [in] Pointer to an IO Tracker for this user input. \remarks If prompt is empty, a default prompt is used. This function uses the underlying OdEdBaseIO function putString for low level output. */ OdString getStringInternal(const OdString& prompt, int options = OdEd::kInpDefault, OdEdStringTracker* pTracker = 0); protected: // Leave this here--DO NOT move it out of the class definition. Moving it // outside causes an "internal compiler error" in CodeWarrior 8 & 9 on the mac. TvExDbCommandContext() : m_pDb(0) { } public: /** \details Returns a database, for use in a custom command. */ virtual OdDbBaseDatabase* database(); TvExDbUserIO* dbUserIO(); /** \details Creates an instance of this CommandContext object. \param pStreamBuf [in] Pointer to the the stream buffer. \param pDb [in] Pointer to the database. \remarks Returns a SmartPointer to the newly created object. */ static TvExDbCommandContextBasePtr createObject(OdEdBaseIO* pIOStream, OdRxObject* pRxDb = 0); OdRxObject* baseDatabase(); /*!DOM*/ void reset(OdEdBaseIO* pIOStream, OdRxObject* pRxDb); /*!DOM*/ OdEdBaseIO* baseIO(); /*!DOM*/ virtual OdEdCommandContextPtr cloneObject(OdEdBaseIO* pIOStream = NULL, OdRxObject* pRxDb = NULL); OdEdUserIO* userIO() { return this; } OdEdFunctionIO* funcIO() { return this; } /** \details Sets the parameter object for this CommandContext object. \param pParamObj [in] Pointer to the parameter object. */ virtual void setParam(OdRxObject* pParamObj); /** \details Returns the parameter object for this CommandContext object. */ virtual OdRxObjectPtr param(); /** \details Sets the result object for this CommandContext object. \param pResultObj [in] Pointer to the result object. */ virtual void setResult(OdRxObject* pResultObj); /** \details Returns the result object for this CommandContext object. */ virtual OdRxObjectPtr result(); /** \details Writes arbitrary data to the specified file with this CommandContext object. \param fileName [in] Filename. \param pDataObj [in] Pointer to the data object. */ virtual void setArbitraryData(const OdString& fileName, OdRxObject* pDataObj); /** \details Reads arbitrary data from the specified file with this CommandContext object. \param fileName [in] Filename. \remarks Returns a SmartPointer to the data object. */ virtual OdRxObjectPtr arbitraryData(const OdString& fileName) const; // OdEdUserIO interface: virtual OdUnitsFormatter& baseFormatter(); virtual void putString(const OdString& string); virtual int getInt(const OdString& prompt, int options = OdEd::kInpDefault, int defVal = 0, const OdString& keywords = OdString::kEmpty, OdEdIntegerTracker* pTracker = 0); virtual double getReal(const OdString& prompt, int options = OdEd::kInpDefault, double defVal = 0.0, const OdString& keywordList = OdString::kEmpty, OdEdRealTracker* pTracker = 0); virtual OdString getString(const OdString& prompt, int options = OdEd::kInpDefault, const OdString& pDefVal = OdString::kEmpty, const OdString& keywords = OdString::kEmpty, OdEdStringTracker* pTracker = 0); virtual int getKeyword(const OdString& prompt, const OdString& keywords, int defRes = -1, int options = OdEd::kInpDefault, OdEdIntegerTracker* pTracker = 0); virtual double getAngle(const OdString& prompt, int options = OdEd::kInpDefault, double defVal = 0.0, const OdString& keywords = OdString::kEmpty, OdEdRealTracker* pTracker = 0); /** \details Returns the LASTPOINT system variable for this CommandContext object. */ virtual OdGePoint3d getLASTPOINT() const; /** \details Sets the LASTPOINT system variable for this CommandContext object. \param val [in] New value for LASTPOINT. */ virtual void setLASTPOINT(const OdGePoint3d& val); /** \details Creates a rubberband line from the specified point to the user input. \param base [in] Base point. */ virtual OdEdPointDefTrackerPtr createRubberBand(const OdGePoint3d& base, OdGsModel* pModel = NULL) const; /** \details Creates a rectangular frame from the specified point to the user input. \param base [in] Base point. */ virtual OdEdPointDefTrackerPtr createRectFrame(const OdGePoint3d& base, OdGsModel* pModel = NULL) const; virtual OdGePoint3d getPoint(const OdString& prompt, int options = OdEd::kGptDefault, const OdGePoint3d* pDefVal = 0, const OdString& keywords = OdString::kEmpty, OdEdPointTracker* = 0); virtual double getDist(const OdString& prompt, int options = OdEd::kInpDefault, double defVal = 0.0, const OdString& keywords = OdString::kEmpty, OdEdRealTracker* pTracker = 0); virtual OdSharedPtr getCmColor(const OdString& sPrompt, int options = OdEd::kInpDefault, const OdCmColorBase* pDefVal = 0, const OdString& sKeywords = OdString::kEmpty, OdEdColorTracker* pTracker = 0); protected: virtual bool interactive(); }; #include "TD_PackPop.h" #endif // _TvExDbCommandContext_h_Included_