/src/libreoffice/svx/source/engine3d/sphere3d.cxx
Line | Count | Source |
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 | | |
28 | | #include <sdr/properties/e3dsphereproperties.hxx> |
29 | | #include <basegfx/vector/b3dvector.hxx> |
30 | | #include <basegfx/point/b3dpoint.hxx> |
31 | | #include <sdr/contact/viewcontactofe3dsphere.hxx> |
32 | | |
33 | | // DrawContact section |
34 | | std::unique_ptr<sdr::contact::ViewContact> E3dSphereObj::CreateObjectSpecificViewContact() |
35 | 0 | { |
36 | 0 | return std::make_unique<sdr::contact::ViewContactOfE3dSphere>(*this); |
37 | 0 | } |
38 | | |
39 | | std::unique_ptr<sdr::properties::BaseProperties> E3dSphereObj::CreateObjectSpecificProperties() |
40 | 0 | { |
41 | 0 | return std::make_unique<sdr::properties::E3dSphereProperties>(*this); |
42 | 0 | } |
43 | | |
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 | 0 | : E3dCompoundObject(rSdrModel) |
51 | 0 | { |
52 | | // Set defaults |
53 | 0 | SetDefaultAttributes(rDefault); |
54 | |
|
55 | 0 | m_aCenter = rCenter; |
56 | 0 | m_aSize = r3DSize; |
57 | 0 | } |
58 | | |
59 | | E3dSphereObj::E3dSphereObj(SdrModel& rSdrModel) |
60 | 0 | : E3dCompoundObject(rSdrModel) |
61 | 0 | { |
62 | | // Set defaults |
63 | 0 | const E3dDefaultAttributes aDefault; |
64 | |
|
65 | 0 | SetDefaultAttributes(aDefault); |
66 | 0 | } |
67 | | |
68 | | E3dSphereObj::E3dSphereObj(SdrModel& rSdrModel, E3dSphereObj const & rSource) |
69 | 0 | : E3dCompoundObject(rSdrModel, rSource) |
70 | 0 | { |
71 | | // Set defaults |
72 | 0 | const E3dDefaultAttributes aDefault; |
73 | 0 | SetDefaultAttributes(aDefault); |
74 | |
|
75 | 0 | m_aCenter = rSource.m_aCenter; |
76 | 0 | m_aSize = rSource.m_aSize; |
77 | 0 | } |
78 | | |
79 | | E3dSphereObj::~E3dSphereObj() |
80 | 0 | { |
81 | 0 | } |
82 | | |
83 | | void E3dSphereObj::SetDefaultAttributes(const E3dDefaultAttributes& rDefault) |
84 | 0 | { |
85 | | // Set defaults |
86 | 0 | m_aCenter = rDefault.GetDefaultSphereCenter(); |
87 | 0 | m_aSize = rDefault.GetDefaultSphereSize(); |
88 | 0 | } |
89 | | |
90 | | SdrObjKind E3dSphereObj::GetObjIdentifier() const |
91 | 0 | { |
92 | 0 | return SdrObjKind::E3D_Sphere; |
93 | 0 | } |
94 | | |
95 | | // Convert the object into a group object consisting of n polygons |
96 | | |
97 | | rtl::Reference<SdrObject> E3dSphereObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const |
98 | 0 | { |
99 | 0 | return nullptr; |
100 | 0 | } |
101 | | |
102 | | rtl::Reference<SdrObject> E3dSphereObj::CloneSdrObject(SdrModel& rTargetModel) const |
103 | 0 | { |
104 | 0 | return new E3dSphereObj(rTargetModel, *this); |
105 | 0 | } |
106 | | |
107 | | // Set local parameters with geometry re-creating |
108 | | |
109 | | void E3dSphereObj::SetCenter(const basegfx::B3DPoint& rNew) |
110 | 0 | { |
111 | 0 | if(m_aCenter != rNew) |
112 | 0 | { |
113 | 0 | m_aCenter = rNew; |
114 | 0 | ActionChanged(); |
115 | 0 | } |
116 | 0 | } |
117 | | |
118 | | void E3dSphereObj::SetSize(const basegfx::B3DVector& rNew) |
119 | 0 | { |
120 | 0 | if(m_aSize != rNew) |
121 | 0 | { |
122 | 0 | m_aSize = rNew; |
123 | 0 | ActionChanged(); |
124 | 0 | } |
125 | 0 | } |
126 | | |
127 | | // Get the name of the object (singular) |
128 | | |
129 | | OUString E3dSphereObj::TakeObjNameSingul() const |
130 | 0 | { |
131 | 0 | OUString sName(SvxResId(STR_ObjNameSingulSphere3d)); |
132 | |
|
133 | 0 | OUString aName(GetName()); |
134 | 0 | if (!aName.isEmpty()) |
135 | 0 | { |
136 | 0 | sName += " '" + aName + "'"; |
137 | 0 | } |
138 | 0 | return sName; |
139 | 0 | } |
140 | | |
141 | | // Get the name of the object (plural) |
142 | | |
143 | | OUString E3dSphereObj::TakeObjNamePlural() const |
144 | 0 | { |
145 | 0 | return SvxResId(STR_ObjNamePluralSphere3d); |
146 | 0 | } |
147 | | |
148 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |