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 
33 // DrawContact section
34 std::unique_ptr<sdr::contact::ViewContact> E3dSphereObj::CreateObjectSpecificViewContact()
35 {
36  return std::make_unique<sdr::contact::ViewContactOfE3dSphere>(*this);
37 }
38 
39 std::unique_ptr<sdr::properties::BaseProperties> E3dSphereObj::CreateObjectSpecificProperties()
40 {
41  return std::make_unique<sdr::properties::E3dSphereProperties>(*this);
42 }
43 
44 // Build Sphere from polygon facets in latitude and longitude
46  SdrModel& rSdrModel,
47  const E3dDefaultAttributes& rDefault,
48  const basegfx::B3DPoint& rCenter,
49  const basegfx::B3DVector& r3DSize)
50 : E3dCompoundObject(rSdrModel)
51 {
52  // Set defaults
53  SetDefaultAttributes(rDefault);
54 
55  aCenter = rCenter;
56  aSize = r3DSize;
57 }
58 
60 : E3dCompoundObject(rSdrModel)
61 {
62  // Set defaults
63  const E3dDefaultAttributes aDefault;
64 
65  SetDefaultAttributes(aDefault);
66 }
67 
69 {
70 }
71 
73 {
74  // Set defaults
75  aCenter = rDefault.GetDefaultSphereCenter();
76  aSize = rDefault.GetDefaultSphereSize();
77 }
78 
80 {
81  return E3D_SPHEREOBJ_ID;
82 }
83 
84 // Convert the object into a group object consisting of n polygons
85 
86 SdrObjectUniquePtr E3dSphereObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
87 {
88  return nullptr;
89 }
90 
92 {
93  return CloneHelper< E3dSphereObj >(rTargetModel);
94 }
95 
97 {
98  if( this == &rObj )
99  return *this;
101 
102  aCenter = rObj.aCenter;
103  aSize = rObj.aSize;
104 
105  return *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  OUStringBuffer sName(SvxResId(STR_ObjNameSingulSphere3d));
133 
134  OUString aName(GetName());
135  if (!aName.isEmpty())
136  {
137  sName.append(' ');
138  sName.append('\'');
139  sName.append(aName);
140  sName.append('\'');
141  }
142  return sName.makeStringAndClear();
143 }
144 
145 // Get the name of the object (plural)
146 
148 {
149  return SvxResId(STR_ObjNamePluralSphere3d);
150 }
151 
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: sphere3d.cxx:34
E3dSphereObj & operator=(const E3dSphereObj &rObj)
Definition: sphere3d.cxx:96
virtual sal_uInt16 GetObjIdentifier() const override
Definition: sphere3d.cxx:79
const basegfx::B3DPoint & GetDefaultSphereCenter() const
Definition: deflt3d.hxx:72
virtual OUString TakeObjNamePlural() const override
Definition: sphere3d.cxx:147
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
void SetDefaultAttributes(const E3dDefaultAttributes &rDefault)
Definition: sphere3d.cxx:72
void SetCenter(const basegfx::B3DPoint &rNew)
Definition: sphere3d.cxx:110
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:45
basegfx::B3DPoint aCenter
Definition: sphere3d.hxx:38
OUString sName
const basegfx::B3DVector & GetDefaultSphereSize() const
Definition: deflt3d.hxx:73
void SetSize(const basegfx::B3DVector &rNew)
Definition: sphere3d.cxx:119
E3dCompoundObject & operator=(const E3dCompoundObject &rObj)
Definition: obj3d.cxx:597
void ActionChanged() const
Definition: svdobj.cxx:281
virtual ~E3dSphereObj() override
Definition: sphere3d.cxx:68
virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override
Definition: sphere3d.cxx:86
virtual OUString TakeObjNameSingul() const override
Definition: sphere3d.cxx:130
OUString GetName() const
Definition: svdobj.cxx:722
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:39
virtual E3dSphereObj * CloneSdrObject(SdrModel &rTargetModel) const override
Definition: sphere3d.cxx:91