Kaydet (Commit) 2813d70f authored tarafından Armin Le Grand's avatar Armin Le Grand

borderline: move geometry creation to linear algebra

Adapted Array::DrawRange to Style/Vector usages, feeding new
CreateBorderPrimitives method. That one roughly feeds the old
implementations to test and check (and keep working)

Change-Id: I09557f826cd023d27db6b53e53aa69c149308711
üst a9c59cbf
......@@ -334,41 +334,36 @@ SVX_DLLPUBLIC void CreateBorderPrimitives(
const Color* pForceColor /// If specified, overrides frame border color.
);
/** Draws both diagonal frame borders, regards all connected frame styles.
One or both passed diagonal frame styles may be invisible.
The function preserves all settings of the passed output device.
*/
SVX_DLLPUBLIC void CreateDiagFrameBorderPrimitives(
drawinglayer::primitive2d::Primitive2DContainer& rTarget, /// target for created primitives
const basegfx::B2DPoint& rOrigin, /// Origin of the coordinate system spawning the cell
const basegfx::B2DVector& rXAxis, /// X-Axis of the coordinate system spawning the cell
const basegfx::B2DVector& rYAxis, /// Y-Axis of the coordinate system spawning the cell
class StyleVectorCombination
{
private:
const Style& mrStyle;
const basegfx::B2DVector& mrB2DVector;
const Style& rTLBR, /// Style of the processed top-left to bottom-right diagonal frame border.
const Style& rBLTR, /// Style of the processed bottom-left to top-right diagonal frame border.
public:
StyleVectorCombination(const Style& rStyle, const basegfx::B2DVector& rB2DVector) :
mrStyle(rStyle),
mrB2DVector(rB2DVector)
{}
const Style& rTLFromB, /// Vertical frame border from bottom to top-left end of rTLBR.
const Style& rTLFromR, /// Horizontal frame border from right to top-left end of rTLBR.
const Style& rBRFromT, /// Vertical frame border from top to bottom-right end of rTLBR.
const Style& rBRFromL, /// Horizontal frame border from left to bottom-right end of rTLBR.
const Style& getStyle() const { return mrStyle; }
const basegfx::B2DVector& getB2DVector() const { return mrB2DVector; }
};
const Style& rBLFromT, /// Vertical frame border from top to bottom-left end of rBLTR.
const Style& rBLFromR, /// Horizontal frame border from right to bottom-left end of rBLTR.
const Style& rTRFromB, /// Vertical frame border from bottom to top-right end of rBLTR.
const Style& rTRFromL, /// Horizontal frame border from left to top-right end of rBLTR.
typedef std::vector< StyleVectorCombination > StyleVectorTable;
const Color* pForceColor /// If specified, overrides frame border color.
SVX_DLLPUBLIC void CreateBorderPrimitives(
drawinglayer::primitive2d::Primitive2DContainer& rTarget, /// target for created primitives
const basegfx::B2DPoint& rOrigin, /// start point of borderline
const basegfx::B2DVector& rX, /// X-Axis of borderline with length
const Style& rBorder, /// Style of borderline
const StyleVectorTable& rStartStyleVectorTable, /// Styles and vectors (pointing away) at borderline start, ccw
const StyleVectorTable& rEndStyleVectorTable, /// Styles and vectors (pointing away) at borderline end, cw
const Color* pForceColor /// If specified, overrides frame border color.
);
}
}
/* Yes, I love ASCII art. :-) -DR- */
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -620,6 +620,44 @@ void CreateBorderPrimitives(
}
}
void CreateBorderPrimitives(
drawinglayer::primitive2d::Primitive2DContainer& rTarget,
const basegfx::B2DPoint& rOrigin,
const basegfx::B2DVector& rX,
const Style& rBorder,
const StyleVectorTable& rStartStyleVectorTable,
const StyleVectorTable& rEndStyleVectorTable,
const Color* pForceColor)
{
/// rough mapping for testing
if (rBorder.Prim() || rBorder.Secn())
{
const size_t nStart(rStartStyleVectorTable.size());
const size_t nEnd(rEndStyleVectorTable.size());
CreateBorderPrimitives(
rTarget,
rOrigin,
rX,
basegfx::getNormalizedPerpendicular(rX),
rBorder,
2 == nStart ? rStartStyleVectorTable[0].getStyle() : 5 == nStart ? rStartStyleVectorTable[0].getStyle() : Style(),
5 == nStart ? rStartStyleVectorTable[1].getStyle() : Style(),
5 == nStart ? rStartStyleVectorTable[2].getStyle() : Style(),
5 == nStart ? rStartStyleVectorTable[3].getStyle() : Style(),
2 == nStart ? rStartStyleVectorTable[1].getStyle() : 5 == nStart ? rStartStyleVectorTable[4].getStyle() : Style(),
2 == nEnd ? rEndStyleVectorTable[0].getStyle() : 5 == nEnd ? rEndStyleVectorTable[0].getStyle() : Style(),
5 == nEnd ? rEndStyleVectorTable[1].getStyle() : Style(),
5 == nEnd ? rEndStyleVectorTable[2].getStyle() : Style(),
5 == nEnd ? rEndStyleVectorTable[3].getStyle() : Style(),
2 == nEnd ? rEndStyleVectorTable[1].getStyle() : 5 == nEnd ? rEndStyleVectorTable[4].getStyle() : Style(),
pForceColor);
}
}
void CreateBorderPrimitives(
drawinglayer::primitive2d::Primitive2DContainer& rTarget,
const basegfx::B2DPoint& rOrigin,
......@@ -656,98 +694,6 @@ void CreateBorderPrimitives(
}
}
void CreateDiagFrameBorderPrimitives(
drawinglayer::primitive2d::Primitive2DContainer& rTarget,
const basegfx::B2DPoint& rOrigin,
const basegfx::B2DVector& rXAxis,
const basegfx::B2DVector& rYAxis,
const Style& rTLBR,
const Style& rBLTR,
const Style& /*rTLFromB*/,
const Style& /*rTLFromR*/,
const Style& /*rBRFromT*/,
const Style& /*rBRFromL*/,
const Style& /*rBLFromT*/,
const Style& /*rBLFromR*/,
const Style& /*rTRFromB*/,
const Style& /*rTRFromL*/,
const Color* pForceColor)
{
// currently the diagonal edges are just added as-is without cutting them against the incoming
// edges. This needs to be improved in the future, so please do *not* remove the currently unused
// parameters from above
if (rTLBR.Prim())
{
// top-left to bottom-right
if (basegfx::fTools::equalZero(rTLBR.Secn()))
{
rTarget.append(
new drawinglayer::primitive2d::BorderLinePrimitive2D(
rOrigin,
rOrigin + rXAxis + rYAxis,
drawinglayer::primitive2d::BorderLine(
rTLBR.Prim(),
(pForceColor ? *pForceColor : rTLBR.GetColorPrim()).getBColor()),
rTLBR.Type(),
rTLBR.PatternScale()));
}
else
{
rTarget.append(
new drawinglayer::primitive2d::BorderLinePrimitive2D(
rOrigin,
rOrigin + rXAxis + rYAxis,
drawinglayer::primitive2d::BorderLine(
rTLBR.Prim(),
(pForceColor ? *pForceColor : rTLBR.GetColorPrim()).getBColor()),
drawinglayer::primitive2d::BorderLine(
rTLBR.Dist(),
(pForceColor ? *pForceColor : rTLBR.GetColorGap()).getBColor()),
drawinglayer::primitive2d::BorderLine(
rTLBR.Secn(),
(pForceColor ? *pForceColor : rTLBR.GetColorSecn()).getBColor()),
rTLBR.UseGapColor(),
rTLBR.Type(),
rTLBR.PatternScale()));
}
}
if (rBLTR.Prim())
{
// bottom-left to top-right
if (basegfx::fTools::equalZero(rTLBR.Secn()))
{
rTarget.append(
new drawinglayer::primitive2d::BorderLinePrimitive2D(
rOrigin + rYAxis,
rOrigin + rXAxis,
drawinglayer::primitive2d::BorderLine(
rTLBR.Prim(),
(pForceColor ? *pForceColor : rTLBR.GetColorPrim()).getBColor()),
rBLTR.Type(),
rBLTR.PatternScale()));
}
else
{
rTarget.append(
new drawinglayer::primitive2d::BorderLinePrimitive2D(
rOrigin + rYAxis,
rOrigin + rXAxis,
drawinglayer::primitive2d::BorderLine(
rTLBR.Prim(),
(pForceColor ? *pForceColor : rTLBR.GetColorPrim()).getBColor()),
drawinglayer::primitive2d::BorderLine(
rTLBR.Dist(),
(pForceColor ? *pForceColor : rTLBR.GetColorGap()).getBColor()),
drawinglayer::primitive2d::BorderLine(
rTLBR.Secn(),
(pForceColor ? *pForceColor : rTLBR.GetColorSecn()).getBColor()),
rBLTR.UseGapColor(),
rBLTR.Type(),
rBLTR.PatternScale()));
}
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment