Beispiel #1
0
void
MFCArrangeView::DrawGridGraphics(Graphics &pdc, CRect &cbp)
{
	Metric *dm = (displayMetric?displayMetric:quaLink->QMetric());
//	pdc->SetBkColor(rgb_red);
	Pen	ltGrayPen(AlphaColor(255, rgb_ltGray), 1);
	Pen	mdGrayPen(AlphaColor(255, rgb_mdGray), 1);
	Pen	dkGrayPen(AlphaColor(255, rgb_dkGray), 1);

	long startTick = cbp.left/pixPerNotch;
	long endTick = cbp.right/pixPerNotch;
	short notchInc = 1;
	long notchPx = startTick*pixPerNotch;
	long tickCnt = 0;
	short tickPerNotch = 1;
//	cerr << "start tick" << startTick << ", end " << endTick << endl;

	MFCChannelView *fv =(MFCChannelView *)channeler->CR(0);
	MFCChannelView *ev =(MFCChannelView *)channeler->CR(channeler->NCR()-1);
	
	for (tickCnt=startTick; tickCnt<=endTick; tickCnt+=tickPerNotch, notchPx += pixPerNotch) {
		if (tickCnt % (dm->granularity*dm->beatsPerBar) == 0) {
			pdc.DrawLine(&dkGrayPen, notchPx, cbp.top, notchPx, cbp.bottom);
		} else if (tickCnt % dm->granularity == 0) {
			pdc.DrawLine(&mdGrayPen, notchPx, cbp.top, notchPx, cbp.bottom);
		} else {
//			pdc.DrawLine(&ltGrayPen, notchPx, cbp.top, notchPx, cbp.bottom);
		}

	}

	for (short i=0; i<quaLink->NChannel(); i++) {
		pdc.DrawLine(&dkGrayPen, cbp.left, Channel2Pix(i), cbp.right, Channel2Pix(i));
	}
}
Beispiel #2
0
void
MFCSequenceEditor::DrawGridGraphics(Graphics &pdc, CRect &cbp)
{
	Metric *dm = (displayMetric?displayMetric:NULL);
//	pdc->SetBkColor(rgb_red);
	Pen	ltGrayPen(Color(255, 200, 200, 200), 1);
	Pen	mdGrayPen(Color(255, 140, 140, 140), 1);
	Pen	dkGrayPen(Color(255, 80, 80, 80), 1);

	long startTick = cbp.left/pixPerNotch;
	long endTick = cbp.right/pixPerNotch;
	short notchInc = 1;
	long notchPx = startTick*pixPerNotch;
	long tickCnt = 0;
	short tickPerNotch = 1;

//	MFCChannelView *fv =(MFCChannelView *)channeler->CR(0);
//	MFCChannelView *ev =(MFCChannelView *)channeler->CR(channeler->NCR()-1);

	for (tickCnt=startTick; tickCnt<=endTick; tickCnt+=tickPerNotch, notchPx += pixPerNotch) {
		Pen		*gridPen;
		if (tickCnt % (dm->granularity*dm->beatsPerBar) == 0) {
			gridPen = &dkGrayPen;
		} else if (tickCnt % dm->granularity == 0) {
			gridPen = &mdGrayPen;
		} else {
			gridPen = &ltGrayPen;
		}
		pdc.DrawLine(gridPen, notchPx, cbp.top, notchPx, cbp.bottom);
	}
	for (short i=0; i<NHorizontalPix(); i++) {
		pdc.DrawLine(&dkGrayPen, cbp.left, HorizontalPix(i), cbp.right, HorizontalPix(i));
	}
}
Beispiel #3
0
BOOL GDIPluseExt::DrawRect(Graphics &gp,CRect rect,Color linecolor,REAL nbold)
{
	Pen solipen(linecolor,nbold);
	gp.DrawLine(&solipen,Point(rect.left,rect.top),Point(rect.left,rect.bottom));                    //纵向左轴
	gp.DrawLine(&solipen,Point(rect.left,rect.top),Point(rect.right ,rect.top));                       //水平上端轴
	gp.DrawLine(&solipen,Point(rect.right,rect.top),Point(rect.right ,rect.bottom));               //纵向右轴
	gp.DrawLine(&solipen,Point(rect.left,rect.bottom),Point(rect.right,rect.bottom));            //水平下轴
	return TRUE;
}
Beispiel #4
0
/*
** Draws a bevel inside the given area
*/
void Meter::DrawBevel(Graphics& graphics, const Rect& rect, const Pen& light, const Pen& dark)
{
    int l = rect.GetLeft();
    int r = rect.GetRight() - 1;
    int t = rect.GetTop();
    int b = rect.GetBottom() - 1;

    graphics.DrawLine(&light, l,     t,     l,     b);
    graphics.DrawLine(&light, l,     t,     r,     t);
    graphics.DrawLine(&light, l + 1, t + 1, l + 1, b - 1);
    graphics.DrawLine(&light, l + 1, t + 1, r - 1, t + 1);
    graphics.DrawLine(&dark,  l,     b,     r,     b);
    graphics.DrawLine(&dark,  r,     t,     r,     b);
    graphics.DrawLine(&dark,  l + 1, b - 1, r - 1, b - 1);
    graphics.DrawLine(&dark,  r - 1, t + 1, r - 1, b - 1);
}
void CToolRegularRuler::DrawRulerMarks(Graphics& graph)
{
	int nNumber = 0;
	int nbegin = m_rcHot.left + 10;
	int nend = m_rcHot.right - 10;

	CString strNumber;
	Font fontNumber(L"Arial", 10);
	SolidBrush brush(Color::Black);
	StringFormat format;
	format.SetAlignment(StringAlignmentCenter);

	Pen penDraw(Color::Black, 1);
	PointF ptBegin((float)nbegin, m_rcHot.top + 1.0f);
	PointF ptEnd = ptBegin;
	graph.SetTextRenderingHint(TextRenderingHintAntiAlias);

	for(int i = nbegin; i < nend; i+= 10)
	{
		ptEnd.X = (float)i;
		ptBegin.X = (float)i;
		if((i - nbegin) % 100 == 0)
		{
			ptEnd.Y = ptBegin.Y + 30;
			graph.DrawLine(&penDraw, ptBegin, ptEnd);
			nNumber = (i - nbegin) / 100;
			strNumber.Format(_T("%d"), nNumber);
			
			graph.DrawString(strNumber, strNumber.GetLength(), &fontNumber, ptEnd, &format, &brush);
		}
		else if((i - nbegin) % 50 == 0)
		{
			ptEnd.Y = ptBegin.Y + 20;
			graph.DrawLine(&penDraw, ptBegin, ptEnd);
		}
		else
		{
			ptEnd.Y = ptBegin.Y + 10;
			graph.DrawLine(&penDraw, ptBegin, ptEnd);
		}
	}
}
void Bullet::draw(Graphics& graphics)
{
	postion = postion + velocity;
	int num = (sizeof(bLines) / sizeof(*bLines));
	graphics.SetColor(RGB(200,100,200));
	for(int count = 0; count < num; count ++){
		Vector2D first = bLines[count] + postion;
		Vector2D second = bLines[(count+1)%num] + postion;
		graphics.DrawLine(first.x, first.y, second.x, second.y);
	}
}
/*
** Draws the meter on the double buffer
**
*/
bool CMeterRoundLine::Draw(Graphics& graphics)
{
	if (!CMeter::Draw(graphics)) return false;

	// Calculate the center of for the line
	int x = GetX();
	int y = GetY();
	double cx = x + m_W / 2.0;
	double cy = y + m_H / 2.0;

	double lineStart = ((m_CntrlLineStart) ? m_LineStartShift * m_Value : 0) + m_LineStart;
	double lineLength = ((m_CntrlLineLength) ? m_LineLengthShift * m_Value : 0) + m_LineLength;

	// Calculate the end point of the line
	double angle = ((m_CntrlAngle) ? m_RotationAngle * m_Value : m_RotationAngle) + m_StartAngle;
	double e_cos = cos(angle);
	double e_sin = sin(angle);

	REAL sx = (REAL)(e_cos * lineStart + cx);
	REAL sy = (REAL)(e_sin * lineStart + cy);
	REAL ex = (REAL)(e_cos * lineLength + cx);
	REAL ey = (REAL)(e_sin * lineLength + cy);

	if (m_Solid)
	{
		REAL startAngle = (REAL)(CONVERT_TO_DEGREES(m_StartAngle));
		REAL sweepAngle = (REAL)(CONVERT_TO_DEGREES(m_RotationAngle * m_Value));

		// Calculate the start point of the line
		double s_cos = cos(m_StartAngle);
		double s_sin = sin(m_StartAngle);

		//Create a path to surround the arc
		GraphicsPath path;
		path.AddArc((REAL)(cx - lineStart), (REAL)(cy - lineStart), (REAL)(lineStart * 2.0), (REAL)(lineStart * 2.0), startAngle, sweepAngle);
		path.AddLine((REAL)(lineStart * s_cos + cx), (REAL)(lineStart * s_sin + cy), (REAL)(lineLength * s_cos + cx), (REAL)(lineLength * s_sin + cy));
		path.AddArc((REAL)(cx - lineLength), (REAL)(cy - lineLength), (REAL)(lineLength * 2.0), (REAL)(lineLength * 2.0), startAngle, sweepAngle);
		path.AddLine(ex, ey, sx, sy);

		SolidBrush solidBrush(m_LineColor);
		graphics.FillPath(&solidBrush, &path);
	}
	else
	{
		Pen pen(m_LineColor, (REAL)m_LineWidth);
		graphics.DrawLine(&pen, sx, sy, ex, ey);
	}

	return true;
}
Beispiel #8
0
void
MFCArrangeView::DrawCursor(Graphics &pdc, CRect &clipBox)
{
//	cerr << "curser " << clipBox.left << ", " << cursorPx <<  ", " << clipBox.right << endl;
	bool	doDraw = true;
	if (clipBox != NULL) {
		if (clipBox.left > cursorPx || cursorPx > clipBox.right) {
			doDraw = false;
		}
	}
	if (doDraw) {
		Pen	cursorPen(AlphaColor(255, rgb_purple), 1);
		pdc.DrawLine(&cursorPen, cursorPx, clipBox.top, cursorPx, clipBox.bottom);
	}
}
void TargetShip::drawShip(Graphics& graphics, Bullet* bullet)
{
	checkIfAlive(bullet);

	if(isAlive){
		position = position + velocity;
		graphics.SetColor(RGB(0,15,230));
		const unsigned int numLines = sizeof(TargetShipPoints) / sizeof(*TargetShipPoints);
		for(unsigned int x = 0; x < numLines; x++){
			const Vector2D& first = TargetShipPoints[x] + position ;
			const Vector2D& second = TargetShipPoints[(x+1) % numLines] + position;
			graphics.DrawLine(first.x, first.y,
				second.x, second.y);
		}
	}
	graphics.SetColor(RGB(100,175,230));
}
Beispiel #10
0
void DrawLine(const Point &pt1, const Point &pt2, HDC hdcPaint, DashStyle dashStyle, Color clr, REAL width)
{
    Pen*         myPen;
    Graphics*    myGraphics;
    myPen = new Pen(clr, width);
    if(myPen)
    {
        myPen->SetDashStyle(dashStyle);
        myGraphics = new Graphics(hdcPaint);
        if(myGraphics)
        {
            myGraphics->DrawLine(myPen, pt1, pt2);
            delete myGraphics;
        }
        delete myPen;
    }
}
void CToolRegularRuler::DrawHotShape(Graphics& graph)
{
	SolidBrush sbrush(Color::Green);
	Pen penDraw(Color::Blue, 2);
	penDraw.SetDashStyle(DashStyleDot);

	PointF pt((m_ptary[0].X + m_ptary[1].X) / 2, m_ptary[0].Y);
	
	graph.DrawLine(&penDraw, pt, m_HotPts.ptRotate);
	graph.FillEllipse(&sbrush, m_HotPts.ptRotate.X - HOTINTERVAL,
					  m_HotPts.ptRotate.Y - HOTINTERVAL,
					  2.0 * HOTINTERVAL, 2.0 * HOTINTERVAL);

	penDraw.SetDashStyle(DashStyleDash);
	penDraw.SetColor(Color::Red);

	graph.DrawRectangle(&penDraw, m_rcGrip.left, m_rcGrip.top, m_rcGrip.Width(), m_rcGrip.Height());
}
Beispiel #12
0
/*
** Draws the meter on the double buffer
**
*/
bool CMeterLine::Draw(Graphics& graphics)
{
	int maxSize = m_GraphHorizontalOrientation ? m_H : m_W;
	if (!CMeter::Draw(graphics) || maxSize <= 0) return false;

	double maxValue = 0.0;
	int counter = 0;

	// Find the maximum value
	if (m_Autoscale)
	{
		double newValue = 0;
		std::vector< std::vector<double> >::const_iterator i = m_AllValues.begin();
		counter = 0;
		for (; i != m_AllValues.end(); ++i)
		{
			double scale = m_ScaleValues[counter];
			std::vector<double>::const_iterator j = (*i).begin();
			for (; j != (*i).end(); ++j)
			{
				double val = (*j) * scale;
				newValue = max(newValue, val);
			}
			++counter;
		}

		// Scale the value up to nearest power of 2
		if (newValue > DBL_MAX / 2.0)
		{
			maxValue = DBL_MAX;
		}
		else
		{
			maxValue = 2.0;
			while (maxValue < newValue)
			{
				maxValue *= 2.0;
			}
		}
	}
	else
	{
		if (m_Measure)
		{
			maxValue = m_Measure->GetMaxValue();

			std::vector<CMeasure*>::const_iterator i = m_Measures.begin();
			for (; i != m_Measures.end(); ++i)
			{
				double val = (*i)->GetMaxValue();
				maxValue = max(maxValue, val);
			}
		}

		if (maxValue == 0.0)
		{
			maxValue = 1.0;
		}
	}

	int x = GetX();
	int y = GetY();

	// Draw the horizontal lines
	if (m_HorizontalLines)
	{
		// Calc the max number of lines we should draw
		int maxLines = m_H / 4;	// one line per 4 pixels is max
		int numOfLines;

		// Check the highest power of 2 that fits in maxLines
		int power = 2;
		while (power < maxLines)
		{
			power *= 2;
		}

		numOfLines = ((int)maxValue % power) + 1;

		Pen pen(m_HorizontalColor);

		REAL Y;
		for (int j = 0; j < numOfLines; ++j)
		{
			Y = (REAL)((j + 1) * m_H / (numOfLines + 1));
			Y = y + m_H - Y - 1;
			graphics.DrawLine(&pen, (REAL)x, Y, (REAL)(x + m_W - 1), Y);	// GDI+
		}
	}

	// Draw all the lines

	if (m_GraphHorizontalOrientation)
	{
		const REAL W = m_W - 1.0f;
		counter = 0;
		std::vector< std::vector<double> >::const_iterator i = m_AllValues.begin();
		for (; i != m_AllValues.end(); ++i)
		{
			// Draw a line
			REAL X, oldX;

			const double scale = m_ScaleValues[counter] * W / maxValue;

			int pos = m_CurrentPos;

			oldX = (REAL)((*i)[pos] * scale);
			oldX = min(oldX, W);
			oldX = max(oldX, 0.0f);
			oldX = x + (m_GraphStartLeft ? oldX : W - oldX);

			// Cache all lines
			GraphicsPath path;
		
			if (!m_Flip)
			{
				for (int j = y + 1, R = y + m_H; j < R; ++j)
				{
					++pos;
					if (pos >= m_H) pos = 0;

					X = (REAL)((*i)[pos] * scale);
					X = min(X, W);
					X = max(X, 0.0f);
					X = x + (m_GraphStartLeft ? X : W - X);

					path.AddLine(oldX, (REAL)(j - 1), X, (REAL)j);

					oldX = X;
				}
			}
			else
			{
				for (int j = y + m_H, R = y + 1; j > R; --j)
				{
					++pos;
					if (pos >= m_H) pos = 0;

					X = (REAL)((*i)[pos] * scale);
					X = min(X, W);
					X = max(X, 0.0f);
					X = x + (m_GraphStartLeft ? X : W - X);

					path.AddLine(oldX, (REAL)(j - 1), X, (REAL)(j - 2));

					oldX = X;
				}
			}

			// Draw cached lines
			Pen pen(m_Colors[counter], (REAL)m_LineWidth);
			pen.SetLineJoin(LineJoinBevel);
			graphics.DrawPath(&pen, &path);

			++counter;
		}
	}
	else
	{
		const REAL H = m_H - 1.0f;
		counter = 0;
		std::vector< std::vector<double> >::const_iterator i = m_AllValues.begin();
		for (; i != m_AllValues.end(); ++i)
		{
			// Draw a line
			REAL Y, oldY;

			const double scale = m_ScaleValues[counter] * H / maxValue;

			int pos = m_CurrentPos;

			oldY = (REAL)((*i)[pos] * scale);
			oldY = min(oldY, H);
			oldY = max(oldY, 0.0f);
			oldY = y + (m_Flip ? oldY : H - oldY);

			// Cache all lines
			GraphicsPath path;
		
			if (!m_GraphStartLeft)
			{
				for (int j = x + 1, R = x + m_W; j < R; ++j)
				{
					++pos;
					if (pos >= m_W) pos = 0;

					Y = (REAL)((*i)[pos] * scale);
					Y = min(Y, H);
					Y = max(Y, 0.0f);
					Y = y + (m_Flip ? Y : H - Y);

					path.AddLine((REAL)(j - 1), oldY, (REAL)j, Y);

					oldY = Y;
				}
			}
			else
			{
				for (int j = x + m_W, R = x + 1; j > R; --j)
				{
					++pos;
					if (pos >= m_W) pos = 0;

					Y = (REAL)((*i)[pos] * scale);
					Y = min(Y, H);
					Y = max(Y, 0.0f);
					Y = y + (m_Flip ? Y : H - Y);

					path.AddLine((REAL)(j - 1), oldY, (REAL)(j - 2), Y);

					oldY = Y;
				}
			}

			// Draw cached lines
			Pen pen(m_Colors[counter], (REAL)m_LineWidth);
			pen.SetLineJoin(LineJoinBevel);
			graphics.DrawPath(&pen, &path);

			++counter;
		}
	}

	return true;
}
Beispiel #13
0
unsigned int tabs_impl_win32::draw_tab(Graphics &g, unsigned int a_X, unsigned int a_Y, unsigned int a_Index){
	if(a_X > get_size().m_Width) return a_X;

	Color c = Color(255, 44, 61, 91);

	if(m_ActiveTab == a_Index) c = Color(255, 255, 232, 166);
	else if(m_HoverTab == a_Index) c = Color(255, 100, 110, 117);

	SolidBrush b(c);
	SolidBrush t(m_ActiveTab == a_Index ? Color(255, 255, 248, 225) : c);
	SolidBrush black(Color(255, 0, 0, 0));
	SolidBrush white(Color(255, 255, 255, 255));
	SolidBrush closeDark(Color(255, 117, 99, 61));
	SolidBrush closeLight(Color(255, 206, 212, 221));
	Pen p(Color(255, 0, 0, 0));
	Font font(L"Tahoma", 10);
	PointF origin(a_X + 5, a_Y + 3), originX(a_X + 10, a_Y + 5);

	RectF bb, close;

	std::string s = this->get_child_name(a_Index);
	std::wstring w(s.begin(), s.end());

	// draw tab
	g.MeasureString(w.c_str(), w.size(), &font, origin, &bb);
	bb.Height = 25;
	originX.X += bb.Width + 5;
	close = RectF(originX.X, originX.Y, 15.f, 15.f);
	RectF::Union(bb, bb, close);

	GraphicsPath gp;

	// draw header
	int x = a_X; int y = a_Y;
	int headerHeight = get_size().m_Height / 2;
	int arcSize = 10;
	int width = bb.Width;

	// top part = arc
	gp.AddLine(x, y + headerHeight + arcSize / 2, x, y + arcSize / 2);
	gp.AddArc(x, y, arcSize, arcSize, 180.f, 90.f);
	gp.AddArc(x + width, y, arcSize, arcSize, 270.f, 90.f);
	gp.AddLine(x + width + arcSize, y + arcSize / 2, x + width + arcSize, y + headerHeight + arcSize / 2);

	g.FillPath(&t, &gp);

	bb.Width += arcSize;

	// bottom = rect
	g.FillRectangle(&b, a_X, a_Y + headerHeight, bb.Width, 10.f);

	g.DrawString(w.c_str(), w.size(), &font, origin, m_ActiveTab == a_Index ? &black : &white);

	// draw close button
	if(m_ActiveTab == a_Index || m_HoverTab == a_Index){
		SolidBrush closeBrush(Color(190, 40, 30));
		
		Pen hoverPen(Color::White, 2);
		Pen regularPen(Color(20, 20, 20), 2);

		Pen *p = &regularPen;

		float shrink = 4;

		RectF lines = close;
		lines.X += shrink;
		lines.Y += shrink;
		lines.Width -= shrink * 2;
		lines.Height -= shrink * 2;

		// just get mouse position here instead of passing it through
		// from wm_mousemove
		POINT mouse;
		GetCursorPos(&mouse);
		ScreenToClient(m_hWndTabs, &mouse);
		if(close.Contains(mouse.x, mouse.y)) {
			g.FillEllipse(&closeBrush, close);
			p = &hoverPen;
		}

		g.DrawLine(p, lines.X, lines.Y, lines.X + lines.Width, lines.Y + lines.Height);
		g.DrawLine(p, lines.X + lines.Width, lines.Y, lines.X, lines.Y + lines.Height);
	}

	m_VisibleTabs[a_Index].m_BoundingBox = bb;
	m_VisibleTabs[a_Index].m_CloseBox    = close;

	return bb.Width;
}
void MyPaint_Mem(HDC my_hdc)
{
	Graphics *mygraphics;
	mygraphics = new Graphics(my_hdc);
	mygraphics->SetSmoothingMode(SmoothingModeAntiAlias);
	Pen *myRectangle_pen;
	Pen * my_inline_pen;

	Pen * CurePen;

	SolidBrush *BlackBrush;
	

	myRectangle_pen = new Pen(Color(255,0,255,255));
	my_inline_pen = new Pen(Color(255,220,220,220));

	REAL dashValues[2] = {5, 5};
	//Pen blackPen(Color(255, 0, 0, 0), 5);
	my_inline_pen->SetDashPattern(dashValues, 2);


	CurePen = new Pen(Graphic_Color[1],3.0f);
	PointF      pointF(0, 0);

	BlackBrush =new SolidBrush(Color(255,0,0,0));
	mygraphics->FillRectangle(BlackBrush,X_ORIGIN,Y_ORIGIN,X_WIDTH,Y_HIGHT);
	mygraphics->DrawRectangle(myRectangle_pen,X_ORIGIN,Y_ORIGIN,X_WIDTH,Y_HIGHT);

	SolidBrush *Static_blackground_Brush;
	Pen *mystaticRectangle_pen;
	mystaticRectangle_pen = new Pen(Color(255,0,0,0),2.0f);
	Static_blackground_Brush =new SolidBrush(Color(255,187,187,187));
	mygraphics->FillRectangle(Static_blackground_Brush,0,window_hight - 120,window_width,120);
	mygraphics->DrawRectangle(mystaticRectangle_pen,2,window_hight - 110,window_width-15,110 -30);

	SolidBrush  time_brush(Color(255, 225, 225, 225));
	FontFamily  fontFamily(_T("Times New Roman"));
	Gdiplus::Font        time_font(&fontFamily, 18, FontStyleRegular, UnitPixel);
	for(int i=0;i<x_line_scale;i++)				//画网格线
	{
		mygraphics->DrawLine(my_inline_pen,X_ORIGIN+(X_WIDTH/x_line_scale)*(i+1),Y_ORIGIN,X_ORIGIN+(X_WIDTH/x_line_scale)*(i+1),Y_ORIGIN + Y_HIGHT);
		CString strTime ;
		wchar_t temp_char[200];
		//time_t test = old_early_time;
		//CTime timeTest(test);
		time_t test ;
		CTime timeTest;

		switch(scale_type)
		{
		case _6_min:
			break;
		case _1_hour:
			test = old_early_time + i*600;

			timeTest = test ;

			strTime = timeTest.Format("%Y/%m/%d\r\n %H:%M:%S");
			pointF.X = X_ORIGIN - 40 + i*(X_WIDTH/x_line_scale);
			pointF.Y = Y_ORIGIN+Y_HIGHT + 10;
			mygraphics->DrawString(strTime, -1, &time_font, pointF, &time_brush);
			//old_early_time
			break;
		case _4_hour:
			break;
		case _12_hour:
			break;
		case _1_day:
			break;
		}

	}
	SolidBrush  unit_brush(Graphic_Color[1]);
	FontFamily  UnitfontFamily(_T("Times New Roman"));
	Gdiplus::Font        unitfont(&UnitfontFamily, 18, FontStyleRegular, UnitPixel);
	for(int i=0;i<=y_line_scale;i++)				//画网格线
	{
		CString Unit_value;
		if(i!=y_line_scale)
		mygraphics->DrawLine(my_inline_pen,X_ORIGIN,Y_ORIGIN+(Y_HIGHT/y_line_scale)*(1+i),X_WIDTH + X_ORIGIN,Y_ORIGIN+(Y_HIGHT/y_line_scale)*(1+i));

		if(i!=y_line_scale)
		Unit_value.Format(_T("%d"),(Total_SCALE/y_line_scale)*(y_line_scale-i));// = timeTest.Format("%Y/%m/%d\r\n %H:%M:%S");
		else
		Unit_value.Format(_T("%d"),Min_Scale_value);
		pointF.X = X_ORIGIN - 30;
		pointF.Y = Y_ORIGIN+ i*(Y_HIGHT/y_line_scale);
		mygraphics->DrawString(Unit_value, -1, &unitfont, pointF, &unit_brush);
		//swprintf_s(temp_char,200,L"%d",i*5);
		//mygraphics->DrawString(temp_char, -1, &font, pointF, &brush);

	}
	for (int i=1;i<=14;i++)
	{
		CString temp_item;
		temp_item.Format(_T("%x"),i);
		temp_item = temp_item.MakeUpper();

		SolidBrush  static_item_brush(Graphic_Color[i]);
		FontFamily  UnitfontFamily(_T("Arial Black"));
		Gdiplus::Font        unitfont(&UnitfontFamily, 22, FontStyleRegular, UnitPixel);
		pointF.X = Static_Num_Rect[i].left;
		pointF.Y = Static_Num_Rect[i].top;
		mygraphics->DrawString(temp_item, -1, &unitfont, pointF, &static_item_brush);
	}
	

	CPointItem *first_item=NULL,*second_item=NULL,*third_item=NULL;
	first_item = m_pFirstItem;
	//********************************************
	//直线
	for (int i=0;i<60;i=i+1)
	{
		second_item=first_item->GetNext();
		if(second_item==NULL)
			break;
		CurePen->SetStartCap(LineCapArrowAnchor);
		CurePen->SetEndCap(LineCapRoundAnchor);
		mygraphics->DrawLine(CurePen,first_item->GetPoint().x,first_item->GetPoint().y,second_item->GetPoint().x,second_item->GetPoint().y);
		first_item = second_item;

	}
	//********************************************

#if 0
	for (int i=0;i<60;i=i+2)
	//for (int i=0;i<m_monitor_block.index - 1;i=i+2)	//画贝塞尔曲线,使得线条平滑;3个点一画;		TEST
	//for (int i=0;i<Total_count-1;i=i+2)	//画贝塞尔曲线,使得线条平滑;3个点一画;
	{
		second_item=first_item->GetNext();
		third_item = second_item->GetNext();
		if(second_item==NULL)
			break;
		if(third_item == NULL)
		{
			first_item = second_item;
			break;
		}
		//mygraphics->DrawCurve(CurePen,, 3, 1.5f);
		//取3个点给画曲线的GDI函数;
		Point myPointArray[] =
		{Point(first_item->GetPoint().x,first_item->GetPoint().y),
		Point(second_item->GetPoint().x,second_item->GetPoint().y),
		Point(third_item->GetPoint().x,third_item->GetPoint().y)};

		CurePen->SetStartCap(LineCapArrowAnchor);
		CurePen->SetEndCap(LineCapRoundAnchor);


			mygraphics->DrawCurve(CurePen,myPointArray, 3, 1.0f);
			first_item = third_item;

		
	}
#endif

	delete CurePen;
	delete mygraphics;
	delete myRectangle_pen;
	delete my_inline_pen;
	delete BlackBrush;
}
Beispiel #15
0
void cGameStateChart::render(Graphics &con){
 
  //Clear buffer and draw graphics
  con.ClearBuffer(0, 0, 0, 0);
  con.BeginDrawing();
  GRAPHIC_IMAGE gi;

  CGameData *pData = CGameData::Instance();

  //draw chart stuff
  gi = g_Sprite.GetSpriteData(48);//white square for chart background
  gi.scale = 5.05;
  con.RenderGraphicModulate(262 + pData->m_shockX, 134 + pData->m_shockX, gi, m_red, m_green, m_blue);

  //chart highlights and reference lines
  con.DrawRect(262, 134, 762, 634,255, 0, 0);
  con.DrawLine(512, 134, 512, 634, 0, 0, 120);
  con.DrawLine(262, 384, 762, 384, 0, 0, 120);
  
  //draw user interface on right side of chart
  con.DrawLine(780, 134, 800, 134, 0, 255, 0);//horizontal tick marks
  con.DrawLine(780, 249, 800, 249, 0, 255, 0);
  con.DrawLine(780, 269, 800, 269, 0, 255, 0);
  con.DrawLine(780, 384, 800, 384, 0, 255, 0);
  con.DrawLine(790, 134, 790, 249, 0, 255, 0);//vertical lines
  con.DrawLine(790, 269, 790, 384, 0, 255, 0);

  //draw range
  con.Draw2DTextValue("SCALE", (float)m_chartScale[m_chartScaleIndex], F_V20, 780, 249, 0, 255, 0);

  //zoom in and zoom out
  if(g_Global.g_mouse.x > 806 && g_Global.g_mouse.x < 1006 
    && ::GetActiveWindow() == g_hWnd){
    if(g_Global.g_mouse.y > 134 && g_Global.g_mouse.y < 249 && m_chartScaleIndex < 4){//zoom in
      gi = g_Sprite.GetSpriteData(30);
      con.RenderGraphicModulate(811,139,gi,m_red, m_green, m_blue);
    }
    else if(g_Global.g_mouse.y > 269 && g_Global.g_mouse.y < 384 && m_chartScaleIndex > 0){//zoom out
      gi = g_Sprite.GetSpriteData(29);
      con.RenderGraphicModulate(811,274,gi,m_red, m_green, m_blue);
    }
  }

  //display ship and sub data
//  CGameData *pData = CGameData::Instance();
  float posX = 0, posY = 0;
  float range = (float)m_chartScale[m_chartScaleIndex];

  //ships
  for(int i = 0; i < pData->m_targets.size(); ++i){
    posX = (pData->m_targets[i].m_posX - pData->m_Player.m_posX) * 250/range;
    posY = (pData->m_targets[i].m_posY - pData->m_Player.m_posY) * 250/range;

    if(pData->m_targets[i].m_bAlive == true &&  posX >= -250 && posX <= 250 && posY >= -250 && posY <= 250)//{
      con.DrawCircle(512 + posX,384 - posY, 255,0,0,(pData->m_targets[i].m_length/500) * (20000/(range * 2) ));
  }

  //torpedo
  for(int i = 0; i < pData->m_torpedos.size(); ++i){
    posX = (pData->m_torpedos[i].GetPositionX()- pData->m_Player.m_posX) * 250/range;
    posY = (pData->m_torpedos[i].GetPositionY() - pData->m_Player.m_posY) * 250/range;

    if(pData->m_torpedos[i].IsRunning() == true &&  posX >= -250 && posX <= 250 && posY >= -250 && posY <= 250)//{
      con.DrawCircle(512 + posX,384 - posY, 0, 0, 0,2 * (20000/(range * 8)));
  }

  //draw scope bearing line to indicate which target is being viewed
  float s = 0, t = 0;
  s = 512 + 250 * cos(pData->ConvertDegreesToRadians( pData->m_Player.m_heading + pData->m_scopeRotateAngle/5.689));
  t = 384 - 250 * sin(pData->ConvertDegreesToRadians( pData->m_Player.m_heading + pData->m_scopeRotateAngle/ 5.689));
  con.DrawLine(512,384,s,t, 0, 255,0);

  //draw sub in center of chart
  gi = g_Sprite.GetSpriteData(57);
  gi.rotationAngle =  pData->m_Player.m_heading * 3.141592654/180;
  gi.scale = 1;// (1000/range);
  con.RenderGraphicModulate(512 - (gi.width/2)* gi.scale, 384 - (gi.height/2) * gi.scale, gi, m_red, m_green, m_blue);

  //display short cuts
  gi = g_Sprite.GetSpriteData(36);//sonar
  con.RenderGraphicModulate(10,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(37);//radar
  con.RenderGraphicModulate(120,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(38);//conn selected
  con.RenderGraphicModulate(230,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(39);//fire control
  con.RenderGraphicModulate(694,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(40);//damage control
  con.RenderGraphicModulate(804,10,gi,m_red, m_green, m_blue);
  gi = g_Sprite.GetSpriteData(47);//chart
  con.RenderGraphicModulate(914,10,gi,m_red, m_green, m_blue);

  //draw tool tips for short cuts
  if(g_Global.g_mouse.y > 10 && g_Global.g_mouse.y < 130){
    //if(g_Global.g_mouse.x > 10 & g_Global.g_mouse.x < 104)
    //  con.Draw2DText("Sonar", F_V20, 20, 10, 0,255,255);
    //else if(g_Global.g_mouse.x > 120 & g_Global.g_mouse.x < 207)
    //  con.Draw2DText("Radar", F_V20, 130, 10, 0,255,255);
    if(g_Global.g_mouse.x > 230 & g_Global.g_mouse.x < 310)
      con.Draw2DText("Conn", F_V20, 240, 10, 0,255,255);
    //else if(g_Global.g_mouse.x > 694 & g_Global.g_mouse.x < 794)
    //  con.Draw2DText("Torpedos", F_V20, 704, 10, 0,255,255);
    //else if(g_Global.g_mouse.x > 804 & g_Global.g_mouse.x < 904)
    //  con.Draw2DText("Damage", F_V20, 814, 10, 0,255,255);
  }

  // SMJ - 11/13/2007 Draw FPS on screen
  if(g_Global.g_bDisplayFramerate == true)
      con.Draw2DText(g_Global.g_strFPS, F_V20, 0, 720, 0,255,255);
  //con.Draw2DTextValue("subX", (long)pData->m_Player.m_posX, F_V20, 0, 140, 255, 0, 0);
  //con.Draw2DTextValue("subY", (long)pData->m_Player.m_posY, F_V20, 0, 160, 255, 0, 0);
  //con.Draw2DTextValue("T", (long)pData->m_torpedos.size(), F_V20, 0, 200, 255, 0, 0);
  
  con.Draw2DTextValue("BRG", (long)( (float)pData->m_scopeRotateAngle/5.689),F_V20,484, 640, 255, 255, 0);
  con.Draw2DTextValue("Damage", (long)( (float)pData->m_Player.m_damage),F_V20,474, 660, 255, 0, 0);

  //display target data
  //for(int i = 0; i < pData->m_targets.size(); ++i){
  ///  con.Draw2DTextValue("X", (long)pData->m_targets[i].m_posX, F_V20, 0, 220 + (i * 20), 255, 0, 0);
  //  con.Draw2DTextValue("Y", (long)pData->m_targets[i].m_posY, F_V20, 120, 220 + (i * 20), 255, 0, 0);
  //}

  con.EndDrawing ();
  con.Present();
}
void MyPaint_Mem(HDC my_hdc)
{

	Graphics *mygraphics;
	mygraphics = new Graphics(my_hdc);
	mygraphics->SetSmoothingMode(SmoothingModeAntiAlias);
	Pen *myRectangle_pen;
	Pen * my_inline_pen;

	Pen * CurePen;

	SolidBrush *BlackBrush;


	myRectangle_pen = new Pen(Color(255,0,255,255));
	my_inline_pen = new Pen(Color(255,0,128,64));

	CurePen = new Pen(Color(255,0,255,0));

	m_interval = (m_interval++)%5;	//让其向左平移;


	if(runonce < 2)				//初始化时画背景图案;
	{
		runonce ++;
		//Image myImage(L"texture.BMP");
		//TextureBrush myTextureBrush(&myImage);
		//RECT newrect_now;
		//GetWindowRect(myhWnd,&newrect_now);
		//mygraphics->FillRectangle(&myTextureBrush, 0, 0, newrect_now.right, newrect_now.bottom);


		SolidBrush  brush(Color(255, 0, 0, 255));
		FontFamily  fontFamily(_T("Times New Roman"));
		Gdiplus::Font        font(&fontFamily, 24, FontStyleRegular, UnitPixel);
		PointF      pointF(40.0f, 600.0f);
		for(int i=0;i<=20;i=i+2)				//增加文字 %;
		{
			pointF.Y = 600;
			pointF.Y = pointF.Y - i*30;
			wchar_t temp_char[200];
			//swprintf_s(temp_char,200,L"%d%%",i*5);
			swprintf_s(temp_char,200,L"%d",i*5);
			mygraphics->DrawString(temp_char, -1, &font, pointF, &brush);
		}
		pointF.X = 200;
		pointF.Y = 650;
		//mygraphics->DrawString(L"CPU 使用率", -1, &font, pointF, &brush);

	}


	//BlackBrush =new SolidBrush(Color(255,0,0,0));
	BlackBrush =new SolidBrush(Color(255,0,0,0));
	mygraphics->FillRectangle(BlackBrush,100,10,1200,600);
	mygraphics->DrawRectangle(myRectangle_pen,100,10,1200,600);



	for(int i=0;i<=39;i++)				//画网格线
		mygraphics->DrawLine(my_inline_pen,100+line_interval*(i+1)-m_interval*6,10,100+line_interval*(i+1)-m_interval*6,610);

	for(int i=0;i<19;i++)				//画网格线
		mygraphics->DrawLine(my_inline_pen,100,10+line_interval*(1+i),1300,10+line_interval*(1+i));
#if 0
	CPointItem *first_item=NULL,*second_item=NULL;
	first_item = m_pFirstItem;
	for (int i=0;i<Total_count-1;i++)
	{
		second_item=first_item->GetNext();
		if(second_item==NULL)
			break;
		//mygraphics->DrawCurve(CurePen,, 3, 1.5f);
		//Point myPointArray[] =
		//{Point(first_item->GetPoint().x,first_item->GetPoint().y),Point(second_item->GetPoint().x,second_item->GetPoint().y)};
		//mygraphics->DrawCurve(CurePen,myPointArray, 2, 1.0f);
		//mygraphics->DrawLine(CurePen,first_item->GetPoint().x,first_item->GetPoint().y,second_item->GetPoint().x,second_item->GetPoint().y);
		first_item = second_item;
	}
#endif
#if 1
	CPointItem *first_item=NULL,*second_item=NULL,*third_item=NULL;
	first_item = m_pFirstItem;

	for (int i=0;i<Total_count-1;i=i+2)	//画贝塞尔曲线,使得线条平滑;3个点一画;
	{
		second_item=first_item->GetNext();
		third_item = second_item->GetNext();
		if(second_item==NULL)
			break;
		if(third_item == NULL)
		{
			first_item = second_item;
			break;
		}
		//mygraphics->DrawCurve(CurePen,, 3, 1.5f);
		//取3个点给画曲线的GDI函数;
		Point myPointArray[] =
		{Point(first_item->GetPoint().x,first_item->GetPoint().y),
		Point(second_item->GetPoint().x,second_item->GetPoint().y),
		Point(third_item->GetPoint().x,third_item->GetPoint().y)};
		mygraphics->DrawCurve(CurePen,myPointArray, 3, 1.0f);
		//mygraphics->DrawLine(CurePen,first_item->GetPoint().x,first_item->GetPoint().y,second_item->GetPoint().x,second_item->GetPoint().y);

		first_item = third_item;
	}
#endif
	//	mygraphics->DrawLine(CurePen,)


	delete CurePen;
	delete mygraphics;
	delete myRectangle_pen;
	delete my_inline_pen;
	delete BlackBrush;
}
Beispiel #17
0
void
MFCClipItemView::Draw(Graphics &dc, CRect &clipBox)
{
// !!!??? need to clip properly for short instances with long names
	cerr << "clip item draw " << item->sym->name << endl;
	Pen blackPen(Color(250, 0, 0, 0), 1);
	Pen redPen(Color(250, 238, 100, 100), 1);
	Pen orangePen(Color(200, 250, 150, 10), 1);
	SolidBrush blueBrush(Color(100, 100, 100, 238));
	SolidBrush blackBrush(Color(200, 0, 0, 0));
	SolidBrush orangeBrush(Color(190, 250, 150, 10));

	dc.DrawLine( &orangePen, bounds.left, 0, bounds.left, bounds.bottom);
	bool	isMarker = false;
	if (item != NULL && item->duration.ticks <= 0) {
		isMarker = true;
	}
	if (!isMarker) {
		dc.DrawLine( &orangePen, bounds.right, 0, bounds.right, bounds.bottom);
	}

	PointF	tri[3];

	Font	labelFont(L"Arial", 8.0, FontStyleRegular, UnitPoint, NULL);
	wstring nm;
	const char *cp = item->sym->uniqueName();
	while (*cp) {
		nm.push_back(*cp++);
	}
	PointF	p;
	UINT py = 0;
	do {
		if (!isMarker) {
			// a triangle bit
			tri[0].X = bounds.left; tri[0].Y = py;
			tri[1].X = bounds.left+6; tri[1].Y = py+3;
			tri[2].X = bounds.left; tri[2].Y = py+6;
			dc.FillPolygon(&orangeBrush, tri, 3);
		}

		p.X = bounds.left-1;
		p.Y = py+5;
		RectF	box;
		StringFormat	sff = StringFormatFlagsDirectionVertical;
		dc.MeasureString(nm.c_str(), -1, &labelFont, p, &sff, &box);
		dc.DrawString(nm.c_str(), -1, &labelFont, box,	&sff, &blackBrush);

		if (!isMarker) {
			// a nother triangle bit
			tri[0].X = bounds.right;
			tri[1].X = bounds.right-6;
			tri[2].X = bounds.right;
			dc.FillPolygon(&orangeBrush, tri, 3);

			p.X = bounds.right-10;
			p.Y = py+5;
			dc.MeasureString(nm.c_str(), -1, &labelFont, p, &sff, &box);
			dc.DrawString(nm.c_str(), -1, &labelFont, box,	&sff, &blackBrush);
		}
		py += editor->bounds.bottom;
	} while (py < bounds.bottom);

}
Beispiel #18
0
//
//  函数:  WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  目的:    处理主窗口的消息。
//
//  WM_COMMAND	- 处理应用程序菜单
//  WM_PAINT	- 绘制主窗口
//  WM_DESTROY	- 发送退出消息并返回
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;


	switch (message)
	{
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// 分析菜单选择: 
		switch (wmId)
		{
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		case ID_HELP_SPLASHSCREEN:
			ghDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_SPLASH), 0, Splash);
			ShowWindow(ghDlg, SW_SHOW);
			break;
		case ID_CONTROL_YIELD:
			if (!eval_null()){
				MessageBoxA(0, "You could only yield before a game start.", "Yield", 0);
				break;
			}
			mainboard[7][7] = 1;
			paint_board(hWnd);
			break;
		case ID_CONTROL_RESTART:
			clear_board(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_PAINT:{
		Graphics *myGraphics;
		Pen *myPen;
		hdc = BeginPaint(hWnd, &ps);
		// TODO:  在此添加任意绘图代码...
		myGraphics = new Graphics(hdc);
		myPen = new Pen(Color(255, 0, 0, 0), 1);
		myGraphics->DrawRectangle(myPen, Rect(400, 20, 20, 20));
		for (int i = 0; i < 375; i += 25)
			myGraphics->DrawLine(myPen, 20, 20 + i, 370, 20 + i);
		for (int i = 0; i < 375; i += 25)
			myGraphics->DrawLine(myPen, 20 + i, 20, 20 + i, 370);
		delete myGraphics;
		delete myPen;
		EndPaint(hWnd, &ps);
		paint_board(hWnd);
	}
		break;
	case WM_DESTROY:
		GdiplusShutdown(gdiplusToken);
		PostQuitMessage(0);
		break;
	case WM_LBUTTONDOWN:
		board_clicked(hWnd, LOWORD(lParam), HIWORD(lParam));
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
 void LineObject::Draw(Graphics& g) const {
     g.DrawLine(m_a, m_b);
 }
Beispiel #20
0
// #define DrawPolygonMacro
void drawBezierSmoothPoly(HDC hdc, AlpointsList &points, float f, COLORREF color) {
	if(points.count()<3) return;
	GdiPlusIniter ginit;
	Graphics *graphics = Graphics::FromHDC(hdc);
	graphics->SetSmoothingMode(SmoothingModeHighQuality);
	graphics->SetCompositingMode(CompositingModeSourceOver);
	Pen pen(Color::Red);
	pen.SetLineJoin(LineJoinRound);
	pen.SetLineCap(LineCapRound,LineCapRound, DashCapRound);
// 绘制多边形
#if defined(DrawPolygonMacro)
	pen.SetColor(Color::Blue);
	pen.SetDashStyle(DashStyleDash);
	for(int i=0; i<points.count() - 1; i++){
		Point p1(points[i+0].x, -points[i+0].y);
		Point p2(points[i+1].x, -points[i+1].y);
		graphics->DrawLine(&pen, p1, p2 );
	}
#endif
#if defined(ThroghtEveryPoint)
	ALPoint b, e, n, c1, c2, c3;
	int last = 0;
	for(int i=0; i<points.count()-1; i++){
		if( distance(points[last], points[i+1])<4 ){
			continue;
		}
		b = points[last];
		e = points[i+1];
		n = points[i+2];
		c1 = last==0? points[0]:c3;
		c2 = cubicBezierControlPoint(b, e, n, &c3, f);
		{
			// 绘制控制点!!!
#if 0
			pen.SetDashStyle(DashStyleDot);
			pen.SetColor(Color::Green);
			Point p1(c2.x, -c2.y);
			Point p2(c3.x, -c3.y);
			graphics->DrawEllipse(&pen, p1.X-1, p1.Y-1,2,2);
			graphics->DrawEllipse(&pen, p2.X-1, p2.Y-1,2,2);
			graphics->DrawLine(&pen, p1, p2);
#endif
		}
		pen.SetDashStyle(DashStyleSolid);
		pen.SetColor(Color::Red);
		Point p1(b.x, -b.y);
		Point p2(c1.x, -c1.y);
		Point p3(c2.x, -c2.y);
		Point p4(e.x, -e.y);
		graphics->DrawBezier(&pen, p1,p2,p3,p4); 
		last = i+1;
	} 
#else  // 使用顶点作为控制点!!!!!
	pen.SetColor(Color::Red);
	pen.SetDashStyle(DashStyleSolid);
	int last = 0;
	float bx,by,cx,cy,ex,ey;
	for(int i=0; i<points.count(); i++){
		bx = i==0?points[0].x:ex;
		by = i==0?points[0].y:ey;
		ex = (points[i+1].x + points[i+2].x)/2;
		ey = (points[i+1].y + points[i+2].y)/2;
		cx = points[i+1].x; cy = points[i+1].y;
		// b(t) = (1-t)^2*p0 + 2t(1-t)*p1 + t^2*p2
		float x0 = bx, y0 = -by;
		for(float t=0.02; t<=1.0; t+=0.02){
			float x1 = square(1-t)*bx + 2*t*(1-t)*cx + square(t)*ex;
			float y1 = square(1-t)*by + 2*t*(1-t)*cy + square(t)*ey;
			y1 = -y1;
			graphics->DrawLine(&pen,x0, y0,x1,y1);
			x0 = x1; y0 = y1;
		}
	}

#endif
}