Ну, в C++ Builder можно делать так.
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено Bill 22 апреля 2005 г. 20:50
В ответ на: как в С++ рисовать линии? отправлено колян безпарольный 22 апреля 2005 г. 20:25


void __fastcall TForm1::Timer1Timer(TObject *Sender) // Timer event
{
...........
Form1->Invalidate(); // Обновить окно
}
//
// ** Form1 OnPaint event function
//
void __fastcall TForm1::FormPaint(TObject *Sender)
{
int x, y;
TPenMode _mode;

_canvas->Pen->Color = clWhite; // Draw the PaintBox frame
_canvas->Pen->Width = 3; //
_canvas->Polygon(_points, 3); //
_canvas->Pen->Width = 1; //
for (x=START_X, i=0; i < NSAMPLES; x+=DX, ++i) // Fill the buffer with data
{
y = (SampleBuffer[i] * SCALE_Y) / 2048;
GraphData[i] = Point(x, X_AXIS-y);
}
y = (SortedValues[i] * SCALE_Y) / 2048;
GraphData2[i] = Point(x, X_AXIS-y);
_canvas->PenPos = Point(x, X_AXIS);
_canvas->LineTo(x, X_AXIS+5);
sprintf(_str,"%2d", i);
_canvas->TextOut(x-5, X_AXIS+5, AnsiString(_str));
_canvas->Polyline(GraphData, NSAMPLES-1);
//
// Draw the grid
//
_canvas->Brush->Color = clSilver;
_canvas->Pen->Color = clWhite; // Draw the PaintBox frame
for (x = START_X; x <= END_X; x += GRID_SIZE) // Draw the vertical lines
{ //
_canvas->Pen->Style =
psSolid : psDot;
if (x==(T1_AXIS+125) || x==(T2_AXIS+125))
continue;
} //
for (y = START_Y; y <= END_Y; y += GRID_SIZE) // Draw the horozontal lines
{ //
MoveToEx(_hdl, START_X, y, 0); //
LineTo(_hdl, END_X, y); //
} //
//
// Draw the axes
//
SelectObject(_hdl, _penB); // Set black pen
MoveToEx(_hdl, T1_AXIS, START_Y, 0); // Draw the T-axis
LineTo(_hdl, T1_AXIS, END_Y); //
MoveToEx(_hdl, T2_AXIS, START_Y, 0); //
LineTo(_hdl, T2_AXIS, END_Y); //
MoveToEx(_hdl, T3_AXIS, START_Y, 0); //
LineTo(_hdl, T3_AXIS, END_Y); //
MoveToEx(_hdl, START_X, START_Y, 0); // Draw the X-axis
LineTo(_hdl, END_X, START_Y); //

if (Timer1->Enabled && // Draw the cursor position
(CursorX>=START_X&&CursorX<=END_X) &&
(CursorY>=START_Y&&CursorY<=END_Y))
{
_mode = _canvas->Pen->Mode;
_canvas->Pen->Mode = pmNotXor;
_canvas->Pen->Style = psDot;
_canvas->Pen->Color = clBlue;
_canvas->MoveTo(START_X, CursorY);
_canvas->LineTo(END_X, CursorY);
_canvas->MoveTo(CursorX, START_Y);
_canvas->LineTo(CursorX, END_Y);
_canvas->Pen->Mode = _mode;
}
}


Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru