CWS-TOOLING: integrate CWS aw066_DEV300
2009-03-19 17:20:55 +0100 aw r269762 : #i99662# enhanced MetaFile paint by avoiding single pixel scalings due to MapMode errors 2009-03-19 17:20:18 +0100 aw r269761 : #i99662# enhanced 3D AA by using the SnapHorVerLinesToDiscrete options flag to unify the hor/ver hairlines
This commit is contained in:
@@ -174,6 +174,20 @@ namespace basegfx
|
||||
bool equal(const B3DPolygon& rCandidateA, const B3DPolygon& rCandidateB, const double& rfSmallValue);
|
||||
bool equal(const B3DPolygon& rCandidateA, const B3DPolygon& rCandidateB);
|
||||
|
||||
/** snap some polygon coordinates to discrete coordinates
|
||||
|
||||
This method allows to snap some polygon points to discrete (integer) values
|
||||
which equals e.g. a snap to discrete coordinates. It will snap points of
|
||||
horizontal and vertical edges
|
||||
|
||||
@param rCandidate
|
||||
The source polygon
|
||||
|
||||
@return
|
||||
The modified version of the source polygon
|
||||
*/
|
||||
B3DPolygon snapPointsOfHorizontalOrVerticalEdges(const B3DPolygon& rCandidate);
|
||||
|
||||
} // end of namespace tools
|
||||
} // end of namespace basegfx
|
||||
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#include <basegfx/matrix/b3dhommatrix.hxx>
|
||||
#include <basegfx/polygon/b2dpolygon.hxx>
|
||||
#include <basegfx/polygon/b2dpolygontools.hxx>
|
||||
#include <basegfx/tuple/b3ituple.hxx>
|
||||
#include <numeric>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1101,6 +1102,67 @@ namespace basegfx
|
||||
return equal(rCandidateA, rCandidateB, fSmallValue);
|
||||
}
|
||||
|
||||
// snap points of horizontal or vertical edges to discrete values
|
||||
B3DPolygon snapPointsOfHorizontalOrVerticalEdges(const B3DPolygon& rCandidate)
|
||||
{
|
||||
const sal_uInt32 nPointCount(rCandidate.count());
|
||||
|
||||
if(nPointCount > 1)
|
||||
{
|
||||
// Start by copying the source polygon to get a writeable copy. The closed state is
|
||||
// copied by aRetval's initialisation, too, so no need to copy it in this method
|
||||
B3DPolygon aRetval(rCandidate);
|
||||
|
||||
// prepare geometry data. Get rounded from original
|
||||
B3ITuple aPrevTuple(basegfx::fround(rCandidate.getB3DPoint(nPointCount - 1)));
|
||||
B3DPoint aCurrPoint(rCandidate.getB3DPoint(0));
|
||||
B3ITuple aCurrTuple(basegfx::fround(aCurrPoint));
|
||||
|
||||
// loop over all points. This will also snap the implicit closing edge
|
||||
// even when not closed, but that's no problem here
|
||||
for(sal_uInt32 a(0); a < nPointCount; a++)
|
||||
{
|
||||
// get next point. Get rounded from original
|
||||
const bool bLastRun(a + 1 == nPointCount);
|
||||
const sal_uInt32 nNextIndex(bLastRun ? 0 : a + 1);
|
||||
const B3DPoint aNextPoint(rCandidate.getB3DPoint(nNextIndex));
|
||||
const B3ITuple aNextTuple(basegfx::fround(aNextPoint));
|
||||
|
||||
// get the states
|
||||
const bool bPrevVertical(aPrevTuple.getX() == aCurrTuple.getX());
|
||||
const bool bNextVertical(aNextTuple.getX() == aCurrTuple.getX());
|
||||
const bool bPrevHorizontal(aPrevTuple.getY() == aCurrTuple.getY());
|
||||
const bool bNextHorizontal(aNextTuple.getY() == aCurrTuple.getY());
|
||||
const bool bSnapX(bPrevVertical || bNextVertical);
|
||||
const bool bSnapY(bPrevHorizontal || bNextHorizontal);
|
||||
|
||||
if(bSnapX || bSnapY)
|
||||
{
|
||||
const B3DPoint aSnappedPoint(
|
||||
bSnapX ? aCurrTuple.getX() : aCurrPoint.getX(),
|
||||
bSnapY ? aCurrTuple.getY() : aCurrPoint.getY(),
|
||||
aCurrPoint.getZ());
|
||||
|
||||
aRetval.setB3DPoint(a, aSnappedPoint);
|
||||
}
|
||||
|
||||
// prepare next point
|
||||
if(!bLastRun)
|
||||
{
|
||||
aPrevTuple = aCurrTuple;
|
||||
aCurrPoint = aNextPoint;
|
||||
aCurrTuple = aNextTuple;
|
||||
}
|
||||
}
|
||||
|
||||
return aRetval;
|
||||
}
|
||||
else
|
||||
{
|
||||
return rCandidate;
|
||||
}
|
||||
}
|
||||
|
||||
} // end of namespace tools
|
||||
} // end of namespace basegfx
|
||||
|
||||
|
Reference in New Issue
Block a user