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