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 <tools/poly.hxx>
25 #include <svx/svdpage.hxx>
26 #include <svx/globl3d.hxx>
27 #include <svx/lathe3d.hxx>
28 #include <svx/xpoly.hxx>
29 #include <svx/svxids.hrc>
30 #include <svx/svdopath.hxx>
31 #include <svx/svdmodel.hxx>
32 #include <svx/svx3ditems.hxx>
33 #include <svx/xlineit0.hxx>
39 
40 
41 // DrawContact section
42 std::unique_ptr<sdr::contact::ViewContact> E3dLatheObj::CreateObjectSpecificViewContact()
43 {
44  return std::make_unique<sdr::contact::ViewContactOfE3dLathe>(*this);
45 }
46 
47 std::unique_ptr<sdr::properties::BaseProperties> E3dLatheObj::CreateObjectSpecificProperties()
48 {
49  return std::make_unique<sdr::properties::E3dLatheProperties>(*this);
50 }
51 
52 // Constructor from 3D polygon, scale is the conversion factor for the coordinates
54  SdrModel& rSdrModel,
55  const E3dDefaultAttributes& rDefault,
56  const basegfx::B2DPolyPolygon& rPoly2D)
57 : E3dCompoundObject(rSdrModel),
58  maPolyPoly2D(rPoly2D)
59 {
60  // since the old class PolyPolygon3D did mirror the given PolyPolygons in Y, do the same here
61  basegfx::B2DHomMatrix aMirrorY;
62  aMirrorY.scale(1.0, -1.0);
63  maPolyPoly2D.transform(aMirrorY);
64 
65  // Set Defaults
66  SetDefaultAttributes(rDefault);
67 
68  // Superfluous items removed, in particular to prevent duplicate
69  // start and end points
71 
72  if(maPolyPoly2D.count())
73  {
75  sal_uInt32 nSegCnt(rPoly.count());
76 
77  if(nSegCnt && !rPoly.isClosed())
78  {
79  nSegCnt -= 1;
80  }
81 
83  }
84 }
85 
87 : E3dCompoundObject(rSdrModel)
88 {
89  // Set Defaults
90  const E3dDefaultAttributes aDefault;
91 
92  SetDefaultAttributes(aDefault);
93 }
94 
96 {
97 }
98 
100 {
106 }
107 
109 {
110  return E3D_LATHEOBJ_ID;
111 }
112 
114 {
115  return CloneHelper< E3dLatheObj >(rTargetModel);
116 }
117 
119 {
120  if( this == &rObj )
121  return *this;
123 
124  maPolyPoly2D = rObj.maPolyPoly2D;
125 
126  return *this;
127 }
128 
129 // Convert the object to group object consisting of n polygons
130 
131 SdrObjectUniquePtr E3dLatheObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
132 {
133  return nullptr;
134 }
135 
136 // Set Local parameters set to re-create geometry
137 
139 {
140  if(maPolyPoly2D != rNew)
141  {
142  maPolyPoly2D = rNew;
144 
145  if(maPolyPoly2D.count())
146  {
148  sal_uInt32 nSegCnt(rPoly.count());
149 
150  if(nSegCnt && !rPoly.isClosed())
151  {
152  nSegCnt -= 1;
153  }
154 
156  }
157 
158  ActionChanged();
159  }
160 }
161 
162 // Get the name of the object (singular)
163 
165 {
166  OUStringBuffer sName(SvxResId(STR_ObjNameSingulLathe3d));
167 
168  OUString aName(GetName());
169  if (!aName.isEmpty())
170  {
171  sName.append(' ');
172  sName.append('\'');
173  sName.append(aName);
174  sName.append('\'');
175  }
176  return sName.makeStringAndClear();
177 }
178 
179 // Get the name of the object (plural)
180 
182 {
183  return SvxResId(STR_ObjNamePluralLathe3d);
184 }
185 
187 {
188  return true;
189 }
190 
191 std::unique_ptr<SdrAttrObj,SdrObjectFreeOp> E3dLatheObj::GetBreakObj()
192 {
193  // create PathObj
195  basegfx::B2DPolyPolygon aTransPoly(TransformToScreenCoor(aLathePoly3D));
196  std::unique_ptr<SdrPathObj,SdrObjectFreeOp> pPathObj(new SdrPathObj(getSdrModelFromSdrObject(), OBJ_PLIN, aTransPoly));
197 
198  // Set Attribute
200 
201  // Enable lines to guarantee that the object becomes visible
202  aSet.Put(XLineStyleItem(css::drawing::LineStyle_SOLID));
203 
204  pPathObj->SetMergedItemSet(aSet);
205 
206  return std::unique_ptr<SdrAttrObj,SdrObjectFreeOp>(pPathObj.release());
207 }
208 
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const sal_uInt16 E3D_LATHEOBJ_ID
Definition: globl3d.hxx:30
virtual void SetObjectItemDirect(const SfxPoolItem &rItem)=0
virtual OUString TakeObjNamePlural() const override
Definition: lathe3d.cxx:181
bool GetDefaultLatheCharacterMode() const
Definition: deflt3d.hxx:78
bool GetDefaultLatheCloseBack() const
Definition: deflt3d.hxx:81
bool GetDefaultLatheSmoothed() const
Definition: deflt3d.hxx:76
SfxUInt32Item makeSvx3DVerticalSegmentsItem(sal_uInt32 nVal)
Definition: svx3ditems.hxx:49
virtual sdr::properties::BaseProperties & GetProperties() const
Definition: svdobj.cxx:230
polygon, PolyPolygon
Definition: svdobj.hxx:126
E3dLatheObj(SdrModel &rSdrModel, const E3dDefaultAttributes &rDefault, const basegfx::B2DPolyPolygon &rPoly2D)
Definition: lathe3d.cxx:53
B2DPolygon const & getB2DPolygon(sal_uInt32 nIndex) const
virtual OUString TakeObjNameSingul() const override
Definition: lathe3d.cxx:164
B3DPolyPolygon createB3DPolyPolygonFromB2DPolyPolygon(const B2DPolyPolygon &rCandidate, double fZCoordinate)
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
const SfxItemSet & GetObjectItemSet() const
Definition: svdobj.cxx:1906
virtual sal_uInt16 GetObjIdentifier() const override
Definition: lathe3d.cxx:108
bool GetDefaultLatheCloseFront() const
Definition: deflt3d.hxx:80
basegfx::B2DPolyPolygon TransformToScreenCoor(const basegfx::B3DPolyPolygon &rCandidate)
Definition: obj3d.cxx:640
OUString sName
E3dCompoundObject & operator=(const E3dCompoundObject &rObj)
Definition: obj3d.cxx:631
E3dLatheObj & operator=(const E3dLatheObj &rObj)
Definition: lathe3d.cxx:118
void ActionChanged() const
Definition: svdobj.cxx:283
void scale(double fX, double fY)
SdrModel & getSdrModelFromSdrObject() const
Definition: svdobj.cxx:299
void transform(const basegfx::B2DHomMatrix &rMatrix)
void SetDefaultAttributes(const E3dDefaultAttributes &rDefault)
Definition: lathe3d.cxx:99
virtual ~E3dLatheObj() override
Definition: lathe3d.cxx:95
bool GetDefaultLatheSmoothFrontBack() const
Definition: deflt3d.hxx:77
OUString GetName() const
Definition: svdobj.cxx:725
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt32 count() const
virtual std::unique_ptr< SdrAttrObj, SdrObjectFreeOp > GetBreakObj() override
Definition: lathe3d.cxx:191
OUString aName
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:114
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: lathe3d.cxx:42
basegfx::B2DPolyPolygon maPolyPoly2D
Definition: lathe3d.hxx:44
virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override
Definition: lathe3d.cxx:131
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: lathe3d.cxx:47
virtual E3dLatheObj * CloneSdrObject(SdrModel &rTargetModel) const override
Definition: lathe3d.cxx:113
void SetPolyPoly2D(const basegfx::B2DPolyPolygon &rNew)
Definition: lathe3d.cxx:138
virtual bool IsBreakObjPossible() override
Definition: lathe3d.cxx:186