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/svdpage.hxx>
26 #include <svx/globl3d.hxx>
27 #include <svx/sphere3d.hxx>
28 
29 #include <svx/svxids.hrc>
30 #include <svx/svx3ditems.hxx>
36 
37 // DrawContact section
38 std::unique_ptr<sdr::contact::ViewContact> E3dSphereObj::CreateObjectSpecificViewContact()
39 {
40  return std::make_unique<sdr::contact::ViewContactOfE3dSphere>(*this);
41 }
42 
43 std::unique_ptr<sdr::properties::BaseProperties> E3dSphereObj::CreateObjectSpecificProperties()
44 {
45  return std::make_unique<sdr::properties::E3dSphereProperties>(*this);
46 }
47 
48 // Build Sphere from polygon facets in latitude and longitude
50  SdrModel& rSdrModel,
51  const E3dDefaultAttributes& rDefault,
52  const basegfx::B3DPoint& rCenter,
53  const basegfx::B3DVector& r3DSize)
54 : E3dCompoundObject(rSdrModel)
55 {
56  // Set defaults
57  SetDefaultAttributes(rDefault);
58 
59  aCenter = rCenter;
60  aSize = r3DSize;
61 }
62 
64 : E3dCompoundObject(rSdrModel)
65 {
66  // Set defaults
67  const E3dDefaultAttributes aDefault;
68 
69  SetDefaultAttributes(aDefault);
70 }
71 
73 {
74 }
75 
77 {
78  // Set defaults
79  aCenter = rDefault.GetDefaultSphereCenter();
80  aSize = rDefault.GetDefaultSphereSize();
81 }
82 
84 {
85  return E3D_SPHEREOBJ_ID;
86 }
87 
88 // Convert the object into a group object consisting of n polygons
89 
90 SdrObjectUniquePtr E3dSphereObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
91 {
92  return nullptr;
93 }
94 
96 {
97  return CloneHelper< E3dSphereObj >(rTargetModel);
98 }
99 
101 {
102  if( this == &rObj )
103  return *this;
105 
106  aCenter = rObj.aCenter;
107  aSize = rObj.aSize;
108 
109  return *this;
110 }
111 
112 // Set local parameters with geometry re-creating
113 
115 {
116  if(aCenter != rNew)
117  {
118  aCenter = rNew;
119  ActionChanged();
120  }
121 }
122 
124 {
125  if(aSize != rNew)
126  {
127  aSize = rNew;
128  ActionChanged();
129  }
130 }
131 
132 // Get the name of the object (singular)
133 
135 {
136  OUStringBuffer sName(SvxResId(STR_ObjNameSingulSphere3d));
137 
138  OUString aName(GetName());
139  if (!aName.isEmpty())
140  {
141  sName.append(' ');
142  sName.append('\'');
143  sName.append(aName);
144  sName.append('\'');
145  }
146  return sName.makeStringAndClear();
147 }
148 
149 // Get the name of the object (plural)
150 
152 {
153  return SvxResId(STR_ObjNamePluralSphere3d);
154 }
155 
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: sphere3d.cxx:38
E3dSphereObj & operator=(const E3dSphereObj &rObj)
Definition: sphere3d.cxx:100
virtual sal_uInt16 GetObjIdentifier() const override
Definition: sphere3d.cxx:83
const basegfx::B3DPoint & GetDefaultSphereCenter() const
Definition: deflt3d.hxx:72
virtual OUString TakeObjNamePlural() const override
Definition: sphere3d.cxx:151
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
void SetDefaultAttributes(const E3dDefaultAttributes &rDefault)
Definition: sphere3d.cxx:76
void SetCenter(const basegfx::B3DPoint &rNew)
Definition: sphere3d.cxx:114
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:49
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:123
E3dCompoundObject & operator=(const E3dCompoundObject &rObj)
Definition: obj3d.cxx:631
void ActionChanged() const
Definition: svdobj.cxx:283
virtual ~E3dSphereObj() override
Definition: sphere3d.cxx:72
virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override
Definition: sphere3d.cxx:90
virtual OUString TakeObjNameSingul() const override
Definition: sphere3d.cxx:134
OUString GetName() const
Definition: svdobj.cxx:725
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:43
virtual E3dSphereObj * CloneSdrObject(SdrModel &rTargetModel) const override
Definition: sphere3d.cxx:95