void wxGCDCImpl::DoGradientFillConcentric(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, const wxPoint& circleCenter) { //Radius wxInt32 cx = rect.GetWidth() / 2; wxInt32 cy = rect.GetHeight() / 2; wxInt32 nRadius; if (cx < cy) nRadius = cx; else nRadius = cy; // make sure the background is filled (todo move into specific platform implementation ?) m_graphicContext->SetPen(*wxTRANSPARENT_PEN); m_graphicContext->SetBrush( wxBrush( destColour) ); m_graphicContext->DrawRectangle(rect.x,rect.y,rect.width,rect.height); m_graphicContext->SetBrush( m_graphicContext->CreateRadialGradientBrush( rect.x+circleCenter.x,rect.y+circleCenter.y, rect.x+circleCenter.x,rect.y+circleCenter.y, nRadius,initialColour,destColour)); m_graphicContext->DrawRectangle(rect.x,rect.y,rect.width,rect.height); m_graphicContext->SetPen(m_pen); m_graphicContext->SetBrush(m_brush); CalcBoundingBox(rect.x, rect.y); CalcBoundingBox(rect.x + rect.width, rect.y + rect.height); }
void wxSVGFileDC::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoord y, double angle) { //known bug; if the font is drawn in a scaled DC, it will not behave exactly as wxMSW if (m_graphics_changed) NewGraphics (); wxString s, sTmp; // calculate bounding box wxCoord w, h, desc ; DoGetTextExtent(sText, &w, &h, &desc); double rad = DegToRad(angle); // wxT("upper left") and wxT("upper right") CalcBoundingBox(x, y); CalcBoundingBox((wxCoord)(x + w*cos(rad)), (wxCoord)(y - h*sin(rad))); // wxT("bottom left") and wxT("bottom right") x += (wxCoord)(h*sin(rad)); y += (wxCoord)(h*cos(rad)); CalcBoundingBox(x, y); CalcBoundingBox((wxCoord)(x + h*sin(rad)), (wxCoord)(y + h*cos(rad))); if (m_backgroundMode == wxSOLID) { // draw background first // just like DoDrawRectangle except we pass the text color to it and set the border to a 1 pixel wide text background wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::Draw Rotated Text Call plotting text background")) ; sTmp.Printf ( wxT(" <rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" "), x,y+desc-h, w, h ); s = sTmp + wxT("style=\"fill:#") + wxColStr (m_textBackgroundColour) + wxT("; ") ; s = s + wxT("stroke-width:1; stroke:#") + wxColStr (m_textBackgroundColour) + wxT("; ") ; sTmp.Printf ( wxT("\" transform=\"rotate( %.2g %d %d ) \">"), -angle, x,y ) ; s = s + sTmp + newline ; write(s); } //now do the text itself s.Printf (wxT(" <text x=\"%d\" y=\"%d\" "),x,y ); sTmp = m_font.GetFaceName () ; if (sTmp.Len () > 0) s = s + wxT("style=\"font-family:") + sTmp + wxT("; "); else s = s + wxT("style=\" ") ; wxString fontweights [3] = { wxT("normal"), wxT("lighter"), wxT("bold") }; s = s + wxT("font-weight:") + fontweights[m_font.GetWeight() - wxNORMAL] + semicolon + space; wxString fontstyles [5] = { wxT("normal"), wxT("style error"), wxT("style error"), wxT("italic"), wxT("oblique") }; s = s + wxT("font-style:") + fontstyles[m_font.GetStyle() - wxNORMAL] + semicolon + space; sTmp.Printf (wxT("font-size:%dpt; fill:#"), m_font.GetPointSize () ); s = s + sTmp ; s = s + wxColStr (m_textForegroundColour) + wxT("; stroke:#") + wxColStr (m_textForegroundColour) + wxT("; ") ; sTmp.Printf ( wxT("stroke-width:0;\" transform=\"rotate( %.2g %d %d ) \" >"), -angle, x,y ) ; s = s + sTmp + sText + wxT("</text> ") + newline ; if (m_OK) { write(s); } wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DrawRotatedText Call executed")) ; }
void wxGCDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask ) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid DC") ); wxCHECK_RET( bmp.IsOk(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid bitmap") ); int w = bmp.GetScaledWidth(); int h = bmp.GetScaledHeight(); if ( bmp.GetDepth() == 1 ) { m_graphicContext->SetPen(*wxTRANSPARENT_PEN); m_graphicContext->SetBrush(m_textBackgroundColour); m_graphicContext->DrawRectangle( x, y, w, h ); m_graphicContext->SetBrush(m_textForegroundColour); m_graphicContext->DrawBitmap( bmp, x, y, w, h ); m_graphicContext->SetBrush( m_graphicContext->CreateBrush(m_brush)); m_graphicContext->SetPen( m_graphicContext->CreatePen(m_pen)); } else // not a monochrome bitmap, handle it normally { // make a copy in case we need to remove its mask, if we don't modify // it the copy is cheap as bitmaps are reference-counted wxBitmap bmpCopy(bmp); if ( !useMask && bmp.GetMask() ) bmpCopy.SetMask(NULL); m_graphicContext->DrawBitmap( bmpCopy, x, y, w, h ); } CalcBoundingBox(x, y); CalcBoundingBox(x + w, y + h); }
void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y) { wxCHECK_RET( Ok(), wxT("invalid dc") ); wxCoord xx = XLOG2DEV(x); wxCoord yy = YLOG2DEV(y); // update the bounding box wxCoord w, h; CalcBoundingBox(x, y); GetTextExtent(text, &w, &h); CalcBoundingBox(x + w, y + h); // if background mode is solid, DrawText must paint text's background: if ( m_backgroundMode == wxSOLID ) { wxCHECK_RET( m_textBackgroundColour.Ok(), wxT("invalid background color") ); SelectColour(m_textBackgroundColour); m_surface->FillRectangle(xx, yy, XLOG2DEVREL(w), YLOG2DEVREL(h)); } // finally draw the text itself: wxCHECK_RET( m_textForegroundColour.Ok(), wxT("invalid foreground color") ); SelectColour(m_textForegroundColour); m_surface->DrawString(wxSTR_TO_DFB(text), -1, xx, yy, DSTF_LEFT | DSTF_TOP); // restore pen's colour, because other drawing functions expect the colour // to be set to the pen: SelectColour(m_pen.GetColour()); }
void wxGCDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double radius) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawRoundedRectangle - invalid DC") ); if ( !m_logicalFunctionSupported ) return; if (radius < 0.0) radius = - radius * ((w < h) ? w : h); // CMB: draw nothing if transformed w or h is 0 if (w == 0 || h == 0) return; CalcBoundingBox(x, y); CalcBoundingBox(x + w, y + h); if ( m_graphicContext->ShouldOffset() ) { // if we are offsetting the entire rectangle is moved 0.5, so the // border line gets off by 1 w -= 1; h -= 1; } m_graphicContext->DrawRoundedRectangle( x,y,w,h,radius); }
void wxGCDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawLines - invalid DC") ); wxASSERT_MSG( n > 0, wxT("wxGCDC(cg)::DoDrawLines - number of points too small") ); if ( !m_logicalFunctionSupported ) return; int minX = points[0].x; int minY = points[0].y; int maxX = minX; int maxY = minY; wxPoint2DDouble* pointsD = new wxPoint2DDouble[n]; for( int i = 0; i < n; ++i) { wxPoint p = points[i]; pointsD[i].m_x = p.x + xoffset; pointsD[i].m_y = p.y + yoffset; if (p.x < minX) minX = p.x; else if (p.x > maxX) maxX = p.x; if (p.y < minY) minY = p.y; else if (p.y > maxY) maxY = p.y; } m_graphicContext->StrokeLines( n , pointsD); delete[] pointsD; CalcBoundingBox(minX + xoffset, minY + yoffset); CalcBoundingBox(maxX + xoffset, maxY + yoffset); }
void wxGCDCImpl::DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) { wxASSERT(n > 1); wxGraphicsPath path = m_graphicContext->CreatePath(); int i = 0; for ( int j = 0; j < n; ++j) { wxPoint start = points[i]; path.MoveToPoint( start.x+ xoffset, start.y+ yoffset); ++i; int l = count[j]; for ( int k = 1; k < l; ++k) { path.AddLineToPoint( points[i].x+ xoffset, points[i].y+ yoffset); ++i; } // close the polygon if ( start != points[i-1]) path.AddLineToPoint( start.x+ xoffset, start.y+ yoffset); } m_graphicContext->DrawPath( path , fillStyle); wxRect2DDouble box = path.GetBox(); CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y)); CalcBoundingBox(wxRound(box.m_x + box.m_width), wxRound(box.m_y + box.m_height)); }
void wxGCDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double radius) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawRoundedRectangle - invalid DC") ); if ( !m_logicalFunctionSupported ) return; if (radius < 0.0) radius = - radius * ((w < h) ? w : h); // CMB: draw nothing if transformed w or h is 0 if (w == 0 || h == 0) return; CalcBoundingBox(x, y); CalcBoundingBox(x + w, y + h); if (m_pen.IsOk() && m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT && m_pen.GetWidth() > 0) { // outline is one pixel larger than what raster-based wxDC implementations draw w -= 1; h -= 1; } m_graphicContext->DrawRoundedRectangle( x,y,w,h,radius); }
void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y) { // For compatibility with other ports (notably wxGTK) and because it's // genuinely useful, we allow passing multiline strings to DrawText(). // However there is no native OSX function to draw them directly so we // instead reuse the generic DrawLabel() method to render them. Of course, // DrawLabel() itself will call back to us but with single line strings // only so there won't be any infinite recursion here. if ( str.find('\n') != wxString::npos ) { GetOwner()->DrawLabel(str, wxRect(x, y, 0, 0)); return; } wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawText - invalid DC") ); if ( str.empty() ) return; if ( !m_logicalFunctionSupported ) return; if ( m_backgroundMode == wxTRANSPARENT ) m_graphicContext->DrawText( str, x ,y); else m_graphicContext->DrawText( str, x ,y , m_graphicContext->CreateBrush(m_textBackgroundColour) ); wxCoord w, h; GetOwner()->GetTextExtent(str, &w, &h); CalcBoundingBox(x, y); CalcBoundingBox(x + w, y + h); }
void wxGCDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") ); if ( text.empty() ) return; if ( !m_logicalFunctionSupported ) return; // we test that we have some font because otherwise we should still use the // "else" part below to avoid that DrawRotatedText(angle = 180) and // DrawRotatedText(angle = 0) use different fonts (we can't use the default // font for drawing rotated fonts unfortunately) if ( (angle == 0.0) && m_font.IsOk() ) { DoDrawText(text, x, y); // Bounding box already updated by DoDrawText(), no need to do it again. return; } // Get extent of whole text. wxCoord w, h, heightLine; GetOwner()->GetMultiLineTextExtent(text, &w, &h, &heightLine); // Compute the shift for the origin of the next line. const double rad = wxDegToRad(angle); const double dx = heightLine * sin(rad); const double dy = heightLine * cos(rad); // Draw all text line by line const wxArrayString lines = wxSplit(text, '\n', '\0'); for ( size_t lineNum = 0; lineNum < lines.size(); lineNum++ ) { // Calculate origin for each line to avoid accumulation of // rounding errors. if ( m_backgroundMode == wxTRANSPARENT ) m_graphicContext->DrawText( lines[lineNum], x + wxRound(lineNum*dx), y + wxRound(lineNum*dy), wxDegToRad(angle )); else m_graphicContext->DrawText( lines[lineNum], x + wxRound(lineNum*dx), y + wxRound(lineNum*dy), wxDegToRad(angle ), m_graphicContext->CreateBrush(m_textBackgroundColour) ); } // call the bounding box by adding all four vertices of the rectangle // containing the text to it (simpler and probably not slower than // determining which of them is really topmost/leftmost/...) // "upper left" and "upper right" CalcBoundingBox(x, y); CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad))); // "bottom left" and "bottom right" x += (wxCoord)(h*sin(rad)); y += (wxCoord)(h*cos(rad)); CalcBoundingBox(x, y); CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad))); }
void wxSVGFileDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) { NewGraphicsIfNeeded(); wxString s; s = wxString::Format(wxS(" <path %sd=\"M%d %d L%d %d\"/>\n"), wxGetPenPattern(m_pen), x1, y1, x2, y2); write(s); CalcBoundingBox(x1, y1); CalcBoundingBox(x2, y2); }
void wxGCDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawEllipse - invalid DC") ); if ( !m_logicalFunctionSupported ) return; CalcBoundingBox(x, y); CalcBoundingBox(x + w, y + h); m_graphicContext->DrawEllipse(x,y,w,h); }
void wxSVGFileDCImpl::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) { NewGraphicsIfNeeded(); wxString s; s.Printf ( wxT("<path d=\"M%d %d L%d %d\" /> \n"), x1,y1,x2,y2 ); if (m_OK) { write(s); } CalcBoundingBox(x1, y1); CalcBoundingBox(x2, y2); }
void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea ) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawEllipticArc - invalid DC") ); if ( !m_logicalFunctionSupported ) return; wxCoord dx = x + w / 2.0; wxCoord dy = y + h / 2.0; wxDouble factor = ((wxDouble) w) / h; m_graphicContext->PushState(); m_graphicContext->Translate(dx, dy); m_graphicContext->Scale(factor, 1.0); wxGraphicsPath path = m_graphicContext->CreatePath(); // If end angle equals start angle we want draw a full ellipse. if (ea == sa) { ea += 360.0; } // since these angles (ea,sa) are measured counter-clockwise, we invert them to // get clockwise angles if ( m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT ) { path.MoveToPoint( 0, 0 ); path.AddArc( 0, 0, h/2.0, wxDegToRad(-sa), wxDegToRad(-ea), false ); path.AddLineToPoint( 0, 0 ); m_graphicContext->FillPath( path ); path = m_graphicContext->CreatePath(); path.AddArc( 0, 0, h/2.0, wxDegToRad(-sa), wxDegToRad(-ea), false ); m_graphicContext->StrokePath( path ); } else { path.AddArc( 0, 0, h/2.0, wxDegToRad(-sa), wxDegToRad(-ea), false ); m_graphicContext->DrawPath( path ); } wxRect2DDouble box = path.GetBox(); // apply the transformation to the box box.m_x *= factor; box.m_width *= factor; box.m_x += dx; box.m_y += dy; CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y)); CalcBoundingBox(wxRound(box.m_x + box.m_width), wxRound(box.m_y + box.m_height)); m_graphicContext->PopState(); }
void wxGCDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawLine - invalid DC") ); if ( !m_logicalFunctionSupported ) return; m_graphicContext->StrokeLine(x1,y1,x2,y2); CalcBoundingBox(x1, y1); CalcBoundingBox(x2, y2); }
void wxGCDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawIcon - invalid DC") ); wxCHECK_RET( icon.IsOk(), wxT("wxGCDC(cg)::DoDrawIcon - invalid icon") ); wxCoord w = icon.GetWidth(); wxCoord h = icon.GetHeight(); m_graphicContext->DrawIcon( icon , x, y, w, h ); CalcBoundingBox(x, y); CalcBoundingBox(x + w, y + h); }
void wxGCDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc ) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawArc - invalid DC") ); if ( !m_logicalFunctionSupported ) return; double dx = x1 - xc; double dy = y1 - yc; double radius = sqrt((double)(dx * dx + dy * dy)); wxCoord rad = (wxCoord)radius; double sa, ea; if (x1 == x2 && y1 == y2) { sa = 0.0; ea = 360.0; } else if (radius == 0.0) { sa = ea = 0.0; } else { sa = (x1 - xc == 0) ? (y1 - yc < 0) ? 90.0 : -90.0 : -atan2(double(y1 - yc), double(x1 - xc)) * RAD2DEG; ea = (x2 - xc == 0) ? (y2 - yc < 0) ? 90.0 : -90.0 : -atan2(double(y2 - yc), double(x2 - xc)) * RAD2DEG; } bool fill = m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT; wxGraphicsPath path = m_graphicContext->CreatePath(); if ( fill && ((x1!=x2)||(y1!=y2)) ) path.MoveToPoint( xc, yc ); // since these angles (ea,sa) are measured counter-clockwise, we invert them to // get clockwise angles path.AddArc( xc, yc , rad, wxDegToRad(-sa), wxDegToRad(-ea), false ); if ( fill && ((x1!=x2)||(y1!=y2)) ) path.AddLineToPoint( xc, yc ); m_graphicContext->DrawPath(path); wxRect2DDouble box = path.GetBox(); CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y)); CalcBoundingBox(wxRound(box.m_x + box.m_width), wxRound(box.m_y + box.m_height)); }
void wxDC::Clear() { wxCHECK_RET( Ok(), wxT("invalid dc") ); if ( m_backgroundBrush.GetStyle() == wxTRANSPARENT ) return; wxColour clr = m_backgroundBrush.GetColour(); m_surface->Clear(clr.Red(), clr.Green(), clr.Blue(), clr.Alpha()); wxSize size(GetSize()); CalcBoundingBox(XDEV2LOG(0), YDEV2LOG(0)); CalcBoundingBox(XDEV2LOG(size.x), YDEV2LOG(size.y)); }
void wxSVGFileDC::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) { if (m_graphics_changed) NewGraphics (); wxString s ; s.Printf ( wxT("<path d=\"M%d %d L%d %d\" /> \n"), x1,y1,x2,y2 ); if (m_OK) { write(s); } wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DrawLine Call executed")) ; CalcBoundingBox(x1, y1) ; CalcBoundingBox(x2, y2) ; return; };
void wxSVGFileDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) { NewGraphicsIfNeeded(); wxString s; s = wxString::Format(wxS(" <rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"%s\"%s"), x, y, width, height, NumStr(radius), wxGetBrushFill(m_brush)); s += wxS("/>\n"); write(s); CalcBoundingBox(x, y); CalcBoundingBox(x + width, y + height); }
cCaveTunnel::cCaveTunnel( int a_BlockStartX, int a_BlockStartY, int a_BlockStartZ, int a_StartRadius, int a_BlockEndX, int a_BlockEndY, int a_BlockEndZ, int a_EndRadius, cNoise & a_Noise ) { m_Points.push_back(cCaveDefPoint(a_BlockStartX, a_BlockStartY, a_BlockStartZ, a_StartRadius)); m_Points.push_back(cCaveDefPoint(a_BlockEndX, a_BlockEndY, a_BlockEndZ, a_EndRadius)); if ((a_BlockStartY <= 0) && (a_BlockEndY <= 0)) { // Don't bother detailing this cave, it's under the world anyway m_MinBlockX = m_MaxBlockX = 0; m_MinBlockY = m_MaxBlockY = -1; m_MinBlockZ = m_MaxBlockZ = 0; return; } Randomize(a_Noise); Smooth(); // We know that the linear finishing won't affect the bounding box, so let's calculate it now, as we have less data: CalcBoundingBox(); FinishLinear(); }
void wxSVGFileDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { NewGraphicsIfNeeded(); int rh = height / 2; int rw = width / 2; wxString s; s = wxString::Format(wxS(" <ellipse cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\""), x + rw, y + rh, rw, rh); s += wxS("/>\n"); write(s); CalcBoundingBox(x, y); CalcBoundingBox(x + width, y + height); }
void wxGCDCImpl::DoCrossHair( wxCoord x, wxCoord y ) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoCrossHair - invalid DC") ); if ( !m_logicalFunctionSupported ) return; int w = 0, h = 0; GetOwner()->GetSize( &w, &h ); m_graphicContext->StrokeLine(0,y,w,y); m_graphicContext->StrokeLine(x,0,x,h); CalcBoundingBox(0, 0); CalcBoundingBox(w, h); }
void wxGCDCImpl::DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection ) { wxPoint start; wxPoint end; switch( nDirection) { case wxWEST : start = rect.GetRightBottom(); start.x++; end = rect.GetLeftBottom(); break; case wxEAST : start = rect.GetLeftBottom(); end = rect.GetRightBottom(); end.x++; break; case wxNORTH : start = rect.GetLeftBottom(); start.y++; end = rect.GetLeftTop(); break; case wxSOUTH : start = rect.GetLeftTop(); end = rect.GetLeftBottom(); end.y++; break; default : break; } if (rect.width == 0 || rect.height == 0) return; m_graphicContext->SetBrush( m_graphicContext->CreateLinearGradientBrush( start.x,start.y,end.x,end.y, initialColour, destColour)); m_graphicContext->SetPen(*wxTRANSPARENT_PEN); m_graphicContext->DrawRectangle(rect.x,rect.y,rect.width,rect.height); m_graphicContext->SetPen(m_pen); m_graphicContext->SetBrush(m_brush); CalcBoundingBox(rect.x, rect.y); CalcBoundingBox(rect.x + rect.width, rect.y + rect.height); }
void wxSVGFileDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) { if (m_graphics_changed) NewGraphics (); wxString s ; s.Printf ( wxT(" <rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"%.2g\" "), x, y, width, height, radius ); s = s + wxT(" /> ") + newline ; write(s); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawRoundedRectangle Call executed")) ; CalcBoundingBox(x, y) ; CalcBoundingBox(x + width, y + height) ; }
void wxSVGFileDC::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord height) { if (m_graphics_changed) NewGraphics (); int rh = height /2 ; int rw = width /2 ; wxString s; s.Printf ( wxT("<ellipse cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" "), x+rw,y+rh, rw, rh ); s = s + wxT(" /> ") + newline ; write(s); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawEllipse Call executed")) ; CalcBoundingBox(x, y) ; CalcBoundingBox(x + width, y + height) ; }
bool wxDFBDCImpl::DoBlitFromSurface(const wxIDirectFBSurfacePtr& src, wxCoord srcx, wxCoord srcy, wxCoord w, wxCoord h, wxCoord dstx, wxCoord dsty) { // don't do anything if the source rectangle is outside of source surface, // DirectFB would assert in that case: wxSize srcsize; src->GetSize(&srcsize.x, &srcsize.y); if ( !wxRect(srcx, srcy, w, h).Intersects(wxRect(srcsize)) ) { wxLogDebug("Blitting from area outside of the source surface, caller code needs fixing."); return false; } CalcBoundingBox(dstx, dsty); CalcBoundingBox(dstx + w, dsty + h); DFBRectangle srcRect = { srcx, srcy, w, h }; DFBRectangle dstRect = { XLOG2DEV(dstx), YLOG2DEV(dsty), XLOG2DEVREL(w), YLOG2DEVREL(h) }; wxIDirectFBSurfacePtr dst(m_surface); // FIXME: this will have to be different in useMask case, see above DFBSurfaceBlittingFlags blitFlag = (src->GetPixelFormat() == DSPF_ARGB) ? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX; if ( !dst->SetBlittingFlags(blitFlag) ) return false; if ( srcRect.w != dstRect.w || srcRect.h != dstRect.h ) { // the bitmap is drawn stretched: dst->StretchBlit(src, &srcRect, &dstRect); } else { // no stretching, size is preserved: dst->Blit(src, &srcRect, dstRect.x, dstRect.y); } return true; }
void wxGCDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawEllipse - invalid DC") ); if ( !m_logicalFunctionSupported ) return; CalcBoundingBox(x, y); CalcBoundingBox(x + w, y + h); if ( m_graphicContext->ShouldOffset() ) { // if we are offsetting the entire rectangle is moved 0.5, so the // border line gets off by 1 w -= 1; h -= 1; } m_graphicContext->DrawEllipse(x,y,w,h); }
void ComputeBoundingBox(UStaticMesh* StaticMesh, FVector& Center, FVector& Extents) { // Calculate bounding Box. FRawMesh RawMesh; FStaticMeshSourceModel& SrcModel = StaticMesh->SourceModels[0]; SrcModel.RawMeshBulkData->LoadRawMesh(RawMesh); FVector unitVec = FVector(1.f); CalcBoundingBox(RawMesh, Center, Extents, unitVec); }
void wxGCDCImpl::DoDrawPolygon( int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle ) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawPolygon - invalid DC") ); if ( n <= 0 || (m_brush.GetStyle() == wxBRUSHSTYLE_TRANSPARENT && m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) ) return; if ( !m_logicalFunctionSupported ) return; bool closeIt = false; if (points[n-1] != points[0]) closeIt = true; int minX = points[0].x; int minY = points[0].y; int maxX = minX; int maxY = minY; wxPoint2DDouble* pointsD = new wxPoint2DDouble[n+(closeIt?1:0)]; for( int i = 0; i < n; ++i) { wxPoint p = points[i]; pointsD[i].m_x = p.x + xoffset; pointsD[i].m_y = p.y + yoffset; if (p.x < minX) minX = p.x; else if (p.x > maxX) maxX = p.x; if (p.y < minY) minY = p.y; else if (p.y > maxY) maxY = p.y; } if ( closeIt ) pointsD[n] = pointsD[0]; m_graphicContext->DrawLines( n+(closeIt?1:0) , pointsD, fillStyle); delete[] pointsD; CalcBoundingBox(minX + xoffset, minY + yoffset); CalcBoundingBox(maxX + xoffset, maxY + yoffset); }