fix build
[LibreOffice.git] / include / svx / obj3d.hxx
blob54919a49c9319ea6c94959f8c99d8ca140f254b2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVX_OBJ3D_HXX
21 #define INCLUDED_SVX_OBJ3D_HXX
23 #include <svx/svdoattr.hxx>
24 #include <svx/svdobj.hxx>
25 #include <svx/svdgeodata.hxx>
26 #include <basegfx/matrix/b3dhommatrix.hxx>
27 #include <basegfx/range/b3drange.hxx>
28 #include <basegfx/polygon/b3dpolypolygon.hxx>
29 #include <svx/svxdllapi.h>
31 // Forward declarations
32 class E3dScene;
34 namespace sdr::properties {
35 class BaseProperties;
36 class E3dCompoundProperties;
37 class E3dExtrudeProperties;
38 class E3dLatheProperties;
39 class E3dSphereProperties;
42 /*************************************************************************
44 |* GeoData relevant for undo actions
46 \************************************************************************/
48 class E3DObjGeoData : public SdrObjGeoData
50 public:
51 basegfx::B3DRange maLocalBoundVol; // surrounding volume of the object
52 basegfx::B3DHomMatrix maTransformation; // local transformations
54 E3DObjGeoData() {}
57 /*************************************************************************
59 |* Base class for 3D objects
61 \************************************************************************/
63 class SVXCORE_DLLPUBLIC E3dObject : public SdrAttrObj
65 private:
66 // Allow everything for E3dObjList and E3dDragMethod
67 friend class E3dDragMethod;
69 protected:
70 virtual std::unique_ptr<sdr::properties::BaseProperties> CreateObjectSpecificProperties() override;
72 basegfx::B3DRange maLocalBoundVol; // surrounding volume of the object (from the geometry generation)
73 basegfx::B3DHomMatrix maTransformation; // local transformation
74 basegfx::B3DHomMatrix maFullTransform; // global transformation (including. parents)
76 // Flags
77 bool mbTfHasChanged : 1;
78 bool mbIsSelected : 1;
80 protected:
81 virtual basegfx::B3DRange RecalcBoundVolume() const;
83 // E3dObject is only a helper class (for E3DScene and E3DCompoundObject)
84 // and no instances should be created from anyone, so i move the constructors
85 // to protected area
86 E3dObject(SdrModel& rSdrModel);
87 E3dObject(SdrModel& rSdrModel, E3dObject const & rSource);
89 // protected destructor
90 virtual ~E3dObject() override;
92 public:
93 virtual void StructureChanged();
94 virtual void SetTransformChanged();
95 virtual void RecalcSnapRect() override;
97 virtual SdrInventor GetObjInventor() const override;
98 virtual SdrObjKind GetObjIdentifier() const override;
99 virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
100 virtual void NbcMove(const Size& rSize) override;
101 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
103 E3dScene* getParentE3dSceneFromE3dObject() const;
104 virtual E3dScene* getRootE3dSceneFromE3dObject() const;
106 const basegfx::B3DRange& GetBoundVolume() const;
107 void InvalidateBoundVolume();
109 // calculate complete transformation including all parents
110 const basegfx::B3DHomMatrix& GetFullTransform() const;
112 // get and (re)set transformation matrix
113 const basegfx::B3DHomMatrix& GetTransform() const { return maTransformation;}
114 virtual void NbcSetTransform(const basegfx::B3DHomMatrix& rMatrix);
115 virtual void SetTransform(const basegfx::B3DHomMatrix& rMatrix);
117 // 2D rotations, are implemented as a rotation around the Z axis
118 // which is vertical to the screen, plus a shift of the scene.
119 // This means that also the scene (E3dScene) must define this
120 // routine as virtual in its class.
121 virtual void NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs) override;
123 // get wireframe polygon for local object. No transform is applied.
124 basegfx::B3DPolyPolygon CreateWireframe() const;
126 // TakeObjName...() is for the display in the UI, for example "3 frames selected".
127 virtual OUString TakeObjNameSingul() const override;
128 virtual OUString TakeObjNamePlural() const override;
129 virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
131 virtual std::unique_ptr<SdrObjGeoData> NewGeoData() const override;
132 virtual void SaveGeoData(SdrObjGeoData& rGeo) const override;
133 virtual void RestoreGeoData(const SdrObjGeoData& rGeo) override;
135 // get/set the selection
136 bool GetSelected() const { return mbIsSelected; }
137 virtual void SetSelected(bool bNew);
139 // break up
140 virtual bool IsBreakObjPossible();
141 virtual rtl::Reference<SdrAttrObj> GetBreakObj();
144 /*************************************************************************
146 |* Class for all compound objects (Cube, Lathe, Scene, Extrude)
147 |* This class saves some ISA queries and accelerates the behaviour
148 |* significantly, because all the attributes etc. are kept through this.
149 |* The polygons may only keep attributes if they are directly
150 |* subordinated to the scene.
152 \************************************************************************/
154 class SVXCORE_DLLPUBLIC E3dCompoundObject : public E3dObject
156 private:
157 // to allow sdr::properties::E3dCompoundProperties access to SetGeometryValid()
158 friend class sdr::properties::E3dCompoundProperties;
159 friend class sdr::properties::E3dExtrudeProperties;
160 friend class sdr::properties::E3dLatheProperties;
161 friend class sdr::properties::E3dSphereProperties;
163 protected:
164 virtual std::unique_ptr<sdr::properties::BaseProperties> CreateObjectSpecificProperties() override;
166 protected:
167 // convert given basegfx::B3DPolyPolygon to screen coor
168 basegfx::B2DPolyPolygon TransformToScreenCoor(const basegfx::B3DPolyPolygon& rCandidate) const;
170 // protected destructor
171 virtual ~E3dCompoundObject() override;
173 public:
174 E3dCompoundObject(SdrModel& rSdrModel, E3dCompoundObject const & rSource);
175 E3dCompoundObject(SdrModel& rSdrModel);
177 virtual basegfx::B2DPolyPolygon TakeXorPoly() const override;
178 virtual sal_uInt32 GetHdlCount() const override;
179 virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
181 virtual SdrObjKind GetObjIdentifier() const override;
182 virtual void RecalcSnapRect() override;
184 virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
187 #endif // INCLUDED_SVX_OBJ3D_HXX
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */