Exemple #1
0
Text_sPtr TextParser::parseContent(const char* data, const unsigned int& len)
{
    DBG() << "\n---------------Text---------------------------" << ENDL;

    CColumn column = char2Bin<C_COLUMN_BYTES * BIT_PER_BYTE>( data );
    unsigned int offset = C_LINE_BYTES;

    CLine line = char2Bin<C_LINE_BYTES * BIT_PER_BYTE>( &data[offset] );
    offset += C_COLUMN_BYTES;

    unsigned int textLength = len - offset;

    Text_sPtr text( new ContentProcess<std::string> );
    text->pos.x = column.to_uint();
    text->pos.y = line.to_uint();
    text->content.insert(0, &data[offset], textLength);
    text->pos.len_x = text->content.size();
    text->size = C_LINE_BYTES + C_COLUMN_BYTES + text->pos.len_x;

    INFO() << "line: " << text->pos.y << ENDL;
    INFO() << "column: " << text->pos.x << ENDL;
    INFO() << "text: " << text->content << ENDL;

    return text;
}
void CMy010_SDIView::OnDraw(CDC* pDC)
{
	CMy010_SDIDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	// TODO: add draw code for native data here

	// Get the number of lines in the document
	int liCount = pDoc->GetLineCount();

	// Are there any lines in the document?
	if (liCount)
	{
		int liPos;
		CLine *lptLine;

		// Loop through the lines in the document
		for (liPos = 0; liPos < liCount; liPos++)
		{
			// Get the from and to point for each line
			lptLine = pDoc->GetLine(liPos);
			// Draw the line
			lptLine->Draw(pDC);
		}
	}
}
void CMy010_SDIView::OnMouseMove(UINT nFlags, CPoint point)
{
	// TODO: Add your message handler code here and/or call default

	// Check to see if the left mouse button is down
	if ((nFlags & MK_LBUTTON) == MK_LBUTTON)
	{
		// Have we captured the mouse?
		if (GetCapture() == this)
		{
			// Get the Device Context
			CClientDC dc(this);

			// Add the line to the document
			CLine *pLine = GetDocument()->AddLine(m_ptPrevPos, point);

			// Draw the current stretch of line
			pLine->Draw(&dc);

			// Save the current point as the previous point
			m_ptPrevPos = point;
		}
	}
	CView::OnMouseMove(nFlags, point);
}
Exemple #4
0
	void CPlot::AddNewPoint( float x,float y,int nLineIndex )
	{
		CLine* nLinePtr = GetLineByIndex(nLineIndex);
		nLinePtr->AddPoint(x,y);
		m_axisX.SetAxisRange(x-100.0f,x);
		// 几率X轴的范围
		m_originXLwLmt = x-100.0f;
		m_originXUpLmt = x;	
		// 自动调整纵坐标轴的范围
		if (m_bAdjustable)
		{	
			// 调整Y轴
			float newLowerLmt = m_axisY.GetRangeLowerLimit();
			float newUpperLmt = m_axisY.GetRangeUpperLimit();
			if (y>newUpperLmt)
			{
				newUpperLmt = y;
			}
			if(y<newLowerLmt){
				newLowerLmt = y;
			}
			m_axisY.SetAxisRange(newLowerLmt,newUpperLmt);
			// 几率原始Y轴范围
			m_originYLwLmt = newLowerLmt;
			m_originYUpLmt = newUpperLmt;	
		}
	}
