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