|
-
February 5th, 2010, 09:19 AM
#4
Re: [MFC] PolyLine and autoscrolling canvas
Hello again ProgramArtist,
I've figured about "drawing" a PolyLine graphic on the canvas but I have this doubt: is the PolyLine compatible with MM_ANISOTROPIC and rescaling automatically graphic at repaint?...
This because, having this code below:
Code:
CPaintDC dc(this); // device context for painting
dc.SetBkColor(RGB(0,0,0));
CRect rect;
GetClientRect(&rect);
int save = dc.SaveDC();
if(bSetDraw)
{
CMemDC mDC(&dc);
//mDC.SetBkColor(RGB(0,0,0));
mDC.SetMapMode(MM_ANISOTROPIC);
mDC.SetWindowOrg(rect.BottomRight());
mDC.SetViewportOrg(0, 0);
mDC.SetViewportExt(-1, -1);
mDC.SetWindowExt(1, 1);
// ********** Background ***********
// Grid
if (bActivateGrid)
{
CPen qLinePen(PS_SOLID, 1, RGB(0,139,0));
mDC.SelectObject(&qLinePen);
// Grid - Horizontal lines
mDC.MoveTo(1, 0);
mDC.LineTo(rect.Width(), 0);
int height = rect.Height();
int maxlines = height / (int)12.5;
for (int i=1;i<=maxlines;i++){
int y_axis = (int)((double)i * 12.5);
if (y_axis <= rect.Height()) {
mDC.MoveTo(1, y_axis);
mDC.LineTo(rect.Width(), y_axis);
}
}
// Grid - Vertical lines
mDC.MoveTo(0, 0);
mDC.LineTo(0, rect.Height());
int width = rect.Width();
maxlines = width / (int)12.5;
for (int i=1;i<=maxlines;i++){
int x_axis = (int)(((double)i * 12.5) - gridOffset);
if (x_axis <= rect.Width()) {
mDC.MoveTo(x_axis, 1);
mDC.LineTo(x_axis, rect.Height());
}
}
qLinePen.DeleteObject();
}
// *********** graphic component ***********
// based on choice of graph type
CPen qPolylinePen(PS_SOLID, 1, RGB(0, 255, 0));
switch (iGraphType)
{
case GRAPH_BARS:
break;
case GRAPH_LINES:
{
if (vtPoints.capacity() == 1)
{
mDC.SelectObject(qPolylinePen);
vectfPoints* pointsline = &vtPoints[0];
mDC.Polyline(&(*pointsline)[0], (int)pointsline->size());
//mDC->PolyPolyline()
qPolylinePen.DeleteObject();
}
}
break;
default:
break;
}
GDI_FLUSH();
}
dc.RestoreDC(save);
inside the OnPaint() event it draws the graphic but when I resize window it doesn't rescale and redraw graphic depending of the height of the canvas...May I have forgot something or coded wrong something else?...
Thanks in advance!!
Ciao, Luigi
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|