Home > Software engineering >  Curve correction problem
Curve correction problem

Time:09-22

Consult everybody, want to do data processing, specific as follows: in the notepad (or excle) there are four column data (tens of thousands of lines), the first listed as time axis, the second, three, four as each point in time the corresponding motor data, want to translate them into waveform figure (similar to sine curve) inverse time, longitudinal axis data, and then the curve in a certain period of time point is bad (volatility,) you can manually drag curve, drag again will be processed after the completion of data stored in notepad (or excle) , could you tell me how to implement or player who knows what software can be achieved? Urgent!!
Tried the labview and excel's built-in line chart can't drag line, ask the great spirit guide!!!!!!

CodePudding user response:

Fyi:
 # pragma comment (lib, "user32") 
# pragma comment (lib, "gdi32")
#include
#include
#include
Double * d [7], mind [7], maxd [7];
Int I, nn, h, x, y, mx=0, my=0, independence idx, cc, n, r, j, L, L1, jj=0, cc2, cb.
The FILE * f;
Char STR [1024], * p;
The RECT cr, vr, br.
COLORREF cj [7]={//the color of the first j column data
0 x00ff0000,
0 x00005000,
0 x000000ff,
0 x00ff00ff,
0 x0000ffff,
0 x00ffffff,
0 x00ffff00,
};
LRESULT a CALLBACK WndProc (HWND HWND, UINT message, WPARAM WPARAM, LPARAM LPARAM) {
PAINTSTRUCT ps;
HDC HDC.
HFONT HFONT ohfont;
COLORREF oc;
HBRUSH HBRUSH;//, ob;
HPEN HPEN, op;
HANDLE hData;
LPSTR lpData.

The switch (the message) {
Case WM_CLOSE://Alt + F4 exit
The PostQuitMessage (0);
break;
Case WM_KEYUP://press Esc to exit the
If (wParam==VK_ESCAPE) PostQuitMessage (0);
break;
Case WM_LBUTTONUP://mouse the left key click on the graphic display near the corresponding information
Mx=LOWORD (lParam);
My=HIWORD (lParam);
If (my> 13) {//cr. The bottom line message at the bottom click
Jj=cc (jj + 1) %;//rotate the display (shown above) the column data
The InvalidateRect (hWnd, & amp; Cr, TRUE);
} the else InvalidateRect (hWnd, & amp; Vr, TRUE);
break;
In case the WM_PAINT:
BeginPaint (hWnd, & amp; Ps);
HDC=ps. HDC;
GetClientRect (hWnd, & amp; Cr);
Br. Left=cr. Left;
Br. Right=cr. Right;
H=(cr) bottom - 13 - cr) top)/(1 + nn/(cr) right - cr) left));//each pixel height
If (h==0) h=1;
Hbrush=CreateSolidBrush ((a COLORREF) 0 x00b0b0b0);
//ob=(HBRUSH) SelectObject (HDC, HBRUSH);
For (I=0; iIf (0==I % (cr) right - cr) left)) {
If (0==I/(cr) right - cr) left) % 2) {
Br. Bottom=h - 1 + cr. Top + I/(cr) right - cr) left) * h.
Br. Top=br. Bottom - h;
FillRect (HDC, & amp; Br, hbrush);
}
}
}
If (0==I/(cr) right - cr) left) % 2) {
Br. Bottom=h - 1 + cr. Top + I/(cr) right - cr) left) * h.
Br. Top=br. Bottom - h;
If (br. TopBr. Bottom=cr. Bottom - 13;
FillRect (HDC, & amp; Br, hbrush);//, if necessary, at the bottom of the bottom line of fill light gray, make sure that the bottom line of the height of h
}
}
For (j=cc - 1; J>=0; J -) {
If (j==jj) continue;//to skip the first jj column data
Hpen=CreatePen (PS_SOLID, 0, cj [7] + j (cb) %).
Op=(HPEN) SelectObject (HDC, HPEN);
For (I=0; iX=cr. I left + % (cr) right - cr) left);
Y=h - 2 + cr. Top + I/(cr) right - cr) left) * h - ((maxd [j]==mind [j])? Zero: ((int) ((d [j] [I] - mind [j])/(maxd [j] - mind [j]) * h)));
If (0==I % (cr) right - cr) left)) {
MoveToEx (HDC, x, y, NULL);
}
The else LineTo (HDC, x, y);
}
SelectObject (HDC, op);
DeleteObject (hpen);
}
J=jj;//will first jj column data showed last (shown above)
Hpen=CreatePen (PS_SOLID, 0, cj [7] + j (cb) %).
Op=(HPEN) SelectObject (HDC, HPEN);
For (I=0; iX=cr. I left + % (cr) right - cr) left);
Y=h - 2 + cr. Top + I/(cr) right - cr) left) * h - ((maxd [j]==mind [j])? Zero: ((int) ((d [j] [I] - mind [j])/(maxd [j] - mind [j]) * h)));
If (0==I % (cr) right - cr) left)) {
MoveToEx (HDC, x, y, NULL);
}
The else LineTo (HDC, x, y);
}
SelectObject (HDC, op);
DeleteObject (hpen);

Vr. Top=cr. Bottom - 13;
Vr. The bottom=cr. The bottom;
Vr. Left=cr. Left;
Vr. Right=cr. Right;
FillRect (HDC, & amp; Vr, hbrush);
Hfont=CreateFont (12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "tahoma");
Ohfont=(HFONT) SelectObject (HDC, HFONT);
SetBkMode (HDC, TRANSPARENT);
Oc=SetTextColor (HDC, (a COLORREF) 0 x00000000);
Independence idx=(my + 1)/h * (cr) right - cr) left) + mx;
If (idx>=nn) independence idx=0;
L=sprintf (STR, "a total of % d row x % d column in each column, the minimum maximum=", nn, cc).
TextOut (HDC, vr. Left + 8, vr. The top + 1, STR, L);
For (j=0; jSetTextColor (HDC, cj [7] + j (cb) %).
L1=sprintf (STR, "% % lg, lg," mind [j], maxd [j]);
TextOut (HDC, vr. Left + 8 + L * 6, vr. The top + 1, STR, L1);
If (j==jj) TextOut (HDC, vr. Left + 8 + L * 6 + 1, vr. The top + 1, STR, L1);
L +=L1;
}
SetTextColor (HDC, (a COLORREF) 0 x00000000);
L1=sprintf (STR, "the first line % d:", independence idx + 1);
TextOut (HDC, vr. Left + 8 + L * 6, vr. The top + 1, STR, L1);
L +=L1;
For (j=0; jSetTextColor (HDC, cj [7] + j (cb) %).
L1=sprintf (STR, "% lg," d [j] [independence idx]);
TextOut (HDC, vr. Left + 8 + L * 6, vr. The top + 1, STR, L1);
If (j==jj) TextOut (HDC, vr. Left + 8 + L * 6 + 1, vr. The top + 1, STR, L1);
L +=L1;
}
If (idx> 0 {
If (OpenClipboard (hWnd)) {
EmptyClipboard ();
hData=https://bbs.csdn.net/topics/GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, 16);
lpData=https://bbs.csdn.net/topics/(char *) GlobalLock (hData);
Sprintf (lpData, % d ", "independence idx + 1);//the current line Numbers into the clipboard, convenient external program positioning the cursor to the current line,
GlobalUnlock (hData);
SetClipboardData (CF_TEXT hData);
CloseClipboard ();
}
}
SetTextColor (HDC, oc);
SelectObject (HDC, ohfont);
DeleteObject (hfont);

//SelectObject (HDC, ob);
DeleteObject (hbrush);

EndPaint (hWnd, & amp; Ps);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related