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_svx.hxx" 26 27 #include "svx/svdstr.hrc" 28 #include "svx/svdglob.hxx" 29 #include <tools/poly.hxx> 30 #include <svx/svdpage.hxx> 31 #include "svx/globl3d.hxx" 32 #include <svx/lathe3d.hxx> 33 #include <svx/xpoly.hxx> 34 #include <svx/svxids.hrc> 35 #include <svx/svdopath.hxx> 36 #include <svx/svdmodel.hxx> 37 #include <svx/svx3ditems.hxx> 38 #include <svx/sdr/properties/e3dlatheproperties.hxx> 39 #include <svx/sdr/contact/viewcontactofe3dlathe.hxx> 40 #include <basegfx/polygon/b2dpolypolygontools.hxx> 41 #include <basegfx/polygon/b2dpolygontools.hxx> 42 #include <basegfx/matrix/b2dhommatrix.hxx> 43 44 ////////////////////////////////////////////////////////////////////////////// 45 // #110094# DrawContact section 46 47 sdr::contact::ViewContact* E3dLatheObj::CreateObjectSpecificViewContact() 48 { 49 return new sdr::contact::ViewContactOfE3dLathe(*this); 50 } 51 52 ////////////////////////////////////////////////////////////////////////////// 53 54 sdr::properties::BaseProperties* E3dLatheObj::CreateObjectSpecificProperties() 55 { 56 return new sdr::properties::E3dLatheProperties(*this); 57 } 58 59 ////////////////////////////////////////////////////////////////////////////// 60 61 TYPEINIT1(E3dLatheObj, E3dCompoundObject); 62 63 /************************************************************************* 64 |* 65 |* Konstruktor aus 3D-Polygon, Scale gibt den Umrechnungsfaktor fuer 66 |* die Koordinaten an 67 |* 68 \************************************************************************/ 69 70 E3dLatheObj::E3dLatheObj(E3dDefaultAttributes& rDefault, const basegfx::B2DPolyPolygon rPoly2D) 71 : E3dCompoundObject(rDefault), 72 maPolyPoly2D(rPoly2D) 73 { 74 // since the old class PolyPolygon3D did mirror the given PolyPolygons in Y, do the same here 75 basegfx::B2DHomMatrix aMirrorY; 76 aMirrorY.scale(1.0, -1.0); 77 maPolyPoly2D.transform(aMirrorY); 78 79 // Defaults setzen 80 SetDefaultAttributes(rDefault); 81 82 // Ueberfluessige Punkte entfernen, insbesondere doppelte 83 // Start- und Endpunkte verhindern 84 maPolyPoly2D.removeDoublePoints(); 85 86 if(maPolyPoly2D.count()) 87 { 88 const basegfx::B2DPolygon rPoly(maPolyPoly2D.getB2DPolygon(0L)); 89 sal_uInt32 nSegCnt(rPoly.count()); 90 91 if(nSegCnt && !rPoly.isClosed()) 92 { 93 nSegCnt -= 1; 94 } 95 96 GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nSegCnt)); 97 } 98 } 99 100 /************************************************************************* 101 |* 102 |* Leer-Konstruktor 103 |* 104 \************************************************************************/ 105 106 E3dLatheObj::E3dLatheObj() 107 : E3dCompoundObject() 108 { 109 // Defaults setzen 110 E3dDefaultAttributes aDefault; 111 SetDefaultAttributes(aDefault); 112 } 113 114 void E3dLatheObj::SetDefaultAttributes(E3dDefaultAttributes& rDefault) 115 { 116 GetProperties().SetObjectItemDirect(Svx3DSmoothNormalsItem(rDefault.GetDefaultLatheSmoothed())); 117 GetProperties().SetObjectItemDirect(Svx3DSmoothLidsItem(rDefault.GetDefaultLatheSmoothFrontBack())); 118 GetProperties().SetObjectItemDirect(Svx3DCharacterModeItem(rDefault.GetDefaultLatheCharacterMode())); 119 GetProperties().SetObjectItemDirect(Svx3DCloseFrontItem(rDefault.GetDefaultLatheCloseFront())); 120 GetProperties().SetObjectItemDirect(Svx3DCloseBackItem(rDefault.GetDefaultLatheCloseBack())); 121 } 122 123 /************************************************************************* 124 |* 125 |* Identifier zurueckgeben 126 |* 127 \************************************************************************/ 128 129 sal_uInt16 E3dLatheObj::GetObjIdentifier() const 130 { 131 return E3D_LATHEOBJ_ID; 132 } 133 134 /************************************************************************* 135 |* 136 |* Zuweisungsoperator 137 |* 138 \************************************************************************/ 139 140 void E3dLatheObj::operator=(const SdrObject& rObj) 141 { 142 // erstmal alle Childs kopieren 143 E3dCompoundObject::operator=(rObj); 144 145 // weitere Parameter kopieren 146 const E3dLatheObj& r3DObj = (const E3dLatheObj&)rObj; 147 148 maPolyPoly2D = r3DObj.maPolyPoly2D; 149 } 150 151 /************************************************************************* 152 |* 153 |* Wandle das Objekt in ein Gruppenobjekt bestehend aus n Polygonen 154 |* 155 \************************************************************************/ 156 157 SdrObject *E3dLatheObj::DoConvertToPolyObj(sal_Bool /*bBezier*/, bool /*bAddText*/) const 158 { 159 return NULL; 160 } 161 162 /************************************************************************* 163 |* 164 |* Neue Segmentierung (Beschreibung siehe Header-File) 165 |* 166 \************************************************************************/ 167 168 void E3dLatheObj::ReSegment(sal_uInt32 nHSegs, sal_uInt32 nVSegs) 169 { 170 if ((nHSegs != GetHorizontalSegments() || nVSegs != GetVerticalSegments()) && 171 (nHSegs != 0 || nVSegs != 0)) 172 { 173 GetProperties().SetObjectItemDirect(Svx3DHorizontalSegmentsItem(nHSegs)); 174 GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nVSegs)); 175 176 ActionChanged(); 177 } 178 } 179 180 /************************************************************************* 181 |* 182 |* Lokale Parameter setzen mit Geometrieneuerzeugung 183 |* 184 \************************************************************************/ 185 186 void E3dLatheObj::SetPolyPoly2D(const basegfx::B2DPolyPolygon& rNew) 187 { 188 if(maPolyPoly2D != rNew) 189 { 190 maPolyPoly2D = rNew; 191 maPolyPoly2D.removeDoublePoints(); 192 193 if(maPolyPoly2D.count()) 194 { 195 const basegfx::B2DPolygon rPoly(maPolyPoly2D.getB2DPolygon(0L)); 196 sal_uInt32 nSegCnt(rPoly.count()); 197 198 if(nSegCnt && !rPoly.isClosed()) 199 { 200 nSegCnt -= 1; 201 } 202 203 GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nSegCnt)); 204 } 205 206 ActionChanged(); 207 } 208 } 209 210 /************************************************************************* 211 |* 212 |* Get the name of the object (singular) 213 |* 214 \************************************************************************/ 215 216 void E3dLatheObj::TakeObjNameSingul(XubString& rName) const 217 { 218 rName=ImpGetResStr(STR_ObjNameSingulLathe3d); 219 220 String aName( GetName() ); 221 if(aName.Len()) 222 { 223 rName += sal_Unicode(' '); 224 rName += sal_Unicode('\''); 225 rName += aName; 226 rName += sal_Unicode('\''); 227 } 228 } 229 230 /************************************************************************* 231 |* 232 |* Get the name of the object (plural) 233 |* 234 \************************************************************************/ 235 236 void E3dLatheObj::TakeObjNamePlural(XubString& rName) const 237 { 238 rName=ImpGetResStr(STR_ObjNamePluralLathe3d); 239 } 240 241 /************************************************************************* 242 |* 243 |* Aufbrechen 244 |* 245 \************************************************************************/ 246 247 sal_Bool E3dLatheObj::IsBreakObjPossible() 248 { 249 return sal_True; 250 } 251 252 SdrAttrObj* E3dLatheObj::GetBreakObj() 253 { 254 // create PathObj 255 basegfx::B3DPolyPolygon aLathePoly3D(basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(maPolyPoly2D)); 256 basegfx::B2DPolyPolygon aTransPoly(TransformToScreenCoor(aLathePoly3D)); 257 SdrPathObj* pPathObj = new SdrPathObj(OBJ_PLIN, aTransPoly); 258 259 if(pPathObj) 260 { 261 // Attribute setzen 262 SfxItemSet aSet(GetObjectItemSet()); 263 264 // Linien aktivieren, um Objekt garantiert sichtbar zu machen 265 aSet.Put(XLineStyleItem(XLINE_SOLID)); 266 267 pPathObj->SetMergedItemSet(aSet); 268 } 269 270 return pPathObj; 271 } 272 273 // eof 274