即使 AutoCAD 在没有纤程的情况下运行,“应用程序上下文”和“文档上下文”之间的区别仍然存在,如 的返回值所示,但应用程序上下文现在通过“返回”文档上下文逻辑来“切换到”。AcApDocManager::isApplicationContext 对于 AutoCAD 用户和您的应用程序来说,这意味着不能再使用活动命令和/或 LISP 表达式切换活动文档,也不能切换回来并恢复这些命令。 无光纤文档切换仅在上一个文档中的所有命令和 LISP 表达式结束后完成。调用旨在导致文档切换的函数后,应用程序必须返回,AutoCAD 将完成文档切换。文档切换请求包括关闭活动文档或打开/创建新文档。发出此类请求后,将禁用输入喉咙,直到 AutoCAD 完成文档切换。这可能会导致与文档删除相关的某些 Reactor 回调的时间差异。 定义命令时,设置 theflag 仍表示命令应在应用程序上下文中运行,这仍会影响某些 API 函数的行为方式。如果 LISP 或其他命令处于活动状态,则与光纤化操作相比,此类命令的执行在内部是延迟的,因此某些反应堆回调可能不合时宜。当没有其他命令或 LISP 处于活动状态时,执行时间的差异应该可以忽略不计。ACRX_CMD_SESSION 鉴于此 MDI API 更改摘要,下面是对以下特定 MDI API 函数的影响,这些函数都在类中定义。为简洁起见,行为差异列在每个函数前面的注释中,并描述了运行无纤维 AutoCAD 时将看到的不同行为。AcApDocManager class ADESK_NO_VTABLE AcApDocManager : public AcRxObject
{
public:
// Still has meaning in fiberless operations, but the timing of when
// the system is in application context differs in two significant ways:
// 1. when running fiberless, CLI prompts issued in active commands never
// leave document context. In fiberized operations, all prompts
// enter and leave application context on every event.
// 2. See executeInApplicationContext function, it literally forces
// this function to return true, even with active document-related
// logic on the stack. This usually works to everyone’s advangate,
// but active document switch requests are deferred until all command
// and LISP expressions, and it allows one to use appContextCloseDocument,
// but in this context, active command logic will likely crash
// AutoCAD if the closed document is active.
virtual bool isApplicationContext() const = 0;
// If activate is true, the actual activation will not occur until after
// all commands and LISP are ended, and keyboard/mouse/script input is disabled.
virtual Acad::ErrorStatus setCurDocument(AcApDocument* pDoc,
AcAp::DocLockMode = AcAp::kNone,
bool activate = false) = 0;
// Actual activation will not occur until after all commands and LISP are ended
// After calling activateDocument, all keyboard and mouse input is disabled
// until after the document switch finally occurs.
virtual Acad::ErrorStatus activateDocument(AcApDocument* pAcTargetDocument,
bool bPassScript = false) = 0;
// If activate is true, the actual activation will not occur until after
// all commands and LISP are ended, and keyboard/mouse/script input is disabled.
virtual Acad::ErrorStatus sendStringToExecute(AcApDocument* pAcTargetDocument,
const ACHAR * pszExecute,
bool bActivate = true,
bool bWrapUpInactiveDoc = false,
bool bEchoString = true) = 0;
// During document creation, the new document is no longer activated until
// its initialization is complete. In fiberized operations, the new
// document is activated very early in initialization.
virtual Acad::ErrorStatus appContextNewDocument(const ACHAR *pszTemplateName) = 0;
virtual Acad::ErrorStatus appContextOpenDocument(const ACHAR *pszDrawingName) = 0;
ACCORE_PORT Acad::ErrorStatus appContextPromptNewDocument();
ACCORE_PORT Acad::ErrorStatus appContextPromptOpenDocument();
virtual Acad::ErrorStatus newDocument() = 0;
virtual Acad::ErrorStatus openDocument() = 0;
//
// Caution: This function immediately destroys the active document and
// a lot of related data when called from application context, even if it
// is artificially set by using executeInApplicationContext.
// Use closeDocument whenever it will work for you, it queues up a request
// to appContextCloseDocument to be performed at a safer point of execution.
ACCORE_PORT Acad::ErrorStatus appContextCloseDocument(AcApDocument* pDoc);
virtual Acad::ErrorStatus closeDocument(AcApDocument* pAcTargetDocument) = 0;
// Essentially forces the system to behave as if in the application context, even
// if a document has active commands. See the note on appContextCloseDocument,
// which is especially dangerous when invoked from logic invoked through this
// function.
virtual void executeInApplicationContext(void (*procAddr)(void *), void *pData ) const = 0;
};
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-29 19:49
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.