Esempio n. 1
0
bool CSinuosity::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode){	
	
	int iX, iY;

	if(	Mode != MODULE_INTERACTIVE_LDOWN || !Get_Grid_Pos(iX, iY) )
	{
		return( false );
	}

//	if( !m_pDEM->is_InGrid_byPos(ptWorld.Get_X(), ptWorld.Get_Y()) ){
//		return false;
//	}//if

//	iX	= (int) ((ptWorld.Get_X() - m_pDEM->Get_XMin()) / m_pDEM->Get_Cellsize());
//	iY	= (int) ((ptWorld.Get_Y() - m_pDEM->Get_YMin()) / m_pDEM->Get_Cellsize());

	m_iX = iX;
	m_iY = iY;

	m_pSinuosity->Assign((double)0);
	
	writeDistOut(iX, iY, iX, iY);
	ZeroToNoData();
	calculateSinuosity();

	DataObject_Update(m_pSinuosity);
    
	return true;

}//method
Esempio n. 2
0
bool CIsochronesVar::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode)
{
	int iX, iY;

	if(	Mode != MODULE_INTERACTIVE_LDOWN || !Get_Grid_Pos(iX, iY) )
	{
		return( false );
	}
	
	m_pTime->Assign((double)0);

	writeTimeOut(iX, iY, iX, iY);

	for(int y=0; y<Get_NY() && Set_Progress(y); y++){
		for(int x=0; x<Get_NX(); x++){
			m_pTime->Set_Value(x,y,m_pTime->asDouble(x,y)/3600.);
        }// for
    }// for

	ZeroToNoData();

	DataObject_Update(m_pTime, true);

	return (true);

}//method
Esempio n. 3
0
bool CFlowDepth::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode){	

	int iX, iY;	
	int iNextX, iNextY;
	int x,y;
	int iOutletX, iOutletY;
	double fArea;
	double fDepth, fPreviousDepth = 0;

	if(	Mode != MODULE_INTERACTIVE_LDOWN || !Get_Grid_Pos(iOutletX, iOutletY) )
	{
		return( false );
	}

	m_pFlowDepth->Assign((double)0);

	fArea = m_pCatchArea->asFloat(iOutletX, iOutletY);
	
	if (fArea < m_dThreshold * 2.){ //check outlet point
		iNextX = iOutletX;
		iNextY = iOutletY;
		do{
			iOutletX = iNextX;
			iOutletY = iNextY;
			getNextCell(m_pDEM, iOutletX, iOutletY, iNextX, iNextY);
		}while (m_pCatchArea->asFloat(iOutletX, iOutletY) < m_dThreshold * 2. &&
				(iOutletX != iNextX || iOutletY != iNextY));
			
		if (m_pCatchArea->asFloat(iOutletX, iOutletY) < m_dThreshold * 2.){
			Message_Add(_TL("** Error : Wrong outlet point selected **"));
			return false;
		}//if
		Message_Add(_TL("** Warning : Outlet point was modified **"));
    }//if

	CalculateBasinGrid(m_pBasinGrid, m_pDEM, iOutletX, iOutletY);

	m_fMaxFlowAcc = m_pCatchArea->asFloat(iOutletX, iOutletY);		
    
    for(y=0; y<Get_NY() && Set_Progress(y); y++){		
		for(x=0; x<Get_NX(); x++){
			if (m_pCatchArea->asFloat(x,y) > m_dThreshold){
				if (isHeader(x,y)){					
					iNextX = x;
					iNextY = y;
					do {
						iX = iNextX;
						iY = iNextY;
						if (m_pFlowDepth->asFloat(iX,iY) == 0. && m_pBasinGrid->asInt(iX, iY) != 0){
							getNextCell(m_pDEM, iX, iY, iNextX, iNextY);
							fDepth = CalculateFlowDepth(iX,iY);
							if (fDepth == NO_DEPTH){
								m_pFlowDepth->Set_Value(iX,iY, fPreviousDepth);
							}//if
							else{
								fPreviousDepth = fDepth;
							}//else
						}//if
					}while ((iX != iOutletX || iY != iOutletY)
							&& (iX != iNextX || iY != iNextY));
				}//if
			}//if
		}//for
	}// for

	DataObject_Update(m_pFlowDepth);

	return true;

}//method
bool CMine_Sweeper::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode)
{
	int ok = true;
	
	int time;
	int redraw = false;
	int xpos; 	int ypos;

	if( !Get_Grid_Pos(xpos, ypos) )
		return( false );

	xpos/=SPRITE_SIZE; 	ypos/=SPRITE_SIZE;

	ypos=Mine_NY-1-ypos;
	
	switch( Mode )
	{
	default:
		return( false );

	case MODULE_INTERACTIVE_LDOWN:
		if(First_Click)
		{
			ResetBoard(xpos, ypos);
			First_Click=false;
		}

		ok = Play(xpos, ypos, false);
		redraw = true;
		break;

	case MODULE_INTERACTIVE_RDOWN:
		Mark(xpos, ypos);
		redraw = true;
		break;
	}

	if (redraw)
	{
		if(ok)
		{
			Show_GameBoard(false);
			
			time= Time->Time();
			
			Message_Add(CSG_String::Format(SG_T(":-) Time:%ds Mines:%d\n"),time,N_Mines-MarkedMines));
			
			if (OpenFields == Mine_NX*Mine_NY-N_Mines  )
			{
				Message_Add(CSG_String::Format(_TL(":-) :-) you are a winner :-) :-) Time:%ds\n"),time));
				Message_Dlg(CSG_String::Format(_TL(":-) :-) you are a winner :-) :-) Time:%ds\n"),time));
			
				Show_GameBoard(true);

				First_Click=true;
			}
		}
		else 
		{
			Show_GameBoard(true);

			Message_Dlg(CSG_String::Format(_TL(":-( :-( you are a loser :-( :-(")));
			Message_Add(CSG_String::Format(_TL(":-( :-( you are a loser :-( :-(")));

			First_Click=true;
		}
	}
	return true;
}