Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CPlot2D::plot1(CDC& dc, bool drawOuterRect, bool drawInnerGrid, bool anis)//рисуем графики
- {
- // Устанавливает режим отображения контекста устройства. Определяет единицу измерения,
- // для преобразования единиц измерения пространства страницы в пространства устройства
- if (anis == 0) dc.SetMapMode(MM_TEXT); // Логическая единица измерения отображается как один пиксель устройства
- CMatrix V(3), W(3);
- V(2) = 1;
- if (anis)
- {
- for (int i = 0; i < _converter.countRows(); i++)
- {
- for (int j = 0; j < _converter.countCols(); j++)
- {
- _converter(i, j) = 1;
- }
- }
- }
- // Оси
- if (drawOuterRect)
- {
- dc.Rectangle(_rectWindow);
- }
- // График
- if (drawInnerGrid)
- {
- CPen pen(_penAxis._style, _penAxis._width, _penAxis._color);//передаем параметры пера
- CPen* pOldPen = dc.SelectObject(&pen); // Выбираем перо в контекст памяти
- V(0) = 0; //по х 0
- V(1) = _rectWorld._top; //по у передается значение верхушки прямоугольника
- W = anis ? V : _converter * V; // Конвертируем в ОСК
- V(0) = 0;
- V(1) = _rectWorld._bottom;
- W = anis ? V : _converter * V;
- for (double i = 0; i < (_rectWindow.bottom - _rectWindow.top); i += 10)
- {
- dc.MoveTo(_rectWindow.left, _rectWindow.top + i);//ставим точку
- dc.LineTo(_rectWindow.right, _rectWindow.top + i);//рисуем линию
- }
- for (double i = 0; i < (_rectWindow.right - _rectWindow.left); i += 10)
- {
- dc.MoveTo(_rectWindow.left + i, _rectWindow.top);
- dc.LineTo(_rectWindow.left + i, _rectWindow.bottom);
- }
- dc.SelectObject(pOldPen);
- }
- V(0) = _functionArgument(0);
- V(1) = _functionValue(0);
- W = anis ? V : _converter * V;
- // Передаем параметры пера
- CPen MyPen(_penLine._style, _penLine._width, _penLine._color);
- CPen* pOldPen = dc.SelectObject(&MyPen);//передаем в контекст для рисования перо
- if (anis)
- {
- double top = _functionValue.getMin();
- double bottom = _functionValue.getMax();
- double left = _functionArgument.getMin();
- double right = _functionArgument.getMax();
- int buffer = dc.SetMapMode(MM_ANISOTROPIC);//Логические единицы измерения отображаются произвольными единицами измерения с произвольно масштабируемыми осями
- dc.SetWindowOrg(left, top); //Устанавливает начало окна контекста устройства.
- dc.SetWindowExt(right - left, -(bottom - top));//размеры окна
- dc.SetViewportOrg(0, _rectWindow.bottom);//Устанавливает начало области просмотра контекста устройства
- dc.SetViewportExt(_rectWindow.right - _rectWindow.left, _rectWindow.bottom - _rectWindow.top);//размеры области просмотра
- dc.MoveTo((int)W(0), (int)W(1));//определяем начальную точку
- for (int i = 1; i < _functionArgument.countRows(); i++)
- {
- V(0) = _functionArgument(i);
- V(1) = _functionValue(i);
- W = anis ? V : _converter * V;
- dc.LineTo((int)W(0), (int)W(1)); //ведем линию
- }
- dc.SelectObject(pOldPen);//возвращаем контекст рисования
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement