void drawTest::plotData(void){
int changing_size = 10;
int start_index = index;
for(int i=0; i<changing_size; ++i){
data_y[index] = (qSin(index*0.1)*100+100) + (qrand() % 20);
if(++index > plot_size) index = 0;
}
HWND hwnd = canvas->winId();
HDC hdc = GetDC(hwnd);
static HPEN hpen_white = CreatePen(PS_SOLID,1,RGB(0,0,0));
SelectObject(hdc, hpen_white);
RECT rec;
rec.bottom = canvas->rect().height();
rec.top = 0;
rec.left = data_x[start_index];
rec.right = data_x[start_index+changing_size];
FillRect(hdc, &rec, (HBRUSH) (COLOR_WINDOW+1) );
static HPEN hpen_black = CreatePen(PS_SOLID,1,RGB(0,0,0));
SelectObject(hdc, hpen_black);
if(start_index+changing_size > plot_size){
for(int i=start_index; i<plot_size; ++i){ LineTo(hdc, data_x[i], data_y[i] ); }
MoveToEx(hdc, data_x[0], data_y[0],NULL);
for(int i=0; i<(start_index+changing_size)-plot_size; ++i){ LineTo(hdc, data_x[i], data_y[i] ); }
}
else{
MoveToEx(hdc, data_x[start_index], data_y[start_index],NULL);
for(int i=0; i<changing_size; ++i){ LineTo(hdc, data_x[start_index+i], data_y[start_index+i] ); }
}
ReleaseDC(hwnd, hdc);
}
void drawTest::plotData(void){
int changing_size = 10;
int start_index = index;
for(int i=0; i<changing_size; ++i){
data_y[index] = (qSin(index*0.1)*100+100) + (qrand() % 20);
if(++index > plot_size) index = 0;
}
QwtPlotCanvas * canvas = plot->canvas();
HWND hwnd = canvas->winId();
HDC hdc = GetDC(hwnd);
static HPEN hpen_white = CreatePen(PS_SOLID,1,RGB(0,0,0));
SelectObject(hdc, hpen_white);
RECT rec;
rec.bottom = canvas->rect().height();
rec.top = 0;
rec.left = data_x[start_index];
rec.right = data_x[start_index+changing_size];
FillRect(hdc, &rec, (HBRUSH) (COLOR_WINDOW+1) );
static HPEN hpen_black = CreatePen(PS_SOLID,1,RGB(0,0,0));
SelectObject(hdc, hpen_black);
if(start_index+changing_size > plot_size){
for(int i=start_index; i<plot_size; ++i){ LineTo(hdc, data_x[i], data_y[i] ); }
MoveToEx(hdc, data_x[0], data_y[0],NULL);
for(int i=0; i<(start_index+changing_size)-plot_size; ++i){ LineTo(hdc, data_x[i], data_y[i] ); }
}
else{
MoveToEx(hdc, data_x[start_index], data_y[start_index],NULL);
for(int i=0; i<changing_size; ++i){ LineTo(hdc, data_x[start_index+i], data_y[start_index+i] ); }
}
ReleaseDC(hwnd, hdc);
}
To copy to clipboard, switch view to plain text mode
Bookmarks