LibreOffice Module svx (master)  1
obj3d.hxx
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 #ifndef INCLUDED_SVX_OBJ3D_HXX
21 #define INCLUDED_SVX_OBJ3D_HXX
22 
23 #include <svx/svdoattr.hxx>
24 #include <svx/svdobj.hxx>
28 #include <svx/svxdllapi.h>
29 
30 // Forward declarations
31 class E3dScene;
32 
33 namespace sdr { namespace properties {
34  class BaseProperties;
35  class E3dCompoundProperties;
36  class E3dExtrudeProperties;
37  class E3dLatheProperties;
38  class E3dSphereProperties;
39 }}
40 
41 /*************************************************************************
42 |*
43 |* GeoData relevant for undo actions
44 |*
45 \************************************************************************/
46 
48 {
49 public:
50  basegfx::B3DRange maLocalBoundVol; // surrounding volume of the object
51  basegfx::B3DHomMatrix maTransformation; // local transformations
52 
54 };
55 
56 /*************************************************************************
57 |*
58 |* Base class for 3D objects
59 |*
60 \************************************************************************/
61 
63 {
64 private:
65  // Allow everything for E3dObjList and E3dDragMethod
66  friend class E3dDragMethod;
67 
68  protected:
69  virtual std::unique_ptr<sdr::properties::BaseProperties> CreateObjectSpecificProperties() override;
70 
71  basegfx::B3DRange maLocalBoundVol; // surrounding volume of the object (from the geometry generation)
72  basegfx::B3DHomMatrix maTransformation; // local transformation
73  basegfx::B3DHomMatrix maFullTransform; // global transformation (including. parents)
74 
75  // Flags
76  bool mbTfHasChanged : 1;
77  bool mbIsSelected : 1;
78 
79 protected:
80  virtual basegfx::B3DRange RecalcBoundVolume() const;
81 
82  // E3dObject is only a helper class (for E3DScene and E3DCompoundObject)
83  // and no instances should be created from anyone, so i move the constructors
84  // to protected area
85  E3dObject(SdrModel& rSdrModel);
86 
87  // protected destructor
88  virtual ~E3dObject() override;
89 
90 public:
91  virtual void StructureChanged();
92  virtual void SetTransformChanged();
93  virtual void RecalcSnapRect() override;
94 
95  virtual SdrInventor GetObjInventor() const override;
96  virtual sal_uInt16 GetObjIdentifier() const override;
97  virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
98  virtual void NbcMove(const Size& rSize) override;
99  virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
100 
101  E3dScene* getParentE3dSceneFromE3dObject() const;
102  virtual E3dScene* getRootE3dSceneFromE3dObject() const;
103 
104  const basegfx::B3DRange& GetBoundVolume() const;
105  void InvalidateBoundVolume();
106 
107  // calculate complete transformation including all parents
108  const basegfx::B3DHomMatrix& GetFullTransform() const;
109 
110  // get and (re)set transformation matrix
111  const basegfx::B3DHomMatrix& GetTransform() const { return maTransformation;}
112  virtual void NbcSetTransform(const basegfx::B3DHomMatrix& rMatrix);
113  virtual void SetTransform(const basegfx::B3DHomMatrix& rMatrix);
114 
115  // 2D rotations, are implemented as a rotation around the Z axis
116  // which is vertical to the screen, plus a shift of the scene.
117  // This means that also the scene (E3dScene) must define this
118  // routine as virtual in its class.
119  virtual void NbcRotate(const Point& rRef, long nAngle, double sn, double cs) override;
120 
121  // get wireframe polygon for local object. No transform is applied.
122  basegfx::B3DPolyPolygon CreateWireframe() const;
123 
124  // TakeObjName...() is for the display in the UI, for example "3 frames selected".
125  virtual OUString TakeObjNameSingul() const override;
126  virtual OUString TakeObjNamePlural() const override;
127  virtual E3dObject* CloneSdrObject(SdrModel& rTargetModel) const override;
128  E3dObject& operator=( const E3dObject& rObj );
129 
130  virtual SdrObjGeoData *NewGeoData() const override;
131  virtual void SaveGeoData(SdrObjGeoData& rGeo) const override;
132  virtual void RestGeoData(const SdrObjGeoData& rGeo) override;
133 
134  // get/set the selection
135  bool GetSelected() const { return mbIsSelected; }
136  virtual void SetSelected(bool bNew);
137 
138  // break up
139  virtual bool IsBreakObjPossible();
140  virtual std::unique_ptr<SdrAttrObj,SdrObjectFreeOp> GetBreakObj();
141 };
142 
143 /*************************************************************************
144 |*
145 |* Class for all compound objects (Cube, Lathe, Scene, Extrude)
146 |* This class saves some ISA queries and accelerates the behaviour
147 |* significantly, because all the attributes etc. are kept through this.
148 |* The polygons may only keep attributes if they are directly
149 |* subordinated to the scene.
150 |*
151 \************************************************************************/
152 
154 {
155 private:
156  // to allow sdr::properties::E3dCompoundProperties access to SetGeometryValid()
161 
162 protected:
163  virtual std::unique_ptr<sdr::properties::BaseProperties> CreateObjectSpecificProperties() override;
164 
165 protected:
166  // convert given basegfx::B3DPolyPolygon to screen coor
167  basegfx::B2DPolyPolygon TransformToScreenCoor(const basegfx::B3DPolyPolygon& rCandidate);
168 
169  // protected destructor
170  virtual ~E3dCompoundObject() override;
171 
172 public:
173  E3dCompoundObject(SdrModel& rSdrModel);
174 
175  virtual basegfx::B2DPolyPolygon TakeXorPoly() const override;
176  virtual sal_uInt32 GetHdlCount() const override;
177  virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
178 
179  virtual sal_uInt16 GetObjIdentifier() const override;
180  virtual void RecalcSnapRect() override;
181 
182  virtual E3dCompoundObject* CloneSdrObject(SdrModel& rTargetModel) const override;
183 
184  // implemented mainly for the purposes of Clone()
186 };
187 
188 #endif // INCLUDED_SVX_OBJ3D_HXX
189 
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual basegfx::B2DPolyPolygon TakeXorPoly() const
The Xor-Polygon is required by the View to drag the object.
Definition: svdobj.cxx:1094
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const
Definition: svdobj.cxx:590
basegfx::B3DHomMatrix maTransformation
Definition: obj3d.hxx:51
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact)
Definition: svdobj.cxx:1407
E3DObjGeoData()
Definition: obj3d.hxx:53
SdrInventor
Definition: svdobj.hxx:152
virtual OUString TakeObjNameSingul() const
Definition: svdobj.cxx:1045
basegfx::B3DRange maLocalBoundVol
Definition: obj3d.hxx:71
virtual void AddToHdlList(SdrHdlList &rHdlList) const
Definition: svdobj.cxx:1196
const basegfx::B3DHomMatrix & GetTransform() const
Definition: obj3d.hxx:111
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
All geometrical data of an arbitrary object for use in undo/redo.
Definition: svdobj.hxx:226
virtual sal_uInt16 GetObjIdentifier() const override
Definition: obj3d.cxx:124
basegfx::B3DHomMatrix maTransformation
Definition: obj3d.hxx:72
Provides information about various ZObject properties.
Definition: svdobj.hxx:248
virtual void RecalcSnapRect()
Snap is not done on the BoundRect but if possible on logic coordinates (i.e.
Definition: svdobj.cxx:1620
SdrAttrObj & operator=(SdrAttrObj const &)=default
virtual void NbcRotate(const Point &rRef, long nAngle, double sn, double cs)
Definition: svdobj.cxx:1428
basegfx::B3DRange maLocalBoundVol
Definition: obj3d.hxx:50
virtual E3dObject * CloneSdrObject(SdrModel &rTargetModel) const override
Definition: obj3d.cxx:416
bool GetSelected() const
Definition: obj3d.hxx:135
virtual sal_uInt16 GetObjIdentifier() const
Definition: svdobj.cxx:585
virtual void SaveGeoData(SdrObjGeoData &rGeo) const
Definition: svdobj.cxx:1837
virtual sal_uInt32 GetHdlCount() const
Via GetHdlCount the number of Handles can be retrieved.
Definition: svdobj.cxx:1191
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: svdoattr.cxx:76
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: obj3d.cxx:79
virtual SdrInventor GetObjInventor() const
Definition: svdobj.cxx:580
virtual void RestGeoData(const SdrObjGeoData &rGeo)
Definition: svdobj.cxx:1860
virtual SdrObjGeoData * NewGeoData() const
A derived class must override these 3 methods if it has own geometric data that must be saved for Und...
Definition: svdobj.cxx:1832
virtual void NbcMove(const Size &rSiz)
The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and SetLogicRect call the corresponding ...
Definition: svdobj.cxx:1401
virtual SdrObject * CloneSdrObject(SdrModel &rTargetModel) const
Definition: svdobj.cxx:1001
E3dObject & operator=(const E3dObject &rObj)
Definition: obj3d.cxx:421
virtual OUString TakeObjNamePlural() const
Definition: svdobj.cxx:1060
bool mbIsSelected
virtual void RecalcSnapRect() override
Snap is not done on the BoundRect but if possible on logic coordinates (i.e.
Definition: obj3d.cxx:263
basegfx::B3DHomMatrix maFullTransform
Definition: obj3d.hxx:73