Example #1
0
void cMapManager::Draw() {
    int shiftX = 0;
    int shiftY = 0;
    for(int i = start.x; i <= end.x; i++){
        for(int j = start.y; j <= end.y; j++){
            if(chunks[i][j] != NULL){
                shiftX = camera.x - (i * GetCommon()->mapChunkWidthPx);
                shiftY = camera.y - (j * GetCommon()->mapChunkHeightPx);
                chunks[i][j]->DrawBot(-shiftX, -shiftY);
                chunks[i][j]->DrawTop(-shiftX, -shiftY, drawTriggerGrid);
            } else {
                chunks[i][j] = new cMapChunk();
                char tmpName[50];
                sprintf(tmpName, "%dx%d", i, j);
                switch(chunks[i][j]->Load(tmpName)){
                    case CHUNK_NOT_FOUND:
                        chunks[i][j]->InitEmpty(1);
                        break;
                    case CHUNK_INVALID_FILE:
                        break;
                }
                loadedChunks.push_back(sPoint(i, j));
            }
        }
    }
}
void CCWidget::Draw(CCDrawContext* pDC){
	if(m_bVisible==false) return;

	unsigned char nLastOpacity;
	nLastOpacity = pDC->GetOpacity();

	sRect sr = GetScreenRect();
	pDC->SetOrigin(sPoint(sr.x, sr.y));

	if(m_pFont!=NULL) pDC->SetFont(m_pFont);
	else pDC->SetFont(CCFontManager::Get(NULL));

	pDC->SetOpacity((unsigned char)(nLastOpacity * (float)(m_iOpacity / 255.0f)));
	if(!IsEnable())
		pDC->SetOpacity((unsigned char)(pDC->GetOpacity()*0.70));	

	bool bIntersect = true;
	sRect rectScreen(0, 0, CCGetWorkspaceWidth()-1, CCGetWorkspaceHeight()-1);
	sRect PrevClipRect;
	if(GetParent()!=NULL) {
		sRect parentClipRect = CCClientToScreen(GetParent(), GetParent()->GetClientRect());
		bIntersect = rectScreen.Intersect(&PrevClipRect,parentClipRect);
	}else
		PrevClipRect = rectScreen;

	sRect CurrClipRect = GetScreenRect();
	sRect IntersectClipRect;

	if(m_bClipByParent==true){
		if(PrevClipRect.Intersect(&IntersectClipRect, CurrClipRect)==true){
			sRect test = IntersectClipRect;
			if(IntersectClipRect.w>0 && IntersectClipRect.h>0) {
				pDC->SetClipRect(IntersectClipRect);
				OnDraw(pDC);
			}
		}
	}
	else{
		pDC->SetClipRect(CurrClipRect);
		OnDraw(pDC);
	}

	for(int i=0; i<m_Children.GetCount(); i++){
		CCWidget* pCurWnd = m_Children.Get(i);
		if(pCurWnd==GetLatestExclusive()) continue;
		if(pCurWnd != NULL ) pCurWnd->Draw(pDC);
	}
	if(GetLatestExclusive()!=NULL) 
		GetLatestExclusive()->Draw(pDC);

	pDC->SetOpacity(nLastOpacity);
}
Example #3
0
File: srunway.C Project: zear/sabre
sRunway::sRunway(const srunway_info &rwi)
{
sPoint position;
sAttitude attitude;

	position = sPoint(rwi.x,rwi.y,rwi.z);
	attitude.yaw = rwi.heading;
	finalApproachHeading = attitude.yaw;
	takeoffHeading = sIncrementAngle(attitude.yaw,Pi);
	attitude.roll = attitude.pitch = 0.0;
	length = rwi.length;
	width = rwi.width;
	sSlewer::SetPositionAndAttitude(position,attitude);
}
std::vector<sPoint> GeneratePoissonPoints( float MinDist, int NewPointsCount, size_t NumPoints )
{
	std::vector<sPoint> SamplePoints;
	std::vector<sPoint> ProcessList;

	// create the grid
	float CellSize = MinDist / sqrt( 2.0f );

	int GridW = ( int )ceil( 1.0f / CellSize );
	int GridH = ( int )ceil( 1.0f / CellSize );

	sGrid Grid( GridW, GridH, CellSize );

	sPoint FirstPoint = sPoint( RandomFloat(), RandomFloat() );

	// update containers
	ProcessList.push_back( FirstPoint );
	SamplePoints.push_back( FirstPoint );
	Grid.Insert( FirstPoint );

	// generate new points for each point in the queue
	while ( !ProcessList.empty() && SamplePoints.size() < NumPoints )
	{
		// a progress indicator, kind of
		if ( SamplePoints.size() % 100 == 0 ) std::cout << ".";

		sPoint Point = PopRandom( ProcessList );

		for ( int i = 0; i < NewPointsCount; i++ )
		{
			sPoint NewPoint = GenerateRandomPointAround( Point, MinDist );

			bool Fits = Circle ? NewPoint.IsInCircle() : NewPoint.IsInRectangle();

			if ( Fits && !Grid.IsInNeighbourhood( NewPoint, MinDist, CellSize ) )
			{
				ProcessList.push_back( NewPoint );
				SamplePoints.push_back( NewPoint );
				Grid.Insert( NewPoint );
				continue;
			}
		}
	}

	std::cout << std::endl << std::endl;

	return SamplePoints;
}
CCBFrameLook::CCBFrameLook(void)	: CCScalableLook()
{
    m_szDefaultTitle[0]=0;
    m_TitlePosition = sPoint(14, 10);
    m_FontColor = sColor(255,255,255,255);
    m_bStretch = true;

    for(int i=0; i<FRAME_BITMAP_COUNT; i++) {
        m_pFrameBitmaps[i] = NULL;
    }
    for (int i=0; i<FRAME_BUTTON_BITMAP_COUNT; i++)
    {
        m_pCloseButtonBitmaps[i] = NULL;
        m_pMinimizeButtonBitmaps[i] = NULL;
    }
    m_iCustomLook = 0;
}
sPoint GenerateRandomPointAround( const sPoint& P, float MinDist )
{
	// start with non-uniform distribution
	float R1 = RandomFloat();
	float R2 = RandomFloat();

	// radius should be between MinDist and 2 * MinDist
	float Radius = MinDist * ( R1 + 1.0f );

	// random angle
	float Angle = 2 * 3.141592653589f * R2;

	// the new point is generated around the point (x, y)
	float X = P.x + Radius * cos( Angle );
	float Y = P.y + Radius * sin( Angle );

	return sPoint( X, Y );
}
Example #7
0
void FolderPane::onClick(FolderCtrl &aFolderCtrl)
{
    if (XPR_IS_TRUE(gOpt->mMain.mSingleFolderPaneMode))
    {
        CPoint sPoint(0,0);
        GetCursorPos(&sPoint);
        aFolderCtrl.ScreenToClient(&sPoint);

        xpr_uint_t sFlags = 0;
        HTREEITEM sTreeItem = aFolderCtrl.HitTest(sPoint, &sFlags);

        HTREEITEM sSelTreeItem = aFolderCtrl.GetSelectedItem();
        if (sTreeItem == sSelTreeItem && XPR_ANY_BITS(sFlags, TVHT_ONITEM))
        {
            mFolderCtrl->explore(sTreeItem);
        }
    }
}
CCBButtonLook::CCBButtonLook(void) : CCScalableLook()
{
	for(int i=0; i<9; i++){
		m_pUpBitmaps[i] = NULL;
		m_pDownBitmaps[i] = NULL;
		m_pOverBitmaps[i] = NULL;
	}
	for(int i=0; i<4; i++){
		m_pFocusBitmaps[i] = NULL;
	}

	m_pFont = NULL;
	m_FontColor = sColor(DEFCOLOR_CCBUTTON_TEXT);
	m_FontDownColor = sColor(DEFCOLOR_LIGHT);
	m_FontDisableColor = sColor(DEFCOLOR_DISABLE);
	m_FontHighlightColor = sColor(DEFCOLOR_PEN_HIGHLIGHT);
	m_bStretch = true;
	m_bCustomLook = false;

	m_FontDownOffset = sPoint(0,0);
}
Example #9
0
//*****************************************************************************
//*
//*		CreateEx
//*
//*****************************************************************************
//	Creates a new Tree-List-Control over a dialog item
//	dwExStyle	: Is the exdended style of the window (WS_EX_????)
//	dwStyle     : Style of the Window
//                	TVS_CHECKBOXES
//                	TVS_DISABLEDRAGDROP
//                	TVS_EDITLABELS
//                	TVS_FULLROWSELECT
//                	TVS_HASBUTTONS
//                	TVS_HASLINES
//                	TVS_INFOTIP
//                	TVS_LINESATROOT
//                	TVS_NONEVENHEIGHT
//                	TVS_NOSCROLL
//                	TVS_NOTOOLTIPS
//                	TVS_RTLREADING
//                	TVS_SHOWSELALWAYS
//                	TVS_SINGLEEXPAND
//                	TVS_TRACKSELECT
//	uItem       : Is the ID of the dialog item
//	pDlg		: Pointer to parent dialog
//	nId			: Is the ID of the window
//	Returns TRUE if the window was created or FALSE if an error occurs
BOOL CTreeListCtrl::CreateEx(DWORD dwExStyle, DWORD dwStyle, UINT uItem, CDialog *pDlg, UINT nId) {
	CPoint	sPoint(0, 0);
	CRect	sRect;
	CWnd   *pWnd;


	pWnd = pDlg->GetDlgItem(uItem);
	ASSERT(pWnd != 0);


	pWnd->GetWindowRect(&sRect);
	pDlg->ClientToScreen(&sPoint);

	sRect.left	  -= sPoint.x;
	sRect.right   -= sPoint.x;
	sRect.top	  -= sPoint.y;
	sRect.bottom  -= sPoint.y;


	return CTreeListCtrl::CreateEx(dwExStyle, dwStyle | WS_CHILD | WS_VISIBLE, sRect, pDlg, nId);
}
void object::test<8>
()
{
    geos::geom::PrecisionModel pm(1e+13);
    geos::geom::GeometryFactory::Ptr factory = geos::geom::GeometryFactory::create(&pm);
    geos::io::WKBReader reader(*factory);

    // POINT located between 3rd and 4th vertex of LINESTRING
    // POINT(-23.1094689600055080 50.5195368635957180)
    std::string point("01010000009a266328061c37c0e21a172f80424940");
    // LINESTRING(-23.122057005539 50.5201976774794,-23.1153476966995 50.5133404815199,-23.1094689600055150 50.5223376452201340,-23.1094689600055010 50.5169177629559480,-23.0961967920942 50.5330464848094,-23.0887991006034 50.5258515213185,-23.0852302622362 50.5264582238409)
    std::string
    line("0102000000070000009909bf203f1f37c05c1d66d6954249404afe386d871d37c0a7eb1124b54149409c266328061c37c056d8bff5db42494098266328061c37c0034f7b5c2a42494060065c5aa01837c08ac001de3a4449408401b189bb1637c0b04e471a4f43494014ef84a6d11537c0b20dabfb62434940");
    std::stringstream sPoint(point);
    geom2_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sPoint));
    std::stringstream sLine(line);
    geom1_ = reinterpret_cast<GEOSGeometry*>(reader.readHEX(sLine));

    prepGeom1_ = GEOSPrepare(geom1_);
    ensure(nullptr != prepGeom1_);
    int ret = GEOSPreparedIntersects(prepGeom1_, geom2_);
    ensure_equals(ret, 1);
}
Example #11
0
	inline sPoint operator +(const sPositionOffset &b) const
	{ return sPoint( x + b.x, y + b.y ); }
