LCOV - code coverage report
Current view: top level - include/svx - obj3d.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 5 20.0 %
Date: 2015-06-13 12:38:46 Functions: 1 6 16.7 %
Legend: Lines: hit not hit

          Line data    Source code
       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>
      25             : #include <svx/def3d.hxx>
      26             : #include <svx/svdpage.hxx>
      27             : #include <svx/deflt3d.hxx>
      28             : #include <vcl/bitmap.hxx>
      29             : #include <svx/svx3ditems.hxx>
      30             : #include <svx/xflclit.hxx>
      31             : #include <svl/itemset.hxx>
      32             : #include <basegfx/range/b3drange.hxx>
      33             : #include <basegfx/polygon/b3dpolypolygon.hxx>
      34             : #include <basegfx/point/b2dpoint.hxx>
      35             : #include <basegfx/polygon/b2dpolygon.hxx>
      36             : #include <basegfx/vector/b2enums.hxx>
      37             : #include <svx/svxdllapi.h>
      38             : 
      39             : 
      40             : // Forward declaration
      41             : 
      42             : 
      43             : class SfxPoolItem;
      44             : class Viewport3D;
      45             : class E3dScene;
      46             : class E3dPolyScene;
      47             : 
      48             : namespace basegfx { class B3DPolyPolygon; }
      49             : namespace sdr { namespace properties {
      50             :     class BaseProperties;
      51             :     class E3dProperties;
      52             :     class E3dCompoundProperties;
      53             :     class E3dExtrudeProperties;
      54             :     class E3dLatheProperties;
      55             :     class E3dSphereProperties;
      56             : }}
      57             : 
      58             : /*************************************************************************
      59             : |*
      60             : |* GeoData relevant for undo actions
      61             : |*
      62             : \************************************************************************/
      63             : 
      64           0 : class E3DObjGeoData : public SdrObjGeoData
      65             : {
      66             : public:
      67             :     basegfx::B3DRange           maLocalBoundVol;    // surrounding volume of the object
      68             :     basegfx::B3DHomMatrix       maTransformation;   // lokal transformations
      69             : 
      70           0 :     E3DObjGeoData() {}
      71             : };
      72             : 
      73             : /*************************************************************************
      74             : |*
      75             : |* List for 3D objects
      76             : |*
      77             : \************************************************************************/
      78             : 
      79             : class E3dObjList : public SdrObjList
      80             : {
      81             :     E3dObjList &operator=(const E3dObjList& rSrcList) SAL_DELETED_FUNCTION;
      82             : 
      83             : public:
      84             :     TYPEINFO_OVERRIDE();
      85             :     E3dObjList(SdrModel* pNewModel = 0, SdrPage* pNewPage = 0, E3dObjList* pNewUpList = 0);
      86             :     SVX_DLLPUBLIC virtual ~E3dObjList();
      87             : 
      88             :     virtual E3dObjList* Clone() const SAL_OVERRIDE;
      89             : 
      90             :     virtual void NbcInsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE, const SdrInsertReason* pReason=NULL) SAL_OVERRIDE;
      91             :     virtual void InsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE, const SdrInsertReason* pReason=NULL) SAL_OVERRIDE;
      92             :     virtual SdrObject* NbcRemoveObject(size_t nObjNum) SAL_OVERRIDE;
      93             :     virtual SdrObject* RemoveObject(size_t nObjNum) SAL_OVERRIDE;
      94             : 
      95             : protected:
      96             :     SVX_DLLPUBLIC E3dObjList(const E3dObjList& rSrcList);
      97             : };
      98             : 
      99             : /*************************************************************************
     100             : |*
     101             : |* Base class for 3D objects
     102             : |*
     103             : \************************************************************************/
     104             : 
     105             : class SVX_DLLPUBLIC E3dObject : public SdrAttrObj
     106             : {
     107             : private:
     108             :     // to allow sdr::properties::E3dProperties access to StructureChanged()
     109             :     friend class sdr::properties::E3dProperties;
     110             : 
     111             :     // Allow everything for E3dObjList and E3dDragMethod
     112             :     friend class E3dObjList;
     113             :     friend class E3dDragMethod;
     114             : 
     115             :  protected:
     116             :     virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() SAL_OVERRIDE;
     117             : 
     118             :     E3dObjList                  maSubList;          // child objects
     119             : 
     120             :     basegfx::B3DRange           maLocalBoundVol;    // surrounding volume of the object (from the geometry generation)
     121             :     basegfx::B3DHomMatrix       maTransformation;   // local transformation
     122             :     basegfx::B3DHomMatrix       maFullTransform;    // global transformation (including. parents)
     123             : 
     124             :     // Flags
     125             :     bool            mbTfHasChanged          : 1;
     126             :     bool            mbIsSelected            : 1;
     127             : 
     128             :  public:
     129             :     void SetBoundVolInvalid();
     130             : 
     131             :  protected:
     132             :     void SetTransformChanged();
     133             :     virtual void NewObjectInserted(const E3dObject* p3DObj);
     134             :     virtual void StructureChanged();
     135             :     basegfx::B3DRange RecalcBoundVolume() const;
     136             : 
     137             : protected:
     138             :     // E3dObject is only a helper class (for E3DScene and E3DCompoundObject)
     139             :     // and no instances should be created from anyone, so i move the constructors
     140             :     // to protected area
     141             :     E3dObject();
     142             :     E3dObject(bool bIsFromChart);
     143             : 
     144             : public:
     145             :     TYPEINFO_OVERRIDE();
     146             :     virtual void RecalcSnapRect() SAL_OVERRIDE;
     147             :     virtual void SetRectsDirty(bool bNotMyself = false) SAL_OVERRIDE;
     148             : 
     149             :     virtual ~E3dObject();
     150             : 
     151             :     virtual sal_uInt32  GetObjInventor() const SAL_OVERRIDE;
     152             :     virtual sal_uInt16  GetObjIdentifier() const SAL_OVERRIDE;
     153             : 
     154             :     virtual void    TakeObjInfo(SdrObjTransformInfoRec& rInfo) const SAL_OVERRIDE;
     155             : 
     156             :     virtual void        NbcSetLayer(SdrLayerID nLayer) SAL_OVERRIDE;
     157             : 
     158             :     virtual void        SetObjList(SdrObjList* pNewObjList) SAL_OVERRIDE;
     159             :     virtual void        SetPage(SdrPage* pNewPage) SAL_OVERRIDE;
     160             :     virtual void        SetModel(SdrModel* pNewModel) SAL_OVERRIDE;
     161             :     virtual void        NbcMove(const Size& rSize) SAL_OVERRIDE;
     162             :     virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE;
     163             :     virtual SdrObjList* GetSubList() const SAL_OVERRIDE;
     164             : 
     165             :     // Insert 3D object into the group; transfer to other owner!
     166             :     void Insert3DObj(E3dObject* p3DObj);
     167             :     void Remove3DObj(E3dObject* p3DObj);
     168             : 
     169             :     E3dObject* GetParentObj() const;
     170             :     virtual E3dScene* GetScene() const;
     171             : 
     172             :     const basegfx::B3DRange& GetBoundVolume() const;
     173             :     void InvalidateBoundVolume();
     174             : 
     175             :     // calculate complete transformation including all parents
     176             :     const basegfx::B3DHomMatrix& GetFullTransform() const;
     177             : 
     178             :     // get and (re)set transformation matrix
     179       27171 :     const basegfx::B3DHomMatrix& GetTransform() const { return maTransformation;}
     180             :     virtual void NbcSetTransform(const basegfx::B3DHomMatrix& rMatrix);
     181             :     virtual void SetTransform(const basegfx::B3DHomMatrix& rMatrix);
     182             : 
     183             :     // 2D rotations, are implemented as a rotation around the Z axis
     184             :     // which is vertical to the screen, plus a shift of the scene.
     185             :     // This means that also the scene (E3dScene) must define this
     186             :     // routine as virtual in its class.
     187             :     virtual void NbcRotate(const Point& rRef, long nAngle, double sn, double cs) SAL_OVERRIDE;
     188             : 
     189             :     // get wireframe polygon for local object. No transform is applied.
     190             :     basegfx::B3DPolyPolygon CreateWireframe() const;
     191             : 
     192             :     // TakeObjName...() is for the display in the UI, for example "3 frames selected".
     193             :     virtual OUString TakeObjNameSingul() const SAL_OVERRIDE;
     194             :     virtual OUString TakeObjNamePlural() const SAL_OVERRIDE;
     195             :     virtual E3dObject* Clone() const SAL_OVERRIDE;
     196             :     E3dObject& operator=( const E3dObject& rObj );
     197             : 
     198             :     virtual SdrObjGeoData *NewGeoData() const SAL_OVERRIDE;
     199             :     virtual void          SaveGeoData(SdrObjGeoData& rGeo) const SAL_OVERRIDE;
     200             :     virtual void          RestGeoData(const SdrObjGeoData& rGeo) SAL_OVERRIDE;
     201             : 
     202             :     // get/set the selection
     203           0 :     bool GetSelected() const { return mbIsSelected; }
     204             :     void SetSelected(bool bNew);
     205             : 
     206             :     // break up
     207             :     virtual bool IsBreakObjPossible();
     208             :     virtual SdrAttrObj* GetBreakObj();
     209             : };
     210             : 
     211             : /*************************************************************************
     212             : |*
     213             : |* Class for all compound objects (Cube, Lathe, Scene, Extrude)
     214             : |* This class saves some ISA queries and accelerates the behaviour
     215             : |* significantly, because all the attributes etc. are kept through this.
     216             : |* The polygons may only keep attributes if they are directly
     217             : |* subordinated to the scene.
     218             : |*
     219             : \************************************************************************/
     220             : 
     221           0 : class SVX_DLLPUBLIC E3dCompoundObject : public E3dObject
     222             : {
     223             : private:
     224             :     // to allow sdr::properties::E3dCompoundProperties access to SetGeometryValid()
     225             :     friend class sdr::properties::E3dCompoundProperties;
     226             :     friend class sdr::properties::E3dExtrudeProperties;
     227             :     friend class sdr::properties::E3dLatheProperties;
     228             :     friend class sdr::properties::E3dSphereProperties;
     229             : 
     230             : protected:
     231             :     virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() SAL_OVERRIDE;
     232             : 
     233             :     // material of the object
     234             :     Color                   aMaterialAmbientColor;
     235             : 
     236             :     // attributes for geometry creation
     237             :     bool                    bCreateNormals              : 1;
     238             :     bool                    bCreateTexture              : 1;
     239             : 
     240             : protected:
     241             :     void SetDefaultAttributes(E3dDefaultAttributes& rDefault);
     242             : 
     243             :     // convert given basegfx::B3DPolyPolygon to screen coor
     244             :     basegfx::B2DPolyPolygon TransformToScreenCoor(const basegfx::B3DPolyPolygon& rCandidate);
     245             : 
     246             : public :
     247             :     TYPEINFO_OVERRIDE();
     248             : 
     249             :     E3dCompoundObject();
     250             :     E3dCompoundObject(E3dDefaultAttributes& rDefault);
     251             :     virtual ~E3dCompoundObject();
     252             : 
     253             :     virtual basegfx::B2DPolyPolygon TakeXorPoly() const SAL_OVERRIDE;
     254             :     virtual sal_uInt32 GetHdlCount() const SAL_OVERRIDE;
     255             :     virtual void    AddToHdlList(SdrHdlList& rHdlList) const SAL_OVERRIDE;
     256             : 
     257             :     // DoubleSided: sal_True/FALSE
     258             :     bool GetDoubleSided() const
     259             :         { return static_cast<const SfxBoolItem&>(GetObjectItemSet().Get(SDRATTR_3DOBJ_DOUBLE_SIDED)).GetValue(); }
     260             : 
     261             :     // NormalsKind: 0 == sal_False/sal_False, 1 == sal_True/sal_False, else == sal_True/TRUE
     262             :     sal_uInt16 GetNormalsKind() const
     263             :         { return static_cast<const Svx3DNormalsKindItem&>(GetObjectItemSet().Get(SDRATTR_3DOBJ_NORMALS_KIND)).GetValue(); }
     264             : 
     265             :     // NormalsInvert: sal_True/FALSE
     266             :     bool GetNormalsInvert() const
     267             :         { return static_cast<const SfxBoolItem&>(GetObjectItemSet().Get(SDRATTR_3DOBJ_NORMALS_INVERT)).GetValue(); }
     268             : 
     269             :     // TextureProjX: 0 == sal_False/sal_False, 1 == sal_True/sal_False, else == sal_True/TRUE
     270             :     sal_uInt16 GetTextureProjectionX() const
     271             :         { return static_cast<const Svx3DTextureProjectionXItem&>(GetObjectItemSet().Get(SDRATTR_3DOBJ_TEXTURE_PROJ_X)).GetValue(); }
     272             : 
     273             :     // TextureProjY: 0 == sal_False/sal_False, 1 == sal_True/sal_False, else == sal_True/TRUE
     274             :     sal_uInt16 GetTextureProjectionY() const
     275             :         { return static_cast<const Svx3DTextureProjectionYItem&>(GetObjectItemSet().Get(SDRATTR_3DOBJ_TEXTURE_PROJ_Y)).GetValue(); }
     276             : 
     277             :     // Shadow3D: sal_True/FALSE
     278             :     bool GetShadow3D() const
     279             :         { return static_cast<const SfxBoolItem&>(GetObjectItemSet().Get(SDRATTR_3DOBJ_SHADOW_3D)).GetValue(); }
     280             : 
     281             :     // MaterialColor: Color
     282             :     Color GetMaterialColor() const
     283             :         { return static_cast<const SvxColorItem&>(GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_COLOR)).GetValue(); }
     284             : 
     285             :     // MaterialEmission: Color
     286             :     Color GetMaterialEmission() const
     287             :         { return static_cast<const SvxColorItem&>(GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_EMISSION)).GetValue(); }
     288             : 
     289             :     // MaterialSpecular: Color
     290             :     Color GetMaterialSpecular() const
     291             :         { return static_cast<const SvxColorItem&>(GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_SPECULAR)).GetValue(); }
     292             : 
     293             :     // MaterialSpecularIntensity:
     294             :     sal_uInt16 GetMaterialSpecularIntensity() const
     295             :         { return static_cast<const SfxUInt16Item&>(GetObjectItemSet().Get(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY)).GetValue(); }
     296             : 
     297             :     // TextureFilter: sal_True/FALSE
     298             :     bool GetTextureFilter() const
     299             :         { return static_cast<const SfxBoolItem&>(GetObjectItemSet().Get(SDRATTR_3DOBJ_TEXTURE_FILTER)).GetValue(); }
     300             : 
     301             :     // #i28528#
     302             :     // Added extra Item (Bool) for chart2 to be able to show reduced line geometry
     303             :     bool GetReducedLineGeometry() const
     304             :         { return static_cast<const Svx3DReducedLineGeometryItem&>(GetObjectItemSet().Get(SDRATTR_3DOBJ_REDUCED_LINE_GEOMETRY)).GetValue(); }
     305             : 
     306             :     virtual sal_uInt16 GetObjIdentifier() const SAL_OVERRIDE;
     307             :     virtual void RecalcSnapRect() SAL_OVERRIDE;
     308             : 
     309             :     // set/get parameters for geometry creation
     310             :     bool GetCreateNormals() const { return bCreateNormals; }
     311             : 
     312             :     bool GetCreateTexture() const { return bCreateTexture; }
     313             : 
     314             :     virtual E3dCompoundObject* Clone() const SAL_OVERRIDE;
     315             : 
     316             :     // material of the object
     317             :     const Color& GetMaterialAmbientColor() const { return aMaterialAmbientColor; }
     318             : 
     319             :     bool IsAOrdNumRemapCandidate(E3dScene*& prScene) const;
     320             : };
     321             : 
     322             : #endif // INCLUDED_SVX_OBJ3D_HXX
     323             : 
     324             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11