xref: /AOO41X/main/svx/source/sdr/overlay/overlaytools.cxx (revision f6e50924346d0b8c0b07c91832a97665dd718b0c)
1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f6e50924SAndrew Rist  * distributed with this work for additional information
6*f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f6e50924SAndrew Rist  * specific language governing permissions and limitations
18*f6e50924SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*f6e50924SAndrew Rist  *************************************************************/
21*f6e50924SAndrew Rist 
22*f6e50924SAndrew 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>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
39cdf0e10cSrcweir 
40cdf0e10cSrcweir namespace drawinglayer
41cdf0e10cSrcweir {
42cdf0e10cSrcweir 	namespace primitive2d
43cdf0e10cSrcweir 	{
44cdf0e10cSrcweir         OverlayBitmapExPrimitive::OverlayBitmapExPrimitive(
45cdf0e10cSrcweir 			const BitmapEx& rBitmapEx,
46cdf0e10cSrcweir 			const basegfx::B2DPoint& rBasePosition,
47cdf0e10cSrcweir 			sal_uInt16 nCenterX,
48cdf0e10cSrcweir 			sal_uInt16 nCenterY)
49cdf0e10cSrcweir 		:   DiscreteMetricDependentPrimitive2D(),
50cdf0e10cSrcweir 			maBitmapEx(rBitmapEx),
51cdf0e10cSrcweir 			maBasePosition(rBasePosition),
52cdf0e10cSrcweir 			mnCenterX(nCenterX),
53cdf0e10cSrcweir 			mnCenterY(nCenterY)
54cdf0e10cSrcweir 		{}
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 		Primitive2DSequence OverlayBitmapExPrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
57cdf0e10cSrcweir 		{
58cdf0e10cSrcweir             Primitive2DSequence aRetval;
59cdf0e10cSrcweir 			const Size aBitmapSize(getBitmapEx().GetSizePixel());
60cdf0e10cSrcweir 
61cdf0e10cSrcweir             if(aBitmapSize.Width() && aBitmapSize.Height() && basegfx::fTools::more(getDiscreteUnit(), 0.0))
62cdf0e10cSrcweir 			{
63cdf0e10cSrcweir                 // calculate back from internal bitmap's extreme coordinates (the edges)
64cdf0e10cSrcweir                 // to logical coordinates. Only use a unified scaling value (getDiscreteUnit(),
65cdf0e10cSrcweir                 // the prepared one which expresses how many logic units form a discrete unit)
66cdf0e10cSrcweir                 // for this step. This primitive is to be displayed always unscaled (in it's pixel size)
67cdf0e10cSrcweir                 // and unrotated, more like a marker
68cdf0e10cSrcweir                 const double fLeft(((0.0 - getCenterX()) * getDiscreteUnit()) + getBasePosition().getX());
69cdf0e10cSrcweir                 const double fTop(((0.0 - getCenterY()) * getDiscreteUnit()) + getBasePosition().getY());
70cdf0e10cSrcweir                 const double fRight((((aBitmapSize.getWidth() - 1.0) - getCenterX()) * getDiscreteUnit()) + getBasePosition().getX());
71cdf0e10cSrcweir                 const double fBottom((((aBitmapSize.getHeight() - 1.0) - getCenterY()) * getDiscreteUnit()) + getBasePosition().getY());
72cdf0e10cSrcweir 
73cdf0e10cSrcweir                 // create a BitmapPrimitive2D using those positions
74cdf0e10cSrcweir 				basegfx::B2DHomMatrix aTransform;
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 				aTransform.set(0, 0, fRight - fLeft);
77cdf0e10cSrcweir 				aTransform.set(1, 1, fBottom - fTop);
78cdf0e10cSrcweir 				aTransform.set(0, 2, fLeft);
79cdf0e10cSrcweir 				aTransform.set(1, 2, fTop);
80cdf0e10cSrcweir 
81cdf0e10cSrcweir                 const Primitive2DReference aPrimitive(new BitmapPrimitive2D(getBitmapEx(), aTransform));
82cdf0e10cSrcweir                 aRetval = Primitive2DSequence(&aPrimitive, 1);
83cdf0e10cSrcweir             }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir             return aRetval;
86cdf0e10cSrcweir 		}
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 		bool OverlayBitmapExPrimitive::operator==( const BasePrimitive2D& rPrimitive ) const
89cdf0e10cSrcweir 		{
90cdf0e10cSrcweir 			if(DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
91cdf0e10cSrcweir 			{
92cdf0e10cSrcweir 				const OverlayBitmapExPrimitive& rCompare = static_cast< const OverlayBitmapExPrimitive& >(rPrimitive);
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 				return (getBitmapEx() == rCompare.getBitmapEx()
95cdf0e10cSrcweir 					&& getBasePosition() == rCompare.getBasePosition()
96cdf0e10cSrcweir 					&& getCenterX() == rCompare.getCenterX()
97cdf0e10cSrcweir 					&& getCenterY() == rCompare.getCenterY());
98cdf0e10cSrcweir 			}
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 			return false;
101cdf0e10cSrcweir 		}
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 		ImplPrimitrive2DIDBlock(OverlayBitmapExPrimitive, PRIMITIVE2D_ID_OVERLAYBITMAPEXPRIMITIVE)
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 	} // end of namespace primitive2d
106cdf0e10cSrcweir } // end of namespace drawinglayer
107cdf0e10cSrcweir 
108cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
109cdf0e10cSrcweir 
110cdf0e10cSrcweir namespace drawinglayer
111cdf0e10cSrcweir {
112cdf0e10cSrcweir 	namespace primitive2d
113cdf0e10cSrcweir 	{
114cdf0e10cSrcweir         OverlayCrosshairPrimitive::OverlayCrosshairPrimitive(
115cdf0e10cSrcweir             const basegfx::B2DPoint& rBasePosition,
116cdf0e10cSrcweir 			const basegfx::BColor& rRGBColorA,
117cdf0e10cSrcweir 			const basegfx::BColor& rRGBColorB,
118cdf0e10cSrcweir 			double fDiscreteDashLength)
119cdf0e10cSrcweir         :   ViewportDependentPrimitive2D(),
120cdf0e10cSrcweir 			maBasePosition(rBasePosition),
121cdf0e10cSrcweir 			maRGBColorA(rRGBColorA),
122cdf0e10cSrcweir 			maRGBColorB(rRGBColorB),
123cdf0e10cSrcweir 			mfDiscreteDashLength(fDiscreteDashLength)
124cdf0e10cSrcweir         {}
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 		Primitive2DSequence OverlayCrosshairPrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
127cdf0e10cSrcweir 		{
128cdf0e10cSrcweir             // use the prepared Viewport information accessible using getViewport()
129cdf0e10cSrcweir             Primitive2DSequence aRetval;
130cdf0e10cSrcweir 
131cdf0e10cSrcweir             if(!getViewport().isEmpty())
132cdf0e10cSrcweir             {
133cdf0e10cSrcweir                 aRetval.realloc(2);
134cdf0e10cSrcweir                 basegfx::B2DPolygon aPolygon;
135cdf0e10cSrcweir 
136cdf0e10cSrcweir                 aPolygon.append(basegfx::B2DPoint(getViewport().getMinX(), getBasePosition().getY()));
137cdf0e10cSrcweir                 aPolygon.append(basegfx::B2DPoint(getViewport().getMaxX(), getBasePosition().getY()));
138cdf0e10cSrcweir 
139cdf0e10cSrcweir                 aRetval[0] = Primitive2DReference(
140cdf0e10cSrcweir                     new PolygonMarkerPrimitive2D(
141cdf0e10cSrcweir                         aPolygon,
142cdf0e10cSrcweir                         getRGBColorA(),
143cdf0e10cSrcweir                         getRGBColorB(),
144cdf0e10cSrcweir                         getDiscreteDashLength()));
145cdf0e10cSrcweir 
146cdf0e10cSrcweir                 aPolygon.clear();
147cdf0e10cSrcweir                 aPolygon.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMinY()));
148cdf0e10cSrcweir                 aPolygon.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMaxY()));
149cdf0e10cSrcweir 
150cdf0e10cSrcweir                 aRetval[1] = Primitive2DReference(
151cdf0e10cSrcweir                     new PolygonMarkerPrimitive2D(
152cdf0e10cSrcweir                         aPolygon,
153cdf0e10cSrcweir                         getRGBColorA(),
154cdf0e10cSrcweir                         getRGBColorB(),
155cdf0e10cSrcweir                         getDiscreteDashLength()));
156cdf0e10cSrcweir             }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir             return aRetval;
159cdf0e10cSrcweir 		}
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 		bool OverlayCrosshairPrimitive::operator==( const BasePrimitive2D& rPrimitive ) const
162cdf0e10cSrcweir 		{
163cdf0e10cSrcweir 			if(ViewportDependentPrimitive2D::operator==(rPrimitive))
164cdf0e10cSrcweir 			{
165cdf0e10cSrcweir 				const OverlayCrosshairPrimitive& rCompare = static_cast< const OverlayCrosshairPrimitive& >(rPrimitive);
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 				return (getBasePosition() == rCompare.getBasePosition()
168cdf0e10cSrcweir 					&& getRGBColorA() == rCompare.getRGBColorA()
169cdf0e10cSrcweir 					&& getRGBColorB() == rCompare.getRGBColorB()
170cdf0e10cSrcweir                     && getDiscreteDashLength() == rCompare.getDiscreteDashLength());
171cdf0e10cSrcweir 			}
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 			return false;
174cdf0e10cSrcweir 		}
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 		ImplPrimitrive2DIDBlock(OverlayCrosshairPrimitive, PRIMITIVE2D_ID_OVERLAYCROSSHAIRPRIMITIVE)
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 	} // end of namespace primitive2d
179cdf0e10cSrcweir } // end of namespace drawinglayer
180cdf0e10cSrcweir 
181cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
182cdf0e10cSrcweir 
183cdf0e10cSrcweir namespace drawinglayer
184cdf0e10cSrcweir {
185cdf0e10cSrcweir 	namespace primitive2d
186cdf0e10cSrcweir 	{
187cdf0e10cSrcweir         OverlayHatchRectanglePrimitive::OverlayHatchRectanglePrimitive(
188cdf0e10cSrcweir             const basegfx::B2DRange& rObjectRange,
189cdf0e10cSrcweir 			double fDiscreteHatchDistance,
190cdf0e10cSrcweir 			double fHatchRotation,
191cdf0e10cSrcweir 			const basegfx::BColor& rHatchColor,
192cdf0e10cSrcweir             double fDiscreteGrow,
193cdf0e10cSrcweir             double fDiscreteShrink,
194cdf0e10cSrcweir             double fRotation)
195cdf0e10cSrcweir         :   DiscreteMetricDependentPrimitive2D(),
196cdf0e10cSrcweir             maObjectRange(rObjectRange),
197cdf0e10cSrcweir 			mfDiscreteHatchDistance(fDiscreteHatchDistance),
198cdf0e10cSrcweir 			mfHatchRotation(fHatchRotation),
199cdf0e10cSrcweir 			maHatchColor(rHatchColor),
200cdf0e10cSrcweir             mfDiscreteGrow(fDiscreteGrow),
201cdf0e10cSrcweir             mfDiscreteShrink(fDiscreteShrink),
202cdf0e10cSrcweir             mfRotation(fRotation)
203cdf0e10cSrcweir         {}
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 		Primitive2DSequence OverlayHatchRectanglePrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
206cdf0e10cSrcweir 		{
207cdf0e10cSrcweir             Primitive2DSequence aRetval;
208cdf0e10cSrcweir 
209cdf0e10cSrcweir             if(basegfx::fTools::more(getDiscreteUnit(), 0.0))
210cdf0e10cSrcweir             {
211cdf0e10cSrcweir 			    basegfx::B2DRange aInnerRange(getObjectRange());
212cdf0e10cSrcweir 			    basegfx::B2DRange aOuterRange(getObjectRange());
213cdf0e10cSrcweir 			    basegfx::B2DPolyPolygon aHatchPolyPolygon;
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 			    aOuterRange.grow(getDiscreteUnit() * getDiscreteGrow());
216cdf0e10cSrcweir 			    aInnerRange.grow(getDiscreteUnit() * -getDiscreteShrink());
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 			    aHatchPolyPolygon.append(basegfx::tools::createPolygonFromRect(aOuterRange));
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 				if(!aInnerRange.isEmpty())
221cdf0e10cSrcweir 				{
222cdf0e10cSrcweir 				    aHatchPolyPolygon.append(basegfx::tools::createPolygonFromRect(aInnerRange));
223cdf0e10cSrcweir 				}
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 			    if(!basegfx::fTools::equalZero(getRotation()))
226cdf0e10cSrcweir 			    {
227cdf0e10cSrcweir                     const basegfx::B2DHomMatrix aTransform(basegfx::tools::createRotateAroundPoint(
228cdf0e10cSrcweir                         getObjectRange().getMinX(), getObjectRange().getMinY(), getRotation()));
229cdf0e10cSrcweir 
230cdf0e10cSrcweir                     aHatchPolyPolygon.transform(aTransform);
231cdf0e10cSrcweir 			    }
232cdf0e10cSrcweir 
233cdf0e10cSrcweir                 const basegfx::BColor aEmptyColor(0.0, 0.0, 0.0);
234cdf0e10cSrcweir 				const drawinglayer::attribute::FillHatchAttribute aFillHatchAttribute(
235cdf0e10cSrcweir 					drawinglayer::attribute::HATCHSTYLE_SINGLE,
236cdf0e10cSrcweir 					getDiscreteHatchDistance() * getDiscreteUnit(),
237cdf0e10cSrcweir 					getHatchRotation() - getRotation(),
238cdf0e10cSrcweir 					getHatchColor(),
239cdf0e10cSrcweir 					false);
240cdf0e10cSrcweir                 const Primitive2DReference aPrimitive(
241cdf0e10cSrcweir                     new PolyPolygonHatchPrimitive2D(
242cdf0e10cSrcweir                         aHatchPolyPolygon,
243cdf0e10cSrcweir                         aEmptyColor,
244cdf0e10cSrcweir                         aFillHatchAttribute));
245cdf0e10cSrcweir 
246cdf0e10cSrcweir                 aRetval = Primitive2DSequence(&aPrimitive, 1);
247cdf0e10cSrcweir             }
248cdf0e10cSrcweir 
249cdf0e10cSrcweir             return aRetval;
250cdf0e10cSrcweir 		}
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 		bool OverlayHatchRectanglePrimitive::operator==( const BasePrimitive2D& rPrimitive ) const
253cdf0e10cSrcweir 		{
254cdf0e10cSrcweir 			if(DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
255cdf0e10cSrcweir 			{
256cdf0e10cSrcweir 				const OverlayHatchRectanglePrimitive& rCompare = static_cast< const OverlayHatchRectanglePrimitive& >(rPrimitive);
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 				return (getObjectRange() == rCompare.getObjectRange()
259cdf0e10cSrcweir 					&& getDiscreteHatchDistance() == rCompare.getDiscreteHatchDistance()
260cdf0e10cSrcweir 					&& getHatchRotation() == rCompare.getHatchRotation()
261cdf0e10cSrcweir 					&& getHatchColor() == rCompare.getHatchColor()
262cdf0e10cSrcweir 					&& getDiscreteGrow() == rCompare.getDiscreteGrow()
263cdf0e10cSrcweir 					&& getDiscreteShrink() == rCompare.getDiscreteShrink()
264cdf0e10cSrcweir 					&& getRotation() == rCompare.getRotation());
265cdf0e10cSrcweir 			}
266cdf0e10cSrcweir 
267cdf0e10cSrcweir 			return false;
268cdf0e10cSrcweir 		}
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 		ImplPrimitrive2DIDBlock(OverlayHatchRectanglePrimitive, PRIMITIVE2D_ID_OVERLAYHATCHRECTANGLEPRIMITIVE)
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 	} // end of namespace primitive2d
273cdf0e10cSrcweir } // end of namespace drawinglayer
274cdf0e10cSrcweir 
275cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
276cdf0e10cSrcweir 
277cdf0e10cSrcweir namespace drawinglayer
278cdf0e10cSrcweir {
279cdf0e10cSrcweir 	namespace primitive2d
280cdf0e10cSrcweir 	{
281cdf0e10cSrcweir         OverlayHelplineStripedPrimitive::OverlayHelplineStripedPrimitive(
282cdf0e10cSrcweir             const basegfx::B2DPoint& rBasePosition,
283cdf0e10cSrcweir             HelplineStyle eStyle,
284cdf0e10cSrcweir 			const basegfx::BColor& rRGBColorA,
285cdf0e10cSrcweir 			const basegfx::BColor& rRGBColorB,
286cdf0e10cSrcweir 			double fDiscreteDashLength)
287cdf0e10cSrcweir         :   ViewportDependentPrimitive2D(),
288cdf0e10cSrcweir 			maBasePosition(rBasePosition),
289cdf0e10cSrcweir             meStyle(eStyle),
290cdf0e10cSrcweir 			maRGBColorA(rRGBColorA),
291cdf0e10cSrcweir 			maRGBColorB(rRGBColorB),
292cdf0e10cSrcweir 			mfDiscreteDashLength(fDiscreteDashLength)
293cdf0e10cSrcweir         {}
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 		Primitive2DSequence OverlayHelplineStripedPrimitive::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
296cdf0e10cSrcweir 		{
297cdf0e10cSrcweir             // use the prepared Viewport information accessible using getViewport()
298cdf0e10cSrcweir             Primitive2DSequence aRetval;
299cdf0e10cSrcweir 
300cdf0e10cSrcweir             if(!getViewport().isEmpty())
301cdf0e10cSrcweir             {
302cdf0e10cSrcweir 			    switch(getStyle())
303cdf0e10cSrcweir 			    {
304cdf0e10cSrcweir 				    case HELPLINESTYLE_VERTICAL :
305cdf0e10cSrcweir 				    {
306cdf0e10cSrcweir                         aRetval.realloc(1);
307cdf0e10cSrcweir                         basegfx::B2DPolygon aLine;
308cdf0e10cSrcweir 
309cdf0e10cSrcweir                         aLine.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMinY()));
310cdf0e10cSrcweir 					    aLine.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMaxY()));
311cdf0e10cSrcweir 
312cdf0e10cSrcweir                         aRetval[0] = Primitive2DReference(
313cdf0e10cSrcweir                             new PolygonMarkerPrimitive2D(
314cdf0e10cSrcweir                                 aLine,
315cdf0e10cSrcweir                                 getRGBColorA(),
316cdf0e10cSrcweir                                 getRGBColorB(),
317cdf0e10cSrcweir                                 getDiscreteDashLength()));
318cdf0e10cSrcweir 					    break;
319cdf0e10cSrcweir 				    }
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 				    case HELPLINESTYLE_HORIZONTAL :
322cdf0e10cSrcweir 				    {
323cdf0e10cSrcweir                         aRetval.realloc(1);
324cdf0e10cSrcweir                         basegfx::B2DPolygon aLine;
325cdf0e10cSrcweir 
326cdf0e10cSrcweir                         aLine.append(basegfx::B2DPoint(getViewport().getMinX(), getBasePosition().getY()));
327cdf0e10cSrcweir 					    aLine.append(basegfx::B2DPoint(getViewport().getMaxX(), getBasePosition().getY()));
328cdf0e10cSrcweir 
329cdf0e10cSrcweir                         aRetval[0] = Primitive2DReference(
330cdf0e10cSrcweir                             new PolygonMarkerPrimitive2D(
331cdf0e10cSrcweir                                 aLine,
332cdf0e10cSrcweir                                 getRGBColorA(),
333cdf0e10cSrcweir                                 getRGBColorB(),
334cdf0e10cSrcweir                                 getDiscreteDashLength()));
335cdf0e10cSrcweir 					    break;
336cdf0e10cSrcweir 				    }
337cdf0e10cSrcweir 
338cdf0e10cSrcweir                     default: // case HELPLINESTYLE_POINT :
339cdf0e10cSrcweir 				    {
340cdf0e10cSrcweir             			const double fDiscreteUnit((rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)).getLength());
341cdf0e10cSrcweir                         aRetval.realloc(2);
342cdf0e10cSrcweir                         basegfx::B2DPolygon aLineA, aLineB;
343cdf0e10cSrcweir 
344cdf0e10cSrcweir 					    aLineA.append(basegfx::B2DPoint(getBasePosition().getX(), getBasePosition().getY() - fDiscreteUnit));
345cdf0e10cSrcweir 					    aLineA.append(basegfx::B2DPoint(getBasePosition().getX(), getBasePosition().getY() + fDiscreteUnit));
346cdf0e10cSrcweir 
347cdf0e10cSrcweir                         aRetval[0] = Primitive2DReference(
348cdf0e10cSrcweir                             new PolygonMarkerPrimitive2D(
349cdf0e10cSrcweir                                 aLineA,
350cdf0e10cSrcweir                                 getRGBColorA(),
351cdf0e10cSrcweir                                 getRGBColorB(),
352cdf0e10cSrcweir                                 getDiscreteDashLength()));
353cdf0e10cSrcweir 
354cdf0e10cSrcweir 					    aLineB.append(basegfx::B2DPoint(getBasePosition().getX() - fDiscreteUnit, getBasePosition().getY()));
355cdf0e10cSrcweir 					    aLineB.append(basegfx::B2DPoint(getBasePosition().getX() + fDiscreteUnit, getBasePosition().getY()));
356cdf0e10cSrcweir 
357cdf0e10cSrcweir                         aRetval[1] = Primitive2DReference(
358cdf0e10cSrcweir                             new PolygonMarkerPrimitive2D(
359cdf0e10cSrcweir                                 aLineB,
360cdf0e10cSrcweir                                 getRGBColorA(),
361cdf0e10cSrcweir                                 getRGBColorB(),
362cdf0e10cSrcweir                                 getDiscreteDashLength()));
363cdf0e10cSrcweir 
364cdf0e10cSrcweir 					    break;
365cdf0e10cSrcweir 				    }
366cdf0e10cSrcweir 			    }
367cdf0e10cSrcweir             }
368cdf0e10cSrcweir 
369cdf0e10cSrcweir             return aRetval;
370cdf0e10cSrcweir 		}
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 		bool OverlayHelplineStripedPrimitive::operator==( const BasePrimitive2D& rPrimitive ) const
373cdf0e10cSrcweir 		{
374cdf0e10cSrcweir 			if(ViewportDependentPrimitive2D::operator==(rPrimitive))
375cdf0e10cSrcweir 			{
376cdf0e10cSrcweir 				const OverlayHelplineStripedPrimitive& rCompare = static_cast< const OverlayHelplineStripedPrimitive& >(rPrimitive);
377cdf0e10cSrcweir 
378cdf0e10cSrcweir 				return (getBasePosition() == rCompare.getBasePosition()
379cdf0e10cSrcweir                     && getStyle() == rCompare.getStyle()
380cdf0e10cSrcweir 					&& getRGBColorA() == rCompare.getRGBColorA()
381cdf0e10cSrcweir 					&& getRGBColorB() == rCompare.getRGBColorB()
382cdf0e10cSrcweir                     && getDiscreteDashLength() == rCompare.getDiscreteDashLength());
383cdf0e10cSrcweir 			}
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 			return false;
386cdf0e10cSrcweir 		}
387cdf0e10cSrcweir 
388cdf0e10cSrcweir 		ImplPrimitrive2DIDBlock(OverlayHelplineStripedPrimitive, PRIMITIVE2D_ID_OVERLAYHELPLINESTRIPEDPRIMITIVE)
389cdf0e10cSrcweir 
390cdf0e10cSrcweir 	} // end of namespace primitive2d
391cdf0e10cSrcweir } // end of namespace drawinglayer
392cdf0e10cSrcweir 
393cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
394cdf0e10cSrcweir 
395cdf0e10cSrcweir namespace drawinglayer
396cdf0e10cSrcweir {
397cdf0e10cSrcweir 	namespace primitive2d
398cdf0e10cSrcweir 	{
399cdf0e10cSrcweir         OverlayRollingRectanglePrimitive::OverlayRollingRectanglePrimitive(
400cdf0e10cSrcweir             const basegfx::B2DRange& aRollingRectangle,
401cdf0e10cSrcweir 			const basegfx::BColor& rRGBColorA,
402cdf0e10cSrcweir 			const basegfx::BColor& rRGBColorB,
403cdf0e10cSrcweir 			double fDiscreteDashLength)
404cdf0e10cSrcweir         :   ViewportDependentPrimitive2D(),
405cdf0e10cSrcweir 			maRollingRectangle(aRollingRectangle),
406cdf0e10cSrcweir 			maRGBColorA(rRGBColorA),
407cdf0e10cSrcweir 			maRGBColorB(rRGBColorB),
408cdf0e10cSrcweir 			mfDiscreteDashLength(fDiscreteDashLength)
409cdf0e10cSrcweir         {}
410cdf0e10cSrcweir 
411cdf0e10cSrcweir 		Primitive2DSequence OverlayRollingRectanglePrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
412cdf0e10cSrcweir 		{
413cdf0e10cSrcweir             // use the prepared Viewport information accessible using getViewport()
414cdf0e10cSrcweir             Primitive2DSequence aRetval;
415cdf0e10cSrcweir 
416cdf0e10cSrcweir             if(!getViewport().isEmpty())
417cdf0e10cSrcweir             {
418cdf0e10cSrcweir                 basegfx::B2DPolygon aLine;
419cdf0e10cSrcweir                 aRetval.realloc(8);
420cdf0e10cSrcweir 
421cdf0e10cSrcweir 				// Left lines
422cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getViewport().getMinX(), getRollingRectangle().getMinY()));
423cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMinY()));
424cdf0e10cSrcweir                 aRetval[0] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
425cdf0e10cSrcweir 
426cdf0e10cSrcweir                 aLine.clear();
427cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getViewport().getMinX(), getRollingRectangle().getMaxY()));
428cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMaxY()));
429cdf0e10cSrcweir                 aRetval[1] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
430cdf0e10cSrcweir 
431cdf0e10cSrcweir 				// Right lines
432cdf0e10cSrcweir                 aLine.clear();
433cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMinY()));
434cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getViewport().getMaxX(), getRollingRectangle().getMinY()));
435cdf0e10cSrcweir                 aRetval[2] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
436cdf0e10cSrcweir 
437cdf0e10cSrcweir                 aLine.clear();
438cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMaxY()));
439cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getViewport().getMaxX(), getRollingRectangle().getMaxY()));
440cdf0e10cSrcweir                 aRetval[3] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
441cdf0e10cSrcweir 
442cdf0e10cSrcweir 				// Top lines
443cdf0e10cSrcweir                 aLine.clear();
444cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getViewport().getMinY()));
445cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMinY()));
446cdf0e10cSrcweir                 aRetval[4] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
447cdf0e10cSrcweir 
448cdf0e10cSrcweir                 aLine.clear();
449cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getViewport().getMinY()));
450cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMinY()));
451cdf0e10cSrcweir                 aRetval[5] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
452cdf0e10cSrcweir 
453cdf0e10cSrcweir 				// Bottom lines
454cdf0e10cSrcweir                 aLine.clear();
455cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMaxY()));
456cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getViewport().getMaxY()));
457cdf0e10cSrcweir                 aRetval[6] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
458cdf0e10cSrcweir 
459cdf0e10cSrcweir                 aLine.clear();
460cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMaxY()));
461cdf0e10cSrcweir                 aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getViewport().getMaxY()));
462cdf0e10cSrcweir                 aRetval[7] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
463cdf0e10cSrcweir             }
464cdf0e10cSrcweir 
465cdf0e10cSrcweir             return aRetval;
466cdf0e10cSrcweir 		}
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 		bool OverlayRollingRectanglePrimitive::operator==( const BasePrimitive2D& rPrimitive ) const
469cdf0e10cSrcweir 		{
470cdf0e10cSrcweir 			if(ViewportDependentPrimitive2D::operator==(rPrimitive))
471cdf0e10cSrcweir 			{
472cdf0e10cSrcweir 				const OverlayRollingRectanglePrimitive& rCompare = static_cast< const OverlayRollingRectanglePrimitive& >(rPrimitive);
473cdf0e10cSrcweir 
474cdf0e10cSrcweir 				return (getRollingRectangle() == rCompare.getRollingRectangle()
475cdf0e10cSrcweir 					&& getRGBColorA() == rCompare.getRGBColorA()
476cdf0e10cSrcweir 					&& getRGBColorB() == rCompare.getRGBColorB()
477cdf0e10cSrcweir                     && getDiscreteDashLength() == rCompare.getDiscreteDashLength());
478cdf0e10cSrcweir 			}
479cdf0e10cSrcweir 
480cdf0e10cSrcweir 			return false;
481cdf0e10cSrcweir 		}
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 		ImplPrimitrive2DIDBlock(OverlayRollingRectanglePrimitive, PRIMITIVE2D_ID_OVERLAYROLLINGRECTANGLEPRIMITIVE)
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 	} // end of namespace primitive2d
486cdf0e10cSrcweir } // end of namespace drawinglayer
487cdf0e10cSrcweir 
488cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
489cdf0e10cSrcweir // eof
490