1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 31 #include "svx/svdstr.hrc" 32 #include "svx/svdglob.hxx" 33 #include <tools/poly.hxx> 34 #include <svx/svdpage.hxx> 35 #include "svx/globl3d.hxx" 36 #include <svx/lathe3d.hxx> 37 #include <svx/xpoly.hxx> 38 #include <svx/svxids.hrc> 39 #include <svx/svdopath.hxx> 40 #include <svx/svdmodel.hxx> 41 #include <svx/svx3ditems.hxx> 42 #include <svx/sdr/properties/e3dlatheproperties.hxx> 43 #include <svx/sdr/contact/viewcontactofe3dlathe.hxx> 44 #include <basegfx/polygon/b2dpolypolygontools.hxx> 45 #include <basegfx/polygon/b2dpolygontools.hxx> 46 #include <basegfx/matrix/b2dhommatrix.hxx> 47 48 ////////////////////////////////////////////////////////////////////////////// 49 // #110094# DrawContact section 50 51 sdr::contact::ViewContact* E3dLatheObj::CreateObjectSpecificViewContact() 52 { 53 return new sdr::contact::ViewContactOfE3dLathe(*this); 54 } 55 56 ////////////////////////////////////////////////////////////////////////////// 57 58 sdr::properties::BaseProperties* E3dLatheObj::CreateObjectSpecificProperties() 59 { 60 return new sdr::properties::E3dLatheProperties(*this); 61 } 62 63 ////////////////////////////////////////////////////////////////////////////// 64 65 TYPEINIT1(E3dLatheObj, E3dCompoundObject); 66 67 /************************************************************************* 68 |* 69 |* Konstruktor aus 3D-Polygon, Scale gibt den Umrechnungsfaktor fuer 70 |* die Koordinaten an 71 |* 72 \************************************************************************/ 73 74 E3dLatheObj::E3dLatheObj(E3dDefaultAttributes& rDefault, const basegfx::B2DPolyPolygon rPoly2D) 75 : E3dCompoundObject(rDefault), 76 maPolyPoly2D(rPoly2D) 77 { 78 // since the old class PolyPolygon3D did mirror the given PolyPolygons in Y, do the same here 79 basegfx::B2DHomMatrix aMirrorY; 80 aMirrorY.scale(1.0, -1.0); 81 maPolyPoly2D.transform(aMirrorY); 82 83 // Defaults setzen 84 SetDefaultAttributes(rDefault); 85 86 // Ueberfluessige Punkte entfernen, insbesondere doppelte 87 // Start- und Endpunkte verhindern 88 maPolyPoly2D.removeDoublePoints(); 89 90 if(maPolyPoly2D.count()) 91 { 92 const basegfx::B2DPolygon rPoly(maPolyPoly2D.getB2DPolygon(0L)); 93 sal_uInt32 nSegCnt(rPoly.count()); 94 95 if(nSegCnt && !rPoly.isClosed()) 96 { 97 nSegCnt -= 1; 98 } 99 100 GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nSegCnt)); 101 } 102 } 103 104 /************************************************************************* 105 |* 106 |* Leer-Konstruktor 107 |* 108 \************************************************************************/ 109 110 E3dLatheObj::E3dLatheObj() 111 : E3dCompoundObject() 112 { 113 // Defaults setzen 114 E3dDefaultAttributes aDefault; 115 SetDefaultAttributes(aDefault); 116 } 117 118 void E3dLatheObj::SetDefaultAttributes(E3dDefaultAttributes& rDefault) 119 { 120 GetProperties().SetObjectItemDirect(Svx3DSmoothNormalsItem(rDefault.GetDefaultLatheSmoothed())); 121 GetProperties().SetObjectItemDirect(Svx3DSmoothLidsItem(rDefault.GetDefaultLatheSmoothFrontBack())); 122 GetProperties().SetObjectItemDirect(Svx3DCharacterModeItem(rDefault.GetDefaultLatheCharacterMode())); 123 GetProperties().SetObjectItemDirect(Svx3DCloseFrontItem(rDefault.GetDefaultLatheCloseFront())); 124 GetProperties().SetObjectItemDirect(Svx3DCloseBackItem(rDefault.GetDefaultLatheCloseBack())); 125 } 126 127 /************************************************************************* 128 |* 129 |* Identifier zurueckgeben 130 |* 131 \************************************************************************/ 132 133 sal_uInt16 E3dLatheObj::GetObjIdentifier() const 134 { 135 return E3D_LATHEOBJ_ID; 136 } 137 138 /************************************************************************* 139 |* 140 |* Zuweisungsoperator 141 |* 142 \************************************************************************/ 143 144 void E3dLatheObj::operator=(const SdrObject& rObj) 145 { 146 // erstmal alle Childs kopieren 147 E3dCompoundObject::operator=(rObj); 148 149 // weitere Parameter kopieren 150 const E3dLatheObj& r3DObj = (const E3dLatheObj&)rObj; 151 152 maPolyPoly2D = r3DObj.maPolyPoly2D; 153 } 154 155 /************************************************************************* 156 |* 157 |* Wandle das Objekt in ein Gruppenobjekt bestehend aus n Polygonen 158 |* 159 \************************************************************************/ 160 161 SdrObject *E3dLatheObj::DoConvertToPolyObj(sal_Bool /*bBezier*/, bool /*bAddText*/) const 162 { 163 return NULL; 164 } 165 166 /************************************************************************* 167 |* 168 |* Neue Segmentierung (Beschreibung siehe Header-File) 169 |* 170 \************************************************************************/ 171 172 void E3dLatheObj::ReSegment(sal_uInt32 nHSegs, sal_uInt32 nVSegs) 173 { 174 if ((nHSegs != GetHorizontalSegments() || nVSegs != GetVerticalSegments()) && 175 (nHSegs != 0 || nVSegs != 0)) 176 { 177 GetProperties().SetObjectItemDirect(Svx3DHorizontalSegmentsItem(nHSegs)); 178 GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nVSegs)); 179 180 ActionChanged(); 181 } 182 } 183 184 /************************************************************************* 185 |* 186 |* Lokale Parameter setzen mit Geometrieneuerzeugung 187 |* 188 \************************************************************************/ 189 190 void E3dLatheObj::SetPolyPoly2D(const basegfx::B2DPolyPolygon& rNew) 191 { 192 if(maPolyPoly2D != rNew) 193 { 194 maPolyPoly2D = rNew; 195 maPolyPoly2D.removeDoublePoints(); 196 197 if(maPolyPoly2D.count()) 198 { 199 const basegfx::B2DPolygon rPoly(maPolyPoly2D.getB2DPolygon(0L)); 200 sal_uInt32 nSegCnt(rPoly.count()); 201 202 if(nSegCnt && !rPoly.isClosed()) 203 { 204 nSegCnt -= 1; 205 } 206 207 GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nSegCnt)); 208 } 209 210 ActionChanged(); 211 } 212 } 213 214 /************************************************************************* 215 |* 216 |* Get the name of the object (singular) 217 |* 218 \************************************************************************/ 219 220 void E3dLatheObj::TakeObjNameSingul(XubString& rName) const 221 { 222 rName=ImpGetResStr(STR_ObjNameSingulLathe3d); 223 224 String aName( GetName() ); 225 if(aName.Len()) 226 { 227 rName += sal_Unicode(' '); 228 rName += sal_Unicode('\''); 229 rName += aName; 230 rName += sal_Unicode('\''); 231 } 232 } 233 234 /************************************************************************* 235 |* 236 |* Get the name of the object (plural) 237 |* 238 \************************************************************************/ 239 240 void E3dLatheObj::TakeObjNamePlural(XubString& rName) const 241 { 242 rName=ImpGetResStr(STR_ObjNamePluralLathe3d); 243 } 244 245 /************************************************************************* 246 |* 247 |* Aufbrechen 248 |* 249 \************************************************************************/ 250 251 sal_Bool E3dLatheObj::IsBreakObjPossible() 252 { 253 return sal_True; 254 } 255 256 SdrAttrObj* E3dLatheObj::GetBreakObj() 257 { 258 // create PathObj 259 basegfx::B3DPolyPolygon aLathePoly3D(basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(maPolyPoly2D)); 260 basegfx::B2DPolyPolygon aTransPoly(TransformToScreenCoor(aLathePoly3D)); 261 SdrPathObj* pPathObj = new SdrPathObj(OBJ_PLIN, aTransPoly); 262 263 if(pPathObj) 264 { 265 // Attribute setzen 266 SfxItemSet aSet(GetObjectItemSet()); 267 268 // Linien aktivieren, um Objekt garantiert sichtbar zu machen 269 aSet.Put(XLineStyleItem(XLINE_SOLID)); 270 271 pPathObj->SetMergedItemSet(aSet); 272 } 273 274 return pPathObj; 275 } 276 277 // eof 278