1*3334a7e6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*3334a7e6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*3334a7e6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*3334a7e6SAndrew Rist * distributed with this work for additional information 6*3334a7e6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*3334a7e6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*3334a7e6SAndrew Rist * "License"); you may not use this file except in compliance 9*3334a7e6SAndrew Rist * with the License. You may obtain a copy of the License at 10*3334a7e6SAndrew Rist * 11*3334a7e6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*3334a7e6SAndrew Rist * 13*3334a7e6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*3334a7e6SAndrew Rist * software distributed under the License is distributed on an 15*3334a7e6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*3334a7e6SAndrew Rist * KIND, either express or implied. See the License for the 17*3334a7e6SAndrew Rist * specific language governing permissions and limitations 18*3334a7e6SAndrew Rist * under the License. 19*3334a7e6SAndrew Rist * 20*3334a7e6SAndrew Rist *************************************************************/ 21*3334a7e6SAndrew Rist 22*3334a7e6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _E3D_OBJ3D_HXX 25cdf0e10cSrcweir #define _E3D_OBJ3D_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <svx/svdoattr.hxx> 28cdf0e10cSrcweir #include <svx/svdobj.hxx> 29cdf0e10cSrcweir #include <svx/volume3d.hxx> 30cdf0e10cSrcweir #include <svx/def3d.hxx> 31cdf0e10cSrcweir #include <svx/svdpage.hxx> 32cdf0e10cSrcweir #include <svx/deflt3d.hxx> 33cdf0e10cSrcweir #include <vcl/bitmap.hxx> 34cdf0e10cSrcweir #include <svx/svx3ditems.hxx> 35cdf0e10cSrcweir #include <svx/xflclit.hxx> 36cdf0e10cSrcweir #include <svl/itemset.hxx> 37cdf0e10cSrcweir #include <basegfx/polygon/b3dpolypolygon.hxx> 38cdf0e10cSrcweir #include <basegfx/point/b2dpoint.hxx> 39cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx> 40cdf0e10cSrcweir #include <basegfx/vector/b2enums.hxx> 41cdf0e10cSrcweir #include "svx/svxdllapi.h" 42cdf0e10cSrcweir 43cdf0e10cSrcweir //************************************************************ 44cdf0e10cSrcweir // Vorausdeklarationen 45cdf0e10cSrcweir //************************************************************ 46cdf0e10cSrcweir 47cdf0e10cSrcweir class SfxPoolItem; 48cdf0e10cSrcweir class Viewport3D; 49cdf0e10cSrcweir class E3dScene; 50cdf0e10cSrcweir class E3dPolyScene; 51cdf0e10cSrcweir 52cdf0e10cSrcweir namespace basegfx { class B3DPolyPolygon; } 53cdf0e10cSrcweir namespace sdr { namespace properties { 54cdf0e10cSrcweir class BaseProperties; 55cdf0e10cSrcweir class E3dProperties; 56cdf0e10cSrcweir class E3dCompoundProperties; 57cdf0e10cSrcweir class E3dExtrudeProperties; 58cdf0e10cSrcweir class E3dLatheProperties; 59cdf0e10cSrcweir class E3dSphereProperties; 60cdf0e10cSrcweir }} 61cdf0e10cSrcweir 62cdf0e10cSrcweir /************************************************************************* 63cdf0e10cSrcweir |* 64cdf0e10cSrcweir |* GeoData relevant fuer Undo-Actions 65cdf0e10cSrcweir |* 66cdf0e10cSrcweir \************************************************************************/ 67cdf0e10cSrcweir 68cdf0e10cSrcweir class E3DObjGeoData : public SdrObjGeoData 69cdf0e10cSrcweir { 70cdf0e10cSrcweir public: 71cdf0e10cSrcweir basegfx::B3DRange maLocalBoundVol; // umschliessendes Volumen des Objekts 72cdf0e10cSrcweir basegfx::B3DHomMatrix maTransformation; // lokale Transformation 73cdf0e10cSrcweir E3DObjGeoData()74cdf0e10cSrcweir E3DObjGeoData() {} 75cdf0e10cSrcweir }; 76cdf0e10cSrcweir 77cdf0e10cSrcweir /************************************************************************* 78cdf0e10cSrcweir |* 79cdf0e10cSrcweir |* Liste fuer 3D-Objekte 80cdf0e10cSrcweir |* 81cdf0e10cSrcweir \************************************************************************/ 82cdf0e10cSrcweir 83cdf0e10cSrcweir class E3dObjList : public SdrObjList 84cdf0e10cSrcweir { 85cdf0e10cSrcweir public: 86cdf0e10cSrcweir TYPEINFO(); 87cdf0e10cSrcweir E3dObjList(SdrModel* pNewModel = 0, SdrPage* pNewPage = 0, E3dObjList* pNewUpList = 0); 88cdf0e10cSrcweir SVX_DLLPUBLIC E3dObjList(const E3dObjList& rSrcList); 89cdf0e10cSrcweir SVX_DLLPUBLIC virtual ~E3dObjList(); 90cdf0e10cSrcweir 91cdf0e10cSrcweir virtual void NbcInsertObject(SdrObject* pObj, sal_uIntPtr nPos=CONTAINER_APPEND, const SdrInsertReason* pReason=NULL); 92cdf0e10cSrcweir virtual void InsertObject(SdrObject* pObj, sal_uIntPtr nPos=CONTAINER_APPEND, const SdrInsertReason* pReason=NULL); 93cdf0e10cSrcweir virtual SdrObject* NbcRemoveObject(sal_uIntPtr nObjNum); 94cdf0e10cSrcweir virtual SdrObject* RemoveObject(sal_uIntPtr nObjNum); 95cdf0e10cSrcweir }; 96cdf0e10cSrcweir 97cdf0e10cSrcweir /************************************************************************* 98cdf0e10cSrcweir |* 99cdf0e10cSrcweir |* Basisklasse fuer 3D-Objekte 100cdf0e10cSrcweir |* 101cdf0e10cSrcweir \************************************************************************/ 102cdf0e10cSrcweir 103cdf0e10cSrcweir class SVX_DLLPUBLIC E3dObject : public SdrAttrObj 104cdf0e10cSrcweir { 105cdf0e10cSrcweir private: 106cdf0e10cSrcweir // to allow sdr::properties::E3dProperties access to StructureChanged() 107cdf0e10cSrcweir friend class sdr::properties::E3dProperties; 108cdf0e10cSrcweir 109cdf0e10cSrcweir // Aus der E3dObjList und E3dDragMethod alles erlauben 110cdf0e10cSrcweir friend class E3dObjList; 111cdf0e10cSrcweir friend class E3dDragMethod; 112cdf0e10cSrcweir 113cdf0e10cSrcweir protected: 114cdf0e10cSrcweir virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties(); 115cdf0e10cSrcweir 116cdf0e10cSrcweir E3dObjList maSubList; // Subliste (Childobjekte) 117cdf0e10cSrcweir 118cdf0e10cSrcweir basegfx::B3DRange maLocalBoundVol; // umschliessendes Volumen des Objekts (aus geometrieerzeugung) 119cdf0e10cSrcweir basegfx::B3DHomMatrix maTransformation; // lokale Transformation 120cdf0e10cSrcweir basegfx::B3DHomMatrix maFullTransform; // globale Transformation (inkl. Parents) 121cdf0e10cSrcweir 122cdf0e10cSrcweir // Flags 123cdf0e10cSrcweir unsigned mbTfHasChanged : 1; 124cdf0e10cSrcweir unsigned mbIsSelected : 1; 125cdf0e10cSrcweir 126cdf0e10cSrcweir public: 127cdf0e10cSrcweir void SetBoundVolInvalid(); 128cdf0e10cSrcweir 129cdf0e10cSrcweir protected: 130cdf0e10cSrcweir void SetTransformChanged(); 131cdf0e10cSrcweir virtual void NewObjectInserted(const E3dObject* p3DObj); 132cdf0e10cSrcweir virtual void StructureChanged(); 133cdf0e10cSrcweir basegfx::B3DRange RecalcBoundVolume() const; 134cdf0e10cSrcweir 135cdf0e10cSrcweir protected: 136cdf0e10cSrcweir // E3dObject is only a helper class (for E3DScene and E3DCompoundObject) 137cdf0e10cSrcweir // and no instances should be created from anyone, so i move the constructors 138cdf0e10cSrcweir // to protected area 139cdf0e10cSrcweir E3dObject(); 140cdf0e10cSrcweir E3dObject(sal_Bool bIsFromChart); 141cdf0e10cSrcweir 142cdf0e10cSrcweir public: 143cdf0e10cSrcweir TYPEINFO(); 144cdf0e10cSrcweir virtual void RecalcSnapRect(); 145cdf0e10cSrcweir virtual void SetRectsDirty(sal_Bool bNotMyself = sal_False); 146cdf0e10cSrcweir 147cdf0e10cSrcweir virtual ~E3dObject(); 148cdf0e10cSrcweir 149cdf0e10cSrcweir virtual sal_uInt32 GetObjInventor() const; 150cdf0e10cSrcweir virtual sal_uInt16 GetObjIdentifier() const; 151cdf0e10cSrcweir 152cdf0e10cSrcweir virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const; 153cdf0e10cSrcweir 154cdf0e10cSrcweir virtual void NbcSetLayer(SdrLayerID nLayer); 155cdf0e10cSrcweir 156cdf0e10cSrcweir virtual void SetObjList(SdrObjList* pNewObjList); 157cdf0e10cSrcweir virtual void SetPage(SdrPage* pNewPage); 158cdf0e10cSrcweir virtual void SetModel(SdrModel* pNewModel); 159cdf0e10cSrcweir virtual void NbcMove(const Size& rSize); 160cdf0e10cSrcweir virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact); 161cdf0e10cSrcweir virtual SdrObjList* GetSubList() const; 162cdf0e10cSrcweir 163cdf0e10cSrcweir // 3D-Objekt in die Gruppe einfuegen; Eigentumsuebergang! 164cdf0e10cSrcweir virtual void Insert3DObj(E3dObject* p3DObj); 165cdf0e10cSrcweir void Remove3DObj(E3dObject* p3DObj); 166cdf0e10cSrcweir 167cdf0e10cSrcweir E3dObject* GetParentObj() const; 168cdf0e10cSrcweir virtual E3dScene* GetScene() const; 169cdf0e10cSrcweir 170cdf0e10cSrcweir const basegfx::B3DRange& GetBoundVolume() const; 171cdf0e10cSrcweir void InvalidateBoundVolume(); 172cdf0e10cSrcweir 173cdf0e10cSrcweir // komplette Transformation inklusive aller Parents berechnen 174cdf0e10cSrcweir const basegfx::B3DHomMatrix& GetFullTransform() const; 175cdf0e10cSrcweir 176cdf0e10cSrcweir // Transformationsmatrix abfragen bzw. (zurueck)setzen 177cdf0e10cSrcweir const basegfx::B3DHomMatrix& GetTransform() const; 178cdf0e10cSrcweir virtual void NbcSetTransform(const basegfx::B3DHomMatrix& rMatrix); 179cdf0e10cSrcweir virtual void SetTransform(const basegfx::B3DHomMatrix& rMatrix); 180cdf0e10cSrcweir 181cdf0e10cSrcweir // [FG] 2D-Rotationen, werden hier als Rotationen um die Z-Achse, die in den Bildschirm zeigt, 182cdf0e10cSrcweir // implementiert plus eine Verschiebung der Scene. Dies bedeutet auch die Scene (E3dScene) 183cdf0e10cSrcweir // muss diese Routine in der Klasse als virtual definieren. 184cdf0e10cSrcweir virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs); 185cdf0e10cSrcweir 186cdf0e10cSrcweir // get wireframe polygon for local object. No transform is applied. 187cdf0e10cSrcweir basegfx::B3DPolyPolygon CreateWireframe() const; 188cdf0e10cSrcweir 189cdf0e10cSrcweir // TakeObjName...() ist fuer die Anzeige in der UI, z.B. "3 Rahmen selektiert". 190cdf0e10cSrcweir virtual void TakeObjNameSingul(String& rName) const; 191cdf0e10cSrcweir virtual void TakeObjNamePlural(String& rName) const; GetLogicalGroup()192cdf0e10cSrcweir sal_uInt16 GetLogicalGroup() { return 0; } 193cdf0e10cSrcweir virtual void operator=(const SdrObject&); 194cdf0e10cSrcweir 195cdf0e10cSrcweir virtual SdrObjGeoData *NewGeoData() const; 196cdf0e10cSrcweir virtual void SaveGeoData(SdrObjGeoData& rGeo) const; 197cdf0e10cSrcweir virtual void RestGeoData(const SdrObjGeoData& rGeo); 198cdf0e10cSrcweir 199cdf0e10cSrcweir // Selektion Setzen/Lesen GetSelected() const200cdf0e10cSrcweir bool GetSelected() const { return mbIsSelected; } 201cdf0e10cSrcweir void SetSelected(bool bNew); 202cdf0e10cSrcweir 203cdf0e10cSrcweir // Aufbrechen 204cdf0e10cSrcweir virtual sal_Bool IsBreakObjPossible(); 205cdf0e10cSrcweir virtual SdrAttrObj* GetBreakObj(); 206cdf0e10cSrcweir }; 207cdf0e10cSrcweir 208cdf0e10cSrcweir /************************************************************************* 209cdf0e10cSrcweir |* 210cdf0e10cSrcweir |* Klasse fuer alle zusammengesetzen Objekte (Cube, Lathe, Scene, Extrude) 211cdf0e10cSrcweir |* Diese Klasse erspart ein paar ISA-Abfragen und sie beschleunigt das 212cdf0e10cSrcweir |* Verhalten ungemein, da alle Attribute usw. fuer die untergeordneten 213cdf0e10cSrcweir |* Polygone hierueber gehalten werden. Die Polygone duerfen nur Attribute 214cdf0e10cSrcweir |* halten, wenn sie direkt einer Szene untergeordnet sind. 215cdf0e10cSrcweir |* 216cdf0e10cSrcweir \************************************************************************/ 217cdf0e10cSrcweir 218cdf0e10cSrcweir class SVX_DLLPUBLIC E3dCompoundObject : public E3dObject 219cdf0e10cSrcweir { 220cdf0e10cSrcweir private: 221cdf0e10cSrcweir // to allow sdr::properties::E3dCompoundProperties access to SetGeometryValid() 222cdf0e10cSrcweir friend class sdr::properties::E3dCompoundProperties; 223cdf0e10cSrcweir friend class sdr::properties::E3dExtrudeProperties; 224cdf0e10cSrcweir friend class sdr::properties::E3dLatheProperties; 225cdf0e10cSrcweir friend class sdr::properties::E3dSphereProperties; 226cdf0e10cSrcweir 227cdf0e10cSrcweir protected: 228cdf0e10cSrcweir virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties(); 229cdf0e10cSrcweir 230cdf0e10cSrcweir // Material des Objektes 231cdf0e10cSrcweir Color aMaterialAmbientColor; 232cdf0e10cSrcweir 233cdf0e10cSrcweir // Attribute zur Geometrieerzeugung 234cdf0e10cSrcweir unsigned bCreateNormals : 1; 235cdf0e10cSrcweir unsigned bCreateTexture : 1; 236cdf0e10cSrcweir 237cdf0e10cSrcweir protected: 238cdf0e10cSrcweir void SetDefaultAttributes(E3dDefaultAttributes& rDefault); 239cdf0e10cSrcweir 240cdf0e10cSrcweir // convert given basegfx::B3DPolyPolygon to screen coor 241cdf0e10cSrcweir basegfx::B2DPolyPolygon TransformToScreenCoor(const basegfx::B3DPolyPolygon& rCandidate); 242cdf0e10cSrcweir 243cdf0e10cSrcweir public : 244cdf0e10cSrcweir TYPEINFO(); 245cdf0e10cSrcweir 246cdf0e10cSrcweir E3dCompoundObject(); 247cdf0e10cSrcweir E3dCompoundObject(E3dDefaultAttributes& rDefault); 248cdf0e10cSrcweir virtual ~E3dCompoundObject(); 249cdf0e10cSrcweir 250cdf0e10cSrcweir virtual basegfx::B2DPolyPolygon TakeXorPoly() const; 251cdf0e10cSrcweir virtual sal_uInt32 GetHdlCount() const; 252cdf0e10cSrcweir virtual void AddToHdlList(SdrHdlList& rHdlList) const; 253cdf0e10cSrcweir 254cdf0e10cSrcweir // DoubleSided: sal_True/FALSE GetDoubleSided() const255cdf0e10cSrcweir sal_Bool GetDoubleSided() const 256cdf0e10cSrcweir { return ((const Svx3DDoubleSidedItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_DOUBLE_SIDED)).GetValue(); } 257cdf0e10cSrcweir 258cdf0e10cSrcweir // NormalsKind: 0 == sal_False/sal_False, 1 == sal_True/sal_False, else == sal_True/TRUE GetNormalsKind() const259cdf0e10cSrcweir sal_uInt16 GetNormalsKind() const 260cdf0e10cSrcweir { return ((const Svx3DNormalsKindItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_NORMALS_KIND)).GetValue(); } 261cdf0e10cSrcweir 262cdf0e10cSrcweir // NormalsInvert: sal_True/FALSE GetNormalsInvert() const263cdf0e10cSrcweir sal_Bool GetNormalsInvert() const 264cdf0e10cSrcweir { return ((const Svx3DNormalsInvertItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_NORMALS_INVERT)).GetValue(); } 265cdf0e10cSrcweir 266cdf0e10cSrcweir // TextureProjX: 0 == sal_False/sal_False, 1 == sal_True/sal_False, else == sal_True/TRUE GetTextureProjectionX() const267cdf0e10cSrcweir sal_uInt16 GetTextureProjectionX() const 268cdf0e10cSrcweir { return ((const Svx3DTextureProjectionXItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_TEXTURE_PROJ_X)).GetValue(); } 269cdf0e10cSrcweir 270cdf0e10cSrcweir // TextureProjY: 0 == sal_False/sal_False, 1 == sal_True/sal_False, else == sal_True/TRUE GetTextureProjectionY() const271cdf0e10cSrcweir sal_uInt16 GetTextureProjectionY() const 272cdf0e10cSrcweir { return ((const Svx3DTextureProjectionYItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_TEXTURE_PROJ_Y)).GetValue(); } 273cdf0e10cSrcweir 274cdf0e10cSrcweir // Shadow3D: sal_True/FALSE GetShadow3D() const275cdf0e10cSrcweir sal_Bool GetShadow3D() const 276cdf0e10cSrcweir { return ((const Svx3DShadow3DItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_SHADOW_3D)).GetValue(); } 277cdf0e10cSrcweir 278cdf0e10cSrcweir // MaterialColor: Color GetMaterialColor() const279cdf0e10cSrcweir Color GetMaterialColor() const 280cdf0e10cSrcweir { return ((const Svx3DMaterialColorItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_COLOR)).GetValue(); } 281cdf0e10cSrcweir 282cdf0e10cSrcweir // MaterialEmission: Color GetMaterialEmission() const283cdf0e10cSrcweir Color GetMaterialEmission() const 284cdf0e10cSrcweir { return ((const Svx3DMaterialEmissionItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_EMISSION)).GetValue(); } 285cdf0e10cSrcweir 286cdf0e10cSrcweir // MaterialSpecular: Color GetMaterialSpecular() const287cdf0e10cSrcweir Color GetMaterialSpecular() const 288cdf0e10cSrcweir { return ((const Svx3DMaterialSpecularItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_SPECULAR)).GetValue(); } 289cdf0e10cSrcweir 290cdf0e10cSrcweir // MaterialSpecularIntensity: GetMaterialSpecularIntensity() const291cdf0e10cSrcweir sal_uInt16 GetMaterialSpecularIntensity() const 292cdf0e10cSrcweir { return ((const Svx3DMaterialSpecularIntensityItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY)).GetValue(); } 293cdf0e10cSrcweir 294cdf0e10cSrcweir // TextureFilter: sal_True/FALSE GetTextureFilter() const295cdf0e10cSrcweir sal_Bool GetTextureFilter() const 296cdf0e10cSrcweir { return ((const Svx3DTextureFilterItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_TEXTURE_FILTER)).GetValue(); } 297cdf0e10cSrcweir 298cdf0e10cSrcweir // #i28528# 299cdf0e10cSrcweir // Added extra Item (Bool) for chart2 to be able to show reduced line geometry GetReducedLineGeometry() const300cdf0e10cSrcweir sal_Bool GetReducedLineGeometry() const 301cdf0e10cSrcweir { return ((const Svx3DReducedLineGeometryItem&)GetObjectItemSet().Get(SDRATTR_3DOBJ_REDUCED_LINE_GEOMETRY)).GetValue(); } 302cdf0e10cSrcweir 303cdf0e10cSrcweir virtual sal_uInt16 GetObjIdentifier() const; 304cdf0e10cSrcweir virtual void RecalcSnapRect(); 305cdf0e10cSrcweir 306cdf0e10cSrcweir // Parameter Geometrieerzeugung setzen/lesen GetCreateNormals() const307cdf0e10cSrcweir sal_Bool GetCreateNormals() const { return bCreateNormals; } 308cdf0e10cSrcweir void SetCreateNormals(sal_Bool bNew); 309cdf0e10cSrcweir GetCreateTexture() const310cdf0e10cSrcweir sal_Bool GetCreateTexture() const { return bCreateTexture; } 311cdf0e10cSrcweir void SetCreateTexture(sal_Bool bNew); 312cdf0e10cSrcweir 313cdf0e10cSrcweir // Copy-Operator 314cdf0e10cSrcweir virtual void operator=(const SdrObject&); 315cdf0e10cSrcweir 316cdf0e10cSrcweir // Material des Objektes GetMaterialAmbientColor() const317cdf0e10cSrcweir const Color& GetMaterialAmbientColor() const { return aMaterialAmbientColor; } 318cdf0e10cSrcweir void SetMaterialAmbientColor(const Color& rColor); 319cdf0e10cSrcweir 320cdf0e10cSrcweir // #110988# 321cdf0e10cSrcweir sal_Bool IsAOrdNumRemapCandidate(E3dScene*& prScene) const; 322cdf0e10cSrcweir }; 323cdf0e10cSrcweir 324cdf0e10cSrcweir #endif // _E3D_OBJ3D_HXX 325