- UID
- 5043
- 积分
- 1357
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-5-13
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
[pcode=cpp,true]
static LPCTSTR docLockModeToStr(AcAp::DocLockMode activity, CString& str);
static LPCTSTR dateToStr(const AcDbDate& date, CString& str);
static LPCTSTR promptStatusToStr(Acad::PromptStatus stat, CString& str);
static LPCTSTR initFlagsToStr(int initFlags, CString& str);
static LPCTSTR deepCloneContextToStr(AcDb::DeepCloneType context, CString& str);
static LPCTSTR filerTypeToStr(AcDb::FilerType type, CString& str);
static LPCTSTR osnapToStr(int osnapMode, CString& str);
static LPCTSTR doubleArray3dToStr(double array[], CString& str);
static LPCTSTR doubleArray2dToStr(double array[], CString& str);
static void stuffAcadCmdLine(const CString& str);
static void clearAcadCmdLine();
static void printIdMap(AcDbIdMapping* idMap, LPCTSTR msgStr);
static Acad::ErrorStatus getPlinePointArrayFromUser(AcGePoint3dArray& vertices);
static void grdrawPline(const AcGePoint3dArray& pts, BOOL close, BOOL hilite);
static void debugPause(LPCTSTR msg);
static Acad::ErrorStatus getFileName(bool isForWrite, LPCTSTR prompt,
LPCTSTR def, LPCTSTR ext, CString& fname,
bool defIsDirectory = true,
bool allowArbitraryExt = false);
static Acad::ErrorStatus getFileNameForRead(LPCTSTR prompt, LPCTSTR def,
LPCTSTR ext, CString& fname,
bool defIsDirectory = true,
bool allowArbitraryExt = false);
static Acad::ErrorStatus getFileNameForWrite(LPCTSTR prompt, LPCTSTR def,
LPCTSTR ext, CString& fname,
bool defIsDirectory = true,
bool allowArbitraryExt = false);
static ArxDbgUiPrBase::Status yesNoPrompt(LPCTSTR msg, bool& answer);
static ArxDbgUiPrBase::Status yesNoPromptDef(LPCTSTR msg, bool& answer, bool def);
static ArxDbgUiPrBase::Status getNewSymbolName(LPCTSTR msg, AcRxClass* symType, CString& symName);
static ArxDbgUiPrBase::Status getExistingSymbolName(LPCTSTR msg, AcRxClass* symType,
CString& symName, bool allowPipes = true);
static bool getEntityOrObject(AcDbObjectId& objId);
[/pcode]
[sell=10]
[pcode=cpp,true]
/****************************************************************************
**
** XdAcadUi::docLockModeToStr
**
** **jma
**
*************************************/
LPCTSTR
XdAcadUi::docLockModeToStr(AcAp::DocLockMode mode, CString& str)
{
str.Empty();
if (mode & AcAp::kNone)
str += _T("None");
if (mode & AcAp::kAutoWrite) {
if (str.IsEmpty() == false)
str += _T(" | ");
str += _T("Auto Write");
}
if (mode & AcAp::kNotLocked) {
if (str.IsEmpty() == false)
str += _T(" | ");
str += _T("Not Locked");
}
if (mode & AcAp::kWrite) {
if (str.IsEmpty() == false)
str += _T(" | ");
str += _T("Write");
}
if (mode & AcAp::kProtectedAutoWrite) {
if (str.IsEmpty() == false)
str += _T(" | ");
str += _T("Protected Auto Write");
}
if (mode & AcAp::kRead) {
if (str.IsEmpty() == false)
str += _T(" | ");
str += _T("Read");
}
if (mode & AcAp::kXWrite) {
if (str.IsEmpty() == false)
str += _T(" | ");
str += _T("X Write");
}
return str;
}
/***********************************************************************
**
** XdAcadUi::deepCloneContextToStr
**
** **jma
**
****************************************/
LPCTSTR
XdAcadUi::deepCloneContextToStr(AcDb::DeepCloneType context, CString& str)
{
if (context == AcDb::kDcCopy)
str = _T("Copy");
else if (context == AcDb::kDcExplode)
str = _T("Explode");
else if (context == AcDb::kDcBlock)
str = _T("Block");
else if (context == AcDb::kDcSymTableMerge)
str = _T("Sym Tbl Merge");
else if (context == AcDb::kDcInsert)
str = _T("Insert");
else if (context == AcDb::kDcInsertCopy)
str = _T("Insert Copy");
else if (context == AcDb::kDcWblock)
str = _T("Wblock");
else if (context == AcDb::kDcObjects)
str = _T("Objects");
else if (context == AcDb::kDcXrefInsert)
str = _T("XRef Insert");
else if (context == AcDb::kDcXrefBind)
str = _T("Xref Bind");
else if (context == AcDb::kDcWblkObjects)
str = _T("Wblock Objects");
else {
ASSERT(0);
str = _T("*Unknown*");
}
return str;
}
/***********************************************************************
**
** XdAcadUi::dateToStr
**
** **jma
**
****************************************/
LPCTSTR
XdAcadUi::dateToStr(const AcDbDate& date, CString& str)
{
str.Format(_T("%d Hr., %d Min., %d Sec, %d Msec"),
date.hour(), date.minute(), date.second(), date.millisecond());
return str;
}
/***********************************************************************
**
** XdAcadUi::promptStatusToStr
**
** **jma
**
****************************************/
LPCTSTR
XdAcadUi::promptStatusToStr(Acad::PromptStatus stat, CString& str)
{
if (stat == Acad::eNone)
str = _T("None");
else if (stat == Acad::eNormal)
str = _T("Normal");
else if (stat == Acad::eError)
str = _T("Error");
else if (stat == Acad::eCancel)
str = _T("Cancel");
else if (stat == Acad::eRejected)
str = _T("Rejected");
else if (stat == Acad::eFailed)
str = _T("Failed");
else if (stat == Acad::eKeyword)
str = _T("Keyword");
else if (stat == Acad::eDirect)
str = _T("Direct");
else {
ASSERT(0);
str.Format(_T("*Unknown* (%d)"), stat);
}
return str;
}
/***********************************************************************
**
** XdAcadUi::initFlagsToStr
**
** **jma
**
****************************************/
LPCTSTR
XdAcadUi::initFlagsToStr(int initFlags, CString& str)
{
str.Empty();
if (initFlags & RSG_NONULL)
str += _T("NoNull");
if (initFlags & RSG_NOZERO) {
if (str.IsEmpty() == false)
str += _T(" | ");
str += _T("NoZero");
}
if (initFlags & RSG_NONEG) {
if (str.IsEmpty() == false)
str += _T(" | ");
str += _T("NoNeg");
}
if (initFlags & RSG_NOLIM) {
if (str.IsEmpty() == false)
str += _T(" | ");
str += _T("NoLim");
}
if (initFlags & RSG_GETZ) {
if (str.IsEmpty() == false)
str += _T(" | ");
str += _T("GetZ");
}
if (initFlags & RSG_DASH) {
if (str.IsEmpty() == false)
str += _T(" | ");
str += _T("Dash");
}
if (initFlags & RSG_2D) {
if (str.IsEmpty() == false)
str += _T(" | ");
str += _T("2D");
}
if (initFlags & RSG_OTHER) {
if (str.IsEmpty() == false)
str += _T(" | ");
str += _T("Other");
}
if (initFlags & RSG_DDISTFIRST) {
if (str.IsEmpty() == false)
str += _T(" | ");
str += _T("DdDistFirst");
}
return str;
}
/***********************************************************************
**
** XdAcadUi::promptStatusToStr
**
** **jma
**
****************************************/
LPCTSTR
XdAcadUi::filerTypeToStr(AcDb::FilerType type, CString& str)
{
if (type == AcDb::kFileFiler)
str = _T("File");
else if (type == AcDb::kCopyFiler)
str = _T("Copy");
else if (type == AcDb::kUndoFiler)
str = _T("Undo");
else if (type == AcDb::kBagFiler)
str = _T("Bag");
else if (type == AcDb::kIdXlateFiler)
str = _T("IdXlate");
else if (type == AcDb::kPageFiler)
str = _T("Page");
else if (type == AcDb::kIdFiler)
str = _T("Id");
else if (type == AcDb::kDeepCloneFiler)
str = _T("DeepClone");
else if (type == AcDb::kPurgeFiler)
str = _T("Purge");
else if (type == AcDb::kWblockCloneFiler)
str = _T("WblockClone");
else {
ASSERT(0);
str.Format(_T("*Unknown* (%d)"), type);
}
return str;
}
/****************************************************************************
**
** XdAcadUi::osnapToStr
**
** **jma
**
*************************************/
LPCTSTR
XdAcadUi::osnapToStr(int osnapMode, CString& str)
{
if (osnapMode == AcDb::kOsModeEnd)
str = _T("End");
else if (osnapMode == AcDb::kOsModeMid)
str = _T("Mid");
else if (osnapMode == AcDb::kOsModeCen)
str = _T("Cen");
else if (osnapMode == AcDb::kOsModeNode)
str = _T("Node");
else if (osnapMode == AcDb::kOsModeQuad)
str = _T("Quad");
else if (osnapMode == AcDb::kOsModeIns)
str = _T("Ins");
else if (osnapMode == AcDb::kOsModePerp)
str = _T("Perp");
else if (osnapMode == AcDb::kOsModeTan)
str = _T("Tan");
else if (osnapMode == AcDb::kOsModeNear)
str = _T("Near");
else
str.Format(_T("*Unknown* (%d)"), osnapMode);
return str;
}
/****************************************************************************
**
** XdAcadUi::doubleArray3dToStr
**
** **jma
**
*************************************/
LPCTSTR
XdAcadUi::doubleArray3dToStr(double array[], CString& str)
{
str.Format(_T("(%.15g, %.15g, %.15g)"), array[0], array[1], array[2]);
return str;
}
/****************************************************************************
**
** XdAcadUi::doubleArray2dToStr
**
** **jma
**
*************************************/
LPCTSTR
XdAcadUi::doubleArray2dToStr(double array[], CString& str)
{
str.Format(_T("(%.15g, %.15g)"), array[0], array[1]);
return str;
}
/***********************************************************************
**
** XdAcadUi::printIdMap
**
** **jma
**
****************************************/
void
XdAcadUi::printIdMap(AcDbIdMapping* idMap, LPCTSTR msgStr)
{
AcDbObject* obj;
Acad::ErrorStatus es;
acutPrintf(_T("\n*********************************************\n"));
acutPrintf(_T("\nEVENT: %s"), msgStr);
AcDbIdPair idPair;
AcDbIdMappingIter mapIter(*idMap);
for (mapIter.start(); !mapIter.done(); mapIter.next()) {
if (mapIter.getMap(idPair)) {
es = acdbOpenAcDbObject(obj, idPair.value(), AcDb::kForRead);
if (es == Acad::eOk) {
acutPrintf(_T("\nCloned: <%-20s>"), XdAcadUi::objToClassStr(obj));
acutPrintf(_T("\n%ld --> %ld"), idPair.key().asOldId(), idPair.value().asOldId());
acutPrintf(_T("\nIsCloned: %ld"), idPair.isCloned());
acutPrintf(_T("\nIsXlated: %ld"), idPair.isOwnerXlated());
obj->close();
}
}
}
acutPrintf(_T("\n*********************************************\n"));
}
/***********************************************************************
**
** XdAcadUi::grdrawPline
**
** **jma
**
****************************************/
void
XdAcadUi::grdrawPline(const AcGePoint3dArray& pts, BOOL close, BOOL hilite)
{
int len;
if ((len = pts.length()) == 0)
return;
int color;
if (hilite)
color = 6;
else
color = 7;
for (int i=1;i<len;i++)
acedGrDraw(asDblArray(pts.at(i-1)), asDblArray(pts.at(i)), color, 0);
if (close)
acedGrDraw(asDblArray(pts.at(0)), asDblArray(pts.at(len-1)), color, 0);
}
/***********************************************************************
**
** XdAcadUi::stuffAcadCmdLine
**
** **jma
**
****************************************/
void
XdAcadUi::stuffAcadCmdLine(const CString& str)
{
if (str.IsEmpty())
return;
CString tmpStr = str;
tmpStr += _T("\n");
Acad::ErrorStatus es;
es = acDocManager->sendStringToExecute(acDocManager->curDocument(), tmpStr, false, true);
if (es != Acad::eOk)
XdAcadUi::rxErrorMsg(es);
}
/***********************************************************************
**
** XdAcadUi::clearAcadCmdLine
**
** **jma
**
****************************************/
void
XdAcadUi::clearAcadCmdLine()
{
acedGetAcadTextCmdLine()->PostMessage(WM_CHAR, VK_ESCAPE, 0);
acedGetAcadTextCmdLine()->PostMessage(WM_CHAR, VK_ESCAPE, 0);
}
/****************************************************************************
**
** XdAcadUi::getPlinePointArrayFromUser
**
** **jma
**
*************************************/
Acad::ErrorStatus
XdAcadUi::getPlinePointArrayFromUser(AcGePoint3dArray& vertices)
{
int i = 0;
ArxDbgUiPrPoint prPoint(_T("Point"), NULL);
prPoint.setAllowNone(true);
while (prPoint.go() == ArxDbgUiPrBase::kOk) {
vertices.append(prPoint.value());
if (i > 0)
acedGrDraw(asDblArray(vertices[i-1]), asDblArray(vertices), -1, 0);
i++;
prPoint.setBasePt(prPoint.value());
}
int ptCount = vertices.length();
if (ptCount < 2) {
acutPrintf(_T("\nThere must be at least 2 points."));
return Acad::eInvalidInput;
}
i = 1;
while(i < ptCount){
acedGrDraw(asDblArray(vertices[i-1]), asDblArray(vertices), -1, 0);
i++;
}
return Acad::eOk;
}
/************************************************************************
**
** XdAcadUi::debugPause
**
** **jma
**
***********************************/
void
XdAcadUi::debugPause(LPCTSTR msg)
{
TCHAR str[256];
if (msg)
acedGetString(0, msg, str);
else
acedGetString(0, _T("\nPAUSE: Press <RETURN> to continue >>> "), str);
}
/****************************************************************************
**
** XdAcadUi::getFileName
** use AutoCAD's acedGetFileD() to get a file name from the user. Support
** drawing preview for AutoCAD DWG files, but looks like Win32 Explorer dialog
**
** **jma
**
*************************************/
Acad::ErrorStatus
XdAcadUi::getFileName(bool isForWrite, LPCTSTR prompt,
LPCTSTR def, LPCTSTR ext, CString& fname,
bool defIsDirectory, bool allowArbitraryExt)
{
resbuf *rb;
int flags;
short result;
flags = 2; // disable the silly "type it" button
if (isForWrite)
flags += 1;
if (allowArbitraryExt)
flags += 4; // enable arbitrary extension
if (defIsDirectory)
flags += 16; // interpret default path as directory, not filename
rb = acutNewRb(RTSTR);
rb->resval.rstring = NULL;
result = acedGetFileD(prompt, def, ext, flags, rb);
if (result != RTNORM) {
acutRelRb(rb);
return Acad::eInvalidInput;
}
else {
fname = rb->resval.rstring;
acutRelRb(rb);
return Acad::eOk;
}
}
/****************************************************************************
**
** XdAcadUi::getFileNameForRead
** wrapper function for opening for read
**
** **jma
**
*************************************/
Acad::ErrorStatus
XdAcadUi::getFileNameForRead(LPCTSTR prompt, LPCTSTR def, LPCTSTR ext,
CString& fname, bool defIsDirectory, bool allowArbitraryExt)
{
return getFileName(false, prompt, def, ext, fname, defIsDirectory, allowArbitraryExt);
}
/****************************************************************************
**
** XdAcadUi::getFileNameForWrite
** wrapper function for opening for read
**
** **jma
**
*************************************/
Acad::ErrorStatus
XdAcadUi::getFileNameForWrite(LPCTSTR prompt, LPCTSTR def, LPCTSTR ext,
CString& fname, bool defIsDirectory, bool allowArbitraryExt)
{
return getFileName(true, prompt, def, ext, fname, defIsDirectory, allowArbitraryExt);
}
/****************************************************************************
**
** XdAcadUi::yesNoPrompt
**
** **jma
**
*************************************/
ArxDbgUiPrBase::Status
XdAcadUi::yesNoPrompt(LPCTSTR msg, bool& answer)
{
ArxDbgKeywordArray kwords(ArxDbgApp::getApp()->dllInstance());
kwords.append(_T("Yes"), _T("Yes"));
kwords.append(_T("No"), _T("No"));
CString optionsStr, kwordStr;
kwords.makeOptionsList(optionsStr);
kwords.makeKeywordList(kwordStr);
// Concatenate original message with options list (in sqr braces)
// Also prevent any extra white space chars between msg & [op1/op2]
// <msg - w/o xtra trailing white space> + <space> + [<options list>]
//
// Example: msg = "Do it?" or "Do it? "
// Prompt String: "Do it? [Yes/No]" and NOT "Do it? [Yes/No]"
//
// Final Prompt from ArxDbgUiPrKeyWord::getKeyWord():
// "\nDo it? [Yes/No]: "
CString msgSansTrlSpc, promptStr;
msgSansTrlSpc = msg;
msgSansTrlSpc.TrimRight();
promptStr.Format(_T("%s %s"), msgSansTrlSpc, optionsStr);
ArxDbgUiPrKeyWord prmpt(promptStr, kwordStr);
if (prmpt.go() == ArxDbgUiPrBase::kOk) {
int keywordIndex;
if (kwords.find(prmpt.keyWordPicked(), keywordIndex) == Adesk::kFalse) {
return ArxDbgUiPrBase::kCancel;
}
if (keywordIndex == 0) // Yes
answer = true;
else // No
answer = false;
return ArxDbgUiPrBase::kOk;
}
else
return ArxDbgUiPrBase::kCancel;
}
/****************************************************************************
**
** XdAcadUi::yesNoPromptDef
**
** **jma
**
*************************************/
ArxDbgUiPrBase::Status
XdAcadUi::yesNoPromptDef(LPCTSTR msg, bool& answer, bool def)
{
LPCTSTR defStr;
if (def == true)
defStr = _T("Y");
else
defStr = _T("N");
ArxDbgKeywordArray kwords(ArxDbgApp::getApp()->dllInstance());
kwords.append(_T("Yes"), _T("Yes"));
kwords.append(_T("No"), _T("No"));
CString optionsStr, kwordStr;
kwords.makeOptionsList(optionsStr);
kwords.makeKeywordList(kwordStr);
// Concatenate original message with options list (in sqr braces)
// Also prevent any extra white space chars between msg & [op1/op2], but
// add a trailing space to separate the [op1/op2] and default string "<Y>:"
// <msg - w/o xtra trailing white space> + <space> + [<options list>] + <space>
//
// Example: msg = "Do it?" or "Do it? "
// def = TRUE
// Prompt string: "Do it? [Yes/No]" and NOT "Do it? [Yes/No]"
//
// Final Prompt from ArxDbgUiPrKeyWordDef::getKeyWord():
// "\nDo it? [Yes/No] <Y>: "
CString msgSansTrlSpc, promptStr;
msgSansTrlSpc = msg;
msgSansTrlSpc.TrimRight();
promptStr.Format(_T("%s %s "), msgSansTrlSpc, optionsStr);
ArxDbgUiPrKeyWordDef prmpt(promptStr, kwordStr, defStr);
if (prmpt.go() == ArxDbgUiPrBase::kOk) {
int keywordIndex;
if (kwords.find(prmpt.keyWordPicked(), keywordIndex) == Adesk::kFalse) {
return ArxDbgUiPrBase::kCancel;
}
if (keywordIndex == 0) // Yes
answer = true;
else // No
answer = false;
return ArxDbgUiPrBase::kOk;
}
else
return ArxDbgUiPrBase::kCancel;
}
/****************************************************************************
**
** XdAcadUi::getNewSymbolName
**
** **jma
**
*************************************/
ArxDbgUiPrBase::Status
XdAcadUi::getNewSymbolName(LPCTSTR msg, AcRxClass* symType, CString& symName)
{
ArxDbgUiPrString prName(msg, false);
while (1) {
if (prName.go() == ArxDbgUiPrBase::kCancel)
return ArxDbgUiPrBase::kCancel;
if (acdbSNValid(prName.value(), 0) != RTNORM) {
acutPrintf(_T("\n\"%s\" is not a valid symbol name."), prName.value());
continue;
}
if (XdAcadUi::symbolExists(symType, prName.value(), acdbHostApplicationServices()->workingDatabase()) == TRUE)
acutPrintf(_T("\nSymbol \"%s\" already exists."), prName.value());
else {
symName = prName.value();
return ArxDbgUiPrBase::kOk;
}
}
}
/****************************************************************************
**
** XdAcadUi::getExistingSymbolName
**
** **jma
**
*************************************/
ArxDbgUiPrBase::Status
XdAcadUi::getExistingSymbolName(LPCTSTR msg, AcRxClass* symType, CString& symName,
bool allowPipes)
{
ArxDbgUiPrString prName(msg, false);
while (1) {
if (prName.go() == ArxDbgUiPrBase::kCancel)
return ArxDbgUiPrBase::kCancel;
if (acdbSNValid(prName.value(), allowPipes) != RTNORM) {
acutPrintf(_T("\n\"%s\" is not a valid symbol name."), prName.value());
continue;
}
if (XdAcadUi::symbolExists(symType, prName.value(), acdbHostApplicationServices()->workingDatabase()) == false)
acutPrintf(_T("\nSymbol \"%s\" does not exist."), prName.value());
else {
symName = prName.value();
return ArxDbgUiPrBase::kOk;
}
}
}
/****************************************************************************
**
** XdAcadUi::getEntityOrObject
**
** **jma
**
*************************************/
bool
XdAcadUi::getEntityOrObject(AcDbObjectId& objId)
{
ArxDbgUiPrEntity prEnt("Select an entity (or RETURN for Handle)", NULL);
prEnt.setAllowNone(true);
ArxDbgUiPrBase::Status stat = prEnt.go();
if (stat == ArxDbgUiPrBase::kNone) {
ArxDbgUiPrString prHandle("Handle of database object", false);
if (prHandle.go() == ArxDbgUiPrBase::kOk) {
CString handleStr = prHandle.value();
if (handleStr.IsEmpty())
return false;
if (XdAcadUi::handleStrToObjId(acdbHostApplicationServices()->workingDatabase(), prHandle.value(), objId) != Acad::eOk) {
acutPrintf("\nERROR: Couldn't find that handle!");
return false;
}
return true;
}
return false;
}
else if (stat == ArxDbgUiPrBase::kOk) {
objId = prEnt.objectId();
return true;
}
else {
return false;
}
}
[/pcode]
[/sell]
|
评分
-
查看全部评分
|