//----------------------------------------------------------------------------- void GdiplusDrawContext::fillRadialGradient (CGraphicsPath* _path, const CGradient& gradient, const CPoint& center, CCoord radius, const CPoint& originOffset, bool evenOdd, CGraphicsTransform* t) { #if DEBUG DebugPrint ("WARNING: GdiplusDrawContext::fillRadialGradient is not working as expected ! FIXME\n"); #endif GdiplusGraphicsPath* gdiPlusPath = dynamic_cast<GdiplusGraphicsPath*> (_path); if (gdiPlusPath && pGraphics) { GdiplusDrawScope drawScope (pGraphics, currentState.clipRect, getCurrentTransform ()); Gdiplus::GraphicsPath* path = gdiPlusPath->getGraphicsPath (); if (t) { Gdiplus::Matrix matrix; convert (matrix, *t); path = path->Clone (); path->Transform (&matrix); } path->SetFillMode (evenOdd ? Gdiplus::FillModeAlternate : Gdiplus::FillModeWinding); Gdiplus::PointF c1p ((Gdiplus::REAL)(center.x + originOffset.x), (Gdiplus::REAL)(center.y + originOffset.y)); CRect boundingBox = gdiPlusPath->getBoundingBox (); Gdiplus::GraphicsPath brushPath; brushPath.AddEllipse ((Gdiplus::REAL)boundingBox.left, (Gdiplus::REAL)boundingBox.top, (Gdiplus::REAL)boundingBox.getWidth (), (Gdiplus::REAL)boundingBox.getHeight ()); Gdiplus::Matrix graphicsMatrix; pGraphics->GetTransform (&graphicsMatrix); brushPath.Transform (&graphicsMatrix); Gdiplus::PathGradientBrush brush (&brushPath); // set center brush.SetCenterPoint (c1p); // set the colors Gdiplus::Color* colors = new Gdiplus::Color [gradient.getColorStops ().size ()]; Gdiplus::REAL* positions = new Gdiplus::REAL [gradient.getColorStops ().size ()]; uint32_t index = 0; for (CGradient::ColorStopMap::const_iterator it = gradient.getColorStops ().begin (); it != gradient.getColorStops ().end (); ++it, ++index) { CColor color = it->second; color.alpha = (int8_t)((float)color.alpha * currentState.globalAlpha); colors[index] = createGdiPlusColor (color); positions[index] = (Gdiplus::REAL)it->first; } brush.SetCenterColor (colors[0]); INT count = static_cast<INT> (gradient.getColorStops ().size ()) - 1; brush.SetSurroundColors (colors+1, &count); pGraphics->FillPath (&brush, path); if (path != gdiPlusPath->getGraphicsPath ()) delete path; delete [] colors; delete [] positions; } }
//----------------------------------------------------------------------------- void GdiplusDrawContext::fillLinearGradient (CGraphicsPath* _path, const CGradient& gradient, const CPoint& startPoint, const CPoint& endPoint, bool evenOdd, CGraphicsTransform* t) { #if DEBUG DebugPrint ("WARNING: GdiplusDrawContext::fillLinearGradient is not working as expected ! FIXME"); #endif GdiplusGraphicsPath* gdiPlusPath = dynamic_cast<GdiplusGraphicsPath*> (_path); if (gdiPlusPath && pGraphics) { GdiplusDrawScope drawScope (pGraphics, currentState.clipRect, getCurrentTransform ()); Gdiplus::GraphicsPath* path = gdiPlusPath->getGraphicsPath (); if (t) { Gdiplus::Matrix matrix; convert (matrix, *t); path = path->Clone (); path->Transform (&matrix); } Gdiplus::Color* colors = new Gdiplus::Color [gradient.getColorStops ().size ()]; Gdiplus::REAL* positions = new Gdiplus::REAL [gradient.getColorStops ().size ()]; uint32_t index = 0; for (CGradient::ColorStopMap::const_iterator it = gradient.getColorStops ().begin (); it != gradient.getColorStops ().end (); ++it, ++index) { CColor color = it->second; color.alpha = (int8_t)((float)color.alpha * currentState.globalAlpha); colors[index] = createGdiPlusColor (color); positions[index] = (Gdiplus::REAL)it->first; } Gdiplus::PointF c1p ((Gdiplus::REAL)(startPoint.x), (Gdiplus::REAL)(startPoint.y)); Gdiplus::PointF c2p ((Gdiplus::REAL)(endPoint.x), (Gdiplus::REAL)(endPoint.y)); Gdiplus::LinearGradientBrush brush (c1p, c2p, colors[0], colors[gradient.getColorStops ().size () - 1]); brush.SetInterpolationColors (colors, positions, static_cast<INT> (gradient.getColorStops ().size ())); path->SetFillMode (evenOdd ? Gdiplus::FillModeAlternate : Gdiplus::FillModeWinding); pGraphics->FillPath (&brush, path); if (path != gdiPlusPath->getGraphicsPath ()) delete path; delete [] colors; delete [] positions; } }
TopAbs_State GEOMAlgo_FinderShapeOnQuad::GetPointState(const gp_Pnt& aP) { // Return IN if aP has TopAbs_IN with all sides. // In the case of concave quadrangle, return IN if // aP is OUT of only one concave side double nbIn = 0.; for ( int i = 0; i < myPlanes.size(); ++i ) { TopAbs_State aSt; GEOMAlgo_SurfaceTools::GetState(aP, myPlanes[i], myTolerance, aSt); if ( aSt == TopAbs_IN ) { nbIn += myConcaveSide[i] ? 0.5 : 1.0; } else if ( aSt == TopAbs_ON ) { // check that aP is between quadrangle corners Handle(Geom_Plane) aSidePlane = Handle(Geom_Plane)::DownCast( myPlanes[i].Surface() ); gp_Vec aSideNorm = aSidePlane->Axis().Direction(); gp_Vec aSideVec = myQuadNormal ^ aSideNorm; gp_Vec c1p ( myPoints[i], aP ); gp_Vec pc2 ( aP, myPoints[i+1] ); if ( aSideVec * c1p >= 0. && aSideVec * pc2 >= 0. ) return TopAbs_ON; // consider to be IN (???????????) //nbIn += myConcaveSide[i] ? 0.5 : 1.0; } } Standard_Real inThreshold = myPlanes.size(); // usually 4.0 if ( myConcaveQuad ) inThreshold = 2.5; // 1.0 + 1.0 + 0.5 if ( nbIn >= inThreshold ) return TopAbs_IN; return TopAbs_OUT; }