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/globl3d.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 
70 {
71 }
72 
73 void E3dSphereObj::SetDefaultAttributes(const E3dDefaultAttributes& rDefault)
74 {
75  // Set defaults
76  aCenter = rDefault.GetDefaultSphereCenter();
77  aSize = rDefault.GetDefaultSphereSize();
78 }
79 
81 {
82  return E3D_SPHEREOBJ_ID;
83 }
84 
85 // Convert the object into a group object consisting of n polygons
86 
87 SdrObjectUniquePtr E3dSphereObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
88 {
89  return nullptr;
90 }
91 
93 {
94  return CloneHelper< E3dSphereObj >(rTargetModel);
95 }
96 
98 {
99  if( this == &rObj )
100  return *this;
102 
103  aCenter = rObj.aCenter;
104  aSize = rObj.aSize;
105 
106  return *this;
107 }
108 
109 // Set local parameters with geometry re-creating
110 
112 {
113  if(aCenter != rNew)
114  {
115  aCenter = rNew;
116  ActionChanged();
117  }
118 }
119 
121 {
122  if(aSize != rNew)
123  {
124  aSize = rNew;
125  ActionChanged();
126  }
127 }
128 
129 // Get the name of the object (singular)
130 
132 {
133  OUStringBuffer sName(SvxResId(STR_ObjNameSingulSphere3d));
134 
135  OUString aName(GetName());
136  if (!aName.isEmpty())
137  {
138  sName.append(' ');
139  sName.append('\'');
140  sName.append(aName);
141  sName.append('\'');
142  }
143  return sName.makeStringAndClear();
144 }
145 
146 // Get the name of the object (plural)
147 
149 {
150  return SvxResId(STR_ObjNamePluralSphere3d);
151 }
152 
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: sphere3d.cxx:35
E3dSphereObj & operator=(const E3dSphereObj &rObj)
Definition: sphere3d.cxx:97
virtual sal_uInt16 GetObjIdentifier() const override
Definition: sphere3d.cxx:80
virtual OUString TakeObjNamePlural() const override
Definition: sphere3d.cxx:148
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
void SetDefaultAttributes(const E3dDefaultAttributes &rDefault)
Definition: sphere3d.cxx:73
void SetCenter(const basegfx::B3DPoint &rNew)
Definition: sphere3d.cxx:111
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:120
E3dCompoundObject & operator=(const E3dCompoundObject &rObj)
Definition: obj3d.cxx:598
void ActionChanged() const
Definition: svdobj.cxx:257
virtual ~E3dSphereObj() override
Definition: sphere3d.cxx:69
virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override
Definition: sphere3d.cxx:87
virtual OUString TakeObjNameSingul() const override
Definition: sphere3d.cxx:131
OUString GetName() const
Definition: svdobj.cxx:698
basegfx::B3DVector aSize
Definition: sphere3d.hxx:39
OUString aName
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:114
const sal_uInt16 E3D_SPHEREOBJ_ID
Definition: globl3d.hxx:28
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: sphere3d.cxx:40
virtual E3dSphereObj * CloneSdrObject(SdrModel &rTargetModel) const override
Definition: sphere3d.cxx:92