Home > Software engineering >  Double buffer drawing problems, clear the data and the background grid are not synchronized
Double buffer drawing problems, clear the data and the background grid are not synchronized

Time:01-06

Directly on the code,
 
Void Ccurve: : addtaxis (int data, int * path)//data for drawing data frames
{
If (vec) size () & gt; 0)
Deepth=vec [vec_start] [12];

for(int i=0; i<12. I++)
{
Picline [I]=arrline [I];//will choose 12 data for drawing library data
Pen [I]=new pen (picline [I] return_color (), picline [I] return_width ());//set 12 brush color and line width
}
Int dpi.//printer pixel
Float flat;//print image scale 1:20 0? 1:50 to add global variable
//memory mapping
PWnd1=GetDlgItem (IDC_STATIC_view);//control ID
PDC1=pWnd1 - & gt; GetDC ();
PWnd1 - & gt; GetWindowRect (& amp; Rect1);//rc to control the size of the
The ScreenToClient (& amp; Rect1);
W=rect1. Width () - 20;
H=rect1. Height ();
M=H/40;
Bmp1=new Bitmap (W + 20-2 H - 1);//memory bitmap H
Tite_W=W - 100.//remove the depth display curve drawing area
Left_W=Tite_W/2 + 100;
Pen pen2 (Color (0, 0, 0), (3);//frame bold lines
Pen spen (Color (0, 0, 0), 1);//border lines
Gdiplus: : the Font myFont (L "Arial", 15);
255,0,0,0 SolidBrush brushB (Color ());
Graphics Graphics (bmp1);
HatchBrush newBrush (HatchStyleCross, Color (2555, 255, 255, 255), Color (255, 255, 255255));//white
Graphics. FillRectangle (& amp; NewBrush, 0, 0, rect1. Width (), H);//to draw area filling white back
StringFormat StringFormat;
Stringformat. SetAlignment (StringAlignmentCenter);
//vertical bar area
for(int i=0; i<4. I++)
{
Graphics. DrawLine (& amp; Pen2, Tite_W * I/6, 0, + 20 Tite_W * I/6 + 20, H);//in front of the four bar, three regional
Graphics. DrawLine (& amp; Pen2, left_W * I/6, 0, + Tite_W left_W + Tite_W * I/6, H);//behind four ordinate, three regional
for(int j=1; J<4. J++)//each two black line between the 3 lines
{
If (I)//in front of the first line does not draw
{
Graphics. DrawLine (& amp; Spen, Tite_W * 6 - Tite_W * I/j/24, 0, + 20 Tite_W * 6 - Tite_W * I/j/24 + 20, H);//the first thread
Graphics. DrawLine (& amp; Spen, left_W + Tite_W * I/j/24, 0, 6 - Tite_W * left_W + I/6 - Tite_W Tite_W * * j/24, H); Second part//thin lines
}
}
}


for(int j=1; J<=(meter * 10); J++)
{
If (0==10) (deepth - j) %//the position of the integer m
{
Graphics. DrawLine (& amp; Spen, 20, j/H - H * * 10 (meter), Tite_W/2 + 20, H - H * j/(meter * 10));//on the left side of the horizontal lines
Graphics. DrawLine (& amp; Spen left_W, H - H * j/(meter * 10), left_W + Tite_W/2, H - H * j/(meter * 10));//on the right side of cross thread
If ((deepth - j) % 100==0)//10 m the location of the
{
Graphics. DrawLine (& amp; Pen2, 20, j/H - H * (* 10 meter), Tite_W/2 + 20, H - H * j/(meter * 10));//on the left side of the cross bold lines
Graphics. DrawLine (& amp; Pen2 left_W, j/H - H * (* 10 meter), left_W + Tite_W/2, H - H * j/(meter * 10));//on the right side of horizontal thick line
WCHAR buf [160].
WsprintfW (buf, L "% d", (deepth - j)/10);//note is the figure, the above figures, the following number is small, + 40 is a screen is empty because of the beginning, attach useless
Graphics. DrawString (buf, 1, & amp; MyFont PointF (Tite_W/2 + 50 + 10, H - H * j/(meter * 10) - 10), & amp; Stringformat, & amp; BrushB);//every 10 meters, add the longitudinal coordinate data
}
}
}
//the above part as the background grid

If (vec) size () & gt; 0)
{

If (float (deepth - 10) & gt;=vec [vec. The size () - 1] to [12])//when the line drawing data is more than 399 and refresh the page 30 meters,
{
Vec_start=vec. The size () - 1;//start point
For (int I=vec_start; i{
If (float (deepth - 10) & gt;=vec [I] [12])//data more than full screen it depth less than or equal to the points on the top of the screen
Vec_end=I;
}
}
Dissatisfaction with the else//data screen will take container to a point on the top
Vec_end=vec. The size () - 1;

for(int i=0; i<12. I++)
Addcurve (graphics, pen [I], I, picline [I] return_path (), data);//here for data curve part
}
Graphics gr (pDC1 - & gt; M_hDC);
Gr. DrawImage (bmp1, 1,1,0,0, W + 50, H 2, UnitPixel);
The ReleaseDC (pDC1);//release DC;
The delete bmp1;
Bmp1=NULL;
}
Void Ccurve: : addcurve (Graphics & amp; G, Pen, Pen * int j, int path, int data)//draw curve, j=0 to article 1,
{//pos=0 means real-time log, pos for roller position
Cstrings st.
Int z=path;//painting area,
PointF point [400].
/* if (data> 400)
{*/
For (int I=vec_start; i{
If (z<3)
(point [I - vec_start]) X=(vec [I] [j] - picline [j]. J return_min ())/(picline [j]. J return_max () - picline [j]. J return_min ()) * Tite_W/6 + 20 + Tite_W * z/;
The else
(point [I - vec_start]) X=(vec [I] [j] - picline [j]. J return_min ())/(picline [j]. J return_max () - picline [j]. J return_min ()) * 6 + Tite_W Tite_W/* (z - 3)/6 + left_W;
//(point [I]) Y=H - 0.1 * I * m;
(point [I - vec_start].) Y=H - (deepth - vec [I] [12]) * H/meter * (10);//the deepth - 300 * turn_page for deep drawing the bottom screen
}
G.D rawCurve (pen point, vec_end + 1 - vec_start, 1.0 f);
}

I have to background grid and data curves are drawn in a function, first disappear when data reset to the curve, but also in background grid, such as the next frame data to the background grid to redraw, effect is the data I want to empty the curve with the grid synchronization
  • Related