예제 #1
0
void __fastcall TFrmMain::ToolButton1Click(TObject *Sender)
{
    bool SeFlag=true;
    if(FrmSearch->ShowModal()==mrOk){
            switch (FrmSearch->rgSI->ItemIndex)
           {
             case 0: //向上找;
                 for(int i=sgEdit->ColCount*sgEdit->Row+sgEdit->Col-1;i>sgEdit->ColCount;i--){
                     if(i%sgEdit->ColCount!=0){
                          if( 0==CompareStr(sgEdit->Cells[i-sgEdit->ColCount*(i/sgEdit->ColCount)][i/sgEdit->ColCount],
                                 FrmSearch->edSeach->Text)){ //找到了
                                 sgEdit->Col=i-sgEdit->ColCount*i/sgEdit->ColCount;
                                 sgEdit->Row=i/sgEdit->ColCount;
                                 SeFlag=false;
                                 break;
                          }
                     }
                 }
                 if(SeFlag)  ShowMessage("Seach Top,Find Nothing.");
             break;
             case 1:  //向下找;
                 for(int i=sgEdit->ColCount*sgEdit->Row+sgEdit->Col+1;i<sgEdit->ColCount*sgEdit->RowCount;i++){
                     if(i%sgEdit->ColCount!=0){
                          if( 0==CompareStr(sgEdit->Cells[i-sgEdit->ColCount*(i/sgEdit->ColCount)][i/sgEdit->ColCount],
                                 FrmSearch->edSeach->Text)){ //找到了
                                 sgEdit->Col=i-sgEdit->ColCount*(i/sgEdit->ColCount);
                                 sgEdit->Row=i/sgEdit->ColCount;
                                 SeFlag=false;
                                 break;
                          }
                     }
                 }
                 if(SeFlag)  ShowMessage("Seach End,Find Nothing");
             break;
             case 2: //当前列向上找;
                 for(int i=sgEdit->Row;i>1;i--){
                          if( 0==CompareStr(sgEdit->Cells[sgEdit->Col][i],
                                 FrmSearch->edSeach->Text)){ //找到了
                                 sgEdit->Row=i;
                                 SeFlag=false;
                                 break;
                          }
                 }
                 if(SeFlag)  ShowMessage("Seach col top,Find Nothing");
             break;
             case 3:  //当前列向下找;
                 for(int i=sgEdit->Row;i<sgEdit->RowCount;i++){
                          if( 0==CompareStr(sgEdit->Cells[sgEdit->Col][i],
                                 FrmSearch->edSeach->Text)){ //找到了
                                 sgEdit->Row=i;
                                 SeFlag=false;
                                 break;
                          }
                 }
                 if(SeFlag)  ShowMessage("Seach col end,Find Nothing.");
             break;
           }
    }
}
예제 #2
0
파일: fileutil.cpp 프로젝트: gkathire/wxVCL
wxString FindDiskFileCaseInsensitive(wxString const & Filename)
{
	wxString result = "";
	wxString ShortFilename;
	wxString CurDir;
	wxDir dir;
	CurDir = ExtractFilePath(Filename);
	wxArrayString FileList;
	dir.GetAllFiles(CurDir, &FileList, GetAllFilesMask(), wxDIR_DEFAULT);

	for (size_t i = 0; i < FileList.GetCount(); i++)
	{
		ShortFilename = ExtractFileName(Filename);
		if (CompareText(FileList[i], ShortFilename) == 0)
		{
			if (CompareStr(FileList[i], ShortFilename) == 0)
			{
				// fits exactly
				result = Filename;
				break;
			}
			// fits case insensitive
			result = CurDir + FileList[i];
			// search further
		}
	}
	return result;
}
예제 #3
0
bool Searcher::Compare(const bool isMe, const std::wstring& message, TCHAR *strFind)
{
	if (onlyIn && isMe || onlyOut && !isMe)
		return false;

	return CompareStr(message, strFind);
}
예제 #4
0
void ComTerrain::LoadMap()
{
	vector<Vector3> vecP;
	vector<DWORD> vecAttbuf;
	CString mtlName;
	char token[TOKEN_SIZE];

	std::ifstream fin;

	fin.open(m_filePath + m_mapFilename);

	if (fin.is_open() == false)
		assert(false && "fin.is_open() == false");

	float fPosXMax = 0.0f;
	float fPosZMax = 0.0f;

	while (fin.eof() == false)
	{
		fin >> token;

		if (CompareStr(token, "mtllib"))
		{
			fin >> token;
			LoadMtlLib(m_filePath + token);
		}
		else if (CompareStr(token, "v"))
예제 #5
0
파일: fileutil.cpp 프로젝트: gkathire/wxVCL
/* ------------------------------------------------------------------------------
 function CompareFileExt(const Filename, Ext: string;
 CaseSensitive: boolean): integer;
 ------------------------------------------------------------------------------ */
int CompareFileExt(wxString const & Filename, wxString const & Ext,
  bool CaseSensitive)
{
	wxString FileExt = ExtractFileExt(Filename);
	if (CaseSensitive)
		return CompareStr(FileExt, Ext);
	else
		return CompareText(FileExt, Ext);
}
예제 #6
0
bool Searcher::IsInSel(int sel, TCHAR *strFind)
{
	if (sel < 0 || sel >= (int)context->eventList.size())
		return false;

	TCHAR str[MAXSELECTSTR + 8]; // for safety reason
	EventList::EventData data;
	for (std::deque<EventList::EventIndex>::iterator it = context->eventList[sel].begin(); it != context->eventList[sel].end(); ++it) {
		EventList::EventIndex hDbEvent = *it;
		if (context->GetEventData(hDbEvent, data)) {
			bool isMe = data.isMe;
			if (onlyIn && isMe || onlyOut && !isMe)
				continue;

			context->GetEventMessage(hDbEvent, str);
			if (CompareStr(str, strFind))
				return true;
		}
	}
		
	return false;
}
예제 #7
0
long CreateUniverse(long loc0, char *name, long level)
{
  long loc1, loc2, lst, ptr, uni, cell, nst, reg, lat, pbd, umsh, stl, n;

  /* Check level count */

  if (level > MAX_GEOMETRY_LEVELS)
    Error(loc0, "Maximum number of geometry levels exceeded (infinite loop?)");

  /* Compare level to maximum */

  if (level + 1 > (long)RDB[DATA_GEOM_LEVELS])
    WDB[DATA_GEOM_LEVELS] = (double)(level + 1.0);

  /***************************************************************************/
 
  /***** Check if universe exists ********************************************/

  /* Loop over universes */

  uni = RDB[DATA_PTR_U0];
  while (uni > VALID_PTR)
    {
      /* Compare names */
      
      if (!strcmp(GetText(uni + UNIVERSE_PTR_NAME), name)) 
	return uni;
      
      /* Next universe */
      
      uni = NextItem(uni);
    }

  /* Create new universe */

  uni = NewItem(DATA_PTR_U0, UNIVERSE_BLOCK_SIZE);

  /* Put name */

  WDB[uni + UNIVERSE_PTR_NAME] = (double)PutText(name);

  /* Put level */
  
  WDB[uni + UNIVERSE_LEVEL] = (double)level;

  /* Reset pointers */

  WDB[uni + UNIVERSE_PTR_CELL_LIST] = NULLPTR;
  WDB[uni + UNIVERSE_PTR_NEST] = NULLPTR;
  WDB[uni + UNIVERSE_PTR_LAT] = NULLPTR;
  WDB[uni + UNIVERSE_PTR_PBED] = NULLPTR;
  WDB[uni + UNIVERSE_PTR_UMSH] = NULLPTR;
  WDB[uni + UNIVERSE_PTR_SYM] = NULLPTR;

  /* Allocate memory for collision counter */

  AllocValuePair(uni + UNIVERSE_COL_COUNT);

  /* Allocate memory for coordinates */

  ptr = AllocPrivateData(1, PRIVA_ARRAY);
  WDB[uni + UNIVERSE_PTR_PRIVA_X] = (double)ptr;

  ptr = AllocPrivateData(1, PRIVA_ARRAY);
  WDB[uni + UNIVERSE_PTR_PRIVA_Y] = (double)ptr;

  ptr = AllocPrivateData(1, PRIVA_ARRAY);
  WDB[uni + UNIVERSE_PTR_PRIVA_Z] = (double)ptr;

  /* Onko tän ajan pakko olla universe-rakenteessa? */

  ptr = AllocPrivateData(1, PRIVA_ARRAY);
  WDB[uni + UNIVERSE_PTR_PRIVA_T] = (double)ptr;

  /* Allocate memory for previous region */

  ptr = AllocPrivateData(1, PRIVA_ARRAY);
  WDB[uni + UNIVERSE_PTR_PREV_REG] = (double)ptr;

  /***************************************************************************/

  /***** Cells ***************************************************************/

  /* Loop over cells */

  cell = RDB[DATA_PTR_C0];
  while (cell > VALID_PTR)
    {

      /* Compare names and check used-flag */

      if (!((long)RDB[cell + CELL_OPTIONS] & OPT_USED))
	if (CompareStr(cell + CELL_PTR_UNI, uni + UNIVERSE_PTR_NAME))
	  {
	    /* Set used-flag */

	    SetOption(cell + CELL_OPTIONS, OPT_USED);

	    /* Put pointer */
	    
	    WDB[cell + CELL_PTR_UNI] = (double)uni;
	    
	    /* Create new item in universe cell list */
	    
	    lst = NewItem(uni + UNIVERSE_PTR_CELL_LIST, CELL_LIST_BLOCK_SIZE);
	    
	    /* Put pointer */
	    
	    WDB[lst + CELL_LIST_PTR_CELL] = (double)cell;

	    /* Allocate memory from private array */

	    ptr = AllocPrivateData(1, PRIVA_ARRAY);

	    /* Put pointer */
	    
	    WDB[lst + CELL_LIST_PTR_COUNT] = (double)ptr;

	    /* Check if fill pointer is set */
	    
	    if (RDB[cell + CELL_PTR_FILL] > VALID_PTR)
	      {
		/* Call recursively */
		
		sprintf(name, "%s", GetText(cell + CELL_PTR_FILL));
		loc1 = CreateUniverse(cell, name, level + 1);
		
		/* Put pointer */
		
		WDB[cell + CELL_PTR_FILL] = (double)loc1;
	      }
	    
	    /* Put universe type */
	    
	    WDB[uni + UNIVERSE_TYPE] = (double)UNIVERSE_TYPE_CELL;
	  }
      
      /* Next cell */
      
      cell = NextItem(cell);
    }

  /* Check if cells are defined */
  
  if ((ptr = (long)RDB[uni + UNIVERSE_PTR_CELL_LIST]) > 0)
    {
      /* Close list (NOTE: Tää oli processinput.c:ssä 8.11.2010 asti) */

      CloseList(ptr);

      /* Return pointer to universe */

      return uni;
    }

  /***************************************************************************/

  /***** Nests ***************************************************************/

  /* Loop over nests */

  nst = RDB[DATA_PTR_NST0];
  while (nst > VALID_PTR)
    {
      /* Compare names and check used-flag */
      
      if ((CompareStr(nst + NEST_PTR_NAME, uni + UNIVERSE_PTR_NAME)) &
	  !((long)RDB[nst + NEST_OPTIONS] & OPT_USED))
	{
	  /* Set used-flag */

	  SetOption(nst + NEST_OPTIONS, OPT_USED);

	  /* Put pointers */
	  
	  WDB[nst + NEST_PTR_UNI] = (double)uni;
	  WDB[uni + UNIVERSE_PTR_NEST] = (double)nst;

	  /* Get pointer to regions */
	      
	  reg = (long)RDB[nst + NEST_PTR_REGIONS];
	  CheckPointer(FUNCTION_NAME, "(reg)", DATA_ARRAY, reg);

	  /* Close list */

	  CloseList(reg);

	  /* Loop over regions */ 
	      
	  while (reg > VALID_PTR)
	    {
	      /* Check if fill pointer is set */

	      if (RDB[reg + NEST_REG_PTR_FILL] > VALID_PTR)
		{
		  /* Call recursively */

		  sprintf(name, "%s", GetText(reg + NEST_REG_PTR_FILL));
		  loc1 = CreateUniverse(nst, name, level + 1);

		  /* Put pointer */

		  WDB[reg + NEST_REG_PTR_FILL] = (double)loc1;
		}

	      /* Next region */

	      reg = NextItem(reg);
	    }

	  /* Put universe type */

	  WDB[uni + UNIVERSE_TYPE] = (double)UNIVERSE_TYPE_NEST;

	  /* Return pointer to universe */

	  return uni;
	}

      /* Next nest */

      nst = NextItem(nst);
    }

  /***************************************************************************/

  /***** Lattices ************************************************************/

  /* Loop over lattices */

  lat = RDB[DATA_PTR_L0];
  while (lat > VALID_PTR)
    {
      /* Compare names and check used-flag */

      if ((CompareStr(lat + LAT_PTR_NAME, uni + UNIVERSE_PTR_NAME)) &
	  !((long)RDB[lat + LAT_OPTIONS] & OPT_USED))
	{
	  /* Set used-flag */

	  SetOption(lat + LAT_OPTIONS, OPT_USED);

	  /* Put pointers */

	  WDB[lat + LAT_PTR_UNI] = (double)uni;
	  WDB[uni + UNIVERSE_PTR_LAT] = (double)lat;

	  /* Check type */

	  if ((long)RDB[lat + LAT_TYPE] == LAT_TYPE_CLU)
	    {
	      /***** Circular array ******************************************/
	      
	      /* Get pointer to rings */
	      
	      reg = (long)RDB[lat + LAT_PTR_FILL];
	      CheckPointer(FUNCTION_NAME, "(reg)", DATA_ARRAY, reg);

	      /* Loop over rings */ 
	      
	      while (reg > VALID_PTR)
		{
		  /* Loop over items */ 
		  
		  ptr = (long)RDB[reg + RING_PTR_FILL];
		  while ((long)RDB[ptr] > VALID_PTR)
		    {
		      /* Call recursively */
		      
		      sprintf(name, "%s", GetText(ptr));
		      loc1 = CreateUniverse(lat, name, level + 1);
		      
		      /* Put pointer */
		      
		      WDB[ptr++] = (double)loc1;
		    }

		  /* Next region */

		  reg = NextItem(reg);
		}

	      /***************************************************************/
	    }
	  else
	    {
	      /***** Simple types ********************************************/
	      
	      /* Loop over items */ 
	  
	      ptr = (long)RDB[lat + LAT_PTR_FILL];
	      while ((long)RDB[ptr] > VALID_PTR)
		{
		  /* Get universe  name */

		  sprintf(name, "%s", GetText(ptr));

		  /* Check if intentionally undefined (dots) */

		  for (n = 0; n < strlen(name); n++)
		    if (name[n] != '.')
		      break;
		  
		  /* Call recursively or put null pointer */
		  
		  if (n < strlen(name))
		    loc1 = CreateUniverse(lat, name, level + 1);
		  else
		    loc1 = NULLPTR;
		    
		  /* Put pointer */
		  
		  WDB[ptr++] = (double)loc1;
		}

	      /***************************************************************/
	    }

	  /* Put universe type */

	  WDB[uni + UNIVERSE_TYPE] = (double)UNIVERSE_TYPE_LATTICE;

	  /* Return pointer to universe */

	  return uni;
	}

      /* Next lattice */

      lat = NextItem(lat);
    }

  /***************************************************************************/

  /***** Pebble-bed geometries ***********************************************/

  /* Loop over geometries */

  pbd = RDB[DATA_PTR_PB0];
  while (pbd > VALID_PTR)
    {
      /* Compare names and check used-flag */
      
      if ((CompareStr(pbd + PBED_PTR_NAME, uni + UNIVERSE_PTR_NAME)) &
	  !((long)RDB[pbd + PBED_OPTIONS] & OPT_USED))
	{
	  /* Set used-flag */

	  SetOption(pbd + PBED_OPTIONS, OPT_USED);

	  /* Put pointers */

	  WDB[pbd + PBED_PTR_UNI] = (double)uni;
	  WDB[uni + UNIVERSE_PTR_PBED] = (double)pbd;

	  /* Call recursively for background universe */
	  
	  sprintf(name, "%s", GetText(pbd + PBED_PTR_BG_UNIV));
	  loc1 = CreateUniverse(pbd, name, level + 1);

	  /* Put pointer */

	  WDB[pbd + PBED_PTR_BG_UNIV] = (double)loc1;

	  /* Loop over pebbles */
	  
	  loc1 = (long)RDB[pbd + PBED_PTR_PEBBLES];
	  while (loc1 > VALID_PTR)
	    {
	      /* Call recursively for pebble */
	  
	      sprintf(name, "%s", GetText(loc1 + PEBBLE_PTR_UNIV));
	      ptr = CreateUniverse(pbd, name, level + 1);

	      /* Put pointer */

	      WDB[loc1 + PEBBLE_PTR_UNIV] = (double)ptr;

	      /* Loop over types */

	      loc2 = (long)RDB[pbd + PBED_PTR_PEBBLE_TYPES];
	      while(loc2 > VALID_PTR)
		{
		  /* Compare universe pointer */

		  if ((long)RDB[loc2 + PEBTYPE_PTR_UNIV] == ptr)
		    {
		      /* Add counter */

		      WDB[loc2 + PEBTYPE_COUNT] = 
			RDB[loc2 + PEBTYPE_COUNT] + 1.0;

		      /* Break loop */

		      break;
		    }

		  /* Next type */

		  loc2 = NextItem(loc2);
		}

	      /* Check pointer */

	      if (loc2 < VALID_PTR)
		{
		  /* No previous definition */

		  loc2 = NewItem(pbd + PBED_PTR_PEBBLE_TYPES, 
				 PEBTYPE_BLOCK_SIZE);

		  /* Put universe pointer */

		  WDB[loc2 + PEBTYPE_PTR_UNIV] = (double)ptr;

		  /* Init counter */

		  WDB[loc2 + PEBTYPE_COUNT] = 1.0;
		}

	      /* Next pebble */

	      loc1 = NextItem(loc1);
	    }

	  /* Put universe type */

	  WDB[uni + UNIVERSE_TYPE] = (double)UNIVERSE_TYPE_PBED;

	  /* Return pointer to universe */

	  return uni;
	}

      /* Next geometry */

      pbd = NextItem(pbd);
    }

  /***************************************************************************/

  /***** Unstructured mesh based geometries **********************************/

  /* Loop over geometries */

  umsh = RDB[DATA_PTR_UMSH0];
  while (umsh > VALID_PTR)
    {
      /* Compare names and check used-flag */
      
      if ((CompareStr(umsh + UMSH_PTR_NAME, uni + UNIVERSE_PTR_NAME)) &
	  !((long)RDB[umsh + UMSH_OPTIONS] & OPT_USED))
	{
	  /* Set used-flag */

	  SetOption(umsh + UMSH_OPTIONS, OPT_USED);

	  /* Put pointers */

	  WDB[umsh + UMSH_PTR_UNI] = (double)uni;
	  WDB[uni + UNIVERSE_PTR_UMSH] = (double)umsh;

	  /* Call recursively for background universe */
	  
	  sprintf(name, "%s", GetText(umsh + UMSH_PTR_BG_UNIV));
	  loc1 = CreateUniverse(umsh, name, level + 1);

	  /* Put pointer */

	  WDB[umsh + UMSH_PTR_BG_UNIV] = (double)loc1;

	  /* Put universe type */

	  WDB[uni + UNIVERSE_TYPE] = (double)UNIVERSE_TYPE_UMSH;

	  /* Allocate memory for next cell */

	  AllocValuePair(uni + UNIVERSE_PTR_NEXT_CELL);

	  /* Return pointer to universe */

	  return uni;
	}

      /* Next geometry */

      umsh = NextItem(umsh);
    }

  /***************************************************************************/

  /***** STL geometries ******************************************************/

  /* Loop over geometries */
 
  stl = RDB[DATA_PTR_STL0];
  while (stl > VALID_PTR)
    {
      /* Compare names and check used-flag */
      
      if ((CompareStr(stl + STL_PTR_NAME, uni + UNIVERSE_PTR_NAME)) &
	  !((long)RDB[stl + STL_OPTIONS] & OPT_USED))
	{
	  /* Set used-flag */

	  SetOption(stl + STL_OPTIONS, OPT_USED);

	  /* Put pointers */

	  WDB[stl + STL_PTR_UNI] = (double)uni;
	  WDB[uni + UNIVERSE_PTR_STL] = (double)stl;

	  /* Call recursively for background universe */
	  
	  sprintf(name, "%s", GetText(stl + STL_PTR_BG_UNIV));
	  loc1 = CreateUniverse(stl, name, level + 1);

	  /* Put pointer */

	  WDB[stl + STL_PTR_BG_UNIV] = (double)loc1;

	  /* Put universe type */

	  WDB[uni + UNIVERSE_TYPE] = (double)UNIVERSE_TYPE_STL;

	  /* Return pointer to universe */

	  return uni;
	}

      /* Next geometry */

      stl = NextItem(stl);
    }

  /***************************************************************************/

  /* Universe is not defined */
  
  if ((level == 0) && ((long)RDB[DATA_PTR_ROOT_UNIVERSE] < VALID_PTR))
    Error(loc0, "Root universe %s is not defined", name);
  else
    Error(loc0, "Universe %s is not defined", name);
  
  /* Avoid compiler warning */

  return NULLPTR;
}
예제 #8
0
void Searcher::Find()
{
	FINDTEXTEX ft;
	TCHAR str[128];
	int curSel = 0;
	bool isStart = false;
	bool finished = false;
	ft.chrg.cpMin = 0;
	ft.chrg.cpMax = -1;
	ft.lpstrText = str;
	if (context->currentGroup.size() < 1) {
		SendMessage(context->editWindow,EM_SETOPTIONS,ECOOP_AND,~ECO_NOHIDESEL);
		lastFindSelection = -1;
		return;
	}

	GetWindowText(context->findWindow, str, 128);
	if (!str[0]) {
		TCHAR buf[256];
		mir_sntprintf(buf, 256, TranslateT("\"%s\" not found"), str);
		MessageBox(context->hWnd, buf, TranslateT("Search"), MB_OK | MB_ICONINFORMATION);
		return;
	}
	if (!matchCase) {
		std::locale loc;
		std::transform(str, str + _tcslen(str), str, std::bind2nd(std::ptr_fun(mytoupper), &loc));
	}
	
	bool findBack1 = findBack ^ !searchForInMes;
	bool findBack2 = findBack ^ !searchForInLG;
	int adder1 = findBack1 ? -1 : 1;
	int adder2 = findBack2 ? -1 : 1;
	WPARAM findStyle = (findBack1 ? 0 : FR_DOWN) | (matchCase ? FR_MATCHCASE : 0) | (matchWholeWords ? FR_WHOLEWORD : 0);
	if (lastFindSelection >= 0 && lastFindSelection < (int)context->currentGroup.size()) {
		if (onlyIn && context->currentGroup[lastFindSelection].isMe || onlyOut && !context->currentGroup[lastFindSelection].isMe)
			curSel = lastFindSelection + adder1;
		else {
			SendDlgItemMessage(context->hWnd,IDC_EDIT,EM_EXGETSEL,0,(LPARAM)&ft.chrg);
			if (findBack1) {
				ft.chrg.cpMin = ft.chrg.cpMin < context->currentGroup[lastFindSelection].endPos ? ft.chrg.cpMin : context->currentGroup[lastFindSelection].endPos; 
				ft.chrg.cpMax = context->currentGroup[lastFindSelection].startPos;
			}
			else {
				ft.chrg.cpMin = ft.chrg.cpMax > context->currentGroup[lastFindSelection].startPos ? ft.chrg.cpMax : context->currentGroup[lastFindSelection].startPos;
				ft.chrg.cpMax = context->currentGroup[lastFindSelection].endPos;
			}
			SendMessage(context->editWindow,EM_FINDTEXTEX, findStyle,(LPARAM)&ft);
			if (ft.chrgText.cpMin < 0 || ft.chrgText.cpMax < 0)
				curSel = lastFindSelection + adder1;
			else {
				if (isFindContactChanged && startFindContact == context->hContact && isFindSelChanged && context->selected == startFindSel && ((!findBack1 && ft.chrg.cpMin >= startFindPos) || (findBack1 && ft.chrg.cpMax <= startFindPos)))
					finished = true;
				else {
					curSel = lastFindSelection;
					SendMessage(context->editWindow,EM_EXSETSEL,0,(LPARAM)&ft.chrgText);
					SendMessage(context->editWindow,EM_SETOPTIONS,ECOOP_OR,ECO_NOHIDESEL);
					lastFindSelection = curSel;
					return;
				}
			}
		}
	}
	else {
		isStart = true;
		SendMessage(context->editWindow,EM_SETOPTIONS,ECOOP_OR,ECO_NOHIDESEL);
		SendMessage(context->editWindow,EM_EXGETSEL,0,(LPARAM)&ft.chrg);
		startFindPos = findBack1 ? ft.chrg.cpMin : (ft.chrg.cpMax >= 0 ? ft.chrg.cpMax : ft.chrg.cpMin);
		startFindSel = context->selected;
		if (startFindPos < 0)
			startFindPos = 0;
		isFindSelChanged = false;
		startFindContact = context->hContact;
		isFindContactChanged = !allUsers;
		if (findBack1) {
			for (curSel = (int)context->currentGroup.size() - 1; curSel >= 0; --curSel)
				if (context->currentGroup[curSel].startPos < startFindPos)
					break;
		}
		else
			for (; curSel < (int)context->currentGroup.size(); ++curSel)
				if (context->currentGroup[curSel].endPos > startFindPos)
					break;
	}

	if (!finished) {
		for (; curSel < (int)context->currentGroup.size() && curSel >= 0; curSel += adder1) {
			if (onlyIn && context->currentGroup[curSel].isMe || onlyOut && !context->currentGroup[curSel].isMe)
				continue;

			if (CompareStr(context->currentGroup[curSel].description, str)) {
				if (findBack1) {
					ft.chrg.cpMin = context->currentGroup[curSel].endPos;
					ft.chrg.cpMax = context->currentGroup[curSel].startPos;
					if (!isFindSelChanged && ft.chrg.cpMin > startFindPos)
						ft.chrg.cpMin = startFindPos;
				}
				else {
					ft.chrg.cpMin = context->currentGroup[curSel].startPos;
					ft.chrg.cpMax = context->currentGroup[curSel].endPos;
					if (!isFindSelChanged && ft.chrg.cpMin < startFindPos)
						ft.chrg.cpMin = startFindPos;
				}
				SendMessage(context->editWindow,EM_FINDTEXTEX, findStyle,(LPARAM)&ft);
				if (!(ft.chrgText.cpMin < 0 || ft.chrgText.cpMax < 0)) {
					if (isFindContactChanged && startFindContact == context->hContact && isFindSelChanged && context->selected == startFindSel && ((!findBack1 && ft.chrg.cpMin >= startFindPos) || (findBack1 && ft.chrg.cpMax <= startFindPos))) {
						finished = true;
						break;
					}
					SendMessage(context->editWindow,EM_EXSETSEL,0,(LPARAM)&ft.chrgText);
					SendMessage(context->editWindow,EM_SETOPTIONS,ECOOP_OR,ECO_NOHIDESEL);
					lastFindSelection = curSel;
					return;
				}
			}
		}
	}
	
	if (isFindContactChanged && startFindContact == context->hContact && isFindSelChanged && context->selected == startFindSel)
		finished = true;

	if (!finished) {
		isFindSelChanged = true;
		if (onlyGroup) {
			if (IsInSel(context->selected, str)) {
				CHARRANGE ch;
				ch.cpMin = ch.cpMax = findBack1 ? MAXLONG : 0;
				SendMessage(context->editWindow,EM_EXSETSEL,0,(LPARAM)&ch);
				lastFindSelection = findBack1 ? (int)context->currentGroup.size() - 1 : 0;
				Find();
				return;
			}
		}
		else {
			for (int sel = context->selected + adder2; ; sel += adder2) {
				if (sel < 0) {
					isFindContactChanged = true;
					if (allUsers) {
						HANDLE hNext = context->hContact; 
						do
						{
							hNext = context->GetNextContact(hNext, adder2);
						}
							while(hNext != startFindContact && !context->SearchInContact(hNext, str, this));
						context->SelectContact(hNext);
					}

					sel = (int)context->eventList.size() - 1;
				}
				else if (sel >= (int)context->eventList.size()) {
					isFindContactChanged = true;
					if (allUsers) {
						HANDLE hNext = context->hContact;
						do
						{
							hNext = context->GetNextContact(hNext, adder2);
						}
							while(hNext != startFindContact && !context->SearchInContact(hNext, str, this));
						context->SelectContact(hNext);
					}

					sel = 0;
				}
				if (IsInSel(sel, str)) {
					LVITEM item = {0};
					item.mask = LVIF_STATE;
					item.iItem = context->selected;
					item.state = 0;
					item.stateMask = LVIS_SELECTED;
					ListView_SetItem(context->listWindow, &item);
					item.iItem = sel;
					item.state = LVIS_SELECTED;
					ListView_SetItem(context->listWindow, &item);
					ListView_EnsureVisible(context->listWindow, sel, FALSE);		
					CHARRANGE ch;
					ch.cpMin = ch.cpMax = findBack1 ? MAXLONG : 0;
					SendMessage(context->editWindow,EM_EXSETSEL,0,(LPARAM)&ch);
					SendMessage(context->editWindow,EM_SETOPTIONS,ECOOP_OR,ECO_NOHIDESEL);
					lastFindSelection = findBack1 ? (int)context->currentGroup.size() - 1 : 0;
					isFindSelChanged = true;
					Find();
					return;
				}
				if (startFindContact == context->hContact && sel == startFindSel)
					break;
			}
		}
	}
	
	if (startFindContact != context->hContact)
		context->SelectContact(startFindContact);

	if (startFindSel != context->selected) {
		LVITEM item = {0};
		item.mask = LVIF_STATE;
		item.iItem = context->selected;
		item.state = 0;
		item.stateMask = LVIS_SELECTED;
		ListView_SetItem(context->listWindow, &item);
		item.iItem = startFindSel;
		item.state = LVIS_SELECTED;
		ListView_SetItem(context->listWindow, &item);
		ListView_EnsureVisible(context->listWindow, startFindSel, FALSE);			
		context->SelectEventGroup(startFindSel);
		SendMessage(context->editWindow,EM_SETOPTIONS,ECOOP_OR,ECO_NOHIDESEL);
	}
	ft.chrgText.cpMin = startFindPos;
	ft.chrgText.cpMax = startFindPos;
	SendMessage(context->editWindow,EM_EXSETSEL,0,(LPARAM)&ft.chrgText);
	SendMessage(context->editWindow,EM_SETOPTIONS,ECOOP_AND,~ECO_NOHIDESEL);
	lastFindSelection = -1;
	if (isStart) {
		TCHAR buf[256];
		GetWindowText(context->findWindow, str, 128);
		mir_sntprintf(buf, 256, TranslateT("\"%s\" not found"), str);
		MessageBox(context->hWnd, buf, TranslateT("Search"), MB_OK | MB_ICONINFORMATION);
	}
	else MessageBox(context->hWnd, TranslateTS(onlyGroup ? LPGENT("You have reached the end of the group.") : LPGENT("You have reached the end of the history.")), TranslateT("Search"), MB_OK | MB_ICONINFORMATION);
}
예제 #9
0
int
VerifyState(const Options &opts, const ReadUserLog::FileState &state )
{
    ReadUserLogState	rstate( state, 60 );
    const ReadUserLogState::FileState	*istate;
    ReadUserLogState::convertState( state, istate );

    const FieldData	*wdata = opts.getField( );
    if ( wdata == NULL ) {
        fprintf( stderr, "Verify: no field!\n" );
        return -1;
    }

    bool	ok;
    switch( wdata->m_field )
    {
    case FIELD_SIGNATURE:
        ok = CompareStr( opts, istate->m_signature );
        break;

    case FIELD_VERSION:
        ok = CompareInt( opts, istate->m_version );
        break;

    case FIELD_UPDATE_TIME:
        ok = CompareTime( opts, istate->m_update_time );
        break;

    case FIELD_BASE_PATH:
        ok = CompareStr( opts, istate->m_base_path );
        break;

    case FIELD_CUR_PATH:
        ok = CompareStr( opts, rstate.CurPath(state) );
        break;

    case FIELD_UNIQ_ID:
        ok = CompareStr( opts, istate->m_uniq_id );
        break;

    case FIELD_SEQUENCE:
        ok = CompareInt( opts, istate->m_sequence );
        break;

    case FIELD_MAX_ROTATION:
        ok = CompareInt( opts, istate->m_max_rotations );
        break;

    case FIELD_ROTATION:
        ok = CompareInt( opts, istate->m_rotation );
        break;

    case FIELD_OFFSET:
        ok = CompareFsize( opts, istate->m_offset.asint );
        break;

    case FIELD_EVENT_NUM:
        ok = CompareFsize( opts, istate->m_event_num.asint );
        break;

    case FIELD_GLOBAL_POSITION:
        ok = CompareFsize( opts, istate->m_log_position.asint );
        break;

    case FIELD_GLOBAL_RECORD_NUM:
        ok = CompareFsize( opts, istate->m_log_record.asint );
        break;

    case FIELD_INODE:
        ok = CompareInode( opts, istate->m_inode );
        break;

    case FIELD_CTIME:
        ok = CompareTime( opts, istate->m_ctime );
        break;

    case FIELD_SIZE:
        ok = CompareFsize( opts, istate->m_size.asint );
        break;

    default:
        return -1;
    }
    return ok ? 0 : 1;
}
예제 #10
0
void ProcessFinix()
{
  long msh0, i,j, fib, npins;
  double val;
  Rod *rod;
  Boundary_conditions *bc;
  Scenario *scenario;
  Results *results;
  Options *options;
  char **err=NULL;

  /* Check that some finix pins are defined */

  if ((fib = (long)RDB[DATA_PTR_FIN0]) < VALID_PTR)
    return;

  /* Close list to allow omp-loops over it later */

  CloseList(fib);
  
  fprintf(out, "Processing Finix pins\n");

  /* reset number of pins */

  npins = 0;

  /* Loop over FINIX definitions */

  while (fib > VALID_PTR)
    {

      /* Link power binning here */

      msh0 = (long)RDB[DATA_PTR_FINBIN0];

      while (msh0 > VALID_PTR)
	{
	  /* Compare name */
	      
	  if (CompareStr(msh0 + MESH_PTR_NAME, fib + FINIX_PTR_POWMSH))
	    break;

	  /* Next possible binning mesh */

	  msh0 = NextItem(msh0);
	}

      /* Check that power binning was found */

      if (msh0 < VALID_PTR)
	Error(fib, "Power binning \"%s\" not defined", GetText(fib + FINIX_PTR_POWMSH));

      /* Put direct pointer to mesh */

      WDB[fib + FINIX_PTR_POWMSH] = (double)msh0;

      /* Construct arrays */

      rod = finix_rod_construct();
      bc = finix_bc_construct();
      scenario = finix_scenario_construct();
      results = finix_results_construct();
      options = finix_options_construct();

      /* Store pointers */

      WDB[fib + FINIX_PTR_ROD] = (double)((long)rod);
      WDB[fib + FINIX_PTR_BC] = (double)((long)bc);
      WDB[fib + FINIX_PTR_SCENARIO] = (double)((long)scenario);
      WDB[fib + FINIX_PTR_RESULTS] = (double)((long)results);
      WDB[fib + FINIX_PTR_OPTIONS] = (double)((long)options);

      /* Create finix_rod.inp for this rod */

      WriteFinixInputFile(fib, FILE_TYPE_ROD);

      /* Create finix_options.inp for this rod */

      WriteFinixInputFile(fib, FILE_TYPE_OPTIONS);

      /* Create finix_scenario.inp for this rod */

      WriteFinixInputFile(fib, FILE_TYPE_SCENARIO);

      /* Initialize data structures */

      err = finix_initialize_data_structures(rod, bc, scenario, results, options);

      /* Handle errors */

      if (err != NULL)
	{
	  finix_printf_err(err);
	  Die(FUNCTION_NAME, "Error in initialization of FINIX data structures");
	}

      finix_free_err(&err);

      /* Put zero linear power to all axial segments */

      for (i = 0 ; i < options->axial_nodes ; i++)
	bc->linear_power[i] = 0.0;

      /* Set radial nodes to equal-distance, rather than equal area */

      for (i = 0 ; i < options->axial_nodes ; i++)
	{

	  /* Pellet */
	  for (j = 0; j < options->pellet_radial_nodes ; j++)
	    {
	      val = rod->pellet_inner_radius 
		+ (double)j/(double)(options->pellet_radial_nodes - 1)*
		(rod->pellet_outer_radius - rod->pellet_inner_radius);

	      results->radial_node_position[i][j] = val;
	      results->radial_node_position_cold[i][j] = val;

	    }

	  /* Clad */

	  for (; j < options->pellet_radial_nodes 
		 + options->clad_radial_nodes ; j++)
	    {
	      val = rod->clad_inner_radius 
		+ (double)(j - options->pellet_radial_nodes)/
		(double)(options->clad_radial_nodes - 1)*
		(rod->clad_outer_radius - rod->clad_inner_radius);

	      results->radial_node_position[i][j] = val;
	      results->radial_node_position_cold[i][j] = val;

	    }
	}

      /* Solve initial steady state (HZP) */

      err = finix_solve_initial_steady_state(rod, bc, results, options);

      /* Handle errors */

      if (err != NULL)
	{
	  finix_printf_err(err);
	  Die(FUNCTION_NAME, "Error in initialization of FINIX data structures");
	}

      finix_free_err(&err);

      npins++;

      /* Process next pin */

      fib = NextItem(fib);

    }

  /* Store total number of pins (needed for interface file) */

  fib = RDB[DATA_PTR_FIN0];

  while(fib > VALID_PTR)
    {
      WDB[fib + FINIX_N_PIN] = (double)npins;
      fib = NextItem(fib);
    }

  /* Set Density Factor usage on */

  WDB[DATA_USE_DENSITY_FACTOR] = (double)YES;

  /* Read initial conditions */

  ReadFinixIFC();
 
  /* Write pins to an interface file */

  WriteFinixIFC();

  /* Create interface data structure */

  CreateFinixIFC();

}
예제 #11
0
void __fastcall TFrmMain::sgEditKeyDown(TObject* Sender, WORD& Key,
                                        TShiftState Shift)
{

    bool SeFlag = true;
    if (Key == VK_F3)
    {
        switch (FrmSearch->rgSI->ItemIndex)
        {
            case 0: //向上找;
                for (int i = sgEdit->ColCount * sgEdit->Row + sgEdit->Col - 1; i > sgEdit->ColCount; i--)
                {
                    if (i % sgEdit->ColCount != 0)
                    {
                        if (0 == CompareStr(sgEdit->Cells[i - sgEdit->ColCount * (i / sgEdit->ColCount)][i / sgEdit->ColCount],
                                            FrmSearch->edSeach->Text))  //找到了
                        {
                            sgEdit->Col = i - sgEdit->ColCount * i / sgEdit->ColCount;
                            sgEdit->Row = i / sgEdit->ColCount;
                            SeFlag = false;
                            break;
                        }
                    }
                }
                if (SeFlag)  ShowMessage("Seach Top,Find Nothing.");
                break;
            case 1:  //向下找;
                for (int i = sgEdit->ColCount * sgEdit->Row + sgEdit->Col + 1; i < sgEdit->ColCount * sgEdit->RowCount; i++)
                {
                    if (i % sgEdit->ColCount != 0)
                    {
                        if (0 == CompareStr(sgEdit->Cells[i - sgEdit->ColCount * (i / sgEdit->ColCount)][i / sgEdit->ColCount],
                                            FrmSearch->edSeach->Text))  //找到了
                        {
                            sgEdit->Col = i - sgEdit->ColCount * (i / sgEdit->ColCount);
                            sgEdit->Row = i / sgEdit->ColCount;
                            SeFlag = false;
                            break;
                        }
                    }
                }
                if (SeFlag)  ShowMessage("Seach End,Find Nothing.");
                break;
            case 2: //当前列向上找;
                for (int i = sgEdit->Row; i > 1; i--)
                {
                    if (0 == CompareStr(sgEdit->Cells[sgEdit->Col][i],
                                        FrmSearch->edSeach->Text))  //找到了
                    {
                        sgEdit->Row = i;
                        SeFlag = false;
                        break;
                    }
                }
                if (SeFlag)  ShowMessage("Seach col Top,Find Nothing.");
                break;
            case 3:  //当前列向下找;
                for (int i = sgEdit->Row; i < sgEdit->RowCount; i++)
                {
                    if (0 == CompareStr(sgEdit->Cells[sgEdit->Col][i],
                                        FrmSearch->edSeach->Text))  //找到了
                    {
                        sgEdit->Row = i;
                        SeFlag = false;
                        break;
                    }
                }
                if (SeFlag)  ShowMessage("Seach col end,Find Nothing.");
                break;
        }
    }
}
예제 #12
0
/** writeValue:
* write a value of a given type to the buffer
* 
* @param string type
*	value type to be read: uint64, int64/sint64, uint32, int32/sint32, uint16, int16/sint16, uint8/byte, int8/sint8/char
*
* @param value to be writen
*/
void CJSBuffer::FxWriteValue(const v8::FunctionCallbackInfo<v8::Value> &args)
{
	v8::HandleScope HandleScope(v8::Isolate::GetCurrent());
	CJSBuffer* jBuffer = GetJSObject<CJSBuffer>(args.Holder());
	CBufferObj* pBuffer = jBuffer->m_pBuffer;
	if (args.Length() < 2)
	{
		args.GetIsolate()->ThrowException(v8::String::NewFromOneByte(v8::Isolate::GetCurrent(), (uint8_t*)"Invalid Argument"));
		return;
	}

	BUFFER_TRY
	wstring Type = CJSEngine::GetWStr(args[0]);
	if(CompareStr(Type, L"uint64"))
		pBuffer->WriteValue<uint64>(args[1]->NumberValue());
	else if(CompareStr(Type, L"int64") || CompareStr(Type, L"sint64"))
		pBuffer->WriteValue<sint64>(args[1]->NumberValue());
	else if(CompareStr(Type, L"uint32"))
		pBuffer->WriteValue<uint32>(args[1]->Uint32Value());
	else if(CompareStr(Type, L"int32") || CompareStr(Type, L"sint32"))
		pBuffer->WriteValue<sint32>(args[1]->Int32Value());
	else if(CompareStr(Type, L"uint16"))
		pBuffer->WriteValue<uint16>(args[1]->Uint32Value());
	else if(CompareStr(Type, L"int16") || CompareStr(Type, L"sint16"))
		pBuffer->WriteValue<sint16>(args[1]->Int32Value());
	else if(CompareStr(Type, L"uint8") || CompareStr(Type, L"byte"))
		pBuffer->WriteValue<uint8>(args[1]->Uint32Value());
	else if(CompareStr(Type, L"int8") || CompareStr(Type, L"sint8") || CompareStr(Type, L"char"))
		pBuffer->WriteValue<sint8>(args[1]->Int32Value());
	else if(CompareStr(Type, L"str"))
		pBuffer->WriteString(CJSEngine::GetWStr(args[1]));
	else
		args.GetIsolate()->ThrowException(v8::String::NewFromOneByte(v8::Isolate::GetCurrent(), (uint8_t*)"Invalid Argument"));
	BUFFER_CATCH
}
예제 #13
0
void ProcessIFCPtAvg(long loc0, long update)
{
  long loc1, mat0, mat, ptr, found, msh, dim, nx, ny, nz, override;
  double x, y, z, rad, xmin, xmax, ymin, ymax, zmin, zmax, dmax;
  double lims[6], matdens;

  /***********************************************************************/

  /***** Link material ***************************************************/

  mat = -1;

  /* Check material pointer (not set in all types) */

  if ((long)RDB[loc0 + IFC_PTR_MAT] < VALID_PTR)
    Die(FUNCTION_NAME, "material pointer not set");
  else if(!update)
    {
      /* Link material and set TMS limits */

      /* Reset found flag */

      found = NO;
	  
      /* Loop over materials and find match */
	  
      mat0 = (long)RDB[DATA_PTR_M0];
      while (mat0 > VALID_PTR)
	{
	  /* Reset pointer */
	      
	  mat = -1;
	      
	  /* Compare name */
	      
	  if (CompareStr(mat0 + MATERIAL_PTR_NAME, loc0 + IFC_PTR_MAT))
	    mat = mat0;
	      
	  /* Check if material was divided for burnup calculation */
	      
	  if ((ptr = (long)RDB[mat0 + MATERIAL_DIV_PTR_PARENT]) 
	      > VALID_PTR)
	    if (CompareStr(ptr + MATERIAL_PTR_NAME, loc0 + IFC_PTR_MAT))
	      mat = mat0;
	      
	  /* Check material */
	      
	  if (mat > VALID_PTR)
	    {
	      /* Link interface and put flag */
	      
	      WDB[mat + MATERIAL_PTR_IFC] = (double)loc0;
	      WDB[mat + MATERIAL_USE_IFC] = (double)YES;		  

	      WDB[loc0 + IFC_PTR_MAT] = (double)mat;
 
	      /* Check if temperature is given */
		  
	      if (RDB[loc0 + IFC_MAX_TEMP] > 0.0)
		{
		  /* Put maximum temperature */
		      
		  if (RDB[loc0 + IFC_MAX_TEMP] > 
		      RDB[mat + MATERIAL_TMS_TMAX])
		    {
		      if(!update)
			{
			  WDB[mat + MATERIAL_TMS_TMAX] = 
			    RDB[loc0 + IFC_MAX_TEMP];

			}
		      else
			Die(FUNCTION_NAME,
			    "Material temperature above TMS majorant for material %s",
			    GetText(mat + MATERIAL_PTR_NAME));
		    }
		  /* Put minimum temperature */
		      
		  if (RDB[loc0 + IFC_MIN_TEMP] < 
		      RDB[mat + MATERIAL_TMS_TMIN])
		    {
		      if(!update)
			{
			  WDB[mat + MATERIAL_TMS_TMIN] = 
			    RDB[loc0 + IFC_MIN_TEMP];

			}
		      else
			Die(FUNCTION_NAME,
			    "Material temperature below TMS minorant for material %s",
			    GetText(mat + MATERIAL_PTR_NAME));

		    }

		  if (!update)
		    {	      

		      /* Set on-the-fly Doppler-broadening mode */
		      /* TMS is set on if the TMS-limits differ */
		      /* TMS is always set on for mixtures */

		      if ((RDB[mat + MATERIAL_TMS_TMIN] <
			   RDB[mat + MATERIAL_TMS_TMAX]) ||
			  ((long)RDB[mat + MATERIAL_PTR_MIX] > VALID_PTR))		      
			{
			  /* Check that material doppler temperature is not already */
			  /* set by tmp-card */

			  if (RDB[mat + MATERIAL_DOPPLER_TEMP] >= 0)
			    Error(mat, "Material temperature set by tmp-card but a temperature distribution is also given by interface %s", GetText(loc0 + IFC_PTR_INPUT_FNAME));

			  /* Set TMS mode on */

			  WDB[mat + MATERIAL_TMS_MODE] = (double)YES;

			  /* Set Doppler-preprocessor off */

			  WDB[mat + MATERIAL_DOPPLER_TEMP] = -1.0;

			}
		      else
			{

			  /* Check that material doppler temperature is not already */
			  /* set by tmp-card */

			  if (RDB[mat + MATERIAL_DOPPLER_TEMP] >= 0)
			    Error(mat, "Material temperature set by tmp-card but a temperature distribution is also given by interface %s", GetText(loc0 + IFC_PTR_INPUT_FNAME));

			  WDB[mat + MATERIAL_DOPPLER_TEMP] = -RDB[loc0 + IFC_MIN_TEMP];
			}
		    }
		}


	      /* Set found flag */
		  
	      found = YES;

	    }
	      
	  /* Next material */
	      
	  mat0 = NextItem(mat0);
	}
      
      /* Check that material was found */
      
      if (found == NO)
	Error(loc0, "Material %s in distribution file not defined", 
	      GetText(loc0 + IFC_PTR_MAT));

    }
  else
    {
      /* Check TMS limits */

      mat = (long)RDB[loc0 + IFC_PTR_MAT];

      /* Check if temperature is given */
		  
      if (RDB[loc0 + IFC_MAX_TEMP] > 0.0)
	{
	  /* Check maximum temperature */
		      
	  if (RDB[loc0 + IFC_MAX_TEMP] > 
	      RDB[mat + MATERIAL_TMS_TMAX])
		Die(FUNCTION_NAME,
		    "Material temperature above TMS majorant for material %s",
		    GetText(mat + MATERIAL_PTR_NAME));

	  /* Checkminimum temperature */
		      
	  if (RDB[loc0 + IFC_MIN_TEMP] < 
	      RDB[mat + MATERIAL_TMS_TMIN])
	    Die(FUNCTION_NAME,
		"Material temperature below TMS minorant for material %s",
		GetText(mat + MATERIAL_PTR_NAME));	   

	}

    }

  /* Set material density to maximum density */

  mat = (long)RDB[loc0 + IFC_PTR_MAT];

  /* Get interface maximum density */

  dmax = RDB[loc0 + IFC_MAX_DENSITY];

  /* Get material density */

  override = 0;