Exemplo n.º 1
0
CString CXMLElement::ToString(BOOL bHeader, BOOL bNewline, BOOL bEncoding, TRISTATE bStandalone) const
{
	CString strXML;
	strXML.Preallocate( 256 );

	if ( bHeader )
	{
		strXML = _T("<?xml version=\"1.0\"");

		if ( bEncoding )
			strXML.Append( _PT(" encoding=\"utf-8\"") );

		if ( bStandalone == TRI_TRUE )
			strXML.Append( _PT(" standalone=\"yes\"") );
		else if ( bStandalone == TRI_FALSE )
			strXML.Append( _PT(" standalone=\"no\"") );

		strXML.Append( _PT("?>") );

		if ( bNewline )
			strXML.Append( _PT("\r\n") );
	}

	ToString( strXML, bNewline );
//	ASSERT( strXML.GetLength() == int( _tcslen(strXML) ) );

	return strXML;
}
Exemplo n.º 2
0
// Spidy - auto start option
void getExeNameStr(std::string * strResult) {
	CString CStrcaExePath;
	CStrcaExePath.Preallocate(MAX_PATH);
	GetModuleFileName(NULL, CStrcaExePath.GetBuffer(), MAX_PATH);
	CT2CA pszConvertedAnsiString (CStrcaExePath);
	std::string strAppName(pszConvertedAnsiString);

	strResult->assign(strAppName.substr(strAppName.rfind("\\") + 1));

	CStrcaExePath.ReleaseBuffer();
}
Exemplo n.º 3
0
void CCollectionFile::Render(CString& strBuffer) const
{
	strBuffer.Preallocate( GetFileCount() * 128 + 256 );

	strBuffer.Format( L"<html>\n<head>\n"
		L"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n"
		L"<title>%s</title>\n"
		L"<style type=\"text/css\">\n"
		L"body  { margin: 0px; padding: 0px; background-color: #ffffff; color: #000000; font-family: %s; font-size: %upx; }\n"
		L"h1    { text-align: left; color: #ffffff; height: 64px; margin: 0px; padding: 20px; font-size: 10pt; font-weight: bold; background-image: url(res://Envy.exe/312); }\n"
		L"table { font-size: 8pt; width: 100%%; }\n"
		L"td    { background-color: #e0e8f0; padding: 4px; }\n"
		L".num  { width: 40px; text-align: center; }\n"
		L".url  { text-align: left; cursor: hand; }\n"
		L".size { width: 100px; text-align: center; }\n"
		L"</style>\n</head>\n<body>\n<h1>%s</h1>\n<table>\n",
		(LPCTSTR)GetTitle(),
		(LPCTSTR)Settings.Fonts.DefaultFont, Settings.Fonts.DefaultSize,
		(LPCTSTR)GetTitle() );

	DWORD i = 1;
	for ( POSITION pos = GetFileIterator(); pos; ++i )
	{
		CCollectionFile::File* pFile = GetNextFile( pos );

		CString strURN;
		if ( pFile->m_oSHA1 )
			strURN = pFile->m_oSHA1.toUrn();
		else if ( pFile->m_oTiger )
			strURN = pFile->m_oTiger.toUrn();
		else if ( pFile->m_oED2K )
			strURN = pFile->m_oED2K.toUrn();
		else if ( pFile->m_oMD5 )
			strURN = pFile->m_oMD5.toUrn();
		else if ( pFile->m_oBTH )
			strURN = pFile->m_oBTH.toUrn();

		CString strTemp;
		strTemp.Format( L"<tr><td class=\"num\">%u</td>"
			L"<td class=\"url\" onclick=\"if ( ! window.external.open('%s') ) window.external.download('%s');\" onmouseover=\"window.external.hover('%s');\" onmouseout=\"window.external.hover('');\">%s</td>"
			L"<td class=\"size\">%s</td></tr>\n",
			i, (LPCTSTR)strURN, (LPCTSTR)strURN, (LPCTSTR)strURN, (LPCTSTR)pFile->m_sName,
			(LPCTSTR)Settings.SmartVolume( pFile->m_nSize ) );
		strBuffer += strTemp;
	}

	strBuffer += L"</table>\n</body>\n</html>";
}
Exemplo n.º 4
0
int CReportDoc::MakeQuery(CString *query)
{
	int i = 0, ret = SUCCESS;
	CString tmpStr = _T("");
	CString tempQuery; 
	CString subQuery1, subQuery2;
	BOOL bCmpProtocl = FALSE;
	list <CString>::iterator iter;
	
	/* allocate large buffer for the query */
	tempQuery.Preallocate(QUERY_LENGTH);

	/* Step 1: if query is to retrieve data for two protocol, initialize sub query buffer */
	if (m_nYValues == COMPARE_TWO_PROTOCOL) 
	{
		subQuery1.Preallocate(SUB_QUERY_LENGTH);
		subQuery2.Preallocate(SUB_QUERY_LENGTH);
		subQuery1 = _T("SELECT ");
		subQuery2 = _T("SELECT ");
		bCmpProtocl = TRUE;
	} 
	
	/* Step 2: Build main query */
	tempQuery = _T("SELECT ");

	/* Step 3. check if x value is valid. If so, added it query. Return INVALID_ARGUMENT otherwise */
	if (!m_query.m_xValue.IsEmpty())
	{
		if (bCmpProtocl) {
			tempQuery.Format(_T("%s ProtocolA.%s"), tempQuery, m_query.m_xValue);
			subQuery1.Format(_T("%s %s"), subQuery1, m_query.m_xValue);
			subQuery2.Format(_T("%s %s"), subQuery2, m_query.m_xValue);
		} else {
			tempQuery.Format(_T("%s %s"), tempQuery, m_query.m_xValue);
		}

		m_xLabel = m_query.m_xValue;
	} 
	else if (!m_query.m_xValue2.IsEmpty() && !m_query.m_xFormula.IsEmpty()) 
	{
		if (bCmpProtocl) {
			tempQuery.Format(_T("%s ProtocolA.%s"), tempQuery, m_query.m_yValue2);
			subQuery1.Format(_T("%s (%s) as %s"), subQuery1, m_query.m_xFormula, m_query.m_xValue2);
			subQuery2.Format(_T("%s (%s) as %s"), subQuery2, m_query.m_xFormula, m_query.m_xValue2);
		}else {
			tempQuery.Format(_T("%s (%s) as %s"), tempQuery, m_query.m_xFormula, m_query.m_xValue2);
		}
		m_xLabel = m_query.m_xValue2;
	}
	else 
	{
		return (-INVALID_ARGUMENT);
	}
	
	/* Step 4. check if query is for two y values*/
	if (bCmpProtocl) 
	{
		/* CASE 1. construct querys for comparing two protocols*/

		/* Step 4A-1: check if x value is valid and added to query */
		if (!m_query.m_yValue.IsEmpty())
		{
			tempQuery.Format(_T("%s, ProtocolA.%s, ProtocolB.%s"), tempQuery, m_query.m_yValue, m_query.m_yValue);
			subQuery1.Format(_T("%s, %s"), subQuery1, m_query.m_yValue);
			subQuery2.Format(_T("%s, %s"), subQuery2, m_query.m_yValue);
			m_yLabel = m_query.m_yValue;
		} 
		else if (!m_query.m_yValue2.IsEmpty() && !m_query.m_yFormula.IsEmpty()) 
		{
			tempQuery.Format(_T("%s, ProtocolA.%s, Protoco1B.%s"), tempQuery, m_query.m_yValue2, m_query.m_yValue2);
			subQuery1.Format(_T("%s, (%s) as %s"), subQuery1, m_query.m_yFormula, m_query.m_yValue2);
			subQuery2.Format(_T("%s, (%s) as %s"), subQuery2, m_query.m_yFormula, m_query.m_yValue2);
			m_yLabel = m_query.m_yValue2;
		}
		else 
		{
			return (-INVALID_ARGUMENT);
		}

		/* Step 4A-2: add "from" clause to queries */
		tempQuery.Format(_T("%s from ("), tempQuery);
		subQuery1.Format(_T("%s from resultmaster"), subQuery1);
		subQuery2.Format(_T("%s from resultmaster"), subQuery2);

		/* Step 4A-3: add data range to sub query 1*/
		if (m_query.m_dataSource->empty() == TRUE) 
		{
			return (-INVALID_ARGUMENT);
		} 
		else 
		{
			iter = m_query.m_dataSource->begin();
			for( i = 0; iter != m_query.m_dataSource->end(); iter++, i++)
			{
				tmpStr.Format(_T("%s"), *iter);
				if (i == 0)
					subQuery1.Format(_T("%s WHERE ScenarioID = %s"), subQuery1, tmpStr);
				else 
					subQuery1.Format(_T("%s OR scenarioID = %s"), subQuery1, tmpStr);
			}
		}
	
		/* Step 4A-4: add data range to sub query 2*/
		if (m_query.m_dataSource2->empty() == TRUE) 
		{
			return (-INVALID_ARGUMENT);
		} 
		else 
		{
			iter = m_query.m_dataSource2->begin();
			for( i = 0; iter != m_query.m_dataSource2->end(); iter++, i++)
			{
				tmpStr.Format(_T("%s"), *iter);
				if (i == 0)
					subQuery2.Format(_T("%s WHERE ScenarioID = %s"), subQuery2, tmpStr);
				else 
					subQuery2.Format(_T("%s OR scenarioID = %s"), subQuery2, tmpStr);
			}
		}
	
		/* Step 4A-5: integrate sub queries into a main query*/
		tempQuery.Format(_T("%s (%s) ProtocolA, (%s) ProtocolB) WHERE ProtocolA.%s = ProtocolB.%s"), 
					tempQuery, subQuery1, subQuery2, m_xLabel, m_xLabel);

	} else { 
		/* CASE2: construct query for one protocol */
		/* Step 4B-1: add y value to the query */
		if (!m_query.m_xValue.IsEmpty())
		{
			tempQuery.Format(_T("%s, %s"), tempQuery, m_query.m_yValue);
			m_yLabel = m_query.m_yValue;
		} 
		else if (!m_query.m_xValue2.IsEmpty() && !m_query.m_xFormula.IsEmpty()) 
		{
			tempQuery.Format(_T("%s, (%s) as %s"), tempQuery, m_query.m_yFormula, m_query.m_yValue2);
			m_yLabel = m_query.m_yValue2;
		}
		else 
		{
			return (-INVALID_ARGUMENT);
		}
		/* Step 4B-2: FIXME: add table name (This should be got from config file) */
		tempQuery.Format(_T("%s from resultmaster"), tempQuery);

		/* Step 4B-3: check if data source range is valid. If so, added it query. Return INVALID_ARGUMENT otherwise */
		if (m_query.m_dataSource->empty() == TRUE) 
		{
			return (-INVALID_ARGUMENT);
		} 
		else 
		{
			m_query.m_dataSource->sort();
			iter = m_query.m_dataSource->begin();
			for( i = 0; iter != m_query.m_dataSource->end(); iter++, i++)
			{
				tmpStr.Format(_T("%s"), *iter);
				if (i == 0)
					tempQuery.Format(_T("%s WHERE ScenarioID = %s"), tempQuery, tmpStr);
				else 
					tempQuery.Format(_T("%s OR scenarioID = %s"), tempQuery, tmpStr);
			}
		}

	}
	
	/* Step 5: put data range formula if exists */
	if (!m_query.m_rangeFormula.IsEmpty())
		tempQuery.Format(_T("%s and (%s)"), tempQuery, m_query.m_rangeFormula);

	/* 5. put group by condition if exists */
	if (!m_query.m_groupby.IsEmpty())
		tempQuery.Format(_T("%s GROUP BY %s"), tempQuery, m_query.m_groupby);

	/* 6. put order by condition if exists */
	if (!m_query.m_orderby.IsEmpty())
		tempQuery.Format(_T("%s ORDER BY %s"), tempQuery, m_query.m_orderby);
	
	*query = tempQuery;
	return ret;
}
Exemplo n.º 5
0
void FormatLogMessage(ELogMessageType type,
                      ELogMessageLevel nLevel,
                      LPCTSTR pszDate,
                      LPCTSTR pszTime,
                      LPCTSTR pszThreadId,
                      LPCTSTR pszThreadName,
                      LPCTSTR pszModule,
                      LPCTSTR pszMessage,
                      CString& output)
{
#if 1
    output.Empty();
    output.Preallocate(1024);

    if (type != eLM_DirectOutput)
    {
        output += pszDate;
        output += _T(' ');
        output += pszTime;
#if defined(LOG_THREAD_NAME)
        output += _T(" [");
        output += pszThreadId;
        output += _T(":");
        size_t nThreadNameLen = _tcslen(pszThreadName);
        if (nThreadNameLen > 12)
            output.append(pszThreadName, 12);
        else
        {
            output.append(12 - nThreadNameLen, _T(' '));
            output += pszThreadName;
        }
        output += _T("] ");
#else
        output += _T(" ");
#endif

        switch (type)
        {
        case eLM_Info:
            output += _T('I');
            break;
        case eLM_Debug:
            output += _T('-');
            break;
        case eLM_Warning:
            output += _T('W');
            break;
        case eLM_Error:
            output += _T('E');
            break;
        default:
            ASSERT(false);
        }

        if (nLevel>0)
            output.AppendFormat(_T("%i"), nLevel);
        else
            output += _T(' ');
#if 0
        output += _T(" : [");
        output += pszModule;
        output += _T("] ");
#else
        output += _T(" : ");
#endif
    }
    output += pszMessage;
    output.TrimRight();
#else
    output.Empty();
    output.reserve(1024);

    output += pszDate;
    output += _T(' ');
    output += pszTime;
    output += _T("\t");
    output += pszThreadId;
    output += _T("\t");
    output += pszThreadName;
    output += _T("\t");
    output += pszModule;
    output += _T("\t");

    switch (type)
    {
    case eLM_Info:
        output += _T("Inf");
        break;
    case eLM_Debug:
        output += _T("Dbg");
        break;
    case eLM_Warning:
        output += _T("Wrn");
        break;
    case eLM_Error:
        output += _T("Err");
        break;
    default:
        ASSERT(false);
    }

    if (nLevel>0)
        output.AppendFormat(_T("%i"), nLevel);
    output += _T('\t');
    output += pszMessage;
    output.TrimRight();
#endif
}
HRESULT CProteinSurfaceMSMS::CreateSurface()
{
	HRESULT hr;

	GetMainActiveView()->ResetProgress();

	m_arrayAtom.clear();
	m_arrayAtom.reserve(m_pChain->m_arrayAtom.size());

	for ( int i = 0 ; i < m_pChain->m_arrayAtom.size(); i++ )
	{
		if ( m_bAddHETATM == TRUE )
		{
			m_arrayAtom.push_back(m_pChain->m_arrayAtom[i]);
		}
		else
		{
			if ( m_pChain->m_arrayAtom[i]->m_bHETATM == FALSE )
				m_arrayAtom.push_back(m_pChain->m_arrayAtom[i]);
		}
	}

	if ( m_arrayAtom.size() == 0 )
		return E_FAIL;

	char drive[_MAX_DRIVE];
	char dir[_MAX_DIR];
	char fname[_MAX_FNAME];
	char ext[_MAX_EXT];
	_splitpath(m_pPDB->m_strFilename, drive, dir, fname, ext );

	CString strSurfaceDir = GetMainApp()->m_strBaseSurfacePath;

	m_arrayVertex.clear();
	m_arrayNormal.clear();
	m_arrayIndexFace.clear();
	m_arrayIndexAtom.clear();
	m_arrayTypeVertex.clear();
	m_arrayTypeFace.clear();
	m_ArrayArrayFaceIndex.clear();
	m_ArrayArrayAdjacentVertex.clear();

	m_arrayVertex.reserve(m_arrayAtom.size());
	m_arrayNormal.reserve(m_arrayAtom.size());
	m_arrayIndexFace.reserve(m_arrayAtom.size());
	m_arrayIndexAtom.reserve(m_arrayAtom.size());
	m_arrayTypeVertex.reserve(m_arrayAtom.size());
	m_arrayTypeFace.reserve(m_arrayAtom.size());

	CString outputName;
	outputName.Format ( _T("%s%s_%02d_%c_%03d_%.2f_%d_%d_%d") , strSurfaceDir, fname, m_modelID, m_chainID, m_arrayAtom.size(), m_probeSphere, m_surfaceQuality , m_bAddHETATM , GetTypeGenSurface() );

	CString outputFilenameVertex = outputName + _T(".vert");
	CString outputFilenameFace = outputName + _T(".face");

	BOOL bExistSurface = FALSE;
	HANDLE fileVert = CreateFile( outputFilenameVertex, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL );
	HANDLE fileFace = CreateFile( outputFilenameFace, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL );
	if( INVALID_HANDLE_VALUE != fileVert &&  INVALID_HANDLE_VALUE != fileFace )
	{
		bExistSurface = TRUE;
	}
	if ( fileVert != INVALID_HANDLE_VALUE ) CloseHandle(fileVert);
	if ( fileFace != INVALID_HANDLE_VALUE ) CloseHandle(fileFace);
	
	if ( bExistSurface == FALSE )
	{
		long iProgress = GetMainActiveView()->InitProgress(100);
		GetMainActiveView()->SetProgress(0, iProgress );

		//	Make xyzr file
		CString coordFilename;
		coordFilename.Format ( _T("%s%s_%02d_%c_%03d_%d.xyzr") , strSurfaceDir , fname, m_modelID, m_chainID, m_arrayAtom.size() , m_bAddHETATM );

		CString strCoord;
		strCoord.Preallocate(m_arrayAtom.size()*50);
		
		for ( int i = 0 ; i < m_arrayAtom.size() ; i++ )
		{
			CAtom * pAtom = m_arrayAtom[i];

			CString strLine;
			strLine.Format("%.3f %.3f %.3f %.3f\n", pAtom->m_pos.x, pAtom->m_pos.y, pAtom->m_pos.z, pAtom->m_fRadius );

			strCoord += strLine;
		}

		CFile fileMSMS;
		CFileException ex;
		if ( !fileMSMS.Open(coordFilename, CFile::modeWrite|CFile::modeCreate, &ex) )
		{
			TCHAR szError[1024];
			ex.GetErrorMessage(szError, 1024);

			CString strMsg;
			strMsg.Format( _T("Couldn't open source file: %s"), szError );

			OutputTextMsg(strMsg);

			return E_FAIL;
		}

		GetMainActiveView()->SetProgress(20, iProgress );

		TCHAR * buff = strCoord.GetBuffer();
		fileMSMS.Write(buff, strCoord.GetLength());
		strCoord.ReleaseBuffer();
		fileMSMS.Close();

		GetMainActiveView()->SetProgress(60, iProgress );
		//	Run MSMS
		CString strCommand;
		strCommand.Format(_T("%smsms.exe -if \"%s\" -of \"%s\" -no_header -probe_radius %f -density %f") ,  GetMainApp()->m_strBaseExePath , coordFilename, outputName , m_probeSphere, GetSurfaceQuality(m_surfaceQuality) );

		OutputTextMsg(strCommand);
		//	TODO: directory에 공백이 있을 경우 msms 가 실행되는지 조사.
		if ( m_redirector.Open(strCommand) == FALSE )
		{
			m_redirector.Close();
			GetMainActiveView()->EndProgress(iProgress);
			OutputTextMsg(_T("Cannot execute msms.exe. Check file"));
			return E_FAIL;
		}
		m_redirector.Close();
		GetMainActiveView()->EndProgress(iProgress);
	}
	
	long iProgress = GetMainActiveView()->InitProgress(100);
	GetMainActiveView()->SetProgress(0, iProgress );

	//	Gather results
	{
		CFile fileVert;
		CFileException ex;
		if ( !fileVert.Open(outputFilenameVertex , CFile::modeRead, &ex ) )
		{
			TCHAR szError[1024];
			ex.GetErrorMessage(szError, 1024);

			CString strMsg;
			strMsg.Format( _T("Couldn't open source file: %s"), szError );

			 OutputTextMsg(strMsg);

			return E_FAIL;
		}

		DWORD fileLen = fileVert.GetLength()+1;

		TCHAR * pBuff, * pBuffOrig;
		pBuff = pBuffOrig = new TCHAR [fileLen];
		ZeroMemory(pBuff, fileLen);
		fileVert.Read(pBuff, fileLen);

		while(1)
		{
			TCHAR * pFind = _tcschr(pBuff, _T('\n') );
			if ( pFind == NULL )
				break;

			(*pFind) = _T('\0');

			TCHAR * pLine = pBuff;
			pBuff = pFind+1;

			//	"%9.3f %9.3f %9.3f %9.3f %9.3f %9.3f %7d %7d %2d"

			D3DXVECTOR3		pos;
			D3DXVECTOR3		norm;

			pLine[9] = _T('\0');
			pos.x = _tstof(&pLine[0]);		//	x

			pLine[19] = _T('\0');
			pos.y = _tstof(&pLine[10]);		//	y

			pLine[29] = _T('\0');
			pos.z = _tstof(&pLine[20]);		//	z

			pLine[39] = _T('\0');
			norm.x = _tstof(&pLine[30]);		//	nx

			pLine[49] = _T('\0');
			norm.y = _tstof(&pLine[40]);		//	ny

			pLine[59] = _T('\0');
			norm.z = _tstof(&pLine[50]);		//	nz

			m_arrayVertex.push_back(pos);
			m_arrayNormal.push_back(norm);

			//	
			pLine[67] = _T('\0');
			//	_tstoi(&pLine[60]);	skip

			pLine[75] = _T('\0');
			long indexAtom = _tstoi(&pLine[68])-1;
			m_arrayIndexAtom.push_back(indexAtom);
			
			long typeVertex = _tstoi(&pLine[76]);
			m_arrayTypeVertex.push_back(typeVertex);
		};

		fileVert.Close();

		SAFE_DELETE_AR(pBuffOrig);
	}

	GetMainActiveView()->SetProgress(50, iProgress );
	//
	//	face
	//
	{
		CFile fileFace;
		CFileException ex;
		if ( !fileFace.Open(outputFilenameFace, CFile::modeRead, &ex ) )
		{
			TCHAR szError[1024];
			ex.GetErrorMessage(szError, 1024);

			CString strMsg;
			strMsg.Format( _T("Couldn't open source file: %s"), szError );

			OutputTextMsg(strMsg);

			return E_FAIL;
		}

		DWORD fileLen = fileFace.GetLength()+1;

		TCHAR * pBuff, * pBuffOrig;
		pBuff = pBuffOrig = new TCHAR [fileLen];
		ZeroMemory(pBuff, fileLen);
		fileFace.Read(pBuff, fileLen);

		while(1)
		{
			TCHAR * pFind = _tcschr(pBuff, _T('\n') );
			if ( pFind == NULL )
				break;

			(*pFind) = _T('\0');

			TCHAR * pLine = pBuff;
			pBuff = pFind+1;

			//	"%6d %6d %6d %2d %6d"
			int		index[3];

			pLine[6] = _T('\0');
			index[0] = _tstoi(&pLine[0])-1;		//	i1		1 based index

			pLine[13] = _T('\0');
			index[1] = _tstoi(&pLine[7])-1;		//	i2

			pLine[20] = _T('\0');
			index[2] = _tstoi(&pLine[14])-1;		//	i3

			m_arrayIndexFace.push_back(index[0]);
			m_arrayIndexFace.push_back(index[1]);
			m_arrayIndexFace.push_back(index[2]);

			pLine[23] = _T('\0');
			long typeFace = _tstof(&pLine[21]);		//	nx
			m_arrayTypeFace.push_back(typeFace);

		};

		fileFace.Close();

		SAFE_DELETE_AR(pBuffOrig);
	}

	GetMainActiveView()->EndProgress(iProgress );

	//	m_ArrayArrayFaceIndex 를 구함
	//	세로가 m_pChain->m_arrayAtom 의 index.
	//	가로가 atom 이 가리키는 vertex의 index.
	//	atom 이 가지는 triangle face 의 index를 저장
	{
		m_ArrayArrayFaceIndex.clear();
		//	HETATM 때문에 배열의 index를 m_pChain->m_arrayAtom을 사용한다.
		m_ArrayArrayFaceIndex.resize(m_pChain->m_arrayAtom.size());

		long iProgress = GetMainActiveView()->InitProgress(100);
		GetMainActiveView()->SetProgress(0, iProgress );

		long deltaProgress = m_arrayIndexFace.size()/90;
		deltaProgress -= deltaProgress%3;

		for ( long i = 0 ; i < m_arrayIndexFace.size() ; i+= 3 )
		{
			if ( deltaProgress && (i % deltaProgress == 0) )
				GetMainActiveView()->SetProgress(i*100/m_arrayIndexFace.size() , iProgress);

			long index = m_arrayIndexFace[i];
			long iAtom = m_arrayIndexAtom[index];

			//	HETATM 때문에 배열의 index를 m_pChain->m_arrayAtom을 사용한다.
			long arrayIndex = m_arrayAtom[iAtom]->m_arrayIndex;

			CSTLLONGArray & stlLongArray = m_ArrayArrayFaceIndex[arrayIndex];
			if ( stlLongArray.capacity() == 0 )
				stlLongArray.reserve(3*10);

			//	vertexIndex 를 넣어둔다.
			//	
			//	CAtom 에 Surface의 vertex 와 연결된 vertex Index list를 넣어둔다.
			//	vertex Index list = 3* n개
			//
			stlLongArray.push_back(m_arrayIndexFace[i]);
			stlLongArray.push_back(m_arrayIndexFace[i+1]);
			stlLongArray.push_back(m_arrayIndexFace[i+2]);
		}

		GetMainActiveView()->EndProgress(iProgress);
	}

	return S_OK;
}
Exemplo n.º 7
0
HRESULT GetRibbonText(BSTR * RibbonXml)
{
	LPBYTE content = NULL;
	DWORD content_length = 0;

	ASSERT_RETURN_VALUE(LoadResourceFromModule(
		AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_RESOURCE_H), L"TEXT", &content, &content_length), S_FALSE);

	CMemFile mf(content, content_length);
	CTextFileRead rdr(&mf);

	CMapStringToString replacements;

	CString line;
	while (rdr.ReadLine(line))
	{
		CSimpleArray<CString> tokens;

		CString token;
		token.Preallocate(30);

		for (LPCWSTR pos = line; *pos; ++pos)
		{
			if (*pos == ' ' || *pos == '\t')
			{
				if (!token.IsEmpty())
				{
					tokens.Add(token);
					token = CString();
				}
			}
			else
			{
				token += *pos;
			}
		}

		if (!token.IsEmpty())
			tokens.Add(token);

		if (tokens.GetSize() != 3)
			continue;

		if (tokens[0] != "#define")
			continue;

		replacements[tokens[1]] = tokens[2];
	}

	CString ribbon = LoadTextFromModule(AfxGetInstanceHandle(), IDR_RIBBON);

	for (int pos = 0; pos < ribbon.GetLength(); ++pos)
	{
		if (ribbon[pos] != '{')
			continue;

		int endpos = ribbon.Find('}', pos);
		ASSERT_CONTINUE(endpos != -1);

		CString token = ribbon.Mid(pos+1, endpos-pos-1);
		CString token_found;

		ASSERT_CONTINUE(replacements.Lookup(token, token_found));	

		ribbon.Delete(pos, endpos-pos+1);
		ribbon.Insert(pos, token_found);

		pos += (token_found.GetLength()-1);
	}

	*RibbonXml = ribbon.AllocSysString();
	return S_OK;
}