summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2017-08-11 18:32:33 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2017-09-15 12:58:03 +0200
commitfe14ddf25003c0f79f9f8a249bc22d45f57a0068 (patch)
treef0470ccd992a439bf52b83688d818c776bcd733e /drawinglayer
parent596efaad51735a130e7b7bd27dbc34dc07f32f68 (diff)
borderline: Abstraction of BorderLinePrimitive
As preparation for more detailed definition of BorderLine primitives I have adapted the BorderLine definition to work with motre possibilities to define the LineStartEnd definitions in a BorderLineExtend class. That one is flexible to hold all kinds of definitions - from none to all four possible extends (Start/End, Left/Right of vector) Cleanup of DiagStyle and others: DiagStyle is not needed anymore due to no longer using angles calculated, but being based on vectors defining the geometry. Also cleaned up quite a bit of no longer needed calculation stuff for the control.
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/qa/unit/border.cxx36
-rw-r--r--drawinglayer/source/primitive2d/baseprimitive2d.cxx1
-rw-r--r--drawinglayer/source/primitive2d/borderlineprimitive2d.cxx142
-rw-r--r--drawinglayer/source/processor2d/vclpixelprocessor2d.hxx1
4 files changed, 157 insertions, 23 deletions
diff --git a/drawinglayer/qa/unit/border.cxx b/drawinglayer/qa/unit/border.cxx
index 326c5deaa163..a070f9cdff24 100644
--- a/drawinglayer/qa/unit/border.cxx
+++ b/drawinglayer/qa/unit/border.cxx
@@ -65,9 +65,21 @@ void DrawinglayerBorderTest::testDoubleDecompositionSolid()
new drawinglayer::primitive2d::BorderLinePrimitive2D(
aStart,
aEnd,
- drawinglayer::primitive2d::BorderLine(fLeftWidth, aColorLeft, fExtendLeftStart, fExtendLeftEnd),
- drawinglayer::primitive2d::BorderLine(fDistance, aColorGap),
- drawinglayer::primitive2d::BorderLine(fRightWidth, aColorRight, fExtendRightStart, fExtendRightEnd),
+ drawinglayer::primitive2d::BorderLine(
+ fLeftWidth,
+ aColorLeft,
+ drawinglayer::primitive2d::BorderLineExtend(
+ fExtendLeftStart,
+ fExtendLeftEnd)),
+ drawinglayer::primitive2d::BorderLine(
+ fDistance,
+ aColorGap),
+ drawinglayer::primitive2d::BorderLine(
+ fRightWidth,
+ aColorRight,
+ drawinglayer::primitive2d::BorderLineExtend(
+ fExtendRightStart,
+ fExtendRightEnd)),
bHasGapColor,
nStyle));
@@ -121,9 +133,21 @@ void DrawinglayerBorderTest::testDoublePixelProcessing()
new drawinglayer::primitive2d::BorderLinePrimitive2D(
aStart,
aEnd,
- drawinglayer::primitive2d::BorderLine(fLeftWidth, aColorLeft, fExtendLeftStart, fExtendLeftEnd),
- drawinglayer::primitive2d::BorderLine(fDistance, aColorGap),
- drawinglayer::primitive2d::BorderLine(fRightWidth, aColorRight, fExtendRightStart, fExtendRightEnd),
+ drawinglayer::primitive2d::BorderLine(
+ fLeftWidth,
+ aColorLeft,
+ drawinglayer::primitive2d::BorderLineExtend(
+ fExtendLeftStart,
+ fExtendLeftEnd)),
+ drawinglayer::primitive2d::BorderLine(
+ fDistance,
+ aColorGap),
+ drawinglayer::primitive2d::BorderLine(
+ fRightWidth,
+ aColorRight,
+ drawinglayer::primitive2d::BorderLineExtend(
+ fExtendRightStart,
+ fExtendRightEnd)),
bHasGapColor,
nStyle));
diff --git a/drawinglayer/source/primitive2d/baseprimitive2d.cxx b/drawinglayer/source/primitive2d/baseprimitive2d.cxx
index bdb96f96d423..581f0c421c75 100644
--- a/drawinglayer/source/primitive2d/baseprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/baseprimitive2d.cxx
@@ -367,7 +367,6 @@ namespace drawinglayer
case PRIMITIVE2D_ID_PATTERNFILLPRIMITIVE2D: return OUString("PATTERNFILL");
case PRIMITIVE2D_ID_OBJECTINFOPRIMITIVE2D: return OUString("OBJECTINFO");
case PRIMITIVE2D_ID_POLYPOLYGONSELECTIONPRIMITIVE2D: return OUString("POLYPOLYGONSELECTION");
- case PRIMITIVE2D_ID_CLIPPEDBORDERLINEPRIMITIVE2D: return OUString("CLIPPEDBORDERLINE");
default: return OUString::number((nId >> 16) & 0xFF) + "|" + OUString::number(nId & 0xFF);
}
}
diff --git a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
index dae52a26f0c6..47da04a10945 100644
--- a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx
@@ -37,15 +37,128 @@ namespace drawinglayer
{
namespace primitive2d
{
+ BorderLineExtend::BorderLineExtend()
+ : mfExtends()
+ {
+ }
+
+ BorderLineExtend::BorderLineExtend(
+ double fStart,
+ double fEnd)
+ : mfExtends(2)
+ {
+ mfExtends[0] = fStart;
+ mfExtends[1] = fEnd;
+ }
+
+ BorderLineExtend::BorderLineExtend(
+ double fStartLeft,
+ double fStartRight,
+ double fEndLeft,
+ double fEndRight)
+ : mfExtends(4)
+ {
+ mfExtends[0] = fStartLeft;
+ mfExtends[1] = fStartRight;
+ mfExtends[2] = fEndLeft;
+ mfExtends[3] = fEndRight;
+ }
+
+ BorderLineExtend::~BorderLineExtend()
+ {
+ }
+
+ bool BorderLineExtend::equalStart() const
+ {
+ if (mfExtends.empty()|| 2 == mfExtends.size())
+ return true;
+ return mfExtends[0] == mfExtends[1];
+ }
+
+ bool BorderLineExtend::equalEnd() const
+ {
+ if (mfExtends.empty() || 2 == mfExtends.size())
+ return true;
+ return mfExtends[2] == mfExtends[3];
+ }
+
+ double BorderLineExtend::getStartLeft() const
+ {
+ if (mfExtends.empty())
+ return 0.0;
+ return mfExtends[0];
+ }
+
+ double BorderLineExtend::getStartRight() const
+ {
+ if (mfExtends.empty())
+ return 0.0;
+ if (2 == mfExtends.size())
+ return mfExtends[0];
+ return mfExtends[1];
+ }
+
+ double BorderLineExtend::getEndLeft() const
+ {
+ if (mfExtends.empty())
+ return 0.0;
+ if (2 == mfExtends.size())
+ return mfExtends[1];
+ return mfExtends[2];
+ }
+
+ double BorderLineExtend::getEndRight() const {
+ if (mfExtends.empty())
+ return 0.0;
+ if (2 == mfExtends.size())
+ return mfExtends[1];
+ return mfExtends[3];
+ }
+
+ double BorderLineExtend::getStartAverage() const
+ {
+ if (mfExtends.empty())
+ return 0.0;
+ if (2 == mfExtends.size())
+ return mfExtends[0];
+ return (mfExtends[0] + mfExtends[1]) * 0.5;
+ }
+
+ double BorderLineExtend::getEndAverage() const
+ {
+ if (mfExtends.empty())
+ return 0.0;
+ if (2 == mfExtends.size())
+ return mfExtends[1];
+ return (mfExtends[2] + mfExtends[3]) * 0.5;
+ }
+
+ bool BorderLineExtend::operator==(const BorderLineExtend& rBorderLineExtend) const
+ {
+ if (mfExtends.size() == rBorderLineExtend.mfExtends.size())
+ {
+ return mfExtends == rBorderLineExtend.mfExtends;
+ }
+
+ return false;
+ }
+
BorderLine::BorderLine(
double fWidth,
const basegfx::BColor& rRGBColor,
- double fExtendStart,
- double fExtendEnd)
- : mfWidth(fWidth),
+ const BorderLineExtend& rBorderLineExtend)
+ : mfWidth(fWidth),
+ maRGBColor(rRGBColor),
+ maBorderLineExtend(rBorderLineExtend)
+ {
+ }
+
+ BorderLine::BorderLine(
+ double fWidth,
+ const basegfx::BColor& rRGBColor)
+ : mfWidth(fWidth),
maRGBColor(rRGBColor),
- mfExtendStart(fExtendStart),
- mfExtendEnd(fExtendEnd)
+ maBorderLineExtend()
{
}
@@ -57,8 +170,7 @@ namespace drawinglayer
{
return getWidth() == rBorderLine.getWidth()
&& getRGBColor() == rBorderLine.getRGBColor()
- && getExtendStart() == rBorderLine.getExtendStart()
- && getExtendEnd() == rBorderLine.getExtendEnd();
+ && getBorderLineExtend() == rBorderLine.getBorderLineExtend();
}
// helper to add a centered, maybe stroked line primitive to rContainer
@@ -117,8 +229,8 @@ namespace drawinglayer
// inside line (left of vector). Create stroke primitive centered on left line width
const double fDeltaY((rLeft.getWidth() - fFullWidth) * 0.5);
const basegfx::B2DVector aDeltaY(aPerpendicular * fDeltaY);
- const basegfx::B2DPoint aStart(getStart() - (aVector * rLeft.getExtendStart()) + aDeltaY);
- const basegfx::B2DPoint aEnd(getEnd() + (aVector * rLeft.getExtendEnd()) + aDeltaY);
+ const basegfx::B2DPoint aStart(getStart() - (aVector * rLeft.getBorderLineExtend().getStartAverage()) + aDeltaY);
+ const basegfx::B2DPoint aEnd(getEnd() + (aVector * rLeft.getBorderLineExtend().getEndAverage()) + aDeltaY);
const attribute::LineAttribute aLineAttribute(rLeft.getRGBColor(), rLeft.getWidth());
addPolygonStrokePrimitive2D(
@@ -135,8 +247,8 @@ namespace drawinglayer
// Create stroke primitive on vector with given color centered on gap position
const double fDeltaY(((fFullWidth - mfDiscreteGapDistance) * 0.5) - rRight.getWidth());
const basegfx::B2DVector aDeltaY(aPerpendicular * fDeltaY);
- const basegfx::B2DPoint aStart(getStart() - (aVector * rGap.getExtendStart()) + aDeltaY);
- const basegfx::B2DPoint aEnd(getEnd() + (aVector * rGap.getExtendEnd()) + aDeltaY);
+ const basegfx::B2DPoint aStart(getStart() - (aVector * rGap.getBorderLineExtend().getStartAverage()) + aDeltaY);
+ const basegfx::B2DPoint aEnd(getEnd() + (aVector * rGap.getBorderLineExtend().getEndAverage()) + aDeltaY);
const attribute::LineAttribute aLineAttribute(rGap.getRGBColor(), mfDiscreteGapDistance);
addPolygonStrokePrimitive2D(
@@ -151,8 +263,8 @@ namespace drawinglayer
// outside line (right of vector). Create stroke primitive centered on right line width
const double fDeltaY((fFullWidth - rRight.getWidth()) * 0.5);
const basegfx::B2DVector aDeltaY(aPerpendicular * fDeltaY);
- const basegfx::B2DPoint aStart(getStart() - (aVector * rRight.getExtendStart()) + aDeltaY);
- const basegfx::B2DPoint aEnd(getEnd() + (aVector * rRight.getExtendEnd()) + aDeltaY);
+ const basegfx::B2DPoint aStart(getStart() - (aVector * rRight.getBorderLineExtend().getStartAverage()) + aDeltaY);
+ const basegfx::B2DPoint aEnd(getEnd() + (aVector * rRight.getBorderLineExtend().getEndAverage()) + aDeltaY);
const attribute::LineAttribute aLineAttribute(rRight.getRGBColor(), rRight.getWidth());
addPolygonStrokePrimitive2D(
@@ -171,8 +283,8 @@ namespace drawinglayer
addPolygonStrokePrimitive2D(
rContainer,
- getStart() - (aVector * rBorderLine.getExtendStart()),
- getEnd() + (aVector * rBorderLine.getExtendEnd()),
+ getStart() - (aVector * rBorderLine.getBorderLineExtend().getStartAverage()),
+ getEnd() + (aVector * rBorderLine.getBorderLineExtend().getEndAverage()),
aLineAttribute,
aStrokeAttribute);
}
diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx
index 19c0282ffc5a..fb7cc5280c64 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx
@@ -34,7 +34,6 @@ namespace drawinglayer { namespace primitive2d {
class PolyPolygonColorPrimitive2D;
class PolygonHairlinePrimitive2D;
class PolygonStrokePrimitive2D;
- class BorderLinePrimitive2D;
}}