xref: /aoo41x/main/svx/source/engine3d/sphere3d.cxx (revision f6e50924)
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 <svx/svdmodel.hxx>
30cdf0e10cSrcweir #include <svx/svdpage.hxx>
31cdf0e10cSrcweir #include "svx/globl3d.hxx"
32cdf0e10cSrcweir #include <svx/sphere3d.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <svx/svxids.hrc>
35cdf0e10cSrcweir #include <svx/svx3ditems.hxx>
36cdf0e10cSrcweir #include <svx/sdr/properties/e3dsphereproperties.hxx>
37cdf0e10cSrcweir #include <basegfx/vector/b3dvector.hxx>
38cdf0e10cSrcweir #include <basegfx/point/b3dpoint.hxx>
39cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofe3dsphere.hxx>
40cdf0e10cSrcweir #include <basegfx/polygon/b3dpolygon.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
43cdf0e10cSrcweir // #110094# DrawContact section
44cdf0e10cSrcweir 
CreateObjectSpecificViewContact()45cdf0e10cSrcweir sdr::contact::ViewContact* E3dSphereObj::CreateObjectSpecificViewContact()
46cdf0e10cSrcweir {
47cdf0e10cSrcweir 	return new sdr::contact::ViewContactOfE3dSphere(*this);
48cdf0e10cSrcweir }
49cdf0e10cSrcweir 
50cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
51cdf0e10cSrcweir 
CreateObjectSpecificProperties()52cdf0e10cSrcweir sdr::properties::BaseProperties* E3dSphereObj::CreateObjectSpecificProperties()
53cdf0e10cSrcweir {
54cdf0e10cSrcweir 	return new sdr::properties::E3dSphereProperties(*this);
55cdf0e10cSrcweir }
56cdf0e10cSrcweir 
57cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
58cdf0e10cSrcweir 
59cdf0e10cSrcweir TYPEINIT1(E3dSphereObj, E3dCompoundObject);
60cdf0e10cSrcweir 
61cdf0e10cSrcweir /*************************************************************************
62cdf0e10cSrcweir |*
63cdf0e10cSrcweir |* Kugel aus Polygonfacetten nach Laengen und Breitengrad aufbauen
64cdf0e10cSrcweir |*
65cdf0e10cSrcweir \************************************************************************/
66cdf0e10cSrcweir 
E3dSphereObj(E3dDefaultAttributes & rDefault,const basegfx::B3DPoint & rCenter,const basegfx::B3DVector & r3DSize)67cdf0e10cSrcweir E3dSphereObj::E3dSphereObj(E3dDefaultAttributes& rDefault, const basegfx::B3DPoint& rCenter, const basegfx::B3DVector& r3DSize)
68cdf0e10cSrcweir :	E3dCompoundObject(rDefault)
69cdf0e10cSrcweir {
70cdf0e10cSrcweir 	// Defaults setzen
71cdf0e10cSrcweir 	SetDefaultAttributes(rDefault);
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	// Uebergebene drueberbuegeln
74cdf0e10cSrcweir 	aCenter = rCenter;
75cdf0e10cSrcweir 	aSize = r3DSize;
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
E3dSphereObj()78cdf0e10cSrcweir E3dSphereObj::E3dSphereObj()
79cdf0e10cSrcweir :	E3dCompoundObject()
80cdf0e10cSrcweir {
81cdf0e10cSrcweir 	// Defaults setzen
82cdf0e10cSrcweir 	E3dDefaultAttributes aDefault;
83cdf0e10cSrcweir 	SetDefaultAttributes(aDefault);
84cdf0e10cSrcweir }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir /*************************************************************************
87cdf0e10cSrcweir |*
88cdf0e10cSrcweir |* Kugel erzeugen ohne die Polygone darin zu erzeugen
89cdf0e10cSrcweir |*
90cdf0e10cSrcweir \************************************************************************/
91cdf0e10cSrcweir 
92cdf0e10cSrcweir // FG: Dieser Aufruf erfolgt von der 3D-Object Factory (objfac3d.cxx) und zwar ausschliesslich beim
93cdf0e10cSrcweir //     laden von Dokumenten. Hier braucht man keinen CreateSphere-Aufruf, denn die wirkliche
94cdf0e10cSrcweir //     Anzahl Segmente ist ja noch nicht bekannt. Dies war bis zum 10.2.97 ein (kleines)
95cdf0e10cSrcweir //     Speicherleck.
E3dSphereObj(int)96cdf0e10cSrcweir E3dSphereObj::E3dSphereObj(int /*dummy*/) // den Parameter braucht es um unterscheiden zu koennen, welcher
97cdf0e10cSrcweir {                                     // der beiden Konstruktoren gemeint ist. Der obige halt per Default
98cdf0e10cSrcweir 	// Defaults setzen
99cdf0e10cSrcweir 	E3dDefaultAttributes aDefault;
100cdf0e10cSrcweir 	SetDefaultAttributes(aDefault);
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
SetDefaultAttributes(E3dDefaultAttributes & rDefault)103cdf0e10cSrcweir void E3dSphereObj::SetDefaultAttributes(E3dDefaultAttributes& rDefault)
104cdf0e10cSrcweir {
105cdf0e10cSrcweir 	// Defaults setzen
106cdf0e10cSrcweir 	aCenter = rDefault.GetDefaultSphereCenter();
107cdf0e10cSrcweir 	aSize = rDefault.GetDefaultSphereSize();
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir /*************************************************************************
111cdf0e10cSrcweir |*
112cdf0e10cSrcweir |* Identifier zurueckgeben
113cdf0e10cSrcweir |*
114cdf0e10cSrcweir \************************************************************************/
115cdf0e10cSrcweir 
GetObjIdentifier() const116cdf0e10cSrcweir sal_uInt16 E3dSphereObj::GetObjIdentifier() const
117cdf0e10cSrcweir {
118cdf0e10cSrcweir 	return E3D_SPHEREOBJ_ID;
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir /*************************************************************************
122cdf0e10cSrcweir |*
123cdf0e10cSrcweir |* Wandle das Objekt in ein Gruppenobjekt bestehend aus n Polygonen
124cdf0e10cSrcweir |*
125cdf0e10cSrcweir \************************************************************************/
126cdf0e10cSrcweir 
DoConvertToPolyObj(sal_Bool,bool) const127a5258243SPedro Giffuni SdrObject *E3dSphereObj::DoConvertToPolyObj(sal_Bool /*bBezier*/, bool /*bAddText*/) const
128cdf0e10cSrcweir {
129cdf0e10cSrcweir 	return NULL;
130cdf0e10cSrcweir }
131cdf0e10cSrcweir 
132cdf0e10cSrcweir /*************************************************************************
133cdf0e10cSrcweir |*
134cdf0e10cSrcweir |* Leer-Konstruktor
135cdf0e10cSrcweir |*
136cdf0e10cSrcweir \************************************************************************/
137cdf0e10cSrcweir 
ReSegment(sal_uInt32 nHSegs,sal_uInt32 nVSegs)138cdf0e10cSrcweir void E3dSphereObj::ReSegment(sal_uInt32 nHSegs, sal_uInt32 nVSegs)
139cdf0e10cSrcweir {
140cdf0e10cSrcweir 	if((nHSegs != GetHorizontalSegments() || nVSegs != GetVerticalSegments()) && (nHSegs != 0 || nVSegs != 0))
141cdf0e10cSrcweir 	{
142cdf0e10cSrcweir 		GetProperties().SetObjectItemDirect(Svx3DHorizontalSegmentsItem(nHSegs));
143cdf0e10cSrcweir 		GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nVSegs));
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 		ActionChanged();
146cdf0e10cSrcweir 	}
147cdf0e10cSrcweir }
148cdf0e10cSrcweir 
149cdf0e10cSrcweir /*************************************************************************
150cdf0e10cSrcweir |*
151cdf0e10cSrcweir |* Zuweisungsoperator
152cdf0e10cSrcweir |*
153cdf0e10cSrcweir \************************************************************************/
154cdf0e10cSrcweir 
operator =(const SdrObject & rObj)155cdf0e10cSrcweir void E3dSphereObj::operator=(const SdrObject& rObj)
156cdf0e10cSrcweir {
157cdf0e10cSrcweir 	// erstmal alle Childs kopieren
158cdf0e10cSrcweir 	E3dCompoundObject::operator=(rObj);
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 	// weitere Parameter kopieren
161cdf0e10cSrcweir 	const E3dSphereObj& r3DObj = (const E3dSphereObj&) rObj;
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	aCenter       = r3DObj.aCenter;
164cdf0e10cSrcweir 	aSize         = r3DObj.aSize;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir 
167cdf0e10cSrcweir /*************************************************************************
168cdf0e10cSrcweir |*
169cdf0e10cSrcweir |* Lokale Parameter setzen mit Geometrieneuerzeugung
170cdf0e10cSrcweir |*
171cdf0e10cSrcweir \************************************************************************/
172cdf0e10cSrcweir 
SetCenter(const basegfx::B3DPoint & rNew)173cdf0e10cSrcweir void E3dSphereObj::SetCenter(const basegfx::B3DPoint& rNew)
174cdf0e10cSrcweir {
175cdf0e10cSrcweir 	if(aCenter != rNew)
176cdf0e10cSrcweir 	{
177cdf0e10cSrcweir 		aCenter = rNew;
178cdf0e10cSrcweir 		ActionChanged();
179cdf0e10cSrcweir 	}
180cdf0e10cSrcweir }
181cdf0e10cSrcweir 
SetSize(const basegfx::B3DVector & rNew)182cdf0e10cSrcweir void E3dSphereObj::SetSize(const basegfx::B3DVector& rNew)
183cdf0e10cSrcweir {
184cdf0e10cSrcweir 	if(aSize != rNew)
185cdf0e10cSrcweir 	{
186cdf0e10cSrcweir 		aSize = rNew;
187cdf0e10cSrcweir 		ActionChanged();
188cdf0e10cSrcweir 	}
189cdf0e10cSrcweir }
190cdf0e10cSrcweir 
191cdf0e10cSrcweir /*************************************************************************
192cdf0e10cSrcweir |*
193cdf0e10cSrcweir |* Get the name of the object (singular)
194cdf0e10cSrcweir |*
195cdf0e10cSrcweir \************************************************************************/
196cdf0e10cSrcweir 
TakeObjNameSingul(XubString & rName) const197cdf0e10cSrcweir void E3dSphereObj::TakeObjNameSingul(XubString& rName) const
198cdf0e10cSrcweir {
199cdf0e10cSrcweir 	rName=ImpGetResStr(STR_ObjNameSingulSphere3d);
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 	String aName( GetName() );
202cdf0e10cSrcweir 	if(aName.Len())
203cdf0e10cSrcweir 	{
204cdf0e10cSrcweir 		rName += sal_Unicode(' ');
205cdf0e10cSrcweir 		rName += sal_Unicode('\'');
206cdf0e10cSrcweir 		rName += aName;
207cdf0e10cSrcweir 		rName += sal_Unicode('\'');
208cdf0e10cSrcweir 	}
209cdf0e10cSrcweir }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir /*************************************************************************
212cdf0e10cSrcweir |*
213cdf0e10cSrcweir |* Get the name of the object (plural)
214cdf0e10cSrcweir |*
215cdf0e10cSrcweir \************************************************************************/
216cdf0e10cSrcweir 
TakeObjNamePlural(XubString & rName) const217cdf0e10cSrcweir void E3dSphereObj::TakeObjNamePlural(XubString& rName) const
218cdf0e10cSrcweir {
219cdf0e10cSrcweir 	rName=ImpGetResStr(STR_ObjNamePluralSphere3d);
220cdf0e10cSrcweir }
221cdf0e10cSrcweir 
222cdf0e10cSrcweir // eof
223