예제 #1
0
void EditStrings()
{
int Choice=0, StringChoice;
int loop;
char String[100];

  while( Choice != 4 )
    {
    printf( "\n\n1. Edit Standing strings\n" );
    printf( "2. Edit Shooting strings\n" );
    printf( "3. Edit Attribute strings\n" );
    printf( "4. Exit back to main\n" );
    printf( "\nSelect >");
    scanf( "%d", &Choice );
    fflush(stdin);
    printf( "\n" );
    switch( Choice )
      {
      case 1:
	for( loop=0; loop<16; loop++ )
	  printf( "%d %s\n", loop+1,StandingStrings[loop] );
	printf( "\n\nSelect >");
	scanf( "%d", &StringChoice );
	if( StringChoice >=1 && StringChoice <= 16 )
	  {
      scanf("");
	  gets( String );
	  PadString( String,StandingStrings[StringChoice-1] );
	  }
	break;
      case 2:
	for( loop=0; loop<16; loop++ )
	  printf( "%d %s\n", loop+1,ShootingStrings[loop] );
	printf( "\n\nSelect >");
	scanf( "%d", &StringChoice );
   fflush(stdin);
	if( StringChoice >=1 && StringChoice <= 16 )
	  {
	  gets( String );
	  PadString( String,ShootingStrings[StringChoice-1] );
	  }
	break;
      case 3:
	for( loop=0; loop<8; loop++ )
	  printf( "%d %s\n", loop+1,AttributeStrings[loop] );
	printf( "\n\nSelect >");
	scanf( "%d", &StringChoice );
   fflush(stdin);
	if( StringChoice >= 1 && StringChoice <= 8 )
	  {
	  gets( String );
	  PadString( String,AttributeStrings[StringChoice-1] );
	  }
	break;
      default:
	break;
      }
    }

}
예제 #2
0
void CSRFormat::WriteCSRHeader(ostream &ofs,OBMol &mol)
{
    char *molnames;
    int nmol, natom;

    molnames = PadString((char*)mol.GetTitle(),100);

    nmol = 1;
    natom = mol.NumAtoms();

    WriteSize(4*sizeof(char),ofs);
    ofs.write("V33 ",strlen("V33 ")*sizeof(char));
    WriteSize(4*sizeof(char),ofs);

    WriteSize(2*sizeof(int),ofs);
    ofs.write((char*)&natom,sizeof(int));
    ofs.write((char*)&nmol,sizeof(int));
    WriteSize(2*sizeof(int),ofs);

    WriteSize(100*sizeof(char),ofs);
    ofs.write(molnames,100*sizeof(char));
    WriteSize(100*sizeof(char),ofs);

    WriteSize(sizeof(int),ofs);
    ofs.write((char*)&natom,sizeof(int));
    WriteSize(sizeof(int),ofs);

    delete [] molnames;
}
예제 #3
0
void CSRFormat::WriteCSRCoords(ostream &ofs,OBMol &mol)
{
    int the_size,jconf;
    double x,y,z,energy;
    char title[100];
    char *tag;

    the_size = sizeof(int) + sizeof(double) + (80 * sizeof(char));

    jconf = 1;
    energy = -2.584565;

    snprintf(title, 80, "%s:%d",mol.GetTitle(),MolCount);
    tag = PadString(title,80);

    WriteSize(the_size,ofs);
    ofs.write((char*)&jconf,sizeof(int));
    ofs.write((char*)&energy,sizeof(double));
    ofs.write(tag,80*sizeof(char));
    WriteSize(the_size,ofs);

    WriteSize(mol.NumAtoms()*sizeof(double),ofs);

    OBAtom *atom;
    vector<OBAtom*>::iterator i;
    for (atom = mol.BeginAtom(i); atom; atom = mol.NextAtom(i))
    {
        x = atom->x();
        ofs.write((char*)&x,sizeof(double));
    }
    WriteSize(mol.NumAtoms()*sizeof(double),ofs);

    WriteSize(mol.NumAtoms()*sizeof(double),ofs);
    for (atom = mol.BeginAtom(i); atom; atom = mol.NextAtom(i))
    {
        y = atom->y();
        ofs.write((char*)&y,sizeof(double));
    }
    WriteSize(mol.NumAtoms()*sizeof(double),ofs);

    WriteSize(mol.NumAtoms()*sizeof(double),ofs);
    for (atom = mol.BeginAtom(i); atom; atom = mol.NextAtom(i))
    {
        z = atom->z();
        ofs.write((char*)&z,sizeof(double));
    }
    WriteSize(mol.NumAtoms()*sizeof(double),ofs);

    delete [] tag;
}
예제 #4
0
CString DiffFunctions(FUNC_COMPARE_METHOD nMethod,
									CFuncDescFile *pFile1, int nFile1FuncNdx,
									CFuncDescFile *pFile2, int nFile2FuncNdx,
									DWORD nOutputOptions,
									double &nMatchPercent,
									CSymbolMap *pSymbolMap)
{
	CString strRetVal = "";
	CString strEntry;
	CString strTemp;
	CStringArray oes;
	CStringArray Func1Lines;
	CStringArray Func2Lines;
	CFuncDesc *pFunction1;
	CFuncDesc *pFunction2;
	CFuncObject *pFuncObj;
	int i;
	int nLeftMax;
	int nRightMax;
	int nLeftIndex;
	int nRightIndex;
	int nLeftPos;
	int nRightPos;
	int nPos;

	if ((pFile1 == NULL) || (pFile2 == NULL)) return strRetVal;

	pFunction1 = pFile1->GetFunc(nFile1FuncNdx);
	pFunction2 = pFile2->GetFunc(nFile2FuncNdx);
	if ((pFunction1 == NULL) ||
		(pFunction2 == NULL)) return strRetVal;

	nMatchPercent = CompareFunctions(nMethod, pFile1, nFile1FuncNdx, pFile2, nFile2FuncNdx, TRUE);
	if (!GetLastEditScript(oes)) return strRetVal;

/*
// The following is for special debugging only:
	for (i=0; i<oes.GetSize(); i++) {
		strRetVal += "    " + oes.GetAt(i) + "\n";
	}
//	return strRetVal;
	strRetVal += "\n";
*/

	nLeftMax = 0;
	for (i=0; i<pFunction1->GetSize(); i++) {
		pFuncObj = pFunction1->GetAt(i);
		if (pFuncObj == NULL) {
			Func1Lines.Add("");
			continue;
		}
		strTemp = pFuncObj->CreateOutputLine(nOutputOptions);
		nLeftMax = __max(nLeftMax, strTemp.GetLength());
		Func1Lines.Add(strTemp);
	}

	nRightMax = 0;
	for (i=0; i<pFunction2->GetSize(); i++) {
		pFuncObj = pFunction2->GetAt(i);
		if (pFuncObj == NULL) {
			Func2Lines.Add("");
			continue;
		}
		strTemp = pFuncObj->CreateOutputLine(nOutputOptions);
		nRightMax = __max(nRightMax, strTemp.GetLength());
		Func2Lines.Add(strTemp);
	}

	strTemp = "";
	for (i=0; i<((nLeftMax-pFunction1->GetMainName().GetLength())/2); i++) strTemp += ' ';
	strRetVal += PadString(strTemp + pFunction1->GetMainName(), nLeftMax);

	strRetVal += "      ";

	strTemp = "";
	for (i=0; i<((nRightMax-pFunction2->GetMainName().GetLength())/2); i++) strTemp += ' ';
	strRetVal += PadString(strTemp + pFunction2->GetMainName(), nRightMax);

	strRetVal += "\n";

	for (i=0; i<nLeftMax; i++) strRetVal += '-';
	strRetVal += "      ";
	for (i=0; i<nRightMax; i++) strRetVal += '-';
	strRetVal += "\n";

	nLeftPos = 0;
	nRightPos = 0;
	for (i=0; i<oes.GetSize(); i++) {
		strEntry = oes.GetAt(i);
		nPos = strEntry.FindOneOf("<->");
		if (nPos == -1) continue;
		nLeftIndex = strtoul(strEntry.Left(nPos), NULL, 0);
		nRightIndex = strtoul(strEntry.Mid(nPos+1), NULL, 0);
		for (; ((nLeftPos < nLeftIndex) && (nRightPos < nRightIndex)); nLeftPos++, nRightPos++) {
			strRetVal += PadString(Func1Lines.GetAt(nLeftPos), nLeftMax);
			if (pFunction1->GetAt(nLeftPos)->IsExactMatch(pFunction2->GetAt(nRightPos))) {
				strRetVal += "  ==  ";
			} else {
				strRetVal += "  --  ";
			}
			strRetVal += Func2Lines.GetAt(nRightPos) + "\n";
			if (pSymbolMap) pSymbolMap->AddObjectMapping(*pFunction1->GetAt(nLeftPos), *pFunction2->GetAt(nRightPos));
		}
		ASSERT(nLeftPos == nLeftIndex);
		ASSERT(nRightPos == nRightIndex);

		#ifdef _DEBUG
		// The following is for special debugging only:
		if (nLeftPos != nLeftIndex) {
			strTemp.Format("\n\n*** ERROR: nLeftPos = %ld,  Expected = %ld\n\n", nLeftPos, nLeftIndex);
			strRetVal += strTemp;
			nLeftPos = nLeftIndex;
		}

		if (nRightPos != nRightIndex) {
			strTemp.Format("\n\n*** ERROR: nRightPos = %ld,  Expected = %ld\n\n", nRightPos, nRightIndex);
			strRetVal += strTemp;
			nRightPos = nRightIndex;
		}
		#endif

		#ifdef _DEBUG
		switch (strEntry.GetAt(nPos)) {
			case '<':
				if (nRightPos >= Func2Lines.GetSize()) {
					strRetVal += "\n\n*** ERROR: Right-Side Index Out-Of-Range!\n\n";
					return strRetVal;
				}
				break;
			case '-':
				if (nLeftPos >= Func1Lines.GetSize()) {
					strRetVal += "\n\n*** ERROR: Left-Side Index Out-Of-Range!\n\n";
					if (nRightPos >= Func2Lines.GetSize()) {
						strRetVal += "\n\n*** ERROR: Right-Side Index Out-Of-Range!\n\n";
					}
					return strRetVal;
				}
				if (nRightPos >= Func2Lines.GetSize()) {
					strRetVal += "\n\n*** ERROR: Right-Side Index Out-Of-Range!\n\n";
					return strRetVal;
				}
				break;
			case '>':
				if (nLeftPos >= Func1Lines.GetSize()) {
					strRetVal += "\n\n*** ERROR: Left-Side Index Out-Of-Range!\n\n";
					return strRetVal;
				}
				break;
		}
		#endif

		switch (strEntry.GetAt(nPos)) {
			case '<':				// Insert in Left
				strRetVal += PadString("", nLeftMax) + "  <<  " + Func2Lines.GetAt(nRightPos) + "\n";
				nRightPos++;
				break;

			case '-':				// Change
				strRetVal += PadString(Func1Lines.GetAt(nLeftPos), nLeftMax) + "  ->  " + Func2Lines.GetAt(nRightPos) + "\n";
				if (pSymbolMap) pSymbolMap->AddObjectMapping(*pFunction1->GetAt(nLeftPos), *pFunction2->GetAt(nRightPos));
				nLeftPos++;
				nRightPos++;
				break;

			case '>':				// Insert in Right
				strRetVal += PadString(Func1Lines.GetAt(nLeftPos), nLeftMax) + "  >>  \n";
				nLeftPos++;
				break;
		}
	}

	nLeftIndex = Func1Lines.GetSize();
	nRightIndex = Func2Lines.GetSize();
	for (; ((nLeftPos < nLeftIndex) && (nRightPos < nRightIndex)); nLeftPos++, nRightPos++) {
		strRetVal += PadString(Func1Lines.GetAt(nLeftPos), nLeftMax);
		if (pFunction1->GetAt(nLeftPos)->IsExactMatch(pFunction2->GetAt(nRightPos))) {
			strRetVal += "  ==  ";
		} else {
			strRetVal += "  --  ";
		}
		strRetVal += Func2Lines.GetAt(nRightPos) + "\n";
		if (pSymbolMap) pSymbolMap->AddObjectMapping(*pFunction1->GetAt(nLeftPos), *pFunction2->GetAt(nRightPos));
	}

	return strRetVal;
}