1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f6e50924SAndrew Rist  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f6e50924SAndrew Rist  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19f6e50924SAndrew Rist  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <svx/sdr/overlay/overlaytools.hxx>
28cdf0e10cSrcweir #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
29cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
30cdf0e10cSrcweir #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
31cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
32cdf0e10cSrcweir #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
33cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
34cdf0e10cSrcweir #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
35cdf0e10cSrcweir #include <drawinglayer/geometry/viewinformation2d.hxx>
36cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx>
371cd65da9SArmin Le Grand #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
381cd65da9SArmin Le Grand #include <vcl/svapp.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
41cdf0e10cSrcweir 
42cdf0e10cSrcweir namespace drawinglayer
43cdf0e10cSrcweir {
44cdf0e10cSrcweir 	namespace primitive2d
45cdf0e10cSrcweir 	{
OverlayBitmapExPrimitive(const BitmapEx & rBitmapEx,const basegfx::B2DPoint & rBasePosition,sal_uInt16 nCenterX,sal_uInt16 nCenterY,double fShearX,double fRotation)46cdf0e10cSrcweir         OverlayBitmapExPrimitive::OverlayBitmapExPrimitive(
47cdf0e10cSrcweir 			const BitmapEx& rBitmapEx,
48cdf0e10cSrcweir 			const basegfx::B2DPoint& rBasePosition,
49cdf0e10cSrcweir 			sal_uInt16 nCenterX,
50*414a0e15SArmin Le Grand 			sal_uInt16 nCenterY,
51*414a0e15SArmin Le Grand             double fShearX,
52*414a0e15SArmin Le Grand             double fRotation)
53cdf0e10cSrcweir 		:   DiscreteMetricDependentPrimitive2D(),
54cdf0e10cSrcweir 			maBitmapEx(rBitmapEx),
55cdf0e10cSrcweir 			maBasePosition(rBasePosition),
56cdf0e10cSrcweir 			mnCenterX(nCenterX),
57*414a0e15SArmin Le Grand 			mnCenterY(nCenterY),
58*414a0e15SArmin Le Grand             mfShearX(fShearX),
59*414a0e15SArmin Le Grand             mfRotation(fRotation)
60cdf0e10cSrcweir 		{}
61cdf0e10cSrcweir 
create2DDecomposition(const geometry::ViewInformation2D &) const62cdf0e10cSrcweir 		Primitive2DSequence OverlayBitmapExPrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
63cdf0e10cSrcweir 		{
64cdf0e10cSrcweir             Primitive2DSequence aRetval;
65cdf0e10cSrcweir 			const Size aBitmapSize(getBitmapEx().GetSizePixel());
66cdf0e10cSrcweir 
67cdf0e10cSrcweir             if(aBitmapSize.Width() && aBitmapSize.Height() && basegfx::fTools::more(getDiscreteUnit(), 0.0))
68cdf0e10cSrcweir 			{
69cdf0e10cSrcweir                 // calculate back from internal bitmap's extreme coordinates (the edges)
70cdf0e10cSrcweir                 // to logical coordinates. Only use a unified scaling value (getDiscreteUnit(),
71cdf0e10cSrcweir                 // the prepared one which expresses how many logic units form a discrete unit)
72cdf0e10cSrcweir                 // for this step. This primitive is to be displayed always unscaled (in it's pixel size)
73cdf0e10cSrcweir                 // and unrotated, more like a marker
74*414a0e15SArmin Le Grand                 const double fLeft((0.0 - getCenterX()) * getDiscreteUnit());
75*414a0e15SArmin Le Grand                 const double fTop((0.0 - getCenterY()) * getDiscreteUnit());
76*414a0e15SArmin Le Grand                 const double fRight((aBitmapSize.getWidth() - getCenterX()) * getDiscreteUnit());
77*414a0e15SArmin Le Grand                 const double fBottom((aBitmapSize.getHeight() - getCenterY()) * getDiscreteUnit());
78cdf0e10cSrcweir 
79cdf0e10cSrcweir                 // create a BitmapPrimitive2D using those positions
80*414a0e15SArmin Le Grand                 basegfx::B2DHomMatrix aTransform;
81cdf0e10cSrcweir 
82*414a0e15SArmin Le Grand                 aTransform.set(0, 0, fRight - fLeft);
83*414a0e15SArmin Le Grand                 aTransform.set(1, 1, fBottom - fTop);
84*414a0e15SArmin Le Grand                 aTransform.set(0, 2, fLeft);
85*414a0e15SArmin Le Grand                 aTransform.set(1, 2, fTop);
86*414a0e15SArmin Le Grand 
87*414a0e15SArmin Le Grand                 // if shearX is used, apply it, too
88*414a0e15SArmin Le Grand                 if(!basegfx::fTools::equalZero(getShearX()))
89*414a0e15SArmin Le Grand                 {
90*414a0e15SArmin Le Grand                     aTransform.shearX(getShearX());
91*414a0e15SArmin Le Grand                 }
92*414a0e15SArmin Le Grand 
93*414a0e15SArmin Le Grand                 // if rotation is used, apply it, too
94*414a0e15SArmin Le Grand                 if(!basegfx::fTools::equalZero(getRotation()))
95*414a0e15SArmin Le Grand                 {
96*414a0e15SArmin Le Grand                     aTransform.rotate(getRotation());
97*414a0e15SArmin Le Grand                 }
98*414a0e15SArmin Le Grand 
99*414a0e15SArmin Le Grand                 // add BasePosition
100*414a0e15SArmin Le Grand                 aTransform.translate(getBasePosition().getX(), getBasePosition().getY());
101cdf0e10cSrcweir 
102cdf0e10cSrcweir                 const Primitive2DReference aPrimitive(new BitmapPrimitive2D(getBitmapEx(), aTransform));
103cdf0e10cSrcweir                 aRetval = Primitive2DSequence(&aPrimitive, 1);
104cdf0e10cSrcweir             }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir             return aRetval;
107cdf0e10cSrcweir 		}
108cdf0e10cSrcweir 
operator ==(const BasePrimitive2D & rPrimitive) const109cdf0e10cSrcweir 		bool OverlayBitmapExPrimitive::operator==( const BasePrimitive2D& rPrimitive ) const
110cdf0e10cSrcweir 		{
111cdf0e10cSrcweir 			if(DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
112cdf0e10cSrcweir 			{
113cdf0e10cSrcweir 				const OverlayBitmapExPrimitive& rCompare = static_cast< const OverlayBitmapExPrimitive& >(rPrimitive);
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 				return (getBitmapEx() == rCompare.getBitmapEx()
116cdf0e10cSrcweir 					&& getBasePosition() == rCompare.getBasePosition()
117cdf0e10cSrcweir 					&& getCenterX() == rCompare.getCenterX()
118*414a0e15SArmin Le Grand 					&& getCenterY() == rCompare.getCenterY()
119*414a0e15SArmin Le Grand                     && getShearX() == rCompare.getShearX()
120*414a0e15SArmin Le Grand                     && getRotation() == rCompare.getRotation());
121cdf0e10cSrcweir 			}
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 			return false;
124cdf0e10cSrcweir 		}
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 		ImplPrimitrive2DIDBlock(OverlayBitmapExPrimitive, PRIMITIVE2D_ID_OVERLAYBITMAPEXPRIMITIVE)
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 	} // end of namespace primitive2d
129cdf0e10cSrcweir } // end of namespace drawinglayer
130cdf0e10cSrcweir 
131cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
132cdf0e10cSrcweir 
133cdf0e10cSrcweir namespace drawinglayer
134cdf0e10cSrcweir {
135cdf0e10cSrcweir 	namespace primitive2d
136cdf0e10cSrcweir 	{
OverlayCrosshairPrimitive(const basegfx::B2DPoint & rBasePosition,const basegfx::BColor & rRGBColorA,const basegfx::BColor & rRGBColorB,double fDiscreteDashLength)137cdf0e10cSrcweir         OverlayCrosshairPrimitive::OverlayCrosshairPrimitive(
138cdf0e10cSrcweir             const basegfx::B2DPoint& rBasePosition,
139cdf0e10cSrcweir 			const basegfx::BColor& rRGBColorA,
140cdf0e10cSrcweir 			const basegfx::BColor& rRGBColorB,
141cdf0e10cSrcweir 			double fDiscreteDashLength)
142cdf0e10cSrcweir         :   ViewportDependentPrimitive2D(),
143cdf0e10cSrcweir 			maBasePosition(rBasePosition),
144cdf0e10cSrcweir 			maRGBColorA(rRGBColorA),
145cdf0e10cSrcweir 			maRGBColorB(rRGBColorB),
146cdf0e10cSrcweir 			mfDiscreteDashLength(fDiscreteDashLength)
147cdf0e10cSrcweir         {}
148cdf0e10cSrcweir 
create2DDecomposition(const geometry::ViewInformation2D &) const149cdf0e10cSrcweir 		Primitive2DSequence OverlayCrosshairPrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
150cdf0e10cSrcweir 		{
151cdf0e10cSrcweir             // use the prepared Viewport information accessible using getViewport()
152cdf0e10cSrcweir             Primitive2DSequence aRetval;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir             if(!getViewport().isEmpty())
155cdf0e10cSrcweir             {
156cdf0e10cSrcweir                 aRetval.realloc(2);
157cdf0e10cSrcweir                 basegfx::B2DPolygon aPolygon;
158cdf0e10cSrcweir 
159cdf0e10cSrcweir                 aPolygon.append(basegfx::B2DPoint(getViewport().getMinX(), getBasePosition().getY()));
160cdf0e10cSrcweir                 aPolygon.append(basegfx::B2DPoint(getViewport().getMaxX(), getBasePosition().getY()));
161cdf0e10cSrcweir 
162cdf0e10cSrcweir                 aRetval[0] = Primitive2DReference(
163cdf0e10cSrcweir                     new PolygonMarkerPrimitive2D(
164cdf0e10cSrcweir                         aPolygon,
165cdf0e10cSrcweir                         getRGBColorA(),
166cdf0e10cSrcweir                         getRGBColorB(),
167cdf0e10cSrcweir                         getDiscreteDashLength()));
168cdf0e10cSrcweir 
169cdf0e10cSrcweir                 aPolygon.clear();
170cdf0e10cSrcweir                 aPolygon.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMinY()));
171cdf0e10cSrcweir                 aPolygon.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMaxY()));
172cdf0e10cSrcweir 
173cdf0e10cSrcweir                 aRetval[1] = Primitive2DReference(
174cdf0e10cSrcweir                     new PolygonMarkerPrimitive2D(
175cdf0e10cSrcweir                         aPolygon,
176cdf0e10cSrcweir                         getRGBColorA(),
177cdf0e10cSrcweir                         getRGBColorB(),
178cdf0e10cSrcweir                         getDiscreteDashLength()));
179cdf0e10cSrcweir             }
180cdf0e10cSrcweir 
181cdf0e10cSrcweir             return aRetval;
182cdf0e10cSrcweir 		}
183cdf0e10cSrcweir 
operator ==(const BasePrimitive2D & rPrimitive) const184cdf0e10cSrcweir 		bool OverlayCrosshairPrimitive::operator==( const BasePrimitive2D& rPrimitive ) const
185cdf0e10cSrcweir 		{
186cdf0e10cSrcweir 			if(ViewportDependentPrimitive2D::operator==(rPrimitive))
187cdf0e10cSrcweir 			{
188cdf0e10cSrcweir 				const OverlayCrosshairPrimitive& rCompare = static_cast< const OverlayCrosshairPrimitive& >(rPrimitive);
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 				return (getBasePosition() == rCompare.getBasePosition()
191cdf0e10cSrcweir 					&& getRGBColorA() == rCompare.getRGBColorA()
192cdf0e10cSrcweir 					&& getRGBColorB() == rCompare.getRGBColorB()
193cdf0e10cSrcweir                     && getDiscreteDashLength() == rCompare.getDiscreteDashLength());
194cdf0e10cSrcweir 			}
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 			return false;
197cdf0e10cSrcweir 		}
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 		ImplPrimitrive2DIDBlock(OverlayCrosshairPrimitive, PRIMITIVE2D_ID_OVERLAYCROSSHAIRPRIMITIVE)
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 	} // end of namespace primitive2d
202cdf0e10cSrcweir } // end of namespace drawinglayer
203cdf0e10cSrcweir 
204cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
205cdf0e10cSrcweir 
206cdf0e10cSrcweir namespace drawinglayer
207cdf0e10cSrcweir {
208cdf0e10cSrcweir 	namespace primitive2d
209cdf0e10cSrcweir 	{
OverlayRectanglePrimitive(const basegfx::B2DRange & rObjectRange,const basegfx::BColor & rColor,double fTransparence,double fDiscreteGrow,double fDiscreteShrink,double fRotation)2101cd65da9SArmin Le Grand         OverlayRectanglePrimitive::OverlayRectanglePrimitive(
211cdf0e10cSrcweir             const basegfx::B2DRange& rObjectRange,
2121cd65da9SArmin Le Grand 			const basegfx::BColor& rColor,
2131cd65da9SArmin Le Grand             double fTransparence,
214cdf0e10cSrcweir             double fDiscreteGrow,
215cdf0e10cSrcweir             double fDiscreteShrink,
216cdf0e10cSrcweir             double fRotation)
217cdf0e10cSrcweir         :   DiscreteMetricDependentPrimitive2D(),
218cdf0e10cSrcweir             maObjectRange(rObjectRange),
2191cd65da9SArmin Le Grand 			maColor(rColor),
2201cd65da9SArmin Le Grand             mfTransparence(fTransparence),
221cdf0e10cSrcweir             mfDiscreteGrow(fDiscreteGrow),
222cdf0e10cSrcweir             mfDiscreteShrink(fDiscreteShrink),
223cdf0e10cSrcweir             mfRotation(fRotation)
224cdf0e10cSrcweir         {}
225cdf0e10cSrcweir 
create2DDecomposition(const geometry::ViewInformation2D &) const2261cd65da9SArmin Le Grand 		Primitive2DSequence OverlayRectanglePrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
227cdf0e10cSrcweir 		{
228cdf0e10cSrcweir             Primitive2DSequence aRetval;
2291cd65da9SArmin Le Grand             basegfx::B2DRange aInnerRange(getObjectRange());
230cdf0e10cSrcweir 
2311cd65da9SArmin Le Grand             if(!aInnerRange.isEmpty() && basegfx::fTools::more(getDiscreteUnit(), 0.0) && getTransparence() <= 1.0)
2321cd65da9SArmin Le Grand             {
2331cd65da9SArmin Le Grand                 basegfx::B2DRange aInnerRange(getObjectRange());
2341cd65da9SArmin Le Grand                 basegfx::B2DRange aOuterRange(getObjectRange());
2351cd65da9SArmin Le Grand 
2361cd65da9SArmin Le Grand                 // grow/shrink inner/outer polygons
2371cd65da9SArmin Le Grand                 aOuterRange.grow(getDiscreteUnit() * getDiscreteGrow());
2381cd65da9SArmin Le Grand                 aInnerRange.grow(getDiscreteUnit() * -getDiscreteShrink());
2391cd65da9SArmin Le Grand 
2401cd65da9SArmin Le Grand                 // convert to polygons
2411cd65da9SArmin Le Grand                 const double fFullGrow(getDiscreteGrow() + getDiscreteShrink());
2421cd65da9SArmin Le Grand                 const double fRelativeRadiusX(fFullGrow / aOuterRange.getWidth());
2431cd65da9SArmin Le Grand                 const double fRelativeRadiusY(fFullGrow / aOuterRange.getHeight());
2441cd65da9SArmin Le Grand                 basegfx::B2DPolygon aOuterPolygon(
2451cd65da9SArmin Le Grand                     basegfx::tools::createPolygonFromRect(
2461cd65da9SArmin Le Grand                         aOuterRange,
2471cd65da9SArmin Le Grand                         fRelativeRadiusX,
2481cd65da9SArmin Le Grand                         fRelativeRadiusY));
2491cd65da9SArmin Le Grand                 basegfx::B2DPolygon aInnerPolygon(
2501cd65da9SArmin Le Grand                     basegfx::tools::createPolygonFromRect(
2511cd65da9SArmin Le Grand                         aInnerRange));
2521cd65da9SArmin Le Grand 
2531cd65da9SArmin Le Grand                 // apply evtl. existing rotation
2541cd65da9SArmin Le Grand                 if(!basegfx::fTools::equalZero(getRotation()))
2551cd65da9SArmin Le Grand                 {
256cdf0e10cSrcweir                     const basegfx::B2DHomMatrix aTransform(basegfx::tools::createRotateAroundPoint(
257cdf0e10cSrcweir                         getObjectRange().getMinX(), getObjectRange().getMinY(), getRotation()));
258cdf0e10cSrcweir 
2591cd65da9SArmin Le Grand                     aOuterPolygon.transform(aTransform);
2601cd65da9SArmin Le Grand                     aInnerPolygon.transform(aTransform);
2611cd65da9SArmin Le Grand                 }
2621cd65da9SArmin Le Grand 
2631cd65da9SArmin Le Grand                 // create filled primitive
2641cd65da9SArmin Le Grand                 basegfx::B2DPolyPolygon aPolyPolygon;
2651cd65da9SArmin Le Grand 
2661cd65da9SArmin Le Grand                 aPolyPolygon.append(aOuterPolygon);
2671cd65da9SArmin Le Grand                 aPolyPolygon.append(aInnerPolygon);
2681cd65da9SArmin Le Grand 
2691cd65da9SArmin Le Grand                 if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
2701cd65da9SArmin Le Grand                 {
2711cd65da9SArmin Le Grand                     // for high contrast, use hatch
2721cd65da9SArmin Le Grand                     const basegfx::BColor aHighContrastLineColor(Application::GetSettings().GetStyleSettings().GetFontColor().getBColor());
2731cd65da9SArmin Le Grand                     const basegfx::BColor aEmptyColor(0.0, 0.0, 0.0);
2741cd65da9SArmin Le Grand                     const double fHatchRotation(45 * F_PI180);
2751cd65da9SArmin Le Grand                     const double fDiscreteHatchDistance(3.0);
2761cd65da9SArmin Le Grand                     const drawinglayer::attribute::FillHatchAttribute aFillHatchAttribute(
2771cd65da9SArmin Le Grand                         drawinglayer::attribute::HATCHSTYLE_SINGLE,
2781cd65da9SArmin Le Grand                         fDiscreteHatchDistance * getDiscreteUnit(),
2791cd65da9SArmin Le Grand                         fHatchRotation - getRotation(),
2801cd65da9SArmin Le Grand                         aHighContrastLineColor,
2811cd65da9SArmin Le Grand                         3, // same default as VCL, a minimum of three discrete units (pixels) offset
2821cd65da9SArmin Le Grand                         false);
2831cd65da9SArmin Le Grand                     const Primitive2DReference aHatch(
2841cd65da9SArmin Le Grand                         new PolyPolygonHatchPrimitive2D(
2851cd65da9SArmin Le Grand                             aPolyPolygon,
2861cd65da9SArmin Le Grand                             aEmptyColor,
2871cd65da9SArmin Le Grand                             aFillHatchAttribute));
2881cd65da9SArmin Le Grand 
2891cd65da9SArmin Le Grand                     aRetval = Primitive2DSequence(&aHatch, 1);
2901cd65da9SArmin Le Grand                 }
2911cd65da9SArmin Le Grand                 else
2921cd65da9SArmin Le Grand                 {
2931cd65da9SArmin Le Grand                     // create fill primitive
2941cd65da9SArmin Le Grand                     const Primitive2DReference aFill(
2951cd65da9SArmin Le Grand                         new PolyPolygonColorPrimitive2D(
2961cd65da9SArmin Le Grand                             aPolyPolygon,
2971cd65da9SArmin Le Grand                             getColor()));
2981cd65da9SArmin Le Grand 
2991cd65da9SArmin Le Grand                     aRetval = Primitive2DSequence(&aFill, 1);
3001cd65da9SArmin Le Grand 
3011cd65da9SArmin Le Grand                     // embed filled to transparency (if used)
3021cd65da9SArmin Le Grand                     if(getTransparence() > 0.0)
3031cd65da9SArmin Le Grand                     {
3041cd65da9SArmin Le Grand                         const Primitive2DReference aFillTransparent(
3051cd65da9SArmin Le Grand                             new UnifiedTransparencePrimitive2D(
3061cd65da9SArmin Le Grand                                 aRetval,
3071cd65da9SArmin Le Grand                                 getTransparence()));
3081cd65da9SArmin Le Grand 
3091cd65da9SArmin Le Grand                         aRetval = Primitive2DSequence(&aFillTransparent, 1);
3101cd65da9SArmin Le Grand                     }
3111cd65da9SArmin Le Grand                 }
312cdf0e10cSrcweir             }
313cdf0e10cSrcweir 
314cdf0e10cSrcweir             return aRetval;
3151cd65da9SArmin Le Grand         }
316cdf0e10cSrcweir 
operator ==(const BasePrimitive2D & rPrimitive) const3171cd65da9SArmin Le Grand 		bool OverlayRectanglePrimitive::operator==( const BasePrimitive2D& rPrimitive ) const
318cdf0e10cSrcweir 		{
319cdf0e10cSrcweir 			if(DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
320cdf0e10cSrcweir 			{
3211cd65da9SArmin Le Grand 				const OverlayRectanglePrimitive& rCompare = static_cast< const OverlayRectanglePrimitive& >(rPrimitive);
322cdf0e10cSrcweir 
323cdf0e10cSrcweir 				return (getObjectRange() == rCompare.getObjectRange()
3241cd65da9SArmin Le Grand 					&& getColor() == rCompare.getColor()
3251cd65da9SArmin Le Grand                     && getTransparence() == rCompare.getTransparence()
326cdf0e10cSrcweir 					&& getDiscreteGrow() == rCompare.getDiscreteGrow()
327cdf0e10cSrcweir 					&& getDiscreteShrink() == rCompare.getDiscreteShrink()
328cdf0e10cSrcweir 					&& getRotation() == rCompare.getRotation());
329cdf0e10cSrcweir 			}
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 			return false;
332cdf0e10cSrcweir 		}
333cdf0e10cSrcweir 
3341cd65da9SArmin Le Grand 		ImplPrimitrive2DIDBlock(OverlayRectanglePrimitive, PRIMITIVE2D_ID_OVERLAYRECTANGLEPRIMITIVE)
335cdf0e10cSrcweir 
336cdf0e10cSrcweir 	} // end of namespace primitive2d
337cdf0e10cSrcweir } // end of namespace drawinglayer
338cdf0e10cSrcweir 
339cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
340cdf0e10cSrcweir 
341cdf0e10cSrcweir namespace drawinglayer
342cdf0e10cSrcweir {
343cdf0e10cSrcweir 	namespace primitive2d
344cdf0e10cSrcweir 	{
OverlayHelplineStripedPrimitive(const basegfx::B2DPoint & rBasePosition,HelplineStyle eStyle,const basegfx::BColor & rRGBColorA,const basegfx::BColor & rRGBColorB,double fDiscreteDashLength)345cdf0e10cSrcweir         OverlayHelplineStripedPrimitive::OverlayHelplineStripedPrimitive(
346cdf0e10cSrcweir             const basegfx::B2DPoint& rBasePosition,
347cdf0e10cSrcweir             HelplineStyle eStyle,
348cdf0e10cSrcweir 			const basegfx::BColor& rRGBColorA,
349cdf0e10cSrcweir 			const basegfx::BColor& rRGBColorB,
350cdf0e10cSrcweir 			double fDiscreteDashLength)
351cdf0e10cSrcweir         :   ViewportDependentPrimitive2D(),
352cdf0e10cSrcweir 			maBasePosition(rBasePosition),
353cdf0e10cSrcweir             meStyle(eStyle),
354cdf0e10cSrcweir 			maRGBColorA(rRGBColorA),
355cdf0e10cSrcweir 			maRGBColorB(rRGBColorB),
356cdf0e10cSrcweir 			mfDiscreteDashLength(fDiscreteDashLength)
357cdf0e10cSrcweir         {}
358cdf0e10cSrcweir 
create2DDecomposition(const geometry::ViewInformation2D & rViewInformation) const359cdf0e10cSrcweir 		Primitive2DSequence OverlayHelplineStripedPrimitive::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
360cdf0e10cSrcweir 		{
361cdf0e10cSrcweir             // use the prepared Viewport information accessible using getViewport()
362cdf0e10cSrcweir             Primitive2DSequence aRetval;
363cdf0e10cSrcweir 
364cdf0e10cSrcweir             if(!getViewport().isEmpty())
365cdf0e10cSrcweir             {
366cdf0e10cSrcweir 			    switch(getStyle())
367cdf0e10cSrcweir 			    {
368cdf0e10cSrcweir 				    case HELPLINESTYLE_VERTICAL :
369cdf0e10cSrcweir 				    {
370cdf0e10cSrcweir                         aRetval.realloc(1);
371cdf0e10cSrcweir                         basegfx::B2DPolygon aLine;
372cdf0e10cSrcweir 
373cdf0e10cSrcweir                         aLine.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMinY()));
374cdf0e10cSrcweir 					    aLine.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMaxY()));
375cdf0e10cSrcweir 
376cdf0e10cSrcweir                         aRetval[0] = Primitive2DReference(
377cdf0e10cSrcweir                             new PolygonMarkerPrimitive2D(
378cdf0e10cSrcweir                                 aLine,
379cdf0e10cSrcweir                                 getRGBColorA(),
380cdf0e10cSrcweir                                 getRGBColorB(),
381cdf0e10cSrcweir                                 getDiscreteDashLength()));
382cdf0e10cSrcweir 					    break;
383cdf0e10cSrcweir 				    }
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 				    case HELPLINESTYLE_HORIZONTAL :
386cdf0e10cSrcweir 				    {
387cdf0e10cSrcweir                         aRetval.realloc(1);
388cdf0e10cSrcweir                         basegfx::B2DPolygon aLine;
389cdf0e10cSrcweir 
390cdf0e10cSrcweir                         aLine.append(basegfx::B2DPoint(getViewport().getMinX(), getBasePosition().getY()));
391cdf0e10cSrcweir 					    aLine.append(basegfx::B2DPoint(getViewport().getMaxX(), getBasePosition().getY()));
392cdf0e10cSrcweir 
393cdf0e10cSrcweir                         aRetval[0] = Primitive2DReference(
394cdf0e10cSrcweir                             new PolygonMarkerPrimitive2D(
395cdf0e10cSrcweir                                 aLine,
396cdf0e10cSrcweir                                 getRGBColorA(),
397cdf0e10cSrcweir                                 getRGBColorB(),
398cdf0e10cSrcweir                                 getDiscreteDashLength()));
399cdf0e10cSrcweir 					    break;
400cdf0e10cSrcweir 				    }
401cdf0e10cSrcweir 
402cdf0e10cSrcweir                     default: // case HELPLINESTYLE_POINT :
403cdf0e10cSrcweir 				    {
404cdf0e10cSrcweir             			const double fDiscreteUnit((rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)).getLength());
405cdf0e10cSrcweir                         aRetval.realloc(2);
406cdf0e10cSrcweir                         basegfx::B2DPolygon aLineA, aLineB;
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 					    aLineA.append(basegfx::B2DPoint(getBasePosition().getX(), getBasePosition().getY() - fDiscreteUnit));
409cdf0e10cSrcweir 					    aLineA.append(basegfx::B2DPoint(getBasePosition().getX(), getBasePosition().getY() + fDiscreteUnit));
410cdf0e10cSrcweir 
411cdf0e10cSrcweir                         aRetval[0] = Primitive2DReference(
412cdf0e10cSrcweir                             new PolygonMarkerPrimitive2D(
413cdf0e10cSrcweir                                 aLineA,
414cdf0e10cSrcweir                                 getRGBColorA(),
415cdf0e10cSrcweir                                 getRGBColorB(),
416cdf0e10cSrcweir                                 getDiscreteDashLength()));
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 					    aLineB.append(basegfx::B2DPoint(getBasePosition().getX() - fDiscreteUnit, getBasePosition().getY()));
419cdf0e10cSrcweir 					    aLineB.append(basegfx::B2DPoint(getBasePosition().getX() + fDiscreteUnit, getBasePosition().getY()));
420cdf0e10cSrcweir 
421cdf0e10cSrcweir                         aRetval[1] = Primitive2DReference(
422cdf0e10cSrcweir                             new PolygonMarkerPrimitive2D(
423cdf0e10cSrcweir                                 aLineB,
424cdf0e10cSrcweir                                 getRGBColorA(),
425cdf0e10cSrcweir                                 getRGBColorB(),
426cdf0e10cSrcweir                                 getDiscreteDashLength()));
427cdf0e10cSrcweir 
428cdf0e10cSrcweir 					    break;
429cdf0e10cSrcweir 				    }
430cdf0e10cSrcweir 			    }
431cdf0e10cSrcweir             }
432cdf0e10cSrcweir 
433cdf0e10cSrcweir             return aRetval;
434cdf0e10cSrcweir 		}
435cdf0e10cSrcweir 
operator ==(const BasePrimitive2D & rPrimitive) const436cdf0e10cSrcweir 		bool OverlayHelplineStripedPrimitive::operator==( const BasePrimitive2D& rPrimitive ) const
437cdf0e10cSrcweir 		{
438cdf0e10cSrcweir 			if(ViewportDependentPrimitive2D::operator==(rPrimitive))
439cdf0e10cSrcweir 			{
440cdf0e10cSrcweir 				const OverlayHelplineStripedPrimitive& rCompare = static_cast< const OverlayHelplineStripedPrimitive& >(rPrimitive);
441cdf0e10cSrcweir 
442cdf0e10cSrcweir 				return (getBasePosition() == rCompare.getBasePosition()
443cdf0e10cSrcweir                     && getStyle() == rCompare.getStyle()
444cdf0e10cSrcweir 					&& getRGBColorA() == rCompare.getRGBColorA()
445cdf0e10cSrcweir 					&& getRGBColorB() == rCompare.getRGBColorB()
446cdf0e10cSrcweir                     && getDiscreteDashLength() == rCompare.getDiscreteDashLength());
447cdf0e10cSrcweir 			}
448cdf0e10cSrcweir 
449cdf0e10cSrcweir 			return false;
450cdf0e10cSrcweir 		}
451cdf0e10cSrcweir 
452cdf0e10cSrcweir 		ImplPrimitrive2DIDBlock(OverlayHelplineStripedPrimitive, PRIMITIVE2D_ID_OVERLAYHELPLINESTRIPEDPRIMITIVE)
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 	} // end of namespace primitive2d
455cdf0e10cSrcweir } // end of namespace drawinglayer
456cdf0e10cSrcweir 
457cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
458cdf0e10cSrcweir 
459cdf0e10cSrcweir namespace drawinglayer
460cdf0e10cSrcweir {
461cdf0e10cSrcweir 	namespace primitive2d
462cdf0e10cSrcweir 	{
OverlayRollingRectanglePrimitive(const basegfx::B2DRange & aRollingRectangle,const basegfx::BColor & rRGBColorA,const basegfx::BColor & rRGBColorB,double fDiscreteDashLength)463cdf0e10cSrcweir         OverlayRollingRectanglePrimitive::OverlayRollingRectanglePrimitive(
464cdf0e10cSrcweir             const basegfx::B2DRange& aRollingRectangle,
465cdf0e10cSrcweir 			const basegfx::BColor& rRGBColorA,
466cdf0e10cSrcweir 			const basegfx::BColor& rRGBColorB,
467cdf0e10cSrcweir 			double fDiscreteDashLength)
468cdf0e10cSrcweir         :   ViewportDependentPrimitive2D(),
469cdf0e10cSrcweir 			maRollingRectangle(aRollingRectangle),
470cdf0e10cSrcweir 			maRGBColorA(rRGBColorA),
471cdf0e10cSrcweir 			maRGBColorB(rRGBColorB),
472cdf0e10cSrcweir 			mfDiscreteDashLength(fDiscreteDashLength)
473cdf0e10cSrcweir         {}
474cdf0e10cSrcweir 
create2DDecomposition(const geometry::ViewInformation2D &) const475cdf0e10cSrcweir 		Primitive2DSequence OverlayRollingRectanglePrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
476cdf0e10cSrcweir 		{
477cdf0e10cSrcweir             // use the prepared Viewport information accessible using getViewport()
478cdf0e10cSrcweir             Primitive2DSequence aRetval;
479cdf0e10cSrcweir 
480cdf0e10cSrcweir             if(!getViewport().isEmpty())
481cdf0e10cSrcweir             {
482cdf0e10cSrcweir                 basegfx::B2DPolygon aLine;
483cdf0e10cSrcweir                 aRetval.realloc(8);
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 				// Left lines
486cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getViewport().getMinX(), getRollingRectangle().getMinY()));
487cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMinY()));
488cdf0e10cSrcweir                 aRetval[0] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
489cdf0e10cSrcweir 
490cdf0e10cSrcweir                 aLine.clear();
491cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getViewport().getMinX(), getRollingRectangle().getMaxY()));
492cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMaxY()));
493cdf0e10cSrcweir                 aRetval[1] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
494cdf0e10cSrcweir 
495cdf0e10cSrcweir 				// Right lines
496cdf0e10cSrcweir                 aLine.clear();
497cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMinY()));
498cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getViewport().getMaxX(), getRollingRectangle().getMinY()));
499cdf0e10cSrcweir                 aRetval[2] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
500cdf0e10cSrcweir 
501cdf0e10cSrcweir                 aLine.clear();
502cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMaxY()));
503cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getViewport().getMaxX(), getRollingRectangle().getMaxY()));
504cdf0e10cSrcweir                 aRetval[3] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 				// Top lines
507cdf0e10cSrcweir                 aLine.clear();
508cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getViewport().getMinY()));
509cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMinY()));
510cdf0e10cSrcweir                 aRetval[4] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
511cdf0e10cSrcweir 
512cdf0e10cSrcweir                 aLine.clear();
513cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getViewport().getMinY()));
514cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMinY()));
515cdf0e10cSrcweir                 aRetval[5] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
516cdf0e10cSrcweir 
517cdf0e10cSrcweir 				// Bottom lines
518cdf0e10cSrcweir                 aLine.clear();
519cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMaxY()));
520cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getViewport().getMaxY()));
521cdf0e10cSrcweir                 aRetval[6] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
522cdf0e10cSrcweir 
523cdf0e10cSrcweir                 aLine.clear();
524cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMaxY()));
525cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getViewport().getMaxY()));
526cdf0e10cSrcweir                 aRetval[7] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
527cdf0e10cSrcweir             }
528cdf0e10cSrcweir 
529cdf0e10cSrcweir             return aRetval;
530cdf0e10cSrcweir 		}
531cdf0e10cSrcweir 
operator ==(const BasePrimitive2D & rPrimitive) const532cdf0e10cSrcweir 		bool OverlayRollingRectanglePrimitive::operator==( const BasePrimitive2D& rPrimitive ) const
533cdf0e10cSrcweir 		{
534cdf0e10cSrcweir 			if(ViewportDependentPrimitive2D::operator==(rPrimitive))
535cdf0e10cSrcweir 			{
536cdf0e10cSrcweir 				const OverlayRollingRectanglePrimitive& rCompare = static_cast< const OverlayRollingRectanglePrimitive& >(rPrimitive);
537cdf0e10cSrcweir 
538cdf0e10cSrcweir 				return (getRollingRectangle() == rCompare.getRollingRectangle()
539cdf0e10cSrcweir 					&& getRGBColorA() == rCompare.getRGBColorA()
540cdf0e10cSrcweir 					&& getRGBColorB() == rCompare.getRGBColorB()
541cdf0e10cSrcweir                     && getDiscreteDashLength() == rCompare.getDiscreteDashLength());
542cdf0e10cSrcweir 			}
543cdf0e10cSrcweir 
544cdf0e10cSrcweir 			return false;
545cdf0e10cSrcweir 		}
546cdf0e10cSrcweir 
547cdf0e10cSrcweir 		ImplPrimitrive2DIDBlock(OverlayRollingRectanglePrimitive, PRIMITIVE2D_ID_OVERLAYROLLINGRECTANGLEPRIMITIVE)
548cdf0e10cSrcweir 
549cdf0e10cSrcweir 	} // end of namespace primitive2d
550cdf0e10cSrcweir } // end of namespace drawinglayer
551cdf0e10cSrcweir 
552cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
553cdf0e10cSrcweir // eof
554