DWORD WINAPI CheckImages(LPVOID pData)
{
	iMode=0;
	bStopCheck=0;
	bStopLoad=0;
	lDeletedFiles=0;
	// Первый этап - сбор дибов
	CSize aMins(100,100);
	CDesktopDC dcDesk;
	int iSize=sListOfImages.GetSize();
	for(int zi=0;zi<iSize;zi++){
		aClosestImage.SetAtGrow(zi,-1);
		aClosestImageTaken.SetAtGrow(zi,0);
	}
	/*CSplashParams* sp=0;
	CSplashWindow* sw=0;
	if(!hDiag){
		sp=new CSplashParams();
		sp->szText="Reading...";
		sp->bgColor=0;
		sp->txColor=RGB(255,255,255);
		sp->dwTextParams|=TXSHADOW_VCENT|TXSHADOW_FILLBG|TXSHADOW_WIDE|TXSHADOW_GLOW|TXSHADOW_MIXBG;////TXSHADOW_SHCOL
		sp->dwSplashAlign=SPLASH_OPACITY;
		sp->dwSplashAlign|=SPLASH_HLEFT;
		sp->dwSplashAlign|=SPLASH_VTOP;
		sw=new CSplashWindow(sp);
	}*/
	{
		CDesktopDC dcDesk;
		CDC dc;
		dc.CreateCompatibleDC(&dcDesk);
		CDC dc2;
		dc2.CreateCompatibleDC(&dcDesk);
		dc.SetStretchBltMode(HALFTONE);
		dc2.SetStretchBltMode(HALFTONE);
		CSmartLock cs(csCheck,TRUE);
		for(int i=0;i<iSize;i++){
			if(bStopCheck){
				break;
			}
			if(bStopLoad){
				iMode=1;
				break;
			}
			if(hDiag){
				::SetWindowText(hDiag,Format("%i%%, %s",long(100*i/double(iSize)),_l("Preparations")));
				::SetWindowText(GetDlgItem(hDiag,IDC_STATUS),Format(" %s #%i/%i...",_l("Preparing image"),i,iSize));
			}
			sListOfImageDibs.SetAtGrow(i,0);
			CBitmap* bmp=_bmpX()->LoadBmpFromPath(sListOfImages[i]);
			CSize size2=GetBitmapSize(bmp);
			if(bmp){
				{// Занести обратно
					//HBITMAP hSmall=0;
					// CopyBitmapToBitmap(*bmp,hSmall,CSize(0,0),&aMins,-1);
					CBitmap bmpSmall;
					bmpSmall.CreateCompatibleBitmap(&dc,aMins.cx,aMins.cy);
					CBitmap* bmpTmp=dc.SelectObject(bmp);
					CBitmap* bmpTmp2=dc2.SelectObject(&bmpSmall);
					dc2.StretchBlt(0,0,aMins.cx,aMins.cy,&dc,0,0,size2.cx,size2.cy,SRCCOPY);
					dc2.SelectObject(&bmpTmp2);
					dc.SelectObject(&bmpTmp);
					CDib* pDib=new CDib();
					if(pDib){
						pDib->Create(aMins.cx,aMins.cy);
						pDib->SetBitmap(&dc2,bmpSmall);
						sListOfImageDibs.SetAtGrow(i,pDib);
					}
					//DeleteObject(hSmall);
				}
				_bmpX()->ReleaseBmp(bmp);
			}
		}
		if(!bStopCheck){
			iMode=1;
			if(hDiag){
				::SetWindowText(GetDlgItem(hDiag,ID_NEXT),_l("Next image pair"));
				::EnableWindow(GetDlgItem(hDiag,ID_NEXT),TRUE);
				::SetWindowText(GetDlgItem(hDiag,IDC_STATUS),CString(" ")+_l("Looking for duplicates")+"...");
				::EnableWindow(GetDlgItem(hDiag,IDC_IMGR_DEL_ALL),TRUE);
				::PostMessage(hDiag,WM_COMMAND,ID_NEXT,0);
			}
		}
	}
	/*
	if(sp){
		delete sp;
	}
	if(sw){
		delete sw;
	}
	*/
	return 0;
};
Example #2
0
void SODL::WriteSODL(INXString sodlfile) {
	ofstream datafile(sodlfile);
	ConData *blob;
	INXPOSITION pos;
	INXString funcName;
	int funcArg = -1;
	int startFunc = 0;
	UINT i;
	UINT j;
	UINT funcInPortNum = 0, funcOutPortNum = 0, funcFinPortNum = 0;
	// *** lineID is an array of unsigned ints. However, it needs to store the value -1 if
	// a port is not connected. Could use a CArray of type int, but this gives a smaller range
	// of line IDs than using a CUIntArray. Using such an array means -1 is stored as 4294967295.
	// This value should never be reached.
	INXObjArray<unsigned int> lineType;
	CArray<long,long> lineID;
	vector<Group> vGroups;
	TagProjMetaSupportData_t tagData;
	INXString csTargetFileName = "", csMessage = "";

	if (!datafile.good()) {
		AfxMessageBox("File could not be written");
	}
	
	//AfxMessageBox( "Get ready to call Copy2Flattened" );
	// Flatten encapsulated blocks
	Copy2Flattened();

	//AfxMessageBox( "Get ready to call Flatten" );
	Flatten();
	//SaveProg2("tmp.prg");	
	// 1. Assign a unique incremental integer (within its data type) to each line
	//AfxMessageBox( "Get ready to call AssignLineIDNum" );
	AssignLineIDNum();
	// First write the number of groups to the sodl file.
	// Turn off scheduling
	//datafile << 0 << endl;

	//AfxMessageBox( "Get ready to call generate SODL proper" );
	//@todo - add the following datafile << "hashmark" << Project << endl;
/************* The following is where everything is written out. This should be a new function *******************/	
	// Write out the parameters for each group
	WriteVersionInformation(&datafile);
/************ Now add the group data **********************/
	pProject->pProjMData->getGroupVec(vGroups);
	datafile << vGroups.size() << endl;
	

	for (i=0; i<vGroups.size(); i++) {
		datafile << vGroups.at(i).ID << '\t';
		datafile << vGroups.at(i).Period << '\t';
		datafile << vGroups.at(i).Alloc << endl;
	}

	/***** Now add the programme body *******************/
	// 2. For each icon
	pos = flattened->GetHeadPosition();

	while(pos) {

		blob = (ConData *) (flattened->GetNext(pos));

		// check that a startport is connected or an internalport exists or it is the new style constant without a startport
		bool writeObject = FALSE;
		for (i=0; i<blob->startport_num; i++) {
			if (blob->startport[i]->line.exist || blob->startport[i]->initialise) {
				writeObject = true;
			}
		}

		if (blob->internalport_num > 0) {
			writeObject = true;
		}

		if (writeObject) {

			// 3. Write the tag and class name.
			datafile << "BEGIN ";
			datafile << (CString)blob->className << endl;

			// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
			// Write the parameter string.
			// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
			if (blob->iParamNum == 1) {
				datafile << NOPARAMS;

			} else {
				for (i=1; i<blob->iParamNum; i++) {
					// if the parameter is an empty string and there is only 1 parameter 
					// then write out "" else write out "NULL"
					if (blob->iconParam[i]->value == "_") {
						if (blob->iParamNum == 2) {
							datafile << "" << " ";
						}
						else {
							datafile << "NULL" << " ";
						}
					}
					// for string constants don't append a space
					else if (blob->m_csIconType == "const_s") {
							datafile << (CString)blob->iconParam[i]->value;
					}
					// for gui components prepend %%%_
					else if (i==1 && (blob->isGuiWidget())) {
						datafile << "%%%_" << (CString)blob->iconParam[i]->value << " ";
					}
					// for screen tags write out the target filename
					else if (blob->iconParam[i]->dataType == 4) {
						LucidErrEnum err = pProject->pProjMData->getScreenTagMetas((CString &)blob->iconParam[i]->value, tagData);
						assert (err == kErr_NoErr);
						datafile << (CString)tagData.tgtFilename << " ";
					}
					// write out target filename for data files
					else if (blob->m_csIconType.Find("file_ro") != -1 && blob->iconParam[i]->name == "File name") {
						if (pProject->pProjMData->getTargetFileNameForDataHostFileName(blob->iconParam[i]->value, csTargetFileName)) {
							csMessage.Format("File \"%s\" does not exist in the project. Your application may not work as expected.", blob->iconParam[i]->value);
							// Don't display message because IPlayer demo runs a script which relies on host filenames
							//AfxMessageBox(csMessage);
							datafile << (CString)blob->iconParam[i]->value << " ";
						}
						else {
							datafile << (CString)csTargetFileName << " ";
						}
					}
					else {
						datafile << (CString)blob->iconParam[i]->value << " ";
					}

				}

			} // (blob->iParamNum != 1)

			// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
			// <ENDOF> Write the parameter string.
			// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


			datafile << endl;
			// 5. Write the tag to begin listing functions


			// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
			// For each start trigger port
			// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

			for (i=0; i<blob->startport_num; i++) {

				funcInPortNum = 0; funcOutPortNum = 0, funcFinPortNum = 0;
				// if the start port is initialised SODL requires a start function
				if (blob->startport[i]->initialise) {
					startFunc = 1;
				}
				// if the start port is connected or initialised
				if (blob->startport[i]->line.exist || blob->startport[i]->initialise) {
					// 7.1 Write its function name. Is there only 1 function?
					funcName = blob->startport[i]->funcName->GetAt(0);
					datafile << (CString)funcName << '\t';
					// Write out atomic flag
					//datafile << blob->startport[i]->atomicFlag << '\t';
					datafile << 1 << '\t';
					// Write out group ID for start port
					datafile << blob->startport[i]->groupID << '\t';
					// Write out start trigger line ID
					datafile << blob->startport[i]->line.idNum << '\t';
					// 7.2 Search through all other ports to find any other references
					// to the function name
					lineID.RemoveAll();
					lineType.RemoveAll();
					for (j=0; j<blob->inputport_num; j++) {
						for (int k=0; k<blob->inputport[j]->funcName->GetSize(); k++) {
							if (blob->inputport[j]->funcName->GetAt(k) == funcName) {
								funcInPortNum++;
								funcArg = blob->inputport[j]->funcArg->GetAt(k);
								//store the line id and type in a temp. array
								// check if a line is connected
								if (blob->inputport[j]->line.exist) {
									lineID.SetAtGrow(funcArg, blob->inputport[j]->line.idNum);
								}
								else {
									lineID.SetAtGrow(funcArg, -1);		
								}
								lineType.SetAtGrow(funcArg, blob->inputport[j]->datatype);
							}
						}
					}

					// write out inputs
					datafile << funcInPortNum << " ";
					for (j=1; j<=funcInPortNum; j++) {
						datafile << convert.DataType2Char(lineType.GetAt(j)) << " ";
						// Originally wrote out a * for uncoonected ports. Now writes out -1.
						/*if (lineID.GetAt(j) == -1) {
							datafile << "* ";
						}
						else {*/
							datafile << lineID.GetAt(j) << " ";
						//}
					}

					for (j=0; j<blob->outputport_num; j++) {
						for (int k=0; k<blob->outputport[j]->funcName->GetSize(); k++) {
							if (blob->outputport[j]->funcName->GetAt(k) == funcName) {
								funcOutPortNum++;
								funcArg = blob->outputport[j]->funcArg->GetAt(k);
								//store the line id and type in a temp. array
								// check if a line is connected
								if (blob->outputport[j]->lineID > -1) {
									lineID.SetAtGrow(funcArg, blob->outputport[j]->lineID);
								}
								else {
									lineID.SetAtGrow(funcArg, -1);
								}
								lineType.SetAtGrow(funcArg, blob->outputport[j]->datatype);
							}
						}
					}
					
					// write out outputs
					datafile << '\t' << funcOutPortNum << " ";
					for (j=(funcInPortNum + 1); j<=(funcInPortNum + funcOutPortNum); j++) {
						datafile << convert.DataType2Char(lineType.GetAt(j)) << " ";
						datafile << lineID.GetAt(j) << " ";
					}
					
					for (j=0; j<blob->finishport_num; j++) {
						for (int k=0; k<blob->finishport[j]->funcName->GetSize(); k++) {
							if (blob->finishport[j]->funcName->GetAt(k) == funcName) {
								funcFinPortNum++;
								funcArg = blob->finishport[j]->funcArg->GetAt(k);
								//store the line id and type in a temp. array
								// check if a line is connected
								if (blob->finishport[j]->lineID > -1) {
									lineID.SetAtGrow(funcArg, blob->finishport[j]->lineID);
								}
								else {
									lineID.SetAtGrow(funcArg, -1);
								}
							}
						}
					}
					// write out finish ports
					datafile << '\t' << funcFinPortNum << " ";
					// Only write out the finish line numbers if there is at least one connection
					if (funcFinPortNum > 0) {
						for (int m=(funcInPortNum + funcOutPortNum + 1); m<lineID.GetSize(); m++) {
							datafile << lineID.GetAt(m) << " ";
						}
					}
					
					datafile << endl;
				}
			}
			// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
			// <ENDOF> For each start trigger port
			// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



			// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
			// For each internal trigger port
			// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

			for (i=0; i<blob->internalport_num; i++) {
				funcInPortNum = 0; funcOutPortNum = 0, funcFinPortNum = 0;
				// ***REVISIT. Write its function name. Is there only 1 function?
				funcName = blob->internalport[i]->funcName->GetAt(0);
				datafile << (CString)funcName << '\t';
				// Write out atomic flag
				//datafile << blob->internalport[i]->atomicFlag << '\t';
				datafile << 1 << '\t';
				// Write out group ID for internal port
				datafile << blob->internalport[i]->groupID << '\t';
				// The internal trigger does not have a line ID so write out 0 if it is the
				// Start function and -1 otherwise.
				if (funcName == START) {
					datafile << 0 << '\t';
				}
				else {
					datafile << -1 << '\t';
				}
				// 7.2 Search through all other ports to find any other references
				// to the function name
				lineID.RemoveAll();
				lineType.RemoveAll();
				for (j=0; j<blob->inputport_num; j++) {
					for (int k=0; k<blob->inputport[j]->funcName->GetSize(); k++) {
						if (blob->inputport[j]->funcName->GetAt(k) == funcName) {
							funcInPortNum++;
							funcArg = blob->inputport[j]->funcArg->GetAt(k);
							//store the line id and type in a temp. array
							// check if a line is connected
							if (blob->inputport[j]->line.exist) {
								lineID.SetAtGrow(funcArg, blob->inputport[j]->line.idNum);
							}
							else {
								lineID.SetAtGrow(funcArg, -1);		
							}
								lineType.SetAtGrow(funcArg, blob->inputport[j]->datatype);
						}
					}
				}
				// write out inputs
				datafile << funcInPortNum << " ";
				for (j=1; j<=funcInPortNum; j++) {
					datafile << convert.DataType2Char(lineType.GetAt(j)) << " ";
					datafile << lineID.GetAt(j) << " ";
				}

				for (j=0; j<blob->outputport_num; j++) {
					for (int k=0; k<blob->outputport[j]->funcName->GetSize(); k++) {
						if (blob->outputport[j]->funcName->GetAt(k) == funcName) {
							funcOutPortNum++;
							funcArg = blob->outputport[j]->funcArg->GetAt(k);
							//store the line id and type in a temp. array
							// check if a line is connected
							if (blob->outputport[j]->lineID > -1) {
								lineID.SetAtGrow(funcArg, blob->outputport[j]->lineID);
							}
							else {
								lineID.SetAtGrow(funcArg, -1);
							}
							lineType.SetAtGrow(funcArg, blob->outputport[j]->datatype);
						}
					}
				}
					
				// write out outputs
				datafile << '\t' << funcOutPortNum << " ";
				for (j=(funcInPortNum + 1); j<=(funcInPortNum + funcOutPortNum); j++) {
					int tmp = lineType.GetAt(j);
					datafile << convert.DataType2Char(lineType.GetAt(j)) << " ";
					datafile << lineID.GetAt(j) << " ";
				}
					
				for (j=0; j<blob->finishport_num; j++) {
					for (int k=0; k<blob->finishport[j]->funcName->GetSize(); k++) {
						if (blob->finishport[j]->funcName->GetAt(k) == funcName) {
							funcFinPortNum++;
							funcArg = blob->finishport[j]->funcArg->GetAt(k);
							//store the line id and type in a temp. array
							// check if a line is connected
							if (blob->finishport[j]->lineID > -1) {
									lineID.SetAtGrow(funcArg, blob->finishport[j]->lineID);
							}
							else {
								lineID.SetAtGrow(funcArg, -1);
							}
						}
					}
				}
				// write out finish ports
				datafile << '\t' << funcFinPortNum << " ";
				for (int m=(funcInPortNum + funcOutPortNum + 1); m<lineID.GetSize(); m++) {
					datafile << lineID.GetAt(m) << " ";
				}		
				datafile << endl;
			}
			// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
			// <ENDOF> For each internal trigger port
			// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


			// 8. Write out end of icon tags
			datafile << "END" << endl;
			//datafile << endl;

		} //if (writeObject)
	}
	// Always Write out start function -- even if no other functions need initialising.
	//if (startFunc) {
		datafile << "BEGIN Start" << endl;
		datafile << "*" << endl;
		datafile << "Run_Start	1	1	0	0 	0 	1 1" << endl;
		datafile << "END" << endl;
	//}
	datafile.close();
}
Example #3
0
void CIISConfigHelper::PopulateTreeFromFileSystem(CTreeCtrl& cTree, HTREEITEM htParent, const std::set<CStringW>& IgnoreDirNames, int nMaxDepth)
{
	if (htParent == NULL)
		return;	

	// get the item data from the tree item
	IISURIItem* pParentItem = (IISURIItem*) cTree.GetItemData(htParent);
	if (pParentItem == NULL)
	{
		ASSERT(pParentItem != NULL);
		return;
	}

	// if the item is incomplete then we need to get it's file system path
	if (pParentItem->Type == IISURIItem::IncompleteFileSystemPath && pParentItem->sFileSystemPath.GetLength() <= 0)
	{
		// get the grand parent item
		HTREEITEM htGrandParent = cTree.GetParentItem(htParent);
		if (htGrandParent == NULL)
		{
			ASSERT(htGrandParent != NULL);
			return;
		}		

		// get the grand parent item data
		IISURIItem* pGrandParentItem = (IISURIItem*) cTree.GetItemData(htGrandParent);
		if (pGrandParentItem == NULL)
		{
			ASSERT(pGrandParentItem != NULL);
			return;
		}

		// the grand parent MUST not be incomplete
		if (pGrandParentItem->Type == IISURIItem::IncompleteFileSystemPath)
		{
			ASSERT(pGrandParentItem->Type != IISURIItem::IncompleteFileSystemPath);
			return;
		}

		// get the item name
		CStringW sName = CStringW(cTree.GetItemText(htParent));
		if (sName.GetLength() <= 0)
		{
			ASSERT(sName.GetLength() > 0);
			return;
		}

		// make the path to the parent item
		CPathT<CStringW> ItemFileSystemPath(pGrandParentItem->sFileSystemPath);
		ItemFileSystemPath.Append(sName);

		// assign the new file system path and set the type
		pParentItem->sFileSystemPath = (LPCWSTR) ItemFileSystemPath;
		pParentItem->Type = IISURIItem::FileSystem;
	}

	// if the item already has children then we need to build up a list of their names
	std::set<CStringW> KnownDirs;
	if (cTree.ItemHasChildren(htParent) == TRUE)
	{
		// loop through all the children
		HTREEITEM htChild = cTree.GetChildItem(htParent);
		while (htChild != NULL)
		{
			// get the child name
			CStringW sName = CStringW(cTree.GetItemText(htChild));

			// we need lower case so we can compare easier
			sName.MakeLower();

			// add the name to the known list
			KnownDirs.insert(sName);

			// move on to the next child item
			htChild = cTree.GetNextSiblingItem(htChild);
		}
	}

#ifdef _DEBUG
	ATLTRACE2(L"CIISConfigHelper::PopulateTreeFromFileSystem() : searching '%s'\n", pParentItem->sFileSystemPath);
#endif

	// create a search string
	CPathT<CStringW> FileSystemPath(pParentItem->sFileSystemPath);
	FileSystemPath.Append(L"*.*");
	CStringW sSearchPath = (LPCWSTR) FileSystemPath;	

	// start the search
	WIN32_FIND_DATAW FindData;	
	HANDLE hFind = ::FindFirstFileW(sSearchPath, &FindData);
	if (hFind == INVALID_HANDLE_VALUE)
	{
		// TODO: empty
		return;
	}

	CArray<CStringW, LPCWSTR> saDirs;	

	// guess that we will have 32 sub dirs (the array will grow if we have more)
	saDirs.SetSize(32);

	// keep track of the number of dirs we have actually found
	int nDirsFound = 0;

	do
	{		
		if ((FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
			continue;		

		// eliminate . and .. from the search
		if (FindData.cFileName[0] == '.')
		{
			if (FindData.cFileName[1] == '\0')
			{
				continue;
			}
			else if (FindData.cFileName[1] == '.' && FindData.cFileName[2] == '\0')
			{
				continue;
			}
		}		
			
		// convert to lower case
		CStringW sTempFileName = FindData.cFileName;
		sTempFileName.MakeLower();

		// only add to the collection if we don't already know about it
		if (KnownDirs.find(sTempFileName) != KnownDirs.end())
			continue;

		// if it's a known ignore dir name - then ignore it
		if (IgnoreDirNames.find(sTempFileName) != IgnoreDirNames.end())
			continue;
		
#ifdef _DEBUG
		ATLTRACE2(L"CIISConfigHelper::PopulateTreeFromFileSystem() : found '%s'\n", FindData.cFileName);
#endif

		saDirs.SetAtGrow(nDirsFound, FindData.cFileName);		

		// we have found one
		nDirsFound++;
	}
	while (::FindNextFileW(hFind, &FindData) == TRUE);	

	// get rid of the find handle
	::FindClose(hFind);
	hFind = NULL;	
	
	if (nDirsFound <= 0)
	{		
		return;
	}

	if (nMaxDepth <= 0)
	{
		cTree.InsertItem(EmptyNodeString, htParent);
		return;
	}

	for (int i = 0; i < nDirsFound; i++)
	{
		CString sDir(saDirs[i]);
		HTREEITEM htChild = cTree.InsertItem(sDir, htParent);		

		// create the child file system path
		CPathT<CStringW> FileSystemPath(pParentItem->sFileSystemPath);
		FileSystemPath.Append(saDirs[i]);

		// we need an item data for this tree item
		IISURIItem* pChildItem = new IISURIItem;
		pChildItem->Type = IISURIItem::FileSystem;
		pChildItem->sFileSystemPath = (LPCWSTR) FileSystemPath;

		// make the child URI
		CStringW sChildURI = pParentItem->sURI;
		int nChildURILength = sChildURI.GetLength();
		if (nChildURILength > 0 && sChildURI[nChildURILength - 1] != '/')
			sChildURI += '/';

		// append the dir name
		sChildURI += saDirs[i];

		// assign the URI to the item data
		pChildItem->sURI = sChildURI;

		// store the item data
		cTree.SetItemData(htChild, (DWORD_PTR) pChildItem);

		PopulateTreeFromFileSystem(cTree, htChild, IgnoreDirNames, nMaxDepth - 1);
	}
}