summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drawinglayer/source/primitive2d/PolyPolygonColorPrimitive2D.cxx49
-rw-r--r--drawinglayer/source/primitive2d/polygonprimitive2d.cxx148
-rw-r--r--include/drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx39
-rw-r--r--include/drawinglayer/primitive2d/PolygonHairlinePrimitive2D.hxx82
-rw-r--r--include/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx3
5 files changed, 309 insertions, 12 deletions
diff --git a/drawinglayer/source/primitive2d/PolyPolygonColorPrimitive2D.cxx b/drawinglayer/source/primitive2d/PolyPolygonColorPrimitive2D.cxx
index ff5578104374..6c7cf4bb365a 100644
--- a/drawinglayer/source/primitive2d/PolyPolygonColorPrimitive2D.cxx
+++ b/drawinglayer/source/primitive2d/PolyPolygonColorPrimitive2D.cxx
@@ -20,6 +20,7 @@
#include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
#include <utility>
@@ -61,6 +62,54 @@ sal_uInt32 PolyPolygonColorPrimitive2D::getPrimitive2DID() const
return PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D;
}
+FilledRectanglePrimitive2D::FilledRectanglePrimitive2D(const basegfx::B2DRange& rB2DRange,
+ const basegfx::BColor& rBColor)
+ : BasePrimitive2D()
+ , maB2DRange(rB2DRange)
+ , maBColor(rBColor)
+{
+}
+
+bool FilledRectanglePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+{
+ if (BasePrimitive2D::operator==(rPrimitive))
+ {
+ const FilledRectanglePrimitive2D& rCompare(
+ static_cast<const FilledRectanglePrimitive2D&>(rPrimitive));
+
+ return (getB2DRange() == rCompare.getB2DRange() && getBColor() == rCompare.getBColor());
+ }
+
+ return false;
+}
+
+basegfx::B2DRange FilledRectanglePrimitive2D::getB2DRange(
+ const geometry::ViewInformation2D& /*rViewInformation*/) const
+{
+ return getB2DRange();
+}
+
+sal_uInt32 FilledRectanglePrimitive2D::getPrimitive2DID() const
+{
+ return PRIMITIVE2D_ID_FILLEDRECTANGLEPRIMITIVE2D;
+}
+
+void FilledRectanglePrimitive2D::get2DDecomposition(
+ Primitive2DDecompositionVisitor& rVisitor,
+ const geometry::ViewInformation2D& /*rViewInformation*/) const
+{
+ if (getB2DRange().isEmpty())
+ {
+ // no geometry, done
+ return;
+ }
+
+ const basegfx::B2DPolygon aPolygon(basegfx::utils::createPolygonFromRect(getB2DRange()));
+ Primitive2DContainer aSequence
+ = { new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPolygon), getBColor()) };
+ rVisitor.visit(aSequence);
+}
+
} // end drawinglayer::primitive2d namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx
index 2fdb535f61d9..fb6a8ed369d2 100644
--- a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx
@@ -24,6 +24,7 @@
#include <drawinglayer/primitive2d/PolygonMarkerPrimitive2D.hxx>
#include <drawinglayer/primitive2d/PolygonStrokeArrowPrimitive2D.hxx>
#include <drawinglayer/primitive2d/PolygonWavePrimitive2D.hxx>
+#include <drawinglayer/primitive2d/pointarrayprimitive2d.hxx>
#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
#include <drawinglayer/geometry/viewinformation2d.hxx>
#include <basegfx/polygon/b2dlinegeometry.hxx>
@@ -32,6 +33,26 @@
using namespace com::sun::star;
+namespace
+{
+void implGrowHairline(basegfx::B2DRange& rRange,
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation)
+{
+ if (!rRange.isEmpty())
+ {
+ // Calculate view-dependent hairline width
+ const basegfx::B2DVector aDiscreteSize(
+ rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0));
+ const double fDiscreteHalfLineWidth(aDiscreteSize.getLength() * 0.5);
+
+ if (basegfx::fTools::more(fDiscreteHalfLineWidth, 0.0))
+ {
+ rRange.grow(fDiscreteHalfLineWidth);
+ }
+ }
+}
+}
+
namespace drawinglayer::primitive2d
{
PolygonHairlinePrimitive2D::PolygonHairlinePrimitive2D(basegfx::B2DPolygon aPolygon,
@@ -61,18 +82,8 @@ PolygonHairlinePrimitive2D::getB2DRange(const geometry::ViewInformation2D& rView
// as base size
basegfx::B2DRange aRetval(getB2DPolygon().getB2DRange());
- if (!aRetval.isEmpty())
- {
- // Calculate view-dependent hairline width
- const basegfx::B2DVector aDiscreteSize(
- rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0));
- const double fDiscreteHalfLineWidth(aDiscreteSize.getLength() * 0.5);
-
- if (basegfx::fTools::more(fDiscreteHalfLineWidth, 0.0))
- {
- aRetval.grow(fDiscreteHalfLineWidth);
- }
- }
+ // Calculate and grow by view-dependent hairline width
+ implGrowHairline(aRetval, rViewInformation);
// return range
return aRetval;
@@ -84,6 +95,119 @@ sal_uInt32 PolygonHairlinePrimitive2D::getPrimitive2DID() const
return PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D;
}
+SingleLinePrimitive2D::SingleLinePrimitive2D(const basegfx::B2DPoint& rStart,
+ const basegfx::B2DPoint& rEnd,
+ const basegfx::BColor& rBColor)
+ : BasePrimitive2D()
+ , maStart(rStart)
+ , maEnd(rEnd)
+ , maBColor(rBColor)
+{
+}
+
+bool SingleLinePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+{
+ if (BasePrimitive2D::operator==(rPrimitive))
+ {
+ const SingleLinePrimitive2D& rCompare(
+ static_cast<const SingleLinePrimitive2D&>(rPrimitive));
+
+ return (getStart() == rCompare.getStart() && getEnd() == rCompare.getEnd()
+ && getBColor() == rCompare.getBColor());
+ }
+
+ return false;
+}
+
+basegfx::B2DRange
+SingleLinePrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const
+{
+ basegfx::B2DRange aRetval(getStart(), getEnd());
+
+ // Calculate and grow by view-dependent hairline width
+ implGrowHairline(aRetval, rViewInformation);
+
+ return aRetval;
+}
+
+sal_uInt32 SingleLinePrimitive2D::getPrimitive2DID() const
+{
+ return PRIMITIVE2D_ID_SINGLELINEPRIMITIVE2D;
+}
+
+void SingleLinePrimitive2D::get2DDecomposition(
+ Primitive2DDecompositionVisitor& rVisitor,
+ const geometry::ViewInformation2D& /*rViewInformation*/) const
+{
+ if (getStart() == getEnd())
+ {
+ // single point
+ std::vector<basegfx::B2DPoint> aPoints = { getStart() };
+ Primitive2DContainer aSequence
+ = { new PointArrayPrimitive2D(std::move(aPoints), getBColor()) };
+ rVisitor.visit(aSequence);
+ }
+ else
+ {
+ // line
+ basegfx::B2DPolygon aPolygon{ getStart(), getEnd() };
+ Primitive2DContainer aSequence = { new PolygonHairlinePrimitive2D(aPolygon, getBColor()) };
+ rVisitor.visit(aSequence);
+ }
+}
+
+LineRectanglePrimitive2D::LineRectanglePrimitive2D(const basegfx::B2DRange& rB2DRange,
+ const basegfx::BColor& rBColor)
+ : BasePrimitive2D()
+ , maB2DRange(rB2DRange)
+ , maBColor(rBColor)
+{
+}
+
+bool LineRectanglePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+{
+ if (BasePrimitive2D::operator==(rPrimitive))
+ {
+ const LineRectanglePrimitive2D& rCompare(
+ static_cast<const LineRectanglePrimitive2D&>(rPrimitive));
+
+ return (getB2DRange() == rCompare.getB2DRange() && getBColor() == rCompare.getBColor());
+ }
+
+ return false;
+}
+
+basegfx::B2DRange
+LineRectanglePrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const
+{
+ basegfx::B2DRange aRetval(getB2DRange());
+
+ // Calculate and grow by view-dependent hairline width
+ implGrowHairline(aRetval, rViewInformation);
+
+ return aRetval;
+}
+
+sal_uInt32 LineRectanglePrimitive2D::getPrimitive2DID() const
+{
+ return PRIMITIVE2D_ID_LINERECTANGLEPRIMITIVE2D;
+}
+
+void LineRectanglePrimitive2D::get2DDecomposition(
+ Primitive2DDecompositionVisitor& rVisitor,
+ const geometry::ViewInformation2D& /*rViewInformation*/) const
+{
+ if (getB2DRange().isEmpty())
+ {
+ // no geometry, done
+ return;
+ }
+
+ const basegfx::B2DPolygon aPolygon(basegfx::utils::createPolygonFromRect(getB2DRange()));
+ Primitive2DContainer aSequence = { new PolygonHairlinePrimitive2D(aPolygon, getBColor()) };
+ rVisitor.visit(aSequence);
+}
+
void PolygonMarkerPrimitive2D::create2DDecomposition(
Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const
{
diff --git a/include/drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx b/include/drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx
index 999322a2654d..29737786df1c 100644
--- a/include/drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx
+++ b/include/drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx
@@ -62,6 +62,45 @@ public:
virtual sal_uInt32 getPrimitive2DID() const override;
};
+/** FilledRectanglePrimitive2D class
+
+ Tooling: This primitive defines a simple rectangle. It is
+ sometimes useful for simpler tasks and decomposes to a
+ more gereralized PolyPolygonColorPrimitive2D (see above)
+*/
+class DRAWINGLAYER_DLLPUBLIC FilledRectanglePrimitive2D final : public BasePrimitive2D
+{
+private:
+ /// the geometry
+ basegfx::B2DRange maB2DRange;
+
+ /// the fill color
+ basegfx::BColor maBColor;
+
+public:
+ /// constructor
+ FilledRectanglePrimitive2D(const basegfx::B2DRange& rB2DRange, const basegfx::BColor& rBColor);
+
+ /// data read access
+ const basegfx::B2DRange& getB2DRange() const { return maB2DRange; }
+ const basegfx::BColor& getBColor() const { return maBColor; }
+
+ /// compare operator
+ virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
+
+ /// get range
+ virtual basegfx::B2DRange
+ getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override;
+
+ /// provide unique ID
+ virtual sal_uInt32 getPrimitive2DID() const override;
+
+ /// return as PolyPolygonColorPrimitive2D
+ virtual void
+ get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor,
+ const geometry::ViewInformation2D& rViewInformation) const override;
+};
+
} // end of namespace primitive2d::drawinglayer
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/drawinglayer/primitive2d/PolygonHairlinePrimitive2D.hxx b/include/drawinglayer/primitive2d/PolygonHairlinePrimitive2D.hxx
index 6c222c76d7bc..9e57ab31f6a4 100644
--- a/include/drawinglayer/primitive2d/PolygonHairlinePrimitive2D.hxx
+++ b/include/drawinglayer/primitive2d/PolygonHairlinePrimitive2D.hxx
@@ -63,6 +63,88 @@ public:
virtual sal_uInt32 getPrimitive2DID() const override;
};
+/** SingleLinePrimitive2D class
+
+ This primitive defines a simple line, just two points. It is
+ sometimes useful for simpler tasks and decomposes to a
+ PolygonHairlinePrimitive2D (see above). It is also a
+ hairline-primitive, see above.
+*/
+class DRAWINGLAYER_DLLPUBLIC SingleLinePrimitive2D final : public BasePrimitive2D
+{
+private:
+ /// the line geometry
+ basegfx::B2DPoint maStart;
+ basegfx::B2DPoint maEnd;
+
+ /// the line color
+ basegfx::BColor maBColor;
+
+public:
+ /// constructor
+ SingleLinePrimitive2D(const basegfx::B2DPoint& rStart, const basegfx::B2DPoint& rEnd,
+ const basegfx::BColor& rBColor);
+
+ /// data read access
+ const basegfx::B2DPoint& getStart() const { return maStart; }
+ const basegfx::B2DPoint& getEnd() const { return maEnd; }
+ const basegfx::BColor& getBColor() const { return maBColor; }
+
+ /// compare operator
+ virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
+
+ /// get range
+ virtual basegfx::B2DRange
+ getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override;
+
+ /// provide unique ID
+ virtual sal_uInt32 getPrimitive2DID() const override;
+
+ /// return as PolygonHairlinePrimitive2D
+ virtual void
+ get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor,
+ const geometry::ViewInformation2D& rViewInformation) const override;
+};
+
+/** LineRectanglePrimitive2D class
+
+ Tooling: This primitive defines a simple rectangle. It is
+ sometimes useful for simpler tasks and decomposes to a
+ more gereralized PolygonHairlinePrimitive2D (see above)
+*/
+class DRAWINGLAYER_DLLPUBLIC LineRectanglePrimitive2D final : public BasePrimitive2D
+{
+private:
+ /// the geometry
+ basegfx::B2DRange maB2DRange;
+
+ /// the line color
+ basegfx::BColor maBColor;
+
+public:
+ /// constructor
+ LineRectanglePrimitive2D(const basegfx::B2DRange& rB2DRange, const basegfx::BColor& rBColor);
+
+ /// data read access
+ const basegfx::B2DRange& getB2DRange() const { return maB2DRange; }
+ const basegfx::BColor& getBColor() const { return maBColor; }
+
+ /// compare operator
+ virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
+
+ /// get range
+ virtual basegfx::B2DRange
+ getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override;
+
+ /// provide unique ID
+ virtual sal_uInt32 getPrimitive2DID() const override;
+
+ /// return as PolygonHairlinePrimitive2D
+ virtual void
+ get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor,
+ const geometry::ViewInformation2D& rViewInformation) const override;
+};
+
} // end of namespace primitive2d::drawinglayer
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx b/include/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx
index 687efb1d85ff..e860476e7e80 100644
--- a/include/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx
+++ b/include/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx
@@ -104,6 +104,9 @@
#define PRIMITIVE2D_ID_PAGEHIERARCHYPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 70)
#define PRIMITIVE2D_ID_GLOWPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 71)
#define PRIMITIVE2D_ID_SOFTEDGEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 72)
+#define PRIMITIVE2D_ID_LINERECTANGLEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 73)
+#define PRIMITIVE2D_ID_FILLEDRECTANGLEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 74)
+#define PRIMITIVE2D_ID_SINGLELINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 75)
// When you add a new primitive, please update the drawinglayer::primitive2d::idToString() function
// in drawinglayer/source/primitive2d/Tools.cxx.