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