int Mode(std::list<R_type *> a) { if (a.empty()) { throw "Function Mode must have >1 arguments"; } std::string sNull("NULL"); std::string sLog("Logical"); std::string sNum("Numeric"); std:: string sChar("Character"); int ind = TTV.put(Character); for (std::list<R_type *>::iterator i = a.begin(); i != a.end(); i++) { kind_of_type t = (*i)->get_type(); switch(t) { case Nulltype: TTV[ind]->add(sNull); break; case Logical: TTV[ind]->add(sLog); break; case Numeric: TTV[ind]->add(sNum); break; case Character: TTV[ind]->add(sChar); break; } } return ind; }
int CstrategyScans::nPrintResultScanTable(int nScanNumberOffset, bool bPrintHeader, double& dTotalRotWidth, DTREK_WORD wCtrl, REFLN_FILE_STRAT_INFO* pReflnFileStrategyInfo) { dTotalRotWidth = 0.0; if( 0 == nGetNumScans() ) return 0; // nothing to do if( 1 > nGetNumAxes() ) return 0; // Should not happen. There should be at least one rotation axis. ////////////////////////////////////////////////////////////////////////////// if( bPrintHeader ) { Cstring sHorizLine("----------------------------------------------------------------------------\n"); // We need to figure out the axes names for the table header. // Assume every scan has the same axes names. Cstring sHeader (" # 2Theta Dist"); Cstring sTemp(""); Cstring sTemp2(""); int nAxisNameLength = 0; int nNumberOfPaddingSpaces = 0; const int c_nMaxAxisColumnWidth = 7;// assuming that an axis name would not be longer than 6 characters + a space for separation for(int jj=0; jj < nGetNumAxes(); jj++) { vGetAxisName(jj, sTemp); nAxisNameLength = sTemp.length(); nNumberOfPaddingSpaces = c_nMaxAxisColumnWidth - nAxisNameLength; sTemp2 = ""; for(int kk=0; kk < nNumberOfPaddingSpaces; kk++) { sTemp2 += " "; } sTemp2 += sTemp; sHeader += sTemp2; } sHeader += " Start End Width %%Comp Redn +/-\n"; if( DTREK_STRATSCANS_PRST_ALL != wCtrl ) printf("\nBest Multiple Scan Solution\n"); printf(sHorizLine.string()); printf(sHeader.string()); printf(sHorizLine.string()); } /////////////////////////////////////////////////////////////////////////////////////////////////////// // Print fixed scan information if( pReflnFileStrategyInfo ) { pReflnFileStrategyInfo->m_sFilePath.vAbbreviateFilePath(58); int nNumberOfCharsBeforeStats = 2 + // scan number for record 14 + // 2Theta and distance nGetNumAxes() * 7 + // crystal gonio axes values 22; // rotation axis values Cstring sNum(nNumberOfCharsBeforeStats); Cstring sFilePathFormat("%-"); sFilePathFormat += sNum; sFilePathFormat += 's'; printf(sFilePathFormat.string(), pReflnFileStrategyInfo->m_sFilePath.string()); printf("%6.1f %5.2f %4.2f\n", pReflnFileStrategyInfo->m_fCompleteness, pReflnFileStrategyInfo->m_fRedundancy, pReflnFileStrategyInfo->m_fRedundancyDev); } CstrategyScan::enStrategyScanType eScanType = !m_bMultipleScanSolution ? CstrategyScan::enSingleScan : CstrategyScan::enMultipleScan; bool bUsed = false; double dRotBegin = 0.0; double dRotEnd = 0.0; double dWidth = 0.0; Cstring strYesNo(""); int nScanNumberForRecord = -1; int nUsedScanNumber = -1; for(int ii=0; ii < nGetNumScans(); ii++) { bUsed = bIsScanUsed(ii, eScanType); // Multiple scan solution should only list used scans if( !bUsed && DTREK_STRATSCANS_PRST_ALL != wCtrl ) continue; nUsedScanNumber++; nScanNumberForRecord = nUsedScanNumber + nScanNumberOffset; printf("%2d", nScanNumberForRecord); // scan number printf(" %6.1f %5.1f ",m_dTwoTheta, m_dDistance); for(int jj=0; jj < nGetNumAxes(); jj++) { printf("%6.1f", dGetScanAxisValue(ii, jj) ); //////////////////////////////////////// // Specify whether it is a rotation axis if( bIsRotationAxis(jj) ) printf("*"); else printf(" "); } //////////////////////////////////////////////////////////////////////////// dRotBegin = dGetScanRotBegin(ii, eScanType); dRotEnd = dGetScanRotEnd (ii, eScanType); dWidth = fabs(dRotBegin - dRotEnd); dTotalRotWidth += dWidth; /////////////////////////////////////////////////////////////////////////// // Format Rotation Begin, End, Width, 2Theta and Distance if( dWidth > 0.0 ) { printf(" %6.1f %6.1f %6.1f ", dRotBegin, dRotEnd, dWidth); } else // scan not tested? { printf("%6s %5s %6s %6s %6s", " ---", " ---", " ---", " ---", " ---"); } /////////////////////////////////////////////////////////////////////////// if( dWidth > 0.0 ) { printf("%6.1f %5.2f %4.2f", dGetScanCompleteness (ii, eScanType), dGetScanRedundancy (ii, eScanType), dGetScanRedundancyDev(ii, eScanType)); } else // scan not tested? { printf("%6s %5s %4s", " ---", " ---", " ---"); } //////////////////////////////////////////////////////////////////////////////////// printf("\n"); } return (nUsedScanNumber+1); }