录制状态
若要仅记录对象状态的一部分,请指定参数,然后使用函数(或其他函数)将相关信息保存在撤消文件中。kFalseautoUndoundoFiler::writeItem()write xxx () 的函数是修改函数的典型例子。因为指定 for ,所以该类承担记录对象状态的相关部分的责任。首先,修改函数必须记录类描述符对象,以便派生类可以检查并让此类在必要时处理其部分撤消数据。setNumSides()AsdkPolyassertWriteEnabled()kFalseautoUndo undoFiler()->writeAddress(AsdkPoly::desc()); 然后修改函数需要指示动作的类型,然后是数据。在此示例中,操作类型为 ,数据为 。kSetNumSidesmNumSides Acad::ErrorStatus AsdkPoly::setNumSides(int numSides) { assertWriteEnabled(Adesk::kFalse, Adesk::kTrue); if (numSides<3) return Acad::eInvalidInput; if (mNumSides == numSides) return Acad::eOk; // There are situations under which AutoCAD doesn't // want to do undo recording, so it won't create an // undo filer. Check for the existence of the filer // before starting to write into it. // AcDbDwgFiler *pFiler = NULL; if ((pFiler = undoFiler()) != NULL) { undoFiler()->writeAddress(AsdkPoly::desc()); undoFiler()->writeItem((Adesk::Int16)kSetNumSides); undoFiler()->writeItem((Adesk::Int32)mNumSides); } mNumSides = numSides; return Acad::eOk; } 对象执行自动撤消操作(记录其完整状态)后,将忽略其他自动撤消请求。 父主题: |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2024-12-15 11:35
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.