Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / svx / source / engine3d / sphere3d.cxx
blob4b1121453921a006063e119d2e98bd035a69afb1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <svx/strings.hrc>
22 #include <svx/deflt3d.hxx>
23 #include <svx/dialmgr.hxx>
24 #include <svx/svdmodel.hxx>
25 #include <svx/svdobjkind.hxx>
26 #include <svx/sphere3d.hxx>
28 #include <sdr/properties/e3dsphereproperties.hxx>
29 #include <basegfx/vector/b3dvector.hxx>
30 #include <basegfx/point/b3dpoint.hxx>
31 #include <sdr/contact/viewcontactofe3dsphere.hxx>
33 // DrawContact section
34 std::unique_ptr<sdr::contact::ViewContact> E3dSphereObj::CreateObjectSpecificViewContact()
36 return std::make_unique<sdr::contact::ViewContactOfE3dSphere>(*this);
39 std::unique_ptr<sdr::properties::BaseProperties> E3dSphereObj::CreateObjectSpecificProperties()
41 return std::make_unique<sdr::properties::E3dSphereProperties>(*this);
44 // Build Sphere from polygon facets in latitude and longitude
45 E3dSphereObj::E3dSphereObj(
46 SdrModel& rSdrModel,
47 const E3dDefaultAttributes& rDefault,
48 const basegfx::B3DPoint& rCenter,
49 const basegfx::B3DVector& r3DSize)
50 : E3dCompoundObject(rSdrModel)
52 // Set defaults
53 SetDefaultAttributes(rDefault);
55 aCenter = rCenter;
56 aSize = r3DSize;
59 E3dSphereObj::E3dSphereObj(SdrModel& rSdrModel)
60 : E3dCompoundObject(rSdrModel)
62 // Set defaults
63 const E3dDefaultAttributes aDefault;
65 SetDefaultAttributes(aDefault);
68 E3dSphereObj::E3dSphereObj(SdrModel& rSdrModel, E3dSphereObj const & rSource)
69 : E3dCompoundObject(rSdrModel, rSource)
71 // Set defaults
72 const E3dDefaultAttributes aDefault;
73 SetDefaultAttributes(aDefault);
75 aCenter = rSource.aCenter;
76 aSize = rSource.aSize;
79 E3dSphereObj::~E3dSphereObj()
83 void E3dSphereObj::SetDefaultAttributes(const E3dDefaultAttributes& rDefault)
85 // Set defaults
86 aCenter = rDefault.GetDefaultSphereCenter();
87 aSize = rDefault.GetDefaultSphereSize();
90 SdrObjKind E3dSphereObj::GetObjIdentifier() const
92 return SdrObjKind::E3D_Sphere;
95 // Convert the object into a group object consisting of n polygons
97 rtl::Reference<SdrObject> E3dSphereObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
99 return nullptr;
102 rtl::Reference<SdrObject> E3dSphereObj::CloneSdrObject(SdrModel& rTargetModel) const
104 return new E3dSphereObj(rTargetModel, *this);
107 // Set local parameters with geometry re-creating
109 void E3dSphereObj::SetCenter(const basegfx::B3DPoint& rNew)
111 if(aCenter != rNew)
113 aCenter = rNew;
114 ActionChanged();
118 void E3dSphereObj::SetSize(const basegfx::B3DVector& rNew)
120 if(aSize != rNew)
122 aSize = rNew;
123 ActionChanged();
127 // Get the name of the object (singular)
129 OUString E3dSphereObj::TakeObjNameSingul() const
131 OUString sName(SvxResId(STR_ObjNameSingulSphere3d));
133 OUString aName(GetName());
134 if (!aName.isEmpty())
136 sName += " '" + aName + "'";
138 return sName;
141 // Get the name of the object (plural)
143 OUString E3dSphereObj::TakeObjNamePlural() const
145 return SvxResId(STR_ObjNamePluralSphere3d);
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */