- 积分
- 3266
- 明经币
- 个
- 注册时间
- 2002-7-5
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2002-10-8 14:12:00
|
显示全部楼层
我没明白你的意思,给你一个文本反应器的例子,自己参考参考
The following example creates a simple context reactor that responds to a variety of input context events:
#include <adslib.h>
#include <aced.h>
#include <dbmain.h>
#include <rxregsvc.h>
#include <acedinpt.h>
#include <acdocman.h>
// The input context reactor class.
class MyContextReactor : public AcEdInputContextReactor
{
public:
void beginGetPoint(const AcGePoint3d* pointIn,const char* promptString, int initGetFlags,const char* pKeywords);
void endGetPoint(Acad::PromptStatus returnStatus,const AcGePoint3d& pointOut, const char*& pKeyword);
void beginGetOrientation(const AcGePoint3d* pointIn,const char* promptString,int initGetFlags,const char* pKeywords);
void endGetOrientation(Acad::PromptStatus returnStatus, double& angle,const char*& pKeyword);
void beginGetCorner(const AcGePoint3d* firstCorner,const char* promptString,int initGetFlags,const char* pKeywords);
void endGetCorner(Acad::PromptStatus returnStatus, AcGePoint3d& secondCorner,const char*& pKeyword);
void beginSSGet(const char* pPrompt,int initGetFlags,const char* pKeywords,const char* pSSControls,const Array<AcGePoint3d>& points,const resbuf* entMask);
void endSSGet(Acad::PromptStatus returnStatus,const AcArray<AcDbObjectId>& ss);
};
void MyContextReactor::beginGetPoint(const AcGePoint3d* pointIn, const char* promptString,int initGetFlags,const char* pKeywords)
{
acutPrintf("beginGetPoint: pointIn = %.2f,%.2f,%.2f\n",
(*pointIn)[0], (*pointIn)[1], (*pointIn)[2]);
if (NULL != promptString)
acutPrintf("%s", promptString);
acutPrintf("initGetFlags: %d\n", initGetFlags);
if (NULL != pKeywords)
acutPrintf("Keywords: %s\n", pKeywords);
}
void MyContextReactor::endGetPoint(Acad::PromptStatus returnStatus, const AcGePoint3d& pointOut,const char*& pKeyword)
{
acutPrintf("endGetPoint: %d\n", returnStatus);
acutPrintf("%.2f,%.2f,%.2f\n", pointOut[0], pointOut[1],
pointOut[2]);
if (NULL != pKeyword)
acutPrintf("Keyword: %s\n", pKeyword);
}
void MyContextReactor::beginGetOrientation(const AcGePoint3d* pointIn,const char* promptString, int initGetFlags,const char* pKeywords)
{
acutPrintf("beginGetOrientation: %.2f, %.2f, %.2f\n",
(*pointIn)[0], (*pointIn)[1], (*pointIn)[2]);
}
void MyContextReactor::endGetOrientation(Acad::PromptStatus returnStatus,double& angle,const char*& pKeyword)
{
acutPrintf("endGetOrientation: %.2f\n", angle);
}
void MyContextReactor::beginGetCorner(const AcGePoint3d* firstCorner,const char* promptString,int initGetFlags,const char* pKeywords)
{
if (NULL != firstCorner)
{
acutPrintf(
"beginGetCorner: %.2f, %.2f, %.2f\n",
(*firstCorner)[0],
(*firstCorner)[1],
(*firstCorner)[2]);
}
}
void MyContextReactor::endGetCorner(Acad::PromptStatus returnStatus,AcGePoint3d& secondCorner,const char*& pKeyword)
{
acutPrintf("endGetCorner\n");
}
void MyContextReactor::beginSSGet(const char* pPrompt, int initGetFlags,const char* pKeywords,const char* pSSControls, const AcArray<AcGePoint3d>& points,const resbuf* entMask)
{
acutPrintf("beginSSGet:%s\n", NULL != pPrompt ? pPrompt : "");
for (int i = 0; i < points.length(); i++)
acutPrintf("%d: %.2f, %.2f, %.2f\n", i, points[X],
points[Y], points[Z]);
}
void MyContextReactor::endSSGet(Acad::PromptStatus returnStatus, const AcArray<AcDbObjectId>& ss)
{
acutPrintf("endSSGet\n");
for (int i = 0; i < ss.length(); i++)
acutPrintf("Entity %d: <%x>\n", i, ss.asOldId());
}
// My context reactor object
MyContextReactor my_icr;
extern "C" __declspec(dllexport) AcRx::AppRetCode
acrxEntryPoint(AcRx::AppMsgCode msg, void *p)
{
switch (msg)
{
case AcRx::kInitAppMsg:
acrxUnlockApplication(p);
acrxRegisterAppMDIAware(p);
break;
case AcRx::kLoadDwgMsg:
// Attach a context reactor to the current document.
//
curDoc()->inputPointManager()->
addInputContextReactor(&my_icr);
break;
case AcRx::kUnloadAppMsg:
// Warning! This sample attaches a context reactor,
// but it never detaches it. A real-life application
// will need to monitor to which document it attached
// the reactor, and will need to detach it.
//
break;
}
return AcRx::kRetOK;
} |
|