1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_drawinglayer.hxx"
24 
25 #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
26 #include <basegfx/polygon/b2dpolygon.hxx>
27 #include <basegfx/polygon/b2dpolygontools.hxx>
28 #include <basegfx/matrix/b2dhommatrix.hxx>
29 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
30 #include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx>
31 
32 //////////////////////////////////////////////////////////////////////////////
33 
34 namespace drawinglayer
35 {
36 	namespace primitive2d
37 	{
createHiddenGeometryPrimitives2D(bool bFilled,const basegfx::B2DHomMatrix & rMatrix)38         Primitive2DReference createHiddenGeometryPrimitives2D(
39             bool bFilled,
40             const basegfx::B2DHomMatrix& rMatrix)
41         {
42 			const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createUnitPolygon());
43 
44             return createHiddenGeometryPrimitives2D(
45                 bFilled,
46                 basegfx::B2DPolyPolygon(aUnitOutline),
47                 rMatrix);
48         }
49 
createHiddenGeometryPrimitives2D(bool bFilled,const basegfx::B2DPolyPolygon & rPolyPolygon)50         Primitive2DReference createHiddenGeometryPrimitives2D(
51             bool bFilled,
52             const basegfx::B2DPolyPolygon& rPolyPolygon)
53         {
54             return createHiddenGeometryPrimitives2D(
55                 bFilled,
56                 rPolyPolygon,
57                 basegfx::B2DHomMatrix());
58         }
59 
createHiddenGeometryPrimitives2D(bool bFilled,const basegfx::B2DRange & rRange)60         Primitive2DReference createHiddenGeometryPrimitives2D(
61             bool bFilled,
62             const basegfx::B2DRange& rRange)
63 		{
64 			return createHiddenGeometryPrimitives2D(
65                 bFilled,
66                 rRange,
67                 basegfx::B2DHomMatrix());
68 		}
69 
createHiddenGeometryPrimitives2D(bool bFilled,const basegfx::B2DRange & rRange,const basegfx::B2DHomMatrix & rMatrix)70         Primitive2DReference createHiddenGeometryPrimitives2D(
71             bool bFilled,
72             const basegfx::B2DRange& rRange,
73             const basegfx::B2DHomMatrix& rMatrix)
74 		{
75 			const basegfx::B2DPolyPolygon aOutline(basegfx::tools::createPolygonFromRect(rRange));
76 
77 			return createHiddenGeometryPrimitives2D(
78                 bFilled,
79                 aOutline,
80                 rMatrix);
81 		}
82 
createHiddenGeometryPrimitives2D(bool bFilled,const basegfx::B2DPolyPolygon & rPolyPolygon,const basegfx::B2DHomMatrix & rMatrix)83         Primitive2DReference createHiddenGeometryPrimitives2D(
84             bool bFilled,
85             const basegfx::B2DPolyPolygon& rPolyPolygon,
86             const basegfx::B2DHomMatrix& rMatrix)
87         {
88             // create fill or line primitive
89             Primitive2DReference xReference;
90 			basegfx::B2DPolyPolygon aScaledOutline(rPolyPolygon);
91             aScaledOutline.transform(rMatrix);
92 
93             if(bFilled)
94             {
95                 xReference = new PolyPolygonColorPrimitive2D(
96                     basegfx::B2DPolyPolygon(aScaledOutline),
97                     basegfx::BColor(0.0, 0.0, 0.0));
98             }
99             else
100             {
101 				const basegfx::BColor aGrayTone(0xc0 / 255.0, 0xc0 / 255.0, 0xc0 / 255.0);
102 
103                 xReference = new PolyPolygonHairlinePrimitive2D(
104                     aScaledOutline,
105                     aGrayTone);
106             }
107 
108             // create HiddenGeometryPrimitive2D
109             return Primitive2DReference(
110                 new HiddenGeometryPrimitive2D(Primitive2DSequence(&xReference, 1)));
111         }
112 	} // end of namespace primitive2d
113 } // end of namespace drawinglayer
114 
115 //////////////////////////////////////////////////////////////////////////////
116 // eof
117