35 lines
1.4 KiB
C++
35 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "model/EditorTypes.h"
|
|
#include "ShapeTypes.h"
|
|
|
|
namespace TikzRefinery {
|
|
|
|
// Shared with parsing: gesture bounds must include the same ink envelope.
|
|
struct ShapeGeometryLimits
|
|
{
|
|
static constexpr qreal rMinimumRectangleCentimeters = ShapeApi::rMinimumRectangleCentimeters;
|
|
static constexpr int iCoordinateDecimals = ShapeApi::iCoordinateDecimals;
|
|
static constexpr qreal rCoordinateStepsPerCentimeter = ShapeApi::rCoordinateStepsPerCentimeter;
|
|
static constexpr qreal rCentimetersPerInch = 2.54;
|
|
static constexpr qreal rTexPointsPerInch = 72.27;
|
|
static constexpr qreal rHalfStroke = 0.5;
|
|
static constexpr qreal rArrowTipBasePoints = 0.28;
|
|
static constexpr qreal rArrowTipWidthFactor = 0.3;
|
|
static constexpr qreal rArrowTipSpanFactor = 4.0;
|
|
static constexpr qreal rArrowStrokeFactor = 0.4;
|
|
};
|
|
|
|
inline qreal outlineMarginCentimeters(const ElementRecord &element)
|
|
{
|
|
using Limits = ShapeGeometryLimits;
|
|
const qreal rEnvelopePoints = element.elementKind == ElementKind::Arrow
|
|
? Limits::rArrowTipSpanFactor * (Limits::rArrowTipBasePoints
|
|
+ Limits::rArrowTipWidthFactor * element.rLineWidthPoints)
|
|
+ Limits::rArrowStrokeFactor * element.rLineWidthPoints
|
|
: Limits::rHalfStroke * element.rLineWidthPoints;
|
|
return rEnvelopePoints * Limits::rCentimetersPerInch / Limits::rTexPointsPerInch;
|
|
}
|
|
|
|
} // namespace TikzRefinery
|