Exemple #5
0
bool CLine::Equals(const CLine & other, unsigned int level) const
{
	if (level == 0)
		return other.GetHash() == GetHash();
	else if(level == 1)
		return other.GetAnchorHash() == GetAnchorHash();
	return Distance(other) < level;
}
Exemple #6
0
void AppendTable(CLineVector & lineVector, const CTable & table, CLine::TYPE type)
{
	for (size_t i = 1; i < table.size() - 1; ++i)
	{
		CLine line = table[i];
		line.SetType(type);
		lineVector.push_back(line);
	}
}
void CLineEditor::addCLine()
{
    QString txt = QInputDialog::getText(this, tr("New CLine"), tr("Insert a CLine : \"C: server port user pass\"\nExample : \"C: server.org 12000 c9nypo abc123\""));

    if(txt != "")
    {
        CLine cline = CLineFileParser::parseCLine(txt);
        if(!cline.getServer().isEmpty())
            model->addCline(cline);
    }
}
Exemple #8
0
void CParticleEngine::NewBulletTracer(int x1, int y1, int x2, int y2, float intensity)
{
	int orderedTracerLength = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1) * (y2 - y1));
	int createdTracerLength = 0;
	bool firstLine = true;
	float gradient = (float)(y2 - y1) / (float)(x2 - x1);
	float lineSegmentLength = standardLineSegmentLength * intensity;
	int loopNumber = 0;

	//create a bunch of lines with decreasing color and alpha intensity 
	while (createdTracerLength < orderedTracerLength)
	{
		float angle = atan2(y2 - y1, x2 - x1);
		float cosAngle = cos(angle);
		float sinAngle = sin(angle);
		CLine * line = new CLine();
		
		if (firstLine)
		{
			firstLine = false;
			line->x1 = x1;
			line->y1 = y1;
		}
		else
		{
			//take first point coordinates from last line's second point coordinates
			line->x1 = lineVector.at(lineVector.size() - 1)->x2 + cosAngle/abs(cosAngle);
			line->y1 = lineVector.at(lineVector.size() - 1)->y2 + sinAngle/abs(sinAngle);

		}
		 
		if (createdTracerLength + lineSegmentLength > orderedTracerLength) //last line is shorter
		{
			lineSegmentLength = orderedTracerLength - createdTracerLength;
		}
		/*x = old_x + length * cos(alpha);
		y = old_y + length * sin(alpha);*/

		//calculate x2 and y2
		
		line->x2 = line->x1 + lineSegmentLength * cosAngle;
		line->y2 = line->y1 + lineSegmentLength * sinAngle;
		
		createdTracerLength += lineSegmentLength;

		//set color values according to intensity
		line->SetRGB(255, 255, 255 - (intensity*150.0f) + loopNumber * (8.0f / intensity));
		line->SetAlpha(160 + (intensity*50.0f) - (loopNumber * (5.0f / intensity)));
		line->SetAlphaLossPerMs(1.3f - intensity * 2);
		loopNumber++;
		lineVector.push_back(line);
	}
}
Exemple #9
0
void AppendBlankLines(CLineVector & lineVector, const CTable & otherTable, CLine::TYPE type)
{
	for (size_t i = 1; i < otherTable.size() - 1; ++i)
	{
		CLine line;
		if (!IsDummyLine(line))
		{
			line.SetType(otherTable[i].GetType() == CLine::TYPE_MOVED ? CLine::TYPE_MATCH : type);
			lineVector.push_back(line);
		}
	}
}
Exemple #10
0
// =============================================================================
// CLine::Intersects
// Does the given line intersect this line
// Returns the intersection point in a parameter
// -----------------------------------------------------------------------------
bool CLine::Intersects(CLine other, CVector2f *intersectionPoint)
{
    bool theResult = false;
    
    // First check that the lines would intersect if they were infinitely long
    // Use the equation from
    // http://devmag.org.za/2009/04/13/basic-collision-detection-in-2d-part-1/
    float otherDY = other.GetEnd().y - other.GetStart().y;
    float otherDX = other.GetEnd().x - other.GetStart().x;
    float thisDY = mEnd.y - mStart.y;
    float thisDX = mEnd.x - mStart.x;
    
    float denominator = (otherDY * thisDX) - (otherDX * thisDY);
    
    // If this denominator is 0 then the lines are parallel, any other value
    // and the lines would intersect at some point if they were of infinite
    // length
    if (denominator != 0.0f)
    {
        // Find the intersection point and make sure it lies between the start
        // and end of each respective line
        float otherToThisStartY = mStart.y - other.GetStart().y;
        float otherToThisStartX = mStart.x - other.GetStart().x;
        
        float percentageAlongThis =     (
                                            (otherDX * otherToThisStartY)
                                            - (otherDY * otherToThisStartX)
                                        )
                                        / denominator;
        float percentageAlongOther =    (
                                            (thisDX * otherToThisStartY)
                                            - (thisDY * otherToThisStartX)
                                        )
                                        / denominator;
        
        if (percentageAlongThis >= 0.0f
            && percentageAlongThis <= 1.0f
            && percentageAlongOther >= 0.0f
            && percentageAlongOther <= 1.0f)
        {
            // This point lies on both lines so we have an intersection
            theResult = true;
            
            // Populate the intersectinoPoint parameter
            CVector2f offsetToEnd = mDirection * GetLength();
            *intersectionPoint = mStart + (percentageAlongThis * offsetToEnd);
        }
    }
    
    return theResult;
}
Exemple #11
0
void CMFCView::OnDraw(CDC* pDC)
{
	CMFCDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	CRect rect;
	GetClientRect(&rect);
	pDC->SetMapMode(MM_ANISOTROPIC);
	pDC->SetWindowExt(rect.Width(),rect.Height());
	pDC->SetViewportExt(rect.Width(),-rect.Height());
	pDC->SetViewportOrg(rect.Width()/2,rect.Height()/2);
	rect.OffsetRect(-rect.Width()/2,-rect.Height()/2);
	CLine c;
	c.Moveto(pDC,0,0);
	c.Lineto(pDC,500,500);
	// TODO: add draw code for native data here
}
Exemple #12
0
void COptimizePath::_AddPathPortion(CLine& line, const A3DPOINT2& dest, const int newCount)
{
	int index;
	int old_count = 0;
	for (index = m_CurIndex +1; index < (int)m_Path.size(); index++)
	{
		old_count++;
		//clear  the old footprint
		int x, y;
		x = (int)m_Path[index].x;
		y = (int)m_Path[index].y;
		SetFootprint(x, y, 0);
		if (x == dest.x && y == dest.y)
		{
			break;
		}
	}

	assert(index < (int)m_Path.size() );

	//adjust the path space between current to dest,  have old_count, need newCount 
	if (old_count > newCount)
	{
		//erase 
		abase::vector<APointF>::iterator it1, it2;
		it1 = &m_Path[m_CurIndex+1];
		it2 = it1 + old_count - newCount;
		m_Path.erase(it1, it2);
	}
	else if (old_count < newCount)
	{
		//insert
		abase::vector<APointF>::iterator it1;
		it1 = &m_Path[m_CurIndex+1];
		m_Path.insert(it1, newCount - old_count, APointF());
	}
	
	//replace the old path portion
	index = m_CurIndex+1;
	while (line.GetCount() < newCount)
	{
		m_Path[index] = line.Next();
		index++;
	}

}
Exemple #13
0
	void CPlot::DrawLines(CDC *pDC)
	{
		// 遍历每一条曲线
		for(int i=0;i<GetLineCount();i++)
		{
			CLine* nLine = GetLineByIndex(i);
			//
			if(!nLine->IsShow || nLine->GetPointCount()<1){
				continue;
			}
			// 动态申请临时数组
			CPoint* nCPointArray = new CPoint[nLine->GetPointCount()];
			// 画笔
			CPen pen(nLine->LineType, nLine->LineWidth, nLine->LineColor);
			CPen *oldPen = pDC->SelectObject(&pen);
			// 坐标转化与处理
			for(int k=0;k<nLine->GetPointCount();k++)
			{
				// 将浮点数Point坐标数据转为整数
				int x = (int)(m_rectPlot.right-((m_axisX.GetRangeUpperLimit()-nLine->GetPointX(k))/(m_axisX.GetAxisRange())*m_rectPlot.Width()));
				int y = (int)(m_rectPlot.bottom - ((nLine->GetPointY(k)-m_axisY.GetRangeLowerLimit())/(m_axisY.GetAxisRange())*m_rectPlot.Height()));
				// 将转化后的值存入数组
				nCPointArray[k].x = x;
				nCPointArray[k].y = y;
			}
			// 绘制单条曲线
			DrawLine(pDC,&(this->m_rectPlot),nCPointArray,nLine->GetPointCount());
			// 释放数组空间
			if(nCPointArray){
				delete [] nCPointArray;
			}
			// 恢复画笔
			pDC->SelectObject(oldPen);
		}		
	}
