void GSurface::calculateCoefficients(){ Transformation geometry(_geometry_matrix); Transformation geometryTransposed = geometry.transpose(); Transformation coords_x(_coords_x); _cx = (geometry * coords_x * geometryTransposed).m(); Transformation coords_y(_coords_y); _cy = (geometry * coords_y * geometryTransposed).m(); Transformation coords_z(_coords_z); _cz = (geometry * coords_z * geometryTransposed).m(); }
void CGraphPanel::DrawAxis(CDC* pDC, CRect& rect_to_draw) { int i; if (CurrentCoordsX == NULL || CurrentCoordsY == NULL) return; //create new set of CCoordinates CCoordinates coords_x(rect_to_draw.left, rect_to_draw.right, CurrentCoordsX->v1(), CurrentCoordsX->v2()); CCoordinates coords_y(rect_to_draw.bottom, rect_to_draw.top, CurrentCoordsY->v1(), CurrentCoordsY->v2()); //draw axis and zero line first CPen BlackDashPen(PS_DOT, 1, RGB(0, 0, 0)); CPen bkPen(PS_SOLID, 1, bkColor); CPen* OldPen = (CPen*)pDC->SelectObject(&BlackDashPen); pDC->SetBkMode( TRANSPARENT); //horizontal double Delta; double* wp; double* sp; int count, maxexp, NMax; NMax = hruler->GetNMax(pDC, rect_to_draw); coords_x.DivideInterval(NMax, &maxexp, &Delta, &count, &sp, &wp); for (i=0; i<count; i++) { int x = (int)sp[i]; pDC->MoveTo(x, rect_to_draw.bottom); pDC->LineTo(x, rect_to_draw.top); }; if (sp!=NULL) delete sp; if (wp!=NULL) delete wp; //vertical NMax = vruler->GetNMax(pDC, rect_to_draw); coords_y.DivideInterval(NMax, &maxexp, &Delta, &count, &sp, &wp); for (i=0; i<count; i++) { int x = (int)sp[i]; pDC->MoveTo(rect_to_draw.right,x); pDC->LineTo(rect_to_draw.left,x); }; if (sp!=NULL) delete sp; if (wp!=NULL) delete wp; pDC->SelectObject(OldPen); }
void CGraphPanel::DrawPoints(CDC* dc, CRect& rect_to_draw) { //draw all the points SSinglePoint ssp, ssp1; int x, y, x1, y1, grnum; if (CurrentCoordsX == NULL || CurrentCoordsY == NULL) return; CGraphWnd* main_wnd = get_main_graph_window(); if (main_wnd == NULL) return; //save current state of device context int saved_dc = dc->SaveDC(); //set new clipping region dc->IntersectClipRect(rect_to_draw); //create new set of CCoordinates CCoordinates coords_x(rect_to_draw.left, rect_to_draw.right, CurrentCoordsX->v1(), CurrentCoordsX->v2()); CCoordinates coords_y(rect_to_draw.bottom, rect_to_draw.top, CurrentCoordsY->v1(), CurrentCoordsY->v2()); CGraphProps* grprop = main_wnd->GetFirstGraph(&grnum); while (grprop!=NULL) { if (grprop->GetSize() ==0 || !grprop->IsVisible()) { grprop = main_wnd->GetNextGraph(&grnum); continue; }; //set color CPen* pen = grprop->GetPen(); CBrush* brush = grprop->GetBrush(); CPen* oldpen = (CPen*)dc->SelectObject(pen); CBrush* oldbrush = (CBrush*)dc->SelectObject(brush); grprop->GetPoint(0, &ssp); x = (int)coords_x.WtoX(ssp.x); y = (int)coords_y.WtoX(ssp.y); if ((long)(m_grflags & GRAPH_SQUAREPOINTS)!=0) DrawSquarePoint(dc, x, y); for (int i=1; i<grprop->GetSize(); i++) { grprop->GetPoint(i, &ssp); x1 = (int)coords_x.WtoX(ssp.x); y1 = (int)coords_y.WtoX(ssp.y); if (x != x1 || y != y1) { if ((m_grflags & GRAPH_SQUAREPOINTS)!=0) DrawSquarePoint(dc, x1, y1); if ((m_grflags & GRAPH_GRAPH_SCATTER) == 0) { dc->MoveTo(x, y); dc->LineTo(x1, y1); }; x = x1; y = y1; }; }; dc->SelectObject(oldpen); dc->SelectObject(oldbrush); grprop->ReleasePen(pen); grprop->ReleaseBrush(brush); grprop = main_wnd->GetNextGraph(&grnum); }; dc->RestoreDC(saved_dc); }