/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// 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.