LCOV - code coverage report
Current view: top level - libreoffice/svx/source/engine3d - extrud3d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 84 1.2 %
Date: 2012-12-27 Functions: 1 17 5.9 %
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             : 
      21             : #include "svx/svdstr.hrc"
      22             : #include "svx/svdglob.hxx"
      23             : #include <svx/svdpage.hxx>
      24             : #include "svx/globl3d.hxx"
      25             : #include <svx/extrud3d.hxx>
      26             : #include <svx/scene3d.hxx>
      27             : 
      28             : #include <svx/svxids.hrc>
      29             : #include <svx/xpoly.hxx>
      30             : #include <svx/svdopath.hxx>
      31             : #include <svx/svdmodel.hxx>
      32             : #include <svx/svx3ditems.hxx>
      33             : #include <svx/sdr/properties/e3dextrudeproperties.hxx>
      34             : #include <svx/sdr/contact/viewcontactofe3dextrude.hxx>
      35             : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      36             : #include <basegfx/polygon/b2dpolygontools.hxx>
      37             : #include <basegfx/polygon/b3dpolygontools.hxx>
      38             : #include <basegfx/polygon/b3dpolypolygontools.hxx>
      39             : 
      40             : //////////////////////////////////////////////////////////////////////////////
      41             : // DrawContact section
      42             : 
      43           0 : sdr::contact::ViewContact* E3dExtrudeObj::CreateObjectSpecificViewContact()
      44             : {
      45           0 :     return new sdr::contact::ViewContactOfE3dExtrude(*this);
      46             : }
      47             : 
      48             : //////////////////////////////////////////////////////////////////////////////
      49             : 
      50           0 : sdr::properties::BaseProperties* E3dExtrudeObj::CreateObjectSpecificProperties()
      51             : {
      52           0 :     return new sdr::properties::E3dExtrudeProperties(*this);
      53             : }
      54             : 
      55             : //////////////////////////////////////////////////////////////////////////////
      56             : 
      57        3601 : TYPEINIT1(E3dExtrudeObj, E3dCompoundObject);
      58             : 
      59             : // Constructor creates a two cover surface PolyPolygon and (point-count 1) side
      60             : // surfaces rectangles from the passed PolyPolygon
      61             : 
      62           0 : E3dExtrudeObj::E3dExtrudeObj(E3dDefaultAttributes& rDefault, const basegfx::B2DPolyPolygon& rPP, double fDepth)
      63             : :   E3dCompoundObject(rDefault),
      64           0 :     maExtrudePolygon(rPP)
      65             : {
      66             :     // since the old class PolyPolygon3D did mirror the given PolyPolygons in Y, do the same here
      67           0 :     basegfx::B2DHomMatrix aMirrorY;
      68           0 :     aMirrorY.scale(1.0, -1.0);
      69           0 :     maExtrudePolygon.transform(aMirrorY);
      70             : 
      71             :     // Set Defaults
      72           0 :     SetDefaultAttributes(rDefault);
      73             : 
      74             :     // set extrude depth
      75           0 :     GetProperties().SetObjectItemDirect(Svx3DDepthItem((sal_uInt32)(fDepth + 0.5)));
      76           0 : }
      77             : 
      78           0 : E3dExtrudeObj::E3dExtrudeObj()
      79           0 : :   E3dCompoundObject()
      80             : {
      81             :     // Set Defaults
      82           0 :     E3dDefaultAttributes aDefault;
      83           0 :     SetDefaultAttributes(aDefault);
      84           0 : }
      85             : 
      86           0 : void E3dExtrudeObj::SetDefaultAttributes(E3dDefaultAttributes& rDefault)
      87             : {
      88           0 :     GetProperties().SetObjectItemDirect(Svx3DSmoothNormalsItem(rDefault.GetDefaultExtrudeSmoothed()));
      89           0 :     GetProperties().SetObjectItemDirect(Svx3DSmoothLidsItem(rDefault.GetDefaultExtrudeSmoothFrontBack()));
      90           0 :     GetProperties().SetObjectItemDirect(Svx3DCharacterModeItem(rDefault.GetDefaultExtrudeCharacterMode()));
      91           0 :     GetProperties().SetObjectItemDirect(Svx3DCloseFrontItem(rDefault.GetDefaultExtrudeCloseFront()));
      92           0 :     GetProperties().SetObjectItemDirect(Svx3DCloseBackItem(rDefault.GetDefaultExtrudeCloseBack()));
      93             : 
      94             :     // For extrudes use StdTexture in X and Y by default
      95           0 :     GetProperties().SetObjectItemDirect(Svx3DTextureProjectionXItem(1));
      96           0 :     GetProperties().SetObjectItemDirect(Svx3DTextureProjectionYItem(1));
      97           0 : }
      98             : 
      99           0 : sal_uInt16 E3dExtrudeObj::GetObjIdentifier() const
     100             : {
     101           0 :     return E3D_EXTRUDEOBJ_ID;
     102             : }
     103             : 
     104           0 : E3dExtrudeObj* E3dExtrudeObj::Clone() const
     105             : {
     106           0 :     return CloneHelper< E3dExtrudeObj >();
     107             : }
     108             : 
     109             : 
     110             : // Set local parameters with geometry re-creating
     111             : 
     112           0 : void E3dExtrudeObj::SetExtrudePolygon(const basegfx::B2DPolyPolygon &rNew)
     113             : {
     114           0 :     if(maExtrudePolygon != rNew)
     115             :     {
     116           0 :         maExtrudePolygon = rNew;
     117           0 :         ActionChanged();
     118             :     }
     119           0 : }
     120             : 
     121             : // Get the name of the object (singular)
     122             : 
     123           0 : void E3dExtrudeObj::TakeObjNameSingul(XubString& rName) const
     124             : {
     125           0 :     rName=ImpGetResStr(STR_ObjNameSingulExtrude3d);
     126             : 
     127           0 :     String aName( GetName() );
     128           0 :     if(aName.Len())
     129             :     {
     130           0 :         rName += sal_Unicode(' ');
     131           0 :         rName += sal_Unicode('\'');
     132           0 :         rName += aName;
     133           0 :         rName += sal_Unicode('\'');
     134           0 :     }
     135           0 : }
     136             : 
     137             : // Get the name of the object (plural)
     138             : 
     139           0 : void E3dExtrudeObj::TakeObjNamePlural(XubString& rName) const
     140             : {
     141           0 :     rName=ImpGetResStr(STR_ObjNamePluralExtrude3d);
     142           0 : }
     143             : 
     144           0 : sal_Bool E3dExtrudeObj::IsBreakObjPossible()
     145             : {
     146           0 :     return sal_True;
     147             : }
     148             : 
     149           0 : SdrAttrObj* E3dExtrudeObj::GetBreakObj()
     150             : {
     151           0 :     basegfx::B3DPolyPolygon aFrontSide;
     152           0 :     basegfx::B3DPolyPolygon aBackSide;
     153             : 
     154           0 :     if(maExtrudePolygon.count())
     155             :     {
     156           0 :         basegfx::B2DPolyPolygon aTemp(maExtrudePolygon);
     157           0 :         aTemp.removeDoublePoints();
     158           0 :         aTemp = basegfx::tools::correctOrientations(aTemp);
     159           0 :         const basegfx::B2VectorOrientation aOrient = basegfx::tools::getOrientation(aTemp.getB2DPolygon(0L));
     160             : 
     161           0 :         if(basegfx::ORIENTATION_POSITIVE == aOrient)
     162             :         {
     163           0 :             aTemp.flip();
     164             :         }
     165             : 
     166           0 :         aFrontSide = basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(aTemp);
     167             :     }
     168             : 
     169           0 :     if(aFrontSide.count())
     170             :     {
     171           0 :         aBackSide = aFrontSide;
     172             : 
     173           0 :         if(GetExtrudeDepth())
     174             :         {
     175           0 :             basegfx::B3DHomMatrix aTransform;
     176             : 
     177           0 :             if(100 != GetPercentBackScale())
     178             :             {
     179             :                 // scale polygon from center
     180           0 :                 const double fScaleFactor(GetPercentBackScale() / 100.0);
     181           0 :                 const basegfx::B3DRange aPolyPolyRange(basegfx::tools::getRange(aBackSide));
     182           0 :                 const basegfx::B3DPoint aCenter(aPolyPolyRange.getCenter());
     183             : 
     184           0 :                 aTransform.translate(-aCenter.getX(), -aCenter.getY(), -aCenter.getZ());
     185           0 :                 aTransform.scale(fScaleFactor, fScaleFactor, fScaleFactor);
     186           0 :                 aTransform.translate(aCenter.getX(), aCenter.getY(), aCenter.getZ());
     187             :             }
     188             : 
     189             :             // translate by extrude depth
     190           0 :             aTransform.translate(0.0, 0.0, (double)GetExtrudeDepth());
     191             : 
     192           0 :             aBackSide.transform(aTransform);
     193             :         }
     194             :     }
     195             : 
     196           0 :     if(aBackSide.count())
     197             :     {
     198             :     // create PathObj
     199           0 :         basegfx::B2DPolyPolygon aPoly = TransformToScreenCoor(aBackSide);
     200           0 :         SdrPathObj* pPathObj = new SdrPathObj(OBJ_PLIN, aPoly);
     201             : 
     202           0 :         if(pPathObj)
     203             :         {
     204           0 :             SfxItemSet aSet(GetObjectItemSet());
     205           0 :             aSet.Put(XLineStyleItem(XLINE_SOLID));
     206           0 :             pPathObj->SetMergedItemSet(aSet);
     207             :         }
     208             : 
     209           0 :         return pPathObj;
     210             :     }
     211             : 
     212           0 :     return 0;
     213             : }
     214             : 
     215             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10