summaryrefslogtreecommitdiff
path: root/chart2/source/view/inc/Clipping.hxx
diff options
context:
space:
mode:
authorIngrid Halama <iha@openoffice.org>2003-12-15 18:36:25 +0000
committerIngrid Halama <iha@openoffice.org>2003-12-15 18:36:25 +0000
commit506a953358ee99a949f7f52beffe6bba0c11aa15 (patch)
tree07c33bb2825c3fc6d95e22a336f7aa342dd6623f /chart2/source/view/inc/Clipping.hxx
parentffeb7e04b10113f868aed59f270df82779df09ca (diff)
moved Clipping from charttypes to main
Diffstat (limited to 'chart2/source/view/inc/Clipping.hxx')
-rw-r--r--chart2/source/view/inc/Clipping.hxx65
1 files changed, 65 insertions, 0 deletions
diff --git a/chart2/source/view/inc/Clipping.hxx b/chart2/source/view/inc/Clipping.hxx
new file mode 100644
index 000000000..e7415217f
--- /dev/null
+++ b/chart2/source/view/inc/Clipping.hxx
@@ -0,0 +1,65 @@
+#ifndef _CHART2_CLIPPING_HXX
+#define _CHART2_CLIPPING_HXX
+
+#ifndef _COM_SUN_STAR_DRAWING_POLYPOLYGONSHAPE3D_HPP_
+#include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
+#endif
+
+//.............................................................................
+namespace chart
+{
+//.............................................................................
+
+//-----------------------------------------------------------------------------
+/**
+*/
+
+struct DoublePoint
+{
+ DoublePoint(double fX, double fY) : X(fX), Y(fY) {};
+ DoublePoint() : X(0.0), Y(0.0) {};
+ DoublePoint operator-( const DoublePoint& rP );
+
+ double X;
+ double Y;
+};
+
+struct DoubleRectangle
+{
+public:
+ DoubleRectangle( double fLeft, double fTop, double fRight, double fBottom );
+ bool isInside( const DoublePoint& rPoint ) const;
+
+ double Left;
+ double Top;
+ double Right;
+ double Bottom;
+};
+
+class Clipping
+{
+ /** This class uses the Liang-Biarsky parametric line-clipping algorithm as described in:
+ Computer Graphics: principles and practice, 2nd ed.,
+ James D. Foley et al.,
+ Section 3.12.4 on page 117.
+ */
+
+public:
+ /** @descr The intersection between an open polygon and a rectangle is
+ calculated and the resulting lines are placed into the poly-polygon aResult.
+ @param rPolygon The polygon is required to be open, ie. it's start and end point
+ have different coordinates and that it is continuous, ie. has no holes.
+ @param rRectangle The clipping area.
+ @param aResult The resulting lines that are the parts of the given polygon lying inside
+ the clipping area are stored into aResult whose prior content is deleted first.
+ */
+ static void clipPolygonAtRectangle(
+ const ::com::sun::star::drawing::PolyPolygonShape3D& rPolygon
+ , const DoubleRectangle& rRectangle
+ , ::com::sun::star::drawing::PolyPolygonShape3D& aResult );
+};
+
+//.............................................................................
+} //namespace chart
+//.............................................................................
+#endif