Esempio n. 1
0
void ToolSelectPoly::endPoly()
{
	this->endPaint();

	this->isSelecting = false;

	if( this->poly != NULL ){
		if( this->poly->getCount() > 3 ){
			if( this->mode == ICC_LASMOS ){
				delete this->poly->removeTail();
				this->setSelection(this->poly,true,true,true);
			}
			else {
				GraphicsPath *path = new GraphicsPath();
				path->AddLines(this->poly->toArray(),this->poly->getCount());
				path->Outline();
				this->setSelection(path,true,this->isCtrl);
			}
		}
	}
	else {
		this->setSelection(NULL,true);
	}

	this->resetOldPath();

	delete this->poly;
	this->poly = NULL;
}
Esempio n. 2
0
void CQTTDemoView::MakeImagePath(GraphicsPath& path)
{
	path.Reset();
	REAL left		= 0;
	REAL top		= 0;
	REAL width		= 108;
	REAL height		= 78;
	PointF *pnt = new PointF[4];
	//
	pnt[0].X = left;
	pnt[0].Y = top;
	//
	pnt[1].X = left + width;
	pnt[1].Y = top;
	//
	pnt[2].X = left + width;
	pnt[2].Y = top + height;
	//
	pnt[3].X = left;
	pnt[3].Y = top + height;
	path.AddLines(pnt,4);
}
Esempio n. 3
0
void CQTTDemoView::MakeStarPath(GraphicsPath& path, int points, int innerRadius, int outerRadius)
{
	path.Reset();

	REAL phi = 2 * (REAL) atan(1.0f);	// 90 degrees
	REAL dPhi = 2 * phi / points;

	PointF * pnt = new PointF[points * 2];

	for (int i = 0; i < points; i++)
	{
		pnt[2 * i].X = (REAL) (innerRadius * sin(phi - dPhi));
		pnt[2 * i].Y = (REAL) (innerRadius * cos(phi - dPhi));
		pnt[2 * i + 1].X = (REAL) (outerRadius * sin(phi));
		pnt[2 * i + 1].Y = (REAL) (outerRadius * cos(phi));
		phi += 2 * dPhi;
	}
	path.AddLines(pnt, points * 2);
	path.CloseFigure();

	delete[] pnt;
}
Esempio n. 4
0
void CAngleLabel::SetRegion()
{
	PointF* pPt = m_ptary.GetData();

	PointF ptd[3];
	ptd[0] = pPt[1];
	ptd[1] = pPt[0];
	ptd[2] = pPt[2];

	Pen penDraw(Color(255, 0, 255, 0));
	penDraw.SetDashStyle(m_nDashStyle);
	penDraw.SetWidth((float)m_nWidth);
	
	GraphicsPath path;
	path.AddLines(ptd, m_nPtCount);

	path.Widen(&penDraw);
	path.Outline();

	m_Region.MakeEmpty();
	m_Region.Union(&path);
}
void CRevisionGraphWnd::DrawConnections (GraphicsDevice& graphics, const CRect& /*logRect*/, const CSize& offset)
{

	CArray<PointF> points;
	CArray<CPoint> pts;

	if(graphics.graphics)
		graphics.graphics->SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);

	float penwidth = 2*m_fZoomFactor<1? 1:2*m_fZoomFactor;
	Gdiplus::Pen pen(Color(0,0,0),penwidth);

	// iterate over all visible lines
	edge e;
	forall_edges(e, m_Graph)
	{
		// get connection and point position
		const DPolyline &dpl = this->m_GraphAttr.bends(e);

		points.RemoveAll();
		pts.RemoveAll();

		PointF pt;
		pt.X = (REAL)m_GraphAttr.x(e->source());
		pt.Y = (REAL)m_GraphAttr.y(e->source());

		points.Add(pt);

		ListConstIterator<DPoint> it;
		for(it = dpl.begin(); it.valid(); ++it)
		{
			pt.X =  (REAL)(*it).m_x;
			pt.Y =  (REAL)(*it).m_y;
			points.Add(pt);
		}

		pt.X = (REAL)m_GraphAttr.x(e->target());
		pt.Y = (REAL)m_GraphAttr.y(e->target());

		points.Add(pt);

		points[0] = this->cutPoint(e->source(), 1, points[0], points[1]);
		points[points.GetCount()-1] =  this->cutPoint(e->target(), 1, points[points.GetCount()-1], points[points.GetCount()-2]);
		// draw the connection

		for (int i = 0; i < points.GetCount(); ++i)
		{
			//CPoint pt;
			points[i].X = points[i].X * this->m_fZoomFactor - offset.cx;
			points[i].Y = points[i].Y * this->m_fZoomFactor - offset.cy;
			//pts.Add(pt);
		}

		if (graphics.graphics)
		{
			graphics.graphics->DrawLines(&pen, points.GetData(), (INT)points.GetCount());

		}
		else if (graphics.pSVG)
		{
			Color color;
			color.SetFromCOLORREF(GetSysColor(COLOR_WINDOWTEXT));
			graphics.pSVG->Polyline(points.GetData(), (int)points.GetCount(), Color(0,0,0), (int)penwidth);
		}
		else if (graphics.pGraphviz)
		{
			CString hash1 = _T("g") + m_logEntries[e->target()->index()].ToString().Left(g_Git.GetShortHASHLength());
			CString hash2 = _T("g") + m_logEntries[e->source()->index()].ToString().Left(g_Git.GetShortHASHLength());
			graphics.pGraphviz->DrawEdge(hash1, hash2);
		}

		//draw arrow
		double dx = points[1].X - points[0].X;
		double dy = points[1].Y - points[0].Y;

		double len = sqrt(dx*dx + dy*dy);
		dx = m_ArrowSize * m_fZoomFactor *dx /len;
		dy = m_ArrowSize * m_fZoomFactor *dy /len;

		double p1_x, p1_y, p2_x, p2_y;
		p1_x = dx * m_ArrowCos - dy * m_ArrowSin;
		p1_y = dx * m_ArrowSin + dy * m_ArrowCos;

		p2_x = dx * m_ArrowCos + dy * m_ArrowSin;
		p2_y = -dx * m_ArrowSin + dy * m_ArrowCos;

		//graphics.graphics->DrawLine(&pen, points[0].X,points[0].Y, points[0].X +p1_x,points[0].Y+p1_y);
		//graphics.graphics->DrawLine(&pen, points[0].X,points[0].Y, points[0].X +p2_x,points[0].Y+p2_y);
		GraphicsPath path;

		PointF arrows[5];
		arrows[0].X =  points[0].X;
		arrows[0].Y =  points[0].Y;

		arrows[1].X =  points[0].X + (REAL)p1_x;
		arrows[1].Y =  points[0].Y + (REAL)p1_y;

		arrows[2].X =  points[0].X + (REAL)dx*3/5;
		arrows[2].Y =  points[0].Y + (REAL)dy*3/5;

		arrows[3].X =  points[0].X + (REAL)p2_x;
		arrows[3].Y =  points[0].Y + (REAL)p2_y;

		arrows[4].X =  points[0].X;
		arrows[4].Y =  points[0].Y;

		path.AddLines(arrows, 5);
		path.SetFillMode(FillModeAlternate);
		if(graphics.graphics)
		{
			graphics.graphics->DrawPath(&pen, &path);
		}else if(graphics.pSVG)
		{
			graphics.pSVG->DrawPath(arrows, 5, Color(0,0,0), (int)penwidth, Color(0,0,0));
		}
	}
}
void CXTPFlowGraphPaintManager::RecalcConnectionLayout(CXTPFlowGraphDrawContext* /*pDC*/, CXTPFlowGraphConnection* pConnection)
{
	CXTPFlowGraphConnectionPoint* pFrom = pConnection->GetOutputPoint();
	CXTPFlowGraphConnectionPoint* pTo = pConnection->GetInputPoint();

	if (pFrom == NULL)
		return;

	CPoint ptFrom, ptTo;

	ptFrom = pFrom->GetNode()->GetLocation();
	ptFrom.x += pFrom->GetNode()->GetSize().cx;
	ptFrom.y += pFrom->m_rcPoint.CenterPoint().y;

	if (pTo != NULL)
	{
		ptTo = pTo->GetNode()->GetLocation();
		ptTo.y += pTo->m_rcPoint.CenterPoint().y;

		if (pTo->GetType() == xtpFlowGraphPointInputAndOutput)
		{
			if (ptFrom.x > ptTo.x)
				ptTo.x += pTo->GetNode()->GetSize().cx;
		}

		pConnection->m_ptInputPoint = ptTo;
	}
	else
	{
		ptTo = pConnection->m_ptInputPoint;
	}

	if (pFrom->GetType() == xtpFlowGraphPointInputAndOutput)
	{
		if (ptTo.x < ptFrom.x - pFrom->GetNode()->GetSize().cx / 2)
			ptFrom.x -= pFrom->GetNode()->GetSize().cx;
	}


	pConnection->m_ptOutputPoint = ptFrom;

	GraphicsPath* path = new GraphicsPath();

	XTPFlowGraphConnectorType type = pConnection->GetStyle() == -1 ? m_nConnectorType : (XTPFlowGraphConnectorType)pConnection->GetStyle();

	CPoint ptControlPoint = pConnection->GetControlPoint();

	if (type == xtpFlowGraphConnectorStraight)
	{
		if (ptControlPoint != CPoint(-1, -1))
		{
			Point pts[] = {Point(ptFrom.x, ptFrom.y), Point(ptControlPoint.x, ptControlPoint.y), Point(ptTo.x, ptTo.y) };

			path->AddLines(pts, 3);
		}
		else
		{
			path->AddLine(ptFrom.x, ptFrom.y, ptTo.x, ptTo.y);
		}
	}
	else
	{
		if (ptControlPoint != CPoint(-1, -1))
		{
			/*PointF pt[3] = {PointF((REAL)ptFrom.x, (REAL)ptFrom.y), PointF((REAL)pConnection->GetControlPoint().x, (REAL)pConnection->GetControlPoint().y),
			PointF((REAL)ptTo.x, (REAL)ptTo.y) };
			path->AddCurve(pt, 3);*/

			PointF pt2[4] = {PointF((REAL)ptFrom.x, (REAL)ptFrom.y),
				PointF((REAL)ptControlPoint.x, (REAL)ptFrom.y), PointF((REAL)ptControlPoint.x,  (REAL)ptTo.y),
				PointF((REAL)ptTo.x, (REAL)ptTo.y) };

			path->AddBeziers(pt2, 4);

		}
		else
		{
			PointF pt[4] = {PointF((REAL)ptFrom.x, (REAL)ptFrom.y), PointF((REAL)(ptFrom.x + ptTo.x) / 2, (REAL)ptFrom.y),
				PointF(REAL(ptFrom.x + ptTo.x) / 2, (REAL)ptTo.y), PointF((REAL)ptTo.x, (REAL)ptTo.y) };
			path->AddBeziers(pt, 4);
		}
	}


	SAFE_DELETE(pConnection->m_pPath);
	pConnection->m_pPath = path;

}
Esempio n. 7
0
void CMyDialog::DrawCloseButton(CDC *pDC,int enumStatus)
{
	Color clrStart,clrEnd,clrBorder,clrCloseMark;
	CRect rc;
	GetClientRect(rc);
	if (enumStatus==DTS_NORMAL)
	{
		clrStart=Color(231,231,231);
		clrEnd=Color(227,227,227);
		clrBorder=Color(158,158,158);
		clrCloseMark=Color(128,128,128);
		
		clrStart=Color(219,219,220);
	    clrEnd=Color(190,192,193);
	}
	else if (enumStatus==DTS_HOVER)
	{
		clrStart=Color(245,28,6);
		clrEnd=Color(207,9,7);
		clrBorder=Color(187,5,0);
		clrCloseMark=Color(255,255,255);
	}
	else// if (enumStatus==DTS_CLICKED)
	{
		clrStart=Color(207,9,7);	
		clrEnd=Color(245,28,6);
		clrBorder=Color(187,5,0);
		clrCloseMark=Color(255,255,255);
	}
	m_rcClose.SetRect(rc.right-36,1,rc.right-6,21);
	GraphicsPath path;
	int nRadius=4;
	Point point[5];
	point[0]=Point(m_rcClose.right,m_rcClose.bottom-nRadius);
	point[1]=Point(m_rcClose.right,m_rcClose.top);
	point[2]=Point(m_rcClose.left,m_rcClose.top);
	point[3]=Point(m_rcClose.left,m_rcClose.bottom);
	point[4]=Point(m_rcClose.right-nRadius,m_rcClose.bottom);
	path.AddLines(point,5);
	path.AddArc(m_rcClose.right-2*nRadius,m_rcClose.bottom-2*nRadius,2*nRadius,2*nRadius,0,90);
	LinearGradientBrush linGrBrush(
		Rect(m_rcClose.left,m_rcClose.top,m_rcClose.Width(),m_rcClose.Height()),
		clrStart,
		clrEnd, 
		LinearGradientModeVertical);
	Graphics gs(pDC->m_hDC);
	gs.FillPath(&linGrBrush,&path);	
	CPoint ptCenter=m_rcClose.CenterPoint();
	if (enumStatus==DTS_CLICKED)
	{
		ptCenter.Offset(1,1);
	}
	CPen penMark(PS_SOLID,2,clrCloseMark.ToCOLORREF());
	CPen *pOldPen=pDC->SelectObject(&penMark);
	pDC->MoveTo(ptCenter.x-5,ptCenter.y-5);
	pDC->LineTo(ptCenter.x+5,ptCenter.y+5);
	pDC->MoveTo(ptCenter.x-5,ptCenter.y+5);
	pDC->LineTo(ptCenter.x+5,ptCenter.y-5);

// 	CPen penBorder(PS_SOLID,1,clrBorder.ToCOLORREF());
// 	pDC->SelectObject(&penBorder);
// 	pDC->MoveTo(m_rcClose.left-1,m_rcClose.top);
// 	pDC->LineTo(m_rcClose.left-1,m_rcClose.bottom);
	pDC->SelectObject(pOldPen);
}