Example #12
0
QgsPointSequence QgsCircularString::compassPointsOnSegment( double p1Angle, double p2Angle, double p3Angle, double centerX, double centerY, double radius )
{
  QgsPointSequence pointList;

  QgsPointV2 nPoint( centerX, centerY + radius );
  QgsPointV2 ePoint( centerX + radius, centerY );
  QgsPointV2 sPoint( centerX, centerY - radius );
  QgsPointV2 wPoint( centerX - radius, centerY );

  if ( p3Angle >= p1Angle )
  {
    if ( p2Angle > p1Angle && p2Angle < p3Angle )
    {
      if ( p1Angle <= 90 && p3Angle >= 90 )
      {
        pointList.append( nPoint );
      }
      if ( p1Angle <= 180 && p3Angle >= 180 )
      {
        pointList.append( wPoint );
      }
      if ( p1Angle <= 270 && p3Angle >= 270 )
      {
        pointList.append( sPoint );
      }
    }
    else
    {
      pointList.append( ePoint );
      if ( p1Angle >= 90 || p3Angle <= 90 )
      {
        pointList.append( nPoint );
      }
      if ( p1Angle >= 180 || p3Angle <= 180 )
      {
        pointList.append( wPoint );
      }
      if ( p1Angle >= 270 || p3Angle <= 270 )
      {
        pointList.append( sPoint );
      }
    }
  }
  else
  {
    if ( p2Angle < p1Angle && p2Angle > p3Angle )
    {
      if ( p1Angle >= 270 && p3Angle <= 270 )
      {
        pointList.append( sPoint );
      }
      if ( p1Angle >= 180 && p3Angle <= 180 )
      {
        pointList.append( wPoint );
      }
      if ( p1Angle >= 90 && p3Angle <= 90 )
      {
        pointList.append( nPoint );
      }
    }
    else
    {
      pointList.append( ePoint );
      if ( p1Angle <= 270 || p3Angle >= 270 )
      {
        pointList.append( sPoint );
      }
      if ( p1Angle <= 180 || p3Angle >= 180 )
      {
        pointList.append( wPoint );
      }
      if ( p1Angle <= 90 || p3Angle >= 90 )
      {
        pointList.append( nPoint );
      }
    }
  }
  return pointList;
}
Example #13
0
sPoint CCWidget::GetPosition(){
	return sPoint(m_Rect.x, m_Rect.y);
}
Example #14
0
sPoint CCScreenToClient(CCWidget* pWidget, sPoint& p){
	sRect r = pWidget->GetScreenRect();
	return sPoint(p.x-r.x, p.y-r.y);
}
Example #15
0
sPoint CCClientToScreen(CCWidget* pWidget, sPoint& p){
	sRect r = pWidget->GetScreenRect();
	return sPoint(p.x+r.x, p.y+r.y);
}