コード例 #1
0
void paintFoliation(const balazs::Foliation& foliation, QPainter &painter, int folW, int folH)
{
    painter.save();
    painter.setPen(Qt::SolidLine);
    painter.drawRect(0, 0, folW, folH);

    for(std::size_t i = 0; i < foliation.numIntervals(); i++){
        double singularityHeight = heightOfSingularity(foliation, i, folH);

        QPointF topPoint(folW * foliation.topDivPoints()[i], 0);
        QPointF middlePoint(folW * foliation.topDivPoints()[i], singularityHeight);
        QPointF bottomPoint(folW * foliation.topDivPoints()[i], folH);

        painter.setPen(Qt::SolidLine);
        painter.drawLine(topPoint, middlePoint);
        painter.setPen(Qt::DotLine);
        painter.drawLine(bottomPoint, middlePoint);

        painter.save();
        painter.setPen(QPen(Qt::black, 4));
        painter.drawPoint(middlePoint);
        painter.restore();
    }

    painter.setPen(Qt::DashLine);
    for(std::size_t i = 0; i < foliation.numIntervals(); i++){
        QPointF topPoint(folW * foliation.bottomDivPoints()[i], folH);
        QPointF bottomPoint(folW * foliation.bottomDivPoints()[i], 1.05 * folH);
        painter.drawLine(topPoint, bottomPoint);
    }
    painter.restore();
}
コード例 #2
0
ファイル: xprocesstable.cpp プロジェクト: zbyufei/Memmon
void XProcessTablePrivate::drawColumnLines(QPainter *painter)
{
    painter->save();
    painter->setPen(XPT::Color::ColumnLineColor);

    qreal initX = 0;

    for(int index = 0;index < _allColumnWidth.size();index++)
    {
        initX += _allColumnWidth.at(index);

        QPointF topPoint(initX,0);
        QPointF bottomPoint(initX,height());
        painter->drawLine(topPoint,bottomPoint);
    }

    painter->restore();
}
コード例 #3
0
ファイル: wtfwidget.cpp プロジェクト: leepood/ucweblike
void WTFWidget::drawInnerArrow(QPainter& painter) {

    if(_innerPercent == 0) return;

    QRect rect = this->contentsRect();
    QPoint center = rect.center();
    painter.save();
    painter.translate(center);
    painter.rotate(90 * _innerPercent);

    QColor arrowColor = QColor::fromRgb(0xff,0xff,0xff,0xff * _innerPercent);
    QPen pen = QPen(arrowColor);
    pen.setWidth(2);
    painter.setPen(pen);
    int left = - CIRCLE_INNER_RADIUS;
    int top =  - CIRCLE_INNER_RADIUS;
    QRect arcRect = QRect(left,top,CIRCLE_INNER_RADIUS * 2,
                          CIRCLE_INNER_RADIUS * 2);
    painter.drawArc(arcRect,90 * 16,270 * 16);

    // start draw arrow
    qreal arrowBorderLen = 8;
    QPainterPath path;
    QPoint topPoint(0,
                    - CIRCLE_INNER_RADIUS - arrowBorderLen/2);
    path.moveTo(topPoint);
    qreal distance = (arrowBorderLen / 2) / qTan(qDegreesToRadians((double)30));
    QPoint rightPoint(distance,-CIRCLE_INNER_RADIUS);
    path.lineTo(rightPoint);
    QPoint bottomPoint(0,
                       - CIRCLE_INNER_RADIUS + arrowBorderLen/2);
    path.lineTo(bottomPoint);
    path.closeSubpath();
    painter.fillPath(path,QBrush(arrowColor));

    painter.translate(-center.x(),-center.y());
    painter.restore();
}
コード例 #4
0
void  CVxDisplayArea::DrawGrid(QPainter& painter,int iW, int iH)
{
	float fW = 1.0 * iW/m_iCol;
	float fH = 1.0 * iH/(m_iRow + 1);

	//画竖直线。
	float fStartX = 0;
	for ( int i = 0; i < m_iCol; i ++ )
	{
		QPoint topPoint(fStartX, 0);
		QPoint bottomPoint(fStartX,iH);
		painter.drawLine(topPoint,bottomPoint);

		QString strDegree = QString("E ") + QString::number(120)+ GetDegreeStr() + QString::number(15.001) + GetMinuteStr();
		painter.drawText(fStartX + 5, 15, strDegree);

		fStartX += fW;
	}

	//画竖直线。
	float fStartY = 0;
	for ( int i = 0; i < m_iRow + 1 + 1; i ++ )//多画最底下一条和副显示区域之间的横线。
	{
		QPoint LeftPoint(0, fStartY);
		QPoint RightPoint(iW,fStartY);
		painter.drawLine(LeftPoint,RightPoint);

		if ( i < m_iRow)
		{
			QString strDegree = QString("N ") + QString::number(120)+ GetDegreeStr() + QString::number(15.001) + GetMinuteStr();
			painter.drawText( 5, fStartY + fH - 10, strDegree);
		}

		fStartY += fH;
	}
}
コード例 #5
0
ファイル: JMIDIInObj.cpp プロジェクト: neattools/neattools
JFPoint JMIDIInObj::inputPoint(int n, JLinkObj& link) 
{ return topPoint(n, link, 0, 1);}
コード例 #6
0
JFPoint JDelaySustainObj::inputPoint(int n, JLinkObj& link) { 
  if (!n) return leftPoint(n, link, 0, 1);
  return topPoint(n, link, 1, IN_LAST-1);
}
コード例 #7
0
ファイル: JSampleObj.cpp プロジェクト: neattools/neattools
JFPoint JSampleObj::inputPoint(int n, JLinkObj& link) {
  if (n<IN_LAST) return topPoint(n, link, 0, IN_LAST);
  return leftPoint(n, link, IN_LAST, N, 0, 1);
}
コード例 #8
0
ファイル: JRandomObj.cpp プロジェクト: neattools/neattools
JFPoint JRandomObj::inputPoint(int n, JLinkObj& link) 
{ return topPoint(n, link, 0, 1);}
コード例 #9
0
ファイル: JTNG4Obj.cpp プロジェクト: neattools/neattools
JFPoint JTNG4Obj::inputPoint(int n, JLinkObj& link) { 
  if (n < IN_BCONFIG)
    return leftPoint(n, link, 0, IN_BCONFIG);
  else return topPoint(n, link, IN_BCONFIG, IN_LAST+extraInputCount-IN_BCONFIG);
}
コード例 #10
0
void MyPrimitive::GenerateSphere(float a_fRadius, int a_nSubdivisions, vector3 a_v3Color)
{
	////Sets minimum and maximum of subdivisions
	//if (a_nSubdivisions < 1)
	//{
	//	GenerateCube(a_fRadius * 2, a_v3Color);
	//	return;
	//}
	//if (a_nSubdivisions > 6)
	//	a_nSubdivisions = 6;

	Release();
	Init();

	//Your code starts here
	vector3 topPoint(0.00f, a_fRadius, 0.00f);
	vector3 bottomPoint(0.00f, -a_fRadius, 0.00f);
	std::vector<std::vector<vector3>> spherePoints; //holds all other vertices on the sphere

	//add the middle ring of vertices; if the number of subdivisions is even, there are two middle rings
	if (a_nSubdivisions % 2 == 0)
	{
		std::vector<vector3> topMiddleRing;
		for (int x = 0; x < a_nSubdivisions; x++)
		{
			//calculate vertex positions
			float angle = ((2 * PI) / a_nSubdivisions) * x;
			float x_Value = a_fRadius * sin(angle);
			float z_Value = a_fRadius * cos(angle);

			topMiddleRing.push_back(vector3(x_Value, a_fRadius / (2 * a_nSubdivisions), z_Value));
		}
		std::vector<vector3> bottomMiddleRing;
		for (int x = 0; x < a_nSubdivisions; x++)
		{
			//calculate vertex positions
			float angle = ((2 * PI) / a_nSubdivisions) * x;
			float x_Value = a_fRadius * sin(angle);
			float z_Value = a_fRadius * cos(angle);

			bottomMiddleRing.push_back(vector3(x_Value, -a_fRadius / (2 * a_nSubdivisions), z_Value));
		}
		spherePoints.push_back(topMiddleRing);
		spherePoints.push_back(bottomMiddleRing);
	}
	else
	{
		std::vector<vector3> middleRing;
		for (int x = 0; x < a_nSubdivisions; x++)
		{
			//calculate vertex positions
			float angle = ((2 * PI) / a_nSubdivisions) * x;
			float x_Value = a_fRadius * sin(angle);
			float z_Value = a_fRadius * cos(angle);

			middleRing.push_back(vector3(x_Value, 0.00f, z_Value));
		}
		spherePoints.push_back(middleRing);
	}

	//add more rings to the sphere equal to the number of subdivisions minus existing rings
	//rings can be added in pairs moving away from the middle ring/rings in both directions,
	//so the loop will run half the number of times
	int existingRings = spherePoints.size();
	for (int x = 0; x < (a_nSubdivisions -  existingRings)/ 2; x++)
	{
		std::vector<vector3> upperRing;
		std::vector<vector3> lowerRing;
		//get an adjusted radius for this pair of rings
		float adjustedRadius = (a_fRadius / ((a_nSubdivisions / 2) + 1)) * ((a_nSubdivisions / 2) - x);

		for (int y = 0; y < a_nSubdivisions; y++)
		{
			//calculate vertex positions
			float angle = ((2 * PI) / a_nSubdivisions) * y;
			float x_Value = adjustedRadius * sin(angle);
			float z_Value = adjustedRadius * cos(angle);

			upperRing.push_back(vector3(x_Value, a_fRadius - adjustedRadius, z_Value));
			lowerRing.push_back(vector3(x_Value, -a_fRadius + adjustedRadius, z_Value));
		}
		spherePoints.push_back(upperRing);
		spherePoints.push_back(lowerRing);
	}

	//draw quads around the sphere moving away from the middle ring/rings
	if (a_nSubdivisions % 2 == 0)
	{
		//draw middle ring of quads
		for (int x = 0; x < spherePoints[0].size(); x++)
		{
			if (x != spherePoints[0].size() - 1)
			{
				AddQuad(spherePoints[1][x], spherePoints[1][x + 1], spherePoints[0][x], spherePoints[0][x + 1]);
			}
			else
			{
				AddQuad(spherePoints[1][x], spherePoints[1][0], spherePoints[0][x], spherePoints[0][0]);
			}
		}
		//draw more rings of quads
		for (int x = 0; x < spherePoints.size() - 2; x++)
		{
			if (x % 2 == 0)
			{
				for (int y = 0; y < spherePoints[x].size(); y++)
				{
					if (y != spherePoints[x].size() - 1)
					{
						AddQuad(spherePoints[x][y], spherePoints[x][y + 1], spherePoints[x + 2][y], spherePoints[x + 2][y + 1]);
					}
					else
					{
						AddQuad(spherePoints[x][y], spherePoints[x][0], spherePoints[x + 2][y], spherePoints[x + 2][0]);
					}
				}
			}
			else
			{
				for (int y = 0; y < spherePoints[x].size(); y++)
				{
					if (y != spherePoints[x].size() - 1)
					{
						AddQuad(spherePoints[x + 2][y], spherePoints[x + 2][y + 1], spherePoints[x][y], spherePoints[x][y + 1]);
					}
					else
					{
						AddQuad(spherePoints[x + 2][y], spherePoints[x + 2][0], spherePoints[x][y], spherePoints[x][0]);
					}
				}
			}
		}
	}
	else
	{

	}

	//draw the tris for the top and bottom
	for (int x = 0; x < spherePoints[spherePoints.size() - 1].size(); x++)
	{
		AddVertexPosition(bottomPoint);
		if (x == spherePoints[spherePoints.size() - 1].size() - 1)
		{
			AddVertexPosition(spherePoints[spherePoints.size() - 1][0]);
		}
		else
		{
			AddVertexPosition(spherePoints[spherePoints.size() - 1][x + 1]);
		}
		AddVertexPosition(spherePoints[spherePoints.size() - 1][x]);
	}
	for (int x = 0; x < spherePoints[spherePoints.size() - 2].size(); x++)
	{
		AddVertexPosition(spherePoints[spherePoints.size() - 2][x]);
		if (x == spherePoints[spherePoints.size() - 2].size() - 1)
		{
			AddVertexPosition(spherePoints[spherePoints.size() - 2][0]);
		}
		else
		{
			AddVertexPosition(spherePoints[spherePoints.size() - 2][x + 1]);
		}
		AddVertexPosition(topPoint);
	}

	//float fValue = 0.5f;
	////3--2
	////|  |
	////0--1
	//vector3 point0(-fValue, -fValue, fValue); //0
	//vector3 point1(fValue, -fValue, fValue); //1
	//vector3 point2(fValue, fValue, fValue); //2
	//vector3 point3(-fValue, fValue, fValue); //3

	//AddQuad(point0, point1, point3, point2);

	//Your code ends here
	CompileObject(a_v3Color);
}
コード例 #11
0
void MyPrimitive::GenerateCone(float a_fRadius, float a_fHeight, int a_nSubdivisions, vector3 a_v3Color)
{
	if (a_nSubdivisions < 3)
		a_nSubdivisions = 3;
	if (a_nSubdivisions > 360)
		a_nSubdivisions = 360;

	Release();
	Init();

	//Your code starts here
	vector3 topPoint(0.00f, a_fHeight / 2, 0.00f); //top vertex
	vector3 midPoint(0.00f, -(a_fHeight / 2), 0.00f); //mid-base vertex
	std::vector<vector3> basePoints; //base vertices
	for (int x = 0; x < a_nSubdivisions; x++)
	{
		//calculate vertex positions
		float angle = ((2 * PI) / a_nSubdivisions) * x;
		float x_Value = a_fRadius * sin(angle);
		float z_Value = a_fRadius * cos(angle);

		basePoints.push_back(vector3(x_Value, -(a_fHeight / 2), z_Value));
	}
	//create cone
	for (int x = 0; x < basePoints.size(); x++)
	{
		AddVertexPosition(topPoint);
		AddVertexPosition(basePoints[x]);
		if (x == basePoints.size() - 1)
		{
			AddVertexPosition(basePoints[0]);
		}
		else
		{
			AddVertexPosition(basePoints[x + 1]);
		}
	}
	//create base
	for (int x = 0; x < basePoints.size(); x++)
	{
		AddVertexPosition(midPoint);
		if (x == basePoints.size() - 1)
		{
			AddVertexPosition(basePoints[0]);
		}
		else
		{
			AddVertexPosition(basePoints[x + 1]);
		}
		AddVertexPosition(basePoints[x]);
	}

	//float fValue = 0.5f;
	////3--2
	////|  |
	////0--1
	//vector3 point0(-fValue, -fValue, fValue); //0
	//vector3 point1(fValue, -fValue, fValue); //1
	//vector3 point2(fValue, fValue, fValue); //2
	//vector3 point3(-fValue, fValue, fValue); //3

	//AddQuad(point0, point1, point3, point2);

	//Your code ends here
	CompileObject(a_v3Color);
}
コード例 #12
0
ファイル: JLEDObj.cpp プロジェクト: neattools/neattools
JFPoint JLEDObj::inputPoint(int n, JLinkObj& link) { 
  if (!n) return leftPoint(n, link, 0, 1);
  return topPoint(n, link, 1, igm-1);
}
コード例 #13
0
ファイル: JSInsObj.cpp プロジェクト: neattools/neattools
JFPoint JSInsObj::inputPoint(int n, JLinkObj& link) {
  if (n < IN_POS) return leftPoint(n, link, 0, IN_POS);
  return topPoint(n, link, IN_POS, IN_LAST-IN_POS);
}
コード例 #14
0
ファイル: JBSubObj.cpp プロジェクト: neattools/neattools
JFPoint JBSubObj::inputPoint(int n, JLinkObj& link) {
  if (n < IN_BEGIN) return leftPoint(n, link, 0, IN_BEGIN);
  return topPoint(n, link, IN_BEGIN, IN_LAST-IN_BEGIN);
}
コード例 #15
0
ファイル: J1DMObj.cpp プロジェクト: neattools/neattools
JFPoint J1DMObj::inputPoint(int n, JLinkObj& link) { 
     if (n < 2) return leftPoint(n, link, 0, 2);
     return topPoint(n, link, 2, 2);
}
コード例 #16
0
ファイル: JTimerObj.cpp プロジェクト: neattools/neattools
JFPoint JTimerObj::inputPoint(int n, JLinkObj& link) { 
  return topPoint(n, link, 0, IN_LAST);
}
コード例 #17
0
void CShapeRenderer::DrawCone(const CMat4& mat, float fButtomRadius, float fTopRadius, float fHeight, CColor coneColor, CColor bottomColor, CColor topColor, bool bSolid) const
{
    DrawCircle(mat, fButtomRadius, bottomColor, bSolid);
    CMat4 translateMat;
    translateMat.SetTranslate(CVec3(0, fHeight, 0));
    CMat4 topMat = mat * translateMat;
    DrawCircle(topMat, fTopRadius, topColor, bSolid);
    if (bSolid)
    {
        CVec3 center(mat[12], mat[13], mat[14]);
        CVec3 upDirection = mat.GetUpVec3();
        upDirection = upDirection * fHeight;
        CVec3 topCenter = center + upDirection;
        CVertexPC point;
        point.position = topCenter;
        point.color = coneColor;
        std::vector<unsigned short> indicesData;
        std::vector<CVertexPC> vertexData;
        vertexData.push_back(point);
        static const float fStepRadians = DegreesToRadians(15);
        for (float fRadian = 0; fRadian <= MATH_PI_DOUBLE; fRadian += fStepRadians)
        {
            CVec3 pos(fButtomRadius * sinf(fRadian), 0, fButtomRadius * cosf(fRadian));
            pos *= mat;
            point.position = pos;
            vertexData.push_back(point);
            if (vertexData.size() >= 3)
            {
                unsigned short index = (unsigned short)vertexData.size();
                indicesData.push_back(0);
                indicesData.push_back(index - 2);
                indicesData.push_back(index - 1);
            }
        }
        CRenderManager::GetInstance()->RenderTriangle(vertexData, indicesData, true);
    }
    else
    {
        CVertexPC startPos, endPos;
        startPos.color = coneColor;
        endPos.color = coneColor;
        CVec3 topPoint(fTopRadius, fHeight, 0);
        CVec3 buttomPoint(fButtomRadius, 0, 0);
        startPos.position = topPoint * mat;
        endPos.position = buttomPoint * mat;
        CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true);
        topPoint.X() *= -1;
        buttomPoint.X() *= -1;
        startPos.position = topPoint * mat;
        endPos.position = buttomPoint * mat;
        CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true);
        topPoint = CVec3(0, fHeight, fTopRadius);
        buttomPoint = CVec3(0, 0, fButtomRadius);
        startPos.position = topPoint * mat;
        endPos.position = buttomPoint * mat;
        CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true);
        topPoint.Z() *= -1;
        buttomPoint.Z() *= -1;
        startPos.position = topPoint * mat;
        endPos.position = buttomPoint * mat;
        CRenderManager::GetInstance()->RenderLine(startPos, endPos, 1.0f, true);
    }
}