Exemple #14
0
bool COptimizePath::_LineTo(CLine& line, APointF& to)
{

#define  LOCAL_STRICT_LINE
	A3DPOINT2 to_pt((int)to.x, (int)to.y);
	A3DPOINT2 cur_pt((int)line.GetFrom().x, (int)line.GetFrom().y);

	CMoveMap * pMoveMap = g_MoveAgentManager.GetMoveMap();
	assert(pMoveMap);

#ifdef LOCAL_STRICT_LINE
	A3DPOINT2  last_pt(cur_pt);

#endif
	while (cur_pt != to_pt )
	{
		
		APointF cur(line.Next());
		cur_pt.x = (int)cur.x;
		cur_pt.y = (int)cur.y;

		if (!pMoveMap->IsPosReachable(cur_pt))
		{
			return false;
		}

#ifdef LOCAL_STRICT_LINE
		if ((cur_pt.x != last_pt.x && cur_pt.y != last_pt.y) 
			&&(!pMoveMap->IsPosReachable(last_pt.x, cur_pt.y)
			  || !pMoveMap->IsPosReachable(cur_pt.x, last_pt.y)) )
		{
			return false;
		}
		last_pt = cur_pt;
#endif

	}
	
#undef  LOCAL_STRICT_LINE
	return true;
}
void CLineEditor::createCCcamFile()
{
    QFile src(remoteFileName + ".bak");
    QFile dst(remoteFileName);
    if(!src.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        QMessageBox::critical(0,tr("Open fail"), tr("Failed to open : %1").arg(src.fileName()));
        return;
    }
    if(!dst.open(QIODevice::WriteOnly | QIODevice::Text))
    {
        QMessageBox::critical(0,tr("Open fail"), tr("Failed to open : %1").arg(dst.fileName()));
        return;
    }

    QTextStream out(&dst);

    while (!src.atEnd())
    {
        QString line = src.readLine().trimmed();
        CLine cline = CLineFileParser::parseCLine(line);

        if(cline.getServer().isEmpty() && line != CLINE_EDITOR_HEADER)
            out << line << "\n";
    }

    if(model->getClines().size() > 0)
        out << CLINE_EDITOR_HEADER << "\n";

    foreach (const CLine &cline, model->getClines())
        out << cline.toString() << "\n";


    src.close();
    dst.close();
}
Exemple #16
0
void SetCharTypes(CLine & line, const CLineVector & lineVector)
{
	int charPos = 0;
	for(CLineVector::const_iterator itr = lineVector.begin(); itr != lineVector.end(); ++itr)
	{
		switch(itr->GetType())
		{
		case CLine::TYPE_DELETED:
		case CLine::TYPE_SIMILAR:
		case CLine::TYPE_MOVED:
			line.SetCharType(charPos, CLine::TYPE_SIMILAR);
			break;
		}
		charPos++;
	}
}
Exemple #17
0
double CLine::GetDistanceTo(const CLine& line) const
{
	if ((*this) * line)  // If two line cross, then return 0
		return 0;

	double d1=GetDistanceTo(line.m_pt1);
	double d2=GetDistanceTo(line.m_pt2);
	double d3=line.GetDistanceTo(m_pt1);
	double d4=line.GetDistanceTo(m_pt2);

	double dMin=d1;
	if (d2<dMin)
		dMin=d2;
	if (d3<dMin)
		dMin=d3;
	if (d4<dMin)
		dMin=d4;

	return dMin;
}
Exemple #18
0
void CAnchors::GetResults(CLineVector & baseResult, CLineVector & compResult)
{
	for(size_t i = 1; i < m_baseTable.size() - 1; ++i)
	{
		CLine line = m_baseTable[i];
		if (AnchorsBaseContains(i))
			line.SetType(CLine::TYPE_MATCH);
		else
			line.SetType(CLine::TYPE_SIMILAR);
		baseResult.push_back(line);
	}

	for(size_t i = 1; i < m_compTable.size() - 1; ++i)
	{
		CLine line = m_compTable[i];
		if (AnchorsCompContains(i))
			line.SetType(CLine::TYPE_MATCH);
		else
			line.SetType(CLine::TYPE_SIMILAR);
		compResult.push_back(line);
	}
}
Exemple #19
0
// =============================================================================
// Operators
// -----------------------------------------------------------------------------
bool operator == (CLine lhs, CLine rhs)
{
    return lhs.GetStart() == rhs.GetStart() && lhs.GetEnd() == rhs.GetEnd();
}
Exemple #20
0
bool IsDummyLine(const CLine & line)
{
	ATLASSERT((line.Equals(startLine, 0) || line.Equals(endLine, 0)) == false);
	return (line.Equals(startLine, 0) || line.Equals(endLine, 0));
}
Exemple #21
0
void AHAI::executePrepareShoot()
{
    AHPoint pPuckFuturePosition;
    CLine* cShotLine;

    float fTimeForThePuckToCome;
    float fDistanceToTarget;

    int iChoice;

    switch(iStateStep)
    {
    case AH_STATE_STEP_ENTER:

        // default: direct shot
        pShotPoint = calculateGoalPoint();
        iChoice = rand() % 2;

        // with bounce
        if(iChoice == 1)
        {
            // against the left wall
            if(pMyPosition.x >= 0.0 && pPuckPosition.x < -fHoleToShoot)
                pShotPoint.x -= AH_TABLE_WIDTH * (1 + rand() % 2);    // one or two bounces

            // against the right wall
            else if(pMyPosition.x < 0.0 && pPuckPosition.x > fHoleToShoot)
                pShotPoint.x += AH_TABLE_WIDTH * (1 + rand() % 2);
        }

        // puck's future position
        fImpulseDistance = fBackSpace;
        pPuckFuturePosition.y = pMyPosition.y + fImpulseDistance;
        pPuckFuturePosition.x = predictPositionX(pPuckFuturePosition.y);

        // shot line
        cShotLine = new CLine(pShotPoint.x, pShotPoint.y, pPuckFuturePosition.x, pPuckFuturePosition.y);
        pTargetPosition = pMyPosition;

        if(cShotLine->can_calculate_x())
            pTargetPosition.x = (float)cShotLine->x(pTargetPosition.y);

        // speed
        if(abs(vPuckVelocity.y) > fStopped)
        {
            fTimeForThePuckToCome = (pPuckFuturePosition.y - pPuckPosition.y) / vPuckVelocity.y;
            fTimeForThePuckToCome = abs(fTimeForThePuckToCome);
            fTimeForThePuckToCome -= 2.0;        // state change frames

            if(fTimeForThePuckToCome < 0.0)
            {
                fCalculatedSpeed = cLevel.SpeedForShooting;
            }
            else
            {
                fDistanceToTarget = (pTargetPosition.x - pMyPosition.x) * (pTargetPosition.x - pMyPosition.x);
                fDistanceToTarget += (pTargetPosition.y - pMyPosition.y) * (pTargetPosition.y - pMyPosition.y);
                fDistanceToTarget = sqrt(fDistanceToTarget);

                fCalculatedSpeed = fDistanceToTarget / fTimeForThePuckToCome;
                fCalculatedSpeed = min(cLevel.SpeedForShooting, fCalculatedSpeed);
            }
        }
        else
        {
            fCalculatedSpeed = cLevel.DefaultSpeed;
        }

        iStateStep = AH_STATE_STEP_EXECUTE;

        break;

    case AH_STATE_STEP_EXECUTE:

        fSpeed = fCalculatedSpeed;

        if(targetPositionReached() ||                        // ready for the shot
           pPuckPosition.y <= pMyPosition.y ||                 // the puck has escaped
           pPuckPosition.y > (AH_TABLE_HEIGHT / 2) ||        // the puck is out of my zone
           abs(vPuckVelocity.y) < fStopped)                    // the puck is stopped
        {
            iStateStep = AH_STATE_STEP_EXIT;
        }

        break;

    case AH_STATE_STEP_EXIT:

        if(pPuckPosition.y > pMyPosition.y)
            selectState(AH_STATE_SHOOT_TO_GOAL);
        else
            selectState(AH_STATE_NOTHING);

        break;

    default:
        break;
    }
}
Exemple #22
0
void CAnchors::GetPaddedResults(CLineVector & baseResult, CLineVector & compResult) const
{
	unsigned int matchCount = GetMatchCount();
	unsigned int gapCount = GetGapCount();
	unsigned int matchPos = 0;
	unsigned int gapPos = 0;
	while(matchPos < matchCount)
	{
		{
			CTable baseTable, compTable;
			GetMatch(matchPos, baseTable, compTable);
			for (size_t i = 1; i < baseTable.size() - 1; ++i)
			{
				CLine baseLine = baseTable[i];
				CLine compLine = compTable[i];
				CLine::TYPE type = baseLine.Equals(compLine, 0) ? CLine::TYPE_MATCH : CLine::TYPE_SIMILAR;
				if (type == CLine::TYPE_SIMILAR)
				{
					CTable baseLineTable(baseLine.GetText(), true);
					CTable compLineTable(compLine.GetText(), true);
					CAnchors lineAnchors(baseLineTable, compLineTable, 0);
					CLineVector baseLineVector, compLineVector;
					lineAnchors.GetResults(baseLineVector, compLineVector);
					SetCharTypes(baseLine, baseLineVector);
					SetCharTypes(compLine, compLineVector);
				}
				baseLine.SetType(type);
				compLine.SetType(type);
				baseResult.push_back(baseLine);
				compResult.push_back(compLine);
			}
			ATLASSERT(baseResult.size() == compResult.size());
			++matchPos;
		}
		if (gapPos < gapCount)
		{
			CTable baseTable, compTable;
			GetGap(gapPos, baseTable, compTable);
			if (baseTable.size() <= 2)	//Added lines
			{
				ATLASSERT(compTable.size() > 2);
				AppendBlankLines(baseResult, compTable, CLine::TYPE_ADDED);
				AppendTable(compResult, compTable, CLine::TYPE_ADDED);
			}
			else if (compTable.size() <= 2)  //Deleted lines
			{
				ATLASSERT(baseTable.size() > 2);
				AppendTable(baseResult, baseTable, CLine::TYPE_DELETED);
				AppendBlankLines(compResult, baseTable, CLine::TYPE_DELETED);
			}
			else if (m_accuracy > 35)	//  Don't recurse too much.
			{
				AppendTable(baseResult, baseTable, CLine::TYPE_DELETED);
				AppendBlankLines(compResult, baseTable, CLine::TYPE_DELETED);
				AppendBlankLines(baseResult, compTable, CLine::TYPE_ADDED);
				AppendTable(compResult, compTable, CLine::TYPE_ADDED);
			}
			else
			{
				CAnchors gapAnchors(baseTable, compTable, m_accuracy + 5);
				gapAnchors.GetPaddedResults(baseResult, compResult);
			}
			ATLASSERT(baseResult.size() == compResult.size());
			++gapPos;
		}
	}
}
Exemple #23
0
CElem* CXMLVecLS::LoadElem(CXmlNode &node)
{
	CString str;
	int nType = GetType(node.GetName());

	CPointF pt;
	CRectF rc; 

	CElem *elem = NULL;
	switch (nType)
	{
	case CElem::Line:
		{		
			CLine *pElem = new CLine();
			
			TEST_FREE_RETURNNULL(!LoadNonFillVecElem(pElem,node),pElem);
 
			pt.x = node.GetFloatAttrib(_T("StartPointX"));
			pt.y = node.GetFloatAttrib(_T("StartPointY"));
			pElem->SetStartPoint(pt);

			pt.x = node.GetFloatAttrib(_T("EndPointX"));
			pt.y = node.GetFloatAttrib(_T("EndPointY")); 
			pElem->SetEndPoint(pt);
			elem = pElem;
		}
		break;
	case CElem::Bezier:
		{		
			CBezier *pElem = new CBezier();
			
			TEST_FREE_RETURNNULL(!LoadNonFillVecElem(pElem,node),pElem);

			CXmlNode n;
			CPointF pt;
			CFPoints pts;
			for (int i=0,cnt=node.ChildCount; i<cnt; ++i)
			{
				n = node.Child[i];
				if (n.GetName() == _T("Point"))
				{
					pt.x = n.GetFloatAttrib(_T("X"));
					pt.y = n.GetFloatAttrib(_T("Y"));
					pts.Add(pt);
				}
			}
			pElem->SetPoints(pts);
			elem = pElem;
		}
		break;
	case CElem::FreeLine:
		{		
			CFreeLine *pElem = new CFreeLine();
			
			TEST_FREE_RETURNNULL(!LoadNonFillVecElem(pElem,node),pElem);

			CXmlNode n;
			CPointF pt;
			CFPoints pts;
			for (int i=0,cnt=node.ChildCount; i<cnt; ++i)
			{
				n = node.Child[i];
				if (n.GetName() == _T("Point"))
				{
					pt.x = n.GetFloatAttrib(_T("X"));
					pt.y = n.GetFloatAttrib(_T("Y"));
					pts.Add(pt);
				}
			}
			pElem->SetPoints(pts);
			elem = pElem;
		}
		break;
	case CElem::Arc:
		{
			CArc *pElem = new CArc();
			
			TEST_FREE_RETURNNULL(!LoadNonFillVecElem(pElem,node),pElem);

			rc.left = node.GetFloatAttrib(_T("RectLeft"));
			rc.top = node.GetFloatAttrib(_T("RectTop"));
			rc.right = node.GetFloatAttrib(_T("RectRight"));			
			rc.bottom = node.GetFloatAttrib(_T("RectBottom"));
			pElem->SetBoundsRect(rc);

			pElem->SetStartAngel(node.GetFloatAttrib(_T("StartAngel")));
			pElem->SetEndAngel(node.GetFloatAttrib(_T("EndAngel")));

			elem = pElem;
		}
		break;
	case CElem::Chord:
		{
			CChord *pElem = new CChord();
			
			TEST_FREE_RETURNNULL(!LoadFilledVecElem(pElem,node),pElem);

			rc.left = node.GetFloatAttrib(_T("RectLeft"));
			rc.top = node.GetFloatAttrib(_T("RectTop"));
			rc.right = node.GetFloatAttrib(_T("RectRight"));			
			rc.bottom = node.GetFloatAttrib(_T("RectBottom"));
			pElem->SetBoundsRect(rc);

			pElem->SetStartAngel(node.GetFloatAttrib(_T("StartAngel")));
			pElem->SetEndAngel(node.GetFloatAttrib(_T("EndAngel")));
			elem = pElem; 
		}
		break;
	case CElem::Pie:
		{
			CPie *pElem = new CPie();
			
			TEST_FREE_RETURNNULL(!LoadFilledVecElem(pElem,node),pElem);

			rc.left = node.GetFloatAttrib(_T("RectLeft"));
			rc.top = node.GetFloatAttrib(_T("RectTop"));
			rc.right = node.GetFloatAttrib(_T("RectRight"));			
			rc.bottom = node.GetFloatAttrib(_T("RectBottom"));
			pElem->SetBoundsRect(rc);

			pElem->SetStartAngel(node.GetFloatAttrib(_T("StartAngel")));
			pElem->SetEndAngel(node.GetFloatAttrib(_T("EndAngel")));
			elem = pElem;  
		}
		break;

	case CElem::Poly:
		{
			CPoly *pElem = new CPoly();
			
			TEST_FREE_RETURNNULL(!LoadFilledVecElem(pElem,node),pElem);

			CXmlNode n;
			CPointF pt;
			CFPoints pts;
			for (int i=0,cnt=node.ChildCount; i<cnt; ++i)
			{
				n = node.Child[i];
				if (n.GetName() == _T("Point"))
				{
					pt.x = n.GetFloatAttrib(_T("X"));
					pt.y = n.GetFloatAttrib(_T("Y"));
					pts.Add(pt);
				}
			}
			pElem->SetPoints(pts);
			elem = pElem;
		}
		break;
	case CElem::Region:
		{
			CRegion *pElem = new CRegion();
			
			TEST_FREE_RETURNNULL(!LoadFilledVecElem(pElem,node),pElem);

			CXmlNode n;
			CPointF pt;
			CFPoints pts;
			for (int i=0,cnt=node.ChildCount; i<cnt; ++i)
			{
				n = node.Child[i];
				if (n.GetName() == _T("Point"))
				{
					pt.x = n.GetFloatAttrib(_T("X"));
					pt.y = n.GetFloatAttrib(_T("Y"));
					pts.Add(pt);
				}
			}
			pElem->SetPoints(pts);
			elem = pElem;
		}
		break;
	case CElem::Rectangle:
		{			
			CRectangle *pElem = new CRectangle();
			
			TEST_FREE_RETURNNULL(!LoadFilledVecElem(pElem,node),pElem);

			pElem->SetText(node.GetStringAttrib(_T("Text")));
			rc.left = node.GetFloatAttrib(_T("RectLeft"));
			rc.top = node.GetFloatAttrib(_T("RectTop"));
			rc.right = node.GetFloatAttrib(_T("RectRight"));			
			rc.bottom = node.GetFloatAttrib(_T("RectBottom"));
			pElem->SetBoundsRect(rc);
			elem = pElem;
		}
		break;
	case CElem::RoundRect:
		{
			CRoundRect *pElem = new CRoundRect();
			
			TEST_FREE_RETURNNULL(!LoadFilledVecElem(pElem,node),pElem);

			rc.left = node.GetFloatAttrib(_T("RectLeft"));
			rc.top = node.GetFloatAttrib(_T("RectTop"));
			rc.right = node.GetFloatAttrib(_T("RectRight"));			
			rc.bottom = node.GetFloatAttrib(_T("RectBottom"));
			pElem->SetBoundsRect(rc);

			pElem->SetXEllipse(node.GetFloatAttrib(_T("XEllipse")));
			pElem->SetYEllipse(node.GetFloatAttrib(_T("YEllipse")));

			elem = pElem;
		}
		break;
	case CElem::Ellipse:
		{
			CEllipse *pElem = new CEllipse();
			
			TEST_FREE_RETURNNULL(!LoadFilledVecElem(pElem,node),pElem);

			rc.left = node.GetFloatAttrib(_T("RectLeft"));
			rc.top = node.GetFloatAttrib(_T("RectTop"));
			rc.right = node.GetFloatAttrib(_T("RectRight"));			
			rc.bottom = node.GetFloatAttrib(_T("RectBottom"));
			pElem->SetBoundsRect(rc);

			elem = pElem;;
		}
		break;
	default: 
		ASSERT(FALSE);
		return NULL;
	} 
	if (elem != NULL)
	{
		elem->SetCustomData(node.GetBigUIntAttrib(_T("CustomData")));
		elem->SetDesc(node.GetStringAttrib(_T("Desc")));
		//elem->SetText(node.GetStringAttrib(_T("Text")));
		//elem->SetTextColor(node.GetUIntAttrib(_T("TextColor")));
	}

	return elem;
}
Exemple #24
0
//-------------------------
//  FX_AddLine
//-------------------------
CLine *FX_AddLine( int clientID, vec3_t start, float size1, float size2, float sizeParm,
									float alpha1, float alpha2, float alphaParm,
									vec3_t sRGB, vec3_t eRGB, float rgbParm,
									int killTime, qhandle_t shader, int impactFX_id, int flags = 0 )
{
	if ( theFxHelper.mFrameTime < 1 )
	{ // disallow adding new effects when the system is paused
		return 0;
	}

	CLine *fx = new CLine;

	if ( fx )
	{
		fx->SetOrgOffset( start );
		fx->SetOrigin1( NULL );

		// RGB----------------
		fx->SetRGBStart( sRGB );
		fx->SetRGBEnd( eRGB );

		if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
		{
			fx->SetRGBParm( rgbParm * PI * 0.001f );
		}
		else if ( flags & FX_RGB_PARM_MASK )
		{
			// rgbParm should be a value from 0-100..
			fx->SetRGBParm( rgbParm * 0.01f * killTime + theFxHelper.mTime );
		}

		// Alpha----------------
		fx->SetAlphaStart( alpha1 );
		fx->SetAlphaEnd( alpha2 );

		if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
		{
			fx->SetAlphaParm( alphaParm * PI * 0.001f );
		}
		else if ( flags & FX_ALPHA_PARM_MASK )
		{
			fx->SetAlphaParm( alphaParm * 0.01f * killTime + theFxHelper.mTime );
		}

		// Size----------------
		fx->SetSizeStart( size1 );
		fx->SetSizeEnd( size2 );

		if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
		{
			fx->SetSizeParm( sizeParm * PI * 0.001f );
		}
		else if ( flags & FX_SIZE_PARM_MASK )
		{
			fx->SetSizeParm( sizeParm * 0.01f * killTime + theFxHelper.mTime );
		}

		fx->SetShader( shader );
		fx->SetFlags( flags );

		fx->SetSTScale( 1.0f, 1.0f );
		fx->SetClient( clientID );
		fx->SetImpactFxID( impactFX_id );

		FX_AddPrimitive( (CEffect**)&fx, killTime );
		// in the editor, fx may now be NULL
	}

	return fx;
}
Exemple #25
0
//-------------------------
//  FX_AddLine
//-------------------------
CLine *FX_AddLine( vec3_t start, vec3_t end, float size1, float size2, float sizeParm,
									float alpha1, float alpha2, float alphaParm,
									vec3_t sRGB, vec3_t eRGB, float rgbParm,
									int killTime, qhandle_t shader, int flags = 0, 
									EMatImpactEffect matImpactFX /*MATIMPACTFX_NONE*/, int fxParm /*-1*/,
									int iGhoul2/*0*/, int entNum/*-1*/, int modelNum/*-1*/, int boltNum/*-1*/)
{
	if ( theFxHelper.mFrameTime < 0 )
	{ // disallow adding new effects when the system is paused
		return 0;
	}

	CLine *fx = new CLine;

	if ( fx )
	{
		if (flags&FX_RELATIVE && iGhoul2>0)
		{
			fx->SetOrigin1( NULL );
			fx->SetOrgOffset( start ); //offset from bolt pos
			fx->SetVel( end );	//vel is the vector offset from bolt+orgOffset
			fx->SetBoltinfo( iGhoul2, entNum, modelNum, boltNum );
		}
		else
		{
			fx->SetOrigin1( start );
			fx->SetOrigin2( end );
		}
		fx->SetMatImpactFX(matImpactFX);
		fx->SetMatImpactParm(fxParm);

		// RGB----------------
		fx->SetRGBStart( sRGB );
		fx->SetRGBEnd( eRGB );

		if (( flags & FX_RGB_PARM_MASK ) == FX_RGB_WAVE )
		{
			fx->SetRGBParm( rgbParm * PI * 0.001f );
		}
		else if ( flags & FX_RGB_PARM_MASK )
		{
			// rgbParm should be a value from 0-100..
			fx->SetRGBParm(rgbParm * 0.01f * killTime + theFxHelper.mTime + theFxHelper.mTimeFraction);
		}

		// Alpha----------------
		fx->SetAlphaStart( alpha1 );
		fx->SetAlphaEnd( alpha2 );

		if (( flags & FX_ALPHA_PARM_MASK ) == FX_ALPHA_WAVE )
		{
			fx->SetAlphaParm( alphaParm * PI * 0.001f );
		}
		else if ( flags & FX_ALPHA_PARM_MASK )
		{
			fx->SetAlphaParm(alphaParm * 0.01f * killTime + theFxHelper.mTime + theFxHelper.mTimeFraction);
		}

		// Size----------------
		fx->SetSizeStart( size1 );
		fx->SetSizeEnd( size2 );

		if (( flags & FX_SIZE_PARM_MASK ) == FX_SIZE_WAVE )
		{
			fx->SetSizeParm( sizeParm * PI * 0.001f );
		}
		else if ( flags & FX_SIZE_PARM_MASK )
		{
			fx->SetSizeParm(sizeParm * 0.01f * killTime + theFxHelper.mTime + theFxHelper.mTimeFraction);
		}

		fx->SetShader( shader );
		fx->SetFlags( flags );

		fx->SetSTScale( 1.0f, 1.0f );

		FX_AddPrimitive( (CEffect**)&fx, killTime );
	}

	return fx;
}
Exemple #26
0
int DrawChart(CDataInterface *pData, CEnvParam *pEnv, Interaction *itt,
			 string VO, string &ppOutStruct,CResult **ppRst)
{	
	AnaWord aw;
	aw.Import(VO);
	CTString szChartType = aw.GetAt(0);//调用的算法名字
	
	if (szChartType == CHART_LINE)          //直线图
	{
		CLine line;
		(*ppRst) = line.OnChart(pData, VO);  
	}
	else if (szChartType == CHART_BAR)      //条状图
	{
		CBar Bar;
		(*ppRst) = Bar.OnChart(pData, VO);
	}
	else if (szChartType == CHART_PIE)      //饼图
	{
		CPie Pie;
		(*ppRst) = Pie.OnChart(pData, VO);
	}
	else if (szChartType == CHART_AREA)     //面积图
	{
		CArea Area;
		(*ppRst) = Area.OnChart(pData, VO);
	}
	else if (szChartType == CHART_BOXPLOT)  //盒状图
	{
		CBox Box;
		(*ppRst) = Box.OnChart(pData, VO);
	}
	else if (szChartType == CHART_HISTOGRAM)//直方图
	{
		CHistogram Histogram;
		(*ppRst) = Histogram.OnChart(pData, VO);
	}
	else if (szChartType == CHART_SCATTER)  //散点图
	{
		CScatter Scatter;
		(*ppRst) = Scatter.OnChart(pData, VO);
	}
	else if (szChartType == CHART_SELFCORRELATIONS) //自相关
	{
		CSelfCorrelation SelfCorr;
		(*ppRst) = SelfCorr.OnChart(pData,VO);
	}
	else if (szChartType == CHART_CROSSCORRELATIONS) //互相关
	{
		CCrossCorrelation CrossCorr;
		(*ppRst) = CrossCorr.OnChart(pData,VO);
	}
	else if (szChartType == CHART_EMP)
	{
		CEmp Emp;
		(*ppRst) = Emp.OnChart(pData,VO);
	}
	else
	{
		CResult *pResult = new CResult("图形接口算法调用错误");
		CTString szWarning = "没有相应的图形接口,请与供应商联系!";
		CRsltElementText *pWarningTextRslt = new CRsltElementText("错误!");
		pWarningTextRslt->AddString(szWarning);
		pResult->Add(pWarningTextRslt);
		(*ppRst) = pResult; 
		(*ppRst)->Print();
		return 1;
	}

	if (ppRst == NULL)
	{
		CResult *pResult = new CResult("图形接口算法调用错误");
		CTString szWarning = "您所选择的数据不适合相应的图形接口算法,请重新运行!";
		CRsltElementText *pWarningTextRslt = new CRsltElementText( "错误!" );
		pWarningTextRslt->AddString(szWarning);
		pResult->Add(pWarningTextRslt);
		(*ppRst) = pResult; 
		(*ppRst)->Print();
		return 1;
	}
	else
	{
		(*ppRst)->Print();
		return 0;
	}
}