LibreOffice Module svx (master) 1
lathe3d.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/deflt3d.hxx>
22#include <svx/strings.hrc>
23#include <svx/dialmgr.hxx>
24#include <svx/svdobjkind.hxx>
25#include <svx/lathe3d.hxx>
26#include <svx/svdopath.hxx>
27#include <svx/svdmodel.hxx>
28#include <svx/svx3ditems.hxx>
29#include <svx/xlineit0.hxx>
34#include <utility>
35
36
37// DrawContact section
38std::unique_ptr<sdr::contact::ViewContact> E3dLatheObj::CreateObjectSpecificViewContact()
39{
40 return std::make_unique<sdr::contact::ViewContactOfE3dLathe>(*this);
41}
42
43std::unique_ptr<sdr::properties::BaseProperties> E3dLatheObj::CreateObjectSpecificProperties()
44{
45 return std::make_unique<sdr::properties::E3dLatheProperties>(*this);
46}
47
48// Constructor from 3D polygon, scale is the conversion factor for the coordinates
50 SdrModel& rSdrModel,
51 const E3dDefaultAttributes& rDefault,
53: E3dCompoundObject(rSdrModel),
54 maPolyPoly2D(std::move(aPoly2D))
55{
56 // since the old class PolyPolygon3D did mirror the given PolyPolygons in Y, do the same here
57 basegfx::B2DHomMatrix aMirrorY;
58 aMirrorY.scale(1.0, -1.0);
59 maPolyPoly2D.transform(aMirrorY);
60
61 // Set Defaults
62 SetDefaultAttributes(rDefault);
63
64 // Superfluous items removed, in particular to prevent duplicate
65 // start and end points
67
69 {
71 sal_uInt32 nSegCnt(rPoly.count());
72
73 if(nSegCnt && !rPoly.isClosed())
74 {
75 nSegCnt -= 1;
76 }
77
79 }
80}
81
83: E3dCompoundObject(rSdrModel)
84{
85 // Set Defaults
86 const E3dDefaultAttributes aDefault;
87
88 SetDefaultAttributes(aDefault);
89}
90
91E3dLatheObj::E3dLatheObj(SdrModel& rSdrModel, E3dLatheObj const & rSource)
92: E3dCompoundObject(rSdrModel, rSource)
93{
94 // Set Defaults
95 const E3dDefaultAttributes aDefault;
96
97 SetDefaultAttributes(aDefault);
98
99 maPolyPoly2D = rSource.maPolyPoly2D;
100}
101
103{
104}
105
106void E3dLatheObj::SetDefaultAttributes(const E3dDefaultAttributes& rDefault)
107{
108 GetProperties().SetObjectItemDirect(Svx3DSmoothNormalsItem(rDefault.GetDefaultLatheSmoothed()));
109 GetProperties().SetObjectItemDirect(Svx3DSmoothLidsItem(rDefault.GetDefaultLatheSmoothFrontBack()));
110 GetProperties().SetObjectItemDirect(Svx3DCharacterModeItem(rDefault.GetDefaultLatheCharacterMode()));
111 GetProperties().SetObjectItemDirect(Svx3DCloseFrontItem(rDefault.GetDefaultLatheCloseFront()));
112 GetProperties().SetObjectItemDirect(Svx3DCloseBackItem(rDefault.GetDefaultLatheCloseBack()));
113}
114
116{
118}
119
121{
122 return new E3dLatheObj(rTargetModel, *this);
123}
124
125// Convert the object to group object consisting of n polygons
126
127rtl::Reference<SdrObject> E3dLatheObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
128{
129 return nullptr;
130}
131
132// Set Local parameters set to re-create geometry
133
135{
136 if(maPolyPoly2D == rNew)
137 return;
138
139 maPolyPoly2D = rNew;
141
142 if(maPolyPoly2D.count())
143 {
145 sal_uInt32 nSegCnt(rPoly.count());
146
147 if(nSegCnt && !rPoly.isClosed())
148 {
149 nSegCnt -= 1;
150 }
151
153 }
154
156}
157
158// Get the name of the object (singular)
159
161{
162 OUString sName(SvxResId(STR_ObjNameSingulLathe3d));
163
164 OUString aName(GetName());
165 if (!aName.isEmpty())
166 {
167 sName += " '" + aName + "'";
168 }
169 return sName;
170}
171
172// Get the name of the object (plural)
173
175{
176 return SvxResId(STR_ObjNamePluralLathe3d);
177}
178
180{
181 return true;
182}
183
185{
186 // create PathObj
188 basegfx::B2DPolyPolygon aTransPoly(TransformToScreenCoor(aLathePoly3D));
190
191 // Set Attribute
193
194 // Enable lines to guarantee that the object becomes visible
195 aSet.Put(XLineStyleItem(css::drawing::LineStyle_SOLID));
196
197 pPathObj->SetMergedItemSet(aSet);
198
199 return pPathObj;
200}
201
202/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
basegfx::B2DPolyPolygon TransformToScreenCoor(const basegfx::B3DPolyPolygon &rCandidate) const
Definition: obj3d.cxx:602
virtual OUString TakeObjNamePlural() const override
Definition: lathe3d.cxx:174
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: lathe3d.cxx:38
void SetDefaultAttributes(const E3dDefaultAttributes &rDefault)
Definition: lathe3d.cxx:106
basegfx::B2DPolyPolygon maPolyPoly2D
Definition: lathe3d.hxx:44
virtual rtl::Reference< SdrAttrObj > GetBreakObj() override
Definition: lathe3d.cxx:184
E3dLatheObj(SdrModel &rSdrModel, const E3dDefaultAttributes &rDefault, basegfx::B2DPolyPolygon aPoly2D)
Definition: lathe3d.cxx:49
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: lathe3d.cxx:43
virtual rtl::Reference< SdrObject > DoConvertToPolyObj(bool bBezier, bool bAddText) const override
Definition: lathe3d.cxx:127
virtual SdrObjKind GetObjIdentifier() const override
Definition: lathe3d.cxx:115
virtual bool IsBreakObjPossible() override
Definition: lathe3d.cxx:179
void SetPolyPoly2D(const basegfx::B2DPolyPolygon &rNew)
Definition: lathe3d.cxx:134
virtual ~E3dLatheObj() override
Definition: lathe3d.cxx:102
virtual rtl::Reference< SdrObject > CloneSdrObject(SdrModel &rTargetModel) const override
Definition: lathe3d.cxx:120
virtual OUString TakeObjNameSingul() const override
Definition: lathe3d.cxx:160
void ActionChanged() const
Definition: svdobj.cxx:273
virtual sdr::properties::BaseProperties & GetProperties() const
Definition: svdobj.cxx:220
SdrModel & getSdrModelFromSdrObject() const
Definition: svdobj.cxx:289
virtual const OUString & GetName() const
Definition: svdobj.cxx:771
const SfxItemSet & GetObjectItemSet() const
Definition: svdobj.cxx:1969
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void scale(double fX, double fY)
B2DPolygon const & getB2DPolygon(sal_uInt32 nIndex) const
void transform(const basegfx::B2DHomMatrix &rMatrix)
sal_uInt32 count() const
bool isClosed() const
sal_uInt32 count() const
virtual void SetObjectItemDirect(const SfxPoolItem &rItem)=0
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
OUString sName
OUString aName
B3DPolyPolygon createB3DPolyPolygonFromB2DPolyPolygon(const B2DPolyPolygon &rCandidate, double fZCoordinate)
SdrObjKind
Definition: svdobjkind.hxx:25
@ PolyLine
polygon, PolyPolygon
SfxUInt32Item makeSvx3DVerticalSegmentsItem(sal_uInt32 nVal)
Definition: svx3ditems.hxx:50