// decompose grid matrix to get logic size
basegfx::B2DVector aScale, aTranslate; double fRotate, fShearX;
getTransform().decompose(aScale, aTranslate, fRotate, fShearX);
// create grid matrix which transforms from scaled logic to view
basegfx::B2DHomMatrix aRST(basegfx::utils::createShearXRotateTranslateB2DHomMatrix(
fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
aRST *= rViewInformation.getObjectToViewTransformation();
// get step widths double fStepX(getWidth()); double fStepY(getHeight()); constdouble fMinimalStep(10.0);
// guarantee a step width of 10.0 if(basegfx::fTools::less(fStepX, fMinimalStep))
{
fStepX = fMinimalStep;
}
// put to aExtendedViewport and crop on object logic size
aExtendedViewport = basegfx::B2DRange(
std::max(fMinX, 0.0),
std::max(fMinY, 0.0),
std::min(fMaxX, aScale.getX()),
std::min(fMaxY, aScale.getY()));
}
}
if(aExtendedViewport.isEmpty()) return nullptr;
// prepare point vectors for point and cross markers
std::vector< basegfx::B2DPoint > aPositionsPoint;
std::vector< basegfx::B2DPoint > aPositionsCross;
for(double fX(aExtendedViewport.getMinX()); fX < aExtendedViewport.getMaxX(); fX += fStepX)
{ constbool bXZero(basegfx::fTools::equalZero(fX));
if(!bXZero && !bYZero)
{ // get discrete position and test against 3x3 area surrounding it // since it's a cross constdouble fHalfCrossSize(3.0 * 0.5); const basegfx::B2DPoint aViewPos(aRST * basegfx::B2DPoint(fX, fY)); const basegfx::B2DRange aDiscreteRangeCross(
aViewPos.getX() - fHalfCrossSize, aViewPos.getY() - fHalfCrossSize,
aViewPos.getX() + fHalfCrossSize, aViewPos.getY() + fHalfCrossSize);
// prepare return value const sal_uInt32 nCountPoint(aPositionsPoint.size()); const sal_uInt32 nCountCross(aPositionsCross.size());
// add PointArrayPrimitive2D if point markers were added
Primitive2DContainer aContainer; if(nCountPoint)
{
aContainer.push_back(new PointArrayPrimitive2D(std::move(aPositionsPoint), getBColor()));
}
// add MarkerArrayPrimitive2D if cross markers were added if(!nCountCross) returnnew GroupPrimitive2D(std::move(aContainer));
if(!getSubdivisionsX() && !getSubdivisionsY())
{ // no subdivisions, so fall back to points at grid positions, no need to // visualize a difference between divisions and sub-divisions
aContainer.push_back(new PointArrayPrimitive2D(std::move(aPositionsCross), getBColor()));
} else
{
aContainer.push_back(new MarkerArrayPrimitive2D(std::move(aPositionsCross), getCrossMarker()));
} returnnew GroupPrimitive2D(std::move(aContainer));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.