Exemple #1
0
CTable::CTable(const std::_tstring & table, bool line)
{
	m_rows.push_back(CLine(GUID_START));
	if (line)
		parse_line(table);
	else
		parse_rows(table);
	m_rows.push_back(CLine(GUID_END));
}
Exemple #2
0
CTable::CTable(const CTable & table, unsigned int from, unsigned int to)
{
	m_rows.push_back(CLine(GUID_START));
	if (from == 0)
		++from;
	if (to == table.size())
		--to;
	for (unsigned int i = from; i < to; ++i)
		m_rows.push_back(table[i]);
	m_rows.push_back(CLine(GUID_END));
}
Exemple #3
0
void CTable::parse_rows(const std::_tstring & table)
{
	std::_tstring line;
	for(std::size_t i = 0; i < table.size(); ++i)
	{
		line += table[i];
		if (table[i] == _T('\n'))
		{
			m_rows.push_back(CLine(line));
			line = _T("");
		}
	}
	if (line.size())
		m_rows.push_back(CLine(line));
}
Exemple #4
0
/*
函数名:
功能:
参数:

*/
void ShowTree(BinTree bt)
{
	
	int i,j,old_rx,old_ry,sum=0;
	
	
	MAX_X=getmaxx(),MAX_Y=getmaxy();
	BTreeToArr(bt,BTXY);
	GetBTArrXY(BTXY);
	/*两个循环是建模时是二维数组,但实践中二维数组错误,于是用了累加 等算法来查找*/
	for(i=0;i<5;i++)
	{
		
		for(j=0;j<pow(2,i);j++)
		{	
			 if(i==0)
			{
				FilledCircle(BTXY[sum].x,BTXY[sum].y,BTXY[sum].bt->data);
			}else if(BTXY[sum].bt->data)
			{	
				old_ry=30+(i-1)*MAX_Y/7;
				old_rx=pow(-1,j)*MAX_X/pow(2,i+1)+BTXY[sum].x;
				CLine(old_rx,old_ry+10,BTXY[sum].x,BTXY[sum].y,WHITE);
				FilledCircle(BTXY[sum].x,BTXY[sum].y,BTXY[sum].bt->data);
			}
			sum++;		
		}
			
		
		
	}
}
Exemple #5
0
/*-<==>-----------------------------------------------------------------
/ return a line which starts on camera position and goes through the pixel
/ (x,y) from the screen
/---------------------------------------------------------------------*/
CLine CCamera::getLineAt (SCALAR x, SCALAR y) const 
{
	SCALAR beta = (yres/2)- y - 0.5;
	SCALAR alpha = (xres/2) - x - 0.5;
	VECTOR dir = (viewd * front) + (beta * up) + (left * alpha);
	return CLine(loc, dir, 0);
}
CFracControlModel::CFracControlModel( const CRect& rect, std::weak_ptr<IBaseExprModel> parent ) :
	IBaseExprModel(rect, parent)
{
	this->rect.Set( 0, 0, 0, rect.GetHeight() ); // нас интересует только высота, остальное исправится сразу же после инвалидации дерева
	this->params.polygon.push_back( CLine( rect.Left( ), rect.GetHeight( ) / 2, rect.Right( ), rect.GetHeight( ) / 2 ) );

	depth = parent.lock()->GetDepth() + 1;
}
Exemple #7
0
void CTable::parse_line(const std::_tstring & table)
{
	for(std::size_t i = 0; i < table.size(); ++i)
	{
		std::_tstring tchar;
		tchar.resize(1, table[i]);
		m_rows.push_back(CLine(tchar));
	}
}
/*-<==>-----------------------------------------------------------------
/ return a line which starts on camera position and goes through the pixel
/ (x,y) from the screen
/---------------------------------------------------------------------*/
CLine CCamera::getLineAt (SCALAR x, SCALAR y) const {
  // Pendiente de implementar correctamente
  // ...

  VECTOR po = loc;
  SCALAR tmp_xres = xres / 2 - x - 0.5;
  SCALAR tmp_yres = yres / 2 - y - 0.5;
  VECTOR temp_xy = viewd*front + up * tmp_yres + left * tmp_xres ;
  return CLine(loc, temp_xy, 5);
}
void CSystemControlModel::updatePolygons()
{
  params.polygon.clear();

  int middle = rect.Top() + rect.GetHeight() / 2;
  params.polygon.push_back(CLine(rect.Left() + 7, rect.Top() + 5, rect.Left() + 7, middle - 3 )); // середина 1
  params.polygon.push_back(CLine(rect.Left() + 7, middle + 3, rect.Left() + 7, rect.Bottom() - 5)); // середина 2
  params.polygon.push_back(CLine(rect.Left() + 7, middle + 3, rect.Left() + 5, middle - 1)); // "носик" нижний
  params.polygon.push_back(CLine(rect.Left() + 7, middle - 3, rect.Left() + 5, middle + 1)); // "носик" верхний
  params.polygon.push_back(CLine(rect.Left() + 7, rect.Top() + 5, rect.Left() + 10, rect.Top() + 2)); // верх
  params.polygon.push_back(CLine(rect.Left() + 7, rect.Bottom() - 5, rect.Left() + 10, rect.Bottom() - 2)); // низ
}
void CParenthesesControlModel::updatePolygons()
{
	params.polygon.clear();
	// левая скобка
	params.polygon.push_back( CLine( rect.Left(), rect.Top() + 3, rect.Left(), rect.Bottom() - 3 ) ); // середина
	params.polygon.push_back( CLine( rect.Left(), rect.Top() + 3, rect.Left() + 3, rect.Top() ) ); // верх
	params.polygon.push_back( CLine( rect.Left(), rect.Bottom() - 3, rect.Left() + 3, rect.Bottom() ) ); // низ
	// правая скобка
	params.polygon.push_back( CLine( rect.Right(), rect.Top() + 3, rect.Right(), rect.Bottom() - 3 ) ); // середина
	params.polygon.push_back( CLine( rect.Right(), rect.Top() + 3, rect.Right() - 3, rect.Top() ) ); // верх
	params.polygon.push_back( CLine( rect.Right(), rect.Bottom() - 3, rect.Right() - 3, rect.Bottom() ) ); // низ
}
Exemple #11
0
void DrawBT(BinTree bt)
{
	int i=0;
	
	
	while(bt!=BTXY[i].bt&&i<31)i++;
	if(TRAVERSE_SIGN==0)
	{
		STATIC_X=BTXY[i].x;
		STATIC_Y=BTXY[i].y;
		TRAVERSE_SIGN++;
	}
	
	SignFilledCircle(BTXY[i].x,BTXY[i].y,BTXY[i].bt->data);
	CLine(STATIC_X,STATIC_Y,BTXY[i].x,BTXY[i].y,RED);
	delay(200);
	STATIC_X=BTXY[i].x;
	STATIC_Y=BTXY[i].y;
}
Exemple #12
0
void CText::setText(const SFont &font, const wstringEx &t, u32 startline)
{
	SWord w;
	totalHeight = 0;

	m_lines.clear();
	if(font.font != NULL)
		m_font = font;
	if(m_font.font == NULL)
		return;

	firstLine = startline;
	// Don't care about performance
	vector<wstringEx> lines = stringToVector(t, L'\n');
	m_lines.reserve(lines.size());
	// 
	for (u32 k = 0; k < lines.size(); ++k)
	{
		wstringEx &l = lines[k];
		m_lines.push_back(CLine());
		m_lines.back().reserve(32);
		wstringEx::size_type i = l.find_first_not_of(g_whitespaces);
		wstringEx::size_type j;
		while (i != wstringEx::npos)
		{
			j = l.find_first_of(g_whitespaces, i);
			if (j != wstringEx::npos && j > i)
			{
				w.text.assign(l, i, j - i);
				m_lines.back().push_back(w);
				i = l.find_first_not_of(g_whitespaces, j);
			}
			else if (j == wstringEx::npos)
			{
				w.text.assign(l, i, l.size() - i);
				m_lines.back().push_back(w);
				i = wstringEx::npos;
			}
		}
	}
}
Exemple #13
0
	bool	OnSpan(const Span& sp, const Point& p,  bool nearPoints, Point& pNear, Point& pOnSpan) {
		// function returns true if pNear == pOnSpan
		//			returns pNear & pOnSpan if nearPoints true
		//			pNear (nearest on unbound span)
		//			pOnSpan (nearest on finite span)
		if(sp.dir) {
			// arc
			if(fabs(p.Dist(sp.pc) - sp.radius) > geoff_geometry::TOLERANCE) {
				if(!nearPoints) return false;
			}

			pNear = On(Circle(sp.pc, sp.radius), p);

			if(sp.OnSpan(pNear)) {
				if(nearPoints) pOnSpan = pNear;
				return true; // near point is on arc - already calculated
			}

			// point not on arc return the nearest end-point
			if(nearPoints) pOnSpan = (p.Dist(sp.p0) >= p.Dist(sp.p1)) ?sp.p1 : sp.p0;
			return false;
		}
		else {
			// straight
			if(fabs(CLine(sp.p0, sp.vs).Dist(p)) > geoff_geometry::TOLERANCE) {
				if(!nearPoints) return false;
			}
			Vector2d v(sp.p0, p);
			double t = v * sp.vs;
			if(nearPoints) pNear = sp.vs * t + sp.p0;
			bool onSpan = (t > - geoff_geometry::TOLERANCE && t < sp.length + geoff_geometry::TOLERANCE);
			if(! onSpan) {
				if(nearPoints) pOnSpan = (p.Dist(sp.p0) >= p.Dist(sp.p1))?sp.p1 : sp.p0;
			}
			else {
				if(nearPoints) pOnSpan = pNear;
			}
			return onSpan;
		}
	}
