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 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_drawinglayer.hxx" 26 27 #include <drawinglayer/primitive3d/polygonprimitive3d.hxx> 28 #include <basegfx/polygon/b3dpolygontools.hxx> 29 #include <basegfx/tools/canvastools.hxx> 30 #include <basegfx/polygon/b3dpolypolygontools.hxx> 31 #include <drawinglayer/primitive3d/polygontubeprimitive3d.hxx> 32 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx> 33 34 ////////////////////////////////////////////////////////////////////////////// 35 36 using namespace com::sun::star; 37 38 ////////////////////////////////////////////////////////////////////////////// 39 40 namespace drawinglayer 41 { 42 namespace primitive3d 43 { 44 PolygonHairlinePrimitive3D::PolygonHairlinePrimitive3D( 45 const basegfx::B3DPolygon& rPolygon, 46 const basegfx::BColor& rBColor) 47 : BasePrimitive3D(), 48 maPolygon(rPolygon), 49 maBColor(rBColor) 50 { 51 } 52 53 bool PolygonHairlinePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const 54 { 55 if(BasePrimitive3D::operator==(rPrimitive)) 56 { 57 const PolygonHairlinePrimitive3D& rCompare = (PolygonHairlinePrimitive3D&)rPrimitive; 58 59 return (getB3DPolygon() == rCompare.getB3DPolygon() 60 && getBColor() == rCompare.getBColor()); 61 } 62 63 return false; 64 } 65 66 basegfx::B3DRange PolygonHairlinePrimitive3D::getB3DRange(const geometry::ViewInformation3D& /*rViewInformation*/) const 67 { 68 return basegfx::tools::getRange(getB3DPolygon()); 69 } 70 71 // provide unique ID 72 ImplPrimitrive3DIDBlock(PolygonHairlinePrimitive3D, PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D) 73 74 } // end of namespace primitive3d 75 } // end of namespace drawinglayer 76 77 ////////////////////////////////////////////////////////////////////////////// 78 79 namespace drawinglayer 80 { 81 namespace primitive3d 82 { 83 Primitive3DSequence PolygonStrokePrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const 84 { 85 Primitive3DSequence aRetval; 86 87 if(getB3DPolygon().count()) 88 { 89 basegfx::B3DPolyPolygon aHairLinePolyPolygon; 90 91 if(0.0 == getStrokeAttribute().getFullDotDashLen()) 92 { 93 aHairLinePolyPolygon = basegfx::B3DPolyPolygon(getB3DPolygon()); 94 } 95 else 96 { 97 // apply LineStyle 98 basegfx::tools::applyLineDashing(getB3DPolygon(), getStrokeAttribute().getDotDashArray(), &aHairLinePolyPolygon, 0, getStrokeAttribute().getFullDotDashLen()); 99 } 100 101 // prepare result 102 aRetval.realloc(aHairLinePolyPolygon.count()); 103 104 if(getLineAttribute().getWidth()) 105 { 106 // create fat line data 107 const double fRadius(getLineAttribute().getWidth() / 2.0); 108 const basegfx::B2DLineJoin aLineJoin(getLineAttribute().getLineJoin()); 109 110 for(sal_uInt32 a(0L); a < aHairLinePolyPolygon.count(); a++) 111 { 112 // create tube primitives 113 const Primitive3DReference xRef(new PolygonTubePrimitive3D(aHairLinePolyPolygon.getB3DPolygon(a), getLineAttribute().getColor(), fRadius, aLineJoin)); 114 aRetval[a] = xRef; 115 } 116 } 117 else 118 { 119 // create hair line data for all sub polygons 120 for(sal_uInt32 a(0L); a < aHairLinePolyPolygon.count(); a++) 121 { 122 const basegfx::B3DPolygon aCandidate = aHairLinePolyPolygon.getB3DPolygon(a); 123 const Primitive3DReference xRef(new PolygonHairlinePrimitive3D(aCandidate, getLineAttribute().getColor())); 124 aRetval[a] = xRef; 125 } 126 } 127 } 128 129 return aRetval; 130 } 131 132 PolygonStrokePrimitive3D::PolygonStrokePrimitive3D( 133 const basegfx::B3DPolygon& rPolygon, 134 const attribute::LineAttribute& rLineAttribute, 135 const attribute::StrokeAttribute& rStrokeAttribute) 136 : BufferedDecompositionPrimitive3D(), 137 maPolygon(rPolygon), 138 maLineAttribute(rLineAttribute), 139 maStrokeAttribute(rStrokeAttribute) 140 { 141 } 142 143 PolygonStrokePrimitive3D::PolygonStrokePrimitive3D( 144 const basegfx::B3DPolygon& rPolygon, 145 const attribute::LineAttribute& rLineAttribute) 146 : BufferedDecompositionPrimitive3D(), 147 maPolygon(rPolygon), 148 maLineAttribute(rLineAttribute), 149 maStrokeAttribute() 150 { 151 } 152 153 bool PolygonStrokePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const 154 { 155 if(BufferedDecompositionPrimitive3D::operator==(rPrimitive)) 156 { 157 const PolygonStrokePrimitive3D& rCompare = (PolygonStrokePrimitive3D&)rPrimitive; 158 159 return (getB3DPolygon() == rCompare.getB3DPolygon() 160 && getLineAttribute() == rCompare.getLineAttribute() 161 && getStrokeAttribute() == rCompare.getStrokeAttribute()); 162 } 163 164 return false; 165 } 166 167 // provide unique ID 168 ImplPrimitrive3DIDBlock(PolygonStrokePrimitive3D, PRIMITIVE3D_ID_POLYGONSTROKEPRIMITIVE3D) 169 170 } // end of namespace primitive3d 171 } // end of namespace drawinglayer 172 173 ////////////////////////////////////////////////////////////////////////////// 174 // eof 175