LibreOffice Module svx (master)  1
sphere3d.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 
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>
27 
32 #include <rtl/ustrbuf.hxx>
33 
34 // DrawContact section
35 std::unique_ptr<sdr::contact::ViewContact> E3dSphereObj::CreateObjectSpecificViewContact()
36 {
37  return std::make_unique<sdr::contact::ViewContactOfE3dSphere>(*this);
38 }
39 
40 std::unique_ptr<sdr::properties::BaseProperties> E3dSphereObj::CreateObjectSpecificProperties()
41 {
42  return std::make_unique<sdr::properties::E3dSphereProperties>(*this);
43 }
44 
45 // Build Sphere from polygon facets in latitude and longitude
47  SdrModel& rSdrModel,
48  const E3dDefaultAttributes& rDefault,
49  const basegfx::B3DPoint& rCenter,
50  const basegfx::B3DVector& r3DSize)
51 : E3dCompoundObject(rSdrModel)
52 {
53  // Set defaults
54  SetDefaultAttributes(rDefault);
55 
56  aCenter = rCenter;
57  aSize = r3DSize;
58 }
59 
61 : E3dCompoundObject(rSdrModel)
62 {
63  // Set defaults
64  const E3dDefaultAttributes aDefault;
65 
66  SetDefaultAttributes(aDefault);
67 }
68 
69 E3dSphereObj::E3dSphereObj(SdrModel& rSdrModel, E3dSphereObj const & rSource)
70 : E3dCompoundObject(rSdrModel, rSource)
71 {
72  // Set defaults
73  const E3dDefaultAttributes aDefault;
74  SetDefaultAttributes(aDefault);
75 
76  aCenter = rSource.aCenter;
77  aSize = rSource.aSize;
78 }
79 
81 {
82 }
83 
84 void E3dSphereObj::SetDefaultAttributes(const E3dDefaultAttributes& rDefault)
85 {
86  // Set defaults
87  aCenter = rDefault.GetDefaultSphereCenter();
88  aSize = rDefault.GetDefaultSphereSize();
89 }
90 
92 {
93  return E3D_SPHEREOBJ_ID;
94 }
95 
96 // Convert the object into a group object consisting of n polygons
97 
98 SdrObjectUniquePtr E3dSphereObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
99 {
100  return nullptr;
101 }
102 
104 {
105  return new E3dSphereObj(rTargetModel, *this);
106 }
107 
108 // Set local parameters with geometry re-creating
109 
111 {
112  if(aCenter != rNew)
113  {
114  aCenter = rNew;
115  ActionChanged();
116  }
117 }
118 
120 {
121  if(aSize != rNew)
122  {
123  aSize = rNew;
124  ActionChanged();
125  }
126 }
127 
128 // Get the name of the object (singular)
129 
131 {
132  OUString sName(SvxResId(STR_ObjNameSingulSphere3d));
133 
134  OUString aName(GetName());
135  if (!aName.isEmpty())
136  {
137  sName += " '" + aName + "'";
138  }
139  return sName;
140 }
141 
142 // Get the name of the object (plural)
143 
145 {
146  return SvxResId(STR_ObjNamePluralSphere3d);
147 }
148 
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: sphere3d.cxx:35
virtual SdrObjKind GetObjIdentifier() const override
Definition: sphere3d.cxx:91
SdrObjKind
Definition: svdobjkind.hxx:24
virtual OUString TakeObjNamePlural() const override
Definition: sphere3d.cxx:144
void SetDefaultAttributes(const E3dDefaultAttributes &rDefault)
Definition: sphere3d.cxx:84
void SetCenter(const basegfx::B3DPoint &rNew)
Definition: sphere3d.cxx:110
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
SphereObject with diameter r3DSize.
Definition: sphere3d.hxx:35
E3dSphereObj(SdrModel &rSdrModel, const E3dDefaultAttributes &rDefault, const basegfx::B3DPoint &rCenter, const basegfx::B3DVector &r3DSize)
Definition: sphere3d.cxx:46
basegfx::B3DPoint aCenter
Definition: sphere3d.hxx:38
OUString sName
void SetSize(const basegfx::B3DVector &rNew)
Definition: sphere3d.cxx:119
void ActionChanged() const
Definition: svdobj.cxx:263
virtual ~E3dSphereObj() override
Definition: sphere3d.cxx:80
virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override
Definition: sphere3d.cxx:98
virtual OUString TakeObjNameSingul() const override
Definition: sphere3d.cxx:130
OUString GetName() const
Definition: svdobj.cxx:802
basegfx::B3DVector aSize
Definition: sphere3d.hxx:39
OUString aName
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:97
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: sphere3d.cxx:40
virtual E3dSphereObj * CloneSdrObject(SdrModel &rTargetModel) const override
Definition: sphere3d.cxx:103