summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2022-12-19 19:15:52 +0100
committerArmin Le Grand <Armin.Le.Grand@me.com>2022-12-20 12:25:28 +0000
commitfe589d8e5465320f49feeb41d493f84e630bced3 (patch)
tree572f70d86fd4ba58f04608094b667eb1ef3ca73f /include
parent74f51d5ecd0bbeedff7b52d28294828c0726def4 (diff)
Added two simple tooling Primitives for easy/common cases
Added three simple tooling Primitives: (1) SingleLinePrimitive2D: Just a Line from Point A to B with a BColor, decomposes to a PolygonHairlinePrimitive2D (and to a PointArrayPrimitive2D if only a single point aka A == B) (2) LineRectanglePrimitive2D: (3) FilledRectanglePrimitive2D: Rectangles that support fill or line, gets decomposed to maybe PolyPolygonColorPrimitive2D (if filled) and a PolygonHairlinePrimitive2D (if line) or nothing if the B2DRange is empty NOTE: If using these despite being hor/ver aligned due to their nature as B2DRange(s) (aka 'non rotated/sheared') these may have to be transformed if the current transformation context you are working in is rotated or sheared, so *ensure* to handle these correctly if you do handle them yourself. This is not needed with the Polygon-based ones - that's why these are - and stay - the common case(s). Both are hairline primitives themselves, so are potentially *view-dependent* (see comment in *.cxx and *.hxx). They will be useful as very simple primitives for small renderers, e.g. to avoid conversion from rectangles or just lines to polygons. The more general Primitives are always the polygon-based ones, so these new ones get decomposed to these (decomposition direction, complex -> simpler). This assures that a processor/renderer has minimally to support the polygon-based ones, but *can* use these simple tooling ones directly if he wants to. This will come in handy for future System-Dependent PrimitiveRenderers, which I am currently working on one to offer as example - this leads to identifying helpful upstream things that will come in handy in that regard - like these ones. Change-Id: Ie5039e6cfad6c9914c165cae6f8b59abecc38302 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144543 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'include')
-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
3 files changed, 124 insertions, 0 deletions
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.