// 查找从根类型派生的图元 void ArxClassHelper::GetArxClassTypes( const CString& root, AcStringArray& types, bool findAbstractType ) { // 如果根类型不存在,默认为AcDbObject AcRxClass* pParentClass = AcRxClass::cast( acrxClassDictionary->at( root ) ); if( pParentClass == 0 ) pParentClass = AcDbObject::desc(); AcRxDictionaryIterator* iter = acrxClassDictionary->newIterator(); if( iter == 0 ) return; for( ; !iter->done(); iter->next() ) { AcRxClass* pClass; if( ( pClass = AcRxClass::cast( iter->object() ) ) != NULL ) { if( pClass->isDerivedFrom( pParentClass ) ) { const ACHAR* text = pClass->name(); if( text == NULL ) continue; if( !findAbstractType && ( pClass->dxfName() == NULL ) || ( pClass->appName() == NULL ) ) continue; //acutPrintf(_T("appName:%s\ndxfName:%s\nname:%s\n"), pClass->appName(), pClass->dxfName(), pClass->name()); types.append( text ); } } } delete iter; }
void ArxDbgUiDlgClassDict::buildClassList() { // get an interator over the class dictionary AcRxDictionary* classDict = acrxClassDictionary; AcRxDictionaryIterator* iter; if ((classDict == NULL) || ((iter = classDict->newIterator()) == NULL)) { ArxDbgUtils::stopAlertBox(_T("ERROR: Couldn't get class dictionary.")); return; } // iterate over each item and get its info AcRxObject* classDictItem; AcRxClass* classObj; const char* text; CString str, className, dxfName, appName; for (; !iter->done(); iter->next()) { classDictItem = iter->object(); if ((classObj = AcRxClass::cast(classDictItem)) != NULL) { if ((text = classObj->appName()) != NULL) appName = text; else appName = _T(""); if ((text = classObj->name()) != NULL) className = text; else className = _T(""); if ((text = classObj->dxfName()) != NULL) dxfName = text; else dxfName = _T(""); m_classNameStrList.AddTail(className); m_dxfNameStrList.AddTail(dxfName); m_appNameStrList.AddTail(appName); if (dxfName.IsEmpty()) { m_proxyStrList.AddTail(_T("")); m_birthDwgVerList.AddTail(_T("")); m_birthMntVerList.AddTail(_T("")); } else { int dwgVer = 0; int maintVer = 0; classObj->getClassVersion(dwgVer, maintVer); m_proxyStrList.AddTail(ArxDbgUtils::intToStr(classObj->proxyFlags(), str)); m_birthDwgVerList.AddTail(ArxDbgUtils::dwgVersionToStr(static_cast<AcDb::AcDbDwgVersion>(dwgVer), str)); m_birthMntVerList.AddTail(ArxDbgUtils::intToStr(maintVer, str)); } } else { ArxDbgUtils::stopAlertBox(_T("ERROR: found non AcRxClass in class dictionary!")); } } delete iter; }
void printStats(AcRxDictionary* statDict) { AcRxDictionaryIterator* iter; acutPrintf("\n\nCommand Count Elapsed Time\n"); acutPrintf("---------------------- ------- ----------\n"); for (iter = statDict->newIterator(AcRx::kDictSorted); !iter->done(); iter->next()) { // Write out the command string. acutPrintf("%s", iter->key()); // Try for a little reasonable text alignment, // assuming 24 characters for a command or lisp name is sufficient. // But, we'll go to the MAX_CMD_LENGTH, plus one blank, if we must. int nbrOfSpaces = 24 - strlen(iter->key()); do acutPrintf(" "); while (--nbrOfSpaces > 0); // Now the count, plus elapsed time, in primate-comprehensible form. int TempElapsedTime = (int) (((AsdkCommandRecord*) iter->object())->elapsedTime); int hours = TempElapsedTime / 3600; int minutes = (TempElapsedTime % 3600) / 60; acutPrintf("%7i %4d:%0*d:%0*.*f\n", ((AsdkCommandRecord*)iter->object())->count, hours, 2, minutes, 5, 2, ((AsdkCommandRecord*) iter->object())->elapsedTime - (hours * 3600) - (minutes * 60)); } delete iter; }
void AecUiPrEntitySet::getAllowableClassTypes() { ASSERT(m_allowedClassTypes.length() == m_doIsATest.length()); m_classTypeCache = m_allowedClassTypes; // copy over all the definite classes that are ok AcRxDictionaryIterator* iter; AcRxDictionary* classDict = acrxClassDictionary; if (classDict == NULL) { AEC_ASSERT(0); return; } int len = m_doIsATest.length(); for (int i=0; i<len; i++) { // if not doing isA() testing, must get all classes derived from // this one. if (m_doIsATest[i] == Adesk::kFalse) { iter = classDict->newIterator(); if (iter != NULL) { // iterate over each item and get its info AcRxObject* classDictItem; AcRxClass* classObj; for (; !iter->done(); iter->next()) { classDictItem = iter->object(); if ((classObj = AcRxClass::cast(classDictItem)) != NULL) { if (classObj->isDerivedFrom(static_cast<AcRxClass*>(m_allowedClassTypes[i]))) { if (m_classTypeCache.contains(classObj) == Adesk::kFalse) { m_classTypeCache.append(classObj); } } } else { AEC_ASSERT(0); } } delete iter; } else { AEC_ASSERT(0); } } } }
bool ArxClassHelper::GetChildClass( const CString& type, AcStringArray& types ) { AcRxClass* pParentClass = AcRxClass::cast( acrxClassDictionary->at( type ) ); if( pParentClass == 0 ) return false; // 类型不存在 AcRxDictionaryIterator* iter = acrxClassDictionary->newIterator(); if( iter == 0 ) return false; AcRxClass* pClass; for( ; !iter->done(); iter->next() ) { if( ( pClass = AcRxClass::cast( iter->object() ) ) != NULL ) { const ACHAR* text = pClass->name(); if( ( text != NULL ) && ( pClass->myParent() == pParentClass ) ) { types.append( text ); } } } delete iter; return true; }
Adesk::Boolean updateCumulativeStats() { // If anything is going on in any document, now is NOT a good // time to accumulate stats, because each command/LISP expression // in progress has pointers into session stats. // This could be fixed with more recoding than I have time to do // now. WCA 7/15/98 for (int i = docData.length() - 1; i >= 0; i--) { // Make sure our info is up to date. if (docData[i].doc == curDocGlobals.doc) docData[i] = curDocGlobals; if ((docData[i].cmdIndex > 0) || (docData[i].lispRcd != NULL)) return Adesk::kFalse; } if (!readCumulativeStats()) { acutPrintf("\nWarning: Could not find Command Statistics file.\n"); acutPrintf("Will try to create it.\n"); } AcRxDictionaryIterator* iter; // Loop over current session stats, and merge them into cumulative stats. for (iter = sessionStats->newIterator(); !iter->done(); iter->next()) { AsdkCommandRecord* sessionCmdRcd = (AsdkCommandRecord*) iter->object(); AsdkCommandRecord* cumulativeCmdRcd = (AsdkCommandRecord*) cumulativeStats->at(iter->key()); if (!cumulativeCmdRcd) // First time, add it. cumulativeStats->atPut(iter->key(), new AsdkCommandRecord(sessionCmdRcd->count, sessionCmdRcd->elapsedTime)); else { // Not the first time, so bump it. cumulativeCmdRcd->count += sessionCmdRcd->count; cumulativeCmdRcd->elapsedTime += sessionCmdRcd->elapsedTime; } } delete iter; // Now that it has been added in, wipe out the current session Stats; delete sessionStats; sessionStats = initStatDictionary(); // Open the cumulative stat file, creating it if necessary. char statFilePath[MAX_PATH_LENGTH]; int ret = cmdcount_findfile(statFileName, statFilePath,true); assert(ret==RTNORM);//this should always succeed // Open the file FILE* statFile = fopen(statFilePath, /*NOXLATE*/"w"); if (statFile == NULL) { // Bad permission in our chosen directory. Give up. acedAlert("Warning: Could not create Command Statistics file."); return Adesk::kTrue; } // Print version number of STATFILE fprintf(statFile, "v%04.1f\n", STAT_FILENAME_VERSION); // Print create date of STATFILE if (!*createDate) { fprintf(statFile, "Created: "); printCurrentDateTime(statFile); fprintf(statFile, "\n"); } else fprintf(statFile, "%s\n", createDate); // Print date last modified for STATFILE fprintf(statFile, "Last Modified: "); printCurrentDateTime(statFile); fprintf(statFile, "\n"); resbuf tempRes; // Print LOGINNAME if (acedGetVar(/*NOXLATE*/"LOGINNAME", &tempRes) != RTNORM) { sprintf(abort_msg, "%.*s Command\nStatistics Gatherer\nFailure 1", PRODUCTL, getProductName()); acrx_abort(abort_msg); } fprintf(statFile, /*NOXLATE*/"LOGINNAME: %s\n", tempRes.resval.rstring); acdbFree (tempRes.resval.rstring) ; // Print ACAD serial number if (acedGetVar(/*NOXLATE*/"_PKSER", &tempRes) != RTNORM) { sprintf(abort_msg, "%.*s Command\nStatistics Gatherer\nFailure 1", PRODUCTL, getProductName()); acrx_abort(abort_msg); } fprintf(statFile, /*NOXLATE*/"%.*s Serial Number: %s\n", PRODUCTL, getProductName(), tempRes.resval.rstring); acdbFree (tempRes.resval.rstring) ; // Print ACAD version if (acedGetVar(/*NOXLATE*/"_VERNUM", &tempRes) != RTNORM) { sprintf(abort_msg, "%.*s Command\nStatistics Gatherer\nFailure 1", PRODUCTL, getProductName()); acrx_abort(abort_msg); } fprintf(statFile, /*NOXLATE*/"%.*s version: %s\n", PRODUCTL, getProductName(), tempRes.resval.rstring); acdbFree (tempRes.resval.rstring) ; for (iter = cumulativeStats->newIterator(AcRx::kDictSorted); !iter->done(); iter->next()) { // Write out the command string. fprintf(statFile, "%s", iter->key()); // Try for reasonable text alignment, such as allowing 24 chars // for the command name. But have at least 1 space as a delimiter. int nbrOfSpaces = 24 - strlen(iter->key()); do fprintf(statFile, " "); while (--nbrOfSpaces > 0); // Now the count and elapsed time in seconds (assume 1 billion seconds // maximum, which should exceed a typical beta survey period). fprintf(statFile, "%7i %12.2f\n", ((AsdkCommandRecord*) iter->object())->count, ((AsdkCommandRecord*) iter->object())->elapsedTime); } fclose(statFile); delete iter; return Adesk::kTrue; }