// Queries the user for Yes/No answer // static Adesk::Boolean getYorN(const char* pStr) { char yorn_str[132]; // specific prompt. // acutPrintf("\n%s", pStr); acedInitGet(0, "No Yes"); yorn_str[0] = 'Y'; yorn_str[1] = '\0'; switch (acedGetString(Adesk::kFalse, " -- No/<Yes>: ", yorn_str)) { case RTKWORD: acedGetInput(yorn_str); /* Deliberate fallthrough */ default: break; } return (!((yorn_str[0] == 'N') || (yorn_str[0] == 'n'))); }
// Queries the user for Yes/No answer // static Adesk::Boolean getYorN(const TCHAR* pStr) { TCHAR yorn_str[132]; // specific prompt. // acutPrintf(_T("\n%s"), pStr); acedInitGet(0, _T("No Yes")); yorn_str[0] = _T('Y'); yorn_str[1] = _T('\0'); switch (acedGetString(Adesk::kFalse, _T(" -- No/<Yes>: "), yorn_str)) { case RTKWORD: acedGetInput(yorn_str); /* Deliberate fallthrough */ default: break; } return (!((yorn_str[0] == _T('N')) || (yorn_str[0] == _T('n')))); }
ArxDbgUiPrBase::Status ArxDbgUiPrCorner::go() { CString prompt; int result; ads_point adsPt; int initFlag = RSG_NONULL; if (m_noLimCheck == true) initFlag += RSG_NOLIM; if (m_useDashedLine == true) initFlag += RSG_DASH; prompt.Format(_T("\n%s: "), message()); acedInitGet(initFlag, keyWords()); result = acedGetCorner(asDblArray(m_basePt), prompt, adsPt); if (result == RTNORM) { m_value = asPnt3d(adsPt); return ArxDbgUiPrBase::kOk; } else if (result == RTKWORD) { const size_t kBufSize = 512; acedGetInput(m_keyWordPicked.GetBuffer(kBufSize), kBufSize); m_keyWordPicked.ReleaseBuffer(); return ArxDbgUiPrBase::kKeyWord; } else return ArxDbgUiPrBase::kCancel; }
ArxDbgUiPrBase::Status ArxDbgUiPrAngleDef::go() { CString prompt; char defStr[512]; int initFlag; // set up prompt acdbAngToS(m_default, m_unit, m_precision, defStr); prompt.Format(_T("\n%s<%s>: "), message(), defStr); // set up init flag if (m_angType == kNoZero) initFlag = RSG_NOZERO; else initFlag = 0; int result; while (1) { acedInitGet(initFlag, keyWords()); if (m_useBasePt) result = acedGetOrient(asDblArray(m_basePt), prompt, &m_value); else result = acedGetOrient(NULL, prompt, &m_value); if (result == RTNORM) { if (inRange()) return ArxDbgUiPrBase::kOk; } else if(result == RTKWORD) { acedGetInput(m_keyWordPicked.GetBuffer(512)); m_keyWordPicked.ReleaseBuffer(); return ArxDbgUiPrBase::kKeyWord; } else if (result == RTNONE) { if (m_angType == ArxDbgUiPrAngle::kRange) { ASSERT(m_minVal != m_maxVal); // make sure they set ranges! ASSERT((m_default >= m_minVal) && (m_default <= m_maxVal)); } m_value = m_default; return ArxDbgUiPrBase::kOk; } else return ArxDbgUiPrBase::kCancel; } }
ArxDbgUiPrBase::Status ArxDbgUiPrInt::go() { CString prompt; int initFlag; // set up prompt prompt.Format(_T("\n%s: "), message()); // set up init flag if (m_intType == kNoZero) initFlag = RSG_NONULL+RSG_NOZERO; else if (m_intType == kNoNeg) initFlag = RSG_NONULL+RSG_NONEG; else if (m_intType == kNoNegNoZero) initFlag = RSG_NONULL+RSG_NOZERO+RSG_NONEG; else if (m_intType == kNoNegNoZeroAllowNone) initFlag = RSG_NOZERO+ RSG_NONEG; else initFlag = RSG_NONULL; while (1) { acedInitGet(initFlag, keyWords()); int result = acedGetInt(prompt, &m_value); if (result == RTNORM) { if (inRange()) return ArxDbgUiPrBase::kOk; } else if (result == RTKWORD) { acedGetInput(m_keyWordPicked.GetBuffer(512)); m_keyWordPicked.ReleaseBuffer(); return ArxDbgUiPrBase::kKeyWord; } else if (result == RTNONE) { return ArxDbgUiPrBase::kNone; } else return ArxDbgUiPrBase::kCancel; } }
// get yes or no choice from the user bool getYorN(char *msg) { int res, retcode; char kw[4]; acutPrintf("\n %s [Yes/No]", msg); do { acedInitGet(RSG_NONULL, "Yes No"); retcode = acedGetInt(NULL, &res); switch (retcode) { case RTKWORD: if(acedGetInput(kw) != RTNORM) { acutPrintf("\nError getting Yes/No choice"); return false; } if(strcmp(kw, "Yes") == 0) { return true; } else if(strcmp(kw, "No") == 0) { return false; } else { acutPrintf("\nKeyword Error!!"); return false; } break; default: acutPrintf("\n Enter <Yes/No> :"); break; } } while(retcode != RTKWORD); return true; }
ArxDbgUiPrBase::Status ArxDbgUiPrAngle::go() { CString prompt; int initFlag = 0; // set up prompt prompt.Format(_T("\n%s: "), message()); // set up init flag if (m_allowNone == false) initFlag += RSG_NONULL; if (m_angType == kNoZero) initFlag += RSG_NOZERO; int result; while (1) { acedInitGet(initFlag, keyWords()); if (m_useBasePt) result = acedGetOrient(asDblArray(m_basePt), prompt, &m_value); else result = acedGetOrient(NULL, prompt, &m_value); if (result == RTNORM) { if (inRange()) return ArxDbgUiPrBase::kOk; } else if (result == RTKWORD) { acedGetInput(m_keyWordPicked.GetBuffer(512)); m_keyWordPicked.ReleaseBuffer(); return ArxDbgUiPrBase::kKeyWord; } else if (result == RTNONE) { if (inRange()) return ArxDbgUiPrBase::kOk; } else return ArxDbgUiPrBase::kCancel; } }
void commandStats() { char option_str[132]; // specific prompt. acedInitGet(0, "Cumulative Session"); option_str[0] = 'S'; option_str[1] = '\0'; switch (acedGetKword("\nCumulative/<Session>:", option_str)) { case RTKWORD: acedGetInput(option_str); /* Deliberate fallthrough */ default: break; } if (((option_str[0] == 'C') || (option_str[0] == 'c'))) { // record this command's duration now, so updateCumulativeStats will // wipe it out. How this didn't cause continual crashes before is // beyond me. WCA 7/15/98 After this call, the current doc command // stack should also be empty. recordCommandDuration(NULL); if (!updateCumulativeStats()) { acutPrintf("\nA Command or LISP expression is active"); acutPrintf(" in at least one document,"); acutPrintf("\nSession Statistics may not be printed or saved now.\n"); return; } acutPrintf("\n\nCumulative Command Usage Statistics"); printStats(cumulativeStats); acutPrintf("\nNOTE: Session Statistics have been recorded and reset.\n"); delete cumulativeStats; cumulativeStats = NULL; } else { acutPrintf("\n\nCurrent Session Command Usage Statistics"); printStats(sessionStats); } }
ArxDbgUiPrBase::Status ArxDbgUiPrEntity::go() { CString prompt; int result; int errNum; ads_point adsPt; ads_name ent; AcDbObjectId tmpId; AcDbEntity* tmpEnt; Acad::ErrorStatus es; prompt.Format(_T("\n%s: "), message()); while (1) { acedInitGet(0, keyWords()); result = acedEntSel(prompt, ent, adsPt); if (result == RTNORM) { ArxDbgUtils::enameToObjId(ent, tmpId); es = acdbOpenAcDbEntity(tmpEnt, tmpId, AcDb::kForRead); if (es == Acad::eOk) { // if its correct class and we are not filtering locked layers its ok, // or if we are filtering locked layers and this one isn't on a locked layer if (correctClass(tmpEnt)) { // correctClass() will print error msg if ((!m_filterLockedLayers) || (ArxDbgUtils::isOnLockedLayer(tmpEnt, true) == false)) { // isOnLockedLayer() will print error msg tmpEnt->close(); m_pickPt = asPnt3d(adsPt); m_objId = tmpId; return ArxDbgUiPrBase::kOk; } } tmpEnt->close(); // close and loop again until they get it right! } else { ASSERT(0); ArxDbgUtils::rxErrorMsg(es); return ArxDbgUiPrBase::kCancel; } } else if (result == RTERROR) { getSysVar(AcadVar::adserr, errNum); if (errNum == OL_ENTSELPICK) // picked but didn't get anything acutPrintf(_T("\nNothing selected.")); else if (errNum == OL_ENTSELNULL) { // hit RETURN or SPACE if (m_allowNone) return ArxDbgUiPrBase::kNone; // prompt specifically wants to know about None else return ArxDbgUiPrBase::kCancel; // prompt wants to bail on None } else acutPrintf(_T("\nNothing selected.")); } else if (result == RTKWORD) { acedGetInput(m_keyWordPicked.GetBuffer(512)); m_keyWordPicked.ReleaseBuffer(); return ArxDbgUiPrBase::kKeyWord; } else if (result == RTNONE) { return ArxDbgUiPrBase::kNone; } else return ArxDbgUiPrBase::kCancel; } }
//----------------------------------------------------------------------------- // This function uses the AcEdJig mechanism to create and // drag the polyline entity. // void createRect() { // First have the user select the first corner point. // We don't use the Jig for this because there is // nothing to see yet. // int stat, oldOrthoMode; int terminated = FALSE; char keyWord[10]; plineInfo.m_elevHandSet = plineInfo.m_elev != 0.0; // Since it looks quite strange to have orthomode on while trying to draw a // rectangle, we'll temporarily turn it off. Remembering the current setting // and resetting it when we leave. // oldOrthoMode = getIntSysVar(/*NOXLATE*/"ORTHOMODE"); setIntSysVar(/*NOXLATE*/"ORTHOMODE", 0); // Flip to the graphic screen // acedGraphScr(); // Add value line. if ((plineInfo.m_first != 0.0 && plineInfo.m_second != 0 && plineInfo.m_radius == 0.0) || (plineInfo.m_elev != 0) ||(plineInfo.m_radius != 0)||(plineInfo.m_thick != 0) || (plineInfo.m_width != 0)) { acutPrintf("\nRectangle modes: "); if (plineInfo.m_first != 0.0 && plineInfo.m_second != 0. && plineInfo.m_radius == 0.0) { acutPrintf("Chamfer=%.16q0 x %.16q0 ", plineInfo.m_first, plineInfo.m_second); } if (plineInfo.m_elev != 0.) acutPrintf("Elevation=%.16q0 ", plineInfo.m_elev); if (plineInfo.m_radius != 0.) acutPrintf("Fillet=%.16q0 ", plineInfo.m_radius); if (plineInfo.m_thick != 0.) acutPrintf("Thickness=%.16q0 ", plineInfo.m_thick); if (plineInfo.m_width != 0.) acutPrintf("Width=%.16q0 ", plineInfo.m_width); acutPrintf("\n"); } while(!terminated) { // Main prompt for user input. // acedInitGet(RSG_NONULL, "Chamfer Elevation Fillet Thickness Width"); if ((stat = acedGetPoint(NULL, "\nChamfer/Elevation/Fillet/Thickness/Width/<First corner>: ", asDblArray(plineInfo.m_topLeftCorner)))== RTKWORD) { acedGetInput(keyWord); } else { if (stat == RTCAN) terminated = TRUE; break; } switch(indexOfKeyWord(keyWord, "Chamfer Elevation Fillet Thickness Width")) { // Chamfer; case 0: // Retrieve the first chamfer distance. // acutPrintf("\nFirst chamfer distance for rectangles <%.16q0>: ", plineInfo.m_first == 0.0 ? plineInfo.m_radius : plineInfo.m_first); if ((stat = acedGetDist(NULL, NULL, &plineInfo.m_first)) == RTCAN) { terminated = TRUE; break; } else if (stat == RTNONE && plineInfo.m_first == 0.0) plineInfo.m_second = plineInfo.m_radius; // Retrieve the second chamfer distance. // acutPrintf("\nSecond chamfer distance for rectangles <%.16q0>: ", plineInfo.m_second == 0.0 ? plineInfo.m_first : plineInfo.m_second); if ((stat = acedGetDist(NULL, NULL, &plineInfo.m_second)) == RTCAN) { plineInfo.m_first = 0.0; plineInfo.m_second= 0.0; terminated = TRUE; } else { if (stat == RTNONE && plineInfo.m_second == 0.0) plineInfo.m_second = plineInfo.m_first; // If we actually set the chamfer distances, then zero out the // radius and bulge. // plineInfo.m_radius = 0.0; plineInfo.m_bulge = 0.0; } break; // Elevation; case 1: // Retrieve the radius to apply to the filleting of the corners. // acutPrintf("\nElevation for rectangles <%.16q0>: ", plineInfo.m_elev); if ((stat = acedGetDist(NULL, NULL, &plineInfo.m_elev)) == RTCAN) terminated = TRUE; plineInfo.m_elevHandSet = (plineInfo.m_elev == 0.0) ? FALSE : TRUE; break; // Fillet; case 2: // Retrieve the radius to apply to the filleting of the corners. // If the user has previously used the chamfer, then use the // first disance as the default for the radius. // acutPrintf("\nFillet radius for rectangles <%.16q0>: ", plineInfo.m_radius == 0.0 ? plineInfo.m_first : plineInfo.m_radius); if ((stat = acedGetDist(NULL, NULL, &plineInfo.m_radius)) == RTCAN) { terminated = TRUE; } else { if (stat == RTNONE && plineInfo.m_radius == 0.0) plineInfo.m_radius = plineInfo.m_first; plineInfo.m_second = plineInfo.m_first = plineInfo.m_radius; // Bulge is tangent of 1/4 of the included angle. // We'll assume normal[Z] > 0. & clock wise for now, // hence the '-'. plineInfo.m_bulge = -tan(PI / 8.0); } break; // Thickness; case 3: // Retrieve the thickness to apply to the polyline. // acutPrintf("\nThickness for rectangles <%.16q0>: ", plineInfo.m_thick); if ((stat = acedGetDist(NULL, NULL, &plineInfo.m_thick)) == RTCAN) { terminated = TRUE; } break; // Width; case 4: // Retrieve the width to apply to the polyline. // acutPrintf("\nWidth for rectangles <%.16q0>: ", plineInfo.m_width); if ((stat = acedGetDist(NULL, NULL, &plineInfo.m_width)) == RTCAN) { terminated = TRUE; } break; // Just in case; default: terminated = TRUE; break; } } if (!terminated) { if (plineInfo.m_first != 0.0) { // If we are treating the corners, then calculate the unit vector // of the corners. Note for filleting the angle is 45 degrees. // plineInfo.m_chamfDirUnitVec = AcGeVector3d(plineInfo.m_second, plineInfo.m_first, plineInfo.m_elev); univec(plineInfo.m_chamfDirUnitVec, plineInfo.m_chamfDirUnitVec); } // Create an AsdkRectangleJig object passing in the CRectInfo sturcture // filled during the users input // AsdkRectangleJig* pJig = new AsdkRectangleJig(); // Now start up the jig to interactively get the opposite corner. // pJig->doRectangle(); // Now delete the jig object since it's no longer needed // delete pJig; } // Be nice and reset it now. // setIntSysVar(/*NOXLATE*/"ORTHOMODE", oldOrthoMode); return; }