Exemple #14
0
void CArena::Draw(CWindow *theWindow)
{
    // Center the view on the player
    CView theOriginalView = CView(theWindow->getView());
    CView theView = theOriginalView;
    
    CVector2f viewSize = theView.getSize();
    CVector2f viewCenter;
    viewCenter.x = mPlayer->GetPosition().x;
    viewCenter.y = mPlayer->GetPosition().y;
    
    float minmaxPixel = (mArenaSize / 2.0f) + 150.0f;
    float rightmostPixel = viewCenter.x + (viewSize.x / 2.0f);
    float leftmostPixel = viewCenter.x - (viewSize.x / 2.0f);
    if (rightmostPixel > minmaxPixel)
    {
        float offset = rightmostPixel - minmaxPixel;
        viewCenter.x -= offset;
    }
    if (leftmostPixel < -minmaxPixel)
    {
        float offset = -minmaxPixel - leftmostPixel;
        viewCenter.x += offset;
    }
    float topmostPixel = viewCenter.y - (viewSize.y / 2.0f);
    float bottommostPixel = viewCenter.y + (viewSize.y / 2.0f);
    if (bottommostPixel > minmaxPixel)
    {
        float offset = bottommostPixel - minmaxPixel;
        viewCenter.y -= offset;
    }
    if (topmostPixel < -minmaxPixel)
    {
        float offset = -minmaxPixel - topmostPixel;
        viewCenter.y += offset;
    }
    
    theView.setCenter(viewCenter);
    theWindow->setView(theView);
    
    // Draw static objects
    for (CGameObject *theObject : mStaticObjects)
    {
        theObject->Draw(theWindow);
    }
    
    // Draw floor pattern
    int interval = 50;
    for (int xy = interval - 500; xy < 500; xy += interval)
    {
        CLine theHorizontalLine = CLine(CVector2f(-500, xy), CVector2f(500, xy));
        CLine theVerticalLine = CLine(CVector2f(xy, -500), CVector2f(xy, 500));
        theWindow->DrawLine(theHorizontalLine, CColour::Black);
        theWindow->DrawLine(theVerticalLine, CColour::Black);
    }
    
    // Draw dynamic objects
    for (CGameObject *theObject : mObjects)
    {
        theObject->Draw(theWindow);
    }
    
    theWindow->setView(theOriginalView);
}
Exemple #15
0
void CTable::Insert(int pos, int length, CLine::TYPE type)
{
	m_rows.insert(m_rows.begin() + pos, CLine());
	Mark(pos, length, type);
}
Exemple #16
0
CLineRenderer::CLineRenderer(void)
{
	cLine = CLine(1.0f, 1.0f, 1.0f, 1.0f, 2.0f);
	cHalo = CLine(0.0f, 0.0f, 0.0f, 1.0f, 4.0f);
}
//*********************************************************************************************************
void CDisplayerVisualActivitySequence::update()
{
	//H_AUTO(R2_CDisplayerVisualActivitySequence_update)
	if (!_Active) return;
	if (!_Touched) return;
	_Touched = false;
	CObjectTable *activities = getProps().toTable("Components");
	if (!activities)
	{
		clear();
		return;
	}
	// get first world object parent to get start position
	nlassert(getDisplayedInstance());
	CInstance *prevZone = NULL;
	CDisplayerVisual *prevDV = getParentDV();
	if (!prevDV)
	{
		clear();
		return;
	}
	//
	clear(false);
	//
	for(uint k = 0; k < activities->getSize(); ++k)
	{
		// search next zone of activity
		CObjectTable *activity = activities->getValue(k)->toTable();
		if (!activity) continue;
		std::string activityStr = getString(activity, "Activity");
		if (activityStr == "Stand Still" || activityStr == "Inactive") continue;
		//
		CInstance *nextZone = NULL;
		std::string zoneId = getString(activity, "ActivityZoneId");
		//
		if (!zoneId.empty())
		{
			_ObserverHandles.push_back(getEditor().addInstanceObserver(zoneId, this));
			nextZone = getEditor().getInstanceFromId(zoneId);
		}

		if (!nextZone) break;
		CDisplayerVisual *nextDV = nextZone->getDisplayerVisual();
		if (!nextDV) break;

		_TraversedPrimInfos.push_back(CTraversedPrimInfo());
		_TraversedPrimInfos.back().PrimDisplay = nextDV;
		_TraversedPrimInfos.back().Visible = nextDV->getActualDisplayMode() != DisplayModeHidden;


		CWorldPosCache wpc;
		wpc.DV = nextDV;
		wpc.WorldPos2f = nextDV->getWorldPos2f();
		_WPCache.push_back(wpc);

		if (nextDV->getActualDisplayMode() != DisplayModeHidden
			&& prevDV->getActualDisplayMode() != DisplayModeHidden)
		{
			// special case for regions
			if (nextZone->isKindOf("Region"))
			{
				// first case : previous zone is not a region
				if (!prevZone || !prevZone->isKindOf("Region"))
				{
					// search shortest distance bewteen last pos and the region
					CVector entryPos;
					if (nextDV->evalEnterPoint(prevDV->evalExitPoint(), entryPos))
					{
						addFootSteps(CLine(prevDV->evalExitPoint(), entryPos));
					}
					else
					{
						addWanderSteps(prevDV->evalExitPoint());
					}
				}
				else
				{
					// region-region footsteps
					// just use the couple of vertices for which the distance is the smallest
					static std::vector<CVector2f> r0;
					static std::vector<CVector2f> r1;
					prevDV->getSonsWorldPos2f(r0);
					nextDV->getSonsWorldPos2f(r1);
					if (!r0.empty() && !r1.empty())
					{
						CVector2f p0, p1;
						float bestDist = FLT_MAX;
						for(uint k = 0; k < r0.size(); ++k)
						{
							for(uint l = 0; l < r0.size(); ++l)
							{
								float dist = (r0[k] - r1[l]).norm();
								if (dist <bestDist)
								{
									bestDist = dist;
									p0 = r0[k];
									p1 = r1[l];
								}
							}
						}
						nlassert(bestDist != FLT_MAX);
						addFootSteps(CLine(p0.asVector(), p1.asVector()));
					}
				}
			}
			else
			{
				// special case if prev zone is a region
				if (prevZone && prevZone->isKindOf("Region"))
				{
					// search shortest distance bewteen last pos and the region
					CVector entryPos;
					if (prevDV->evalEnterPoint(nextDV->evalLinkPoint(), entryPos))
					{
						addFootSteps(CLine(entryPos, nextDV->evalLinkPoint()));
					}
					else
					{
						addWanderSteps(nextDV->evalLinkPoint());
					}
				}
				else
				{
					// simple footsteps between last & new pos
					addFootSteps(CLine(prevDV->evalExitPoint(), nextDV->evalLinkPoint()));
				}
			}
		}
		prevDV   = nextDV;
		prevZone = nextZone;
	}
	//
	CGroupMap *gm = CTool::getWorldMap();
	if (!_AddedToWorldMap && gm)
	{
		gm->addDeco(this);
	}
	if (_AddedToWorldMap)
	{
		setWorldMapNumEdges((uint)_FootSteps.size());
		nlassert(gm);
		onUpdate(*gm);
	}
}