void wxDCBase::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) { if ( n == 1 ) { DoDrawPolygon(count[0], points, xoffset, yoffset, fillStyle); return; } int i, j, lastOfs; wxPoint* pts; wxPen pen; for (i = j = lastOfs = 0; i < n; i++) { lastOfs = j; j += count[i]; } pts = new wxPoint[j+n-1]; for (i = 0; i < j; i++) pts[i] = points[i]; for (i = 2; i <= n; i++) { lastOfs -= count[n-i]; pts[j++] = pts[lastOfs]; } pen = GetPen(); SetPen(wxPen(*wxBLACK, 0, wxTRANSPARENT)); DoDrawPolygon(j, pts, xoffset, yoffset, fillStyle); SetPen(pen); for (i = j = 0; i < n; i++) { DoDrawLines(count[i], pts+j, xoffset, yoffset); j += count[i]; } delete[] pts; }
void wxSVGFileDCImpl::DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) { if (n == 1) { DoDrawPolygon(count[0], points, xoffset, yoffset, fillStyle); return; } int i, j; int totalPts = 0; for (j = 0; j < n; ++j) totalPts += count[j]; wxScopedArray<wxPoint> pts(totalPts + n); int polyCounter = 0, polyIndex = 0; for (i = j = 0; i < totalPts; ++i) { pts[j++] = points[i]; ++polyCounter; if (polyCounter == count[polyIndex]) { pts[j++] = points[i - count[polyIndex] + 1]; ++polyIndex; polyCounter = 0; } } { wxDCPenChanger setTransp(*GetOwner(), *wxTRANSPARENT_PEN); DoDrawPolygon(j, pts.get(), xoffset, yoffset, fillStyle); } for (i = j = 0; i < n; i++) { DoDrawLines(count[i] + 1, pts.get() + j, xoffset, yoffset); j += count[i] + 1; } }
void wxDCBase::DoDrawEllipticArcRot( wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea, double angle ) { wxList list; CalculateEllipticPoints( &list, x, y, w, h, sa, ea ); Rotate( &list, angle, wxPoint( x+w/2, y+h/2 ) ); // Add center (for polygon/pie) list.Append( (wxObject*) new wxPoint( x+w/2, y+h/2 ) ); // copy list into array and delete list elements int n = list.Number(); wxPoint *points = new wxPoint[n]; int i = 0; wxNode* node = 0; for ( node = list.First(); node; node = node->Next(), i++ ) { wxPoint *point = (wxPoint *)node->Data(); points[i].x = point->x; points[i].y = point->y; delete point; } // first draw the pie without pen, if necessary if( GetBrush() != *wxTRANSPARENT_BRUSH ) { wxPen tempPen( GetPen() ); SetPen( *wxTRANSPARENT_PEN ); DoDrawPolygon( n, points, 0, 0 ); SetPen( tempPen ); } // then draw the arc without brush, if necessary if( GetPen() != *wxTRANSPARENT_PEN ) { // without center DoDrawLines( n-1, points, 0, 0 ); } delete [] points; } // DrawEllipticArcRot
void wxDCBase::DrawPolygon(const wxList *list, wxCoord xoffset, wxCoord yoffset, int fillStyle) { int n = list->GetCount(); wxPoint *points = new wxPoint[n]; int i = 0; for ( wxList::compatibility_iterator node = list->GetFirst(); node; node = node->GetNext(), i++ ) { wxPoint *point = (wxPoint *)node->GetData(); points[i].x = point->x; points[i].y = point->y; } DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); delete [] points; }
EXPORT_C void CHuiCanvasGc::DrawPolygon(RArray<THuiRealPoint>& aPoints) { if (!iGc) { return; } Setup(); EnableBlendingIfNeeded(); EnableDelayedClippingIfNeeded(aPoints); while (ClipNext()) { DoDrawPolygon(aPoints); } DisableDelayedClippingIfNeeded(); Cleanup(); }
EXPORT_C void CHuiCanvasGc::DoDrawArc(const THuiRealRect& aDestinationRect, const THuiRealPoint& aStart, const THuiRealPoint& aEnd) { TPoint start = aStart; TPoint end = aEnd; TReal startx = aDestinationRect.iTl.iX; TReal starty = aDestinationRect.iTl.iY; TReal rx = aDestinationRect.Width()/2; TReal ry = aDestinationRect.Height()/2; startx += rx; starty += ry; //Check if given start and end point lie on ellipse, if not, //Find the point of intersection of ellipse with line joing to ellipse origin and start point //and ellipse origin and end point if ( ((aStart.iX-startx)*(aStart.iX-startx)/(rx*rx) + (aStart.iY-starty)*(aStart.iY-starty)/(ry*ry))!=1 ) { TReal m = (aStart.iY-starty)/(aStart.iX - startx); TReal intersectionPointX; TReal src = (rx*rx*ry*ry)/((ry*ry)+(rx*rx*m*m)); Math::Sqrt(intersectionPointX,src); TReal intersectionPointY = starty + (m*intersectionPointX); intersectionPointX = intersectionPointX + startx; start.iX = intersectionPointX; start.iY = intersectionPointY; } if ( ((aEnd.iX-startx)*(aEnd.iX-startx)/(rx*rx) + (aEnd.iY-starty)*(aEnd.iY-starty)/(ry*ry))!=1 ) { TReal m = (aEnd.iY-starty)/(aEnd.iX - startx); TReal intersectionPointX; TReal src = (rx*rx*ry*ry)/((ry*ry)+(rx*rx*m*m)); Math::Sqrt(intersectionPointX,src); TReal intersectionPointY = (m*intersectionPointX) + starty; intersectionPointX = intersectionPointX + startx; end.iX = intersectionPointX; end.iY = intersectionPointY; } TReal startAngle = 0; Math::ATan(startAngle,(starty-start.iY),(start.iX-startx)); startAngle = (startAngle*180)/KPi; TReal endAngle = 0; Math::ATan(endAngle,(starty-end.iY),(end.iX-startx)); endAngle = (endAngle*180)/KPi; if ( endAngle <= startAngle ) endAngle = 360 + endAngle; // this is very slow, needs to be re-implemented if(iPolygonDrawMode) { TReal x,y,newx,newy; x = startx; y = starty; newx = x; newy = y; RArray<THuiRealPoint> points; for(TInt i = -endAngle; i <-startAngle ; i++) { double a = double(i) * KPi / 180.0; double sin, cos; Math::Sin( sin, a ); Math::Cos( cos, a ); newx = startx + cos * rx; newy = starty + sin * ry; points.Append(THuiRealPoint(x,y)); points.Append(THuiRealPoint(newx, newy)); x = newx; y = newy; } DoDrawPolygon(points); points.Close(); } else { CHuiCurvePath* path = NULL; TRAPD(error, path = CHuiCurvePath::NewL()); if(error ==KErrNone) { TRAP(error,path->AppendArcL(THuiRealPoint(startx, starty), THuiRealSize(rx, ry), -startAngle, -endAngle, 1)); if(error ==KErrNone) { THuiLinearMappingFunction alphaFunc; alphaFunc.iOffset = iOpacity; THuiLinearMappingFunction widthFunc; widthFunc.iOffset = iPenWidth; const TPoint pt(0,0); RHuiOwnedPointer<CHuiCurvePath> iPath; iPath.Set(path, EHuiHasOwnership); iGc->DrawPath(iPath.Ref(), pt, 0.0, 1.0, &alphaFunc, &widthFunc); } } } }